/* Concepto: hoja clínica de optometría. Columna central legible, el rojo y el azul de las gafas anaglifo como única nota de color fuerte. */
:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #566672;
  --line: #d4dde3;
  --accent: #0b7f8c;      /* lente azul-cian, acción principal */
  --accent-ink: #ffffff;
  --lens-l: #d8322b;      /* lente roja */
  --lens-r: #1f5fd6;      /* lente azul */
  --soft: #dcecef;
  --good: #1d8a52;
  --bad: #c2402f;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1419; --surface: #152029; --ink: #e4ecf1; --muted: #93a5b2; --line: #26353f;
    --accent: #3cc3cf; --accent-ink: #062126; --soft: #173139; --lens-l: #ff5a4f; --lens-r: #5b8cff;
    --good: #4fcf8a; --bad: #ff7a66; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1419; --surface: #152029; --ink: #e4ecf1; --muted: #93a5b2; --line: #26353f;
  --accent: #3cc3cf; --accent-ink: #062126; --soft: #173139; --lens-l: #ff5a4f; --lens-r: #5b8cff;
  --good: #4fcf8a; --bad: #ff7a66; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.08rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 62ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); font-weight: 700; margin-bottom: .3em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* cabecera */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top-in { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; padding-block: 6px; }
.brand { font: 800 1.3rem var(--display); color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.mark { position: relative; width: 34px; height: 20px; }
.mark i { position: absolute; top: 0; width: 20px; height: 20px; border-radius: 50%; mix-blend-mode: multiply; }
.mark i:first-child { left: 0; background: var(--lens-l); }
.mark i:last-child { right: 0; background: var(--lens-r); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 700; }
.nav a:hover { color: var(--ink); background: var(--soft); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--soft); }
.who select { max-width: 200px; }

