/* =====================================================================
   Modo estudio y subrayado (DESIGN.md · Reading surface / Modo estudio)
   El mismo mundo cálido de UappTerepi llevado a la lectura larga: una columna tranquila, la letra y el fondo
   que elige el lector (Claro, Sepia, Oscuro o el del sistema), títulos en Nunito y el texto en una letra de leer.
   El acento (marrón Terepi / caramelo) solo en lo que se pulsa; los subrayados usan sus cuatro colores propios.
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Colores de subrayado en la app (lector de la asignatura) */
:root {
  --hl-amarillo: #f8e39b; --hl-verde: #d3e9c3; --hl-azul: #cddff2; --hl-rosa: #f5ccd7;
  --tool-bg: #33261c; --tool-ink: #f4ede3; --tool-ink-2: #cbb9a6; --tool-hover: rgba(244, 237, 227, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --hl-amarillo: rgba(232, 189, 106, .34); --hl-verde: rgba(143, 211, 166, .26); --hl-azul: rgba(132, 178, 230, .3); --hl-rosa: rgba(240, 140, 170, .3);
    --tool-bg: #f4ede3; --tool-ink: #2e2219; --tool-ink-2: #6e5c4d; --tool-hover: rgba(46, 34, 25, .08);
  }
}

/* ---------- Subrayados ---------- */
mark.subr, .prose mark.subr {
  color: inherit; padding: .04em .06em; margin: 0 -.06em; border-radius: 4px; cursor: pointer;
  background: var(--hl-amarillo); box-decoration-break: clone; -webkit-box-decoration-break: clone;
  transition: box-shadow .2s;
}
mark.subr[data-c="verde"] { background: var(--hl-verde); }
mark.subr[data-c="azul"] { background: var(--hl-azul); }
mark.subr[data-c="rosa"] { background: var(--hl-rosa); }
mark.subr:hover { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 14%, transparent); }
mark.subr.has-note::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .22em; vertical-align: -.08em; background: currentColor; opacity: .62;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4h14a1 1 0 0 1 1 1v10l-5 5H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z'/%3E%3Cpath d='M20 15h-4a1 1 0 0 0-1 1v4M8 9h8M8 13h5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 4h14a1 1 0 0 1 1 1v10l-5 5H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z'/%3E%3Cpath d='M20 15h-4a1 1 0 0 0-1 1v4M8 9h8M8 13h5'/%3E%3C/svg%3E") center / contain no-repeat;
}
mark.subr:focus-visible { outline: 2px solid var(--e-accent, var(--accent)); outline-offset: 2px; }
mark.subr.is-flash { animation: subr-flash 1.4s cubic-bezier(.2, .8, .3, 1); }
@keyframes subr-flash { 0%, 40% { box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 22%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Barra flotante de subrayar: una píldora en tinta (invertida) que no tapa el texto que se lee */
.subr-tools {
  position: fixed; z-index: 1200; max-width: calc(100vw - 16px); padding: 6px; border-radius: 22px;
  background: var(--tool-bg); color: var(--tool-ink); font: 700 13.5px/1.2 var(--sans);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 18px 40px -16px rgba(0, 0, 0, .45);
}
.subr-row { display: flex; align-items: center; gap: 2px; }
.subr-sw { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: none; cursor: pointer;
  transition: transform .12s var(--press); }
.subr-sw span { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .12); }
.subr-sw span[data-c="amarillo"] { background: #f5d76e; }
.subr-sw span[data-c="verde"] { background: #a9d696; }
.subr-sw span[data-c="azul"] { background: #9cc3ea; }
.subr-sw span[data-c="rosa"] { background: #eea7bb; }
.subr-sw:hover span { transform: scale(1.1); }
.subr-sw[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--tool-bg), 0 0 0 4px var(--tool-ink); }
.subr-sw:active { transform: scale(.92); }
.subr-sep { width: 1px; height: 22px; margin: 0 4px; background: color-mix(in srgb, var(--tool-ink) 25%, transparent); }
.subr-act { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border: 0; border-radius: 999px;
  background: none; color: var(--tool-ink); font: inherit; cursor: pointer; white-space: nowrap; transition: background .15s, transform .12s var(--press); }
.subr-act:hover { background: var(--tool-hover); }
.subr-act:active { transform: scale(.96); }
.subr-act.icon { width: 38px; padding: 0; justify-content: center; }
.subr-act .ico { width: 17px; height: 17px; }
.subr-act.danger:hover { color: #f2988a; }
.subr-act.main { background: var(--tool-ink); color: var(--tool-bg); }
.subr-tools :focus-visible { outline: 2px solid var(--tool-ink); outline-offset: 1px; }
.subr-note-view { margin: 4px 8px 6px; max-width: 34ch; font: 500 14px/1.45 var(--sans); color: var(--tool-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.subr-noteform { display: grid; gap: 8px; width: min(340px, calc(100vw - 32px)); padding: 6px; }
.subr-note-label { font: 700 12.5px var(--sans); color: var(--tool-ink-2); padding: 0 4px; }
.subr-noteform textarea { width: 100%; min-height: 84px; resize: vertical; padding: 10px 12px; border: 0; border-radius: 14px;
  background: color-mix(in srgb, var(--tool-ink) 10%, transparent); color: var(--tool-ink); font: 500 15px/1.45 var(--sans); }
.subr-noteform textarea::placeholder { color: var(--tool-ink-2); }
.subr-noteform textarea:focus { outline: 2px solid var(--tool-ink); outline-offset: 0; }
.subr-note-actions { display: flex; justify-content: flex-end; gap: 4px; }
@media (pointer: coarse) {
  .subr-sw, .subr-act { height: 44px; } .subr-sw, .subr-act.icon { width: 44px; }
}
/* Táctil con selección viva: anclada abajo, lejos del menú del sistema que sale junto al texto */
.subr-tools.is-docked {
  top: auto; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
}
@media (max-width: 480px) { .subr-act:not(.icon):not(.main) span { display: none; } .subr-act:not(.main) { width: 44px; padding: 0; justify-content: center; } }
/* Borrar y deshacer: discretos (tinta apagada, más pequeños con ratón), al final de la barra */
.subr-act.minor { color: var(--tool-ink-2); }
.subr-act.minor:hover { color: var(--tool-ink); }
.subr-act.minor.danger:hover { color: #f2988a; }
.subr-act.minor:not(.minor + .minor) { margin-left: 4px; }
@media (pointer: fine) { .subr-act.icon.minor { width: 32px; height: 32px; } .subr-act.minor .ico { width: 16px; height: 16px; } }
@media (max-width: 400px) { .subr-sw { width: 41px; } .subr-sep { margin: 0 2px; } }

/* Botón «Estudiar» en las cabeceras del lector */
.reader-head .btn.primary.study-btn { box-shadow: var(--shadow-sm); }

/* ---------- Modo estudio ---------- */
html.est-open, html.est-open body { overflow: hidden; }
.est {
  --e-bg: #fbf8f3; --e-surface: #f2ebe1; --e-rule: #e6dccf;
  --e-ink: #33261c; --e-ink-2: #5c4a3c; --e-ink-3: #75614e;
  --e-accent: #5b3f2b; --e-accent-soft: #efe4d6; --e-on-accent: #ffffff;
  
  --e-shadow: 0 2px 4px rgba(51, 38, 28, .06), 0 22px 48px -18px rgba(51, 38, 28, .3);
  --e-measure: 68ch;
  --hl-amarillo: #f8e39b; --hl-verde: #d3e9c3; --hl-azul: #cddff2; --hl-rosa: #f5ccd7;
  --tool-bg: #33261c; --tool-ink: #f4ede3; --tool-ink-2: #cbb9a6; --tool-hover: rgba(244, 237, 227, .12);
  position: fixed; inset: 0; z-index: 1000; overflow-y: auto; overscroll-behavior: contain;
  background: var(--e-bg); color: var(--e-ink); color-scheme: light;
  font: 400 15.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
.est[data-tema="sepia"] {
  --e-bg: #f4e9d4; --e-surface: #eadcc1; --e-rule: #dccaa6;
  --e-ink: #3b2b1b; --e-ink-2: #5a4530; --e-ink-3: #6d5740;
  --e-accent: #6a4526; --e-accent-soft: #e7d4ae; --e-on-accent: #fffaf0;
  
  --hl-amarillo: #efd68c; --hl-verde: #cddcae; --hl-azul: #c4d4dc; --hl-rosa: #ebc4c2;
  --tool-bg: #3b2b1b; --tool-ink: #f4e9d4;
}
.est[data-tema="oscuro"] {
  --e-bg: #2a1f17; --e-surface: #382a20; --e-rule: #4d3b2d;
  --e-ink: #efe6da; --e-ink-2: #d4c3ae; --e-ink-3: #b29e89;
  --e-accent: #e3b27f; --e-accent-soft: #4a3727; --e-on-accent: #2e2219;
  
  --e-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 50px -20px rgba(0, 0, 0, .7);
  --hl-amarillo: rgba(232, 189, 106, .34); --hl-verde: rgba(143, 211, 166, .26); --hl-azul: rgba(132, 178, 230, .3); --hl-rosa: rgba(240, 140, 170, .3);
  --tool-bg: #f4ede3; --tool-ink: #2e2219; --tool-ink-2: #6e5c4d; --tool-hover: rgba(46, 34, 25, .08);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  .est[data-tema="auto"] {
    --e-bg: #2a1f17; --e-surface: #382a20; --e-rule: #4d3b2d;
    --e-ink: #efe6da; --e-ink-2: #d4c3ae; --e-ink-3: #b29e89;
    --e-accent: #e3b27f; --e-accent-soft: #4a3727; --e-on-accent: #2e2219;
    
    --e-shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 50px -20px rgba(0, 0, 0, .7);
    --hl-amarillo: rgba(232, 189, 106, .34); --hl-verde: rgba(143, 211, 166, .26); --hl-azul: rgba(132, 178, 230, .3); --hl-rosa: rgba(240, 140, 170, .3);
    --tool-bg: #f4ede3; --tool-ink: #2e2219; --tool-ink-2: #6e5c4d; --tool-hover: rgba(46, 34, 25, .08);
    color-scheme: dark;
  }
}
.est[data-ancho="estrecha"] { --e-measure: 58ch; }
.est[data-ancho="ancha"] { --e-measure: 78ch; }
.est ::selection { background: color-mix(in srgb, var(--e-accent) 26%, transparent); color: inherit; }
/* El panel del asistente vive dentro del modo estudio pero conserva los estilos de la app */
.est :focus-visible:not(.adock *) { outline: 2px solid var(--e-accent); outline-offset: 2px; }
.est button:not(.adock *) { font: inherit; color: inherit; }
.est .ico:not(.adock *) { width: 20px; height: 20px; }

/* Progreso y barra de arriba */
.est-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 30; pointer-events: none; }
.est-progress > div { height: 100%; width: 0; background: var(--e-accent); border-radius: 0 3px 3px 0; transition: width .15s ease-out; }
.est-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 12px;
  background: var(--e-bg); border-bottom: 1px solid var(--e-rule); transition: transform .28s cubic-bezier(.16, 1, .3, 1);
}
.est-bar.is-hidden { transform: translateY(-100%); }
.est-bar-r { display: flex; align-items: center; gap: 2px; }
.est-icon {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 999px;
  background: none; color: var(--e-ink-2); cursor: pointer; transition: background .15s, color .15s, transform .12s var(--press);
}
.est-icon:hover { background: var(--e-surface); color: var(--e-ink); }
.est-icon:active { transform: scale(.94); }
.est-icon[aria-expanded="true"] { background: var(--e-accent-soft); color: var(--e-ink); }
.est-icon.small { width: 38px; height: 38px; }

.est-icon.small .ico { width: 17px; height: 17px; }
.est-count:not(:empty) {
  position: absolute; top: 3px; right: 1px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--e-accent); color: var(--e-on-accent); font: 800 11px/19px var(--sans); text-align: center;
}
.est-where {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 14px;
  border: 0; border-radius: 999px; background: none; cursor: pointer; color: var(--e-ink-2); font: 700 14.5px var(--sans);
  transition: background .15s;
}
.est-where:hover, .est-where[aria-expanded="true"] { background: var(--e-surface); color: var(--e-ink); }
.est-where .ico { width: 18px; height: 18px; }
.est-where-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--e-ink); }
.est-where-n { flex: none; font-weight: 600; color: var(--e-ink-3); }
.est-where-n:not(:empty)::before { content: "·"; margin-right: 9px; }
@media (max-width: 640px) { .est-where-n { display: none; } .est-where { justify-content: flex-start; padding: 0 10px; } }
@media (pointer: coarse) { .est-full { display: none; } }

/* Columna de lectura */
.est-main { padding: 104px 28px 120px; }
.est-col { max-width: var(--e-measure); margin: 0 auto; }
.est-title {
  margin: 0; font: 800 clamp(26px, 2.2vw + 14px, 34px)/1.15 var(--display); letter-spacing: -.02em; color: var(--e-ink);
  text-wrap: balance; overflow-wrap: anywhere;
}
.est-title:focus { outline: none; }
.est-meta { margin: 10px 0 0; font: 600 14.5px/1.45 var(--sans); color: var(--e-ink-3); }
.est-outline { margin: 28px 0 0; padding: 14px 18px 16px; border-radius: 18px; background: var(--e-surface); font: 600 15px/1.4 var(--sans); }
.est-outline > p { margin: 0 0 6px; font: 800 12.5px var(--sans); color: var(--e-ink-3); }
.est-outline ol { margin: 0; padding-left: 1.3em; color: var(--e-ink-3); }
.est-outline li { margin: 3px 0; padding-left: 2px; }
.est-outline.is-numbered ol { list-style: none; padding-left: 0; }
.est-text > .est-dup { display: none; }
.est-outline li::marker { font: 700 13px var(--sans); }
.est-outline a { color: var(--e-ink-2); text-decoration: none; }
.est-outline a:hover { color: var(--e-accent); text-decoration: underline; }
.est-empty { margin-top: 40px; padding: 28px; border-radius: 18px; background: var(--e-surface); color: var(--e-ink-2); text-align: center; }
.est-empty p { margin: 0; }

/* El texto */
.est-text {
  margin-top: 36px; font-family: var(--e-font, var(--serif)); font-size: var(--e-size, 18.5px); line-height: 1.78;
  font-optical-sizing: auto; font-variant-numeric: lining-nums; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
}
.est-col[data-kind="transcript"] .est-text { line-height: 1.85; }
.est-col[data-kind="transcript"] .est-text p { margin-bottom: 1.25em; }
.est-text > :first-child { margin-top: 0; }
.est-text p { margin: 0 0 .95em; }
.est-text h1, .est-text h2, .est-text h3, .est-text h4, .est-text h5 {
  font-family: var(--display); color: var(--e-ink); line-height: 1.25; letter-spacing: -.015em; hyphens: manual; text-wrap: balance; scroll-margin-top: 84px;
}
.est-text h1 { margin: 2em 0 .55em; font-size: 1.42em; font-weight: 800; }
.est-text h2 { margin: 2em 0 .55em; font-size: 1.28em; font-weight: 800; }
.est-text h3 { margin: 1.7em 0 .45em; font-size: 1.08em; font-weight: 800; }
.est-text h4, .est-text h5 { margin: 1.5em 0 .35em; font-size: .96em; font-weight: 700; }
/* El título interno (repite el del documento) no compite: se rebaja */
.est-text > h1:first-child, .est-text > p:first-child:has(> strong:only-child) {
  margin: 0 0 1.4em; font: 700 14px/1.4 var(--sans); letter-spacing: 0; color: var(--e-ink-3);
}
.est-text > p:first-child > strong:only-child { font-weight: 700; color: inherit; }
.est-text > hr { border: 0; height: 0; margin: 1.4em 0 0; }
.est-text > hr + h2, .est-text > hr + h3 { margin-top: 1.4em; }
.est-text strong { font-weight: 700; color: var(--e-ink); }
.est-text a { color: var(--e-accent); text-underline-offset: 3px; }
.est-text ul, .est-text ol { margin: .35em 0 1em; padding-left: 1.35em; }
.est-text li { margin: .3em 0; padding-left: .15em; }
.est-text li > p { margin: .15em 0; }
.est-text li::marker { color: color-mix(in srgb, var(--e-accent) 55%, var(--e-ink-3)); }
.est-text ol > li::marker { font: 700 .86em var(--sans); }
.est-text blockquote { margin: 1.2em 0; padding: .8em 1.1em; border-radius: 14px; background: var(--e-surface); color: var(--e-ink-2); }
.est-text blockquote > :last-child { margin-bottom: 0; }
.est-text hr { border: 0; border-top: 1px solid var(--e-rule); margin: 2em 0; }
.est-text code { font: .86em/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; background: var(--e-surface); padding: .12em .35em; border-radius: 6px; }
.est-text pre { overflow-x: auto; padding: 14px 16px; border-radius: 14px; background: var(--e-surface); font-size: .84em; line-height: 1.5; }
.est-text pre code { background: none; padding: 0; }
.est-text img { max-width: 100%; height: auto; border-radius: 12px; }
.est-table {
  --w: min(64rem, calc(100vw - 56px)); width: var(--w); margin: 1.5em 0 1.5em calc((100% - var(--w)) / 2);
  overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--e-rule);
}
.est-text table { width: 100%; border-collapse: collapse; font: 15px/1.45 var(--sans); font-variant-numeric: tabular-nums lining-nums; hyphens: manual; }
.est-text th { padding: .6em .8em; background: var(--e-surface); text-align: left; font-weight: 800; vertical-align: bottom; }
.est-text td { padding: .55em .8em; border-top: 1px solid var(--e-rule); vertical-align: top; }
.est[data-cifras="on"] .cifra { font-weight: 600; color: var(--e-ink); text-decoration: underline dotted 1.5px; text-decoration-color: var(--e-ink-3); text-underline-offset: .22em; }

/* Final del texto */
.est-end { margin-top: 3.2em; padding-top: 1.6em; border-top: 1px solid var(--e-rule); }
.est-source { margin: 0 0 1.2em; font: 600 14px/1.45 var(--sans); color: var(--e-ink-3); }
.est-source a { color: var(--e-accent); }
.est-check {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 22px;
  margin: 0 0 22px; padding: 18px 20px; border-radius: 20px; background: var(--e-surface);
}
.est-check > div { flex: 1 1 280px; }
.est-check p { margin: 0; font: 500 14.5px/1.45 var(--sans); color: var(--e-ink-2); }
.est-check .est-check-t { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; font: 800 16.5px/1.3 var(--sans); color: var(--e-ink); }
.est-check-t .ico { width: 19px; height: 19px; }
.est-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.est-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 8px 20px; max-width: 100%;
  border: 1px solid var(--e-rule); border-radius: 999px; background: var(--e-bg); color: var(--e-ink); cursor: pointer;
  font: 700 14.5px/1.25 var(--sans); text-align: left; transition: background .15s, transform .12s var(--press);
}
.est-btn:hover { background: var(--e-surface); }
.est-btn:active { transform: scale(.97); }
.est-btn > span { min-width: 0; display: flex; flex-direction: column; }
.est-btn small { font: 700 12px var(--sans); color: var(--e-ink-3); }
.est-btn.main { border-color: var(--e-accent); background: var(--e-accent); color: var(--e-on-accent); margin-left: auto; }
.est-btn.main small { color: color-mix(in srgb, var(--e-on-accent) 75%, transparent); }
.est-btn.main:hover { background: color-mix(in srgb, var(--e-accent) 86%, #000); }
.est-btn.wide { width: 100%; margin-top: 14px; }
.est-nav .est-btn { flex: 0 1 auto; max-width: min(100%, 26rem); }
.est-nav .est-btn > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.est-keys { margin: 2.4em 0 0; text-align: center; font: 600 13px var(--sans); color: var(--e-ink-3); }
@media (hover: none) { .est-keys { display: none; } }

/* Paneles: índice (izquierda), lectura (arriba a la derecha), subrayados (derecha) */
.est-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20, 14, 9, .32); }
.est-panel {
  position: fixed; z-index: 50; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 28px;
  background: var(--e-bg); color: var(--e-ink); box-shadow: var(--e-shadow); font: 500 15px/1.4 var(--sans);
}
.est-left { inset: 0 auto 0 0; width: min(400px, 92vw); border-radius: 0 24px 24px 0; }
.est-right { inset: 0 0 0 auto; width: min(460px, 100vw); border-radius: 24px 0 0 24px; }
.est-menu { top: 66px; right: 12px; width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - 82px); border-radius: 22px; }
@media (max-width: 640px) {
  .est-right { border-radius: 0; }
  .est-menu { inset: auto 0 0 0; top: auto; width: 100%; max-height: 82dvh; border-radius: 24px 24px 0 0; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
}
.est-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.est-panel-head h2 { margin: 0; padding-top: 9px; font: 800 18px/1.25 var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.est-panel-sub { margin: 3px 0 0; font: 600 13.5px/1.4 var(--sans); color: var(--e-ink-3); }
.est-toc-group { margin: 18px 0 6px; font: 800 12.5px var(--sans); color: var(--e-ink-3); }
.est-toc-none { margin: 8px 0 0; }
.est-toc { list-style: none; margin: 0; padding: 0; }
.est-toc a, .est-toc button {
  display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer;
  color: var(--e-ink); text-decoration: none; font: 700 15px/1.3 var(--sans);
}
.est-toc .lv-h3 a { padding-left: 26px; font-weight: 600; font-size: 14px; color: var(--e-ink-2); }
.est-toc a:hover, .est-toc button:hover { background: var(--e-surface); }
.est-toc a.is-here { background: var(--e-accent-soft); }
.est-toc-sib button { display: flex; flex-direction: column; gap: 1px; }
.est-toc-sib small { font: 600 12.5px var(--sans); color: var(--e-ink-3); }
.est-toc-sib button[aria-current="page"] { background: var(--e-accent-soft); cursor: default; }

.est-menu fieldset { margin: 0 0 16px; padding: 0; border: 0; }
.est-menu legend { display: flex; gap: 8px; margin-bottom: 7px; font: 800 13px var(--sans); color: var(--e-ink-2); }
.est-legend-v { font-weight: 600; color: var(--e-ink-3); }
.est-seg { display: grid; gap: 6px; }
.est-seg-2 { grid-template-columns: repeat(2, 1fr); }
.est-seg-3 { grid-template-columns: repeat(3, 1fr); }
.est-seg-4 { grid-template-columns: repeat(4, 1fr); }
.est-seg button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 6px;
  border: 1.5px solid var(--e-rule); border-radius: 16px; background: none; cursor: pointer; font: 700 13px var(--sans);
  transition: background .15s, border-color .15s, transform .12s var(--press);
}
.est-seg button:hover:not(:disabled) { background: var(--e-surface); }
.est-seg button:active:not(:disabled) { transform: scale(.97); }
.est-seg button[aria-pressed="true"] { border-color: var(--e-accent); background: var(--e-accent-soft); }
.est-seg button:disabled { opacity: .4; cursor: default; }
.est-seg-big { font-size: 22px; line-height: 1; font-weight: 400; }
.est-swatch { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.est-swatch[data-sw="claro"] { background: #fbf8f3; }
.est-swatch[data-sw="sepia"] { background: #f4e9d4; }
.est-swatch[data-sw="oscuro"] { background: #2a1f17; }
.est-swatch[data-sw="auto"] { background: conic-gradient(#fbf8f3 0 50%, #2a1f17 50% 100%); transform: rotate(45deg); }
.est-width { display: grid; gap: 3px; justify-items: center; }
.est-width i { display: block; height: 2px; border-radius: 2px; background: currentColor; opacity: .7; }
.est-width[data-w="estrecha"] i { width: 16px; }
.est-width[data-w="normal"] i { width: 22px; }
.est-width[data-w="ancha"] i { width: 30px; }
.est-switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font: 700 14.5px var(--sans); cursor: pointer; }
.est-switch input { width: 20px; height: 20px; accent-color: var(--e-accent); }

/* Panel de subrayados */
.est-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.est-filter button {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--e-rule); border-radius: 999px;
  background: none; cursor: pointer; font: 700 13px var(--sans); color: var(--e-ink-2);
}
.est-filter button[aria-pressed="true"] { border-color: var(--e-accent); background: var(--e-accent-soft); color: var(--e-ink); }
.est-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.est-dot[data-c="amarillo"] { background: #f5d76e; }
.est-dot[data-c="verde"] { background: #a9d696; }
.est-dot[data-c="azul"] { background: #9cc3ea; }
.est-dot[data-c="rosa"] { background: #eea7bb; }
.est-mks { list-style: none; margin: 0; padding: 0; }
.est-mk { display: flex; align-items: flex-start; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--e-rule); }
.est-mk:last-child { border-bottom: 0; }
.est-mk-go {
  flex: 1; min-width: 0; display: grid; gap: 6px; padding: 8px 10px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer;
}
.est-mk-go:hover:not(:disabled) { background: var(--e-surface); }
.est-mk-go:disabled { cursor: default; opacity: .75; }
.est-mk-q { font: 400 15.5px/1.55 var(--e-font, var(--serif)); color: var(--e-ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.est-mk-q mark.subr { cursor: inherit; }
.est-mk-note { display: flex; gap: 6px; font: 600 13.5px/1.4 var(--sans); color: var(--e-ink-2); white-space: pre-wrap; }
.est-mk-note .ico { width: 15px; height: 15px; margin-top: 1px; color: var(--e-ink-3); }
.est-mk-empty { padding: 8px 2px; color: var(--e-ink-2); font: 500 14.5px/1.5 var(--sans); }
.est-mk-empty p { margin: 0 0 10px; }
.est-mk-empty b { color: var(--e-ink); }
.est-legend-colors { display: flex; flex-wrap: wrap; gap: 14px; }
.est-legend-colors > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }

@media (pointer: coarse) {
  .est-mk-del.est-icon.small { width: 44px; height: 44px; }
  .est-filter button { height: 44px; padding: 0 14px; }
}
@media (max-width: 640px) {
  .est-text table { min-width: 34rem; }
  .est-bar { height: 56px; padding: 0 6px; }
  .est-main { padding: 84px 18px 96px; }
  .est-text { font-size: calc(var(--e-size, 18.5px) - 1px); }
  .est-table { --w: calc(100vw - 36px); }
  .est-nav .est-btn { flex: 1 1 100%; max-width: none; }
  .est-btn.main { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .est-bar, .est-progress > div, .est-btn, .est-icon, .subr-sw, .subr-act { transition: none; }
  mark.subr.is-flash { animation: none; outline: 3px solid color-mix(in srgb, currentColor 25%, transparent); }
}
@media print {
  .est { position: static; overflow: visible; }
  .est-bar, .est-progress, .est-end, .est-panel, .est-scrim, .subr-tools, .adock { display: none !important; }
  .est-main { padding: 0; }
}

/* ---------- El asistente al lado de lo que lees (assist.js) ----------
   Ordenador: panel de la altura de la ventana a la derecha y el texto se estrecha; móvil y tableta: pantalla completa. */
:root { --adock-w: clamp(380px, 31vw, 470px); }
.adock {
  position: fixed; z-index: 60; display: flex; flex-direction: column; inset: 0; height: 100dvh;
  background: var(--surface); color: var(--text); font-family: var(--sans); overscroll-behavior: contain;
}
.adock[hidden] { display: none; }
.adock.is-side {
  inset: 0 0 0 auto; width: var(--adock-w); border-left: 1px solid var(--border);
  box-shadow: -22px 0 44px -30px rgba(51, 38, 28, .4);
}
html.has-adock body { padding-right: var(--adock-w); }
.est.has-adock { right: var(--adock-w); }
.est.has-adock .est-bar, .est.has-adock .est-progress { right: var(--adock-w); }
.est.has-adock .est-right { right: var(--adock-w); border-radius: 24px; }
.est.has-adock .est-menu { right: calc(var(--adock-w) + 12px); }
.est.has-adock .est-scrim { right: var(--adock-w); }

.adock-head {
  flex: none; display: flex; align-items: center; gap: 2px; height: 60px; padding: 0 8px;
  border-bottom: 1px solid var(--border);
}
.adock:not(.is-side) .adock-head { height: calc(58px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
.adock-t { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.adock-mark { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.adock-mark .mark-svg { width: 17px; height: 16px; fill: currentColor; }
.adock-tt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.adock-tt b { font: 800 15px var(--sans); color: var(--text); }
.adock-tt span { font: 600 12.5px var(--sans); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adock-icon {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, transform .12s cubic-bezier(.2, .8, .3, 1);
}
.adock-icon:hover { background: var(--surface-2); color: var(--text); }
.adock-icon:active { transform: scale(.94); }
.adock-icon .ico { width: 19px; height: 19px; }
@media (pointer: coarse) { .adock-icon { width: 44px; height: 44px; } }
@media (max-width: 380px) { .adock-icon[data-ad="tab"] { display: none; } }
.adock-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.adock-loading, .adock-err { margin: 20px; }

/* La conversación dentro del panel: como en el móvil (conversaciones en cajón, respuesta a todo el ancho) */
.chat-shell.is-dock {
  flex: 1; height: auto; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none;
  grid-template-columns: minmax(0, 1fr); --col: 100%; background: var(--surface);
}
.is-dock .chat-side {
  position: absolute; inset: 0 auto 0 0; width: min(86%, 320px); z-index: 20; transform: translateX(-104%);
  transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .18);
}
.is-dock.side-open .chat-side { transform: none; }
.is-dock .chat-side-close { display: inline-grid; }
.is-dock .chat-scrim { display: block; position: absolute; inset: 0; background: rgba(20, 15, 10, .32); z-index: 15; }
.is-dock .chat-scrim[hidden] { display: none; }
.is-dock .chat-bar { display: none; }
.is-dock .chat-msgs { padding: 20px 18px 16px; gap: 22px; }
.is-dock .msg.user { max-width: 88%; }
.is-dock .msg.assistant { grid-template-columns: minmax(0, 1fr); }
.is-dock .msg.assistant > .chat-mark { display: none; }
.is-dock .prose.answer { font-size: 16px; line-height: 1.68; }
.is-dock .chat-dock { padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
.is-dock .composer { border-radius: 20px; padding: 8px 8px 6px 14px; }
.is-dock .composer-hint { display: none; }
.is-dock .composer-row { justify-content: space-between; }
.is-dock .chat-foot { margin-top: 6px; font-size: 11px; }
.is-dock .chat-suggest { grid-template-columns: 1fr; margin-top: 20px; }
.is-dock .chat-empty { padding-top: 8px; }
.is-dock .chat-empty h2 { font-size: 24px; }
.is-dock .chat-empty > p { font-size: 14.5px; }
.is-dock .chat-empty .more { display: none; }
.is-dock .chat-mark.big { width: 44px; height: 44px; margin-bottom: 14px; }
.is-dock .sources a { grid-template-columns: auto minmax(0, 1fr); }
.is-dock .src-k { display: none; }
@media (max-width: 860px) { .is-dock .chat-foot { display: none; } }
@media (prefers-reduced-motion: reduce) { .is-dock .chat-side { transition: none; } }
/* Con el panel abierto, la barra de subrayar anclada se centra en el texto, no en la ventana */
html.has-adock .subr-tools.is-docked, .est.has-adock .subr-tools.is-docked { left: calc((100vw - var(--adock-w)) / 2); }
