/* =========================================================
   Disciplina espartana — hoja de estilos
   Paleta tomada de la cerámica laconia de figuras negras:
   engobe claro, barniz negro, rojo añadido y bronce de escudo.
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --engobe: #F2EADC;
  --engobe-hondo: #E9DFCC;
  --barniz: #1F1915;
  --barniz-suave: #6A5D50;
  --rojo-anadido: #8A2A2B;
  --bronce: #A57F3E;
  --bronce-texto: #7A5A22;
  --arcilla: #D9CBB3;

  --bg: var(--engobe);
  --surface: var(--engobe-hondo);
  --text: var(--barniz);
  --muted: var(--barniz-suave);
  --accent: var(--rojo-anadido);
  --on-accent: var(--engobe);
  --ornament: var(--bronce);
  --numeral: var(--bronce-texto);
  --line: var(--arcilla);
  --bar-bg: rgba(242, 234, 220, 0.94);
  --backdrop: rgba(31, 25, 21, 0.45);
  --sheet-shadow: 0 -12px 32px rgba(31, 25, 21, 0.18);
  --raise: 0 1px 2px rgba(31, 25, 21, 0.16);

  /* El escudo es la marca: no cambia con el tema. */
  --shield-rim: #A57F3E;
  --shield-field: #8A2A2B;
  --shield-mark: #F2EADC;

  /* Tipografías del sistema: se leen bien, no pesan y funcionan sin conexión. */
  --font-read: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", "Droid Serif", Georgia, serif;
  --font-inscription: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, "Iowan Old Style", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-body: var(--font-read);

  --scale: 1;
  --lh-base: 1.66;
  --lh-extra: 0;
  --reader-size: clamp(1.125rem, 1.04rem + 0.3vw, 1.3125rem);

  --gutter: clamp(1rem, 5vw, 2rem);
  --bar-h: 3.25rem;
  --bottombar-h: 3.75rem;
  --top-inset: env(safe-area-inset-top, 0px);
  --bottom-inset: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

:root[data-font="sans"] { --font-body: var(--font-ui); --lh-base: 1.58; }
:root[data-lh="amplio"] { --lh-extra: 0.22; }

:root[data-theme="sepia"] {
  --bg: #E8DAC0;
  --surface: #DFCFB1;
  --text: #2E241B;
  --muted: #5F5040;
  --accent: #7E2626;
  --on-accent: #F3E9D6;
  --ornament: #9A7434;
  --numeral: #6E5020;
  --line: #CDB993;
  --bar-bg: rgba(232, 218, 192, 0.94);
}

