/* ============================================================================
 * styles.css — "La galaxia judicial en torno a Pedro Sánchez" · DiarioBOE.es
 *
 * Esta pieza es de DiarioBOE, así que hereda su sistema de diseño en lugar de
 * inventarse uno. Tomado tal cual de diarioboe.nuxt:
 *
 *   tokens   assets/css/main.css — triples HSL, tema claro y oscuro con
 *            [data-theme] + prefers-color-scheme
 *   fuentes  Source Serif 4 (titulares) · Public Sans (UI) · IBM Plex Mono (datos)
 *   patrones cabecera de sección con punto azul y regla, kicker en versalita
 *            azul, tarjetas rounded-xl con --shadow-card, badges bg-primary/10
 *
 * Lo único propio de esta pieza es la cronología: el eje, las fichas con
 * pestaña de estado y el sello de fechas. Todo lo demás debe reconocerse
 * como diarioboe.es.
 * ==========================================================================*/

/* ---------------- Tokens del portal ---------------- */
:root {
  --shell: 214 52% 80%;
  --background: 214 64% 87%;
  --foreground: 222 47% 11%;
  --card: 214 55% 98%;
  --muted: 214 56% 92%;
  --muted-foreground: 215 25% 32%;
  --border: 214 35% 82%;
  --primary: 217 92% 55%;
  --primary-foreground: 0 0% 100%;
  --shadow-card: 0 6px 20px -6px #0f172a2e;
  color-scheme: light;

  /* estados judiciales — un valor por tema, como el resto del sistema */
  --st-centro:        hsl(var(--foreground));
  --st-sentenciado:   #64748b;
  --st-pte-sentencia: #dc2626;
  --st-en-juicio:     #ea580c;
  --st-pte-juicio:    #b45309;
  --st-instruccion:   hsl(var(--primary));
  --st-polemica:      #7c3aed;

  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans:  "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:  "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --shell: 222 35% 12%;
  --background: 222 32% 14%;
  --foreground: 214 40% 96%;
  --card: 222 30% 22%;
  --muted: 222 28% 18%;
  --muted-foreground: 215 18% 74%;
  --border: 222 28% 20%;
  --primary: 217 92% 65%;
  --primary-foreground: 222 47% 7%;
  --shadow-card: 0 10px 26px #0000008c;
  color-scheme: dark;

  --st-sentenciado:   #94a3b8;
  --st-pte-sentencia: #f87171;
  --st-en-juicio:     #fb923c;
  --st-pte-juicio:    #fbbf24;
  --st-polemica:      #a78bfa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --shell: 222 35% 12%;
    --background: 222 32% 14%;
    --foreground: 214 40% 96%;
    --card: 222 30% 22%;
    --muted: 222 28% 18%;
    --muted-foreground: 215 18% 74%;
    --border: 222 28% 20%;
    --primary: 217 92% 65%;
    --primary-foreground: 222 47% 7%;
    --shadow-card: 0 10px 26px #0000008c;
    color-scheme: dark;

    --st-sentenciado:   #94a3b8;
    --st-pte-sentencia: #f87171;
    --st-en-juicio:     #fb923c;
    --st-pte-juicio:    #fbbf24;
    --st-polemica:      #a78bfa;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: hsl(var(--primary) / .25); }

#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* versalita de metadato — el patrón de kicker del portal */
.kicker, .sh-section > h4, .tl-half-tag, .tl-sum-k, .crono-k,
.disclaimer-tag, .rel-tag, .badge, .indicios-head, .search-hint {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid hsl(var(--primary)); outline-offset: 2px; border-radius: 4px;
}

/* ---------------- Shell (cabecera del portal) ---------------- */
.shell {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px;
  background: hsl(var(--shell));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: 30;
}
/* el crédito acompaña al logo, separado por un filete, sin competir con él */
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-credit {
  font-size: 11px; color: hsl(var(--muted-foreground));
  padding-left: 12px; border-left: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.brand-credit a { color: hsl(var(--primary)); text-decoration: none; font-weight: 700; }
.brand-credit a:hover { text-decoration: underline; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; font-size: 17px; font-weight: 700; letter-spacing: -.2px;
}
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0;
}
.brand-name strong { color: hsl(var(--primary)); font-weight: 700; }

.shell-actions { display: flex; align-items: center; gap: 10px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap input {
  width: 260px; max-width: 42vw;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 8px; color: hsl(var(--foreground));
  padding: 8px 52px 8px 30px; font-size: 13px; font-family: var(--font-sans);
  outline: none;
}
.search-wrap input::placeholder { color: hsl(var(--muted-foreground) / .8); }
.search-wrap input:focus { border-color: hsl(var(--primary)); }
.search-wrap::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: hsl(var(--muted-foreground)); font-size: 15px; pointer-events: none;
}
.search-hint {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: hsl(var(--muted-foreground)); pointer-events: none;
}
.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0; cursor: pointer;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 8px; color: hsl(var(--muted-foreground)); font-size: 15px;
}
.icon-btn:hover { color: hsl(var(--primary)); border-color: hsl(var(--primary) / .5); }

