/* Fuentes empaquetadas (OFL, subconjunto latino): la app de iOS y la PWA sin
   conexión no pueden depender de Google Fonts. */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/inter-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/inter-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/inter-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/inter-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/playfair-display-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/playfair-display-latin-700-normal.woff2) format('woff2'); }

/* Scoresheet · sistema visual v3 (Piensa CASA)
   Tinta, oro y crema: el manuscrito es el protagonista y cada pantalla pide
   una sola decisión. Los nombres de las variables vienen de la versión 0.6
   (navy, gold): se conservan para no tocar cada regla, pero sus valores son
   los de v3. */
:root {
  color-scheme: light;
  --navy: #1E1B16;
  --navy-2: #2A2620;
  --gold: #D9B77E;
  --gold-2: #B0923E;
  --gold-soft: #F7EEDA;
  --gold-line: #EBD9B4;
  --bg: #F3EEE3;
  --card: #FFFFFF;
  --ink: #1E1B16;
  --ink-2: #4A443A;
  --muted: #7A7266;
  --faint: #A39A8B;
  --line: #E6DFCF;
  --line-2: #CFC6B4;
  --paper: #EFEDE2;
  --paper-line: #D9D4C2;
  --ok: #2F8F57;
  --ok-soft: #ECFDF5;
  --ok-line: #BFE9D3;
  --ok-ink: #14532D;
  --warn: #7A5C05;
  --stretch: #8A4C1C;
  --stretch-soft: #F3D3B4;
  --gap: #1D4ED8;
  --gap-soft: #BFD5FF;
  --danger: #9B2C2C;
  --danger-soft: #FFF5F5;
  --danger-line: #F0C5C5;
  --shadow: 0 2px 8px rgba(30,27,22,.08);
  --shadow-lift: 0 4px 14px rgba(30,27,22,.12);
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shell: min(640px, calc(100% - 24px));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; font-family: var(--sans); background: var(--bg); color: var(--ink); padding-bottom: calc(100px + var(--safe-bottom)); }
body[data-screen="Scan"] { padding-bottom: 0; }
button, input, textarea, select { font: inherit; }
input, textarea, select { min-width: 0; max-width: 100%; }
button { border: 1px solid var(--line-2); background: #fff; color: var(--navy); border-radius: 12px; padding: .7rem 1rem; cursor: pointer; font-weight: 600; min-height: 44px; }
button:disabled { opacity: .48; cursor: not-allowed; }
.primary-action { background: var(--navy); color: #fff; border-color: var(--navy); }
.secondary-action { background: #fff; color: var(--navy); border-color: var(--line-2); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes viewIn { from { opacity: .55; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-family: var(--serif); font-size: 1.62rem; font-weight: 600; line-height: 1.18; letter-spacing: -.01em; margin: 0 0 .35rem; color: var(--navy); }
h2 { font-family: var(--serif); font-size: 1.06rem; font-weight: 600; margin: 0; color: var(--navy); letter-spacing: -.005em; }
p { line-height: 1.55; margin: 0; }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .09em; font-size: .62rem; font-weight: 700; color: var(--muted); }
.muted, .privacy { color: var(--muted); font-size: .8rem; }
.field-label { text-transform: uppercase; letter-spacing: .07em; font-size: .62rem; font-weight: 700; color: var(--muted); }

/* ---------- Cromo ---------- */
.global-banner { position: sticky; top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 120; margin: 8px 16px 0; background: var(--navy); color: #fff; border-radius: 18px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.global-banner p { flex: 1; font-size: 13px; line-height: 1.45; margin: 0; }
.banner-dot { width: 10px; height: 10px; border-radius: 50%; background: #E6A23C; margin-top: 4px; flex: none; }
.global-banner.is-error .banner-dot { background: #C8553D; }
.banner-retry { min-height: 0; padding: 0; border: 0; background: none; color: var(--gold); font-size: 13px; font-weight: 700; }
.new-game-fab.is-disabled { background: #E2DACA; color: #9C9282; box-shadow: none; }
.app-header { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-left)) 6px max(20px, env(safe-area-inset-right)); background: var(--bg); color: var(--navy); }
.app-title { font-family: var(--serif); font-size: 2rem; font-weight: 700; margin: 0; color: var(--navy); letter-spacing: 0; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--navy); color: var(--gold); border-radius: 50%; font-size: 17px; flex: none; }
.header-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.install-button { background: transparent; color: var(--navy); border-color: var(--line-2); border-radius: 999px; padding: .4rem .8rem; min-height: 34px; font-size: .74rem; }
.status { white-space: nowrap; border-radius: 999px; padding: .32rem .62rem; font-size: .66rem; font-weight: 600; background: var(--line); color: var(--muted); border: 0; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.status.ok { display: none; }
.status.warn { background: var(--gold-soft); color: var(--warn); }
/* Nueva partida, la lectura y el resultado van a pantalla completa. */
body[data-screen="Scan"] .app-header, body[data-screen="Scan"] .bottom-nav, body[data-screen="Scan"] .new-game-fab { display: none; }
body:not([data-screen="History"]) .new-game-fab { display: none; }

.app-shell { width: var(--shell); margin: 0 auto; padding: 18px 0 32px; }
.app-view { animation: viewIn .18s ease-out; }
.intro { padding: 4px 2px 16px; }
.intro.compact-intro { padding-bottom: 12px; }
.intro p { color: var(--ink-2); font-size: .84rem; }
.card { background: var(--card); border-radius: 20px; padding: 16px; box-shadow: none; margin-bottom: 12px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head.compact-head { align-items: center; margin-bottom: 10px; }
.text-button { min-height: 36px; padding: .3rem .1rem; border: 0; background: transparent; color: var(--navy); font-size: .78rem; font-weight: 600; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.icon-button { width: 34px; height: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; color: inherit; font-size: 1.5rem; line-height: 1; display: grid; place-items: center; flex: 0 0 auto; }
.pill { font-size: .7rem; font-weight: 600; background: var(--bg); border-radius: 999px; padding: .3rem .6rem; color: var(--muted); white-space: nowrap; }

/* ---------- Captura ---------- */
/* Nueva partida (v3): una ficha grande para tu planilla y otra opcional para
   la del rival. Tocar la ficha abre la cámara. */
.new-game { min-height: calc(100vh - 40px); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); }
.new-game-top { display: flex; justify-content: space-between; align-items: flex-start; padding-top: 14px; position: relative; z-index: 20; }
.round-button { width: 38px; height: 38px; min-height: 38px; padding: 0; border: 0; border-radius: 50%; background: #E6DFCF; color: var(--navy); font-size: 20px; display: grid; place-items: center; }
.mode-sheet { position: relative; }
.mode-pill { list-style: none; cursor: pointer; border-radius: 999px; padding: 8px 14px; background: #E6DFCF; color: var(--navy); font-size: 13px; font-weight: 600; }
.mode-pill::-webkit-details-marker { display: none; }
/* v4 · 2d: la píldora abre una hoja inferior con el modo y el modelo de esta
   lectura; el resto (segunda lectura, notación) vive también en Ajustes. */
.mode-sheet[open] .mode-pill { background: var(--navy); color: #fff; }
.mode-sheet .options-body { position: fixed; left: 0; right: 0; bottom: 0; z-index: 150; max-width: 640px; margin: 0 auto; background: var(--bg); border-radius: 28px 28px 0 0; padding: 12px 16px calc(34px + var(--safe-bottom)); display: grid; gap: 12px; box-shadow: 0 0 0 100vmax rgba(30,27,22,.4); }
.mode-sheet .sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); justify-self: center; }
.quick-title { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 0; padding: 0 4px; }
.mode-sheet .segmented-pill { background: #E6DFCF; }
.mode-sheet .segmented-pill button { flex: none; }
.model-cards { display: flex; gap: 8px; }
.segmented.model-cards button { flex: 1; min-height: 0; padding: 12px; border: 0; border-radius: 14px; background: #fff; font-size: 14px; font-weight: 600; }
.segmented.model-cards button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--navy); background: #fff; color: var(--navy); font-weight: 700; }
.quick-note { font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.inline-link { min-height: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; }
.option-group { display: grid; gap: 6px; }
.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; padding: .55rem .3rem; font-size: .74rem; font-weight: 600; min-height: 40px; border-radius: 12px; border-color: var(--line-2); }
.segmented button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.new-game-title { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.1; color: var(--navy); margin: 18px 4px 0; }
.sheet-slots { margin-top: 22px; display: grid; gap: 12px; }
.sheet-slot { display: grid; gap: 8px; }
.slot-tile { position: relative; overflow: hidden; width: 100%; border: 0; text-align: left; border-radius: 26px; padding: 18px; display: flex; color: var(--navy); }
.slot-a .slot-tile { min-height: 190px; flex-direction: column; justify-content: space-between; background: #fff; box-shadow: inset 0 0 0 2px var(--navy); }
.slot-b .slot-tile { min-height: 110px; align-items: center; gap: 14px; background: #F2E6CC; box-shadow: inset 0 0 0 2px #C9A974; }
.sheet-slot[data-filled="true"] .slot-tile { background: var(--navy); color: #fff; box-shadow: none; }
.slot-b[data-filled="true"] .slot-tile { min-height: 150px; }
/* Una planilla de papel asomando: sólo cuando ya hay fotos. */
.sheet-slot[data-filled="true"] .slot-tile::after { content: ''; position: absolute; right: -18px; top: -8px; width: 130px; height: 180px; transform: rotate(8deg); border-radius: 10px; background: repeating-linear-gradient(0deg, #EFEDE2 0 9px, #D9D4C2 9px 10px); }
.slot-b[data-filled="true"] .slot-tile::after { width: 110px; height: 160px; transform: rotate(-6deg); }
.slot-chip { position: relative; z-index: 1; display: grid; place-items: center; font-weight: 700; flex: none; }
.slot-a .slot-chip { width: 32px; height: 32px; border-radius: 10px; background: var(--navy); color: #fff; }
.slot-a[data-filled="true"] .slot-chip { background: #fff; color: var(--navy); }
.slot-b .slot-chip { width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: var(--navy); font-size: 24px; font-weight: 600; }
.slot-copy { position: relative; z-index: 1; display: grid; gap: 2px; }
.slot-copy strong { font-size: 19px; font-weight: 700; }
.slot-b .slot-copy strong { font-size: 17px; }
.slot-copy span { font-size: 13px; font-weight: 600; color: var(--muted); }
.slot-b .slot-copy span { color: #6B4A2E; }
.sheet-slot[data-filled="true"] .slot-copy span { color: var(--gold); }
.slot-tools { display: flex; justify-content: space-between; padding: 0 6px; }
.link-button { min-height: 32px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
/* Las fotos de cada planilla, en una tira de miniaturas bajo su ficha. */
.sheet-slot .preview-wrap.multi { display: flex; gap: 8px; overflow-x: auto; padding: 2px 6px 4px; }
.sheet-slot .preview-item { flex: 0 0 52px; }
.sheet-slot .preview-item img { border-radius: 8px; box-shadow: 0 0 0 1px var(--line-2); }
.sheet-slot .preview-tools { top: -6px; right: -6px; gap: 2px; }
.sheet-slot .preview-tools button { width: 22px; height: 22px; min-height: 22px; font-size: .7rem; }
.new-game-foot { margin-top: auto; padding: 18px 0 calc(18px + var(--safe-bottom)); display: grid; gap: 10px; }
.new-game-hint { text-align: center; font-size: 12.5px; color: var(--muted); }
.build-cta { width: 100%; height: 58px; border: 0; border-radius: 18px; background: var(--gold); color: var(--navy); font-size: 17px; font-weight: 700; }
.build-cta:disabled { background: #E2DACA; color: #9C9282; opacity: 1; }
.new-game .privacy { margin: 0; text-align: center; }

.preview-wrap.multi { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.preview-item { position: relative; margin: 0; min-width: 0; }
.preview-item img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; background: var(--paper); }
.preview-item figcaption { display: none; }
.preview-tools { position: absolute; top: 3px; right: 3px; display: flex; gap: 3px; }
.preview-tools button { width: 26px; height: 26px; min-height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(30,27,22,.82); color: #fff; display: grid; place-items: center; font-size: .8rem; }

.privacy { margin: 10px 2px 12px; font-size: .7rem; line-height: 1.5; }

.scan-cta { width: 100%; min-height: 52px; border: 0; border-radius: 18px; background: var(--gold); color: var(--navy); display: grid; place-items: center; align-content: center; gap: 2px; font-weight: 700; font-size: .98rem; }
.scan-cta small { font-size: .7rem; font-weight: 500; color: rgba(30,27,22,.72); }
.scan-cta:disabled { background: #DFE2E8; color: #94A0B4; }
.scan-cta:disabled small { color: #94A0B4; }
.scan-cta.compact { min-height: 48px; font-size: .92rem; }
.error { margin: 0 0 12px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); border-radius: 6px; padding: 11px 13px; font-size: .82rem; line-height: 1.5; }

/* ---------- Barra de trabajo (la rellena progress-patch.js) ---------- */
.busy { position: sticky; top: 0; z-index: 105; display: flex; align-items: center; gap: 12px; padding: calc(11px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-left)) 11px max(14px, env(safe-area-inset-right)); background: var(--navy); color: #fff; box-shadow: 0 8px 22px rgba(30,27,22,.28); }
.busy strong { font-family: var(--serif); font-size: .95rem; font-weight: 600; }
.busy p { margin: 2px 0 0; color: rgba(255,255,255,.62); font-size: .72rem; }
.busy .muted, .busy small { color: rgba(255,255,255,.55); font-size: .68rem; }
.busy .scan-progress-copy { flex: 1; min-width: 0; }
.busy .scan-cancel { flex: 0 0 auto; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff; min-height: 38px; padding: .4rem .8rem; font-size: .76rem; }
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(201,168,76,.3); border-top-color: var(--gold); border-radius: 50%; animation: spin .9s linear infinite; flex: 0 0 auto; }

/* ---------- Espera ---------- */
.wait-screen { display: grid; gap: 12px; padding-top: 8px; }
.wait-grid-card { display: flex; gap: 12px; align-items: stretch; }
.wait-grid-preview { flex: 0 0 118px; border-radius: 6px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--paper-line); padding: 6px; display: grid; place-items: center; overflow: hidden; }
.wait-grid-preview img { width: 100%; max-height: 190px; object-fit: contain; border-radius: 3px; }
.grid-skeleton { width: 100%; height: 160px; display: grid; grid-template-rows: repeat(11, 1fr); gap: 3px; padding: 4px 2px; }
.grid-skeleton span { display: block; border-radius: 2px; background: rgba(30,27,22,.09); box-shadow: inset 0 0 0 1px rgba(30,27,22,.06); }
.wait-grid-copy { flex: 1; min-width: 0; display: grid; align-content: start; gap: 6px; }
.wait-grid-copy p { font-size: .74rem; line-height: 1.5; color: var(--ink-2); }
.wait-grid-summary { font-size: .76rem !important; color: var(--navy) !important; font-weight: 600; }
.wait-grid-summary.ok { color: #2F6B4F !important; }
.wait-grid-summary.warn { color: var(--warn) !important; }
.wait-meta-card { display: grid; gap: 10px; }
.wait-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wait-meta-grid label:first-child, .wait-meta-grid label:nth-child(2) { grid-column: 1 / -1; }
.wait-meta-card p { font-size: .74rem; }

/* «Leyendo…» (v4 · 4a): fondo de tinta, la planilla con la línea de escaneo y
   los pasos reales (✓ hecho, ● en curso, ○ pendiente). La barra es
   indeterminada: no hay un porcentaje honesto en una llamada de 60-130 s. La
   barra de progress-patch.js se oculta: esta pantalla la sustituye. */
body.reading { background: var(--navy); }
body.reading .busy { display: none !important; }
body.reading .app-shell { padding-top: 0; }
.wait-screen { color: #fff; gap: 0; padding-top: env(safe-area-inset-top, 0px); min-height: 100vh; display: flex !important; flex-direction: column; }
.wait-screen.hidden { display: none !important; }
.read-top { display: flex; justify-content: flex-end; padding: 14px 0 0; }
.read-cancel { min-height: 0; padding: 8px 14px; border: 0; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 600; }
.read-hero { display: flex; gap: 16px; align-items: center; padding: 18px 8px 0; }
.read-sheet { position: relative; overflow: hidden; flex: none; width: 72px; height: 96px; border-radius: 10px; background: repeating-linear-gradient(0deg, #EFEDE2 0 6px, #D9D4C2 6px 7px); }
.read-sheet span { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: readscan 2.4s ease-in-out infinite; }
@keyframes readscan { 0%, 100% { top: 0; } 50% { top: calc(100% - 3px); } }
.read-copy { flex: 1; display: grid; gap: 6px; min-width: 0; }
.read-copy strong { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.read-copy > span { font-size: 13px; color: rgba(255,255,255,.7); }
.read-bar { position: relative; overflow: hidden; height: 4px; border-radius: 2px; background: rgba(255,255,255,.15); }
.read-bar span { position: absolute; top: 0; bottom: 0; width: 40%; border-radius: 2px; background: var(--gold); animation: readbar 1.6s linear infinite; }
@keyframes readbar { from { left: -40%; } to { left: 100%; } }
.read-steps { list-style: none; margin: 22px 8px 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.read-steps li { display: flex; gap: 10px; color: rgba(255,255,255,.35); }
.read-steps li::before { content: '○'; width: 12px; }
.read-steps li[data-status="done"] { color: rgba(255,255,255,.55); }
.read-steps li[data-status="done"]::before { content: '✓'; color: var(--gold); }
.read-steps li[data-status="doing"] { color: #fff; font-weight: 700; }
.read-steps li[data-status="doing"]::before { content: '●'; color: var(--gold); }
.read-note { margin: 4px 8px 0 30px; font-size: 12px; color: rgba(255,255,255,.4); }
.wait-screen.has-error .read-steps, .wait-screen.has-error .read-note, .wait-screen.has-error .read-copy > span, .wait-screen.has-error .read-bar, .wait-screen.has-error .read-cancel, .wait-screen.has-error .read-sheet span { display: none; }
.read-error { margin: 20px 0 0; background: #fff; color: var(--navy); border-radius: 22px; padding: 16px; display: grid; gap: 6px; }
.read-error strong { font-size: 15px; }
.read-error span { font-size: 13px; color: #5A5247; }
.read-error-actions { display: flex; gap: 8px; margin-top: 4px; }
.chip-action, .chip-back { min-height: 0; padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.chip-action { border: 0; background: var(--gold); color: var(--navy); font-weight: 700; }
.chip-back { border: 1px solid var(--line-2); background: transparent; color: var(--navy); font-weight: 600; }
.read-meta { margin: 24px calc((100vw - var(--shell)) / -2) 0; padding: 20px max(16px, calc((100vw - var(--shell)) / 2)) calc(34px + var(--safe-bottom)); background: var(--bg); color: var(--navy); border-radius: 28px 28px 0 0; flex: 1; display: grid; gap: 10px; align-content: start; }
.read-meta h2 { font-size: 20px; font-weight: 700; padding: 0 4px; }
.read-meta .wait-meta-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
.read-meta .wait-meta-grid label:first-child, .read-meta .wait-meta-grid label:nth-child(2) { grid-column: auto; }
.meta-field { background: #fff; border-radius: 14px; padding: 9px 12px; font-size: 11px; font-weight: 400; color: var(--muted); gap: 0; }
.meta-field input { border: 0; padding: 0; min-height: 24px; font-size: 15px; font-weight: 600; color: var(--navy); background: transparent; border-radius: 0; }
.meta-field input:focus-visible { outline: none; }
.meta-field:focus-within { box-shadow: inset 0 0 0 2px var(--navy); }
.meta-result { padding: 4px; display: flex; align-items: center; }
.result-segments { flex: 1; display: flex; gap: 3px; }
.result-segments button { flex: 1; min-height: 0; padding: 8px 0; border: 0; border-radius: 10px; background: transparent; font-size: 13px; font-weight: 600; color: var(--navy); }
.result-segments button[aria-pressed="true"] { background: var(--navy); color: #fff; font-weight: 700; }
.read-meta .muted { padding: 0 4px; font-size: 12px; }
.danger-text { color: #9B2C2C !important; }

label { display: grid; gap: 4px; color: var(--ink-2); font-size: .66rem; font-weight: 600; }
select, input { width: 100%; border: 1px solid var(--line-2); border-radius: 12px; padding: .62rem .7rem; background: #fff; color: var(--navy); min-height: 44px; }

/* ---------- Resultado: cabecera y pasos ---------- */
.result-section { display: grid; gap: 12px; }
.result-topbar { display: flex; align-items: center; gap: 8px; background: var(--navy); color: #fff; border-radius: 20px; padding: 12px 14px; margin-top: env(safe-area-inset-top, 0px); }
.result-topbar-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.result-topbar-copy strong { font-family: var(--serif); font-size: .98rem; font-weight: 600; line-height: 1.22; }
.result-topbar-copy span { font-size: .68rem; color: rgba(255,255,255,.62); line-height: 1.4; }
.completion-badge { flex: 0 0 auto; font-size: .68rem; font-weight: 700; padding: .28rem .6rem; border-radius: 999px; background: rgba(201,168,76,.18); color: var(--gold); white-space: nowrap; }
.completion-badge.done { background: rgba(45,211,111,.18); color: #7BE3A6; }

.steps { list-style: none; display: flex; gap: 8px; margin: 0; padding: 12px 14px 10px; background: #fff; border-radius: 16px; box-shadow: none; }
.steps li { flex: 1; display: grid; gap: 5px; }
.steps span { font-size: .62rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.steps i { height: 3px; border-radius: 2px; background: var(--line); display: block; }
.steps li.current span { color: var(--navy); font-weight: 700; }
.steps li.current i { background: var(--gold); }
.steps li.done span { color: var(--ok); }
.steps li.done i { background: var(--ok); }
.result-step { display: grid; gap: 12px; }
.review-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.review-workload { margin: 0 0 12px; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* ---------- Tarjetas de duda ---------- */
.issues { display: grid; gap: 12px; }
.issue { background: #fff; border-radius: 8px; box-shadow: var(--shadow-lift); padding: 14px; display: grid; gap: 12px; }
.issue-head { display: grid; gap: 3px; }
.issue-head strong { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; color: var(--navy); line-height: 1.25; }
.raw { color: var(--muted); font-size: .72rem; }
.issue p { color: var(--ink-2); margin: 0; font-size: .78rem; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reason { display: inline-block; border-radius: 999px; padding: .25rem .55rem; font-size: .68rem; font-weight: 500; background: var(--bg); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.reason:first-child { background: var(--gold-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--gold-line); }

/* El manuscrito manda: los recortes de A y B van arriba y a lo grande. */
.evidence-crops { display: flex; gap: 8px; }
.evidence-crop-cell { flex: 1; min-width: 0; display: grid; gap: 4px; }
.evidence-crop-cell .crop-label { font-size: .6rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.evidence-crop { width: 100%; height: 92px; object-fit: contain; border-radius: 6px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--paper-line); }
.evidence-crops.compact .evidence-crop { height: 56px; }
.crop-placeholder { height: 92px; border-radius: 6px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--paper-line); display: grid; place-items: center; font-size: .68rem; color: #8A8266; text-align: center; padding: 6px; }
.evidence-read { font-size: .72rem; color: var(--muted); line-height: 1.5; }
.evidence-read b { color: var(--navy); }

.issue-body { display: flex; gap: 12px; align-items: center; }
.issue-body .mini-board { flex: 0 0 138px; }
.issue-controls { display: grid; gap: 8px; }
.issue-explain { flex: 1; min-width: 0; display: grid; gap: 6px; }
.confirm-move { width: 100%; background: var(--navy); color: #fff; border-color: var(--navy); font-size: 1.12rem; font-weight: 700; min-height: 56px; }
.confirm-move .check { color: var(--gold); margin-left: 8px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.choice { width: 100%; font-size: .88rem; font-weight: 600; min-height: 46px; }
.other-move-row { display: grid; gap: 8px; }
.other-move-row > .text-button { justify-self: stretch; border: 1px solid var(--line-2); border-radius: 4px; min-height: 46px; text-decoration: none; font-weight: 500; }
.other-move-row > .text-button[aria-expanded="true"] { background: var(--gold-soft); border-color: var(--gold); }
.other-move { display: grid; gap: 10px; }
.skip-target { justify-self: center; color: var(--muted); text-decoration: none; }

.stretch-card, .gap-card { padding: 0; overflow: hidden; gap: 0; }
.stretch-card > .card-banner, .gap-card > .card-banner { padding: 14px; display: flex; gap: 10px; align-items: flex-start; color: #fff; }
.stretch-card > .card-banner { background: var(--stretch); }
.gap-card > .card-banner { background: var(--gap); }
.card-banner .banner-icon { font-size: 1.05rem; line-height: 1.2; flex: 0 0 auto; }
.stretch-card .card-banner .banner-icon { color: var(--stretch-soft); }
.gap-card .card-banner .banner-icon { color: var(--gap-soft); }
.card-banner .eyebrow { color: rgba(255,255,255,.78); margin-bottom: 3px; }
.card-banner strong { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; line-height: 1.25; }
.card-body { padding: 14px; display: grid; gap: 11px; }
.stretch-plies { display: grid; gap: 8px; }
.stretch-ply-row { display: flex; align-items: center; gap: 8px; }
.stretch-ply-row .stretch-ply-label { flex: 0 0 84px; font-size: .72rem; font-weight: 600; color: var(--muted); }
.stretch-ply-row select { flex: 1; min-width: 0; }
.card-body .actions { display: flex; gap: 6px; margin: 0; }
.card-body .actions button { flex: 1; }

.success { background: var(--ok-soft); border-radius: 8px; padding: 14px; display: flex; align-items: center; gap: 11px; box-shadow: inset 0 0 0 1px var(--ok-line); }
.success-mark { width: 34px; height: 34px; border-radius: 999px; background: var(--ok); color: #fff; display: grid; place-items: center; flex: 0 0 auto; font-size: .95rem; }
.success strong { display: block; font-family: var(--serif); font-size: 1.02rem; font-weight: 600; color: var(--ok-ink); }
.success small { font-size: .74rem; color: #2F6B4F; }
.review-done { display: grid; gap: 10px; }
.alignment-warning { background: var(--gold-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--gold-line); border-radius: 8px; padding: 11px 13px; font-size: .78rem; line-height: 1.5; }

.refine-row { display: grid; gap: 6px; margin-top: 4px; }
.refine-row .secondary-action { font-size: .82rem; }
.refine-hint, .refine-row .muted { margin: 0; font-size: .68rem; text-align: center; color: var(--muted); line-height: 1.45; }

/* ---------- Tableros ---------- */
.mini-board { container-type: inline-size; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); grid-template-rows: repeat(8, minmax(0,1fr)); overflow: hidden; border-radius: 6px; box-shadow: 0 0 0 1px #D8DCE4; width: 100%; font-family: 'Arial Unicode MS', 'Segoe UI Symbol', sans-serif; }
.mini-board .light { background: #EDEBD3; }
.mini-board .dark { background: #7D9A5C; }
.mini-board .move-from, .mini-board .move-to { background: #E6D36A; }
.mini-board-wrap { display: grid; gap: 10px; max-width: 440px; width: 100%; margin: 0 auto; }
.mini-board.interactive button { border: 0; padding: 0; margin: 0; border-radius: 0; font-family: inherit; }
.mini-board.interactive button.selected { box-shadow: inset 0 0 0 3px var(--navy); }
.mini-board.interactive button.target { box-shadow: inset 0 0 0 2px var(--gold); }
.promotion-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.promotion-row.hidden { display: none; }

/* ---------- Visor ---------- */
.game-viewer { gap: 0; }
/* v3: la partida leída es un tablero grande sobre tinta y una hoja inferior
   crema con la navegación, el recorte y las jugadas en fichas. */
body.viewing { background: var(--navy); }
body.viewing .result-topbar { background: transparent; padding: calc(4px + env(safe-area-inset-top, 0px)) 0 4px; }
body.viewing .result-topbar .icon-button { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 20px; }
body.viewing .result-topbar-copy { text-align: center; }
body.viewing .result-topbar-copy span { display: none; }
body.viewing .steps { display: none; }
body.viewing .app-shell { padding-bottom: 0; }
.viewer-stage { display: grid; place-items: center; padding: 8px 0 20px; }
.viewer-board { width: min(100%, 360px); }
.viewer-board .mini-board { border-radius: 12px; box-shadow: none; }
.viewer-sheet { margin: 0 calc((100vw - var(--shell)) / -2); padding: 10px max(16px, calc((100vw - var(--shell)) / 2)) calc(24px + var(--safe-bottom)); background: var(--bg); border-radius: 28px 28px 0 0; display: grid; gap: 12px; min-height: 46vh; align-content: start; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); justify-self: center; }
.viewer-nav { display: grid; grid-template-columns: 50px 1fr 50px; gap: 10px; align-items: center; }
.viewer-nav button { height: 44px; min-height: 44px; border-radius: 14px; border: 0; font-size: 20px; padding: 0; }
.viewer-nav .nav-prev { background: #E4DCCB; color: var(--navy); }
.viewer-nav .nav-next { background: var(--navy); color: #fff; }
.viewer-move-info { display: grid; justify-items: center; gap: 2px; text-align: center; }
.viewer-move-info span:first-child { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--navy); }
.viewer-move-info .reason { background: none; box-shadow: none; border: 0; padding: 0; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; text-transform: none; }
.viewer-move-info .reason.is-doubt { color: #8A4C1C; font-weight: 700; }
.viewer-evidence-col { display: grid; gap: 8px; }
.viewer-evidence-col .evidence-crop { height: 160px; border-radius: 8px; }
.viewer-evidence-col:not(:has(.evidence-crops)) .text-button { justify-self: center; }
.viewer-evidence-col .text-button { justify-self: start; }
.viewer-moves { display: flex; flex-wrap: wrap; gap: 4px 2px; align-content: flex-start; max-height: 32vh; overflow-y: auto; padding-bottom: 4px; }
.viewer-row { display: contents; }
.viewer-move-number { display: none; }
.viewer-move { width: auto; min-height: 0; border: 0; border-radius: 8px; padding: 6px 8px; font-size: 14px; font-weight: 500; background: transparent; color: var(--navy); }
.viewer-move .move-number { color: var(--muted); font-weight: 500; }
.viewer-move.has-doubt { background: #EFE0B8; }
.viewer-move.current { background: var(--navy); color: #fff; font-weight: 700; }
.viewer-move.current .move-number { color: rgba(255,255,255,.7); }
.doubt-dot { display: none; }
.viewer-actions { display: flex; gap: 10px; padding-top: 4px; }
.sheet-secondary { flex: 1; height: 52px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--navy); font-size: 15px; font-weight: 600; }
.sheet-primary { flex: 2; height: 52px; border-radius: 999px; border: 0; background: var(--gold); color: var(--navy); font-size: 15px; font-weight: 700; }

/* ---------- Metadatos y PGN ---------- */
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metadata-grid label.wide { grid-column: 1 / -1; }
.pgn-actions { display: flex; gap: 12px; }
textarea { width: 100%; border: 0; border-radius: 4px; padding: 10px; resize: vertical; min-height: 120px; background: var(--bg); color: var(--ink-2); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .72rem; line-height: 1.6; }
textarea.reference { min-height: 110px; background: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.pgn-card textarea { min-height: 150px; }
.new-scan { width: 100%; border: 0; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 600; margin-top: -4px; }
.done-success { margin-bottom: 0; }

/* ---------- Partidas (v3) ---------- */
.games { display: grid; gap: 10px; padding-top: 8px; padding-bottom: 150px; }
.pending-card { border: 0; text-align: left; background: var(--navy); border-radius: 24px; padding: 16px 18px; color: #fff; display: grid; gap: 10px; }
.pending-top { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--gold); }
.pending-top span:last-child { font-weight: 400; letter-spacing: 0; color: rgba(255,255,255,.6); font-size: 12px; }
.pending-title { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.pending-chips { display: flex; gap: 8px; }
.chip-gold { padding: 6px 12px; border-radius: 999px; background: var(--gold); color: var(--navy); font-size: 13px; font-weight: 700; }
.chip-ghost { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: 13px; }
.history-list { display: grid; gap: 10px; }
.history-item { position: relative; overflow: hidden; border-radius: 20px; background: #9B2C2C; }
/* v4 · 7b: deslizar a la izquierda descubre «Borrar» detrás de la fila. */
.open-game { position: relative; z-index: 1; width: 100%; min-width: 0; border: 0; background: #fff; text-align: left; padding: 14px 16px; display: flex; gap: 12px; align-items: center; border-radius: 20px; color: var(--navy); transition: transform .2s ease; touch-action: pan-y; }
.history-item.swiped .open-game { transform: translateX(-84px); border-radius: 20px 0 0 20px; }
.open-game i { color: #B5AC9C; font-style: normal; font-size: 18px; }
.delete-game { position: absolute; right: 0; top: 0; bottom: 0; width: 84px; min-height: 0; border: 0; border-radius: 0; background: #9B2C2C; color: #fff; font-size: 13px; font-weight: 700; padding: 0; }
.history-item.is-provisional { background: #9B2C2C; }
.history-item.is-provisional .open-game { box-shadow: inset 0 0 0 1.5px #E6A23C; }
.history-item.is-provisional .result-badge { background: transparent; border: 1.5px dashed #E6A23C; color: #B07A1E; }
.history-item.is-provisional .history-main span { color: #B07A1E; font-weight: 600; }
.result-badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; background: #EAE3D3; color: var(--navy); }
.result-badge[data-tone="win"] { background: var(--navy); color: var(--gold); }
.result-badge[data-tone="draw"] { background: #E3EBD8; color: #4E7A3A; }
.history-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.history-main strong { font-size: 15.5px; font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-main span { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.history-count { font-size: 13px; color: var(--muted); }
body:not([data-screen="History"]) .history-count { display: none; }
.limit-note { background: #F2E6CC; border-radius: 16px; padding: 11px 14px; font-size: 13px; color: #6B4A2E; line-height: 1.45; }
.empty-state { text-align: center; display: grid; place-items: center; gap: 12px; padding: 90px 30px 20px; color: var(--muted); }
.empty-state strong { color: var(--navy); font-family: var(--serif); font-size: 22px; }
.empty-state p { margin: 0; max-width: 300px; font-size: 14px; line-height: 1.5; }
.empty-sheet { width: 84px; height: 110px; border-radius: 10px; background: repeating-linear-gradient(0deg, #EFEDE2 0 8px, #D9D4C2 8px 9px); transform: rotate(-6deg); }
.oldest-row { background: var(--bg); border-radius: 14px; padding: 10px 12px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.games-foot { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.new-game-fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(102px + var(--safe-bottom)); z-index: 112; height: 60px; border: 0; border-radius: 20px; background: var(--gold); color: var(--navy); display: flex; align-items: center; gap: 10px; padding: 0 22px; box-shadow: 0 10px 24px rgba(120,85,40,.45); font-size: 16px; font-weight: 700; }
.new-game-fab:active { transform: scale(.96); }
.fab-icon { width: 20px; height: 16px; border-radius: 4px; border: 2.5px solid currentColor; }

/* ---------- Ajustes (v4 · 2a) ---------- */
.settings { display: grid; gap: 10px; padding: 4px 0 120px; }
.settings-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 4px 0; }
.settings-card { background: #fff; border-radius: 20px; padding: 6px; display: grid; gap: 4px; }
.segmented-pill { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border-radius: 14px; padding: 4px; }
.segmented-pill button { min-height: 0; border: 0; border-radius: 11px; padding: 9px 10px; font-size: 13px; font-weight: 600; background: transparent; color: #5A5247; }
.segmented-pill button[aria-pressed="true"] { background: var(--navy); color: #fff; font-weight: 700; }
.settings-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 0; padding: 12px 10px; border: 0; border-radius: 0; background: transparent; color: var(--navy); font-size: 14.5px; font-weight: 400; text-align: left; border-bottom: 1px solid #EFE9DC; }
.settings-line:last-child { border-bottom: 0; }
.settings-value { color: var(--muted); }
.notation-chips { display: flex; gap: 6px; }
.notation-chip { min-height: 0; border: 0; border-radius: 999px; padding: 5px 9px; font-size: 12.5px; font-weight: 600; background: #F2E6CC; color: var(--navy); }
.notation-chip[data-english="true"] { background: #EFE9DC; }
.settings-account { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.settings-title { display: block; font-size: 14.5px; color: var(--navy); }
.settings-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.settings-sub.is-saved { color: #4E7A3A; }
.account-button { min-height: 0; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--navy); color: var(--gold); font-size: 12.5px; font-weight: 700; }
.account-button.is-saved { background: transparent; color: var(--muted); font-weight: 600; }
.settings-install, .lab-entry { width: 100%; min-height: 0; padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; text-align: left; font-weight: 400; }
.settings-install { border: 0; }
.settings-install i, .lab-entry i { font-style: normal; color: #B5AC9C; }
.lab-entry { background: transparent; border: 1px dashed var(--line-2); border-radius: 20px; }
.lab-entry .settings-title { color: #5A5247; font-size: 14px; }
.lab-entry .settings-sub { color: var(--faint); font-size: 12px; }
.settings-foot { margin: 10px 0 0; font-size: 12px; color: var(--faint); text-align: center; }

/* ---------- Diálogos v4: tarjeta centrada y hoja inferior ---------- */
.v4-dialog { width: min(420px, calc(100% - 40px)); border: 0; border-radius: 26px; padding: 0; background: #fff; color: var(--navy); }
.v4-dialog::backdrop, .sheet-dialog::backdrop { background: rgba(30,27,22,.45); }
.v4-dialog form { padding: 22px; display: grid; gap: 14px; }
.v4-dialog h2, .sheet-dialog h2 { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 0; }
.v4-dialog p { margin: 0; font-size: 14px; line-height: 1.5; color: #5A5247; }
.access-input { height: 50px; border-radius: 14px; border: 2px solid var(--navy); font: 16px ui-monospace, monospace; letter-spacing: .2em; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-secondary, .dialog-primary, .dialog-danger { flex: 1; height: 48px; min-height: 48px; border-radius: 999px; font-size: 15px; }
.dialog-secondary { border: 1px solid var(--line-2); background: transparent; color: var(--navy); font-weight: 600; }
.dialog-primary { border: 0; background: var(--gold); color: var(--navy); font-weight: 700; }
.dialog-primary.dark { background: var(--navy); color: var(--gold); }
.dialog-danger { border: 0; background: #9B2C2C; color: #fff; font-weight: 700; }
.sheet-dialog { width: 100%; max-width: 640px; margin: auto auto 0; border: 0; border-radius: 28px 28px 0 0; padding: 0; background: var(--bg); color: var(--navy); }
.sheet-dialog form { padding: 12px 16px calc(34px + var(--safe-bottom)); display: grid; gap: 10px; }
.sheet-dialog .sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); justify-self: center; }
.sheet-dialog h2 { padding: 4px 4px 0; }
.choice-list { background: #fff; border-radius: 18px; padding: 4px; display: grid; }
.choice-row { min-height: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 12px; border: 0; border-bottom: 1px solid #EFE9DC; border-radius: 0; background: transparent; text-align: left; }
.choice-row:last-child { border-bottom: 0; }
.choice-row strong { display: block; font-size: 15px; font-weight: 600; }
.choice-row small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.choice-row i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-style: normal; font-size: 12px; }
.choice-row[aria-pressed="true"] i { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.lab-topbar { display: flex; align-items: center; gap: 8px; background: var(--navy); color: #fff; border-radius: 20px; padding: 12px 14px; margin-bottom: 12px; }

/* ---------- Laboratorio ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metric { border-radius: 6px; background: var(--bg); padding: 9px; min-width: 0; }
.metric span { display: block; color: var(--muted); font-size: .62rem; margin-bottom: 3px; }
.metric strong { font-size: 1.05rem; letter-spacing: -.02em; overflow-wrap: anywhere; color: var(--navy); }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.actions.wrap { flex-wrap: wrap; }
.model-compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.model-run { border-radius: 8px; padding: 12px; background: var(--bg); }
.model-run h3 { margin: 0 0 8px; font-family: var(--serif); font-size: .95rem; color: var(--navy); }
.model-run .model-metrics { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; margin: 8px 0; }
.model-run .model-metrics > div { background: #fff; border-radius: 6px; padding: 7px; }
.model-run .model-metrics span { display: block; color: var(--muted); font-size: .62rem; }
.model-run .model-metrics b { font-size: .92rem; color: var(--navy); }
.model-run .verdict { margin: 8px 0; font-size: .74rem; color: var(--ink-2); }
.evaluation { margin-top: 12px; }
.eval-head { display: flex; justify-content: space-between; gap: 12px; border-radius: 6px; padding: 11px 12px; font-size: .78rem; }
.eval-head.pass { background: var(--ok-soft); color: var(--ok-ink); }
.eval-head.fail { background: var(--gold-soft); color: var(--warn); }
.error-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-top: 9px; }
.error-grid > div { background: var(--bg); border-radius: 6px; padding: 8px; display: grid; gap: 2px; }
.error-grid b { font-size: 1.05rem; color: var(--navy); }
.error-grid span { color: var(--muted); font-size: .62rem; }
.mismatch-list { display: grid; gap: 5px; margin-top: 9px; }
.mismatch { display: grid; grid-template-columns: 50px 140px 1fr; gap: 8px; padding: 8px 9px; border-radius: 6px; font-size: .72rem; background: var(--bg); }
.mismatch.recognition { border-left: 3px solid var(--danger); }
.mismatch.reconstruction { border-left: 3px solid var(--gold-2); }
.mismatch.alignment { border-left: 3px solid #5B62A3; }
.debug summary { cursor: pointer; font-weight: 600; font-size: .8rem; }
.debug pre { overflow: auto; max-height: 460px; font-size: .64rem; line-height: 1.4; background: #10151A; color: #DFE9E5; padding: 10px; border-radius: 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .72rem; margin-top: 10px; }
th, td { text-align: left; padding: 8px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; }

.segmentation-diagnostics { display: grid; gap: 12px; margin-top: 12px; }
.segmentation-case { border-radius: 8px; padding: 12px; background: var(--bg); }
.segmentation-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.segmentation-head strong { display: block; font-size: .85rem; color: var(--navy); }
.segmentation-head span:not(.seg-confidence) { display: block; color: var(--muted); font-size: .66rem; margin-top: 2px; }
.seg-confidence { border-radius: 999px; padding: .3rem .55rem; font-size: .66rem; font-weight: 700; white-space: nowrap; }
.seg-confidence.pass { background: var(--ok-soft); color: var(--ok-ink); }
.seg-confidence.fallback { background: var(--gold-soft); color: var(--warn); }
.seg-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-bottom: 10px; }
.seg-metrics > div { background: #fff; border-radius: 6px; padding: 7px; display: grid; gap: 1px; }
.seg-metrics b { font-size: .9rem; color: var(--navy); }
.seg-metrics span { color: var(--muted); font-size: .6rem; }
.seg-gallery { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; max-height: 520px; overflow: auto; }
.seg-gallery figure { margin: 0; border-radius: 6px; overflow: hidden; background: #fff; }
.seg-gallery img { width: 100%; display: block; max-height: 240px; object-fit: contain; background: var(--paper); }
.seg-gallery figcaption { padding: 6px 8px; color: var(--muted); font-size: .62rem; }
.seg-warnings { display: grid; gap: 4px; margin-top: 9px; font-size: .7rem; color: var(--warn); }
.seg-warnings .ok-note { color: var(--ok); }

/* ---------- Navegación inferior (v3): píldora flotante ---------- */
.bottom-nav { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%); z-index: 110; height: 58px; border-radius: 999px; background: rgba(30,27,22,.95); display: flex; gap: 6px; padding: 6px; box-shadow: 0 10px 26px rgba(30,27,22,.35); }
.nav-item { min-height: 0; border: 0; border-radius: 999px; background: transparent; color: rgba(255,255,255,.65); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; font-size: 13px; font-weight: 700; }
.nav-item small { font: inherit; }
.nav-item.active { background: var(--gold); color: var(--navy); padding: 0 18px; }
.nav-icon { display: inline-block; flex: none; }
.nav-icon-settings::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: currentColor; }

/* ---------- Cámara (v4 · 3): guía de encuadre, revisión y permiso ---------- */
.camera-screen { position: fixed; inset: 0; z-index: 140; background: repeating-linear-gradient(135deg, #24211C 0 10px, #1D1B17 10px 20px); color: #fff; animation: viewIn .2s ease-out; }
.camera-screen[data-state="verdict"], .camera-screen[data-state="analyzing"], .camera-screen[data-state="denied"] { background: var(--navy); }
/* contain, no cover: la foto captura el fotograma entero y la pantalla debe
   enseñar exactamente eso, con los tres bloques visibles. */
.camera-screen video, .camera-screen canvas, .camera-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera-top { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.camera-round { width: 38px; height: 38px; min-height: 38px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 20px; display: grid; place-items: center; }
.camera-system { font-size: 15px; }
.camera-title { padding: 8px 14px; border-radius: 999px; background: rgba(0,0,0,.45); font-size: 13px; font-weight: 600; }
.camera-done { min-height: 38px; height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--gold); color: var(--navy); font-size: 13px; font-weight: 700; }
.camera-advice { position: absolute; left: 50%; transform: translateX(-50%); top: calc(66px + env(safe-area-inset-top, 0px)); z-index: 2; max-width: calc(100% - 40px); text-align: center; padding: 10px 16px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: 13.5px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.camera-advice[data-tone="warn"] { background: #E6A23C; color: var(--navy); border-radius: 18px; }
.camera-advice[data-tone="steady"], .camera-advice[data-tone="good"] { background: var(--gold); color: var(--navy); }
.camera-advice[data-tone="steady"]::before { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--navy); border-right-color: transparent; animation: spin .9s linear infinite; }
.camera-advice[data-tone="ok"] { background: #4E7A3A; color: #fff; }
.camera-flip { position: absolute; left: 40px; right: 40px; top: 36%; display: grid; justify-items: center; gap: 16px; text-align: center; z-index: 2; }
.camera-flip span { width: 72px; height: 72px; border-radius: 50%; background: #E6A23C; color: var(--navy); display: grid; place-items: center; font-size: 36px; font-weight: 700; }
.camera-flip strong { font-family: var(--serif); font-size: 22px; line-height: 1.25; }
.camera-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 30px calc(34px + var(--safe-bottom)); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(transparent, rgba(0,0,0,.85) 45%); }
.camera-screen:not([data-state="live"]) .live-only { display: none; }
.camera-side { min-height: 0; padding: 0; border: 0; background: none; color: #fff; display: grid; justify-items: center; gap: 4px; font-size: 11px; font-weight: 600; }
.camera-thumb { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255,255,255,.7); background: center / cover no-repeat; }
.camera-count { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--navy); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.camera-shutter { width: 80px; height: 80px; min-height: 80px; border-radius: 50%; border: 4px solid rgba(255,255,255,.5); background: transparent; padding: 4px; }
.camera-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: rgba(255,255,255,.3); }
.camera-shutter[data-ready="true"] { border-color: var(--gold); }
.camera-shutter[data-ready="true"] span { background: #fff; }
.camera-shutter:active { transform: scale(.92); }
.auto-switch { width: 44px; height: 26px; border-radius: 999px; background: rgba(255,255,255,.2); padding: 3px; display: flex; }
.auto-switch span { width: 20px; height: 20px; border-radius: 50%; background: #fff; }
.camera-auto[aria-pressed="true"] { color: var(--gold); font-weight: 700; }
.camera-auto[aria-pressed="true"] .auto-switch { background: var(--gold); justify-content: flex-end; }
.camera-auto[aria-pressed="true"] .auto-switch span { background: var(--navy); }
.camera-flash { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: #F6F1E6; box-shadow: inset 0 0 0 10px var(--gold); }
.camera-flash.on { animation: cameraflash .15s ease-out; }
@keyframes cameraflash { from { opacity: .95; } to { opacity: 0; } }
.camera-verdict { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.verdict-card { position: absolute; left: 24px; right: 24px; top: 36%; background: #fff; color: var(--navy); border-radius: 22px; padding: 20px; text-align: center; display: grid; gap: 8px; pointer-events: auto; }
.verdict-card strong { font-family: var(--serif); font-size: 19px; }
.verdict-card span { font-size: 14px; color: #5A5247; line-height: 1.45; }
.verdict-actions { position: absolute; left: 16px; right: 16px; bottom: calc(40px + var(--safe-bottom)); display: flex; gap: 10px; pointer-events: auto; }
.verdict-primary, .verdict-secondary { height: 54px; min-height: 54px; border-radius: 999px; font-size: 15px; }
.verdict-primary { flex: 2; border: 0; background: var(--gold); color: var(--navy); font-weight: 700; }
.verdict-secondary { flex: 1; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; font-weight: 600; }
.camera-denied { position: absolute; inset: 0; z-index: 2; display: grid; align-content: center; justify-items: center; gap: 14px; padding: 0 32px 140px; text-align: center; }
.camera-denied h2 { font-family: var(--serif); font-size: 24px; color: #fff; margin: 0; }
.camera-denied p { font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.7); }
.denied-icon { width: 64px; height: 48px; border-radius: 12px; border: 3px solid rgba(255,255,255,.4); position: relative; }
.denied-icon::after { content: ''; position: absolute; left: -8px; right: -8px; top: 20px; height: 3px; background: #E6A23C; transform: rotate(-30deg); }
.denied-actions { position: absolute; left: 16px; right: 16px; bottom: calc(40px + var(--safe-bottom)); display: grid; gap: 10px; }
.denied-link { min-height: 48px; border: 0; background: none; color: rgba(255,255,255,.75); font-size: 14px; }
body.camera-open { overflow: hidden; }

/* ---------- Diálogos y toast ---------- */
.install-dialog { width: min(420px, calc(100% - 28px)); border: 0; border-radius: 12px; padding: 0; box-shadow: 0 24px 80px rgba(30,27,22,.28); }
.install-dialog::backdrop { background: rgba(30,27,22,.44); backdrop-filter: blur(3px); }
.install-dialog form { position: relative; padding: 24px; text-align: center; }
.dialog-close { position: absolute; right: 8px; top: 8px; width: 38px; height: 38px; min-height: 38px; padding: 0; border: 0; background: transparent; font-size: 1.4rem; color: var(--muted); }
.dialog-icon { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--navy); color: var(--gold); font-size: 1.9rem; }
.install-dialog h2 { font-size: 1.25rem; margin-bottom: 10px; }
.install-dialog p, .install-dialog li { color: var(--ink-2); font-size: .82rem; text-align: left; line-height: 1.55; }
.install-dialog ol { padding-left: 1.2rem; }
.install-dialog .scan-cta { margin-top: 16px; }
.access-label { text-align: left; margin-top: 12px; }
.toast { position: fixed; z-index: 150; left: 50%; top: calc(60px + env(safe-area-inset-top, 0px)); bottom: auto; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px; background: var(--gold); color: var(--navy); font-weight: 700; font-size: .78rem; font-weight: 500; box-shadow: 0 12px 28px rgba(30,27,22,.35); text-align: center; }

/* ---------- Adaptaciones ---------- */
@media (max-width: 420px) {
  .pgn-card .section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .issue-body { flex-direction: column; align-items: stretch; }
  .issue-body .mini-board { flex: none; max-width: 220px; margin: 0 auto; }
  .preview-wrap.multi { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .summary-grid { grid-template-columns: repeat(2,1fr); }
  .model-compare-grid { grid-template-columns: 1fr; }
  .error-grid { grid-template-columns: repeat(2,1fr); }
  .mismatch { grid-template-columns: 45px 1fr; }
  .mismatch span:last-child { grid-column: 1 / -1; }
  .seg-gallery { grid-template-columns: 1fr; }
  .seg-metrics { grid-template-columns: repeat(2,1fr); }
  .wait-grid-card { flex-direction: column; }
  .wait-grid-preview { flex: none; }
}
@media (min-width: 560px) {
  .issue-body .mini-board { flex: 0 0 170px; }
}

/* ---------- Remates ---------- */
.source-evidence { display: grid; gap: 6px; }
.stretch-evidence { display: grid; gap: 4px; }
.evidence-crops.compact .crop-placeholder { height: 56px; font-size: .6rem; }
/* La fila entera es apaisada: se ve mejor a lo ancho de la tarjeta. */
.evidence-crops:has(.row-crop) { flex-direction: column; }
.evidence-crop.row-crop { height: 62px; object-fit: contain; }
.evidence-crops.compact .evidence-crop.row-crop { height: 46px; }
.skipped-note { background: var(--gold-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--gold-line); border-radius: 8px; padding: 10px 12px; font-size: .76rem; line-height: 1.5; }
.review-meta .pill { margin-left: auto; }

/* ---------- Mazo de dudas (v3 · v4 · 5) ---------- */
/* Cabecera: «‹ Partidas» y «Duda i de n» arriba; «N dudas» en grande. */
body.reviewing .result-topbar { background: transparent; color: var(--navy); padding: calc(10px + env(safe-area-inset-top, 0px)) 0 0; flex-wrap: wrap; row-gap: 6px; margin-top: 0; }
body.reviewing .result-topbar .icon-button { width: auto; height: auto; padding: 6px 0; font-size: 16px; color: var(--navy); display: flex; align-items: center; white-space: nowrap; }
body.reviewing .result-topbar .icon-button::after { content: ' Partidas'; font-family: var(--sans); }
body.reviewing .result-topbar-copy { display: none; }
body.reviewing .result-topbar-copy strong { font-size: 26px; font-weight: 700; }
body.reviewing .result-topbar-copy span { display: none; }
body.reviewing .completion-badge { margin-left: auto; background: none; color: var(--muted); font-size: 13px; font-weight: 500; padding: 0; }
body.reviewing .steps, body.reviewing .review-meta .pill { display: none; }
body.reviewing .review-meta { justify-content: flex-end; }
body.reviewing .review-meta .text-button { font-size: 13px; }

/* Revisión: posición, manuscrito y corrección en una superficie. */
.deck-face { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 16px; }
.deck-card::before, .deck-card::after { display: none; }
.deck-face .evidence-crop { height: 180px; border-radius: 8px; }
.deck-face .evidence-crop.row-crop { height: 140px; }
.deck-face .evidence-crops, .viewer-evidence-col .evidence-crops { flex-direction: column; gap: 16px; }
.mini-board span { display: grid; place-items: center; font-size: clamp(14px, 9cqw, 44px); line-height: 1; min-width: 0; min-height: 0; overflow: hidden; }
.mini-board button { display: grid; place-items: center; font-size: clamp(14px, 9cqw, 44px); line-height: 1; min-width: 0; min-height: 0; overflow: hidden; }
.review-position { display: grid; gap: 8px; min-width: 0; }
.position-caption { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.review-board { width: min(100%, 440px); margin-inline: auto; }
.board-files { display: grid; grid-template-columns: repeat(8,1fr); width: min(100%, 440px); margin-inline: auto; font: 13px ui-monospace, monospace; text-align: center; color: var(--muted); }
.review-proposal { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.review-proposal span, .review-choice-label { color: var(--muted); font-size: 14px; }
.review-proposal strong { font-size: 28px; }
.review-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.review-choices .choice { min-width: 64px; min-height: 44px; }
.review-history { border-top: 1px solid var(--line); padding-top: 8px; }
.review-history summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; cursor: pointer; }
.review-history summary::after { content: '⌄'; }
.review-history[open] summary::after { content: '⌃'; }
.review-history .viewer-moves { max-height: 156px; }
.review-editor { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.editor-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.editor-cancel { border: 0; background: transparent; padding: 8px; color: var(--ink-2); }
.editor-input-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 112px); gap: 8px; }
.editor-input-row input, .editor-input-row select { width: 100%; min-height: 50px; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; background: var(--bg); font-size: 17px; }
.editor-input-row input[aria-invalid="true"] { border-color: var(--danger); }
.editor-feedback { font-size: 14px; color: var(--ink-2); min-height: 22px; }
.editor-feedback.is-error { color: var(--danger); }
.editor-apply { min-height: 52px; }
.deck-other, .deck-later, .deck-confirm { width: auto; height: auto; min-height: 52px; border-radius: 12px; padding: 10px; box-shadow: none; font-size: 15px; line-height: 1.3; }
.deck-other { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.deck-later { border: 0; background: transparent; color: var(--ink-2); }
.deck-confirm { border: 0; background: var(--ink); color: #fff; }
.deck-hint { text-align: center; font-size: 13px; color: var(--muted); padding: 0 0 12px; }
.no-crop { min-height: 0; padding: 12px; }
.evidence-enlarge { display: block; border: 1px solid var(--line); padding: 0; border-radius: 8px; width: 100%; overflow: hidden; background: var(--bg); }
.evidence-enlarge::after { content: 'Ampliar'; display: block; font-size: 12px; color: var(--ink-2); padding: 6px; }
.evidence-dialog { width: min(900px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 16px; border: 0; border-radius: 20px; background: var(--bg); }
.evidence-dialog::backdrop { background: rgba(30,27,22,.65); }
.evidence-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.evidence-dialog-head h2 { font: 600 17px var(--sans); }
.evidence-dialog-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-block: 12px; }
.evidence-dialog-controls label { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.evidence-dialog-controls input { width: 120px; }
.evidence-dialog-viewport { overflow: auto; max-height: 65dvh; background: #fff; border-radius: 8px; }
.evidence-dialog-viewport img { display: block; width: 100%; max-width: none; height: auto; }
@media (min-width: 760px) { .empty-state { min-height: auto; padding-bottom: 24px; } .new-game-fab { position: static; transform: none; margin: 24px auto; } }
@media (max-width: 360px) { .deck-actions { grid-template-columns: 1fr auto; } .deck-confirm { grid-column: 1 / -1; } }

.deck-card { position: relative; background: none; box-shadow: none; padding: 0; gap: 0; }
@keyframes deckin { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-where { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card-tag { font-size: 11px; font-weight: 700; color: #6B4A2E; background: #F2E6CC; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.card-tag[data-tone="red"] { color: #9B2C2C; background: #F6E2DC; }
.no-crop { min-height: 0; border-radius: 14px; border: 1.5px dashed var(--line-2); display: grid; place-items: center; text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.4; padding: 10px; }
.no-crop span { color: var(--faint); }
.ask-lead { display: block; font-size: 13px; color: var(--muted); }
.ask-move { display: block; font-family: var(--serif); font-size: 42px; font-weight: 700; line-height: 1.05; color: var(--navy); }
.ask-note { display: block; font-size: 12px; color: var(--faint); margin-top: 4px; }
.deck-alternatives { display: grid; gap: 10px; }
.deck-alternatives .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.deck-alternatives .choice { width: auto; min-height: 0; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; padding: 10px 16px; font-size: 16px; font-weight: 600; }
.deck-text { margin: 0; font-size: 14px !important; line-height: 1.5; color: #3A352D !important; }

/* Acciones en el flujo: su tamaño real reserva espacio incluso con texto grande. */
.deck-actions { position: sticky; bottom: 0; z-index: 60; display: grid; grid-template-columns: 1fr auto 1.3fr; gap: 8px; align-items: stretch; padding: 12px 0 calc(12px + var(--safe-bottom)); background: var(--bg); border-top: 1px solid var(--line-2); margin-top: 16px; }
.deck-confirm:active { opacity: .8; }
.stretch-card .deck-later, .gap-card .deck-later { width: 90px; height: 56px; border-radius: 999px; font-size: 14px; box-shadow: none; }
.deck-primary { flex: 1; height: 56px; min-height: 56px; border: 0; border-radius: 999px; background: var(--navy); color: var(--gold); font-size: 15px; font-weight: 700; }
.deck-secondary { flex: 1; height: 56px; min-height: 56px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--navy); font-size: 15px; font-weight: 600; }

/* 5a · tramo */
.stretch-strip { display: grid; gap: 5px; }
.stretch-row { display: grid; grid-template-columns: 82px 1fr; gap: 8px; align-items: center; border-radius: 12px; padding: 4px; }
.stretch-row.is-first { box-shadow: inset 0 0 0 2px var(--navy); }
.stretch-label { font: 11px ui-monospace, monospace; color: #7D6E52; }
.stretch-label b { display: block; color: var(--navy); font-family: var(--sans); }
.stretch-nocrop { font-size: 11px; color: var(--faint); }
.read-as { display: flex; justify-content: space-between; align-items: center; background: var(--bg); border-radius: 14px; padding: 10px 14px; }
.read-as span { font-size: 13px; color: var(--muted); }
.read-as strong { font-family: var(--serif); font-size: 22px; }

/* 5b · salto */
.gap-table { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 4px; font-size: 15px; font-weight: 600; }
.gap-num { color: var(--faint); font-weight: 500; align-self: center; }
.gap-cell { padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.gap-cell.dim { opacity: .6; }
.gap-slot { padding: 6px 10px; border-radius: 8px; border: 2px dashed #C9A974; color: #6B4A2E; font-size: 13px; display: grid; place-items: center; }
.gap-gain { margin: 0; font-size: 13px !important; color: #4E7A3A !important; font-weight: 600; }

/* 5c · conflicto */
.conflict-swap { display: grid; }
.swap-mine { background: var(--navy); color: #fff; border-radius: 14px; padding: 12px; text-align: center; }
.swap-mine span { display: block; font-size: 11px; color: var(--gold); }
.swap-mine strong { font-family: var(--serif); font-size: 26px; }
.conflict-spots { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.conflict-spots .card-where { flex-basis: 100%; }
.conflict-spots .choice { width: auto; min-height: 0; border-radius: 12px; padding: 9px 14px; font-size: 14px; }

/* 5e · segunda lectura: oferta antes del mazo o enlace en la cabecera. */
.refine-row { display: grid; gap: 10px; margin-top: 4px; }
.refine-eyebrow, .refine-title, .refine-copy, .refine-skip { display: none; }
#stepReview.refine-offer #issues, #stepReview.refine-offer .review-meta { display: none; }
#stepReview.refine-offer .refine-row { background: var(--navy); color: #fff; border-radius: 28px; padding: 22px; margin-top: 14px; }
#stepReview.refine-offer .refine-eyebrow { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
#stepReview.refine-offer .refine-title { display: block; font-family: var(--serif); font-size: 26px; line-height: 1.15; }
#stepReview.refine-offer .refine-copy { display: block; font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.72); margin: 0; }
#stepReview.refine-offer .refine-skip { display: block; min-height: 44px; border: 0; background: none; color: rgba(255,255,255,.7); font-size: 14px; font-weight: 600; }
.refine-button { height: 54px; min-height: 54px; border: 0; border-radius: 999px; background: var(--gold); color: var(--navy); font-weight: 700; }
#stepReview:not(.refine-offer) .refine-button { justify-self: start; height: auto; min-height: 0; padding: 8px 14px; font-size: 13px; background: #E6DFCF; }
.refine-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 0; }
#stepReview.refine-offer .refine-hint { color: rgba(255,255,255,.5); }
#stepReview:not(.refine-offer) .refine-hint { text-align: left; }
.refine-status { background: #fff; color: var(--navy); border-radius: 22px; padding: 14px 16px; font-size: 14px; font-weight: 600; margin: 0; }

/* 5f · final del mazo */
.review-done { justify-items: center; text-align: center; gap: 12px; }
.skipped-note { background: none !important; box-shadow: none !important; display: grid; justify-items: center; gap: 10px; padding: 30px 12px 6px !important; color: #5A5247 !important; font-size: 14px !important; }
.skipped-note strong { font-family: var(--serif); font-size: 26px; color: var(--navy); }
.parked-stack { position: relative; width: 120px; height: 110px; }
.parked-stack i, .parked-stack b { position: absolute; left: 15px; top: 8px; width: 90px; height: 90px; border-radius: 18px; }
.parked-stack i:first-child { left: 10px; top: 10px; background: #E4DCCB; transform: rotate(-8deg); }
.parked-stack i:nth-child(2) { left: 20px; top: 6px; background: #ECE5D6; transform: rotate(6deg); }
.parked-stack b { background: #fff; display: grid; place-items: center; font-family: var(--serif); font-size: 34px; color: var(--navy); }
#resumeSkipped { width: 100%; height: 56px; border-radius: 999px; background: var(--navy); color: var(--gold); font-size: 15px; font-weight: 700; text-decoration: none; }
#viewGame { width: 100%; border-radius: 999px; }
.review-done:has(#resumeSkipped:not(.hidden)) #viewGame { background: transparent; border: 1px solid var(--line-2); color: var(--navy); }
.review-done:has(#resumeSkipped:not(.hidden)) { display: flex; flex-direction: column; }
.review-done:has(#resumeSkipped:not(.hidden)) #resumeSkipped { order: 2; }
.review-done:has(#resumeSkipped:not(.hidden)) #viewGame { order: 3; }

/* ---------- Partida leída (v4 · 6a) ---------- */
.provisional-banner { width: 100%; min-height: 0; margin-top: 4px; padding: 9px 14px; border: 0; border-radius: 14px; background: #E6A23C; color: var(--navy); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; text-align: left; }
.provisional-banner > span:last-child { font-weight: 700; white-space: nowrap; }
body.viewing .result-topbar-copy strong { font-family: var(--sans); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-move.has-doubt { background: transparent; border: 1.5px dashed #E6A23C; padding: 5px 7px; }
.viewer-move.has-doubt.current { background: var(--navy); border-style: solid; border-color: var(--navy); }
.viewer-move-info .reason:not(.is-doubt) { color: var(--muted); }
.viewer-move-info .reason.is-doubt { color: #B07A1E; }
.viewer-legend { margin: -4px 0 0; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.viewer-legend span { width: 14px; height: 10px; border-radius: 3px; border: 1.5px dashed #E6A23C; }

/* ---------- Datos de la partida y PGN (v4 · 6b) ---------- */
body.data-step { background: var(--navy); }
body.data-step .steps { display: none; }
body.data-step .result-topbar { background: transparent; padding: calc(10px + env(safe-area-inset-top, 0px)) 0 6px; }
body.data-step .result-topbar-copy span { display: none; }
.data-sheet { margin: 8px calc((100vw - var(--shell)) / -2) 0; padding: 12px max(16px, calc((100vw - var(--shell)) / 2)) calc(34px + var(--safe-bottom)); background: var(--bg); color: var(--navy); border-radius: 28px 28px 0 0; min-height: calc(100vh - 110px); display: flex; flex-direction: column; gap: 10px; }
.data-sheet .sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); align-self: center; }
.data-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 0; padding: 0 4px; }
.data-head p { font-size: 12.5px; color: var(--muted); padding: 2px 4px 0; }
.data-rows { background: #fff; border-radius: 18px; padding: 2px 14px; }
.data-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid #EFE9DC; font-size: 14.5px; font-weight: 400; color: var(--muted); }
.data-row:last-child { border-bottom: 0; }
.data-row input { flex: 1; text-align: right; border: 0; background: transparent; padding: 8px 0; min-height: 40px; font-size: 14.5px; font-weight: 600; color: var(--navy); border-radius: 0; }
.data-row input:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--gold); }
.data-result { padding: 9px 0; }
.data-result .result-segments { flex: none; }
.data-result .result-segments button { flex: none; padding: 6px 10px; border-radius: 9px; font-weight: 700; }
.data-apply { align-self: flex-end; font-size: 12px; }
.data-pgn { flex: 1; min-height: 120px; border-radius: 14px; background: #E8E1D2; color: #5A5247; padding: 12px; font: 11px/1.5 ui-monospace, monospace; }
.data-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.data-primary, .data-secondary { height: 52px; min-height: 52px; border: 0; border-radius: 16px; font-size: 14px; }
.data-primary { background: var(--gold); color: var(--navy); font-weight: 700; }
.data-secondary { background: #fff; color: var(--navy); font-weight: 600; }
.data-save { height: 54px; min-height: 54px; border: 0; border-radius: 999px; background: var(--navy); color: var(--gold); font-size: 15px; font-weight: 700; }

/* ---------- Refinamiento editorial v5 ----------
   La paleta aprobada sigue intacta. Papel para contenido, tinta para acciones,
   oro para acentos; controles con nombre y un ritmo común de 4/8/16/24. */
:root {
  --sans: -apple-system, BlinkMacSystemFont, Inter, 'Segoe UI', sans-serif;
  --faint: #7A7266;
  --shell: min(640px, calc(100% - 40px));
}
html { scroll-padding-block: 80px; }
body { -webkit-font-smoothing: antialiased; }
button { touch-action: manipulation; }
button, summary, input, select, textarea { scroll-margin-block: 80px; }
.app-header { max-width: 680px; margin-inline: auto; padding-bottom: 12px; }
.app-title { font-size: 2.125rem; letter-spacing: -.035em; }
.app-shell { padding-top: 12px; }
.brand-mark { border-radius: 12px; }
.bottom-nav {
  left: 0; right: 0; bottom: 0; transform: none; height: auto;
  min-height: calc(68px + var(--safe-bottom)); border-radius: 0;
  background: var(--bg); border-top: 1px solid var(--line-2);
  padding: 8px 20px calc(8px + var(--safe-bottom)); gap: 0;
  box-shadow: none; justify-content: center;
}
.nav-item, .nav-item.active {
  flex: 1; max-width: 240px; min-height: 48px; padding: 4px 16px;
  flex-direction: column; gap: 5px; background: transparent;
  border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 500;
}
.nav-item.active { color: var(--navy); font-weight: 700; }
.new-game-fab {
  left: 50%; right: auto; transform: translateX(-50%);
  bottom: calc(84px + var(--safe-bottom)); width: var(--shell);
  height: auto; min-height: 54px; justify-content: center;
  border-radius: 16px; background: var(--navy); color: #fff;
  box-shadow: 0 4px 12px rgba(30,27,22,.12); font-size: 16px;
}
.new-game-fab:active { transform: translateX(-50%) scale(.99); }
.fab-icon { border: 0; border-radius: 0; position: relative; width: 18px; height: 18px; }
.fab-icon::before, .fab-icon::after { content: ''; position: absolute; background: currentColor; border-radius: 1px; }
.fab-icon::before { width: 16px; height: 2px; left: 1px; top: 8px; }
.fab-icon::after { width: 2px; height: 16px; left: 8px; top: 1px; }
.games { padding-top: 8px; padding-bottom: 160px; }
.empty-state { padding: clamp(32px, 8vh, 80px) 8px 32px; gap: 12px; }
.empty-sheet { width: 144px; height: 144px; background: none; transform: none; margin-bottom: 12px; }
.empty-state strong { font-size: 26px; line-height: 1.2; letter-spacing: -.025em; max-width: 280px; }
.empty-state p { font-size: 15px; max-width: 280px; }
.games-foot { font-size: 12px; color: var(--muted); }
.history-list { gap: 8px; }
.history-item, .open-game { border-radius: 16px; }
.open-game { padding: 16px; min-height: 88px; }
.history-main strong { font-size: 16px; }
.history-main span { font-size: 13px; line-height: 1.5; }
.pending-card { border-radius: 18px; padding: 20px; }
.new-game { min-height: calc(100svh - 44px); }
.new-game-title { margin: 28px 0 0; font-size: 36px; letter-spacing: -.035em; }
.capture-intro { margin-top: 8px; font-size: 15px; color: var(--muted); }
.sheet-slots { margin-top: 28px; gap: 20px; }
.slot-tile { border-radius: 18px; padding: 20px; }
.slot-a .slot-tile { min-height: 168px; box-shadow: inset 0 0 0 1px var(--line-2); }
.slot-b .slot-tile { min-height: 96px; background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.slot-b[data-filled="true"] .slot-tile { background: var(--navy); min-height: 112px; }
.slot-a .slot-chip { width: 40px; height: 40px; background: var(--gold-soft); color: var(--navy); border-radius: 12px; }
.slot-chip svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.6; }
.slot-b .slot-chip { width: 40px; height: 40px; font-size: 24px; background: var(--gold-soft); border-radius: 12px; }
.sheet-slot[data-filled="true"] .slot-tile::after { display: none; }
.sheet-slot .preview-item { flex-basis: 88px; padding-top: 8px; }
.sheet-slot .preview-tools { position: static; display: flex; justify-content: center; gap: 0; margin-top: 4px; }
.sheet-slot .preview-tools button { width: 44px; height: 44px; min-height: 44px; border-radius: 10px; font-size: 16px; background: #fff; color: var(--navy); }
.slot-tools { padding: 0; }
.link-button { min-height: 44px; font-size: 14px; color: var(--ink-2); }
.slot-copy span, .slot-b .slot-copy span { font-size: 14px; color: var(--muted); }
.build-cta { background: var(--navy); color: #fff; height: auto; min-height: 54px; border-radius: 16px; font-size: 16px; }
.build-cta:disabled { color: #706757; }
.new-game-hint, .privacy { font-size: 12px; }
.round-button, .icon-button, .camera-round, .camera-done, .dialog-close { min-width: 44px; min-height: 44px; height: 44px; }
.mode-pill { display: flex; align-items: center; min-height: 44px; }
.settings-label, .field-label { font-size: 12px; letter-spacing: .04em; }
.settings-line { min-height: 52px; }
.settings-title, .settings-line { font-size: 16px; }
.settings-sub, .settings-value { font-size: 14px; }
.notation-chip, .text-button, .inline-link, .choice-row, .account-button { min-height: 44px; }
.settings-notation { flex-wrap: wrap; }
input, select, .data-row input { font-size: 16px; min-height: 44px; }
.read-note, .read-meta .muted, .read-copy span { font-size: 14px; }
.read-meta h2, .quick-title, .data-head h2 { font-family: var(--sans); font-size: 20px; letter-spacing: -.02em; }
.card-head { flex-wrap: wrap; }
.card-where { font-size: 13px; letter-spacing: 0; text-transform: none; }
.card-tag { white-space: normal; font-size: 12px; line-height: 1.4; }
.evidence-crop-cell .crop-label { font-size: 12px; letter-spacing: 0; text-transform: none; }
.ask-move { font-family: var(--sans); font-size: 36px; letter-spacing: -.035em; }
.ask-lead, .ask-note, .deck-ask .evidence-read { font-size: 13px; color: var(--muted); }
.deck-alternatives .choice { min-height: 44px; }
#stepReview:not(.refine-offer) .refine-button { min-height: 44px; }
.viewer-moves { display: block; max-height: 32vh; overflow-y: auto; }
.viewer-row { display: grid; grid-template-columns: 40px 1fr 1fr; gap: 4px; align-items: center; padding-block: 3px; border-bottom: 1px solid var(--line); }
.viewer-move-number { display: block; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.viewer-move { min-height: 44px; text-align: left; padding: 10px 12px; font-size: 16px; font-variant-numeric: tabular-nums; }
.viewer-move .move-number { display: none; }
.viewer-move.has-doubt { padding: 9px 11px; }
.viewer-move-info span:first-child { font-family: var(--sans); }
.viewer-nav button { min-height: 48px; height: auto; }
.data-pgn { font-size: 13px; line-height: 1.6; }
.data-head p, .viewer-legend { font-size: 13px; }
.camera-screen { background: var(--navy); }
.camera-side, .camera-auto { min-width: 44px; min-height: 44px; }
.camera-advice { width: max-content; max-width: calc(100% - 40px); border-radius: 16px; }
@media (min-width: 760px) {
  .new-game-fab { width: 320px; }
  .empty-state { padding-top: 80px; }
}
@media (max-width: 360px) {
  :root { --shell: calc(100% - 32px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  :root { --muted: #4A443A; --faint: #4A443A; --line: #7A7266; --line-2: #7A7266; }
}

.viewer-columns { background: var(--bg); padding-bottom: 8px; display: grid; grid-template-columns: 40px 1fr 1fr; gap: 4px; color: var(--muted); font-size: 12px; padding-top: 8px; }
.viewer-columns span { padding-inline: 12px; }
.viewer-columns span:first-child { text-align: center; padding: 0; }

.nav-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Shared SVG pieces: stable filled silhouettes on iOS and web. */
.mini-board .board-piece { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