:root[data-theme="dark"] {
  --bg: #17120F;
  --surface: #221B16;
  --text: #E8DECB;
  --muted: #B3A58F;
  --accent: #E39595;
  --on-accent: #17120F;
  --ornament: #B48A45;
  --numeral: #C9A266;
  --line: #3A302A;
  --bar-bg: rgba(23, 18, 15, 0.94);
  --backdrop: rgba(0, 0, 0, 0.6);
  --sheet-shadow: 0 -12px 32px rgba(0, 0, 0, 0.5);
  --raise: 0 1px 2px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #17120F;
    --surface: #221B16;
    --text: #E8DECB;
    --muted: #B3A58F;
    --accent: #E39595;
    --on-accent: #17120F;
    --ornament: #B48A45;
    --numeral: #C9A266;
    --line: #3A302A;
    --bar-bg: rgba(23, 18, 15, 0.94);
    --backdrop: rgba(0, 0, 0, 0.6);
    --sheet-shadow: 0 -12px 32px rgba(0, 0, 0, 0.5);
    --raise: 0 1px 2px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

html.has-dialog { overflow: hidden; }
[hidden] { display: none !important; }
svg { display: block; }
button, input, output { font: inherit; color: inherit; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 60;
  padding: 0.65rem 1rem;
  border-radius: 0.4rem;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: calc(0.75rem + var(--top-inset)); }

/* ---------- 3. Vistas: una a la vez cuando hay JavaScript ---------- */
.js .view { display: none; }
.js[data-view="inicio"] #inicio,
.js[data-view="capitulo-1"] #capitulo-1,
.js[data-view="capitulo-2"] #capitulo-2,
.js[data-view="capitulo-3"] #capitulo-3,
.js[data-view="capitulo-4"] #capitulo-4,
.js[data-view="capitulo-5"] #capitulo-5,
.js[data-view="capitulo-6"] #capitulo-6,
.js[data-view="capitulo-7"] #capitulo-7,
.js[data-view="acerca"] #acerca { display: block; }

/* ---------- 4. Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: calc(var(--bar-h) + var(--top-inset));
  padding: var(--top-inset) max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
  background: var(--bg);
  background: var(--bar-bg);
  border-bottom: 1px solid var(--line);
  transition: transform 0.22s ease;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar, .js .bottombar {
    -webkit-backdrop-filter: saturate(1.15) blur(10px);
    backdrop-filter: saturate(1.15) blur(10px);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
  min-height: 44px;
  color: var(--text);
  font-family: var(--font-read);
  font-size: 1.02rem;
  font-weight: 700;
  text-decoration: none;
}
.shield { width: 1.75rem; height: 1.75rem; flex: none; }
.shield__rim { fill: var(--shield-rim); }
.shield__field { fill: var(--shield-field); }
.shield__mark { fill: var(--shield-mark); }

.topbar__where {
  display: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-read);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar__settings { display: none; }
.aa { font-family: var(--font-read); font-weight: 700; letter-spacing: -0.02em; }

.progress {
  position: fixed;
  top: var(--top-inset);
  left: 0;
  right: 0;
  z-index: 40;
  display: none;
  height: 3px;
  pointer-events: none;
}
.js[data-view^="capitulo"] .progress { display: block; }
.progress__bar {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------- 5. Estructura ---------- */
main {
  display: block;
  padding: 1.75rem max(var(--gutter), env(safe-area-inset-right, 0px)) 3rem max(var(--gutter), env(safe-area-inset-left, 0px));
  outline: none;
}
.js main { padding-bottom: calc(var(--bottombar-h) + var(--bottom-inset) + 2.5rem); }

.layout > .toc { padding: 1rem var(--gutter) 0; }
.js .layout > .toc { display: none; }

/* ---------- 6. Barra inferior (teléfono y tableta) ---------- */
.bottombar { display: none; }
.js .bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 env(safe-area-inset-right, 0px) var(--bottom-inset) env(safe-area-inset-left, 0px);
  background: var(--bg);
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
  transition: transform 0.22s ease;
}
.bb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: var(--bottombar-h);
  padding: 0.35rem 0.25rem;
  border: 0;
  background: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}