/* ---------------- Página ---------------- */
.page {
  flex: 1; width: 100%; max-width: 1440px; margin: 0 auto;
  padding: 18px 20px 22px; display: flex; flex-direction: column; min-height: 0;
}

/* Masthead: la cabecera de periódico del portal */
.masthead { text-align: center; margin-bottom: 14px; }
.masthead h1 {
  font-family: var(--font-serif); font-size: clamp(28px, 4vw, 44px);
  font-weight: 600; letter-spacing: -1px; line-height: 1.06;
}
.subtitle {
  font-family: var(--font-serif); font-size: clamp(13px, 1.4vw, 16px);
  color: hsl(var(--muted-foreground)); margin-top: 5px;
}
.kicker-lead {
  margin-top: 7px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; color: hsl(var(--primary));
}

/* Barra de leyenda: la nav de categorías del portal */
.legendbar {
  border-top: 1px solid hsl(var(--border) / .6);
  border-bottom: 1px solid hsl(var(--border) / .6);
  padding: 8px 0; margin-bottom: 16px;
}
.legend {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; flex-wrap: wrap;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: hsl(var(--muted-foreground)); white-space: nowrap;
}
.dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; }
.dot.dot-diamond { border-radius: 2px; transform: rotate(45deg); }

/* Sección: título con punto azul + regla, como en portada */
.section { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  border-bottom: 2px solid hsl(var(--foreground) / .1);
  padding-bottom: 11px; margin-bottom: 4px;
}
.section-head h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.section-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: hsl(var(--primary)); flex-shrink: 0;
}
.section-note { font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.section-note strong { color: hsl(var(--foreground)); font-weight: 700; }

/* ---------------- Escenario ---------------- */
/* el escenario crece con la cronología; no la encierra en un alto fijo con
 * scroll propio */
.stage { position: relative; min-height: 300px; margin-top: 14px; }

.state-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: hsl(var(--muted-foreground)); font-size: 13px;
  background: hsl(var(--background));
}
.state-overlay[hidden] { display: none; }
.state-overlay.err { color: var(--st-pte-sentencia); gap: 6px; }
.state-overlay code {
  font-family: var(--font-mono); background: hsl(var(--muted)); padding: 1px 5px; border-radius: 4px;
}
.spinner {
  width: 22px; height: 22px; border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary)); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Pie ---------------- */
/* el aviso ocupa el ancho del pie en lugar de apilarse en una columna estrecha */
.footbar {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 22px;
  background: hsl(var(--shell)); border-top: 1px solid hsl(var(--border));
}
.disclaimer { font-size: 11px; color: hsl(var(--muted-foreground)); line-height: 1.55; }
.disclaimer-tag {
  font-size: 9.5px; color: hsl(var(--primary)); margin-right: 8px;
}
/* la fecha de revisión cierra la nota legal, en la misma línea */
.disclaimer .muted {
  font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap;
}
/* el aviso de IA se separa del legal: es de otra naturaleza */
.disclaimer-ia { padding-top: 6px; border-top: 1px dashed hsl(var(--border)); }

/* ============================================================================
 * CRONOLOGÍA — modo ancho: eje horizontal a escala
 * ==========================================================================*/
.timeline { position: relative; }
.tl-scroll {
  width: 100%; overflow-x: auto; overflow-y: hidden;
  padding: 8px 10px; display: flex; align-items: center;
}
.tl-inner { position: relative; margin: auto; flex-shrink: 0; }

