/* ============================================================================
   SORT  (#sortRoot, body.sort-mode). Loaded with the engine (core/app.js ENGINES
   row), so nothing here reaches another chart.
   One memorable thing: the index card. The top card of a ruled paper stack sits
   over the bins, its word large in italic; the cards still to sort lie under it,
   fanned, and the stack thins as you play. A right bin sends the word flying
   into that bin as a small chip; a wrong bin turns the card over to show the
   verse with the word marked. The card is paper in both modes (dark ink on
   cream). Each bin has a tone (rust, leaf, gold, sky, plum) with a dark and a
   light value. Phone: the card shorter but still the largest thing, the bins
   side by side under it (2x2 for four), so both show on the first screen.
   Motion: the deal, the flight, the shake and the turn; none in Lite mode or
   under reduced motion.
   ============================================================================ */

@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces.woff2") format("woff2");
             font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4.woff2") format("woff2");
             font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4-italic.woff2") format("woff2");
             font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
             font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
             font-weight: 600; font-display: swap; }

body.sort-mode #sortRoot {
  /* Bin tones, dark values (every palette): `ink` reads as text on the page and
     on the bin's wash; `fill` is the band, the badge and the chip's edge. */
  --so-rust: #ff9f80;  --so-rust-fill: #e0693f;
  --so-leaf: #82dca0;  --so-leaf-fill: #2fa35c;
  --so-gold: #f2c766;  --so-gold-fill: #c99a2e;
  --so-sky: #96c8ff;   --so-sky-fill: #3d8fe0;
  --so-plum: #ddb0f2;  --so-plum-fill: #a660c9;
  /* The card is paper in both modes. */
  --so-paper: #f1e9d6;
  --so-paper-2: #e6dcc3;
  --so-paper-ink: #2a2418;
  --so-paper-dim: #4a4234;
  --so-paper-rule: rgba(60, 110, 170, .11);
  --so-paper-edge: rgba(80, 60, 30, .28);
  --so-mark: rgba(214, 160, 40, .42);
  --so-surface: color-mix(in srgb, var(--bg-1) 84%, var(--bg-haze));
  --so-rule: color-mix(in srgb, var(--line) 80%, transparent);
  --so-display: "Fraunces", var(--font-display, Georgia), serif;
  --so-read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --so-ui: "IBM Plex Sans", var(--font, system-ui), sans-serif;
  display: block; position: relative; min-height: 100vh; min-height: 100dvh;
  background: var(--bg-1); color: var(--text);
  font-family: var(--so-read); font-size: 18px; line-height: 1.6;
  padding: 0 24px 72px; overflow-x: clip;
}
:root[data-mode="light"] body.sort-mode #sortRoot {
  --so-rust: #a3391a;  --so-rust-fill: #c4562c;
  --so-leaf: #1b6a37;  --so-leaf-fill: #2e8a4d;
  --so-gold: #775300;  --so-gold-fill: #b9870f;
  --so-sky: #1d5a99;   --so-sky-fill: #2f77c2;
  --so-plum: #71338c;  --so-plum-fill: #8c4aa9;
  --so-paper: #fffcf3;
  --so-paper-2: #f3ead4;
  --so-paper-edge: rgba(80, 60, 30, .22);
  --so-surface: color-mix(in srgb, var(--bg-1) 55%, #fff);
}

#sortMain { max-width: 1000px; margin: 0 auto; padding-top: 76px; }
#sortBack { position: absolute; }
#sortCredit { margin-top: 56px; }
#sortRoot :focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
#sortRoot [tabindex="-1"]:focus { outline: none; }
#sortRoot a:not(.lib-link) { color: var(--ink); text-underline-offset: 3px; }
#sortRoot button { font: inherit; color: inherit; }
#sortRoot [hidden] { display: none !important; }

