/* Llaves · sistema visual
   Editorial y limpio: papel cálido, tinta profunda, índigo para aprender, verde para avanzar.
   Las piezas de la gramática tienen color propio: llave (ámbar), verbo (índigo), marca (magenta). */

:root {
  --bg: #f6f5f1;
  --bg-2: #efede7;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #16161a;
  --ink-2: #44444c;
  --muted: #6e6e78;
  --line: #e4e1d9;
  --line-2: #d6d2c8;
  --primary: #4338ca;
  --primary-ink: #ffffff;
  --primary-soft: #ecebfd;
  --ok: #157f3c;
  --ok-soft: #e4f4e9;
  --bad: #c9393b;
  --bad-soft: #fbeaea;
  --key-bg: #ffe7a6;
  --key-ink: #7a4a00;
  --verb-bg: #e2e0ff;
  --verb-ink: #3730a3;
  --mark-ink: #be185d;
  --mark-bg: #ffe0ee;
  --shadow-1: 0 1px 2px rgba(22, 22, 26, .05), 0 1px 1px rgba(22, 22, 26, .03);
  --shadow-2: 0 10px 30px -12px rgba(22, 22, 26, .18), 0 2px 6px rgba(22, 22, 26, .05);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", ui-serif, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d10; --bg-2: #131317; --surface: #17171c; --surface-2: #1c1c22; --ink: #ededf2; --ink-2: #c1c1ca; --muted: #8e8e99;
    --line: #2a2a32; --line-2: #36363f; --primary: #8f88ff; --primary-ink: #0d0d10; --primary-soft: #23214a;
    --ok: #4ade80; --ok-soft: #10301c; --bad: #ff7b7b; --bad-soft: #3a1618;
    --key-bg: #4a3300; --key-ink: #ffd27a; --verb-bg: #29265e; --verb-ink: #c9c5ff; --mark-ink: #ff8fc4; --mark-bg: #4a1430;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 16px 40px -16px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d10; --bg-2: #131317; --surface: #17171c; --surface-2: #1c1c22; --ink: #ededf2; --ink-2: #c1c1ca; --muted: #8e8e99;
  --line: #2a2a32; --line-2: #36363f; --primary: #8f88ff; --primary-ink: #0d0d10; --primary-soft: #23214a;
  --ok: #4ade80; --ok-soft: #10301c; --bad: #ff7b7b; --bad-soft: #3a1618;
  --key-bg: #4a3300; --key-ink: #ffd27a; --verb-bg: #29265e; --verb-ink: #c9c5ff; --mark-ink: #ff8fc4; --mark-bg: #4a1430;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 16px 40px -16px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.ic { flex: none; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- estructura ---------- */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.side { display: none; }
.main { min-width: 0; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
.wrap { max-width: 1040px; margin: 0 auto; }
@media (min-width: 920px) {
  .shell { grid-template-columns: 248px 1fr; }
  .side {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh;
    padding: 22px 14px; border-right: 1px solid var(--line); background: var(--bg);
  }
  .main { padding: 36px 40px 64px; }
  .tabbar { display: none !important; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--ink); color: var(--key-bg);
}
.brand b { font: 400 26px/1 var(--serif); letter-spacing: -.01em; }
.nav-a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px;
  transition: background-color 150ms ease, color 150ms ease;
}
@media (hover: hover) and (pointer: fine) { .nav-a:hover { background: var(--bg-2); color: var(--ink); } }
.nav-a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-a[aria-current="page"] .ic { color: var(--primary); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.streak-mini { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.streak-mini .ic { color: #f97316; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 86%, transparent); backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--line);
}
.tabbar a {
  display: grid; justify-items: center; gap: 2px; padding: 6px 0; min-height: 48px; border-radius: 12px;
  text-decoration: none; font-size: 11px; font-weight: 600; color: var(--muted);
}
.tabbar a[aria-current="page"] { color: var(--primary); }

/* ---------- tipografía ---------- */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.display { font: 400 clamp(34px, 5vw, 52px)/1.04 var(--serif); letter-spacing: -.015em; margin: 0 0 12px; text-wrap: balance; }
.display em { font-style: italic; color: var(--primary); }
.h2 { font: 600 20px/1.25 var(--font); letter-spacing: -.01em; margin: 0 0 4px; }
.h3 { font: 600 16px/1.3 var(--font); margin: 0; }
.sub { color: var(--ink-2); margin: 0; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* ---------- componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow-1);
}
.card.pad-lg { padding: 24px; }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  --b: var(--primary); --bi: var(--primary-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--b); color: var(--bi); font-weight: 600; font-size: 15px; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, opacity 150ms ease;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .38; cursor: default; transform: none; }
.btn.ghost { --b: transparent; --bi: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.soft { --b: var(--bg-2); --bi: var(--ink); }
.btn.dark { --b: var(--ink); --bi: var(--bg); }
.btn.ok { --b: var(--ok); --bi: #fff; }
.btn.bad { --b: var(--bad); --bi: #fff; }
.btn.lg { min-height: 54px; font-size: 16px; padding: 0 26px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) {
  .btn.ghost:hover { background: var(--bg-2); }
  .btn.soft:hover { background: var(--line); }
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0;
  background: transparent; color: var(--ink-2); transition: transform 160ms var(--ease-out), background-color 150ms ease;
}
.icon-btn:active { transform: scale(0.94); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--bg-2); color: var(--ink); } }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--bg-2); color: var(--ink-2); white-space: nowrap;
}
.chip.key { background: var(--key-bg); color: var(--key-ink); }
.chip.primary { background: var(--primary-soft); color: var(--primary); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; letter-spacing: .02em; }