.tl-grid { position: absolute; inset: 0; pointer-events: none; }
.tl-year { position: absolute; top: 0; bottom: 0; border-left: 1px solid hsl(var(--border) / .7); }
.tl-year:nth-child(odd) { background: hsl(var(--muted) / .45); }
.tl-year-label {
  position: absolute; top: var(--axis-y, 50%); transform: translateY(-50%);
  left: 10px; font-family: var(--font-mono); font-size: 23px; font-weight: 600;
  letter-spacing: -1px; color: hsl(var(--foreground) / .13); user-select: none;
}

.tl-axis {
  position: relative; height: 40px;
  border-top: 2px solid hsl(var(--foreground) / .25);
  border-bottom: 1px solid hsl(var(--border));
}

.tl-half { position: relative; }
.tl-half-tag {
  position: absolute; right: 8px; font-size: 9.5px;
  color: hsl(var(--muted-foreground) / .85); user-select: none;
}
.tl-upper .tl-half-tag { top: 4px; }
.tl-lower .tl-half-tag { bottom: 4px; }
.tl-tag-pol { color: var(--st-polemica); }

/* --- ficha: la tarjeta del portal, en pequeño --- */
.tl-item {
  position: absolute; width: 0; padding: 0; border: 0;
  background: transparent; cursor: pointer; transition: opacity .15s;
}
.tl-item.is-dim { opacity: .38; }

.tl-stem { position: absolute; left: -.5px; width: 1px; opacity: .5; }
.tl-item.is-up   .tl-stem { top: 100%; }
.tl-item.is-down .tl-stem { bottom: 100%; }
.tl-item.is-sel .tl-stem, .tl-item.is-peek .tl-stem { opacity: 1; width: 2px; left: -1px; }

.tl-dot {
  position: absolute; left: -4.5px; width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 0 2px hsl(var(--background));
}
.tl-item.is-up   .tl-dot { bottom: -4.5px; }
.tl-item.is-down .tl-dot { top: -4.5px; }
.tl-dot-pol { border-radius: 2px; transform: rotate(45deg); }