/* Each bin (and the card's back) carries its tone as --t / --t-fill. */
#sortRoot [data-tone="rust"] { --t: var(--so-rust); --t-fill: var(--so-rust-fill); }
#sortRoot [data-tone="leaf"] { --t: var(--so-leaf); --t-fill: var(--so-leaf-fill); }
#sortRoot [data-tone="gold"] { --t: var(--so-gold); --t-fill: var(--so-gold-fill); }
#sortRoot [data-tone="sky"]  { --t: var(--so-sky);  --t-fill: var(--so-sky-fill); }
#sortRoot [data-tone="plum"] { --t: var(--so-plum); --t-fill: var(--so-plum-fill); }

/* ---- Title and rounds ------------------------------------------------------ */
#sortRoot .so-eyebrow, #sortRoot .so-res-eyebrow, #sortRoot .so-pick-label, #sortRoot .so-back-head {
  font: 600 12px/1.25 var(--so-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink);
}
#sortRoot .so-eyebrow { margin: 0; }
#sortRoot .so-title h1 { margin: 8px 0 8px; font: 600 clamp(34px, 6vw, 54px)/1.06 var(--so-display); color: var(--ink); text-wrap: balance; }
#sortRoot .so-sub { margin: 0; font-size: 20px; color: var(--text-dim); text-wrap: pretty; }

#sortRoot .so-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 0; }
#sortRoot .so-tab {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 6px;
  border-radius: 999px; border: 1px solid var(--so-rule); background: var(--so-surface); cursor: pointer;
  font: 600 15px/1.2 var(--so-ui) !important; color: var(--text-dim) !important;
}
#sortRoot .so-tab-n {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--so-rule); font-size: 14px;
}
#sortRoot .so-tab[aria-pressed="true"] { border-color: var(--accent); color: var(--ink) !important; }
#sortRoot .so-tab[aria-pressed="true"] .so-tab-n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#sortRoot .so-tab:not([aria-pressed="true"]):hover { color: var(--text) !important; }
#sortRoot .so-tab-score:empty { display: none; }
#sortRoot .so-tab-score { font-weight: 400; color: var(--text-dim); }
#sortRoot .so-tab-score::before { content: "✓ "; color: var(--accent-ink); }

/* ---- Status ------------------------------------------------------------------ */
#sortRoot .so-round { margin-top: 22px; }
#sortRoot .so-lead { margin: 0 0 12px; font-size: 19px; text-wrap: pretty; }
#sortRoot .so-status { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; }
#sortRoot .so-status-text { display: flex; gap: 14px; margin: 0; font: 600 14px/1.2 var(--so-ui); color: var(--text-dim); white-space: nowrap; }
#sortRoot .so-s-left { color: var(--text); }
#sortRoot .so-s-missed.is-some { color: var(--so-rust); }
#sortRoot .so-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--soft-fill-2); overflow: hidden; }
#sortRoot .so-bar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .35s ease; }

/* ---- The stack ---------------------------------------------------------------- */
#sortRoot .so-stage { display: grid; justify-items: center; }
#sortRoot .so-deck { position: relative; width: min(100%, 460px); }
/* The cards still under the top one: fanned paper, fewer as the stack thins. */
#sortRoot .so-deck::before, #sortRoot .so-deck::after {
  content: ""; position: absolute; inset: 0; border-radius: 16px; background: var(--so-paper-2);
  box-shadow: inset 0 0 0 1px var(--so-paper-edge), 0 6px 16px rgba(0, 0, 0, .16);
}
#sortRoot .so-deck::before { transform: rotate(-3.2deg) translate(-6px, 6px); }
#sortRoot .so-deck::after { transform: rotate(2.4deg) translate(7px, 4px); }
#sortRoot .so-deck[data-left="1"]::before, #sortRoot .so-deck[data-left="1"]::after, #sortRoot .so-deck[data-left="2"]::after { display: none; }

