/* ═══ /create · the set builder (r8) ═══════════════════════════════════════
   Loaded only on /create, right after fx.css. Selectors are scoped under
   .cr-wrap so they outrank the page's inline <style> (which comes later)
   and fx.css §56 without !important. Site is dark-only; colours come from
   theme.css tokens, so light still works.

   C1  Page rhythm, scroll padding
   C2  Set-name card, language pickers, swap button
   C3  Words card head: count, sample chip, swap sides, keyboard hint
   C4  Rows: badge, fields, delete, half rows, flash
   C5  Add word, import drop zone, notes, errors
   C6  Actions bar (desktop row, phone sticky bar)
   C7  Result: "Your set is ready"
   C8  Live preview on tablets (side column) and phones (compact strip)
   C9  Presses and hover hygiene
   ════════════════════════════════════════════════════════════════════════ */

/* ── C1 · Page rhythm ──────────────────────────────────────────────────── */
/* Focus and scrollIntoView keep fields clear of the nav island above and
   the sticky action bar below. */
html { scroll-padding-top: 96px; scroll-padding-bottom: 24px; }
@media (max-width: 699px) { html { scroll-padding-bottom: 104px; } }

.cr-wrap .cr-main > .card { margin-bottom: 14px; }

/* ── C2 · Set name + languages ─────────────────────────────────────────── */
.cr-wrap .row-langs { display: flex; align-items: flex-end; gap: 10px; margin-top: 16px; }
.cr-wrap .row-langs > div { flex: 1; min-width: 0; }
.cr-swap {
  flex: none; width: 44px; height: 44px; margin-bottom: 1px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, var(--card-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--card-border));
  color: var(--accent-ink);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 300ms var(--spring, ease);
}
.cr-swap .sym { font-size: 22px; }
.cr-swap:focus-visible, .cr-tool:focus-visible, .cr-dl:focus-visible, .cr-link__copy:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}
/* The language fields read as pickers: a chevron of the datalist. */
.cr-wrap #srcLang, .cr-wrap #tgtLang { text-overflow: ellipsis; }
.cr-wrap input::-webkit-calendar-picker-indicator { opacity: .5; }
.cr-opt { margin-left: 4px; color: var(--muted); font-size: .76rem; font-weight: 500; }
/* Phones: the datalist arrow ate a third of a half-width field; the
   suggestions still drop down while typing. */
@media (max-width: 699px) {
  .cr-wrap input::-webkit-calendar-picker-indicator { display: none !important; }
}

/* ── C3 · Words head ───────────────────────────────────────────────────── */
.cr-wrap .words-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.cr-wrap .words-head h2 {
  display: flex; align-items: center; gap: 10px;
  font: 900 1.18rem/1.2 'Nunito', system-ui, sans-serif; letter-spacing: -.01em;
}
.cr-count {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--card-2); border: 1px solid var(--card-border);
  color: var(--muted); font: 700 .78rem/1.3 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  transition: color 200ms ease, background-color 200ms ease, border-color 200ms ease;
}
html.cr-has-words .cr-count {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, var(--card-2));
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}
.words-tools { display: flex; align-items: center; gap: 8px; }
.cr-count, .cr-wrap .cr-sample, .cr-tool { white-space: nowrap; }

/* The sample: a compact chip beside the empty rows it fills. */
.cr-wrap .cr-sample-wrap { display: block; margin: 0; }
.cr-wrap .cr-sample-wrap > div { padding: 0; margin: 0; overflow: visible; }
.cr-wrap .cr-sample-wrap.is-gone { display: none; }
.cr-wrap .cr-sample {
  min-height: 40px; gap: 9px;
  padding: 4px 14px 4px 4px;
  font-size: .9rem;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 30%, var(--card-border));
}
.cr-wrap .cr-sample__ic { width: 30px; height: 30px; }
.cr-wrap .cr-sample__ic .sym { font-size: 18px; }
.cr-wrap .cr-sample__m { font-size: .78rem; padding-left: 9px; }
.cr-wrap .cr-sample:active { transform: translateY(2px) scale(.98); }