.tl-label {
  position: absolute; right: 10px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 8px; box-shadow: var(--shadow-card);
  padding: 4px 10px; font-size: 12.5px; font-weight: 500;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tl-item.is-up   .tl-label { bottom: -13px; }
.tl-item.is-down .tl-label { top: -13px; }
.tl-item.lab-right .tl-label { right: auto; left: 10px; }
.tl-item:hover .tl-label, .tl-item.is-peek .tl-label { transform: translateY(-1px); }
.tl-item.is-sel .tl-label {
  border-color: hsl(var(--primary)); font-weight: 600;
  box-shadow: 0 0 0 2px hsl(var(--primary) / .25), var(--shadow-card);
}

/* distintivo de estado: número para las causas, rombo para las polémicas */
.tl-num {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px;
  padding: 0 5px; border-radius: 5px;
  background: color-mix(in srgb, var(--tab) 16%, transparent); color: var(--tab);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
}
.tl-pin {
  width: 9px; height: 9px; flex-shrink: 0; border-radius: 2px;
  background: var(--tab); transform: rotate(45deg);
}
/* el desfase, que es de lo que trata la pieza, se lee sin abrir nada */
.tl-gap-mini {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  color: hsl(var(--muted-foreground));
  padding-left: 8px; margin-left: 1px;
  border-left: 1px solid hsl(var(--border));
}
.tl-item.is-sel .tl-gap-mini { color: var(--st-pte-sentencia); }

/* --- periodo de los hechos --- */
.tl-band { position: absolute; height: 6px; border-radius: 3px; opacity: 0; transition: opacity .18s; }
.tl-item.is-up   .tl-band { bottom: -3px; }
.tl-item.is-down .tl-band { top: -3px; }
.tl-band.is-clipped::before {
  content: "◀"; position: absolute; left: -10px; top: -5px;
  font-size: 9px; color: inherit; opacity: .8;
}
.tl-item.is-sel .tl-band { opacity: .95; }
.tl-item.is-peek .tl-band { opacity: .45; }

.tl-link {
  position: absolute; height: 0;
  border-top: 1px dashed hsl(var(--muted-foreground));
  opacity: 0; transition: opacity .18s;
}
.tl-item.is-up   .tl-link { bottom: 0; }
.tl-item.is-down .tl-link { top: 0; }
.tl-link.is-null { display: none; }
.tl-item.is-sel .tl-link { opacity: .9; }
.tl-item.is-peek .tl-link { opacity: .5; }

/* --- resumen de fechas: tarjeta elevada del portal --- */
.tl-tip {
  position: absolute; z-index: 5; width: 340px; max-width: 84vw;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 12px; box-shadow: var(--shadow-card), 0 0 0 4px hsl(var(--background) / .6);
  padding: 14px 16px;
  transform: translateY(3px); opacity: 0; pointer-events: none;
  transition: opacity .14s ease-out, transform .14s ease-out;
}
.tl-tip.is-on { opacity: 1; transform: none; pointer-events: auto; }
.tl-tip-head {
  font-family: var(--font-serif); font-size: 17px; font-weight: 600;
  line-height: 1.2; letter-spacing: -.3px; margin-bottom: 10px;
  padding-bottom: 9px; border-bottom: 1px solid hsl(var(--border));
}

.tl-sum-meta {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.tl-sum-meta .badge { margin-top: 0; }
.tl-sum-count { font-size: 11.5px; color: hsl(var(--muted-foreground)); }

.tl-sum-row { display: flex; gap: 10px; align-items: baseline; margin-bottom: 5px; }
.tl-sum-k {
  flex-shrink: 0; width: 58px; font-size: 9.5px;
  color: hsl(var(--primary));
}
.tl-sum-v { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.tl-sum-gap {
  display: inline-block; margin-top: 6px;
  background: var(--st-pte-sentencia); color: #fff;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.tl-more {
  display: block; width: 100%; margin-top: 13px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border: 0; border-radius: 8px; padding: 9px 12px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 700;
}
.tl-more:hover { background: hsl(var(--primary) / .88); }

/* ============================================================================
 * CRONOLOGÍA — modo estrecho: asientos agrupados por año
 * ==========================================================================*/
.timeline.is-narrow { position: static; }
.timeline.is-narrow .tl-scroll { display: block; padding: 0; height: auto; overflow: visible; }
.tl-vlist { padding: 4px 0 8px; }

.tl-vyear { margin-top: 20px; }
.tl-vyear:first-child { margin-top: 6px; }
.tl-vyear-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tl-vyear-num {
  font-family: var(--font-mono); font-size: 19px; font-weight: 600;
  letter-spacing: -.5px;
}
.tl-vyear-rule { flex: 1; height: 2px; background: hsl(var(--foreground) / .1); }

.tl-vitems { display: flex; flex-direction: column; gap: 9px; }
.tl-vitem {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 10px; box-shadow: var(--shadow-card); overflow: hidden;
}
.tl-vhead {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; background: transparent; border: 0;
  cursor: pointer; text-align: left; font-family: inherit; color: inherit;
}
.tl-vmark {
  flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  color: #fff; border-radius: 50%;
}
.tl-vmark.is-pol { border-radius: 4px; transform: rotate(45deg); }
.tl-vtext { flex: 1; min-width: 0; }
.tl-vname { display: block; font-size: 15px; font-weight: 600; line-height: 1.25; }
.tl-vwhen {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  color: hsl(var(--muted-foreground)); margin-top: 3px;
}
.tl-vchevron { color: hsl(var(--muted-foreground)); font-size: 12px; transition: transform .15s; }
.tl-vitem.is-open .tl-vchevron { transform: rotate(180deg); }
.tl-vitem .tl-sum {
  padding: 12px 14px 14px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / .5);
}

/* ============================================================================
 * FICHA COMPLETA (modal)
 * ==========================================================================*/
.sheet {
  width: min(1080px, 94vw); max-height: 90vh;
  margin: auto;                    /* el reset de * anula el centrado del UA */
  padding: 0; border: 1px solid hsl(var(--border)); border-radius: 14px;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  box-shadow: 0 24px 60px -12px #0f172a66;
  overflow: hidden;                /* una sola barra de scroll, la del cuerpo */
}
.sheet::backdrop { background: hsl(222 47% 8% / .6); backdrop-filter: blur(2px); }
.sheet-body { max-height: 90vh; overflow-y: auto; }

.sh-head {
  position: sticky; top: 0; z-index: 2;
  padding: 24px 32px 20px; background: hsl(var(--card));
  border-bottom: 2px solid hsl(var(--foreground) / .1);
}

/* franja de datos clave: lo primero que se lee al abrir */
.sh-key {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; background: hsl(var(--border));
  border-bottom: 1px solid hsl(var(--border));
}
.key {
  display: flex; flex-direction: column; gap: 3px;
  padding: 16px 32px; background: hsl(var(--muted));
}
.key-k {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: hsl(var(--muted-foreground));
}
.key-v { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }
.key-x { font-size: 10.5px; color: hsl(var(--muted-foreground)); font-style: italic; }
.key.is-gap { background: hsl(var(--primary) / .1); }
.key.is-gap .key-v { color: var(--st-pte-sentencia); font-weight: 600; }
.sh-datenote {
  padding: 12px 32px; font-size: 12.5px; line-height: 1.6;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
}
.sh-close {
  position: absolute; right: 16px; top: 16px;
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  border-radius: 8px; color: hsl(var(--muted-foreground));
  padding: 5px 11px; cursor: pointer;
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
}
.sh-close:hover { color: hsl(var(--primary)); border-color: hsl(var(--primary) / .5); }

.sh-top { display: flex; gap: 16px; align-items: flex-start; }
.avatar {
  width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid currentColor; background-size: cover; background-position: center;
  display: grid; place-items: center;
  color: hsl(var(--muted-foreground)); font-size: 16px; font-weight: 700;
}
.avatar-pol { border-radius: 8px; transform: rotate(45deg); }
.pol-ico { transform: rotate(-45deg); font-size: 19px; }
.case-num { font-family: var(--font-mono); font-size: 22px; font-weight: 600; }

.sh-headtext { min-width: 0; padding-right: 72px; }
.kicker { font-size: 10px; color: hsl(var(--primary)); margin-bottom: 5px; }
.kicker-pol { color: var(--st-polemica); }
.sh-headtext h3 {
  font-family: var(--font-serif); font-size: 26px; font-weight: 600;
  line-height: 1.14; letter-spacing: -.6px;
}
.sh-role { font-size: 13px; color: hsl(var(--muted-foreground)); margin-top: 6px; }

.badge {
  display: inline-block; margin-top: 14px; padding: 4px 10px;
  border-radius: 999px; font-size: 10px; color: #fff;
}

/* dos columnas de lectura cuando hay ancho: es una ficha, no un hilo largo */
.sh-body { padding: 24px 32px 34px; column-gap: 40px; }
@media (min-width: 900px) { .sh-body { column-count: 2; } }
.sh-section { margin-bottom: 24px; break-inside: avoid; }
.sh-section > h4 {
  font-size: 10px; color: hsl(var(--muted-foreground));
  padding-bottom: 6px; margin-bottom: 11px;
  border-bottom: 1px solid hsl(var(--border));
}
.sh-summary { font-size: 15px; line-height: 1.7; color: hsl(var(--foreground) / .9); }

.nonpenal {
  background: color-mix(in srgb, var(--st-polemica) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-polemica) 35%, transparent);
  border-radius: 8px; padding: 12px 14px;
  font-size: 12.5px; line-height: 1.55;
  color: hsl(var(--muted-foreground)); margin-bottom: 22px; break-inside: avoid;
}
.nonpenal strong { color: var(--st-polemica); }

/* --- progreso del caso: los hitos, del más reciente al más antiguo --- */
.sh-progreso { break-inside: avoid-column; }
.sh-count {
  margin-left: 7px; padding: 1px 6px; border-radius: 999px;
  background: hsl(var(--primary) / .14); color: hsl(var(--primary));
  font-family: var(--font-mono); font-size: 9.5px;
}
.hito-list { list-style: none; }
.hito {
  display: flex; gap: 12px; padding: 0 0 14px 0; position: relative;
}
.hito::before {                       /* hilo que une los hitos */
  content: ""; position: absolute; left: 4px; top: 13px; bottom: -1px;
  width: 1px; background: hsl(var(--border));
}
.hito:last-child::before { display: none; }
.hito::after {                        /* marca del hito */
  content: ""; position: absolute; left: 0; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: hsl(var(--muted-foreground)); box-shadow: 0 0 0 2px hsl(var(--card));
}
.hito.is-last::after { background: hsl(var(--primary)); }
.hito-fecha {
  flex-shrink: 0; width: 78px; padding-left: 20px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  color: hsl(var(--muted-foreground)); line-height: 1.5;
}
.hito.is-last .hito-fecha { color: hsl(var(--primary)); font-weight: 600; }
.hito-body { min-width: 0; }
.hito-text { font-size: 13px; line-height: 1.5; }
.hito.is-last .hito-text { font-weight: 600; }
.hito-src {
  display: inline-block; margin-top: 3px;
  font-size: 11px; color: hsl(var(--primary)); text-decoration: none; font-weight: 500;
}
.hito-src::before { content: "↗ "; }
.hito-src:hover { text-decoration: underline; }

/* última novedad dentro del resumen flotante */
.tl-sum-last {
  margin-top: 11px; padding-top: 10px; border-top: 1px solid hsl(var(--border));
  display: flex; flex-direction: column; gap: 2px;
}
.tl-sum-last-k {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: hsl(var(--primary));
}
.tl-sum-last-v { font-size: 12px; line-height: 1.4; color: hsl(var(--foreground)); }

.indicios-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; color: var(--st-pte-sentencia);
  padding-bottom: 6px; margin-bottom: 11px;
  border-bottom: 1px solid hsl(var(--border));
}
.indicio-ico { font-size: 12px; }
.indicio {
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  border-radius: 8px; padding: 12px 14px; margin-bottom: 9px; break-inside: avoid;
}
.indicio-text { font-size: 13.5px; line-height: 1.6; }
.indicio-src {
  display: inline-block; margin-top: 8px;
  font-size: 11.5px; font-weight: 600; color: hsl(var(--primary)); text-decoration: none;
}
.indicio-src::before { content: "↗ "; }
.indicio-src:hover { text-decoration: underline; }