#sortRoot .so-card {
  position: relative; z-index: 1; display: grid; min-height: 240px; border-radius: 16px;
  color: var(--so-paper-ink); cursor: grab; user-select: none; -webkit-user-select: none;
  perspective: 1200px;
}
#sortRoot .so-card.is-dragging { cursor: grabbing; z-index: 30; pointer-events: none; transition: none; }
#sortRoot .so-card:not(.is-dragging) { transition: transform .2s ease; }
#sortRoot .so-front, #sortRoot .so-back {
  grid-area: 1 / 1; min-width: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform .5s cubic-bezier(.3, .7, .2, 1);
}
#sortRoot .so-front {
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  padding: 34px 26px 22px;
  background:
    linear-gradient(var(--so-paper), var(--so-paper)) top / 100% 30px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 29px, var(--so-paper-rule) 29px 30px) 0 30px / 100% 100%,
    var(--so-paper);
  box-shadow: inset 0 0 0 1px var(--so-paper-edge), inset 0 30px 0 -28px rgba(200, 70, 60, .45), 0 10px 26px rgba(0, 0, 0, .22);
}
#sortRoot .so-word {
  margin: 0; font: italic 500 clamp(38px, 7vw, 56px)/1.05 var(--so-display); letter-spacing: -.01em;
  overflow-wrap: anywhere; text-wrap: balance;
}
#sortRoot .so-word.is-long { font-size: clamp(32px, 5.6vw, 46px); }
#sortRoot .so-gloss { margin: 14px 0 0; max-width: 32ch; font: 400 16px/1.45 var(--so-ui); color: var(--so-paper-dim); text-wrap: pretty; }
#sortRoot .so-hint { margin: 16px 0 0; font: 400 13px/1.3 var(--so-ui); color: var(--so-paper-dim); }
#sortRoot .so-hint-touch { display: none; }
@media (pointer: coarse) { #sortRoot .so-hint-touch { display: inline; } #sortRoot .so-hint-mouse { display: none; } }

/* The back: why the card goes elsewhere. */
#sortRoot .so-back {
  display: flex; flex-direction: column; gap: 10px; padding: 20px 22px 18px; overflow: auto;
  background: var(--so-paper); transform: rotateY(180deg);
  box-shadow: inset 0 0 0 1px var(--so-paper-edge), inset 0 5px 0 0 var(--t-fill, #999), 0 10px 26px rgba(0, 0, 0, .22);
}
#sortRoot .so-card.is-flipped .so-front { transform: rotateY(-180deg); }
#sortRoot .so-card.is-flipped .so-back { transform: rotateY(0deg); }
#sortRoot .so-back-head { margin: 0; color: #8f2d14; }
#sortRoot .so-back-line { margin: 0; font: 600 19px/1.3 var(--so-ui); }
#sortRoot .so-back-quotes { display: grid; gap: 8px; }
#sortRoot .so-back .so-passage { border-left-color: var(--t-fill, #999); }
#sortRoot .so-back .so-passage cite { color: var(--so-paper-dim); }
#sortRoot .so-back .so-verse { font-size: 16px; }
#sortRoot .so-back-why { margin: 0; font: 400 15px/1.4 var(--so-ui); }
#sortRoot .so-back .so-continue { align-self: flex-start; margin-top: auto; }

#sortRoot .so-card.is-dealt .so-front { animation: so-deal .32s cubic-bezier(.3, .7, .2, 1); }
@keyframes so-deal { from { transform: translateY(-10px) rotate(-1.5deg); opacity: .4; } }
#sortRoot .so-card.is-shake { animation: so-shake .36s ease; }
@keyframes so-shake { 20% { translate: -8px 0; } 45% { translate: 7px 0; } 70% { translate: -4px 0; } }

/* ---- The bins ------------------------------------------------------------------- */
#sortRoot .so-bins { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 14px; margin-top: 30px; }
#sortRoot .so-bins[data-n="3"] { --cols: 3; }
#sortRoot .so-bins[data-n="4"] { --cols: 4; }
#sortRoot .so-bin {
  min-width: 0; border-radius: 16px; cursor: pointer;
  background: color-mix(in srgb, var(--t-fill) 9%, var(--so-surface));
  border: 1px solid color-mix(in srgb, var(--t-fill) 40%, transparent);
  box-shadow: inset 0 4px 0 0 var(--t-fill);
  transition: background .15s ease, transform .15s ease;
}
#sortRoot .so-bin.is-over, #sortRoot .so-bin:has(.so-bin-drop:hover) { background: color-mix(in srgb, var(--t-fill) 20%, var(--so-surface)); }
#sortRoot .so-bin.is-over { transform: translateY(-2px); }
#sortRoot .so-bin-drop {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; width: 100%;
  min-height: 76px; padding: 16px 16px 10px; border: 0; border-radius: 16px 16px 0 0; background: transparent;
  text-align: left; cursor: pointer;
}
#sortRoot .so-bin-key {
  /* The key to press, a small tab sitting on the bin's top band. */
  position: absolute; top: -11px; right: 18px; display: inline-grid; place-items: center; min-width: 22px; height: 22px;
  padding: 0 5px; border-radius: 6px; border: 1px solid var(--t-fill); background: var(--bg-1);
  font: 600 12px/1 var(--so-ui); color: var(--t);
}
@media (pointer: coarse) { #sortRoot .so-bin-key { display: none; } }
#sortRoot .so-bin { position: relative; }
/* Quick taps are moves, not a double-tap zoom. */
#sortRoot .so-bin, #sortRoot .so-btn, #sortRoot .so-pick-card, #sortRoot .so-tab { touch-action: manipulation; }
#sortRoot .so-bin-label { grid-column: 1; font: 600 21px/1.15 var(--so-display); color: var(--t); }
#sortRoot .so-bin-sub { grid-column: 1; font: 400 13px/1.3 var(--so-ui); color: var(--text-dim); }
#sortRoot .so-bin-count {
  grid-column: 2; grid-row: 1 / span 2; align-self: end; min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-grid; place-items: center; border-radius: 999px; background: var(--t-fill);
  font: 600 15px/1 var(--so-ui); color: #fff;
}
:root[data-mode="dark"] #sortRoot .so-bin-count { color: #10140f; }
/* Light: the badge takes the deeper ink, so white reads on every tone. */
:root[data-mode="light"] #sortRoot .so-bin-count { background: var(--t); }
/* While the card shows why, the bins are switched off: their headings dim. */
#sortRoot .so-round.is-holding .so-bin { cursor: default; }
#sortRoot .so-round.is-holding .so-bin-drop { opacity: .5; cursor: default; }