main.wrap { max-width: 1120px; margin: 0 auto; padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main section { margin-top: 34px; }

/* controles */
.btn { font: 700 .95rem var(--body); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.big { padding: 13px 24px; font-size: 1.05rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
input[type=range] { width: 100%; padding: 0; accent-color: var(--accent); background: transparent; border: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
label { font-weight: 700; font-size: .92rem; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.form { display: grid; gap: 8px; align-content: start; }
.form .row input { flex: 1; min-width: 0; }
.sep { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--ink); }
.code { background: var(--soft); padding: 2px 8px; border-radius: 6px; font-weight: 600; letter-spacing: .04em; }
.note { background: var(--soft); padding: 8px 12px; border-radius: 8px; }
.banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1.5px dashed var(--accent);
  border-radius: var(--r); padding: 12px 16px; margin-bottom: 22px; }
.banner p { margin: 0; }

.glasses-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 700; }
.glasses-pill .lens { display: inline-block; width: 16px; height: 11px; border-radius: 6px 6px 8px 8px; }
.glasses-pill .lens.l { background: var(--lens-l); }
.glasses-pill .lens.r { background: var(--lens-r); }
.glasses-pill.small .lens { width: 12px; height: 8px; }

/* hoy */
.today { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px); gap: 22px; margin-top: 0; }
.today-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 26px; min-width: 0; }
.today-side { display: grid; gap: 10px; align-content: start; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: flex; justify-content: space-between; align-items: baseline; }
.k { font-size: .8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.stat .v { font-size: 1.6rem; font-weight: 600; }
.stat .v small { font-size: .8rem; color: var(--muted); }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; }
.cal ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal li { height: 30px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-size: .7rem; color: var(--muted); max-width: 100%; }
.cal li.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal li.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.plan { list-style: none; padding: 0; margin: 18px 0 22px; display: grid; gap: 0; border-top: 1px solid var(--line); }
.plan li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.plan li small { display: block; color: var(--muted); font-size: .85rem; }
.plan .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-size: .85rem; font-weight: 600; }
.plan li.done .num { background: var(--good); color: #fff; }
.plan li.done strong { text-decoration: line-through; text-decoration-color: var(--muted); }
.lvl { font-size: .8rem; color: var(--muted); }
.program-note { background: var(--soft); border-radius: 8px; padding: 9px 12px; }
.check-card { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 26px; margin-top: 22px; }
.check-card > div { flex: 1 1 360px; min-width: 0; }
.check-card p { margin: 0; color: var(--muted); }

/* tarjetas de juego y progreso */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.game, .pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.game .desc { color: var(--muted); font-size: .9rem; flex: 1; }
.game.blocked { opacity: .7; }
.g-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.g-head h3 { margin: 0; }
.skill { color: var(--accent); font-weight: 700; font-size: .85rem; margin: 0 0 4px; }
.spark { width: 100%; height: 56px; display: block; margin: 6px 0; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--accent); opacity: .12; }
.spark .grid { stroke: var(--line); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark .end { fill: var(--accent); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.mini dt { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mini dd { margin: 0; font-weight: 600; }
.metric { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.delta { font-size: .8rem; }
.up { color: var(--good); } .down { color: var(--bad); }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tr.sel td { background: var(--soft); }
.adh { display: inline-block; width: 80px; height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.adh i { display: block; height: 100%; background: var(--accent); }
.addp { margin-top: 12px; }
.addp input { flex: 1 1 180px; min-width: 0; }
.addp input[type=number] { flex: 0 1 90px; }

.patient { margin-top: 26px; }
.prog { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; margin-top: 12px; }
.prog > .row { grid-column: 1 / -1; }
.prog fieldset { display: grid; gap: 6px; align-content: start; }
.checks { display: grid; gap: 6px; }
.checks label { font-weight: 400; }
.radios label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin-bottom: 6px; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.settings .card { display: grid; gap: 8px; align-content: start; }
.settings .card h2 { margin-bottom: 4px; }
.eye-test canvas { width: 100%; max-width: 320px; height: auto; border-radius: 8px; display: block; }
.card-cal { overflow-x: auto; padding: 6px 0; }
#cal-rect { height: 120px; max-width: none; border: 2px dashed var(--accent); border-radius: 10px; display: grid; place-items: end start; padding: 8px; color: var(--muted); }
.disclaimer { margin-top: 30px; color: var(--muted); font-size: .85rem; max-width: 70ch; }

/* jugador */
#stage { position: fixed; inset: 0; z-index: 50; background: #05090c; color: #e9eef2;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
body.playing { overflow: hidden; }
.player { height: 100%; display: flex; flex-direction: column; }
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; position: relative; flex-wrap: wrap; }
.p-title { display: flex; flex-direction: column; }
.p-title strong { font: 800 1.15rem var(--display); }
.p-cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8fa3b3; }
.p-hud { display: flex; gap: 8px; align-items: center; }
.chip { background: #14212b; border: 1px solid #26353f; border-radius: 99px; padding: 3px 11px; font-size: .85rem; font-weight: 700; }
.p-time { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #14212b; }
.p-time i { display: block; height: 100%; width: 100%; background: #3cc3cf; transition: width .15s linear; }
.player .btn { background: #14212b; color: #e9eef2; border-color: #26353f; }
.player .btn.primary { background: #3cc3cf; border-color: #3cc3cf; color: #062126; }
.p-stage { position: relative; flex: 1; min-height: 0; margin: 8px 12px; border-radius: 12px; overflow: hidden; background: #000; box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .2s; touch-action: none; }
.p-stage.ok { animation: ok .45s; } .p-stage.bad { animation: bad .45s; }
@keyframes ok { 0% { box-shadow: inset 0 0 0 3px #4fcf8a; } 100% { box-shadow: inset 0 0 0 3px transparent; } }
@keyframes bad { 0% { box-shadow: inset 0 0 0 3px #ff7a66; } 100% { box-shadow: inset 0 0 0 3px transparent; } }
.p-stage canvas { display: block; cursor: crosshair; }
.p-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(20, 33, 43, .92); border: 1px solid #26353f; padding: 6px 16px; border-radius: 99px; font-weight: 700; pointer-events: none; white-space: nowrap; }
.p-intro { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: #05090c; overflow-y: auto; }
.player > .p-intro { position: relative; flex: 1; }
.intro-card { max-width: 540px; width: 100%; background: #101a21; border: 1px solid #26353f; border-radius: 14px; padding: 26px; }
.intro-card h2 { font-size: 1.7rem; }
.intro-card .eyebrow { color: #8fa3b3; }
.intro-card .muted { color: #8fa3b3; margin-top: 14px; }
.glasses-note { background: #1a2a33; border-left: 3px solid #ff5a4f; padding: 8px 12px; border-radius: 6px; }
.p-bar { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 4px 12px 14px; min-height: 12px; }
.ans { font: 700 1rem var(--body); background: #14212b; color: #e9eef2; border: 1.5px solid #26353f; border-radius: 10px; padding: 12px 20px; cursor: pointer; min-width: 110px; }
.ans:hover { border-color: #3cc3cf; }
.res { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.res li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid #26353f; padding-bottom: 8px; }
.res .mono { color: #b8c6d0; font-size: .85rem; }
.big-score { font-size: 2rem; font-weight: 600; color: #3cc3cf; margin: 4px 0 14px; }

@media (max-width: 820px) {
  .today { grid-template-columns: minmax(0, 1fr); }
  .today-side { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .today-side .cal { grid-column: 1 / -1; }
  .stat { flex-direction: column; }
  .prog { grid-template-columns: minmax(0, 1fr); }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .who { margin-left: auto; }
  .today-main { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.brand-sub { font-weight: 600; color: var(--accent); }

/* cuentas y planes */
body.logged-out .nav, body.logged-out .who, body.logged-out .plan-chip, body.logged-out .top { display: none; }
.plan-chip { margin-left: auto; }
.tag.premium { background: var(--accent); color: var(--accent-ink); }
.plan-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; margin-bottom: 18px; }
.plan-strip p { margin: 0; }
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 10px 0 16px; }
.plan-col { border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.plan-col.premium { border-color: var(--accent); }
.plan-col.current { background: var(--soft); }
.plan-col h3 small { font: 400 .8rem var(--body); color: var(--muted); }
.plan-col ul { margin: 6px 0 0; padding-left: 18px; font-size: .92rem; }
.plans.dark .plan-col { border-color: #26353f; }
.plans.dark .plan-col.premium { border-color: #3cc3cf; }
.plans.dark .plan-col.current { background: #14212b; }
.plans.dark .plan-col h3 small { color: #8fa3b3; }
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px); gap: 40px; align-items: center; min-height: 80vh; margin-top: 0; }
.big-brand { font-size: 1.7rem; margin-bottom: 26px; }
.auth h1 { font-size: clamp(2rem, 4.6vw, 3.2rem); }
.auth-points { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.auth-points li { padding-left: 28px; position: relative; }
.auth-points li::before { content: ""; position: absolute; left: 0; top: .35em; width: 16px; height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--lens-l) 50%, var(--lens-r) 50%); }
.auth-card { display: grid; gap: 12px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 8px; padding: 4px; }
.tab { font: 700 .95rem var(--body); border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 6px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.error { color: var(--bad); margin: 0; min-height: 1.2em; }
fieldset:disabled { opacity: .5; }
@media (max-width: 820px) {
  .auth { grid-template-columns: minmax(0, 1fr); gap: 24px; min-height: 0; }
  .plans { grid-template-columns: minmax(0, 1fr); }
}
.report-btns { margin-bottom: .4em; }
.plan-strip.install { border-style: dashed; border-color: var(--accent); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