.fact-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.fact-list li {
  font-size: 13.5px; line-height: 1.6; color: hsl(var(--foreground) / .88);
  padding-left: 18px; position: relative;
}
.fact-list li::before {
  content: ""; position: absolute; left: 0; top: 10px;
  width: 9px; height: 2px; border-radius: 2px; background: hsl(var(--primary));
}

.court-box {
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); border-radius: 8px;
  padding: 10px 13px; font-family: var(--font-mono);
  font-size: 12px; line-height: 1.6; color: hsl(var(--muted-foreground));
}

.rel-list { display: flex; flex-direction: column; }
.rel {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 6px; cursor: pointer; text-align: left; border-radius: 6px;
  background: transparent; border: 0;
  border-bottom: 1px solid hsl(var(--border) / .5);
  font-family: inherit; color: inherit;
}
.rel:hover { background: hsl(var(--muted)); }
.rel-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rel-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rel-name { font-size: 13.5px; font-weight: 600; }
.rel-role {
  font-size: 11px; color: hsl(var(--muted-foreground)); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.rel-tag { font-size: 9.5px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.rel-state { font-weight: 600; }

.src-list { display: flex; flex-direction: column; gap: 9px; }
.src-list a {
  font-size: 12.5px; color: hsl(var(--primary)); text-decoration: none;
  line-height: 1.45; font-weight: 500;
}
.src-list a::before { content: "↗ "; }
.src-list a:hover { text-decoration: underline; }

/* ============================================================================
 * BOTONES Y APORTACIONES
 * ==========================================================================*/
.btn-primary {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border: 1px solid hsl(var(--primary)); border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.btn-primary:hover { background: hsl(var(--primary) / .88); }
.btn-ghost {
  background: transparent; color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border)); border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: hsl(var(--primary)); color: hsl(var(--primary)); }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 700; color: hsl(var(--primary));
  text-decoration: underline; text-underline-offset: 2px;
}

