/* Layout: mesa de trabajo de una sola columna con pestañas; las tarjetas llevan al dorso la cuadrícula de la cámara de Neubauer. */
:root {
  --bg: #edf2f5; --surface: #ffffff; --surface2: #f5f8fa; --fg: #14283a; --muted: #566b7a; --line: #c6d4dc;
  --tripan: #2545b8; --tripan-soft: #dfe5fa; --tripan-grid: rgba(37,69,184,.12);
  --ok: #0c6b58; --ok-soft: #d8efe9; --no: #a4462c; --no-soft: #f8e3dc; --hard: #8a5f06; --hard-soft: #f8ecc9; --on-accent: #ffffff;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1b25; --surface: #182836; --surface2: #13222e; --fg: #e8f0f4; --muted: #9db0bd; --line: #2f4454;
  --tripan: #9db1ff; --tripan-soft: #24335f; --tripan-grid: rgba(157,177,255,.13);
  --ok: #6fd6bf; --ok-soft: #173f38; --no: #f3a58e; --no-soft: #4a2a21; --hard: #e9c56a; --hard-soft: #443717; --on-accent: #0f1b25; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0f1b25; --surface: #182836; --surface2: #13222e; --fg: #e8f0f4; --muted: #9db0bd; --line: #2f4454;
  --tripan: #9db1ff; --tripan-soft: #24335f; --tripan-grid: rgba(157,177,255,.13);
  --ok: #6fd6bf; --ok-soft: #173f38; --no: #f3a58e; --no-soft: #4a2a21; --hard: #e9c56a; --hard-soft: #443717; --on-accent: #0f1b25; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.5 var(--body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--tripan); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 5vw, 2.15rem); font-weight: 700; }
h2 { font-size: 1.28rem; font-weight: 700; }
h3 { font-size: 1.03rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 860px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 9px; }
.brand strong { font: 700 1rem var(--display); }
.sync { font-size: .74rem; color: var(--muted); text-align: right; }
.chip-timer { font: 500 .78rem var(--mono); padding: 2px 8px; border: 1px solid var(--tripan); color: var(--tripan); border-radius: 4px; background: none; }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-top: 3px; }
nav::-webkit-scrollbar { display: none; }
nav a { flex: none; padding: 7px 10px 9px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem; border-bottom: 3px solid transparent; }
nav a[aria-current="page"] { color: var(--tripan); border-bottom-color: var(--tripan); font-weight: 600; }
main { max-width: 860px; margin: 0 auto; padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 16px; }
main > * { min-width: 0; }
.stack { display: grid; gap: 10px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 10px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 9px 13px; font-weight: 600; font-size: .94rem; min-height: 42px; }
.btn:hover { border-color: var(--tripan); }
.btn.main { background: var(--tripan); border-color: var(--tripan); color: var(--on-accent); }
.btn.no { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.btn.hard { background: var(--hard-soft); border-color: var(--hard); color: var(--hard); }
.btn.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: .84rem; font-weight: 500; }
.btn[aria-pressed="true"] { background: var(--tripan-soft); border-color: var(--tripan); color: var(--tripan); }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--tripan); font-weight: 500; font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
label.f { display: grid; gap: 3px; font-size: .86rem; font-weight: 600; min-width: 0; }
input[type=text], input[type=password], input[type=search], input:not([type]), select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--surface); min-height: 40px; font-weight: 400; font-size: 1rem; }
textarea { resize: vertical; line-height: 1.4; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 5px 11px; border-radius: 999px; font-size: .86rem; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--tripan); border-color: var(--tripan); color: var(--on-accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.kpi b { display: block; font: 700 1.5rem/1.15 var(--display); font-variant-numeric: tabular-nums; }
.kpi span { font-size: .8rem; color: var(--muted); }
.kpi.t-ok b { color: var(--ok); } .kpi.t-no b { color: var(--no); } .kpi.t-hard b { color: var(--hard); }
.bar { height: 7px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .ok { background: var(--ok); } .bar .no { background: var(--no); } .bar .hard { background: var(--hard); }
.tp { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 10px; align-items: center; padding-block: 5px; }
.tp .bar { grid-column: 1 / -1; }
.scene { perspective: 1400px; }
.card { width: 100%; display: grid; border: 0; padding: 0; background: none; text-align: left; transform-style: preserve-3d; transition: transform .36s cubic-bezier(.3,.8,.3,1); }
.card.flipped { transform: rotateY(180deg); }
.face { grid-area: 1/1; min-height: 300px; padding: 22px; border: 1px solid var(--line); border-radius: 10px; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.back { transform: rotateY(180deg); background-image: linear-gradient(var(--tripan-grid) 1px, transparent 1px), linear-gradient(90deg, var(--tripan-grid) 1px, transparent 1px); background-size: 25% 25%; border-color: var(--tripan); }
.meta { display: flex; justify-content: space-between; gap: 10px; font: 500 .72rem var(--mono); letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.q { flex: 1; display: flex; flex-direction: column; justify-content: center; font: 600 clamp(1.22rem, 4.2vw, 1.6rem)/1.28 var(--display); }
.a { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 7px; font-size: clamp(1rem, 3vw, 1.1rem); font-weight: 500; line-height: 1.45; }
.rich ol, .rich ul { margin: 0; padding-left: 1.25em; display: grid; gap: 2px; text-align: left; }
.note { background: var(--hard-soft); color: var(--fg); padding: 6px 9px; border-radius: 5px; font-size: .86rem; font-weight: 400; }
.tag { font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 3px; background: var(--surface2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); } .tag.no { background: var(--no-soft); color: var(--no); border-color: var(--no); } .tag.hard { background: var(--hard-soft); color: var(--hard); border-color: var(--hard); }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate .btn { min-height: 48px; padding-inline: 4px; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; }
.dot { width: 32px; height: 30px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font: 500 .74rem var(--mono); padding: 0; }
.dot.cur { outline: 2px solid var(--tripan); outline-offset: 1px; }
.dot.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.dot.no { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.dot.hard { background: var(--hard-soft); border-color: var(--hard); color: var(--hard); }
.dot.ans { background: var(--tripan-soft); border-color: var(--tripan); color: var(--tripan); }
.dot.flag { border-style: dashed; border-width: 2px; border-color: var(--hard); }
.opt { display: flex; gap: 10px; text-align: left; width: 100%; border: 1px solid var(--line); background: var(--surface); padding: 11px 13px; border-radius: 7px; font-weight: 500; line-height: 1.35; }
.opt .l { font: 500 .85rem var(--mono); color: var(--muted); flex: none; }
.opt:hover { border-color: var(--tripan); }
.opt.sel { background: var(--tripan-soft); border-color: var(--tripan); }
.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.opt.wrong { background: var(--no-soft); border-color: var(--no); }
.q-title { font: 600 1.18rem/1.3 var(--display); }
.timer { font: 500 .95rem var(--mono); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--no); }
.score { font: 700 3rem/1 var(--display); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; background: var(--surface2); }
td.c, th.c { text-align: center; white-space: nowrap; }
.cl { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.cl:last-child { border-bottom: 0; }
.cl > div { min-width: 0; flex: 1; }
.cl .ops { flex: none; flex-basis: auto; display: flex; gap: 4px; }
.iconb { border: 1px solid var(--line); background: var(--surface); width: 36px; height: 36px; border-radius: 6px; font-size: 1rem; padding: 0; }
.iconb.on { color: var(--hard); border-color: var(--hard); }
.counts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px 14px; font-family: var(--mono); font-size: .86rem; max-width: 460px; }
.counts b { font-weight: 500; color: var(--muted); }
.sol { background: var(--surface2); border-left: 3px solid var(--tripan); padding: 10px 12px; display: grid; gap: 4px; font-size: .93rem; }
.good { color: var(--ok); font-weight: 600; } .bad { color: var(--no); font-weight: 600; }
details.sec { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; }
details.sec summary { cursor: pointer; font: 600 1.03rem var(--display); padding-block: 11px; }
details.sec[open] { padding-bottom: 13px; }
details.sec .rich { display: grid; gap: 8px; font-size: .94rem; }
.formula { font: 500 .92rem var(--mono); background: var(--tripan-soft); padding: 7px 10px; border-radius: 5px; overflow-x: auto; }
.step-btn { display: flex; gap: 8px; width: 100%; text-align: left; align-items: baseline; padding: 9px 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; line-height: 1.35; }
.step-btn:disabled { opacity: .35; }
.seq { display: flex; gap: 8px; padding: 8px 11px; border: 1px solid var(--tripan); background: var(--tripan-soft); border-radius: 6px; line-height: 1.35; }
.seq b { font-family: var(--mono); font-weight: 500; }
.seq.right { background: var(--ok-soft); border-color: var(--ok); }
.seq.wrong { background: var(--no-soft); border-color: var(--no); }
.match { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; align-items: start; }
.match .col { display: grid; gap: 6px; min-width: 0; }
.pair { text-align: left; padding: 8px 9px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: .87rem; line-height: 1.3; min-height: 58px; overflow-wrap: anywhere; }
.pair.sel { border-color: var(--tripan); background: var(--tripan-soft); }
.pair.done { background: var(--ok-soft); border-color: var(--ok); opacity: .7; }
.pair.err { background: var(--no-soft); border-color: var(--no); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); padding: 18px; width: min(620px, calc(100vw - 24px)); max-height: 88vh; overflow: auto; }
dialog::backdrop { background: rgba(8,20,30,.55); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: .9rem; z-index: 30; max-width: calc(100vw - 32px); }
.keys { color: var(--muted); font-size: .8rem; }
@media (hover: none) { .keys { display: none; } }
@media (max-width: 480px) { .face { min-height: 310px; padding: 17px; } .hide-p { display: none; } }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }

/* Acceso */
.auth { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 16px; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth > * { width: min(420px, 100%); }
.auth .panel { gap: 14px; padding: 22px; }
.auth input { min-height: 44px; }
.auth .btn { width: 100%; min-height: 46px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tabs a { text-align: center; padding: 9px; border-radius: 7px; border: 1px solid var(--line); color: var(--fg); background: var(--surface); text-decoration: none; font-weight: 600; font-size: .94rem; }
.tabs a[aria-current="page"] { background: var(--tripan); border-color: var(--tripan); color: var(--on-accent); }
.aviso { padding: 9px 11px; border-radius: 6px; font-size: .88rem; background: var(--hard-soft); color: var(--fg); }
.err { padding: 9px 11px; border-radius: 6px; font-size: .9rem; background: var(--no-soft); color: var(--no); font-weight: 500; }
.user-link { background: none; border: 0; color: var(--tripan); font-size: .8rem; font-weight: 600; padding: 0; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
