/* Aula de álgebra: sistema heredado de Aula de datos (azul, Manrope, barra lateral de banco) */
:root {
  --ink: #10183e;
  --muted: #545c71;
  --blue: #3448e5;
  --blue-dark: #2638c6;
  --line: #e1e5ed;
  --soft: #eef2ff;
  --surface: #ffffff;
  --bg: #ffffff;
  --green: #17674e;
  --green-soft: #e5f4ee;
  --red: #b3261e;
  --red-soft: #fdecea;
  --amber: #8a5a00;
  --amber-soft: #fff4dc;
  --on-blue: #ffffff;
  --radius: 12px;
  --font-display: "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7eaf6; --muted: #a3aac0; --blue: #7d8bff; --blue-dark: #9aa5ff;
    --line: #2a3150; --soft: #1b2246; --surface: #141a33; --bg: #0e1328;
    --green: #5fd0a6; --green-soft: #12352b; --red: #ff8a80; --red-soft: #3a1714;
    --amber: #f2c46b; --amber-soft: #3a2c0c; --on-blue: #0e1328; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e7eaf6; --muted: #a3aac0; --blue: #7d8bff; --blue-dark: #9aa5ff;
  --line: #2a3150; --soft: #1b2246; --surface: #141a33; --bg: #0e1328;
  --green: #5fd0a6; --green-soft: #12352b; --red: #ff8a80; --red-soft: #3a1714;
  --amber: #f2c46b; --amber-soft: #3a2c0c; --on-blue: #0e1328; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  font-synthesis: none; accent-color: var(--blue);
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: -0.02em; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
sup, sub { font-size: 0.72em; line-height: 0; }
.num, .tab-num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; }

/* Cabecera */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 72px;
  display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.45rem; letter-spacing: -0.03em; }
.brand svg { width: 38px; height: 28px; }
.topbar .meta { margin-left: auto; font-weight: 600; font-size: 0.95rem; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 0.95rem; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--blue); }
.btn:disabled { color: var(--muted); opacity: 0.55; cursor: not-allowed; border-color: var(--line); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-dark); }
.btn.wide { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }

/* Estructura */
.layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: calc(100% - 72px); }
.sidebar {
  position: sticky; top: 72px; height: calc(100vh - 72px);
  border-right: 1px solid var(--line); padding: 24px 10px 18px 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.sidebar h2 { font-size: 0.98rem; padding: 0 8px; }
.sidebar .sub { font-size: 0.8rem; color: var(--muted); padding: 0 8px; margin: -6px 0 4px; }
.qlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.qlist a {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px; padding: 7px 8px; border-radius: 8px;
  text-decoration: none; color: var(--ink); font-size: 0.88rem; line-height: 1.3;
}
.qlist a .code { font-weight: 800; font-size: 0.82rem; padding-top: 1px; }
.qlist a:hover { background: var(--soft); }
.qlist a[aria-current="page"] { background: var(--soft); color: var(--blue); font-weight: 700; }
.qlist a.done .code { color: var(--green); }
.qlist a.done .code::after { content: " ✓"; }
.side-foot { border-top: 1px solid var(--line); padding: 14px 8px 0; font-size: 0.82rem; }
.side-foot strong { display: block; font-size: 0.84rem; }
.bar { height: 6px; background: var(--line); border-radius: 99px; margin: 10px 0 14px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; transition: width .3s; }
.side-foot p { margin: 0; color: var(--muted); }

.main { padding: 30px 40px 60px; min-width: 0; max-width: 1140px; }
.tabs { display: flex; flex-wrap: wrap; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none;
  color: var(--ink); font-weight: 600; font-size: 0.95rem;
}
.tabs a:hover { border-color: var(--blue); }
.tabs a[aria-current="page"] { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }

.picker { display: flex; gap: 12px; align-items: center; padding: 22px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.picker select {
  min-width: 0;
  flex: 1 1 320px; max-width: 470px; padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.picker .nav { margin-left: auto; display: flex; gap: 10px; }

/* Pregunta */
.q-head { display: flex; gap: 20px; align-items: flex-start; padding: 30px 0 8px; }
.q-head h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); line-height: 1.15; }
.q-head .lead { color: var(--muted); margin: 6px 0 0; }
.dots { margin-left: auto; text-align: right; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.dots .row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--muted); display: block; }
.dots i.on { background: var(--green); border-color: var(--green); }
.statement { max-width: 72ch; margin: 18px 0 6px; font-size: 1.04rem; }
.statement .marks { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.mathline { display: block; text-align: center; margin: 10px 0; font-size: 1.08rem; }

.subtabs { display: flex; border-bottom: 1px solid var(--line); margin-top: 22px; overflow-x: auto; }
.subtabs button {
  flex: 1 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer;
  padding: 14px 18px; font-weight: 700; color: var(--ink); display: flex; gap: 10px; align-items: center; justify-content: center;
}
.subtabs button[aria-selected="true"] { border-color: var(--blue); color: var(--blue); }
.subtabs .n {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor;
  display: inline-grid; place-items: center; font-size: 0.8rem;
}
.subtabs button.ok .n { background: var(--green); border-color: var(--green); color: var(--on-blue); }

.work { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; margin-top: 24px; align-items: start; }
.explore { background: var(--soft); border-radius: var(--radius); padding: 20px; min-width: 0; }
.explore .tag { font-size: 0.88rem; font-weight: 600; display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.explore .tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.explore .hint { font-size: 0.88rem; color: var(--muted); text-align: center; margin: 12px 0 0; }
.answer { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--surface); min-width: 0; }
.answer h3 { font-size: 1.55rem; margin-bottom: 4px; }
.answer .ask { margin: 4px 0 16px; color: var(--muted); font-size: 0.95rem; }
.field { margin-bottom: 16px; }
.field > label, .field > .flabel { display: block; font-weight: 700; margin-bottom: 8px; font-size: 0.95rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 0.95rem;
}
.pill input { margin: 0; }
.pill:has(input:checked) { border-color: var(--blue); background: var(--soft); }
.field select, .field input[type="text"] {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
}
.field input[type="text"] { font-variant-numeric: tabular-nums; }
.inline-num { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-num input[type="text"] { width: 140px; }
.field.ok .pills, .field.ok select, .field.ok input[type="text"] { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 8px; }
.field.ko .pills, .field.ko select, .field.ko input[type="text"] { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 8px; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 8px; font-size: 0.92rem; }
.feedback.ok { background: var(--green-soft); color: var(--green); }
.feedback.ko { background: var(--red-soft); color: var(--red); }
.tiny { font-size: 0.82rem; color: var(--muted); text-align: center; margin: 10px 0 0; }

.idea { border-top: 1px solid var(--line); margin-top: 34px; padding-top: 24px; }
.idea-head { display: flex; align-items: center; gap: 12px; }
.idea-head h2 { font-size: 1.6rem; }
.idea-head .btn { margin-left: auto; color: var(--blue); }
.idea-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 16px; }
.idea-cols > div { padding-right: 24px; }
.idea-cols > div + div { border-left: 1px solid var(--line); padding: 0 0 0 24px; }
.idea-cols h3 { font-size: 1.08rem; margin-bottom: 6px; }
.idea-cols p { margin: 0 0 8px; color: var(--muted); }
.idea .note { margin-top: 16px; padding: 12px 16px; border-radius: 8px; background: var(--soft); font-size: 0.93rem; }
.hints { margin-top: 14px; display: grid; gap: 8px; }
.hints div { padding: 10px 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); border-radius: 0 8px 8px 0; font-size: 0.93rem; }
.qfoot { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); margin-top: 34px; padding-top: 14px; }