/* bloque de colaboración al pie de la ficha */
.sh-collab {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 32px; border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}
.sh-collab-txt { font-size: 13px; color: hsl(var(--muted-foreground)); }
.sh-collab-acts { display: flex; gap: 9px; }

/* --- formulario --- */
.aportar {
  width: min(560px, 94vw); max-height: 92vh;
  margin: auto; padding: 0; overflow: hidden;
  border: 1px solid hsl(var(--border)); border-radius: 14px;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  box-shadow: 0 24px 60px -12px #0f172a66;
}
.aportar::backdrop { background: hsl(222 47% 8% / .6); backdrop-filter: blur(2px); }
.ap-form { display: flex; flex-direction: column; max-height: 92vh; }

.ap-head {
  position: relative; padding: 22px 26px 16px;
  border-bottom: 2px solid hsl(var(--foreground) / .1);
}
.ap-head h3 {
  font-family: var(--font-serif); font-size: 24px; font-weight: 600;
  letter-spacing: -.5px; line-height: 1.15;
}
.ap-intro {
  margin-top: 8px; font-size: 12.5px; line-height: 1.55;
  color: hsl(var(--muted-foreground)); max-width: 46ch;
}

.ap-body { padding: 18px 26px 8px; overflow-y: auto; }
.ap-field { display: block; margin-bottom: 16px; }
.ap-label {
  display: block; margin-bottom: 6px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: hsl(var(--muted-foreground));
}
.ap-help {
  display: block; margin-top: 5px; font-size: 11.5px; line-height: 1.45;
  color: hsl(var(--muted-foreground));
}
.ap-input {
  width: 100%; display: block;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border)); border-radius: 8px;
  padding: 9px 11px; font-family: var(--font-sans); font-size: 13.5px;
  outline: none;
}
.ap-input:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--primary) / .18); }
.ap-textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
select.ap-input { cursor: pointer; }