.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); font-size: 17px; transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }

/* piezas de gramática */
.pz { border-radius: 6px; padding: 1px 5px; margin: 0 -1px; font-weight: 600; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.pz-key { background: var(--key-bg); color: var(--key-ink); }
.pz-verb { background: var(--verb-bg); color: var(--verb-ink); }
.pz-mark, .pz-mark-solo { color: var(--mark-ink); font-weight: 700; }
.pz-mark-solo { background: var(--mark-bg); border-radius: 6px; padding: 1px 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* anillo */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; }
.ring circle { fill: none; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 600ms var(--ease-out); }
.ring b { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: 99px; transform-origin: left; transition: transform 500ms var(--ease-out); }

/* ---------- vistas ---------- */
.view { animation: viewIn 220ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
.stagger > * { animation: rise 360ms var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 40ms; } .stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; } .stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(n+6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Hoy */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 28px; color: var(--bg);
  background: radial-gradient(120% 140% at 100% 0%, #312e81 0%, #1e1b4b 38%, #121217 100%);
}
:root[data-theme="dark"] .hero, :root:not([data-theme="light"]) .hero { isolation: isolate; }
.hero .display { color: #fff; }
.hero .sub { color: rgba(255,255,255,.74); }
.hero-keys { position: absolute; right: -10px; top: -14px; display: flex; flex-direction: column; gap: 10px; opacity: .9; pointer-events: none; }
.hero-keys span {
  font: 600 13px/1 var(--font); padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.08); transform: rotate(-6deg);
}
.hero-keys span:nth-child(2) { background: var(--key-bg); color: var(--key-ink); border-color: transparent; transform: rotate(4deg) translateX(-24px); }
.hero-keys span:nth-child(3) { transform: rotate(-2deg) translateX(-8px); }
.hero .btn { --b: #fff; --bi: #16161a; }
.hero .chip { background: rgba(255,255,255,.1); color: rgba(255,255,255,.85); }
.coach {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.09); color: rgba(255,255,255,.88); font-size: 15px;
}
.coach .ic { color: var(--key-bg); margin-top: 2px; }
@media (max-width: 640px) { .hero { padding: 22px 18px; } .hero-keys { display: none; } }

.stat { display: grid; gap: 2px; }
.stat b { font: 600 28px/1.1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }

.tile {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; padding: 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-decoration: none;
  transition: transform 160ms var(--ease-out), border-color 150ms ease, box-shadow 200ms ease;
}
.tile:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .tile:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); } }
.tile-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.tile-ic.key { background: var(--key-bg); color: var(--key-ink); }
.tile-ic.ok { background: var(--ok-soft); color: var(--ok); }
.tile-ic.bad { background: var(--bad-soft); color: var(--bad); }
.tile-ic.ink { background: var(--ink); color: var(--bg); }
.tile .t { display: grid; gap: 2px; min-width: 0; }
.tile .t b { font-weight: 600; }
.tile .t span { font-size: 13.5px; color: var(--muted); }
.tile .go { margin-left: auto; color: var(--muted); }