#sortRoot .so-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 4px 14px 16px; min-height: 18px; }
#sortRoot .so-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px;
  background: var(--so-paper); color: var(--so-paper-ink); box-shadow: inset 0 0 0 1px var(--so-paper-edge), inset 3px 0 0 0 var(--t-fill);
  font: italic 500 16px/1.3 var(--so-display);
}
#sortRoot .so-chip.is-missed { box-shadow: inset 0 0 0 1px var(--so-paper-edge), inset 3px 0 0 0 var(--t-fill), inset 0 -2px 0 0 #c4562c; }
#sortRoot .so-chip.is-new { animation: so-pop .4s ease; }
@keyframes so-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } }
#sortRoot .so-chip-tag:empty, #sortRoot .so-chip-more { display: none; }
#sortRoot .so-chip-tag { font: normal 600 12px/1 var(--so-ui); letter-spacing: .06em; text-transform: uppercase; color: #8f2d14; }
#sortRoot .so-chip.is-shown .so-chip-tag { color: var(--so-paper-dim); }

#sortRoot .so-ghost {
  position: fixed; z-index: 40; padding: 3px 10px; border-radius: 8px; pointer-events: none; transform-origin: 0 0;
  background: var(--so-paper); color: var(--so-paper-ink); box-shadow: inset 3px 0 0 0 var(--t-fill), 0 8px 18px rgba(0, 0, 0, .25);
  font: italic 500 40px/1.05 var(--so-display);
}

/* ---- Tools and the pick row -------------------------------------------------------- */
#sortRoot .so-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
#sortRoot .so-round.is-done .so-tools, #sortRoot .so-round.is-done .so-pick { display: none; }
#sortRoot .so-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid var(--so-rule); background: transparent; cursor: pointer;
  font: 600 15px/1.1 var(--so-ui) !important; color: var(--text) !important; white-space: nowrap;
}
#sortRoot .so-btn:hover { border-color: var(--accent); }
#sortRoot .so-btn--solid { background: var(--accent); border-color: var(--accent); color: var(--on-accent) !important; }
#sortRoot .so-back .so-btn--solid { background: #2a2418; border-color: #2a2418; color: #fffcf3 !important; }

