/* iLearn visual foundation + critical surfaces (FV-02 / FV-03). */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/IBMPlexSans-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/IBMPlexSerif-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/IBMPlexSerif-Italic.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Serif";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/IBMPlexSerif-SemiBold.woff2") format("woff2");
}

:root {
  --ink: #1c2430;
  --muted: #5a6573;
  --line: #c5ced8;
  --bg: #eef1f4;
  --surface: #f8fafb;
  --surface-quiet: #f3f5f7;
  --accent: #1d4e89;
  --focus: #1d4e89;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.5rem;
  --radius: 0.25rem;
  --max: 42rem;
  --font: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-reading: "IBM Plex Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --touch: 2.75rem;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

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

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: var(--space-3);
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand a {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.site-nav a,
.site-nav__logout button {
  color: var(--muted);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.25;
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  min-height: 0;
  display: inline;
  appearance: none;
  cursor: pointer;
}

.site-nav a.active,
.site-nav a:hover,
.site-nav__logout button:hover {
  color: var(--ink);
  background: none;
  border-bottom-color: var(--accent);
}

.site-nav__logout {
  display: contents;
}

.login {
  width: min(100%, 28rem);
  max-width: 28rem;
  margin-inline: auto;
}

.login h1 {
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.login .lede {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  line-height: 1.45;
}

.login-cli {
  margin: 0;
  padding: var(--space-3);
  overflow-x: auto;
  border: 1px solid var(--rule, #d8d6cf);
  border-radius: 0.35rem;
  background: var(--surface, #fff);
  font-size: 0.85rem;
  line-height: 1.4;
}

.login-error {
  margin: 0 0 var(--space-3);
  color: var(--danger, #9b1c1c);
  font-weight: 600;
}

.login-form {
  display: grid;
  gap: var(--space-3);
}

.login-form label {
  display: grid;
  gap: var(--space-1);
  font-weight: 600;
  font-size: 0.9rem;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  font: inherit;
  border: 1px solid var(--rule, #d8d6cf);
  border-radius: 0.35rem;
  background: var(--surface, #fff);
  color: var(--ink);
}

.login-form button[type="submit"] {
  justify-self: start;
  margin-top: var(--space-1);
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #2f5d50);
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}

.login-form button[type="submit"]:hover {
  filter: brightness(0.95);
}

@media (max-width: 40rem) {
  .site-header {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .site-nav {
    width: 100%;
    gap: var(--space-3);
  }

  .login {
    width: 100%;
    max-width: none;
  }

  .login-form button[type="submit"] {
    width: 100%;
    justify-self: stretch;
  }
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

.hoy h1 {
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  line-height: 1.25;
}

.hoy-continue-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.hoy-continue-actions form,
.hoy-continue-actions .button,
.hoy-continue-actions button {
  margin-top: 0;
}

.session h1,
.session-stub h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  line-height: 1.25;
}

.surface {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.surface-quiet {
  background: var(--surface-quiet);
  border-color: #d5dbe3;
}

/* Name kept from M1; chrome comes from .surface (FV-03). */
.card-primary {
  margin: 0;
}

.card-primary h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.session-chrome {
  margin-bottom: var(--space-5);
}

.session-chrome h1 {
  margin: 0 0 var(--space-4);
  font-size: 1.35rem;
  line-height: 1.35;
  color: var(--ink);
}

.session-goal {
  margin: 0 0 var(--space-3);
}

.session-label {
  margin: 0 0 var(--space-1);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
}

.session-goal-hint {
  margin: 0 0 var(--space-2);
}

.session-goal-body {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  font-size: 0.95rem;
}

.session-goal-body p {
  margin: 0;
}

.theory-reread {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.theory-reread summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.theory-reread[open] summary {
  margin-bottom: var(--space-2);
}

.session-meta {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.why,
.next {
  color: var(--muted);
}

fieldset {
  border: 1px solid var(--line);
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: #fff;
}

fieldset legend {
  padding: 0 var(--space-1);
  font-weight: 600;
}

fieldset label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  min-height: var(--touch);
  padding: var(--space-1) 0;
}

fieldset input[type="radio"] {
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.mode-option {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-2);
  row-gap: 0.15rem;
  align-items: start;
}

.mode-option input[type="radio"] {
  grid-row: 1 / span 2;
}

.mode-label {
  font-weight: 600;
}

.mode-hint {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.35;
}

.ai-suggestion {
  margin: 0;
  white-space: pre-wrap;
}

label:not(fieldset label) {
  display: block;
  margin: var(--space-3) 0 var(--space-1);
  font-weight: 600;
}

button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
a.button:hover {
  background: #2a3544;
  border-color: #2a3544;
}

form.secondary button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 400;
}

form.secondary button:hover {
  background: var(--surface);
  border-color: var(--muted);
  color: var(--ink);
}

.md-block {
  margin: var(--space-3) 0 var(--space-4);
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.md-reading {
  font-family: var(--font-reading);
  font-size: 1.05rem;
  line-height: 1.65;
  background: #fff;
  border-color: var(--line);
  white-space: normal;
}

.md-reading p {
  margin: 0 0 var(--space-3);
}

.md-reading p:last-child {
  margin-bottom: 0;
}

.md-reading ul,
.md-reading ol {
  margin: 0 0 var(--space-3);
  padding-left: 1.25rem;
}

.md-reading code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

/* ADHD-friendly theory body (LEARN + Releer only — not Meta/prompt). */
.theory-reading {
  max-width: 65ch;
  font-size: 1.125rem;
  line-height: 1.75;
  padding: var(--space-4);
}

.theory-reading p {
  margin: 0 0 var(--space-4);
}

.theory-reading ul,
.theory-reading ol {
  margin: 0 0 var(--space-4);
  padding-left: 1.35rem;
}

.theory-reading li {
  margin-bottom: var(--space-2);
}

.theory-reading li:last-child {
  margin-bottom: 0;
}

.theory-reading strong {
  font-weight: 600;
}

.md-response,
.md-rubric {
  white-space: pre-wrap;
  font-family: var(--font);
}

.md-response {
  background: #fff;
  border-color: var(--accent);
}

.md-rubric {
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--surface-quiet);
  border-color: #d5dbe3;
}

.ai-assist {
  margin: var(--space-3) 0;
}

.ai-panel {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--surface-quiet);
  border-radius: var(--radius);
  color: var(--ink);
}

.ai-panel .ai-json {
  white-space: pre-wrap;
  font-size: 0.85rem;
  margin: 0;
}

.feedback-panel {
  margin-bottom: var(--space-4);
}

.feedback-panel h3 {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
  font-weight: 600;
}

.feedback-rubric h3 {
  color: var(--muted);
  font-weight: 400;
}

textarea,
input[type="text"],
select {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: var(--space-2) 0 var(--space-4);
  padding: var(--space-3);
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

textarea {
  min-height: 10rem;
  resize: vertical;
}

.activity {
  margin-bottom: var(--space-5);
}

.activity h2 {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  font-size: 1.25rem;
}

.parking {
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
}

.parking h2 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.parking label {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

.pause-form {
  margin-top: var(--space-3);
}

.biblioteca h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 var(--space-3);
  line-height: 1.25;
}

.biblioteca-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.biblioteca-tabs a {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.biblioteca-tabs a.active,
.biblioteca-tabs a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.biblioteca-panel {
  margin-bottom: var(--space-6);
}

.biblioteca-panel h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.15rem;
  font-weight: 600;
}

.biblioteca-item {
  margin-bottom: var(--space-4);
}

.biblioteca-item h3 {
  margin: 0 0 var(--space-2);
  font-size: 1.05rem;
  font-weight: 600;
}

.datos h1 {
  margin: 0 0 var(--space-2);
}

.datos .lede {
  margin: 0 0 var(--space-5);
  max-width: 40rem;
}

.datos-panel {
  margin-bottom: var(--space-4);
}

.datos-panel h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.1rem;
}

.datos-dl {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) 1fr;
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

.datos-dl dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.datos-dl dd {
  margin: 0;
  word-break: break-word;
}

.datos-history {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.datos-history li {
  margin: 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.datos-history li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.datos-history__meta {
  margin: 0 0 var(--space-1);
  font-size: 0.85rem;
  color: var(--muted);
}

.datos-history__question {
  margin: 0 0 var(--space-1);
  font-weight: 600;
  line-height: 1.35;
}

.datos-history__counts {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.datos .hint {
  margin: var(--space-3) 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.datos .notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-3);
  border-left: 3px solid var(--accent, #2a6f6a);
}

.datos-actions {
  margin: 0 0 var(--space-3);
}

.datos-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.datos-file-list li {
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border, #ddd);
}

.datos-file-list .meta {
  display: block;
  margin: var(--space-1) 0 var(--space-2);
  font-size: 0.85rem;
  color: var(--muted);
}

.datos-restore label {
  display: block;
  margin: 0 0 var(--space-2);
  font-size: 0.9rem;
}

.empty-state {
  color: var(--muted);
}

.fragment-list {
  margin: var(--space-2) 0 var(--space-3);
  padding-left: var(--space-4);
  color: var(--muted);
  font-size: 0.9rem;
}

.provenance-form,
.search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
}

.provenance-form label,
.search-form label {
  margin: 0;
}

.provenance-form input,
.provenance-form select,
.search-form input {
  margin: 0;
  width: auto;
}

@media (max-width: 40rem) {
  .datos-dl {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .datos-dl dd + dt {
    margin-top: var(--space-2);
  }

  .provenance-form,
  .search-form {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .provenance-form label,
  .provenance-form input,
  .provenance-form select,
  .search-form label,
  .search-form input,
  .provenance-form button,
  .search-form button {
    width: 100%;
  }

  .activity form > button,
  .hoy-continue-actions form,
  .hoy-continue-actions .button,
  .hoy-continue-actions button {
    width: 100%;
  }
}

.search-results {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.teoria .lede {
  margin: 0 0 var(--space-5);
  color: var(--ink);
  line-height: 1.5;
  max-width: 40rem;
}

/* Camino — filing cabinet on Estudiar (compact: fit viewport when possible) */
.camino {
  margin: var(--space-4) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.camino-cabinet {
  margin: 0;
  min-width: 0;
}

.camino-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.15rem;
  align-items: flex-end;
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0;
}

/* Top rail of the folder — sits under tabs; active tab covers its segment */
.camino-tabs::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 0;
}

.camino-tab {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0.4rem 0.5rem;
  border: 2px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted, #66645e);
  font: inherit;
  font-size: clamp(0.72rem, 1.8vw, 0.88rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.camino-tab:first-child {
  border-top-left-radius: 10px;
}

.camino-tab:last-child {
  border-top-right-radius: 10px;
}

.camino-tab:hover,
.camino-tab:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

/*
  Active tab: white background covers the rail under the tab.
  overflow:hidden clips side-border stubs past the box
  (Historia bottom-right, Geología bottom-left, middle tabs both).
*/
.camino-tab.is-active {
  z-index: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  border-color: var(--accent);
  border-bottom: none;
  background: #fff;
  color: var(--accent);
}

.camino-folder {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0.75rem 0.75rem 0.65rem;
  border: 2px solid var(--accent);
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: #fff;
}

.camino-drawer[hidden] {
  display: none;
}

.camino-path {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.2rem;
}

.camino-step {
  position: relative;
  margin: 0;
  padding: 0 0 0.55rem 0;
}

.camino-step:last-child {
  padding-bottom: 0;
}

.camino-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 1.45rem;
  left: 0.85rem;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--line) 85%);
  opacity: 0.45;
}

.camino-step__row {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  padding: 0.1rem 0.2rem 0.1rem 0;
}

.camino-step__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
  min-height: 2.25rem;
  color: var(--ink);
  text-decoration: none;
}

.camino-step__main:hover .camino-step__question,
.camino-step__main:focus-visible .camino-step__question {
  color: var(--accent);
}

.button-quiet {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: var(--space-2) var(--space-3);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.button-quiet:hover {
  color: var(--ink);
}

.camino-step__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  z-index: 1;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

a.camino-step__marker--practice {
  cursor: pointer;
}

a.camino-step__marker--practice:hover,
a.camino-step__marker--practice:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.camino-step__marker-num,
.camino-step__marker-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.camino-step__marker-icon {
  display: none;
}

.camino-step__marker-icon svg {
  display: block;
}

a.camino-step__marker--practice:hover .camino-step__marker-num,
a.camino-step__marker--practice:focus-visible .camino-step__marker-num {
  display: none;
}

a.camino-step__marker--practice:hover .camino-step__marker-icon,
a.camino-step__marker--practice:focus-visible .camino-step__marker-icon {
  display: inline-flex;
}

.camino-step__question {
  min-width: 0;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  transition: color 0.15s ease;
}

.camino-step__badge {
  justify-self: end;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted, #66645e);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (min-width: 720px) {
  .hoy {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  body:has(.camino-cabinet) main {
    padding-bottom: var(--space-4);
  }
}

.teoria-badge {
  grid-column: 3;
  align-self: center;
}

/* ===== Teoría unit — paper-in-canvas + wide H1 (Sol A: A+C) ===== */

main:has(.theory-page) {
  max-width: none;
  padding: 0;
  background: transparent;
}

.theory-page {
  --theory-canvas: #efeee9;
  --theory-paper: #faf9f6;
  --theory-ink: #20201e;
  --theory-muted: #66645e;
  --theory-rule: #d8d6cf;
  --reading-accent: #315f73;
  --reading-accent-hover: #244b5c;
  --reading-focus: #82aabc;
  --inline-code-bg: #f0efe9;
  --reading-measure: 68ch;
  --theory-stage-max: 70rem;
  --theory-page-gutter: clamp(1rem, 3vw, 2.5rem);
  --theory-paper-pad-x: clamp(1.25rem, 6vw, 6rem);
  --theory-paper-pad-y: clamp(2rem, 5vw, 5rem);
  --reading-size: clamp(1.0625rem, 1.02rem + 0.18vw, 1.1875rem);
  --reading-leading: 1.68;
  box-sizing: border-box;
  min-height: calc(100dvh - 4.5rem);
  padding: clamp(1rem, 2.5vw, 2.5rem) var(--theory-page-gutter) clamp(3rem, 6vw, 6rem);
  background: var(--theory-canvas);
  color: var(--theory-ink);
}

.theory-sheet {
  box-sizing: border-box;
  width: min(100%, var(--theory-stage-max));
  margin-inline: auto;
  padding: var(--theory-paper-pad-y) var(--theory-paper-pad-x);
  background: var(--theory-paper);
  border: 1px solid var(--theory-rule);
}

.theory-reader {
  width: 100%;
  max-width: var(--reading-measure);
  margin-inline: auto;
}

.theory-header {
  margin-bottom: clamp(2rem, 4vw, 2.75rem);
}

.theory-context {
  margin: 0 0 0.7rem;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--theory-muted);
}

.theory-question {
  margin: 0;
  max-width: none;
  font-family: var(--font-reading);
  font-size: clamp(2.25rem, 1.55rem + 2vw, 3.7rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.018em;
  color: var(--theory-ink);
  text-wrap: balance;
  hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}

@media (min-width: 56.25rem) {
  .theory-question {
    width: min(118%, calc(100vw - (2 * var(--theory-page-gutter))));
    margin-inline: -9%;
  }
}

.theory-back {
  margin: 0 0 1.25rem;
  font-family: var(--font);
  font-size: 0.875rem;
}

.theory-back a {
  color: var(--theory-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.theory-back a:hover {
  color: var(--reading-accent);
}

.theory-body {
  font-family: var(--font-reading);
  font-size: var(--reading-size);
  font-weight: 400;
  line-height: var(--reading-leading);
  color: var(--theory-ink);
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  white-space: normal;
}

.theory-body p {
  margin: 0 0 1.15em;
}

.theory-body p:last-child {
  margin-bottom: 0;
}

.theory-body ul,
.theory-body ol {
  margin: 1.1em 0 1.35em;
  padding-left: 1.4em;
}

.theory-body li {
  padding-left: 0.25em;
}

.theory-body li + li {
  margin-top: 0.4em;
}

.theory-body strong {
  font-weight: 600;
}

.theory-body em {
  font-style: italic;
  font-family: var(--font-reading);
  color: #2a2926;
}

/* Pull / misconception / formula / takeaway — same blue frame family, black body */
.theory-body blockquote {
  --theory-frame: var(--reading-accent, #315f73);
  --theory-frame-bg: #eef3f4;
  margin: 1.35em 0;
  padding: 0.85rem 1rem 0.85rem 1.1rem;
  border: 0;
  border-left: 3px solid var(--theory-frame);
  background: var(--theory-frame-bg);
  font-family: var(--font-reading);
  font-size: 1em;
  font-weight: 400;
  line-height: 1.5;
  color: var(--theory-ink, #20201e);
}

.theory-body blockquote.theory-pull {
  font-weight: 400;
}

.theory-body blockquote.theory-pull strong {
  font-weight: 600;
  color: inherit;
}

.theory-body blockquote.theory-misconception {
  font-style: italic;
}

.theory-body blockquote.theory-misconception strong {
  font-style: normal;
}

.theory-body blockquote.theory-formula {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.45;
}

.theory-body blockquote.theory-takeaway {
  border-left-width: 4px;
  background: #e8f0f2;
  font-style: normal;
  font-weight: 400;
}

.theory-body blockquote.theory-takeaway strong:first-child {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--theory-frame);
}

.theory-body .theory-section {
  margin: 2rem 0 0.85rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--theory-rule, #d8d6cf);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--reading-accent, #315f73);
}

.theory-body .theory-section:first-of-type {
  margin-top: 1.5rem;
}

/* HTML schemas (theory-schemas kit) */
.theory-schema {
  --schema-ink: var(--theory-ink, #20201e);
  --schema-muted: #66717c;
  --schema-line: var(--theory-rule, #d8d6cf);
  --schema-surface: #f7f8f8;
  --schema-accent: var(--reading-accent, #315f73);
  --schema-accent-soft: #eef3f4;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--schema-line);
  border-radius: 8px;
  background: #fff;
  color: var(--schema-ink);
  font-family: var(--font);
}

.theory-schema figcaption {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.schema-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--schema-accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theory-schema p {
  margin: 0.25rem 0 0;
  line-height: 1.45;
}

.theory-schema strong {
  font-weight: 600;
}

.theory-schema small {
  display: block;
  color: var(--schema-muted);
  line-height: 1.4;
}

.schema-chain__steps,
.schema-repair__steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-items: stretch;
}

.schema-chain__steps > li,
.schema-repair__steps > li {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-width: 0;
  min-height: 100%;
  height: 100%;
  margin: 0;
  padding: 0.9rem;
  border-top: 3px solid var(--schema-accent);
  background: var(--schema-surface);
}

/* Kill .theory-body li+li margin that breaks equal tops */
.theory-body .schema-chain__steps > li + li,
.theory-body .schema-repair__steps > li + li,
.theory-reading .schema-chain__steps > li + li,
.theory-reading .schema-repair__steps > li + li {
  margin-top: 0;
}

.schema-chain__steps > li:not(:last-child)::after,
.schema-repair__steps > li:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 1.35rem;
  right: -1.45rem;
  transform: none;
  color: var(--schema-muted);
  font-size: 1.15rem;
  line-height: 1;
}

.schema-tree ul {
  margin: 0.45rem 0 0;
  padding-left: 1.35rem;
  border-left: 1px solid var(--schema-line);
  list-style: none;
}

.schema-tree li {
  position: relative;
  padding: 0.45rem 0 0.45rem 1rem;
}

.schema-tree li::before {
  content: "";
  position: absolute;
  top: 1rem;
  left: 0;
  width: 0.7rem;
  border-top: 1px solid var(--schema-line);
}

.schema-tree__root {
  padding-left: 0 !important;
  border-left: 0 !important;
}

.schema-tree__root > li {
  padding-left: 0;
}

.schema-tree__root > li::before {
  display: none;
}

.schema-tree__node {
  display: block;
  margin-bottom: 0.1rem;
}

.schema-tree__root > li > .schema-tree__node {
  color: var(--schema-accent);
}

.schema-evidence-grid dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--schema-line);
  border-left: 1px solid var(--schema-line);
}

.schema-evidence-grid dl > div {
  padding: 0.85rem;
  border-right: 1px solid var(--schema-line);
  border-bottom: 1px solid var(--schema-line);
}

.schema-evidence-grid dt {
  margin: 0 0 0.35rem;
  color: var(--schema-accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.schema-evidence-grid dd {
  margin: 0;
  line-height: 1.45;
}

.schema-table {
  overflow-x: auto;
}

.schema-table table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.schema-table th,
.schema-table td {
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--schema-line);
  font-size: 0.92rem;
  line-height: 1.45;
}

.schema-table th {
  background: var(--schema-accent-soft);
  color: var(--schema-ink);
  font-weight: 600;
}

.schema-table td {
  background: #fff;
}

.schema-table p {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.theory-figure {
  margin: 1.5rem 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.theory-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--theory-rule, #d8d6cf);
  border-radius: 6px;
  background: #fff;
}

.theory-figure figcaption {
  margin: 0.65rem 0 0;
  font-family: var(--font);
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--theory-muted, #66645e);
}

@media (max-width: 680px) {
  .schema-chain__steps,
  .schema-repair__steps {
    grid-template-columns: 1fr;
    gap: 1.65rem;
  }

  .schema-chain__steps > li:not(:last-child)::after,
  .schema-repair__steps > li:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: 50%;
    bottom: -1.15rem;
    transform: translateX(50%);
  }

  .schema-evidence-grid dl {
    grid-template-columns: 1fr;
  }
}

/* Inline code kept for rare tokens; formula lines prefer blockquote.theory-formula */
.theory-body code {
  display: inline;
  padding: 0.08em 0.25em;
  border-radius: 0.2rem;
  border: 1px solid var(--theory-rule, #d8d6cf);
  background: var(--inline-code-bg, #f0efe9);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  color: var(--theory-ink, #20201e);
  white-space: pre-wrap;
}

/* Session LEARN / Releer: same reading roles */
.theory-reading em {
  font-style: italic;
}

.theory-reading blockquote {
  margin: 1.1em 0;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid #315f73;
  background: #eef3f4;
  color: #20201e;
  font-size: 1em;
}

.theory-reading blockquote.theory-misconception {
  font-style: italic;
}

.theory-reading blockquote.theory-formula {
  font-weight: 600;
}

.theory-reading blockquote.theory-takeaway {
  border-left-width: 4px;
  background: #e8f0f2;
}

.theory-reading blockquote.theory-takeaway strong:first-child {
  color: #315f73;
}

.theory-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: clamp(2.75rem, 6vw, 4.5rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--theory-rule);
  font-family: var(--font);
}

.theory-pager--with-practice {
  grid-template-columns: 1fr auto 1fr;
}

.theory-pager__link {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding-block: 0.5rem;
  color: var(--theory-ink);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.theory-pager__link:hover {
  color: var(--reading-accent-hover);
  text-decoration: underline;
}

.theory-pager__next {
  justify-content: flex-end;
  text-align: right;
}

.theory-pager__link--disabled {
  color: var(--theory-rule);
  pointer-events: none;
}

.theory-pager__practice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  min-height: var(--touch);
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
}

.theory-pager__practice:hover {
  background: #2a3544;
  border-color: #2a3544;
  color: #fff;
}

.theory-study-hint {
  margin: var(--space-5) 0 0;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--theory-muted);
}

.theory-study-hint a {
  color: var(--reading-accent);
}

.theory-pager__link:focus-visible,
.theory-body a:focus-visible,
.theory-back a:focus-visible {
  outline: 3px solid var(--reading-focus);
  outline-offset: 3px;
}

/* Quiet chrome while reading — keep nav, lower contrast */
body.theory-mode {
  scroll-behavior: auto;
}

body.theory-mode .site-header {
  background: #f4f3ee;
  border-bottom-color: var(--theory-rule, #d8d6cf);
  box-shadow: none;
}

body.theory-mode .brand,
body.theory-mode .site-nav a,
body.theory-mode .site-nav__logout button {
  color: #66645e;
}

body.theory-mode .site-nav a.active,
body.theory-mode .site-nav a:hover,
body.theory-mode .site-nav__logout button:hover {
  color: #20201e;
  background: none;
}

@media (min-width: 90rem) {
  .theory-page {
    padding-top: 2.5rem;
  }

  .theory-sheet {
    padding-top: 5rem;
    padding-bottom: 5rem;
  }
}

@media (max-width: 56.249rem) {
  .theory-question {
    width: auto;
    margin-inline: 0;
    font-size: clamp(2.15rem, 1.75rem + 2vw, 3rem);
  }
}

@media (max-width: 40rem) {
  .theory-page {
    --reading-size: 1.0625rem;
    --reading-leading: 1.65;
    min-height: auto;
    padding: 0;
    background: var(--theory-paper);
  }

  .theory-sheet {
    width: 100%;
    padding: 2rem clamp(1rem, 5vw, 1.5rem) 3rem;
    border: 0;
  }

  .theory-question {
    font-size: clamp(2rem, 1.65rem + 4vw, 2.65rem);
    line-height: 1.08;
    letter-spacing: -0.012em;
  }

  .theory-header {
    margin-bottom: 2rem;
  }

  .theory-pager {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    margin-top: 3rem;
  }

  .theory-pager--with-practice {
    grid-template-columns: 1fr;
  }

  .theory-pager__next {
    justify-content: flex-start;
    text-align: left;
  }

  .theory-pager__practice {
    justify-self: stretch;
    order: -1;
    margin-bottom: 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.theory-mode *,
  body.theory-mode *::before,
  body.theory-mode *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (min-width: 48rem) {
  main:not(:has(.theory-page)) {
    padding: var(--space-6) var(--space-5) 4rem;
  }

  .hoy h1,
  .session h1,
  .teoria h1:not(.theory-question),
  .biblioteca h1,
  .datos h1 {
    font-size: 2rem;
  }

  .surface {
    padding: var(--space-5);
  }
}