.broken { display: grid; gap: 10px; }
.broken-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.broken-row .bar { height: 6px; }
.broken-row .bar > i { background: var(--bad); }

/* Teoría */
.tense-map { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; }
.tense-map .hd { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 8px; align-self: end; }
.tense-map .rh { writing-mode: vertical-rl; transform: rotate(180deg); justify-self: center; align-self: center; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tm-cell {
  text-align: left; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; display: grid; gap: 8px; transition: transform 160ms var(--ease-out), box-shadow 200ms ease;
}
.tm-cell:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .tm-cell:hover { box-shadow: var(--shadow-2); } }
.tm-cell .ex { font-size: 17px; }
.tm-cell .nm { font-size: 13px; color: var(--muted); font-weight: 500; }

.search {
  position: relative; max-width: 420px; width: 100%;
}
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 42px; min-height: 46px; font-size: 15px; }

.topic-card {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; padding: 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow-1);
  transition: transform 160ms var(--ease-out), box-shadow 200ms ease;
}
.topic-card:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .topic-card:hover { box-shadow: var(--shadow-2); } }
.topic-card b { font-weight: 600; }
.topic-card .meta { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.topic-card .ring { grid-row: 1; grid-column: 2; }
.group-title { font: 400 26px/1.1 var(--serif); margin: 34px 0 12px; }

.topic-head { display: grid; gap: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; margin-left: -6px; }
.big-key {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; width: fit-content;
  background: var(--key-bg); color: var(--key-ink); font: 600 20px/1.2 var(--font);
}
.toc { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding-block: 10px; }
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; padding: 7px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; background: var(--bg-2); }
.toc a:active { transform: scale(0.97); }
.th-sec { scroll-margin-top: 64px; }
.formula { display: grid; gap: 10px; }
.formula .lbl { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.formula .lbl.aff { color: var(--ok); } .formula .lbl.neg { color: var(--bad); } .formula .lbl.q { color: var(--primary); }
.formula code { font: 500 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 8px 10px; border-radius: 10px; display: block; }
.formula .ex { font-size: 19px; line-height: 1.5; }
.rules { counter-reset: r; display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.rules li { counter-increment: r; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.rules li::before { content: counter(r); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700; }
.err-row { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); }
.err-row:first-child { border-top: 0; padding-top: 0; }
.err-row .bad { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in oklab, var(--bad) 50%, transparent); }
.err-row .good { color: var(--ok); font-weight: 600; }
.phrase { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.phrase:first-child { border-top: 0; }
.phrase .en { font-weight: 500; }
.phrase .es { font-size: 14px; color: var(--muted); }
.usage { display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.usage .ex { font-size: 17px; }
.tip { display: flex; gap: 12px; padding: 16px; border-radius: 14px; background: var(--key-bg); color: var(--key-ink); }

/* Practicar */
.mode-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-2); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); min-height: 38px; transition: background-color 150ms ease, color 150ms ease; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- reproductor de ejercicios ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; grid-template-rows: auto 1fr auto; }
.player-top { display: flex; align-items: center; gap: 14px; padding: 14px 16px; max-width: 760px; width: 100%; margin: 0 auto; }
.player-top .bar { flex: 1; height: 12px; }
.player-top .bar > i { background: var(--ok); }
.combo { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; color: #f97316; min-width: 44px; font-variant-numeric: tabular-nums; }
.combo.zero { color: var(--muted); }
.stage { overflow-y: auto; padding: 8px 16px 24px; }
.stage-in { max-width: 680px; margin: 0 auto; display: grid; gap: 18px; padding-top: 2vh; }
.q-kind { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.q-text { font: 500 clamp(22px, 3.4vw, 28px)/1.35 var(--font); letter-spacing: -.01em; margin: 0; text-wrap: pretty; }
.q-text .blank { display: inline-block; min-width: 72px; border-bottom: 2.5px solid var(--line-2); margin: 0 2px; transform: translateY(-4px); }
.q-es { font-size: 15px; color: var(--muted); }
.speak-row { display: flex; gap: 8px; }
.speak-big { width: 64px; height: 64px; border-radius: 18px; border: 0; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; transition: transform 160ms var(--ease-out); }
.speak-big:active { transform: scale(0.95); }
.speak-big.slow { background: var(--primary-soft); color: var(--primary); }

.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 16px; min-height: 58px;
  border-radius: 14px; border: 1.5px solid var(--line-2); border-bottom-width: 3px; background: var(--surface);
  font-size: 17px; font-weight: 500; transition: transform 140ms var(--ease-out), border-color 120ms ease, background-color 120ms ease;
}
.opt:active { transform: scale(0.985) translateY(1px); }
.opt .k { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--muted); flex: none; }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.opt[aria-pressed="true"] .k { border-color: var(--primary); color: var(--primary); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
@media (hover: hover) and (pointer: fine) { .opt:hover:not([disabled]) { border-color: var(--muted); } }
.opt[disabled] { cursor: default; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf .opt { justify-content: center; }

.tiles-answer {
  min-height: 72px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 10px 0;
  border-bottom: 2px solid var(--line); background-image: linear-gradient(var(--line) 2px, transparent 2px); background-size: 100% 60px; background-position: 0 58px;
}
.tiles-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 8px; }
.tile-w {
  padding: 9px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); border-bottom-width: 3px; background: var(--surface);
  font-size: 17px; font-weight: 500; transition: transform 140ms var(--ease-out), opacity 150ms ease;
}
.tile-w:active { transform: scale(0.95); }
.tile-w.used { opacity: 0; pointer-events: none; }
.tile-w.ghost { visibility: hidden; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .opt { justify-content: center; text-align: center; font-size: 16px; min-height: 54px; }
.match .opt.done { opacity: .35; border-color: var(--ok); background: var(--ok-soft); pointer-events: none; }
.match .opt.shake { animation: shake 320ms var(--ease-out); border-color: var(--bad); }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

.player-foot { border-top: 1px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); }
.player-foot .in { max-width: 680px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.player-foot .btn.lg { min-width: 180px; }
@media (max-width: 560px) { .player-foot .btn.lg { flex: 1; min-width: 0; } }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 300ms var(--ease-drawer);
  border-top: 1px solid transparent;
}
.sheet.open { transform: translateY(0); }
.sheet.ok { background: var(--ok-soft); border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.sheet.bad { background: var(--bad-soft); border-color: color-mix(in oklab, var(--bad) 30%, transparent); }
.sheet .in { max-width: 680px; margin: 0 auto; display: grid; gap: 12px; }
.sheet .verdict { display: flex; align-items: center; gap: 10px; font: 700 20px/1.2 var(--font); }
.sheet.ok .verdict { color: var(--ok); } .sheet.bad .verdict { color: var(--bad); }
.sheet .badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.sheet.ok .badge { background: var(--ok); } .sheet.bad .badge { background: var(--bad); }
.sheet.open .badge { animation: pop 320ms var(--ease-out); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); } }
.sheet .answer { font-size: 17px; }
.sheet .answer .df { color: var(--bad); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.sheet .why { font-size: 15px; color: var(--ink-2); }
.sheet .actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.done-screen { display: grid; gap: 22px; justify-items: center; text-align: center; padding-top: 6vh; }
.done-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 520px; }
.done-stats .card { padding: 14px 10px; }