#sortRoot .so-pick { margin-top: 26px; }
#sortRoot .so-pick-label { margin: 0 0 8px; color: var(--text-dim); }
#sortRoot .so-pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
#sortRoot .so-pick-card {
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--so-rule); background: var(--so-surface);
  font: italic 500 16px/1 var(--so-display) !important; cursor: pointer;
}
#sortRoot .so-pick-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#sortRoot .so-pick-card:hover { border-color: var(--accent); }

/* ---- Done: the score, and the answers in the bins ------------------------------------ */
#sortRoot .so-result {
  width: min(100%, 520px); padding: 26px 26px 24px; border-radius: 16px; text-align: center;
  background: var(--so-surface); border: 1px solid var(--so-rule);
}
#sortRoot .so-result.is-in { animation: so-deal .4s cubic-bezier(.3, .7, .2, 1); }
#sortRoot .so-res-eyebrow { margin: 0; }
#sortRoot .so-res-num { margin: 6px 0 0; font: 400 30px/1 var(--so-display); color: var(--text-dim); }
#sortRoot .so-res-num strong { font: 600 64px/1 var(--so-display); color: var(--ink); }
#sortRoot .so-res-line { margin: 8px 0 0; font: 600 16px/1.4 var(--so-ui); color: var(--text); }
#sortRoot .so-res-missed { margin: 6px 0 0; font: 400 15px/1.4 var(--so-ui); color: var(--text-dim); }
#sortRoot .so-res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

#sortRoot .so-round.is-done .so-bin { cursor: default; }
#sortRoot .so-round.is-done .so-bin-drop { cursor: default; }
#sortRoot .so-round.is-done .so-bin-key { display: none; }
#sortRoot .so-round.is-done .so-chips { display: grid; gap: 8px; padding: 4px 14px 18px; }
#sortRoot .so-round.is-done .so-chip {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px; padding: 10px 14px 10px 16px;
  border-radius: 12px; font-size: 21px;
}
#sortRoot .so-round.is-done .so-chip-more { display: block; grid-column: 1 / -1; font: normal 400 16px/1.5 var(--so-read); }
/* The bin's passage, once, with its cards' words marked. */
#sortRoot .so-bin-text { display: none; padding: 0 16px 14px; }
#sortRoot .so-round.is-done .so-bin-text { display: grid; gap: 10px; }
#sortRoot .so-bin-text .so-passage { border-left-color: var(--t-fill); }
#sortRoot .so-bin-text .so-passage cite { color: var(--text-dim); }
#sortRoot .so-bin-text .so-verse { font-size: 17px; line-height: 1.55; }
#sortRoot .so-bin-text mark {
  background: color-mix(in srgb, var(--t-fill) 30%, transparent); color: var(--ink);
  padding: 0 .1em; border-radius: 3px; font-style: normal;
}
#sortRoot .so-chip-ref { margin: 2px 0 0; font: 600 13px/1.3 var(--so-ui); letter-spacing: .03em; color: var(--so-paper-dim); }
#sortRoot .so-chip-gloss { margin: 0; font: 400 15px/1.45 var(--so-ui); color: var(--so-paper-dim); }
#sortRoot .so-chip-note { margin: 8px 0 0; font-size: 15px; }
#sortRoot .so-chip .so-passage cite { color: var(--so-paper-dim); }
#sortRoot .so-chip .so-passage { border-left-color: var(--t-fill); }
#sortRoot .so-chip mark, #sortRoot .so-back mark { background: var(--so-mark); color: inherit; padding: 0 .1em; border-radius: 3px; }
#sortRoot .so-also { margin-top: 8px; }
/* Closed, its contents are not laid out (hit-testing would find them otherwise). */
#sortRoot .so-also:not([open]) > :not(summary) { display: none; }
#sortRoot .so-also summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer;
  font: 600 14px/1.2 var(--so-ui); color: #1f4f7f; list-style: none;
}
#sortRoot .so-also summary::-webkit-details-marker { display: none; }
#sortRoot .so-also summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid currentColor; font-size: 14px; }
#sortRoot .so-also[open] summary::before { content: "–"; }
#sortRoot .so-also-note { margin: 6px 0 0; font-size: 15px; }