.cr-tool {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px 0 9px;
  border-radius: var(--r-pill);
  background: transparent; border: 1px solid var(--card-border);
  color: var(--label); font: 700 .84rem/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
  animation: cr-in 320ms cubic-bezier(.2, .9, .3, 1.15) both;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.cr-tool[hidden] { display: none; }
.cr-tool .sym { font-size: 19px; color: var(--accent-ink); }

.cr-kbd { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
  .cr-kbd {
    display: block; margin: -2px 0 12px;
    color: var(--muted); font-size: .8rem; font-weight: 500;
  }
  .cr-kbd kbd {
    display: inline-block; min-width: 1.6em; margin: 0 2px; padding: 1px 6px;
    border-radius: 6px; border: 1px solid var(--card-border); border-bottom-width: 2px;
    background: var(--card-2); color: var(--label);
    font: 700 .72rem/1.4 'Inter', system-ui, sans-serif; text-align: center;
  }
}

/* ── C4 · Rows ─────────────────────────────────────────────────────────── */
.cr-wrap .word-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; position: relative; }
.cr-wrap .word-row input[type="text"] { flex: 1 1 0; min-width: 0; min-height: 46px; }
.cr-wrap .word-row.is-leaving { pointer-events: none; }
.cr-wrap .word-row:focus-within .num {
  background: linear-gradient(180deg, var(--accent-lite), var(--accent));
  color: #fff; box-shadow: 0 2px 0 var(--accent-depth);
}
.cr-wrap .word-row .num { transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }

/* Delete: a calm ×, not a third field. Full strength on rows with words
   and on the row being typed in. */
.cr-wrap .word-row .icon-btn {
  flex: none; width: 36px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px; border: 0;
  background: transparent; color: var(--muted);
  opacity: .5;
  cursor: pointer;
  transition: opacity 160ms ease, color 160ms ease, background-color 160ms ease, transform 280ms var(--spring, ease);
}
.cr-wrap .word-row .icon-btn .sym { font-size: 20px; }
.cr-wrap .word-row.has-text .icon-btn,
.cr-wrap .word-row:focus-within .icon-btn { opacity: 1; }
.cr-wrap .word-row .icon-btn:active { transform: scale(.86); transition-duration: 60ms; color: var(--danger); }
@media (hover: hover) and (pointer: fine) {
  .cr-wrap .word-row .icon-btn:hover { opacity: 1; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
}

/* A row with only one side, after Generate or Study: amber on the gap. */
.cr-wrap .word-row.is-half input[type="text"]:placeholder-shown {
  border-color: color-mix(in srgb, var(--story-ink) 80%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--story-ink) 16%, transparent);
}
.cr-wrap .word-row.is-half input[type="text"]:placeholder-shown::placeholder { color: color-mix(in srgb, var(--story-ink) 85%, transparent); }