/* ---------- voz ---------- */
.rec-stage { display: grid; gap: 18px; justify-items: center; text-align: center; padding: 22px 16px; }
.rec-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 0 0 8px var(--bad-soft); transition: transform 160ms var(--ease-out), box-shadow 300ms ease;
}
.rec-btn:active { transform: scale(0.95); }
.rec-btn.on { box-shadow: 0 0 0 14px var(--bad-soft); }
.wave { width: 100%; max-width: 520px; height: 64px; }
.timer { font: 600 28px/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.transcript { width: 100%; max-width: 620px; text-align: left; min-height: 64px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line-2); color: var(--ink-2); }
.transcript .interim { color: var(--muted); }
.prompt-card { display: grid; gap: 8px; text-align: left; }
.fb { display: grid; gap: 10px; }
.fb-line { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.fb-line .o { color: var(--bad); text-decoration: line-through; }
.fb-line .c { color: var(--ok); font-weight: 600; }

/* ---------- avance ---------- */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 14px; height: 14px; border-radius: 4px; background: var(--line); position: relative; }
.heat i[data-l="1"] { background: color-mix(in oklab, var(--primary) 25%, var(--surface)); }
.heat i[data-l="2"] { background: color-mix(in oklab, var(--primary) 50%, var(--surface)); }
.heat i[data-l="3"] { background: color-mix(in oklab, var(--primary) 75%, var(--surface)); }
.heat i[data-l="4"] { background: var(--primary); }
.heat i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 52px; gap: 12px; align-items: center; padding: 6px 0; }
.hbar .bar { height: 10px; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); }
.hbar .n { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tooltip {
  position: fixed; z-index: 90; pointer-events: none; padding: 8px 10px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow-2); opacity: 0; transform: translateY(4px) scale(.98); transition: opacity 125ms ease-out, transform 125ms var(--ease-out);
}
.tooltip.on { opacity: 1; transform: none; }