/* ---- Passages ------------------------------------------------------------------------ */
#sortRoot .so-passage { margin: 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); }
#sortRoot .so-verse { margin: 0; font-style: italic; }
#sortRoot .so-passage cite { display: block; margin-top: 3px; font: normal 600 13px/1.3 var(--so-ui); letter-spacing: .03em; color: var(--accent-ink); }
#sortRoot .so-passage--small .so-verse { font-size: 15px; }

/* ---- Closing, about, sources ------------------------------------------------------------ */
#sortRoot .so-close { margin-top: 44px; padding: 28px 28px 14px; border-radius: 16px; background: var(--so-surface); border: 1px solid var(--so-rule); }
#sortRoot .so-close h2, #sortRoot .so-about h2, #sortRoot .so-sources h2 { margin: 0 0 14px; font: 600 28px/1.15 var(--so-display); color: var(--ink); }
#sortRoot .so-close-passages { display: grid; gap: 12px; margin: 0 0 18px; }
#sortRoot .so-close-passages .so-verse { font-size: 19px; }
#sortRoot .so-close p { margin: 0 0 14px; }
#sortRoot .so-about { margin-top: 56px; max-width: 760px; }
#sortRoot .so-about p { margin: 0 0 14px; }
#sortRoot .so-sources { margin-top: 40px; max-width: 760px; }
#sortRoot .so-sources h2 { font-size: 20px; }
#sortRoot .so-sources ul { margin: 0; padding-left: 1.2em; font: 400 15px/1.5 var(--so-ui); color: var(--text-dim); }
#sortRoot .so-sources li { margin: 0 0 6px; }

/* ---- Motion off ---------------------------------------------------------------------------- */
body.low-power #sortRoot *, body.low-power #sortRoot *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  #sortRoot *, #sortRoot *::before { animation: none !important; transition: none !important; }
}

/* ---- Between phone and desktop -------------------------------------------------------------- */
@media (max-width: 1100px) and (min-width: 641px) {
  #sortRoot .so-title { padding-right: 8px; }
}

