/* Estilos compartidos por la app (index.html) y el panel de salas (sala.html). */
:root {
  --bg: #F2F3EF;
  --surface: #FFFFFF;
  --surface-2: #E8EBE4;
  --code-bg: #FAFAF7;
  --ink: #1A1E23;
  --muted: #5B636C;
  --line: #D3D8CF;
  --accent: #B0531A;        /* cobre */
  --accent-soft: #F6E3D5;
  --accent-ink: #FFFFFF;
  --cordillera: #1F3A5F;
  --ok: #2B7A4B;
  --ok-soft: #E2F1E7;
  --err: #B42318;
  --err-soft: #FCEBE9;
  --warn: #8A5A00;
  --warn-soft: #FBF1DA;
  --code-size: 14px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1317;
    --surface: #161B21;
    --surface-2: #1E252D;
    --code-bg: #12171C;
    --ink: #E4E8EC;
    --muted: #96A0AB;
    --line: #28313A;
    --accent: #E88A4B;
    --accent-soft: #3A2517;
    --accent-ink: #1B0F06;
    --cordillera: #9DB8DA;
    --ok: #62C48F;
    --ok-soft: #15301F;
    --err: #F28B82;
    --err-soft: #3A1D1B;
    --warn: #E6B84F;
    --warn-soft: #3A2E12;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1317;
  --surface: #161B21;
  --surface-2: #1E252D;
  --code-bg: #12171C;
  --ink: #E4E8EC;
  --muted: #96A0AB;
  --line: #28313A;
  --accent: #E88A4B;
  --accent-soft: #3A2517;
  --accent-ink: #1B0F06;
  --cordillera: #9DB8DA;
  --ok: #62C48F;
  --ok-soft: #15301F;
  --err: #F28B82;
  --err-soft: #3A1D1B;
  --warn: #E6B84F;
  --warn-soft: #3A2E12;
}

/* Colores de sintaxis del editor */
:root {
  --syn-keyword: #A3431A; --syn-string: #2D7A3E; --syn-comment: #7A838C; --syn-number: #1F5FA8;
  --syn-fn: #6A46AE; --syn-tag: #A3431A; --syn-attr: #8A6200; --syn-prop: #1F5FA8;
  --syn-type: #0D7780; --syn-op: #5B636C;
  --active-line: rgb(176 83 26 / 0.06); --selection: rgb(176 83 26 / 0.18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --syn-keyword: #F0A06A; --syn-string: #9CCB82; --syn-comment: #7D8894; --syn-number: #82B4F0;
    --syn-fn: #C6AAF6; --syn-tag: #F0A06A; --syn-attr: #E6C36A; --syn-prop: #82B4F0;
    --syn-type: #6FD0D8; --syn-op: #A9B2BC;
    --active-line: rgb(232 138 75 / 0.07); --selection: rgb(232 138 75 / 0.24);
  }
}
:root[data-theme="dark"] {
  --syn-keyword: #F0A06A; --syn-string: #9CCB82; --syn-comment: #7D8894; --syn-number: #82B4F0;
  --syn-fn: #C6AAF6; --syn-tag: #F0A06A; --syn-attr: #E6C36A; --syn-prop: #82B4F0;
  --syn-type: #6FD0D8; --syn-op: #A9B2BC;
  --active-line: rgb(232 138 75 / 0.07); --selection: rgb(232 138 75 / 0.24);
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 12px 48px;
}
.wrap { max-width: 1400px; margin: 0 auto; display: grid; gap: 12px; }

button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  justify-content: space-between;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.logo {
  font-family: var(--display); font-weight: 800; font-size: 28px;
  letter-spacing: -0.02em; line-height: 1; margin: 0;
}
.logo .tld { color: var(--accent); }
.logo .caret {
  display: inline-block; width: 0.5ch; height: 0.9em; margin-left: 2px;
  background: var(--accent); vertical-align: -0.08em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .logo .caret { animation: none; } }