/* Rows that just arrived (sample, paste, import) glow once. */
.cr-wrap .word-row.is-flash input[type="text"] { animation: cr-flash 1000ms ease-out var(--fd, 0ms) backwards; }
@keyframes cr-flash {
  0%   { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent); }
  100% { border-color: var(--card-border); box-shadow: 0 0 0 0 transparent; }
}
@keyframes cr-in {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ── C5 · Add word, drop zone, notes, errors ───────────────────────────── */
.cr-wrap .cr-add { min-height: 48px; margin-top: 4px; }
.cr-wrap .cr-add .sym { transition: transform 320ms var(--spring, ease); }
.cr-wrap .cr-add:active .sym { transform: rotate(90deg) scale(1.1); transition-duration: 120ms; }

.cr-wrap .drop {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  margin-top: 14px; padding: 14px 14px 14px 14px;
  border-radius: 18px;
  border: 1.5px dashed color-mix(in srgb, var(--muted) 38%, transparent);
  background: color-mix(in srgb, var(--card-2) 70%, transparent);
  transition: border-color 160ms ease, background-color 160ms ease, transform 260ms var(--spring, ease);
}
.drop__ic {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform 300ms var(--spring, ease);
}
.drop__ic .sym { font-size: 24px; }
.drop__copy { display: grid; gap: 2px; min-width: 0; }
.drop__h { font: 800 .98rem/1.25 'Nunito', system-ui, sans-serif; color: var(--label); }
.cr-wrap .drop__t { position: relative; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.drop__over { position: absolute; left: 0; top: 0; opacity: 0; transform: translateY(6px); color: var(--accent-ink); font-weight: 700; transition: opacity 160ms ease, transform 200ms ease; }
.drop__idle { display: inline-block; transition: opacity 160ms ease, transform 200ms ease; }
.cr-wrap .drop #fileBtn { min-height: 44px; padding-inline: 16px; }
.cr-wrap .drop.is-over {
  border-style: solid; border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--card-2));
  transform: scale(1.01);
}
.drop.is-over .drop__ic { transform: translateY(-4px) scale(1.08); }
.drop.is-over .drop__idle { opacity: 0; transform: translateY(-6px); }
.drop.is-over .drop__over { opacity: 1; transform: none; }
.drop.is-done .drop__ic { animation: cr-nod 520ms ease-out; }
@keyframes cr-nod { 0% { transform: none; } 40% { transform: scale(1.18) rotate(-6deg); } 100% { transform: none; } }
.drop__bar {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: translateX(-100%); opacity: 0;
}
.drop.is-busy .drop__bar { opacity: 1; animation: cr-busy 900ms linear infinite; }
@keyframes cr-busy { to { transform: translateX(100%); } }

.cr-wrap .cr-note { margin: 10px 0 0; min-height: 0; }
.cr-wrap .cr-note:empty { display: none; }
.cr-note.is-on, .cr-wrap .error.is-on {
  display: inline-flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px 8px 10px; border-radius: 14px;
  font-size: .86rem; font-weight: 600; line-height: 1.4;
}
.cr-note .sym, .cr-wrap .error .sym { font-size: 18px; line-height: 1.1; flex: none; }
.cr-note.is-ok { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.cr-note.is-warn, .cr-wrap .error.is-warn { color: var(--story-ink); background: color-mix(in srgb, var(--story-ink) 12%, transparent); }
.cr-wrap .error { margin: 0; }
.cr-wrap .error:empty { display: none; }
.cr-wrap .error.is-on { margin: 0 0 14px; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.cr-wrap .error.is-warn { color: var(--story-ink); }

.cr-wrap .cr-bulk { margin-top: 14px; }

/* ── C6 · Actions ──────────────────────────────────────────────────────── */
.cr-wrap .cr-actions { display: block; margin: 4px 0 16px; }
.cr-actions__btns { display: flex; flex-wrap: wrap; gap: 12px; }
.cr-wrap .cr-actions .btn { gap: 8px; min-height: 52px; }
.cr-wrap .cr-actions .btn .sym { font-size: 20px; }
.cr-wrap .cr-actions .hint { margin-top: 10px; }

@media (max-width: 699px) {
  /* The bar earns its space: a slim hint pill while the set is empty,
     the two buttons (springing in) once a word exists. */
  .cr-wrap .cr-actions {
    position: sticky; bottom: 0; z-index: 6;
    margin: 0 0 10px;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--scaffold) 94%, transparent);
    -webkit-backdrop-filter: none; backdrop-filter: none;
    border-top: 0;
    /* full-bleed background without negative margins */
    box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--scaffold) 94%, transparent), 0 -1px 0 100vmax var(--hairline);
    clip-path: inset(-1px -100vmax 0);
    transition: transform 220ms cubic-bezier(.2, .8, .25, 1), opacity 180ms ease;
  }
  .cr-actions__btns { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
  .cr-wrap .cr-actions .btn { width: 100%; min-height: 50px; padding-inline: 10px; font-size: .95rem; }
  html:not(.cr-has-words) .cr-actions__btns { display: none; }
  html.cr-has-words .cr-actions__btns { animation: cr-in 340ms cubic-bezier(.2, .9, .3, 1.15) both; }
  .cr-wrap .cr-actions .hint {
    justify-content: center; margin: 0; min-height: 30px;
    font-size: .86rem;
  }
  .cr-wrap .cr-actions .hint.is-ready { display: none; }
  /* Typing on a phone: the bar slides out of the keyboard's way. */
  html.is-typing .cr-wrap .cr-actions { transform: translateY(calc(100% + 2px)); opacity: 0; pointer-events: none; }
  main.page { padding-bottom: 28px; }
}