/* toasts y diálogos */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-2); transition: opacity 200ms ease, transform 200ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }
.toast.out { opacity: 0; transform: translateY(6px); }
.confetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-2); }
dialog.modal::backdrop { background: rgba(10, 10, 14, .45); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modalIn 220ms var(--ease-out); }
@keyframes modalIn { from { opacity: 0; transform: scale(.96); } }
.modal-in { padding: 22px; display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
select.input { min-height: 46px; font-size: 15px; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.loader { display: grid; place-items: center; min-height: 60dvh; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-property: opacity, background-color, border-color, color !important; }
  .sheet { transition: none; }
}
.ic.inline { display: inline-block; vertical-align: -2px; }
.hero .display em { color: #b9b4ff; }

/* v2 · palabra nueva, textos, lectura, redacción */
.word-card { display: grid; gap: 12px; }
.word-en { font: 400 clamp(44px, 8vw, 64px)/1 var(--serif); letter-spacing: -.01em; }
.word-es { font-size: 20px; font-weight: 600; color: var(--primary); }
.wforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.wf { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.wf b { font-size: 17px; font-weight: 600; }
.long-text { font-size: 18px; line-height: 2.1; }
.long-text p { line-height: 1.7; }
.gap {
  display: inline-block; min-width: 92px; width: 9ch; height: 36px; padding: 0 8px; margin: 0 2px; border-radius: 9px;
  border: 1.5px solid var(--line-2); background: var(--surface-2); font-size: 16px; vertical-align: baseline;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.gap:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select.gap { width: auto; }
.gap[data-res="ok"] { border-color: var(--ok); background: var(--ok-soft); }
.gap[data-res="bad"] { border-color: var(--bad); background: var(--bad-soft); }
.gap-fix { color: var(--ok); font-weight: 700; font-size: 15px; margin: 0 4px; }
.req { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--muted); }
.req .ic { color: var(--line-2); transition: color 150ms ease; }
.req.met { color: var(--ink); }
.req.met .ic { color: var(--ok); }
.long-text .row { line-height: 1.3; }
.player:has(.sheet.open) .stage { padding-bottom: 55vh; }
[hidden] { display: none !important; }
.word-card > .row { width: 100%; justify-self: stretch; }