/* ---- Phone ----------------------------------------------------------------------------------- */
@media (max-width: 640px) {
  body.sort-mode #sortRoot { padding: 0 14px 56px; font-size: 17px; }
  #sortMain { padding-top: 60px; }
  #sortRoot .so-title h1 { font-size: 30px; margin: 6px 0 4px; }
  #sortRoot .so-sub { font-size: 16px; line-height: 1.4; }
  #sortRoot .so-tabs { flex-wrap: nowrap; margin-top: 14px; }
  #sortRoot .so-tab { flex: 1 1 0; min-width: 0; padding: 0 10px 0 5px; gap: 7px; font-size: 14px !important; }
  #sortRoot .so-tab-n { width: 30px; height: 30px; flex: none; }
  #sortRoot .so-tab { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; padding: 5px 10px 5px 5px; text-align: left; }
  #sortRoot .so-tab { align-items: center; }
  #sortRoot .so-tab.is-done .so-tab-n { grid-row: 1 / span 2; }
  #sortRoot .so-tab-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #sortRoot .so-tab-score { grid-column: 2; font-size: 12px; line-height: 1.2; white-space: nowrap; }
  #sortRoot .so-round { margin-top: 14px; }
  #sortRoot .so-lead { font-size: 16px; line-height: 1.45; margin-bottom: 8px; }
  #sortRoot .so-status { margin-bottom: 12px; gap: 10px; }
  #sortRoot .so-status-text { gap: 10px; font-size: 13px; }

  #sortRoot .so-deck { width: calc(100% - 14px); }
  #sortRoot .so-card { min-height: 196px; }
  #sortRoot .so-front { padding: 30px 16px 14px; }
  #sortRoot .so-word { font-size: 40px; }
  #sortRoot .so-word.is-long { font-size: 33px; }
  #sortRoot .so-gloss { margin-top: 10px; font-size: 15px; }
  #sortRoot .so-hint { margin-top: 10px; }
  #sortRoot .so-back { padding: 14px 14px 12px; gap: 7px; }
  #sortRoot .so-back-line { font-size: 16px; }
  #sortRoot .so-back .so-verse { font-size: 15px; line-height: 1.45; }

  #sortRoot .so-bins { gap: 8px; margin-top: 20px; }
  #sortRoot .so-bins[data-n="4"] { --cols: 2; }
  #sortRoot .so-bin { border-radius: 12px; }
  #sortRoot .so-bin-drop { min-height: 70px; padding: 12px 10px 6px; grid-template-columns: 1fr; border-radius: 12px 12px 0 0; }
  #sortRoot .so-bin-label { font-size: 17px; padding-right: 0; }
  #sortRoot .so-bins[data-n="3"] .so-bin-label { font-size: 15.5px; }
  #sortRoot .so-bin-sub { font-size: 12px; }
  #sortRoot .so-bin-count { grid-column: 1; grid-row: auto; justify-self: start; min-width: 28px; height: 26px; font-size: 13px; margin-top: 4px; }
  #sortRoot .so-chips { padding: 2px 8px 10px; gap: 5px; }
  #sortRoot .so-chip { font-size: 14.5px; padding: 2px 8px; }

  #sortRoot .so-tools { gap: 8px; margin-top: 14px; }
  #sortRoot .so-tools .so-btn { padding: 0 13px; font-size: 14px !important; }
  /* The other cards: one row that scrolls sideways, faded at the cut edge. */
  #sortRoot .so-pick { margin-top: 18px; }
  #sortRoot .so-pick-row {
    flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-right: -14px; padding-right: 28px;
    scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  }
  #sortRoot .so-pick-row::-webkit-scrollbar { display: none; }
  #sortRoot .so-pick-card { flex: none; min-height: 42px; }

  /* Done: the answers need the width, so the bins stack. */
  #sortRoot .so-round.is-done .so-bins { grid-template-columns: 1fr; }
  #sortRoot .so-round.is-done .so-bin-drop { min-height: 0; padding-bottom: 10px; grid-template-columns: 1fr auto; }
  #sortRoot .so-round.is-done .so-bin-count { grid-column: 2; grid-row: 1 / span 2; align-self: center; margin: 0; }
  #sortRoot .so-round.is-done .so-chip { font-size: 19px; padding: 9px 12px 9px 14px; }
  #sortRoot .so-round.is-done .so-chips { padding: 2px 10px 12px; }
  #sortRoot .so-bin-text { padding: 0 12px 12px; }
  #sortRoot .so-bin-text .so-verse { font-size: 16px; }
  #sortRoot .so-result { padding: 20px 16px 18px; }
  #sortRoot .so-res-num strong { font-size: 54px; }
  #sortRoot .so-close { margin-top: 32px; padding: 20px 16px 6px; border-radius: 14px; }
  #sortRoot .so-close h2, #sortRoot .so-about h2 { font-size: 24px; }
  #sortRoot .so-close-passages .so-verse { font-size: 17px; }
  #sortRoot .so-about { margin-top: 40px; }
}
@media (max-width: 380px) {
  #sortRoot .so-word { font-size: 36px; }
  #sortRoot .so-word.is-long { font-size: 29px; }
  #sortRoot .so-bins[data-n="3"] .so-bin-label { font-size: 14.5px; }
}
/* A phone on its side: little height, so a shorter card. */
@media (max-height: 500px) and (orientation: landscape) {
  #sortMain { padding-top: 60px; }
  #sortRoot .so-card { min-height: 170px; }
  #sortRoot .so-front { padding: 24px 18px 12px; }
  #sortRoot .so-word { font-size: 36px; }
}
