:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c232c;
  --muted: #5d6875;
  --accent: #2f5d8a;
  --accent-soft: #e3ecf5;
  --ok: #2e7d4f;
  --ok-soft: #e2f2e8;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --fondo: #2f5d8a;
  --puente: #7a4fa3;
  --rescate: #2e7d4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 8px rgba(20, 30, 40, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --surface: #1a2027; --surface-2: #222a33; --border: #2f3944;
    --text: #e4e8ed; --muted: #9aa5b1; --accent: #7fb0e0; --accent-soft: #1f3247;
    --ok: #6cc690; --ok-soft: #173325; --warn: #e3b25a; --warn-soft: #3a2d12;
    --bad: #f08a80; --bad-soft: #3d1a17; --fondo: #7fb0e0; --puente: #b99be0; --rescate: #6cc690;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1rem; border-bottom: 1px solid var(--border); }
.brand small { display: block; color: var(--muted); font-size: .78rem; }
.brand-mark { background: var(--accent); color: #fff; border-radius: 8px; font-weight: 700; font-size: .8rem; padding: .45rem .5rem; }
nav { padding: .6rem; flex: 1; }
.nav-sec { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .9rem .6rem .3rem; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 8px; color: var(--text);
  text-decoration: none; font-size: .93rem; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.disabled { color: var(--muted); pointer-events: none; }
.nav-item .ico { width: 1.2rem; text-align: center; }
.nav-item .tag { margin-left: auto; white-space: nowrap; font-size: .68rem; background: var(--surface-2); border-radius: 99px; padding: 0 .45rem; }
.sidebar-foot { padding: .8rem 1rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .2rem; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.6rem .2rem; }
.topbar h1 { font-size: 1.4rem; margin: 0; }
#view { padding: 1rem 1.6rem 3rem; max-width: 1200px; outline: none; }
.btn-icon { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-size: 1.1rem; padding: .25rem .55rem; cursor: pointer; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .btn-icon { display: inline-block; }
  .topbar, #view { padding-left: 16px; padding-right: 16px; }
}

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.kpi .v { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--bad); }
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-align: left; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .65rem; width: 100%; }
textarea { min-height: 7rem; resize: vertical; }
textarea.mono { font: 14px/1.6 var(--mono); }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field + .field { margin-top: .9rem; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; border-radius: 99px; padding: .08rem .55rem; border: 1px solid transparent; white-space: nowrap; }
.b-fondo { color: var(--fondo); border-color: var(--fondo); }
.b-puente { color: var(--puente); border-color: var(--puente); }
.b-rescate { color: var(--rescate); border-color: var(--rescate); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: .25rem .75rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--text); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.alert { border-radius: 8px; padding: .7rem .9rem; font-size: .92rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: 8px; z-index: 50; max-width: calc(100% - 32px); }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- temario ---------- */
.tema-list { display: grid; gap: .5rem; }
.tema-item { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: .8rem; align-items: center; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .8rem; }
.tema-item:hover { border-color: var(--accent); }
.tema-num { font-weight: 700; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bloque-h { margin: 1.4rem 0 .5rem; font-size: 1rem; color: var(--muted); }

/* ---------- markdown ---------- */
.md { overflow-wrap: anywhere; }
.md h1 { font-size: 1.45rem; } .md h2 { font-size: 1.2rem; margin-top: 1.6em; } .md h3 { font-size: 1.05rem; margin-top: 1.3em; }
.md table { margin: .8rem 0; display: block; overflow-x: auto; }
.md pre { background: var(--surface-2); padding: .8rem; border-radius: 8px; overflow-x: auto; font: 13px/1.5 var(--mono); }
.md code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: .8rem 0; padding: .4rem .9rem; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.md img { max-width: 100%; }
.md mark { background: var(--bad-soft); color: var(--bad); border-radius: 3px; padding: 0 2px; }

/* ---------- corrector ---------- */
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.4rem; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.thumb { position: relative; width: 84px; }
.thumb img, .thumb .pdf { width: 84px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: grid; place-items: center; background: var(--surface-2); font-size: .8rem; }
.thumb button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; background: var(--bad); color: #fff; }
.thumb .n { font-size: .75rem; color: var(--muted); text-align: center; }
.steps { display: flex; gap: .4rem; flex-wrap: wrap; }
.step { font-size: .82rem; padding: .25rem .7rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.step.done { background: var(--ok-soft); color: var(--ok); }
.step.now { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.revision { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.revision .pages { max-height: 75vh; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; }
.revision .pages img { width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.revision textarea { min-height: 75vh; }
@media (max-width: 900px) { .revision { grid-template-columns: 1fr; } .revision textarea { min-height: 50vh; } }
.nota-grande { font-size: 3rem; font-weight: 800; line-height: 1; }
.nota-ok { color: var(--ok); } .nota-mid { color: var(--warn); } .nota-bad { color: var(--bad); }
.falta-escrito { color: var(--bad); text-decoration: line-through; }
.falta-correcto { color: var(--ok); font-weight: 600; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; }
.btn-google { display: flex; gap: .6rem; align-items: center; justify-content: center; width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); }

/* ---------- calendario ---------- */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .cal-wrap { grid-template-columns: 1fr; } }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-cab { margin: .8rem 0 .3rem; text-align: center; color: var(--muted); font-size: .8rem; font-weight: 600; }
.dia { min-height: 84px; background: var(--surface-2); border: 1px solid transparent; border-radius: 6px; padding: 4px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; font: inherit; color: var(--text); overflow: hidden; }
.dia:hover { border-color: var(--border); }
.dia.fuera { opacity: .45; }
.dia.hoy .n { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 .4rem; }
.dia.sel { border-color: var(--accent); }
.dia .n { font-weight: 700; font-size: .8rem; align-self: flex-start; }
.dia .ev { font-size: .7rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dia .ev.hecho { text-decoration: line-through; opacity: .6; }
@media (max-width: 600px) { .dia { min-height: 54px; } .dia .ev { display: none; } }

/* ---------- oral ---------- */
.grabadora { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.reloj { font: 700 2rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.reloj.pasado { color: var(--bad); }
.rec { width: 14px; height: 14px; border-radius: 50%; background: var(--bad); animation: pulso 1s infinite; }
@keyframes pulso { 50% { opacity: .3; } }
.pregunta-tribunal { font-size: 1.15rem; border-left: 4px solid var(--accent); padding: .6rem 1rem; background: var(--accent-soft); border-radius: 0 8px 8px 0; }

/* ---------- noticias ---------- */
.noticia { display: grid; gap: .3rem; }
.noticia.leida { opacity: .7; }
.noticia h3 { margin: 0; font-size: 1rem; }
.noticia h3 a { text-decoration: none; }
.noticia h3 a:hover { text-decoration: underline; }

/* ---------- recursos visuales ---------- */
.mmd { overflow-x: auto; text-align: center; }
.mmd svg { max-width: 100%; height: auto; }
.infografia { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 40%); }

/* ---------- impresión (recursos, informes) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .toast, .btn, button { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  #view { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  details { display: block; } details > summary { display: none; }
  a { color: #000; text-decoration: none; }
}