.ap-choices { display: flex; gap: 7px; flex-wrap: wrap; }
.ap-choice {
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.ap-choice:hover { border-color: hsl(var(--primary)); color: hsl(var(--primary)); }
.ap-choice.is-on {
  background: hsl(var(--primary)); border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground)); font-weight: 600;
}

.ap-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.ap-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 26px; border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
}
.ap-note { font-size: 11.5px; color: hsl(var(--muted-foreground)); flex: 1; min-width: 200px; }
.ap-send {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 700;
}
.ap-send:hover { background: hsl(var(--primary) / .88); }
.ap-send:disabled { opacity: .6; cursor: default; }

.ap-state {
  margin: 0 26px 18px; padding: 10px 13px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.5;
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
}
.ap-state.is-err {
  background: color-mix(in srgb, var(--st-pte-sentencia) 14%, transparent);
  color: var(--st-pte-sentencia); font-weight: 500;
}
.ap-state.is-ok {
  background: hsl(var(--primary) / .12); color: hsl(var(--primary)); font-weight: 500;
}

/* ============================================================================
 * Pantallas estrechas
 * ==========================================================================*/
@media (max-width: 900px) {
  body { font-size: 14px; }
  #app { min-height: 0; }
  .shell { padding: 9px 13px; gap: 9px; }
  .search-wrap input { width: 150px; padding-right: 12px; }
  .search-hint { display: none; }
  .brand-credit { display: none; }   /* en móvil el logo ya identifica la marca */

  .page { padding: 18px 13px 24px; }
  .masthead { margin-bottom: 16px; }
  .legendbar { padding: 8px 0; margin-bottom: 18px; }
  .legend { justify-content: flex-start; gap: 12px; }
  .legend-item { font-size: 10px; }

  .section-head { flex-direction: column; align-items: flex-start; gap: 7px; }
  .section-head h2 { font-size: 16px; }
  .stage { min-height: 0; margin-top: 12px; }

  .footbar { flex-direction: column; align-items: flex-start; gap: 9px; padding: 13px; }

  .sheet {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    border: 0; border-radius: 0;
  }
  .sheet-body { max-height: 100dvh; }
  .sh-head { padding: 16px 16px 14px; }
  .sh-headtext { padding-right: 0; }
  .sh-headtext h3 { font-size: 21px; }
  .sh-close { position: static; display: block; margin: 0 0 12px auto; width: fit-content; }
  .sh-body { padding: 18px 16px 40px; }
  .key { padding: 13px 16px; }
  .sh-datenote { padding: 12px 16px; }
  .sh-collab { padding: 16px; flex-direction: column; align-items: stretch; }
  .sh-collab-acts { display: grid; grid-template-columns: 1fr 1fr; }
  .btn-primary, .btn-ghost { width: 100%; }

  .shell-actions .btn-primary { display: none; }   /* la llamada vive bajo el eje */
  .aportar { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    border: 0; border-radius: 0; }
  .ap-form { max-height: 100dvh; }
  .ap-head { padding: 16px 16px 14px; }
  .ap-body { padding: 16px 16px 8px; }
  .ap-foot { padding: 14px 16px; }
  .ap-send { width: 100%; }
  .ap-state { margin: 0 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