/* ── C7 · Result ───────────────────────────────────────────────────────── */
.cr-wrap .cr-res {
  position: relative;
  padding: 24px;
  border-radius: var(--r-xl, 24px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--card-border));
  background:
    radial-gradient(120% 70% at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--card);
  box-shadow: var(--card-shadow), 0 30px 60px -36px color-mix(in srgb, var(--accent) 55%, transparent);
}
.cr-res__head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cr-res__medal {
  position: relative; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--accent-lite), var(--accent));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 0 var(--accent-depth), 0 10px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.cr-res__medal .sym { font-size: 28px; font-variation-settings: 'wght' 700; }
.cr-res__ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; pointer-events: none; }
.cr-res__hd { min-width: 0; }
.cr-res__t { font: 900 1.4rem/1.15 'Nunito', system-ui, sans-serif; letter-spacing: -.01em; color: var(--label); }
.cr-res__sub { margin-top: 3px; color: var(--muted); font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.cr-res__name { color: var(--label); font-weight: 800; }
.cr-res__pair { white-space: nowrap; }

/* Stale: the words changed after the link was made. */
.cr-stale { display: none; }
.cr-res.is-stale .cr-stale {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px 12px;
  margin: -4px 0 16px; padding: 10px 10px 10px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--story-ink) 12%, transparent);
  color: var(--story-ink); font-size: .88rem; font-weight: 600; line-height: 1.35;
}
.cr-stale__ic {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--story-ink) 18%, transparent);
}
.cr-stale__ic .sym { font-size: 20px; }
.cr-res.is-stale .cr-stale__ic .sym { animation: cr-spin 900ms cubic-bezier(.3, .7, .3, 1) 1; }
@keyframes cr-spin { from { transform: rotate(-180deg); } to { transform: none; } }
.cr-stale__t { min-width: 0; }
@media (max-width: 559px) {
  /* The button tucks under the sentence, in line with its text. */
  .cr-res.is-stale .cr-stale { grid-template-columns: 32px minmax(0, 1fr); padding: 12px; }
  .cr-wrap .cr-stale__btn { grid-column: 2; justify-self: start; }
}
.cr-wrap .cr-stale__btn { min-height: 44px; padding-inline: 16px; }
.cr-res.is-stale .cr-link, .cr-res.is-stale .cr-qr { opacity: .4; transition: opacity 240ms ease; }
.cr-res .cr-link, .cr-res .cr-qr { transition: opacity 240ms ease; }

/* The link: one line in a pill, fading out at the right edge, a copy
   button inside. The full link stays in the element (select, copy). */