/* Exploradores */
.ex-svg { width: 100%; height: auto; display: block; }
.ex-svg text { fill: var(--muted); font-family: var(--font-body); font-size: 12px; }
.ex-svg .ink { fill: var(--ink); }
.ex-svg .axis { stroke: var(--muted); stroke-width: 1; }
.ex-svg .grid { stroke: var(--line); stroke-width: 1; }
.ex-svg .mark { fill: var(--blue); }
.ex-svg .mark2 { fill: var(--green); }
.ex-svg .line { stroke: var(--blue); stroke-width: 2.5; fill: none; }
.ex-svg .line2 { stroke: var(--green); stroke-width: 2.5; fill: none; }
.ex-svg .line3 { stroke: var(--amber); stroke-width: 2.5; fill: none; }
.ex-svg .soft { fill: var(--surface); stroke: var(--line); }
.ctrls { display: grid; gap: 10px; margin-top: 12px; }
.ctrl { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; font-size: 0.9rem; }
.ctrl output { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ctrl input[type="range"] { width: 100%; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 8px 0; }
.stepper button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--blue); background: var(--surface); color: var(--blue); font-size: 1.4rem; cursor: pointer; }
.big { font-size: 2.6rem; font-weight: 800; text-align: center; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big small { display: block; font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.ex-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface); border-radius: 8px; overflow: hidden; }
.ex-table th, .ex-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
.ex-table th { font-weight: 700; color: var(--muted); font-size: 0.8rem; }
.ex-table td.hl { color: var(--blue); font-weight: 700; }
.ex-scroll { overflow-x: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
.chip { padding: 4px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.chip.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.chip.ko { background: var(--red-soft); color: var(--red); border-color: transparent; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.seg button[aria-pressed="true"] { background: var(--blue); color: var(--on-blue); }
.center { text-align: center; }
.pascal { display: grid; gap: 6px; justify-items: center; }
.pascal div { display: flex; gap: 6px; }
.pascal span { min-width: 34px; padding: 4px 6px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); text-align: center; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.pascal span.on { background: var(--blue); color: var(--on-blue); border-color: var(--blue); }
.pascal span.src { background: var(--green-soft); border-color: var(--green); }
.block-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 6px 0; }
.block { width: 26px; height: 26px; border-radius: 5px; background: var(--blue); color: var(--on-blue); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
.block.g { background: var(--green); }
.block.x { background: var(--surface); color: var(--muted); border: 1px dashed var(--muted); text-decoration: line-through; }

/* Página en construcción */
.soon { margin-top: 28px; padding: 26px; border: 1px dashed var(--line); border-radius: var(--radius); }
.soon h1 { font-size: 1.9rem; }
.soon ol { columns: 2; column-gap: 32px; padding-left: 20px; color: var(--muted); }
.soon li { break-inside: avoid; margin-bottom: 4px; }

@media (max-width: 980px) {
  .work { grid-template-columns: 1fr; }
  .idea-cols { grid-template-columns: 1fr; }
  .idea-cols > div + div { border-left: 0; padding: 16px 0 0; border-top: 1px solid var(--line); margin-top: 12px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .topbar .meta { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .qlist { display: none; }
  .main { padding: 18px 16px 50px; }
  .ctrl { grid-template-columns: 90px 1fr 54px; }
  .soon ol { columns: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .sidebar, .tabs, .picker { display: none; } .layout { display: block; } }

/* Campos de ordenar y escribir */
.order { list-style: none; counter-reset: o; margin: 0; padding: 0; display: grid; gap: 6px; }
.order li { counter-increment: o; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 0.92rem; }
.order li::before { content: counter(o); font-weight: 800; color: var(--blue); min-width: 16px; }
.order li > span:first-child { flex: 1; }
.order .mv { display: flex; gap: 4px; }
.order .mv button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; }
.order .mv button:hover { border-color: var(--blue); color: var(--blue); }
.field textarea { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font: inherit; resize: vertical; }
.field.ok .order, .field.ok textarea { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 8px; }
.field.ko .order, .field.ko textarea { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 8px; }
details summary { cursor: pointer; font-weight: 700; }
.seg { max-width: 100%; flex-wrap: wrap; }
.help-picker > div { flex: 1; min-width: 0; }
.help-picker select { width: 100%; }
#class-notes { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
.idea > select { max-width: 100%; }
.idea li { margin-bottom: 8px; }
.idea details { margin-top: 18px; }
@media (max-width: 760px) { .help-picker { flex-direction: column; align-items: stretch; } }
