/* MicroMouse · estilos de todas las páginas.
   Páginas con tablero (Carrera, Programar, Laberintos, Búsquedas): herramientas a la izquierda, la pista (tablero negro con
   postes rojos, como en Micromouse) al centro y el panel de esa página a la derecha.
   Páginas de lectura (Inicio, Taller, Guardados, Aprender): una columna centrada que se desplaza. */
:root {
  --bg: #e9ecf1; --surface: #ffffff; --surface-2: #f3f5f8; --ink: #151b24; --ink-2: #435063; --muted: #66707f; --line: #d6dbe3; --line-2: #c2cad6;
  --accent: #d6336c; --accent-ink: #ffffff; --accent-soft: #fde4ec; --accent-line: #f3a6c1;
  --ok: #19824f; --ok-soft: #dcf1e5; --bad: #c63a2a; --bad-soft: #fbe2de; --warn: #b07800; --warn-soft: #fff3cd; --info: #1c6dd0; --info-soft: #e2edfb;
  --shadow: 0 1px 2px rgba(20, 28, 40, .06), 0 8px 24px rgba(20, 28, 40, .08);
  --f-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --f-ui: 'Instrument Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --pw: 414px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1016; --surface: #141a23; --surface-2: #1a222d; --ink: #e7ecf3; --ink-2: #b2bdcc; --muted: #8592a5; --line: #27313f; --line-2: #33404f;
    --accent: #ff6b9b; --accent-ink: #1a0b12; --accent-soft: #3a1726; --accent-line: #7a2c49;
    --ok: #46c08b; --ok-soft: #163326; --bad: #ff6d5c; --bad-soft: #3d1d19; --warn: #ffc83a; --warn-soft: #3b3014; --info: #7eb2ff; --info-soft: #1a2a42;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1016; --surface: #141a23; --surface-2: #1a222d; --ink: #e7ecf3; --ink-2: #b2bdcc; --muted: #8592a5; --line: #27313f; --line-2: #33404f;
  --accent: #ff6b9b; --accent-ink: #1a0b12; --accent-soft: #3a1726; --accent-line: #7a2c49;
  --ok: #46c08b; --ok-soft: #163326; --bad: #ff6d5c; --bad-soft: #3d1d19; --warn: #ffc83a; --warn-soft: #3b3014; --info: #7eb2ff; --info-soft: #1a2a42;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--f-ui); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font: 600 10.5px var(--f-mono); padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); }
.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }

/* barra superior */
.bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.author { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; margin-right: 2px; border-right: 1px solid var(--line); flex: none; color: var(--ink-2); text-decoration: none; font: 600 12.5px var(--f-mono); white-space: nowrap; }
.author svg { width: 20px; height: 20px; flex: none; }
.author:hover { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 8px; font: 800 19px/1 var(--f-display); letter-spacing: -.02em; white-space: nowrap; color: var(--ink); text-decoration: none; flex: none; }
.brand b { color: var(--accent); font-weight: 800; }
.brand svg { width: 30px; height: 30px; flex: none; }
.mname { min-width: 0; width: 210px; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 5px 8px; font-weight: 600; color: var(--ink-2); text-overflow: ellipsis; }
.mname:hover { border-color: var(--line); } .mname:focus { border-color: var(--accent); outline: none; background: var(--surface-2); color: var(--ink); }
.nav { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; margin-left: 6px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 13.5px; white-space: nowrap; flex: none; }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"] svg { opacity: 1; }
.menus { display: flex; gap: 2px; }
.mwrap { position: relative; }
.mbtn { border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.mbtn:hover, .mbtn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.dd { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.dd button { display: flex; justify-content: space-between; gap: 16px; border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 7px; white-space: nowrap; }
.dd button:hover { background: var(--accent-soft); }
.dd hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.bar-r { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.ib { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); flex: none; }
.ib:hover { background: var(--surface-2); color: var(--ink); } .ib svg { width: 18px; height: 18px; }

/* zona de trabajo */
.work { display: grid; grid-template-columns: auto minmax(0, 1fr) var(--pw); min-height: 0; }
.tools { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; background: var(--surface); border-right: 1px solid var(--line); width: 86px; overflow-y: auto; }
.tool { display: grid; justify-items: center; gap: 2px; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 7px 4px 5px; color: var(--ink-2); font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.15; }
.tool svg { width: 22px; height: 22px; } .tool kbd { font-size: 9.5px; padding: 0 4px; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
.tool.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tool:disabled { opacity: .38; cursor: default; background: transparent; }
.tsep { height: 1px; background: var(--line); margin: 6px 4px; }
.tlabel { font: 600 10px var(--f-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 30%, color-mix(in srgb, var(--bg) 70%, #000 0%), var(--bg)); display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.board-wrap { position: relative; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hint { position: absolute; left: 12px; top: 10px; max-width: min(620px, calc(100% - 230px)); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 6px 11px; font-size: 12.5px; color: var(--ink-2); pointer-events: none; box-shadow: var(--shadow); }
.hint b { color: var(--ink); } .hint:empty { display: none; }
.badge { position: absolute; right: 12px; top: 10px; display: flex; gap: 6px; pointer-events: none; }
.badge span.rec { color: #e03131; border-color: #e03131; }
.badge span { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font: 600 12px var(--f-mono); color: var(--ink-2); }

/* reproductor */
.player { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); flex-wrap: wrap; }
.player .go { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 8px 16px; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.player .go:hover { filter: brightness(1.07); }
.player .go svg { width: 16px; height: 16px; }
.clock { font: 700 15px var(--f-mono); min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); }
.player select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.player .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--surface-2); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* grabar y repetir */
.recb { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 6px 11px; font-weight: 700; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.recb i { width: 11px; height: 11px; border-radius: 50%; background: #e03131; box-shadow: 0 0 0 2px color-mix(in srgb, #e03131 25%, transparent); }
.recb:hover { background: var(--surface-2); }
.recb.on { border-color: #e03131; color: #e03131; background: color-mix(in srgb, #e03131 10%, var(--surface)); }
.recb.on i { animation: blink 1s steps(2, start) infinite; border-radius: 2px; }
@keyframes blink { to { visibility: hidden; } }
.rplayer { background: color-mix(in srgb, var(--info) 9%, var(--surface)); }
.rtag { font: 700 10.5px var(--f-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--info); border: 1px solid currentColor; border-radius: 6px; padding: 2px 7px; }
.rplayer input[type=range] { flex: 1; min-width: 120px; accent-color: var(--info); }
.rplayer .go { background: var(--info); color: #fff; }
:root[data-theme="dark"] .rplayer .go { color: #0b1424; }

/* panel derecho */
.panel { background: var(--surface); border-left: 1px solid var(--line); display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); min-width: 0; min-height: 0; }
.phead { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.pht { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.pht h1 { margin: 0; font: 800 20px/1.1 var(--f-display); letter-spacing: -.01em; }
.pht > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mnamef { align-items: center; } .mnamef > span { font: 700 11px var(--f-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); flex: none; }
.mnamef .mname { flex: 1; width: auto; font: 800 17px var(--f-display); color: var(--ink); padding: 4px 8px; }
.phead .sheetT { display: none; }
.work[data-tab="prog"] .phead { display: none; }
.work[data-tab="prog"] .panel { grid-template-rows: minmax(0, 1fr); }
.trackl { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 7px 10px; margin-bottom: 14px; }
.trackl b { color: var(--ink); }
a.lnk { text-decoration: underline; cursor: pointer; }
.pbody { overflow-y: auto; padding: 14px 16px 28px; min-height: 0; }
.sec { display: grid; gap: 10px; padding-bottom: 16px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h3 { margin: 0; font: 700 11px var(--f-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.sec h2 { margin: 0; font: 800 19px/1.2 var(--f-display); letter-spacing: -.01em; text-wrap: balance; }
.sec p { margin: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 4px; } .field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.in:focus { border-color: var(--accent); outline: none; background: var(--surface); }
textarea.in { font: 11.5px/1.25 var(--f-mono); resize: vertical; min-height: 150px; white-space: pre; }
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 7px 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn.pri:hover { filter: brightness(1.07); background: var(--accent); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.dng { color: var(--bad); }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.note { font-size: 12.5px; color: var(--ink-2); margin: 0; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .pill.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; } .pill.run { background: var(--warn-soft); color: var(--warn); border-color: transparent; } .pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.lvl { font: 700 10px var(--f-ui); text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px; }
.lvl.l0 { background: #e6fcf5; color: #087f5b; } .lvl.l1 { background: #e7f5ff; color: #1864ab; } .lvl.l2 { background: #f3f0ff; color: #6741d9; } .lvl.l3 { background: #ebfbee; color: #2b8a3e; } .lvl.l4 { background: #fff0f6; color: #c2255c; } .lvl.l5 { background: #fff9db; color: #a36200; }
:root[data-theme="dark"] .lvl { filter: brightness(.85) saturate(1.2); }

/* tarjetas de robots */
.rcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; display: grid; gap: 7px; background: var(--surface); min-width: 0; }
.sec { grid-template-columns: minmax(0, 1fr); }
.sec > *, .rcard > * { min-width: 0; }
.rcard { grid-template-columns: minmax(0, 1fr); }
.rcard .row select { flex: 1; min-width: 0; }
.rcard.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.rhead { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.rdot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2); }
.rname { font-weight: 700; flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rstats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.rstats div { background: var(--surface-2); border-radius: 8px; padding: 4px 6px; }
.rstats b { display: block; font: 700 13.5px var(--f-mono); font-variant-numeric: tabular-nums; }
.rstats span { font-size: 10.5px; color: var(--muted); }
.rmsg { font-size: 12.5px; color: var(--ink-2); min-height: 18px; }
.rcard select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 7px; padding: 3px 6px; font-size: 12.5px; max-width: 100%; }
.rcard .ib { width: 28px; height: 28px; } .rcard .ib svg { width: 15px; height: 15px; }
.phase { display: flex; gap: 3px; } .phase i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); } .phase i.on { background: var(--accent); } .phase i.done { background: var(--ok); }

/* tablas */
.tw { overflow-x: auto; max-width: 100%; }
table.st { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
table.st th, table.st td { padding: 5px 7px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.st th { font-weight: 700; color: var(--muted); font-size: 11px; background: var(--surface-2); }
table.st td.num, table.st th.num { text-align: right; }
table.st tr.best td { background: var(--ok-soft); } table.st tr.click { cursor: pointer; } table.st tr.click:hover td { background: var(--accent-soft); }

/* lista de algoritmos de búsqueda */
.alist { display: grid; gap: 6px; }
.aitem { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 11px; display: grid; gap: 2px; }
.aitem:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.aitem.on { border-color: var(--accent); background: var(--accent-soft); }
.aitem b { font-weight: 650; font-size: 13.5px; } .aitem span { font-size: 12px; color: var(--muted); }
.pctl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pctl input[type=range] { flex: 1; min-width: 100px; accent-color: var(--accent); }
.pcount { font: 600 12px var(--f-mono); color: var(--muted); min-width: 70px; text-align: center; }
.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 6px; font-size: 12.5px; align-items: baseline; }
.kv > span { color: var(--muted); font-weight: 600; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* tarjetas: datos extra */
.rx { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 5px 8px; }
.rx b { font: 700 13px var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.trips { display: flex; flex-wrap: wrap; gap: 4px; } .trips:empty { display: none; }
.trips span { font: 600 11px var(--f-mono); padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.trips span.v { border-color: var(--accent-line); }
.trips span.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.rcard.paused { border-style: dashed; }
.scorebar { height: 6px; border-radius: 3px; background: var(--accent); min-width: 2px; }
td .scorebar { display: inline-block; vertical-align: middle; margin-left: 6px; }

/* soluciones */
.sols { display: grid; gap: 6px; }
.sol { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; cursor: pointer; }
.sol:hover { border-color: var(--accent-line); }
.sol input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.sol i { width: 22px; height: 5px; border-radius: 3px; display: block; }
.sol i.dash { background: repeating-linear-gradient(90deg, #66d9e8 0 6px, transparent 6px 10px) !important; }
.sol b { display: block; font-size: 13px; } .sol span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.movetxt { font: 12.5px/1.6 var(--f-mono); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; word-break: break-word; }

/* biblioteca */
.lib { display: grid; gap: 8px; }
.li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px 10px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; align-items: start; }
.li canvas { width: 64px; height: 64px; border-radius: 8px; display: block; background: #0f1216; grid-row: span 2; }
.li .lt { display: grid; gap: 1px; min-width: 0; } .li .lt b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .li .lt span { font-size: 12px; color: var(--muted); }
.li .la { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; grid-column: 2; }
.li .la .ib { width: 30px; height: 30px; } .li .la .ib svg { width: 16px; height: 16px; }
.li .dots { display: flex; gap: 3px; flex-wrap: wrap; } .li .dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.empty { font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px; text-align: center; }
.store { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; }
.store i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

/* galería */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0; overflow: hidden; display: grid; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card canvas { width: 100%; aspect-ratio: 1; display: block; background: #0f1216; }
.card .cb { padding: 7px 9px 9px; display: grid; gap: 2px; } .card b { font-size: 13px; } .card span { font-size: 11.5px; color: var(--muted); }

/* aprender */
.learn h2 { font: 800 18px/1.25 var(--f-display); margin: 0 0 4px; }
.learn p, .learn li { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.learn ul, .learn ol { padding-left: 18px; margin: 4px 0; }
.learn .tip { background: var(--warn-soft); border-radius: 10px; padding: 9px 11px; font-size: 13px; color: var(--ink); }
.learn .fig { background: #0f1216; border-radius: 10px; padding: 8px; }
.learn .fig canvas { width: 100%; display: block; }

/* avisos y diálogos */
.toast { display: flex; align-items: center; gap: 12px; position: fixed; left: 50%; top: calc(62px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -12px); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.act { pointer-events: auto; }
.toast button { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 7px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(8, 12, 18, .5); display: grid; place-items: center; padding: 16px; }
.dlg { width: min(760px, 100%); max-height: calc(100% - 24px); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.dlg > header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--line); }
.dlg h2 { margin: 0; font: 800 20px var(--f-display); }
.mbody { padding: 16px 20px; overflow-y: auto; }
.mfoot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; } .mfoot:empty { display: none; }
.about { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); margin-bottom: 14px; }
.about .gh { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink); flex: none; } .about .gh svg { width: 32px; height: 32px; }
.about a { color: var(--accent); font-weight: 700; }
.about p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; } .about p b { color: var(--ink); }
.podium { display: grid; gap: 6px; }
.podium div { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }
.podium .medal { font-size: 22px; }

/* pantallas bajas: herramientas más compactas */
@media (max-height: 980px) and (min-width: 821px) { .tool kbd { display: none; } .tool { padding: 5px 4px 4px; } .tsep { margin: 3px 4px; } }

/* pantallas angostas */
@media (max-width: 1280px) { :root { --pw: 388px; } .nav a svg { display: none; } .nav a { padding: 7px 8px; } }
@media (max-width: 1050px) { :root { --pw: 360px; } .brand span { display: none; } .author span { display: none; } .author { padding-right: 8px; } .nav a { font-size: 13px; padding: 7px 7px; } }
@media (max-width: 820px) {
  .bar { flex-wrap: wrap; gap: 4px 8px; padding: 6px 10px; }
  .author span { display: inline; }
  .nav { order: 3; flex: 1 1 100%; margin: 0 -10px; padding: 0 6px; border-top: 1px solid var(--line); padding-top: 4px; }
  .nav a svg { display: block; } .nav a { padding: 6px 9px; font-size: 13px; }
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .tools { flex-direction: row; width: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 5px 6px; overflow-x: auto; }
  .tool { padding: 5px 8px; min-width: 56px; flex: none; } .tool kbd, .tsep, .tlabel { display: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: 44vh; }
  .panel.collapsed .pbody { display: none; }
  .phead { padding: 6px 8px 6px 12px; } .pht h1 { font-size: 17px; }
  .phead .sheetT { display: grid; flex: none; }
  .work[data-tab="prog"] .phead { display: flex; } .work[data-tab="prog"] .panel { grid-template-rows: auto minmax(0, 1fr); }
  .player { padding: 6px 8px; gap: 4px; } .player .lbl { display: none; } .rplayer input[type=range] { order: 9; flex-basis: 100%; } .rtag { display: none; }
  .hint { display: none; }
  .badge { display: none; }
}
@media (max-width: 520px) { .recb span { display: none; } .recb { padding: 8px 10px; } .rstats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .clock { min-width: 70px; font-size: 13px; } }

/* ===================== idioma ===================== */
.langb { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 999px; padding: 2px; margin-right: 4px; font: 700 11.5px var(--f-ui); letter-spacing: .04em; }
.langb span { padding: 4px 8px; border-radius: 999px; color: var(--muted); }
.langb span.on { background: var(--accent); color: var(--accent-ink); }
.langb:hover span:not(.on) { color: var(--ink); }

/* ===================== tarjetas: cuerpo y programa ===================== */
.rtags { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 2px 9px 2px 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); max-width: 100%; }
.chip svg { width: 14px; height: 14px; flex: none; } .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--accent-line); color: var(--ink); background: var(--accent-soft); }
.rmsg.err { color: var(--bad); font-weight: 600; }
.li .pico { width: 64px; height: 64px; border-radius: 8px; display: grid; place-items: center; font-size: 30px; background: var(--surface-2); grid-row: span 2; }

/* ===================== Taller ===================== */
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
.presets button { display: grid; gap: 0; padding: 6px 4px; line-height: 1.15; }
.presets button b { font: 800 18px var(--f-display); } .presets button span { font-size: 10.5px; color: var(--muted); }
.presets button.on span { color: var(--accent); }
.shopgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.shopfig { max-width: 340px; width: 100%; justify-self: center; }
.shopsel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; } .shopsel > h4, .shopsel > .btns, .shopsel > p { grid-column: 1 / -1; }
.shopfig { display: grid; gap: 6px; }
.shopsvg { width: 100%; height: auto; border-radius: 12px; display: block; background: #121519; }
.shopsvg .slot { cursor: pointer; outline: none; } .shopsvg text { pointer-events: none; } .shopsvg .slot:focus-visible circle:nth-child(2) { stroke: var(--accent); stroke-width: 4; }
.shopsvg .slot.off:hover circle:nth-child(2) { stroke: #fff; }
.shopsel { display: grid; gap: 8px; align-content: start; }
.shopsel h4 { margin: 0; font: 700 13.5px var(--f-ui); }
.shopsel input[type=range] { width: 100%; accent-color: var(--accent); }
.kv.caps { grid-template-columns: 150px minmax(0, 1fr); }
.note.tip { background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; color: var(--ink); }
@media (max-width: 520px) { .shopsel { grid-template-columns: minmax(0, 1fr); } }

/* ===================== Programar ===================== */
.work[data-tab="prog"] { --pw: clamp(430px, 46vw, 820px); }
.work.pfull[data-tab="prog"] { --pw: calc(100vw - 240px); }
.pbody.pbody-prog { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.prog { display: flex; flex-direction: column; min-height: 0; height: 100%; gap: 0; }
.ptool, .prun { display: flex; align-items: center; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; }
.ptool select.in { width: auto; max-width: 230px; padding: 5px 8px; font-size: 12.5px; }
.ptool .grow { flex: 1; }
.prun { padding-top: 8px; }
.prun .chk { font-size: 12.5px; margin-left: 4px; }
.prun select.in { width: auto; padding: 4px 8px; font-size: 12.5px; }
.pinfo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 12px 0; font-size: 12.5px; color: var(--ink-2); min-height: 24px; }
.pinfo .rdot { width: 11px; height: 11px; }
.pnote { margin: 6px 12px 0; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; } .pnote:empty, .pnote[hidden] { display: none; }
.pmain { flex: 1 1 auto; min-height: 260px; display: flex; flex-direction: column; padding: 8px 12px 0; }
.pv { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.pv.ref { overflow-y: auto; padding-right: 4px; }
.bkhost { flex: 1 1 auto; min-height: 240px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; position: relative; }
.pwarn { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 5px 9px; }
.bkpy { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.bkpy summary { cursor: pointer; padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.bkpy .gen { max-height: 180px; overflow: auto; margin: 0 8px 8px; }
.code { font: 12.5px/19px var(--f-mono); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; white-space: pre; overflow-x: auto; margin: 0; color: var(--ink); }
.pstat { margin: 6px 12px 0; font-size: 12.5px; border-radius: 9px; padding: 7px 10px; line-height: 1.4; }
.pstat.bad { background: var(--bad-soft); color: var(--ink); border-left: 4px solid var(--bad); } .pstat.bad b { color: var(--bad); }
.pstat.warn { background: var(--warn-soft); color: var(--ink); border-left: 4px solid var(--warn); } .pstat.warn b { color: var(--warn); }
.pstale { margin: 6px 12px 0; font-size: 12px; color: var(--info); }
.lnk { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; text-decoration: underline; font-size: inherit; }
.pcon { margin: 8px 12px 0; border: 1px solid var(--line); border-radius: 10px; background: #0f1319; color: #d8dee9; display: flex; flex-direction: column; flex: 0 0 auto; }
.pch { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-bottom: 1px solid #222a35; font-size: 12px; color: #aeb7c4; }
.pch .grow { flex: 1; } .pch .lnk { color: #ff8cc6; font-size: 12px; }
.pcb { font: 12px/18px var(--f-mono); padding: 6px 10px; height: 96px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.pcb .ct { color: #8592a5; margin-right: 8px; font-size: 11px; } .pcb .muted { color: #8592a5; }
.pfoot { display: flex; align-items: center; gap: 6px; padding: 8px 12px 10px; flex-wrap: wrap; }
.pfoot .in { flex: 1 1 140px; width: auto; padding: 5px 8px; }

/* editor de Python */
.ed { position: relative; flex: 1 1 auto; min-height: 240px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; font: 13px/20px var(--f-mono); }
.ed:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ed-scroll { position: absolute; inset: 0; overflow: auto; }
.ed-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 100%; min-width: max-content; }
.ed-gut { padding: 10px 6px 10px 6px; text-align: right; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--line); position: sticky; left: 0; z-index: 1; user-select: none; min-width: 44px; font: inherit; }
.ed-gut div { height: 20px; white-space: nowrap; }
.ed-gut .err { color: var(--bad); font-weight: 700; } .ed-gut .run { color: #fff; background: var(--ok); border-radius: 4px; padding-right: 3px; }
.ed-cell { display: grid; position: relative; }
.ed-hl, .ed-ta { grid-area: 1 / 1; margin: 0; padding: 10px 12px; font: inherit; letter-spacing: 0; tab-size: 4; white-space: pre; border: 0; min-width: 0; }
.ed-hl { color: var(--ink); pointer-events: none; }
.ed-hl div { height: 20px; }
.ed-hl .err { background: color-mix(in srgb, var(--bad) 16%, transparent); box-shadow: inset 3px 0 0 var(--bad); }
.ed-hl .run { background: color-mix(in srgb, var(--ok) 20%, transparent); box-shadow: inset 3px 0 0 var(--ok); }
.ed-ta { color: transparent; caret-color: var(--ink); background: transparent; resize: none; outline: none; overflow: hidden; min-height: 100%; }
.ed-ta::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); color: transparent; }
.ed-ac { position: absolute; z-index: 5; width: 300px; max-height: 250px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; font-family: var(--f-ui); }
.aci { padding: 5px 8px; border-radius: 7px; display: grid; gap: 1px; cursor: pointer; }
.aci b { font: 600 12.5px var(--f-mono); } .aci span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aci.on, .aci:hover { background: var(--accent-soft); }
.hk { color: #c2255c; font-weight: 600; } .hp { color: #0b7285; font-weight: 700; } .hn { color: #b8400a; } .hb { color: #5f3dc4; } .hs { color: #237a36; } .hc { color: #66707d; font-style: italic; } .hd { color: #1864ab; font-weight: 600; }
:root[data-theme="dark"] .hk { color: #ff8cc6; } :root[data-theme="dark"] .hp { color: #63e6be; } :root[data-theme="dark"] .hn { color: #ffa94d; } :root[data-theme="dark"] .hb { color: #b197fc; } :root[data-theme="dark"] .hs { color: #8ce99a; } :root[data-theme="dark"] .hc { color: #8592a5; } :root[data-theme="dark"] .hd { color: #74c0fc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hk { color: #ff8cc6; } :root:not([data-theme="light"]) .hp { color: #63e6be; } :root:not([data-theme="light"]) .hn { color: #ffa94d; } :root:not([data-theme="light"]) .hb { color: #b197fc; } :root:not([data-theme="light"]) .hs { color: #8ce99a; } :root:not([data-theme="light"]) .hc { color: #8592a5; } :root:not([data-theme="light"]) .hd { color: #74c0fc; } }

/* referencia de primitivas */
.prim { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 5px; }
.prim .ph { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prim code, .note code, .learn code { font: 600 12.5px var(--f-mono); background: var(--surface-2); border-radius: 5px; padding: 1px 5px; }
.prim .ph code { color: var(--accent); background: transparent; padding: 0; font-size: 13px; }
.prim p { font-size: 12.5px; color: var(--ink-2); }
.pret { font: 600 11.5px var(--f-mono); color: var(--muted); } .pmv { font-size: 13px; }
.pex { display: flex; gap: 6px; align-items: flex-start; } .pex .code { flex: 1; font-size: 12px; line-height: 18px; padding: 6px 8px; }
.palias { font-size: 11.5px; color: var(--muted); } .palias code { font-size: 11.5px; }

/* Blockly dentro de la página */
.bkhost .blocklySvg { background: transparent; }
.blocklyToolboxDiv { font-family: var(--f-ui) !important; }
.blocklyTreeLabel, .blocklyToolboxCategoryLabel { font: 600 12.5px var(--f-ui) !important; }
.blocklyWidgetDiv, .blocklyDropDownDiv, .blocklyTooltipDiv { z-index: 95 !important; }
.blocklyTooltipDiv { font-family: var(--f-ui) !important; max-width: 320px; }

@media (max-width: 1280px) and (min-width: 821px) { .work[data-tab="prog"] { --pw: clamp(420px, 52vw, 760px); } .work[data-tab="prog"] .tools { width: 70px; } }
@media (max-width: 820px) {
  .work[data-tab="prog"] .panel { max-height: 72vh; }
  .work[data-tab="shop"] .panel { max-height: 60vh; }
  .work.pfull[data-tab="prog"] .stage { display: none; }
  .work.pfull[data-tab="prog"] .panel { max-height: none; }
  .langb span { padding: 3px 6px; }
  .bkhost { min-height: 300px; }
}

.note.steps { padding-left: 20px; margin: 0; display: grid; gap: 2px; }

/* ===================== páginas de lectura (Inicio, Taller, Guardados, Aprender) ===================== */
.doc { overflow-y: auto; min-height: 0; }
.docin { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.dochead { margin-bottom: 20px; max-width: 760px; }
.dochead h1 { margin: 0 0 6px; font: 800 34px/1.05 var(--f-display); letter-spacing: -.02em; }
.dochead p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; text-wrap: pretty; }
.docpage .doc .sec { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px 18px; margin-bottom: 16px; }
.docpage .doc .sec:last-child { border-bottom: 1px solid var(--line); }
.docpage .doc .sec h3 { font-size: 11.5px; }

/* Taller: el robot a la izquierda, lo que puede hacer y la comparación a la derecha */
.shopcols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 18px; align-items: start; }
.docpage .shopgrid { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 18px; }
.docpage .shopfig { max-width: 300px; }
.docpage .shopsel { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1020px) { .shopcols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .docpage .shopgrid { grid-template-columns: minmax(0, 1fr); } .docpage .shopfig { justify-self: center; } }

/* Guardados */
.docpage .lib { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.libcur { display: flex; align-items: center; gap: 14px; }
.libcur canvas { width: 88px; height: 88px; border-radius: 10px; background: #0f1216; flex: none; }
.libcur div { display: grid; gap: 2px; } .libcur b { font-size: 15px; }

/* Aprender: índice a la izquierda */
.learnpage { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start; }
.toc { position: sticky; top: 0; display: grid; gap: 1px; padding: 4px 0; }
.toc b { font: 700 11px var(--f-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 10px 6px; }
.toc a { color: var(--ink-2); text-decoration: none; font-size: 13.5px; padding: 5px 10px; border-radius: 8px; line-height: 1.3; }
.toc a:hover { background: var(--surface); color: var(--ink); }
.learnpage .learn { max-width: 780px; }
.learnpage .learn .sec { scroll-margin-top: 16px; }
.learnpage .learn h2 { font-size: 21px; }
.learnpage .learn p, .learnpage .learn li { font-size: 14.5px; }
@media (max-width: 900px) { .learnpage { grid-template-columns: minmax(0, 1fr); } .toc { position: static; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
@media (max-width: 640px) { .toc { display: none; } }

/* Inicio */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 18px 0 30px; }
.eyebrow { font: 700 11.5px var(--f-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: 0; }
.hero h1 { margin: 8px 0 12px; font: 800 clamp(40px, 6vw, 64px)/1 var(--f-display); letter-spacing: -.03em; }
.hero h1 span { color: var(--accent); }
.hero .lead { margin: 0 0 20px; font-size: 16.5px; line-height: 1.55; color: var(--ink-2); max-width: 58ch; text-wrap: pretty; }
.btn.lg { padding: 10px 18px; font-size: 15px; border-radius: 11px; text-decoration: none; color: inherit; }
.btn.pri.lg { color: var(--accent-ink); }
.now { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.now:hover { border-color: var(--accent-line); }
.now canvas { width: 150px; height: 150px; border-radius: 10px; background: #0f1216; display: block; }
.now-t { display: grid; gap: 4px; min-width: 0; } .now-t b { font: 800 19px/1.2 var(--f-display); }
.now .dots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; } .now .dots i { width: 12px; height: 12px; border-radius: 50%; display: block; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.pcard { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: start; align-content: start; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.pcard .pic { grid-row: span 2; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.pcard .pic svg { width: 22px; height: 22px; }
.pcard b { font: 800 17px/1.2 var(--f-display); } .pcard > span:last-child { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.foot { display: flex; align-items: center; gap: 14px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.foot svg { width: 26px; height: 26px; color: var(--ink-2); flex: none; }
.foot a { color: var(--accent); font-weight: 700; text-decoration: none; } .foot a:hover { text-decoration: underline; }
.foot p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 20px; } }
@media (max-width: 520px) { .docin { padding: 18px 16px 48px; } .dochead h1 { font-size: 28px; } .now { grid-template-columns: 96px minmax(0, 1fr); } .now canvas { width: 96px; height: 96px; } .docpage .doc .sec { padding: 14px; } .docpage .lib { grid-template-columns: minmax(0, 1fr); } }

/* ===================== Aprender: dos caminos (teoría y misiones) ===================== */
.paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.path { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.path:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.path.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.path .pi { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 23px; background: var(--surface-2); }
.path.on .pi { background: var(--accent-soft); }
.path .pt { display: grid; gap: 3px; min-width: 0; }
.path b { font: 800 17px/1.2 var(--f-display); }
.path .pt > span { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.path em { font-style: normal; font: 600 12px var(--f-ui); color: var(--accent); }
@media (max-width: 640px) { .paths { grid-template-columns: minmax(0, 1fr); } }

/* ===================== Misiones: mapa ===================== */
.quest .docin { max-width: 1120px; }
.pipav { width: 64px; height: 64px; flex: none; display: block; }
.qhero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.qhero .pipav { width: 84px; height: 84px; }
.qhero h1 { margin: 0 0 4px; font: 800 32px/1.05 var(--f-display); letter-spacing: -.02em; }
.qhero p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; max-width: 62ch; text-wrap: pretty; }
.qprog { display: grid; gap: 6px; justify-items: start; min-width: 200px; }
.qprog b { font: 800 22px var(--f-display); } .qprog > span { font-size: 12.5px; color: var(--muted); }
.qprog i { display: block; width: 100%; height: 8px; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; }
.qprog i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: linear-gradient(90deg, #fab005, #ff6b9b); border-radius: 4px; }
.qprog .btn { margin-top: 4px; text-decoration: none; }
.qopts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 2px 16px; }
.qopts .grow { flex: 1; }
.qworld { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px 18px; margin-bottom: 14px; border-top: 4px solid var(--wc); }
.qworld header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.qworld .wi { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--wc) 16%, var(--surface)); flex: none; }
.qworld h2 { margin: 0; font: 800 19px/1.2 var(--f-display); }
.qworld header p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.qworld .wst { margin-left: auto; font: 700 13px var(--f-mono); color: var(--ink-2); white-space: nowrap; }
.qpath { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qpath li { position: relative; display: grid; justify-items: center; text-align: center; gap: 4px; padding: 10px 6px 8px; border-radius: 12px; }
.qpath li b { font-size: 13px; line-height: 1.25; text-wrap: balance; }
.qpath li .qt { font-size: 11.5px; color: var(--muted); }
.qnode { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; color: var(--ink); border: 3px solid var(--line-2); background: var(--surface-2); transition: transform .15s; }
.qnode .num { font: 800 20px var(--f-display); }
.qnode .qty { position: absolute; right: -6px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); }
.qpath li.open .qnode { border-color: var(--wc); background: var(--surface); }
.qpath li.done .qnode { border-color: var(--wc); background: var(--wc); color: #fff; }
.qpath li.locked { opacity: .55; } .qpath li.locked .qnode { cursor: not-allowed; }
.qpath li:not(.locked) .qnode:hover { transform: scale(1.07); }
.qpath li.next .qnode { animation: qpulse 1.8s infinite; }
@keyframes qpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--wc) 50%, transparent); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.qst { display: inline-flex; gap: 1px; font-size: 15px; line-height: 1; letter-spacing: 0; }
.qst i { font-style: normal; color: var(--line-2); } .qst i.on { color: #fab005; }
@media (max-width: 760px) { .qhero { grid-template-columns: auto minmax(0, 1fr); } .qprog { grid-column: 1 / -1; width: 100%; } .qhero .pipav { width: 60px; height: 60px; } .qhero h1 { font-size: 26px; } }

/* ===================== Misiones: un nivel ===================== */
.quest.qlevel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; position: relative; }
.qhead { display: flex; align-items: center; gap: 10px; padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--line); border-top: 3px solid var(--wc); flex-wrap: wrap; min-width: 0; }
.qhead .btn { text-decoration: none; color: inherit; }
.qtitle { display: grid; min-width: 0; }
.qtitle span { font: 700 11px var(--f-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--wc); }
.qtitle h1 { margin: 0; font: 800 21px/1.15 var(--f-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qhead .grow { flex: 1; }
.qhead .qst { font-size: 18px; }
.qnav { display: flex; gap: 2px; } .qnav .ib { font-size: 22px; line-height: 1; text-decoration: none; } .qnav [aria-disabled="true"] { opacity: .3; pointer-events: none; }
.qbody { display: grid; grid-template-columns: minmax(340px, 0.85fr) minmax(0, 1.15fr); min-height: 0; }
.qleft { overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 12px; border-right: 1px solid var(--line); min-width: 0; }
.qright { min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 14px; min-width: 0; overflow-y: auto; }
.pip { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; }
.pip .pipav { width: 54px; height: 54px; margin-top: 2px; }
.bubble { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 13px; font-size: 14px; line-height: 1.5; color: var(--ink); box-shadow: var(--shadow); }
.bubble::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; background: inherit; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
.bubble.ok { background: var(--ok-soft); border-color: transparent; } .bubble.ok::before { border-color: transparent; }
.bubble.bad { background: var(--bad-soft); border-color: transparent; } .bubble.bad::before { border-color: transparent; }
.bubble.hint { background: var(--warn-soft); border-color: transparent; } .bubble.hint::before { border-color: transparent; }
.bubble code, .qask code, .learnbox code, .qexp code { font: 600 12.5px var(--f-mono); background: color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 5px; padding: 1px 5px; }
.qgoals { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.qgoals li { display: flex; gap: 8px; align-items: baseline; }
.qgoals li i { font-style: normal; width: 18px; flex: none; text-align: center; font-weight: 800; color: var(--muted); }
.qgoals li.star i { color: var(--line-2); }
.qgoals li.ok { color: var(--ink); } .qgoals li.ok i { color: var(--ok); } .qgoals li.star.ok i { color: #fab005; }
.qgoals li.no i { color: var(--bad); } .qgoals li.star.no { color: var(--muted); } .qgoals li.star.no i { color: var(--line-2); }
.qtests { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qtb { min-width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font: 700 12.5px var(--f-mono); color: var(--ink-2); }
.qtb.cur { border-color: var(--wc); box-shadow: 0 0 0 2px color-mix(in srgb, var(--wc) 25%, transparent); color: var(--ink); }
.qtb.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .qtb.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.qboard { position: relative; background: #0c0f13; border-radius: 14px; overflow: hidden; flex: none; min-height: 150px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); }
.qboard canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.qctl { display: flex; align-items: center; gap: 8px; } .qctl .grow { flex: 1; }
.qctl select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 8px; font-size: 13px; }
.qclock { font: 700 13.5px var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.qed { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }
.qedbar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); } .qedbar .grow { flex: 1; }
.qsize .okc { color: var(--ok); font-weight: 700; }
.qpv { flex: 1 1 auto; min-height: 280px; display: flex; flex-direction: column; gap: 6px; }
.qpv .bkhost { min-height: 300px; }
.qpv .ed { min-height: 260px; }
.qpal { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.qchip { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 3px 8px; cursor: pointer; }
.qchip code { font: 600 12px var(--f-mono); color: #0b7285; }
.qchip.kw code { color: #c2255c; }
:root[data-theme="dark"] .qchip code { color: #63e6be; } :root[data-theme="dark"] .qchip.kw code { color: #ff8cc6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qchip code { color: #63e6be; } :root:not([data-theme="light"]) .qchip.kw code { color: #ff8cc6; } }
.qchip:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.qright .pstat { margin: 0; }
.qrun { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.qrun .btn small { font: 600 11px var(--f-mono); color: var(--muted); }
.qrun .grow { flex: 1; }
.qask { display: grid; gap: 12px; align-content: start; }
.qask h3 { margin: 4px 0 0; font: 800 19px/1.25 var(--f-display); }
.qrace { display: flex; gap: 6px; flex-wrap: wrap; } .qrace .rdot { width: 11px; height: 11px; display: inline-block; }
.qprogv { display: grid; gap: 6px; } .qprogv b { font: 700 11px var(--f-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.qprogv .code { font-size: 14px; line-height: 22px; padding: 12px 14px; }
.qopts2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.qopt { border: 2px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 14px 12px; font: 700 15px var(--f-ui); color: var(--ink); text-align: center; transition: transform .12s, border-color .12s; }
.qopt:hover:not(:disabled) { border-color: var(--wc); transform: translateY(-1px); }
.qopt:disabled { cursor: default; }
.qopt.picked { border-color: var(--info); background: var(--info-soft); }
.qopt.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.qopt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.qbudget { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 10px; font-size: 13px; color: var(--ink-2); }
.qbudget b { font: 800 18px var(--f-mono); color: var(--ink); }
.qbar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.qbar i { position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--wc); border-radius: 3px; transition: width .2s; }

/* festejo */
.qwin { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(2px); }
.qwin-card { width: min(520px, 100%); max-height: calc(100% - 16px); overflow-y: auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 18px 22px 20px; display: grid; gap: 10px; text-align: center; border-top: 5px solid var(--wc); }
.qwin-card h2 { margin: 0; font: 800 26px/1.1 var(--f-display); }
.qwin-card > p { margin: 0; }
.qwin-stars { display: flex; justify-content: center; gap: 8px; font-size: 46px; line-height: 1; }
.qwin-stars i { font-style: normal; color: var(--line); transform: scale(.4); opacity: 0; animation: qstar .45s cubic-bezier(.3, 1.6, .5, 1) forwards; animation-delay: var(--d); }
.qwin-stars i.on { color: #fab005; text-shadow: 0 2px 10px rgba(250, 176, 5, .45); }
@keyframes qstar { to { transform: scale(1); opacity: 1; } }
.qwin-card .qgoals { text-align: left; justify-self: center; }
.qexp { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; text-align: left; }
.learnbox { text-align: left; background: var(--surface-2); border-radius: 12px; padding: 10px 13px; display: grid; gap: 4px; }
.learnbox b { font-size: 13px; } .learnbox p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.qwin-card .btns { justify-content: center; margin-top: 4px; }
.qwin-card .btn { text-decoration: none; color: inherit; } .qwin-card .btn.pri { color: var(--accent-ink); }

@media (max-width: 900px) {
  .quest.qlevel { overflow-y: auto; display: block; }
  .qbody { grid-template-columns: minmax(0, 1fr); }
  .qleft { border-right: 0; overflow: visible; padding-bottom: 8px; }
  .qright { overflow: visible; padding-top: 4px; }
  .qpv { min-height: 360px; }
  .qwin { position: fixed; top: 0; }
  .qtitle h1 { font-size: 18px; white-space: normal; }
}
@media (max-width: 520px) { .qhead { padding: 8px 12px; } .qleft, .qright { padding-left: 12px; padding-right: 12px; } .qopts2 { grid-template-columns: minmax(0, 1fr); } .qwin-stars { font-size: 38px; } }