.cr-link {
  position: relative; overflow: hidden;
  display: flex; align-items: center;
  height: 54px; padding-right: 6px;
  border-radius: 16px;
  background: var(--card-2); border: 1px solid var(--card-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.cr-wrap .out-link {
  flex: 1; min-width: 0; height: 100%;
  margin: 0; padding: 0 0 0 16px;
  background: none; border: 0; border-radius: 0;
  max-height: none; overflow: hidden;
  white-space: nowrap; word-break: normal;
  font: 500 .86rem/54px ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;
  color: var(--ink);
  -webkit-mask-image: linear-gradient(90deg, #000 78%, transparent);
          mask-image: linear-gradient(90deg, #000 78%, transparent);
  cursor: text;
}
.cr-wrap .out-link:focus-visible { outline: none; }
.cr-link:focus-within { border-color: var(--accent); }
.cr-link__copy {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  color: var(--accent-ink); cursor: pointer;
  transition: background-color 160ms ease, transform 280ms var(--spring, ease);
}
.cr-link__copy .sym { font-size: 21px; }
.cr-wrap .cr-link__copy { background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--accent-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
:root[data-theme="dark"] .cr-wrap .cr-link__copy { color: #8BE08F; }
.cr-wrap .cr-link__copy.is-copied { background: var(--accent); color: #fff; }
.cr-link__copy.is-copied { background: var(--accent); color: #fff; }
.cr-link__copy.is-copied .sym { animation: cr-pop 360ms cubic-bezier(.2, .9, .3, 1.3); }
.cr-link::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--accent) 30%, transparent) 50%, transparent 70%);
  transform: translateX(-100%);
}
.cr-link.is-glint::after { animation: cr-glint 620ms cubic-bezier(.3, .6, .3, 1); }
@keyframes cr-glint { to { transform: translateX(100%); } }
@keyframes cr-pop { 0% { transform: scale(.4); } 60% { transform: scale(1.2); } 100% { transform: none; } }

.cr-res__acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.cr-wrap .cr-res__acts .btn { width: 100%; min-height: 50px; justify-content: center; gap: 8px; padding-inline: 12px; }
.cr-wrap .cr-res__acts .btn .sym { font-size: 20px; }
.cr-wrap .cr-res__study { grid-column: 1 / -1; min-height: 56px !important; font-size: 1.04rem; }

/* Copy: the label rolls up and out, "Copied" rolls in from below. */
.cr-wrap .cr-copy { position: relative; overflow: hidden; }
.cr-copy__a, .cr-copy__b { display: inline-flex; align-items: center; gap: 8px; transition: transform 220ms cubic-bezier(.2, .9, .3, 1.2), opacity 160ms ease; }
.cr-copy__b { position: absolute; inset: 0; justify-content: center; transform: translateY(110%); opacity: 0; }
.cr-copy.is-copied .cr-copy__a { transform: translateY(-110%); opacity: 0; }
.cr-copy.is-copied .cr-copy__b { transform: none; opacity: 1; }
.cr-wrap .cr-copy.is-copied { animation: cr-flashbtn 700ms ease-out; color: var(--accent-ink); }
@keyframes cr-flashbtn {
  0%   { background: color-mix(in srgb, var(--accent) 45%, var(--card-2)); }
  100% { background: var(--card-2); }
}

/* QR: a white tile and a caption, side by side from 560px. */
.cr-qr:empty { display: none; }
.cr-qr {
  display: flex; align-items: center; gap: 20px;
  margin-top: 16px; padding: 16px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--card-2) 60%, transparent);
  border: 1px solid var(--card-border);
}
.cr-qr__tile {
  flex: none; padding: 8px;
  border-radius: 14px; background: #fff;
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .6);
}
.cr-qr__tile { position: relative; }
.cr-qr__tile > img { display: block; width: 176px; height: 176px; image-rendering: pixelated; }
/* The FLX badge in the middle (level-M codes only): ~19% of the width,
   a white ring so the modules around it keep a clean edge. */
.cr-qr__logo {
  position: absolute; left: 50%; top: 50%;
  width: 19%; aspect-ratio: 1; translate: -50% -50%;
  display: grid; place-items: center;
  padding: 3px; border-radius: 22%;
  background: #fff;
}
.cr-qr__logo img { display: block; width: 100%; height: 100%; border-radius: 20%; }
.cr-qr__cap { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.cr-qr__cap b { display: flex; align-items: center; gap: 8px; color: var(--label); font: 800 1rem/1.25 'Nunito', system-ui, sans-serif; }
.cr-qr__cap b .sym { font-size: 20px; color: var(--accent-ink); }
.cr-qr__big { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.cr-qr__big .sym { font-size: 22px; color: var(--story-ink); }

.cr-res__foot { display: flex; align-items: center; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; margin-top: 14px; }
.cr-wrap .cr-res__foot .len-note { margin: 0; font-size: .82rem; }
.cr-wrap .cr-res__foot .len-note.warn {
  flex-basis: 100%; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--story-ink) 12%, transparent);
}
.cr-dl {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 6px;
  background: none; border: 0; border-radius: 10px;
  color: var(--accent-ink); font: 700 .88rem/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
}
.cr-dl .sym { font-size: 19px; }
.cr-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 559px) {
  .cr-wrap .cr-res { padding: 20px 16px; }
  .cr-res__medal { width: 44px; height: 44px; }
  .cr-res__t { font-size: 1.25rem; }
  .cr-qr { flex-direction: column; text-align: center; gap: 12px; }
  .cr-qr__cap b { justify-content: center; }
  .cr-qr__tile > img { width: 168px; height: 168px; }
  .cr-wrap .out-link { font-size: .8rem; padding-left: 14px; }
}