.tagline { color: var(--muted); font-size: 13px; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn kbd {
  font-family: var(--mono); font-size: 11px; opacity: 0.8;
  padding: 1px 5px; border-radius: 4px; background: rgb(0 0 0 / 0.14);
}
select.btn { padding-right: 10px; }
.seg { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); height: 34px; }
.seg button { border: 0; background: none; height: 100%; padding: 0 10px; cursor: pointer; font-weight: 600; }
.seg button:hover { color: var(--accent); }
.seg span { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.toggle { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* ---------- Consigna ---------- */
.consigna {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface-2); border-radius: 10px; padding: 10px 14px;
}
.chip {
  flex: none; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cordillera); padding-top: 3px;
}
.consigna textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; resize: none;
  font-size: 15px; line-height: 1.5; padding: 0; min-height: 1.5em; overflow: hidden;
}
.consigna textarea::placeholder { color: var(--muted); }
.consigna textarea:focus-visible { outline: none; }
.consigna:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Espacio de trabajo ---------- */
.ws {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: clamp(480px, 74vh, 860px);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface);
}
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 40px; padding: 0 8px 0 4px; border-bottom: 1px solid var(--line); flex: none;
}
.tabs { display: flex; height: 100%; }
.tab {
  border: 0; background: none; cursor: pointer; height: 100%;
  padding: 0 14px; font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.tab[data-l="html"] { --dot: #D9622B; }
.tab[data-l="css"] { --dot: #2F6FD1; }
.tab[data-l="js"] { --dot: #D4A514; }
.tab[data-l="p"] { --dot: #2B9A5B; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.bar-note { font-size: 12px; color: var(--muted); padding-left: 10px; }

.editor { flex: 1; min-height: 0; background: var(--code-bg); position: relative; }
.editor:focus-within { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.editor .cm-editor { position: absolute; inset: 0; }
/* Sin ligaduras: quien aprende debe ver ">=" tal como lo escribe, no "≥". */
.editor .cm-scroller { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }

.out { display: grid; grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 34%); min-height: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status .led { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status.err .led { background: var(--err); }
.out-title { font-weight: 600; font-size: 13px; padding-left: 10px; }
iframe { width: 100%; height: 100%; border: 0; background: #FFFFFF; display: block; }
.bar.console-bar { border-top: 1px solid var(--line); }
.console-bar { padding-left: 0; }
.otabs { display: flex; height: 100%; }
.otab {
  border: 0; background: none; cursor: pointer; height: 100%; padding: 0 12px;
  font-weight: 600; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.otab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.bar-actions { display: flex; gap: 2px; }
.count, .badge {
  font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 1.5;
  padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.count:empty, .badge:empty { display: none; }
.count.has-err, .badge.bad { background: var(--err-soft); color: var(--err); }
.badge.good { background: var(--ok-soft); color: var(--ok); }

.tests { overflow: auto; background: var(--code-bg); }
.tests .empty { padding: 12px 14px; color: var(--muted); font-size: 13px; display: grid; gap: 6px; justify-items: start; }
.tests .empty p { margin: 0; max-width: 60ch; }
.link-btn.inline { padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.link-btn.inline:hover { background: none; }
.tests-head { display: grid; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tests-head strong { font-family: var(--display); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.tests-head.done strong { color: var(--ok); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); transition: width 0.3s ease; }
.tests-head.done .meter span { background: var(--ok); }
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }
.tests-list { list-style: none; margin: 0; padding: 0; }
.tests-list li { display: flex; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.tests-list .mark { flex: none; width: 1.2em; font-weight: 700; }
.tests-list li.ok .mark { color: var(--ok); }
.tests-list li.fail .mark { color: var(--err); }
.tests-list .name { display: block; }
.tests-errors { display: grid; gap: 4px; padding: 10px 14px; background: var(--err-soft); color: var(--err); font-size: 13px; }
.tests-errors .why { font-family: var(--mono); font-size: 12px; }
.tests-list .why {
  display: block; margin-top: 2px; font-family: var(--mono); font-size: 12px; color: var(--err);
  white-space: pre-wrap; word-break: break-word;
}

.lock {
  position: absolute; top: 8px; right: 12px; z-index: 5;
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 4px 3px 12px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.08);
}
.lock button {
  border: 0; background: var(--surface-2); color: var(--ink); border-radius: 999px;
  padding: 2px 10px; font-weight: 600; font-size: 12px; cursor: pointer;
}
.lock button:hover { color: var(--accent); }
/* Iframe donde corren las pruebas: fuera de pantalla para no tocar la vista previa del alumno. */
.test-frame { position: fixed; left: -10000px; top: 0; width: 800px; height: 600px; border: 0; visibility: hidden; pointer-events: none; }
.link-btn { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 12px; padding: 4px 6px; border-radius: 5px; }
.link-btn:hover { color: var(--ink); background: var(--surface-2); }
.console { overflow: auto; font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); }
.console .row {
  padding: 5px 12px; border-bottom: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
  display: flex; gap: 10px;
}
.console .row .k { flex: none; width: 1.5ch; color: var(--muted); }
.console .row.more { color: var(--muted); font-style: italic; font-family: var(--body); }
.console .row.error { color: var(--err); background: var(--err-soft); }
.console .row.error .k { color: var(--err); }
.console .row.warn { color: var(--warn); background: var(--warn-soft); }
.console .row.warn .k { color: var(--warn); }
.console .empty { padding: 12px; color: var(--muted); font-family: var(--body); font-size: 13px; }
.console .empty code { font-family: var(--mono); color: var(--ink); }

/* ---------- Presentación ---------- */
.about {
  margin-top: 36px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); gap: 28px 48px;
  align-items: start;
}
.about h2 {
  font-family: var(--display); font-weight: 800; font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.05; letter-spacing: -0.02em; margin: 0; text-wrap: balance;
}
.about h2 em { font-style: normal; color: var(--accent); }
.about .lede { color: var(--muted); max-width: 44ch; margin: 12px 0 0; font-size: 15px; }
.feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.feat h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.feat p { margin: 0; color: var(--muted); }
.feat .lbl { font-family: var(--mono); font-size: 11.5px; color: var(--cordillera); margin-bottom: 8px; display: block; }
.soon { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.soon b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.soon span { border: 1px dashed var(--line); padding: 3px 10px; border-radius: 999px; }
footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Diálogo compartir ---------- */
.overlay {
  position: fixed; inset: 0; background: rgb(10 14 18 / 0.5); display: grid; place-items: center;
  padding: 16px; z-index: 20;
}
.dlg {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(560px, 100%);
  padding: 22px; box-shadow: 0 24px 60px rgb(0 0 0 / 0.25); display: grid; gap: 14px;
}
.dlg h3 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.dlg p { margin: 0; color: var(--muted); }
.linkrow { display: flex; gap: 8px; }
.linkrow input {
  flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--code-bg); font-family: var(--mono); font-size: 12.5px;
}
.meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.5em; }
.meta.err { color: var(--err); }
.kinds { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 8px; justify-self: start; }
.kinds button {
  border: 0; background: none; cursor: pointer; padding: 5px 12px; border-radius: 6px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.kinds button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.dlg .actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dlg.guide {
  width: min(660px, 100%); max-height: calc(100vh - 32px); overflow: hidden auto; gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}
.guide pre, .guide code, .guide dt, .tests-list .why { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
.guide h4 { margin: 6px 0 0; font-size: 14px; }
.guide pre.code {
  margin: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto;
}
.guide code { font-family: var(--mono); font-size: 0.92em; }
.guide dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.guide dt { font-family: var(--mono); font-size: 12.5px; color: var(--cordillera); }
.guide dd { margin: 0; color: var(--muted); }
.guide ul { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 4px; }
@media (max-width: 560px) {
  .guide dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .guide dd { margin-bottom: 6px; }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 30;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
}
.toast button {
  border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0;
  text-decoration: underline; text-underline-offset: 3px;
}
:root .toast button { color: color-mix(in srgb, var(--accent) 70%, var(--bg)); }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  .ws { grid-template-columns: minmax(0, 1fr); height: auto; }
  .pane.editors { height: 52vh; min-height: 300px; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .out { height: 70vh; min-height: 380px; }
  .about { grid-template-columns: minmax(0, 1fr); }
  .feats { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .soon { grid-column: 1; }
  .bar-note { display: none; }
}
@media (max-width: 520px) {
  .btn kbd, .tagline { display: none; }
  .controls { width: 100%; }
  .controls select.btn { flex: 1 1 100%; min-width: 0; }
  .controls .btn.primary { margin-left: auto; }
}
html { color-scheme: light; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- Lenguaje: Web / Python ---------- */
.modes { padding: 2px; gap: 2px; }
.modes button { height: 100%; border-radius: 5px; padding: 0 12px; font-weight: 600; color: var(--muted); }
.modes button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.tab[data-l="y"] { --dot: #3A76A8; }

/* Entrada (stdin) de Python: ocupa el lugar de la vista previa */
.out.py { grid-template-rows: auto minmax(0, 30%) auto minmax(0, 1fr); }
.stdin { display: flex; min-height: 0; background: var(--code-bg); }
.stdin textarea {
  flex: 1; min-width: 0; border: 0; resize: none; outline: none; background: transparent; color: var(--ink);
  padding: 10px 14px; font-family: var(--mono); font-size: var(--code-size); line-height: 1.6;
  font-variant-ligatures: none;
}
.stdin:focus-within { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.console .row .in { color: var(--cordillera); font-weight: 500; }

/* ---------- Salas en vivo (alumno) ---------- */
.room-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  background: var(--accent-soft); border-radius: 10px; padding: 8px 14px; font-size: 13px;
}
.room-bar .live { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.room-bar .live b { font-family: var(--mono); letter-spacing: 0.08em; }
.room-note { color: var(--muted); }
.room-status { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-status.bad { color: var(--err); }
.room-bar .link-btn { text-decoration: none; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 1.8s ease-out infinite; }
.pulse.off { background: var(--muted); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.code-chip {
  font-family: var(--mono); font-size: 0.8em; letter-spacing: 0.1em; padding: 2px 10px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink); vertical-align: 2px;
}
.field { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.field input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
  font-weight: 400; font-size: 15px;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.room-create { display: grid; gap: 10px; justify-items: start; }
.room-create p { margin: 0; color: var(--muted); }
#room-panel-link { justify-self: start; text-decoration: none; }
.kinds { flex-wrap: wrap; }

/* ---------- Panel del profe (sala.html) ---------- */
a.logo { color: var(--ink); text-decoration: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); margin: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cordillera); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }

.join-card {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px 40px;
  padding: 20px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.join-main { display: grid; gap: 6px; justify-items: start; }
.join-url {
  margin: 0; font-family: var(--mono); font-size: clamp(22px, 3.4vw, 40px); line-height: 1.1;
  font-variant-ligatures: none; overflow-wrap: anywhere;
}
.join-url span { color: var(--muted); }
.join-url b { color: var(--accent); letter-spacing: 0.08em; font-weight: 500; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.consigna p { margin: 0; font-size: 15px; }

.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
.panel-sec { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; gap: 14px; }
.panel-sec h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.sort { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bar-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; align-items: baseline; }
.bar-name { font-weight: 500; display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.bar-count { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bars .meter { height: 8px; }
.meter span.full { background: var(--ok); }
.tag { font-size: 11px; font-weight: 600; color: var(--err); background: var(--err-soft); padding: 1px 8px; border-radius: 999px; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.students { width: 100%; border-collapse: collapse; font-size: 14px; }
.students th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 10px 8px 0; white-space: nowrap; }
.students td { padding: 10px 10px 10px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.students tr.offline td.who { color: var(--muted); }
.who { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.presence { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.presence.on { background: var(--ok); }
.dots { white-space: nowrap; }
.tdot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 4px; vertical-align: middle; background: var(--surface-2); }
.tdot.ok { background: var(--ok); }
.tdot.fail { background: var(--err); opacity: 0.85; }
.when { color: var(--muted); white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.act { text-align: right; }
.act .link-btn:disabled { opacity: 0.4; cursor: default; }

.notice { max-width: 560px; margin: 12vh auto 0; display: grid; gap: 12px; justify-items: start; }
.notice h2 { margin: 0; font-family: var(--display); font-size: 26px; }
.notice p { margin: 0; color: var(--muted); }
.notice .btn { text-decoration: none; }

.dlg.code-dlg { width: min(860px, 100%); max-height: calc(100vh - 32px); grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
.code-view {
  margin: 0; min-height: 200px; max-height: 60vh; overflow: auto; padding: 12px 14px;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; font-variant-ligatures: none; tab-size: 2;
}

.projector {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); cursor: pointer;
  display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center;
}
.projector .eyebrow { font-size: 18px; margin: 0; }
.p-url { margin: 0; font-family: var(--mono); font-size: clamp(32px, 7vw, 110px); line-height: 1.1; font-variant-ligatures: none; overflow-wrap: anywhere; }
.p-url span { color: var(--muted); }
.p-url b { color: var(--accent); font-weight: 500; letter-spacing: 0.06em; }
.p-hint { margin: 0; color: var(--muted); font-size: 18px; max-width: 40ch; }

@media (max-width: 860px) {
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
}

/* El código de la sala nunca se corta: si no cabe, baja completo a la línea siguiente. */
.join-url b, .p-url b { white-space: nowrap; display: inline-block; }
a.btn { text-decoration: none; }

/* ---------- Guía (ayuda.html) ---------- */
.guide-page .wrap { max-width: 1120px; }
.g-hero { display: grid; gap: 12px; padding-block: 28px 8px; justify-items: start; }
.g-hero h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(32px, 5vw, 52px); letter-spacing: -0.02em; line-height: 1.02; text-wrap: balance; }
.g-hero p { margin: 0; color: var(--muted); font-size: 16px; max-width: 60ch; }
.g-switch {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: inline-flex; gap: 4px; margin-top: 6px;
  background: var(--surface-2); padding: 4px; border-radius: 10px;
}
.g-switch a { padding: 7px 16px; border-radius: 7px; font-weight: 600; color: var(--ink); text-decoration: none; }
.g-switch a:hover { background: var(--surface); }

.g-part { display: grid; gap: 28px; padding-block: 36px; border-top: 1px solid var(--line); scroll-margin-top: 12px; }
.g-part-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.g-part h2 { margin: 4px 0 0; font-family: var(--display); font-weight: 800; font-size: clamp(24px, 3.2vw, 34px); letter-spacing: -0.015em; line-height: 1.1; text-wrap: balance; }
.g-part h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.g-part p { margin: 0 0 8px; max-width: 68ch; }
.g-part code, .g-part kbd, .g-part pre { font-family: var(--mono); font-variant-ligatures: none; }
.g-part code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.g-part kbd { font-size: 0.82em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface); }
.ok-text { color: var(--ok); font-weight: 600; }
.err-text { color: var(--err); font-weight: 600; }

/* Pasos: la numeración es real, el orden importa */
.g-steps-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.g-steps { list-style: none; margin: 0; padding: 0; counter-reset: paso; display: grid; gap: 20px; }
.g-steps > li { counter-increment: paso; display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 14px; }
.g-steps > li::before {
  content: counter(paso); grid-row: span 9; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-family: var(--display); font-weight: 800; font-size: 18px;
}
.g-steps > li > * { grid-column: 2; }
.g-steps-wide { max-width: 860px; }
.tip { color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; font-size: 14px; }
.g-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 6px; max-width: 68ch; }

/* Esquema de la pantalla */
.g-map {
  margin: 0; display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 12px; position: sticky; top: 64px;
}
.g-map > div { position: relative; border-radius: 7px; }
.g-map .n {
  position: absolute; top: -9px; left: -9px; z-index: 1; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 12px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--surface);
}
.m-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.m-bar span { border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; color: var(--muted); }
.m-bar .m-run { margin-left: auto; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.m-room { background: var(--accent-soft); padding: 7px 10px 7px 20px; }
.m-consigna { background: var(--surface-2); padding: 7px 10px 7px 20px; }
.m-consigna b { color: var(--cordillera); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; margin-right: 6px; }
.m-ws { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 180px; }
.m-editor, .m-out { border: 1px solid var(--line); border-radius: 7px; display: grid; grid-template-rows: auto 1fr; overflow: visible; }
.m-out { grid-template-rows: 1fr auto; }
.m-tabs { display: flex; gap: 8px; padding: 5px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 11px; }
.m-tabs .on { color: var(--ink); border-bottom: 2px solid var(--accent); }
.m-code { position: relative; display: grid; gap: 6px; align-content: start; padding: 14px 10px; background: var(--code-bg); }
.m-code span { height: 6px; border-radius: 3px; background: var(--syn-keyword); opacity: 0.45; width: 50%; }
.m-code .w80 { width: 80%; background: var(--syn-fn); } .m-code .w60 { width: 60%; margin-left: 12px; }
.m-code .w70 { width: 70%; margin-left: 12px; background: var(--syn-string); } .m-code .w40 { width: 30%; }
.m-preview { position: relative; display: grid; place-items: center; background: #fff; color: #555; border-radius: 6px 6px 0 0; min-height: 90px; }
.m-tests { position: relative; display: grid; gap: 2px; padding: 8px 10px 8px 18px; border-top: 1px solid var(--line); background: var(--code-bg); }
.g-map figcaption { color: var(--muted); font-size: 12px; }

.g-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px 48px; align-items: start; }
.g-cols h3 { margin-top: 0; }
.g-cols h3 + p { margin-top: 0; }
.g-cols > div > h3:not(:first-child) { margin-top: 24px; }
.g-msgs { margin: 0; display: grid; gap: 4px; }
.g-msgs dt { font-weight: 600; margin-top: 10px; }
.g-msgs dt:first-child { margin-top: 0; }
.g-msgs dd { margin: 0; color: var(--muted); max-width: 60ch; }
.g-keys { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; align-items: baseline; }
.g-keys dd { margin: 0; color: var(--muted); }

.g-code2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 4px 0 10px; }
.g-code2 figure { margin: 0; display: grid; gap: 4px; min-width: 0; }
.g-code2 figcaption { font-size: 12px; color: var(--muted); }
.g-code2 pre {
  margin: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; line-height: 1.6; overflow-x: auto;
}

.g-message { display: grid; gap: 12px; justify-items: start; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.g-message h3, .g-message p { margin: 0; }
.g-message .field { width: min(220px, 100%); }
.g-message .field input { font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.g-msg {
  margin: 0; width: 100%; padding: 12px 14px; white-space: pre-wrap; background: var(--code-bg);
  border: 1px dashed var(--line); border-radius: 8px; font-family: var(--body) !important; font-size: 14px; line-height: 1.55;
}
.guide-page footer a { text-decoration: none; }

/* Modo proyector: solo la parte de estudiantes, en grande */
.projecting .g-hero, .projecting #profes, .projecting .top, .projecting footer { display: none; }
.projecting #estudiantes { zoom: 1.3; border-top: 0; padding-top: 12px; }
.projecting .g-map { position: static; }

@media (max-width: 860px) {
  .g-steps-wrap, .g-cols { grid-template-columns: minmax(0, 1fr); }
  .g-map { position: static; }
  .g-code2 { grid-template-columns: minmax(0, 1fr); }
  .projecting #estudiantes { zoom: 1; }
}

/* Enlaces a la guía */
.guide-link { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.lede-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.dlg a:not(.btn), .room-create a { color: var(--accent); text-underline-offset: 3px; }
.f-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.tip a { color: var(--accent); text-underline-offset: 3px; }

/* ---------- Privacidad ---------- */
.legal { gap: 12px; padding-block: 28px; }
.legal h3 { margin: 12px 0 2px; }
.legal p { color: var(--ink); }
.legal .g-list { color: var(--ink); }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.legal-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 12px 8px 0; }
.legal-table td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: top; }
.legal-table td:first-child { font-weight: 500; }
.legal a, footer a { color: var(--accent); text-underline-offset: 3px; }

/* ---------- Pistas ---------- */
.hint-btn {
  flex: none; align-self: flex-start; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.hint-btn:hover { border-color: var(--accent); color: var(--accent); }
.hint-btn.reveal { background: var(--accent-soft); border-color: transparent; }
.hint-list {
  list-style: none; margin: -4px 0 0; padding: 10px 14px; display: grid; gap: 6px; counter-reset: pista;
  border: 1px dashed var(--line); border-radius: 10px; font-size: 14px;
}
.hint-list li { counter-increment: pista; display: flex; gap: 8px; }
.hint-list li::before { content: "Pista " counter(pista); flex: none; font-weight: 600; color: var(--accent); }
.field textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
  font-weight: 400; font-size: 14px; line-height: 1.45; resize: vertical;
}
.field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.sec-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.hints-col { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hints-col.used { color: var(--warn); font-weight: 600; }

/* ---------- Biblioteca de retos ---------- */
.lib-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding-block: 8px 4px; }
.lib-seg { height: auto; padding: 3px; gap: 2px; flex-wrap: wrap; }
.lib-seg button { padding: 6px 12px; border-radius: 5px; font-weight: 600; color: var(--muted); height: auto; }
.lib-seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 16px; padding-block: 12px 8px; }
.lib-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
}
.lib-card h2 { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }
.lib-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-lang, .lib-level { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.lib-lang.web { background: var(--accent-soft); color: var(--accent); }
.lib-lang.py { background: color-mix(in srgb, #3A76A8 18%, transparent); color: #3A76A8; }
:root[data-theme="dark"] .lib-lang.py { color: #82B4F0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lib-lang.py { color: #82B4F0; } }
.lib-level { background: var(--surface-2); color: var(--muted); }
.lib-desc { margin: 0; }
.lib-meta { margin: 0; font-size: 13px; color: var(--muted); }
.lib-consigna { font-size: 14px; }
.lib-consigna summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
.lib-consigna p { margin: 6px 0 0; color: var(--muted); }
.lib-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.dlg > .link-btn { justify-self: center; }

/* ---------- 404 ---------- */
.notfound { padding-block: 10vh 6vh; }
.nf-code { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 12vw, 128px); line-height: 0.9; color: var(--accent); margin: 0; }
.notfound code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-variant-ligatures: none; }