.bb svg { width: 1.45rem; height: 1.45rem; }
.bb .aa { height: 1.45rem; font-size: 1.12rem; line-height: 1.45rem; }
.bb:active { background: var(--surface); }
.bb[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

@media (max-width: 1023.98px) {
  .js[data-view^="capitulo"] .brand__name {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .js[data-view^="capitulo"] .topbar__where { display: block; }
  .bars-hidden .topbar { transform: translateY(-100%); }
  .js.bars-hidden .bottombar { transform: translateY(100%); }
}

/* ---------- 7. Escritorio: índice lateral fijo ---------- */
@media (min-width: 1024px) {
  .layout {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr);
    align-items: start;
  }
  .layout > .toc,
  .js .layout > .toc {
    display: block;
    position: sticky;
    top: calc(var(--bar-h) + var(--top-inset));
    max-height: calc(100vh - var(--bar-h) - var(--top-inset));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem 1rem 2rem 1.25rem;
    border-right: 1px solid var(--line);
  }
  main, .js main { padding: 2.75rem 3rem 5rem; }
  .js .bottombar { display: none; }
  .js .topbar__settings {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    min-height: 40px;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    cursor: pointer;
  }
  .js .topbar__settings:hover { background: var(--surface); }
  .topbar__settings .aa { font-size: 1.05rem; }
}

/* ---------- 8. Columna de lectura ---------- */
.view {
  max-width: 32em; /* 62–72 caracteres por línea según la fuente del dispositivo */
  margin-inline: auto;
  font-family: var(--font-body);
  font-size: calc(var(--reader-size) * var(--scale));
  line-height: calc(var(--lh-base) + var(--lh-extra));
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  hanging-punctuation: first;
  overflow-wrap: break-word;
}

:where(.view) p { margin: 0 0 1em; }
:where(.view) p, :where(.view) li { text-wrap: pretty; }
@media (max-width: 599.98px) {
  :where(.view) p, :where(.view) li { -webkit-hyphens: auto; hyphens: auto; }
}

:where(.view) h1,
:where(.view) h2 {
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 700;
  text-wrap: balance;
}
:where(.view) h1 { margin: 0.15em 0 0.3em; font-size: 1.9em; line-height: 1.12; letter-spacing: -0.012em; }
:where(.view) h2 { margin: 2.2em 0 0.6em; font-size: 1.3em; line-height: 1.25; }
@media (min-width: 768px) {
  :where(.view) h1 { font-size: 2.15em; }
}

:where(.view) a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
:where(.view) a:hover { text-decoration-thickness: 2px; }

[id] { scroll-margin-top: calc(var(--bar-h) + var(--top-inset) + 1rem); }

/* Apertura de capítulo */
.chapter__head { margin-bottom: 1.6em; }
.chapter__num {
  margin: 0 0 0.2em;
  color: var(--numeral);
  font-family: var(--font-inscription);
  font-size: 2.6em;
  line-height: 1;
  letter-spacing: 0.08em;
}
.chapter__time { margin: 0; color: var(--muted); font-family: var(--font-ui); font-size: 0.8em; }

.epigraph { margin: 0 0 1.5em; padding: 0; color: var(--muted); }
.epigraph p { margin: 0 0 0.35em; font-size: 1.04em; font-style: italic; line-height: 1.5; }
.epigraph footer { font-family: var(--font-ui); font-size: 0.78em; }
.epigraph footer::before { content: "— "; }

.standfirst { margin: 0 0 1.5em; font-size: 1.14em; line-height: 1.5; }

.inchapter {
  margin: 0 0 0.5em;
  border-block: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 0.86em;
}
.inchapter summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  color: var(--muted);
  list-style: none;
  cursor: pointer;
}
.inchapter summary::-webkit-details-marker { display: none; }
.inchapter summary::after { content: "+"; font-size: 1.3em; line-height: 1; }
.inchapter[open] summary::after { content: "−"; }
.inchapter ul { margin: 0 0 0.9em; padding: 0; list-style: none; }
.inchapter a { display: block; padding: 0.45em 0; color: var(--text); text-decoration: none; }
.inchapter a:hover { color: var(--accent); }

/* Notas de contexto */
.note {
  margin: 1.3em 0 1.5em;
  padding: 0.95em 1.1em;
  border-radius: 0.55rem;
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 0.84em;
  line-height: 1.55;
}
.note p { margin: 0; }
.note strong { font-weight: 650; }

/* Ponlo en práctica */
.practice__count {
  min-height: 1.2em;
  margin: -0.25em 0 0.6em;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.8em;
}
.checklist { margin: 0; padding: 0; list-style: none; }
.checklist li { border-top: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 1px solid var(--line); }
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 0.75em;
  padding: 0.8em 0;
  cursor: pointer;
}
.checklist input {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  margin: 0.2em 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.checklist input:checked + span { color: var(--muted); }

/* Para reflexionar */
.reflect ul { margin: 0; padding-left: 1.15em; }
.reflect li { margin: 0 0 0.6em; font-style: italic; }
.reflect li::marker { color: var(--ornament); }

/* Inscripción: el único momento enfático de la página */
.meander {
  height: 12px;
  background-color: var(--ornament);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M0 .75H12M0 11.25H12M1.5 11.25V3.25H9.5V8.5H4.5V5.75H7' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E") 0 0 / 12px 12px repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M0 .75H12M0 11.25H12M1.5 11.25V3.25H9.5V8.5H4.5V5.75H7' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E") 0 0 / 12px 12px repeat-x;
}
.inscription {
  max-width: 24ch;
  margin: 0.95em auto;
  color: var(--text);
  font-family: var(--font-inscription);
  font-size: 1.28em;
  font-weight: 400;
  line-height: 1.34;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
}
.laconic { margin: 2.8em 0 1.4em; }
.laconic figcaption {
  margin-top: 0.75em;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78em;
  text-align: center;
}

/* Cierre de capítulo */
.source {
  margin: 0 0 1.6em;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78em;
  text-align: center;
}
.readmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65em;
  min-height: 52px;
  margin: 0 0 1.25em;
  padding: 0.7em 1em;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.92em;
  cursor: pointer;
}
.readmark input { width: 1.25em; height: 1.25em; margin: 0; accent-color: var(--accent); cursor: pointer; }
.readmark:has(input:checked) { border-color: var(--accent); }

.pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin: 0 0 1rem;
  font-family: var(--font-ui);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  min-height: 56px;
  padding: 0.85em 1.05em;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  color: var(--text);
  text-decoration: none;
}
.pager a:hover { border-color: var(--ornament); }
.pager__dir { color: var(--muted); font-size: 0.76em; }
.pager__title { font-size: 0.92em; font-weight: 600; line-height: 1.3; }
.pager__next { text-align: right; }
@media (min-width: 560px) {
  .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 9. Inicio ---------- */
.today { margin: 0.25em 0 2.4em; text-align: center; }
.today__label { margin: 0 0 0.9em; color: var(--muted); font-family: var(--font-ui); font-size: 0.82em; }
.today .inscription { max-width: 20ch; margin: 1em auto; font-size: 1.55em; }
@media (min-width: 768px) {
  .today .inscription { font-size: 1.95em; }
}
.today__src { margin: 1em 0 0; color: var(--muted); font-family: var(--font-ui); font-size: 0.82em; }

.home__intro h1 { font-size: 1.6em; }
@media (min-width: 768px) {
  .home__intro h1 { font-size: 1.85em; }
}
.home__cta { margin: 1.4em 0 0.6em; }
.home__progress { min-height: 1.2em; color: var(--muted); font-family: var(--font-ui); font-size: 0.82em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7em 1.35em;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.07); }
.button--quiet { background: transparent; color: var(--accent); }

.plan { margin: 0; padding: 0; list-style: none; }
.plan li { border-top: 1px solid var(--line); }
.plan li:last-child { border-bottom: 1px solid var(--line); }
.plan a {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.9em;
  padding: 1em 0;
  color: var(--text);
  text-decoration: none;
}
.plan a:hover .plan__title { color: var(--accent); }
.plan__num { color: var(--numeral); font-family: var(--font-inscription); font-size: 1.05em; letter-spacing: 0.06em; }
.plan__title { display: block; font-weight: 700; line-height: 1.3; }
.plan__desc { display: block; margin-top: 0.25em; color: var(--muted); font-size: 0.86em; line-height: 1.45; }
.plan__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25em;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.74em;
  white-space: nowrap;
}
.plan__state.is-read { color: var(--accent); font-weight: 600; }

.home__how p { margin-bottom: 0.9em; }
.aa-inline {
  padding: 0 0.3em;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  font-family: var(--font-read);
  font-size: 0.9em;
  font-weight: 700;
}
.home__foot {
  margin-top: 2.5em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.8em;
}

/* Acerca */
.about__msg { min-height: 1.2em; color: var(--muted); font-family: var(--font-ui); font-size: 0.85em; }
.about__back { margin-top: 2em; }
[data-offline-status][data-state="ready"]::before { content: "✓ "; color: var(--accent); font-weight: 700; }