/* ── C8 · Live preview on tablets and phones ───────────────────────────── */
/* 700–999px: a side column beside the form, sticky under the nav. */
@media (min-width: 700px) and (max-width: 999px) {
  .cr-wrap .cr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; align-items: start; }
  .cr-wrap .cr-side { display: block; position: sticky; top: 92px; animation: fx-rise 600ms var(--ease-out, ease) 160ms both; }
  .cr-wrap .cr-prev { padding: 16px 16px 18px; }
  .cr-wrap .cr-prev__deck { height: 140px; margin: 14px 6px 18px; }
  .cr-wrap .cr-prev__word { font-size: 1.35rem; }
  .cr-wrap .cr-prev__perks { gap: 8px; font-size: .8rem; }
  .cr-wrap .row-langs { flex-wrap: nowrap; }
  .cr-wrap .drop { grid-template-columns: auto minmax(0, 1fr); }
  .cr-wrap .drop #fileBtn { grid-column: 1 / -1; width: 100%; justify-content: center; }
  /* The QR shares a ~380px row with its caption: a smaller tile keeps
     the caption from wrapping every two words. */
  .cr-wrap .cr-qr { gap: 16px; }
  .cr-wrap .cr-qr__tile > img { width: 140px; height: 140px; }
  /* The form column is ~420px here: the chip says just "Try a sample". */
  .cr-wrap .cr-sample__m { display: none; }
}
/* Phones: a compact strip — the card on the left, name and meta on the
   right — between the set name and the words. Same element (fx.js §56
   drives it by id), moved with order; .cr-main lends its children. */
@media (max-width: 699px) {
  .cr-wrap .cr-grid { display: flex; flex-direction: column; }
  .cr-wrap .cr-main { display: contents; }
  .cr-wrap .cr-meta { order: 1; }
  .cr-wrap .cr-side { order: 2; display: block; margin-bottom: 14px; animation: fx-rise 520ms var(--ease-out, ease) 120ms both; }
  .cr-wrap .cr-words { order: 3; }
  .cr-wrap .cr-actions { order: 4; }
  .cr-wrap .error { order: 5; }
  .cr-wrap .cr-res { order: 6; }
  .cr-wrap .cr-prev {
    display: grid; grid-template-columns: 132px minmax(0, 1fr); grid-template-rows: auto auto 1fr;
    column-gap: 16px; align-items: center;
    padding: 12px 16px 12px 12px;
    border-radius: 20px;
  }
  .cr-wrap .cr-prev__k { grid-column: 2; grid-row: 1; justify-self: start; align-self: end; padding: 3px 9px 3px 7px; font-size: .62rem; margin-bottom: 6px; }
  .cr-wrap .cr-prev__deck { grid-column: 1; grid-row: 1 / span 3; height: 86px; margin: 6px 4px 6px 6px; }
  .cr-wrap .cr-prev__name { grid-column: 2; grid-row: 2; font-size: 1.05rem; }
  .cr-wrap .cr-prev__meta { grid-column: 2; grid-row: 3; align-self: start; font-size: .8rem; }
  .cr-wrap .cr-prev__perks { display: none; }
  .cr-wrap .cr-prev__card { padding: 10px 8px; border-radius: 12px; gap: 2px; }
  .cr-wrap .cr-prev__back { border-radius: 12px; }
  .cr-wrap .cr-prev__back::after { top: calc(50% - 8px); height: 16px; }
  .cr-wrap .cr-prev__word { font-size: 1.02rem; -webkit-line-clamp: 1; }
  .cr-wrap .cr-prev__tr { font-size: .74rem; }
  .cr-wrap .cr-prev__side { top: 6px; left: 8px; font-size: .5rem; }
  .cr-wrap .cr-prev__eg { display: none; }
  .cr-wrap .cr-prev__card::before { height: 3px; }

  /* Header rhythm: the set-name field shows on the first screen. */
  .cr-wrap .cr-head { margin-bottom: 20px; }
  .cr-wrap .cr-head h1 { font-size: 2.1rem; margin-bottom: 8px; }
  .cr-wrap .cr-head .lead { font-size: .97rem; line-height: 1.5; margin-bottom: 16px; }
  .cr-wrap .cr-main > .card, .cr-wrap .cr-meta, .cr-wrap .cr-words { padding: 16px 14px; border-radius: 22px; }
  .cr-wrap .row-langs { gap: 8px; margin-top: 14px; }
  .cr-swap { width: 40px; height: 44px; border-radius: 14px; }

  /* Rows: the fields get the width; a slim badge and a calm ×. */
  .cr-wrap .word-row { gap: 6px; }
  .cr-wrap .word-row .num { min-width: 20px; height: 20px; padding: 0 4px; font-size: .68rem; }
  .cr-wrap .word-row .icon-btn { width: 30px; }
  .cr-wrap .word-row input[type="text"] { padding-inline: 11px; }
  .cr-wrap .cr-sample__m { display: none; }

  /* Drop zone: no drag-and-drop on a phone — one clear button. */
  .cr-wrap .drop { grid-template-columns: auto minmax(0, 1fr); padding: 12px; gap: 12px; }
  .cr-wrap .drop #fileBtn { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .drop__dnd { display: none; }
}
@media (max-width: 370px) {
  .cr-wrap .cr-prev { grid-template-columns: 112px minmax(0, 1fr); column-gap: 12px; }
  .cr-wrap .word-row .num { display: none; }
}

/* ── C9 · Presses and hover hygiene ────────────────────────────────────── */
.cr-wrap :is(.cr-add, #fileBtn, #bulkAdd, .cr-actions .btn, .cr-res .btn, .word-row .icon-btn, .cr-sample, .cr-swap, .cr-tool, .cr-dl, .cr-link__copy) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cr-wrap :is(.cr-swap, .cr-tool, .cr-dl, .cr-link__copy):active { transform: scale(.94); transition-duration: 60ms; }
@media (hover: hover) and (pointer: fine) {
  .cr-swap:hover { background: color-mix(in srgb, var(--accent) 20%, var(--card-2)); border-color: var(--accent); }
  .cr-tool:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--card-border)); background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .cr-dl:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
  .cr-wrap .cr-link__copy:not(.is-copied):hover { background: color-mix(in srgb, var(--accent) 32%, var(--card)); }
}
/* No sticky hover lift on touch screens. */
@media (hover: none) {
  .cr-wrap .cr-sample:hover { transform: none; }
}