/* ---------- 10. Índice ---------- */
.toc { font-family: var(--font-ui); font-size: 0.92rem; }
.toc a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 40px;
  padding: 0.4rem 0.55rem;
  border-radius: 0.45rem;
  color: var(--text);
  line-height: 1.3;
  text-decoration: none;
}
.toc a:hover { background: var(--surface); }
.toc a[aria-current="page"] { background: var(--surface); font-weight: 650; }
.toc__home { margin-bottom: 0.35rem; }
.toc .toc__about { margin-top: 0.6rem; color: var(--muted); }
.toc__chapters { margin: 0; padding: 0; list-style: none; }
.toc__chapters > li { margin: 0 0 0.1rem; }
.toc__num { flex: none; min-width: 2.3rem; color: var(--numeral); font-family: var(--font-inscription); letter-spacing: 0.05em; }
.toc__name { flex: 1; }
.toc__state { flex: none; color: var(--accent); font-weight: 700; }
.toc__sections { margin: 0.1rem 0 0.55rem 2.85rem; padding: 0; list-style: none; font-size: 0.86rem; }
.toc .toc__sections a { min-height: 36px; padding: 0.3rem 0.55rem; color: var(--muted); }
.js .toc__sections { display: none; }
.js .toc li.is-current > .toc__sections { display: block; }
.toc--sheet a { min-height: 44px; }
.toc--sheet .toc__sections a { min-height: 40px; }

/* ---------- 11. Hojas: índice y ajustes ---------- */
dialog.sheet {
  width: 100%;
  max-width: 100%;
  max-height: min(88vh, 46rem);
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 1rem 1rem 0 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--sheet-shadow);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.22s ease-out; }
dialog.sheet::backdrop { background: var(--backdrop); }
@keyframes sheet-in {
  from { transform: translateY(1.25rem); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.sheet__head h2 { margin: 0; font-family: var(--font-read); font-size: 1.15rem; }
.sheet__close {
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  cursor: pointer;
}
.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 1.25rem calc(1.25rem + var(--bottom-inset));
}
@media (min-width: 640px) {
  dialog.sheet {
    width: min(26rem, calc(100% - 2rem));
    margin: auto;
    border-radius: 0.9rem;
  }
  dialog.sheet .sheet__body { padding-bottom: 1.25rem; }
}

.setting { min-width: 0; margin: 0 0 1.1rem; padding: 0; border: 0; }
.setting__label { margin: 0 0 0.45rem; padding: 0; color: var(--muted); font-family: var(--font-ui); font-size: 0.82rem; }

.seg__opts {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.6rem;
  background: var(--surface);
}
.seg label { position: relative; display: block; }
.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 0 0.3rem;
  border-radius: 0.45rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  text-align: center;
}
.seg input:checked + span { background: var(--bg); box-shadow: var(--raise); font-weight: 650; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.seg .f-serif { font-family: var(--font-read); font-size: 1rem; }
.seg .f-sans { font-family: var(--font-ui); }

.swatch {
  display: inline-block;
  flex: none;
  width: 0.85em;
  height: 0.85em;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 50%;
}
.swatch--light { background: #F2EADC; }
.swatch--sepia { background: #E8DAC0; }
.swatch--dark { background: #17120F; }
.swatch--auto { background: linear-gradient(135deg, #F2EADC 50%, #17120F 50%); }

.stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.6rem;
  background: var(--surface);
}
.stepper__btn {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 0.45rem;
  background: var(--bg);
  box-shadow: var(--raise);
  color: var(--text);
  font-family: var(--font-read);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.stepper__btn--big { font-size: 1.4rem; }
.stepper__btn:disabled { opacity: 0.4; cursor: default; }
.stepper__out { flex: 1; font-family: var(--font-ui); font-size: 0.9rem; font-variant-numeric: tabular-nums; text-align: center; }

.setting__sample {
  margin: 0.3rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 0.6rem;
  font-family: var(--font-body);
  font-size: calc(var(--reader-size) * var(--scale));
  line-height: calc(var(--lh-base) + var(--lh-extra));
}

/* ---------- 12. Accesibilidad y medios ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .meander { display: none; }
  .seg input:checked + span { outline: 2px solid CanvasText; }
}

@media print {
  .topbar, .bottombar, .toc, .progress, .skip, dialog, .inchapter,
  .readmark, .pager, .today, .home__cta, [data-install], #reset { display: none !important; }
  .js .view { display: block !important; }
  html, body { background: #fff !important; color: #000 !important; }
  main, .js main { padding: 0 !important; }
  .view { max-width: none; font-size: 11pt; }
  .chapter, .about { break-before: page; }
  .note { border: 1px solid #999; background: none; }
  a { color: inherit; text-decoration: none; }
}
