/* Estilos propios de larialaz, sobre Oat (vendor/oat.min.css) y theme.css.
   Regla: solo variables de theme.css/Oat, nada de colores sueltos (salvo blanco/negro sobre video).
   Orden: base → layout → componentes → vistas. Cada selector se define UNA vez. */

/* ═══ Base ════════════════════════════════════════════════════════════════ */
body { font-feature-settings: "cv11", "ss01"; } /* Inter: a de un piso y dígitos más legibles */

/* Títulos en Playfair 2 (óptica "display": alto contraste, para tamaños grandes). */
.serif {
  font-family: var(--font-serif); font-weight: 700; letter-spacing: -0.005em;
  font-variation-settings: "opsz" 72;
}
h1.serif { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem); line-height: 1.05; }

/* Iconos (Iconoir, subconjunto generado con `make icons`). */
i[class^="iconoir-"] { font-size: 1.15em; vertical-align: -0.2em; flex-shrink: 0; }

/* Cursor de mano en TODO lo clickeable. */
a[href], button:not(:disabled), [role="tab"], summary, select,
input[type="checkbox"], input[type="radio"], input[type="file"], input[type="submit"],
label:has(> input[type="file"]), label:has(> input[type="checkbox"]), .photo-drop,
[data-goto], [data-copy], [data-approve],
video::-webkit-media-controls-panel { cursor: pointer; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
label.busy { opacity: 0.6; pointer-events: none; } /* subiendo fotos */

.meta { color: var(--muted-foreground); font-size: var(--text-8); }

/* Superficies del navegador con la paleta (selección, cursor de texto, controles nativos, barras, foco). */
:root { accent-color: var(--primary); scrollbar-color: color-mix(in srgb, var(--muted-foreground) 45%, transparent) transparent; }
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--foreground); }
input, textarea { caret-color: var(--primary); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.badge, .meta, .tl-scale, .poster-stats, .cmd code { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══ Layout: barra superior, sidebar, página ═══════════════════════════════ */
.topnav {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--card); border-bottom: 1px solid var(--border);
}

/* Marca: "laria" (rojo de marca) + "laz" (color del texto). */
.brand { display: flex; align-items: center; gap: 0; color: var(--foreground); }
.brand-name { font-weight: 700; letter-spacing: -0.025em; font-size: 1.75rem; line-height: 1; }
.brand-a { color: var(--primary); }
.brand-b { color: var(--foreground); }

/* Botón de tema: muestra el icono del modo al que cambia (☀ en oscuro, ☾ en claro). */
.theme-toggle { margin-inline-start: auto; }
.theme-toggle i[class^="iconoir-"] { display: none; font-size: 1.25rem; vertical-align: 0; }
[data-tema="dark"] .theme-toggle .iconoir-sun-light,
[data-tema="light"] .theme-toggle .iconoir-half-moon { display: inline-block; }

aside[data-sidebar] { background: var(--card); }
aside[data-sidebar] nav a { align-items: center; } /* Oat no centra icono, texto y badge */
aside[data-sidebar] nav a > i[class^="iconoir-"] { vertical-align: 0; font-size: 1.15rem; }
.nav-label {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: var(--text-8); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground);
}

/* Contenido pegado al sidebar (sin centrar). Oat trae 32px arriba en <main>: lo controla .page. */
[data-sidebar-layout] > main { padding-top: 0; }
.page { max-width: 110rem; padding: var(--space-4) var(--space-4) var(--space-12); }
@media (min-width: 768px) { .page { padding: var(--space-4) var(--space-6) var(--space-12); } }

.crumbs { font-size: var(--text-7); color: var(--muted-foreground); margin-bottom: var(--space-4); }
.crumbs a { color: var(--muted-foreground); }
.crumbs a:hover { color: var(--foreground); }
.crumbs li[aria-hidden] { display: flex; align-items: center; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-6);
}
.page-head h1 { margin: 0; }
.page-head .meta { margin: var(--space-1) 0 0; }

/* ═══ Componentes ═════════════════════════════════════════════════════════ */

/* Tabs */
[role="tab"] { gap: var(--space-2); }
[role="tab"] .badge { padding: 2px 6px; }

/* Badges · estilo "Sutil": neutro para información; color SOLO para estados/avisos y marca,
   siempre suave (fondo = color al 9 %, borde = 30 %). Contraste validado en theme_test.go. */
.badge {
  gap: 4px; padding: 4px 8px; border-radius: 6px; line-height: 1.1;
  font-size: 12px; font-weight: var(--font-medium);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 55%, var(--card));
  color: var(--foreground);
}
.badge i[class^="iconoir-"] { font-size: 13px; vertical-align: 0; color: var(--muted-foreground); }
.badge:is(.outline, [data-variant="secondary"]) {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 55%, var(--card));
  color: var(--foreground);
}
[data-variant="brand"] { --_variant-color: var(--primary); }
.badge:is([data-variant="success"], [data-variant="warning"], [data-variant="danger"], [data-variant="brand"]) {
  color: var(--_variant-color);
  border-color: color-mix(in srgb, var(--_variant-color) 30%, var(--card));
  background: color-mix(in srgb, var(--_variant-color) 9%, var(--card));
}
.badge:is([data-variant="success"], [data-variant="warning"], [data-variant="danger"], [data-variant="brand"]) i[class^="iconoir-"] { color: inherit; }
.badge.lg { padding: 6px 11px; font-size: 14px; gap: 6px; border-radius: 8px; }
.badge.lg i[class^="iconoir-"] { font-size: 16px; }

/* Tarjetas */
.cards { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color var(--transition-fast); }
a.card:hover { border-color: var(--primary); }
.card h2, .card h3 { margin: 0; }

/* Placeholder "sin video / sin fotos" */
.ph {
  width: 100%; aspect-ratio: 9 / 16; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-1); border-radius: var(--radius-medium); background: var(--muted); color: var(--muted-foreground);
}
.ph small { font-size: var(--text-8); }
.ph i[class^="iconoir-"] { font-size: 1.6rem; }

/* Avisos */
.ai-note {
  display: flex; gap: var(--space-2); align-items: flex-start; margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-medium);
  background: color-mix(in srgb, var(--primary) 7%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--card));
  font-size: var(--text-7); color: var(--foreground);
}
.ai-note i[class^="iconoir-"] { margin-top: 2px; color: var(--primary); }
.pending {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4);
}
.pending-text { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-2); }

/* Documentos de texto (universo, guion) */
.path { margin: 0 0 var(--space-2); font-family: var(--font-mono); font-size: var(--text-8); color: var(--muted-foreground); }
pre.doc {
  margin: 0; padding: 0; border: 0; background: none; white-space: pre-wrap;
  font-family: var(--font-mono); font-size: var(--text-7); line-height: 1.6;
}

/* Subida de fotos (alta) */
.photo-drop {
  position: relative; display: block !important; border: 2px dashed var(--input);
  border-radius: var(--radius-medium); padding: var(--space-5); text-align: center;
  transition: border-color var(--transition-fast);
}
.photo-drop:hover { border-color: var(--primary); }
.photo-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; }
.photo-drop-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); color: var(--muted-foreground); font-weight: var(--font-normal); }
.photo-drop-empty i[class^="iconoir-"] { font-size: 1.8rem; }
.photo-drop-empty strong { color: var(--foreground); }
.photo-drop.has-files .photo-drop-empty { display: none; }
.photo-preview { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.photo-preview img { width: 6rem; height: 4.5rem; object-fit: cover; border-radius: var(--radius-small); }

/* Comando con botón copiar */
.cmd { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-1) 0 var(--space-3); }
.cmd code {
  flex: 1; min-width: 0; display: block; padding: var(--space-2) var(--space-3); overflow-x: auto;
  background: var(--muted); border-radius: var(--radius-medium); font-size: var(--text-8);
}

/* ═══ Vista: serie · tab Episodios (pósters 9:16) ═════════════════════════ */
.posters { display: grid; gap: var(--space-5) var(--space-4); grid-template-columns: repeat(auto-fill, minmax(11rem, 13rem)); }
.poster { display: block; color: inherit; text-decoration: none; }
.poster-frame {
  position: relative; aspect-ratio: 9 / 16; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-large); background: #111;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
/* Sin imagen: degradado con el color primario de la marca (fijo, no depende del tema). */
.poster-frame.is-blank { background: radial-gradient(ellipse at 50% 35%, var(--b-primario), color-mix(in srgb, var(--b-primario) 25%, #000) 70%); }
a.poster:hover .poster-frame { border-color: var(--primary); transform: translateY(-2px); }
.poster-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-caption { /* texto blanco sobre degradado negro: legible sobre cualquier miniatura, en ambos temas */
  position: absolute; inset-inline: 0; bottom: 0; padding: var(--space-12, 3rem) var(--space-3) var(--space-3);
  background: linear-gradient(transparent, rgb(0 0 0 / 0.9) 55%); color: #fff;
}
.poster-caption p { margin: 0; }
.poster-ep { font-size: var(--text-8); text-transform: uppercase; letter-spacing: .12em; opacity: .8; }
.poster-caption .title { font-family: var(--font-serif); font-weight: 700; font-size: var(--text-5); line-height: 1.15; }
.poster-stats { margin-top: var(--space-1) !important; font-size: var(--text-8); opacity: .8; }
.poster-flag { position: absolute; top: var(--space-2); left: var(--space-2); }

/* ═══ Vista: serie · tabs Personajes y Locaciones ═════════════════════════ */
.cards.people { grid-template-columns: repeat(auto-fill, minmax(max(16rem, (100% - 3 * var(--space-4)) / 4), 1fr)); } /* máx. 4 por fila */
.cards.locs { grid-template-columns: repeat(auto-fill, minmax(max(18rem, (100% - 2 * var(--space-4)) / 3), 1fr)); }  /* máx. 3 por fila */

.loc { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); } /* tarjeta de ficha (personaje o locación) */
.loc header { padding-inline: var(--space-1); }
.loc p { margin: 0; padding-inline: var(--space-1); font-size: var(--text-7); }
.loc p.meta { font-size: var(--text-8); }
.loc footer { margin-top: auto; padding: var(--space-1); flex-wrap: wrap; }
.loc h3 a { color: inherit; }
.person h3 { overflow-wrap: normal; word-break: normal; hyphens: none; }

/* La tarjeta entera abre la ficha (el título se estira encima). */
.loc { position: relative; }
.loc .card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.loc .card-link:focus-visible { outline: none; }
.loc:has(.card-link:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Hover de tarjeta con imagen (series del inicio, personajes, locaciones): sube, borde de 2 px en el color
   primario (borde + anillo de 1 px, sin mover el contenido), la imagen se acerca y la cruza el brillo
   diagonal de la portada. */
:is(.loc, .series-tile) { transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast); }
:is(.loc, .series-tile):is(:hover, :has(.card-link:focus-visible)) {
  transform: translateY(-3px); border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 2px 4px rgb(0 0 0 / .05), 0 14px 32px rgb(0 0 0 / .14);
}
.loc:hover h3, .series-tile:hover h2 { color: var(--primary); }
:is(.loc-media, .person-media, .series-tile-cover) { position: relative; }
:is(.loc-media, .person-media, .series-tile-cover) img { transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
:is(.loc, .series-tile):hover :is(.loc-media, .person-media, .series-tile-cover) img { transform: scale(1.04); }
:is(.loc-media:has(img), .person-media:has(img), .series-tile-cover)::after {
  content: ""; position: absolute; inset: -50%; pointer-events: none; transform: translateX(-70%);
  background: linear-gradient(115deg, transparent 40%, rgb(255 255 255 / .1) 45%, rgb(255 255 255 / .5) 50%, rgb(255 255 255 / .08) 55%, transparent 60%);
}
:is(.loc, .series-tile):hover :is(.loc-media, .person-media, .series-tile-cover)::after { animation: card-shine 1.1s cubic-bezier(.3, 0, .3, 1) both; }
@keyframes card-shine { from { transform: translateX(-70%); } to { transform: translateX(70%); } } /* más corto que el de la portada: la franja pasa más tiempo sobre la imagen */
@media (prefers-reduced-motion: reduce) {
  :is(.loc, .series-tile):hover { transform: none; }
  :is(.loc, .series-tile):hover :is(.loc-media, .person-media, .series-tile-cover) img { transform: none; }
  :is(.loc-media, .person-media, .series-tile-cover)::after { display: none; }
}

.loc-media { aspect-ratio: 4 / 3; border-radius: var(--radius-medium); overflow: hidden; background: var(--muted); }
.loc-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.loc-media .ph { aspect-ratio: auto; height: 100%; }
.loc-thumbs { display: flex; gap: var(--space-1); overflow-x: auto; position: relative; z-index: 1; } /* sobre el enlace de la tarjeta: se puede desplazar */
.loc-thumbs img { width: 3.5rem; height: 2.6rem; object-fit: cover; border-radius: var(--radius-small); flex-shrink: 0; }

.person-media { aspect-ratio: 1 / 1; border-radius: var(--radius-medium); overflow: hidden; background: var(--muted); }
.person-media img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.person-ph {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 30%, var(--card)), var(--muted));
}
.person-ph span { font-family: var(--font-serif); font-weight: 700; font-size: 4rem; line-height: 1; font-variation-settings: "opsz" 72; }
.person-ph small { font-size: var(--text-8); color: var(--foreground); opacity: 0.8; }

.tab-empty { grid-column: 1 / -1; }

/* Estado vacío: qué es esto, por qué está vacío y cuál es el siguiente paso. */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center;
  max-width: 34rem; margin: 0 auto; padding: var(--space-8) var(--space-4);
}
.empty-state > i[class^="iconoir-"] { font-size: 2.5rem; color: var(--muted-foreground); margin-bottom: var(--space-1); }
.empty-state h2 { margin: 0; font-size: var(--text-5); }
.empty-state p { margin: 0 0 var(--space-2); color: var(--muted-foreground); line-height: 1.55; }
.empty-state form { margin: 0; }
.empty-state .cmd { width: 100%; }
.montaje-empty { margin: 0; padding: var(--space-6) var(--space-4); border: 1px dashed var(--border); border-radius: var(--radius-large); }

/* ═══ Formularios en tarjeta (fichas, universo, marca, alta de serie) ══════ */
.form-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.form-card > label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-7); font-weight: var(--font-medium); }
.form-card footer { justify-content: flex-end; margin-top: var(--space-2); }
.form-card .ai-note { margin: 0; }
.form-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.form-card-head h2 { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-5); }
.form-card-head form { margin: 0; }
.form-help { margin: 0; font-size: var(--text-8); color: var(--muted-foreground); }

/* ═══ Vista: episodio ═════════════════════════════════════════════════════ */
.ep-head { align-items: center; }
/* Título del episodio: se ve como un título normal; al pasar el mouse se nota que se puede editar
   (clic, escribir, Enter). Sin título, el placeholder "Episodio N" se ve igual que un título real. */
.ep-title { position: relative; margin: 0; }
/* El ancho lo da una copia invisible del texto (data-value) en la misma celda de la grilla:
   field-sizing: content corta la última letra con Playfair. */
.ep-title h1 { display: inline-grid; max-width: 100%; margin: 0; }
.ep-title h1::after { content: attr(data-value); visibility: hidden; white-space: pre; overflow: hidden; }
.ep-title h1::after, .ep-title input { grid-area: 1 / 1; padding: 0 var(--space-2); border: 1px solid transparent; }
.ep-title input {
  width: 100%; min-width: 0; margin: 0 calc(-1 * var(--space-2));
  font: inherit; letter-spacing: inherit; color: var(--foreground); background: transparent;
  border-radius: var(--radius-medium); box-shadow: none; height: auto; cursor: text;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.ep-title h1::after { margin: 0 calc(-1 * var(--space-2)); padding-right: calc(var(--space-2) + .5em); } /* + espacio del cursor y del remate de la última letra */
.ep-title input::placeholder { color: var(--foreground); opacity: 1; }
.ep-title input:hover { background: var(--card); border-color: var(--border); }
.ep-title input:focus { background: var(--card); border-color: var(--primary); outline: none; box-shadow: 0 0 0 1px var(--primary); }
.ep-title input:focus::placeholder { color: var(--muted-foreground); }
.ep-title-status { position: absolute; left: 0; top: 100%; font-size: var(--text-8); color: var(--muted-foreground); white-space: nowrap; }
.ep-title-status:empty { display: none; }
.ep-title-status[data-kind="error"] { color: var(--danger); }
.ep-title:has(.ep-title-status:not(:empty)) + .meta { visibility: hidden; }
/* Anterior / siguiente: un par unido sobre fondo de tarjeta, del alto del título, iconos en el color del texto. */
.ep-pager :is(a, button) {
  width: 2.5rem; height: 2.5rem; padding: 0; justify-content: center;
  background: var(--card); color: var(--foreground); border-color: var(--border);
  box-shadow: 0 1px 2px rgb(0 0 0 / .06);
}
.ep-pager :is(a, button) i[class^="iconoir-"] { font-size: 1.35rem; }
.ep-pager a:hover { color: var(--primary); border-color: var(--primary); background: var(--card); position: relative; z-index: 1; }
.ep-pager button:disabled { color: var(--muted-foreground); opacity: .45; }

/* Guion: tarjeta de documento; el modo (Escribir · Procesado) va DENTRO, con estilo liviano
   (texto + subrayado, como Write/Preview en GitHub), para no competir con las tabs principales. */
.doc-card { display: block; max-width: 56rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-large); overflow: hidden; }
.doc-card > [role="tablist"] {
  display: flex; width: 100%; align-items: stretch; gap: var(--space-4);
  padding: 0 var(--space-4); border-radius: 0;
  background: color-mix(in srgb, var(--muted) 35%, var(--card)); border-bottom: 1px solid var(--border);
}
.doc-card > [role="tablist"] > [role="tab"] {
  gap: 6px; padding: var(--space-3) 2px; margin-bottom: -1px;
  background: transparent; box-shadow: none; border-radius: 0;
  border-bottom: 2px solid transparent; color: var(--muted-foreground);
}
.doc-card > [role="tablist"] > [role="tab"]:hover { color: var(--foreground); }
.doc-card > [role="tablist"] > [role="tab"][aria-selected="true"] { background: transparent; box-shadow: none; color: var(--foreground); border-bottom-color: var(--primary); }
.doc-card > [role="tabpanel"] { padding: 0; }
.doc-meta {
  margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  gap: var(--space-1) var(--space-4); font-size: var(--text-8); color: var(--muted-foreground);
}
.doc-card:has(#procesado[aria-selected="true"]) .writer-meta,
.doc-card:has(#escribir[aria-selected="true"]) .processed-meta { display: none; }
.doc-body { padding: var(--space-5) var(--space-6) !important; }
.writer-status[data-kind="error"] { color: var(--danger); }
.writer textarea { /* hoja de máquina de escribir */
  display: block; width: 100%; min-height: 65vh; resize: vertical;
  padding: var(--space-8) clamp(var(--space-4), 6vw, var(--space-12));
  border: 0; border-radius: 0; outline: none; box-shadow: none;
  background: var(--card); color: var(--foreground);
  font-family: "Courier Prime", "Courier New", Courier, var(--font-mono);
  font-size: 1.05rem; line-height: 1.75; tab-size: 4;
}
.writer textarea::placeholder { color: var(--muted-foreground); }
.writer-help { margin: 0; padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-8); color: var(--muted-foreground); }

/* Storyboard · línea de tiempo: pista = max(90 s, total); marca de gancho (3 s), mínimo (60 s)
   y zona de cliffhanger (últimos 10 s). */
.tl { margin-bottom: var(--space-5); padding: var(--space-4); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-large); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.tl-head strong { font-size: var(--text-4); font-variant-numeric: tabular-nums; }
.tl-track {
  position: relative; height: 34px; border-radius: var(--radius-medium); border: 1px dashed var(--input);
  background: repeating-linear-gradient(90deg, var(--muted) 0 6px, transparent 6px 12px), var(--faint);
}
.tl-segs { position: absolute; inset: 0; display: flex; gap: 2px; padding: 2px; }
.tl-seg {
  all: unset; box-sizing: border-box; min-width: 18px; height: 100%; border-radius: 4px;
  display: grid; place-items: center; font-size: var(--text-8); font-weight: var(--font-semibold);
  color: var(--card); background: color-mix(in srgb, var(--primary) 70%, var(--card));
  transition: filter var(--transition-fast);
}
.tl-seg:hover, .tl-seg:focus-visible { filter: brightness(1.15); outline: 2px solid var(--ring); outline-offset: 1px; }
.tl-zone { position: absolute; top: -4px; bottom: -4px; pointer-events: none; border-radius: var(--radius-small); }
.tl-cliff { border: 2px solid var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.tl-mark { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 2px solid var(--warning); pointer-events: none; }
.tl-mark.tl-min { border-left: 2px dashed var(--muted-foreground); }
.tl-scale { position: relative; height: 1.2rem; margin-top: var(--space-1); font-size: var(--text-8); }
.tl-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-scale span:last-child { transform: translateX(-100%); }
.tl-scale span:first-child { transform: none; } /* "gancho 0:03" queda pegado al inicio: centrado se salía de la tarjeta */

/* Storyboard · una toma por fila, en orden */
.sb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.sb-row {
  display: grid; grid-template-columns: 5.5rem 1fr auto; gap: var(--space-4); align-items: start;
  padding: var(--space-3); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-large);
  scroll-margin-top: 5rem; transition: box-shadow var(--transition), border-color var(--transition);
}
.sb-row.flash { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.sb-thumb { position: relative; aspect-ratio: 9 / 16; border-radius: var(--radius-medium); overflow: hidden; background: var(--muted); }
.sb-thumb video, .sb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.sb-thumb .ph { height: 100%; aspect-ratio: auto; border-radius: 0; }
.sb-thumb-label { position: absolute; inset: auto 0 0; padding: 2px; text-align: center; font-size: 10px; color: #fff; background: rgb(0 0 0 / 0.55); }
.sb-main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.sb-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.sb-head strong { font-size: var(--text-6); }
.sb-head .meta { font-variant-numeric: tabular-nums; }
.sb-dialog { margin: 0; font-family: var(--font-serif); font-size: 1.15rem; line-height: 1.4; font-style: italic; font-variation-settings: "opsz" 24; }
.sb-action { margin: 0; font-size: var(--text-7); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sb-meta { margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-8); color: var(--muted-foreground); }
.sb-row .err { margin: 0; color: var(--danger); font-size: var(--text-8); }
/* "Prompt para HeyGen": enlace compacto (Oat lo estiraría como acordeón a todo el ancho) */
.sb-prompt { display: block; width: fit-content; max-width: 100%; border: 0; background: none; font-size: var(--text-8); }
.sb-prompt[open] { width: 100%; }
.sb-prompt summary {
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; width: auto;
  padding: 0; border: 0; background: none; list-style: none; color: var(--muted-foreground); font-size: var(--text-8);
}
.sb-prompt summary:hover { color: var(--foreground); }
.sb-prompt summary::-webkit-details-marker { display: none; }
.sb-prompt summary::after { position: static; margin: 0 0 0 2px; }
.sb-prompt summary i[class^="iconoir-"] { vertical-align: 0; }
.sb-prompt p {
  margin: var(--space-2) 0 0; padding: var(--space-3); background: var(--faint); border-radius: var(--radius-medium);
  font-family: var(--font-mono); line-height: 1.55; color: var(--foreground);
}
.sb-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); }
.sb-chips { display: flex; gap: var(--space-1); }
.chip {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; cursor: help;
  color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--card));
}
.chip[data-kind="spec"] { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: color-mix(in srgb, var(--danger) 30%, var(--card)); }
.chip i[class^="iconoir-"] { font-size: 14px; vertical-align: 0; }
@media (max-width: 640px) {
  .sb-row { grid-template-columns: 4.5rem 1fr; }
  .sb-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-end; }
}

/* Montaje */
.finals { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-6); }
.finals figure { width: 16rem; margin: 0; }
.finals figcaption { margin-top: var(--space-2); }
.finals video { width: 100%; aspect-ratio: 9 / 16; display: block; background: #000; border-radius: var(--radius-medium); }
.cmds { flex: 1; min-width: 18rem; }
.cmds p { margin: 0; font-size: var(--text-7); color: var(--muted-foreground); }

/* ═══ Vista: ficha (personaje / locación): foto grande + ficha ═════════════ */
.sheet-layout { display: grid; gap: var(--space-6); grid-template-columns: minmax(16rem, 24rem) minmax(0, 40rem); align-items: start; }
@media (max-width: 860px) { .sheet-layout { grid-template-columns: 1fr; } }
.sheet-side { display: flex; flex-direction: column; gap: var(--space-3); position: sticky; top: var(--space-4); }
@media (max-width: 860px) { .sheet-side { position: static; } }

.sheet-photo { margin: 0; aspect-ratio: 1 / 1; border-radius: var(--radius-large); overflow: hidden; background: var(--muted); border: 1px solid var(--border); }
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.sheet-photo-empty {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  aspect-ratio: 1 / 1; border-radius: var(--radius-large); color: var(--muted-foreground);
  background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 30%, var(--card)), var(--muted));
}
.sheet-photo-empty span { font-family: var(--font-serif); font-weight: 700; font-size: 6rem; line-height: 1; color: var(--foreground); font-variation-settings: "opsz" 72; }
.sheet-photo-empty i[class^="iconoir-"] { font-size: 3rem; }
.sheet-photo-empty small { font-size: var(--text-8); }

.sheet-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: var(--space-2); }
.sheet-thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: var(--radius-medium); overflow: hidden; border: 2px solid transparent; }
.sheet-thumb.is-main { border-color: var(--primary); }
.sheet-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-thumb-tag { position: absolute; top: 3px; left: 3px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); }
.sheet-thumb-tag i[class^="iconoir-"] { font-size: 12px; vertical-align: 0; }
.sheet-thumb-actions {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 2px; padding: 2px;
  background: rgb(0 0 0 / 0.55); opacity: 0; transition: opacity var(--transition-fast);
}
.sheet-thumb:hover .sheet-thumb-actions, .sheet-thumb:focus-within .sheet-thumb-actions { opacity: 1; }
.sheet-thumb-actions form { margin: 0; }
.sheet-thumb-actions button { color: #fff; padding: 2px 6px; min-height: 0; }
.sheet-upload label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; aspect-ratio: 1;
  border: 2px dashed var(--input); border-radius: var(--radius-medium); color: var(--muted-foreground); font-size: var(--text-8);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.sheet-upload label:hover { border-color: var(--primary); color: var(--foreground); }
.sheet-upload { margin: 0; }

.sheet-appears h3 { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 var(--space-2); font-size: var(--text-7); color: var(--muted-foreground); font-weight: var(--font-semibold); }
.sheet-appears ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sheet-appears a {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: var(--text-8);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground); text-decoration: none;
}
.sheet-appears a:hover { border-color: var(--primary); color: var(--primary); }

/* Formulario agrupado */
.field-row { display: flex; gap: var(--space-3); }
.field-row label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-7); font-weight: var(--font-medium); }
.field-grow { flex: 1; }
.field-short { width: 7rem; }
/* Secciones de un formulario: planas, separadas por una línea y aire (nada de cajas dentro de la tarjeta). */
.field-group {
  display: flex; flex-direction: column; gap: var(--space-3); min-width: 0;
  margin: var(--space-3) 0 0; padding: var(--space-5) 0 0; border: 0; border-top: 1px solid var(--border); border-radius: 0;
}
.form-card > .field-group:first-child, .form-card > .ai-note + .field-group { margin-top: 0; padding-top: 0; border-top: 0; }
/* float saca a la leyenda del borde del fieldset: queda como el título de la sección */
.field-group legend { float: left; width: 100%; display: flex; align-items: center; gap: var(--space-2); padding: 0; font-size: var(--text-6); font-weight: var(--font-semibold); }
.field-group legend i[class^="iconoir-"] { color: var(--muted-foreground); }
.field-group label, .sheet-form > label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-7); font-weight: var(--font-medium); }
.hint-inline { font-weight: var(--font-normal); color: var(--muted-foreground); font-size: var(--text-8); }
textarea.mono { font-family: var(--font-mono); font-size: var(--text-8); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sheet-photo-open, .sheet-thumb-view { display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: none; cursor: pointer; }
.sheet-photo-open { cursor: zoom-in; }
.sheet-photo.is-viewing img { object-fit: contain; object-position: center; } /* otra foto que no es el retrato: entera, sin recortar */
.sheet-thumb:has(.sheet-thumb-view[aria-pressed="true"]):not(.is-main) { border-color: var(--foreground); }
.sheet-photo-open:focus-visible, .sheet-thumb-view:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

/* Visor de imágenes (template "lightbox"): la foto entera sobre fondo oscuro. */
dialog.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; overflow: hidden; cursor: zoom-out;
}
dialog.lightbox[open] { display: grid; place-items: center; }
dialog.lightbox::backdrop { background: color-mix(in oklch, var(--art) 94%, transparent); }
dialog.lightbox img { max-width: calc(100vw - 2 * var(--space-6)); max-height: calc(100dvh - 7rem); object-fit: contain; border-radius: var(--radius-medium); cursor: default; box-shadow: 0 24px 64px -24px oklch(0% 0 0 / 0.6); }
.lightbox-close {
  position: fixed; top: var(--space-4); right: var(--space-4); display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0;
  border: 0; border-radius: 50%; font-size: 1.4rem; color: var(--art-foreground); background: color-mix(in oklch, var(--art-foreground) 14%, transparent);
}
.lightbox-close:hover { background: color-mix(in oklch, var(--art-foreground) 24%, transparent); }
.lightbox-count { position: fixed; bottom: var(--space-4); left: 0; right: 0; margin: 0; text-align: center; font-size: var(--text-7); color: var(--art-muted-foreground); font-variant-numeric: tabular-nums; }
html:has(dialog.lightbox[open]) { overflow: hidden; }
.sheet-photo.is-set { aspect-ratio: 3 / 4; } /* locaciones: fotos verticales del set */
.sheet-photo.is-set img { object-position: center; }

/* ───────────── Tab Marca ───────────── */
.brand-layout { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 40rem) minmax(16rem, 1fr); align-items: start; }
@media (max-width: 900px) { .brand-layout { grid-template-columns: 1fr; } }
.brand-form .meta { margin: 0; }

.brand-logo-row { display: flex; gap: var(--space-4); align-items: center; }
.brand-logo-box {
  flex: none; width: 10rem; aspect-ratio: 16 / 9; display: grid; place-items: center; padding: var(--space-2);
  border-radius: var(--radius-medium); border: 1px solid var(--border);
  /* cuadriculado: deja ver si el PNG tiene fondo transparente */
  background: repeating-conic-gradient(var(--muted) 0 25%, var(--background) 0 50%) 0 0 / 16px 16px;
}
.brand-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-logo-box.is-empty { color: var(--muted-foreground); }
.brand-logo-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.brand-logo-actions .meta { flex-basis: 100%; }
/* label que abre el selector de archivo, con el mismo aspecto que un button.small.outline */
.field-group :is(.brand-logo-actions, .brand-cover-info) label.button {
  flex-direction: row; align-items: center; gap: var(--space-1); padding: 4px 12px; font-size: 12px; font-weight: var(--font-medium);
  border: 1px solid var(--border); border-radius: var(--radius-medium); background: transparent; color: var(--foreground);
}
.field-group :is(.brand-logo-actions, .brand-cover-info) label.button:hover { background: var(--muted); }

.brand-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-3); }
.brand-swatch { display: flex; align-items: center; gap: var(--space-2); }
.brand-swatch input[type="color"] { width: 2.5rem; height: 2.5rem; padding: 2px; border-radius: var(--radius-medium); border: 1px solid var(--border); background: var(--background); }
.brand-swatch output { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-8); color: var(--muted-foreground); font-weight: var(--font-normal); }
.brand-warning { display: flex; gap: var(--space-2); align-items: baseline; margin: 0; font-size: var(--text-8); color: var(--warning); }

.brand-fonts { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--space-2); }
.field-group label.brand-font {
  position: relative; gap: var(--space-1); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-medium);
}
.brand-font input { position: absolute; opacity: 0; pointer-events: none; }
.brand-font:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.brand-font:has(input:focus-visible) { outline: 2px solid var(--ring, var(--primary)); outline-offset: 2px; }
.brand-font-sample { font-size: var(--text-4); font-weight: 700; line-height: 1.1; }
.brand-font small { color: var(--muted-foreground); font-weight: var(--font-normal); }

/* Vista previa 9:16: imita card.html y los subtítulos ASS (colores reales de la marca, no del tema). */
.brand-preview { position: sticky; top: var(--space-4); }
.brand-preview-label { margin: 0 0 var(--space-2); font-size: var(--text-6); font-weight: var(--font-semibold); }
.brand-frames { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); max-width: 26rem; }
.brand-frames figure { margin: 0; }
.brand-frames figcaption { margin-top: var(--space-1); font-size: var(--text-8); color: var(--muted-foreground); text-align: center; }
.frame { position: relative; aspect-ratio: 9 / 16; border-radius: var(--radius-medium); overflow: hidden; background: #000; container-type: inline-size; }
.frame-card {
  background: radial-gradient(ellipse at 50% 42%, var(--b-primario) 0%, color-mix(in srgb, var(--b-primario) 25%, #000) 58%, #000 100%);
}
/* Medidas en cqw = las de card.html (1080 px de ancho) escaladas. */
.frame-title { position: absolute; left: 8.3cqw; right: 13.9cqw; top: 66.7cqw; margin: 0; text-align: center;
  font: 700 10.4cqw/1.04 var(--b-font), Georgia, serif; letter-spacing: -.1cqw; color: #fff; text-shadow: 0 .5cqw 3.7cqw rgba(0,0,0,.6); }
.frame-logo { position: absolute; left: 13cqw; right: 18.5cqw; top: 51.9cqw; height: 40.7cqw; display: flex; align-items: flex-end; justify-content: center; }
.frame-logo[hidden], .frame-title[hidden] { display: none; }
.frame-logo img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 .5cqw 2.8cqw rgba(0,0,0,.5)); }
.frame-line { position: absolute; left: 36.1cqw; width: 27.8cqw; top: 95.4cqw; height: .4cqw; background: var(--b-secundario); }
.frame-sub { position: absolute; left: 8.3cqw; right: 13.9cqw; top: 99cqw; text-align: center; font: 600 4.6cqw/1.2 var(--b-font), sans-serif; letter-spacing: .74cqw; text-transform: uppercase; color: var(--b-secundario); }
.frame-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-subs {
  position: absolute; left: 8.3cqw; right: 13.9cqw; bottom: 24.5cqw; margin: 0; text-align: center;
  font: 700 6.3cqw/1.15 Arial, sans-serif; color: var(--b-subs);
  -webkit-text-stroke: 1.1cqw #000; paint-order: stroke fill;
}

/* Dos puntos con los colores de la marca, al final del título de la serie. */
h1:has(> .brand-dots) { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: .3em; }
.brand-dots { display: inline-flex; gap: .16em; }
/* Título: apoyados en la línea base y bajados .045em, su centro cae justo en la mitad de las minúsculas
   (altura x de Playfair ≈ .42em, medida en el navegador). */
h1 > .brand-dots { position: relative; top: .045em; }
.brand-dots span { width: .5em; height: .5em; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 15%, transparent); }
/* Sidebar: los puntos van donde iría el icono (mismo ancho que los iconos de la lista). */
.nav-dots { width: 1.15rem; margin: 0; justify-content: center; gap: 2px; flex-shrink: 0; }
.nav-dots span { width: .5rem; height: .5rem; }

/* Portada (póster 3:4) en la tab Marca */
.brand-cover-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.field-group label.brand-cover-box {
  display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: var(--radius-medium); overflow: hidden;
  border: 1px solid var(--border); background: var(--muted); color: var(--muted-foreground); font-weight: var(--font-normal);
}
.brand-cover-box.is-empty { border-style: dashed; }
.brand-cover-box.is-empty:hover { border-color: var(--primary); color: var(--foreground); }
.brand-cover-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-cover-box span { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; }
.brand-cover-box span i[class^="iconoir-"] { font-size: 1.8rem; }
.brand-cover-box small { font-size: var(--text-8); }
.brand-cover-info { display: flex; flex-direction: column; gap: var(--space-3); }
@media (max-width: 600px) { .brand-cover-row { grid-template-columns: 1fr; } .brand-cover-box { max-width: 12rem; } }

/* ───────────── Encabezado de la serie: portada + título + premisa ───────────── */
/* El encabezado es una superficie con un velo del color primario de la serie; las pestañas van pegadas
   a su borde inferior (ver "Pestañas de la serie"). */
.series-head {
  justify-content: flex-start; align-items: center; gap: var(--space-5);
  margin-bottom: 0; padding: var(--space-5) var(--space-6);
  background:
    radial-gradient(ellipse 75% 170% at 0% 0%, color-mix(in srgb, var(--b-primario, var(--primary)) 24%, transparent), transparent 70%),
    var(--card);
  border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-large) var(--radius-large) 0 0;
}
.series-cover {
  flex: none; width: 7.5rem; aspect-ratio: 3 / 4; border-radius: var(--radius-medium); overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  background: var(--muted); color: var(--muted-foreground); text-decoration: none; box-shadow: 0 6px 20px rgb(0 0 0 / .18);
}
.series-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Brillo diagonal al entrar (y al pasar el mouse): una franja de luz cruza la portada una vez. */
.series-cover:not(.is-empty) { position: relative; }
.series-cover:not(.is-empty)::after {
  content: ""; position: absolute; inset: -50%; pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgb(255 255 255 / .08) 45%, rgb(255 255 255 / .55) 50%, rgb(255 255 255 / .08) 55%, transparent 60%);
  transform: translateX(-100%); animation: cover-shine 1.4s cubic-bezier(.4, 0, .2, 1) .35s both;
}
.series-cover:not(.is-empty):hover::after { animation: cover-shine-hover 1s cubic-bezier(.4, 0, .2, 1) both; }
@keyframes cover-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes cover-shine-hover { from { transform: translateX(-100%); } to { transform: translateX(100%); } } /* otro nombre: así se repite al pasar el mouse */
@media (prefers-reduced-motion: reduce) { .series-cover::after { animation: none !important; opacity: 0; } }
.series-cover.is-empty { box-shadow: none; border: 1px dashed var(--border); text-align: center; }
.series-cover.is-empty:hover { border-color: var(--primary); color: var(--foreground); }
.series-cover.is-empty i[class^="iconoir-"] { font-size: 1.6rem; }
.series-cover small { font-size: var(--text-8); }
.series-head-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.series-head-text h1 { margin: 0; }
.series-premise { margin: 0; max-width: 46rem; color: var(--muted-foreground); line-height: 1.5; }
.series-premise.is-empty { font-size: var(--text-7); }
.series-head > .hstack { margin-left: auto; align-self: flex-start; }
@media (max-width: 600px) { .series-cover { width: 5rem; } }

/* ───────────── Tab Universo ───────────── */
.univ-layout { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 46rem) minmax(16rem, 1fr); align-items: start; }
@media (max-width: 1100px) { .univ-layout { grid-template-columns: 1fr; } }
.univ-form .form-help { display: flex; gap: var(--space-1); align-items: baseline; }
.dyn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.dyn-list a {
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: var(--space-3); align-items: center;
  padding: var(--space-2); border-radius: var(--radius-medium); color: inherit; text-decoration: none;
}
.dyn-list a:hover { background: var(--muted); }
.dyn-list img, .dyn-ph { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-small, 6px); object-fit: cover; }
.dyn-ph { display: grid; place-items: center; background: var(--muted); color: var(--muted-foreground); font-weight: 700; }
.dyn-list a > span:nth-child(2) { display: flex; flex-direction: column; font-size: var(--text-7); }
.dyn-list small { color: var(--muted-foreground); font-weight: var(--font-normal); }
.dyn-list a > i[class^="iconoir-"] { color: var(--muted-foreground); }

.secs { display: flex; flex-direction: column; gap: var(--space-3); }
.secs:empty { display: none; }
.sec-row { display: flex; flex-direction: column; gap: var(--space-2); }
.sec-row-head { display: flex; gap: var(--space-2); }
.sec-row-head input { font-weight: var(--font-semibold); }

.univ-context { position: sticky; top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.univ-context-head { display: flex; align-items: center; justify-content: space-between; }
.univ-context-head .brand-preview-label { margin: 0; }
.univ-context .meta { margin: 0; }
.univ-context pre.univ-context-doc { max-height: 70vh; overflow: auto; margin: 0; font-size: 12px; line-height: 1.5; }


/* ═══ Celular (≤ 640 px): vista de serie ═══════════════════════════════════ */
@media (max-width: 640px) {
  /* "Series > La Herencia" repite lo que ya dicen el menú y el título */
  .page:has(.series-head) .crumbs { display: none; }
  /* Portada chica al lado del título; la premisa debajo, a todo el ancho */
  .series-head { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: var(--space-3); align-items: center; padding: var(--space-4); }
  .series-head-text { display: contents; }
  .series-cover { width: 4.5rem; grid-row: 1; box-shadow: 0 4px 12px rgb(0 0 0 / .18); }
  .series-head h1 { grid-column: 2; font-size: 1.75rem; line-height: 1.1; }
  .series-premise { grid-column: 1 / -1; font-size: var(--text-7); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .series-head > .hstack { grid-column: 1 / -1; margin-left: 0; }

  /* Episodios: dos por fila */
  .posters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
  .poster-caption { padding: var(--space-8) var(--space-2) var(--space-2); }
  .poster-caption .title { font-size: var(--text-6); }

  /* Formularios: menos relleno anidado (tarjeta + grupo) para ganar ancho */
  .form-card { padding: var(--space-3); }
  .univ-context pre.univ-context-doc { max-height: 50vh; }

  /* Episodio: los contadores en una línea más chica */
  .ep-head > .hstack { gap: var(--space-3); }
  .ep-head .badge.lg { font-size: var(--text-8); padding: 2px var(--space-2); }

  /* Marca: los tres colores en una fila (solo muestra + nombre) */
  .brand-colors { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .brand-color .hint-inline { display: none; }
  .brand-swatch { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
}

/* ═══ Inicio: estante de series (portada 3:4 + título + premisa) ═════════════ */
.shelf { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(13rem, 16rem)); }
/* Cada serie es una tarjeta: portada + título + premisa + conteos como una sola unidad. */
.series-tile {
  display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3) var(--space-3) var(--space-4);
  color: inherit; text-decoration: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-large);
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
}
.series-tile > :not(.series-tile-cover) { padding-inline: var(--space-1); }
.series-tile-cover {
  aspect-ratio: 3 / 4; margin-bottom: var(--space-2); border-radius: var(--radius-medium); overflow: hidden;
}
.series-tile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Sin portada: los colores de la marca (fijos, no dependen del tema) y el título */
.series-tile-cover.is-blank {
  display: grid; place-items: end start; padding: var(--space-4);
  background: radial-gradient(ellipse at 50% 35%, var(--b-primario), color-mix(in srgb, var(--b-primario) 25%, #000) 75%);
}
.series-tile-cover.is-blank span { color: var(--b-secundario); font-size: var(--text-3); line-height: 1.05; }
.series-tile h2 { margin: 0; font-size: var(--text-4); line-height: 1.15; }
.series-tile-premise { margin: 0; font-size: var(--text-7); color: var(--muted-foreground); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.series-tile .meta { margin: var(--space-1) 0 0; }
.series-tile-counts span { white-space: nowrap; } /* "3 locaciones" nunca se corta al medio */
@media (max-width: 640px) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); } .series-tile { padding: var(--space-2) var(--space-2) var(--space-3); } .series-tile h2 { font-size: var(--text-5); } }

/* Alta de serie */
.new-series { max-width: 40rem; }
.nav-new { color: var(--muted-foreground); }

/* ═══ Pestañas de la serie ═══════════════════════════════════════════════
   Subrayadas y pegadas al encabezado (un solo bloque, como un perfil). El contenido de cada pestaña
   queda debajo, sobre el fondo, donde viven sus tarjetas. */
.series-tabs > [role="tablist"] {
  display: flex; width: 100%; gap: var(--space-5); min-height: 3rem; align-items: stretch;
  padding: 0 var(--space-6); background: var(--card);
  border: 1px solid var(--border); border-radius: 0 0 var(--radius-large) var(--radius-large);
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .04);
}
.series-tabs > [role="tablist"] > [role="tab"] {
  gap: 6px; padding: 0 2px; background: transparent; box-shadow: none; border-radius: 0;
  border-bottom: 2px solid transparent; color: var(--muted-foreground);
}
.series-tabs > [role="tablist"] > [role="tab"]:hover { color: var(--foreground); }
.series-tabs > [role="tablist"] > [role="tab"][aria-selected="true"] {
  background: transparent; box-shadow: none; color: var(--foreground); border-bottom-color: var(--primary);
}
.series-tabs > [role="tabpanel"] { padding-top: var(--space-6); }

/* Acción de la pestaña ("+ Nuevo personaje"). En escritorio va dentro de la fila de pestañas, a la derecha,
   liviana (texto primario + borde fino) para no competir con la barra. El panel es el bloque contenedor
   (la animación de Oat le deja un transform): bottom: 100% lo sube a la fila de pestañas. */
.tab-toolbar { display: flex; justify-content: flex-end; margin-bottom: var(--space-3); }
@media (min-width: 900px) {
  .series-tabs > [role="tablist"] { height: 3rem; }
  .series-tabs > [role="tabpanel"] { position: relative; }
  .series-tabs .tab-toolbar { position: absolute; bottom: 100%; right: var(--space-4); height: 3rem; margin: 0; align-items: center; }
  .series-tabs .tab-toolbar form { margin: 0; }
  .series-tabs .tab-toolbar :is(button, .button) {
    height: 2rem; padding: 0 var(--space-3); gap: 6px; font-size: var(--text-7); font-weight: var(--font-medium);
    background: transparent; color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
    box-shadow: none;
  }
  .series-tabs .tab-toolbar :is(button, .button):hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 60%, transparent);
  }
}

/* Estado vacío dentro de una pestaña: superficie punteada a todo el ancho */
.series-tabs .empty-state {
  max-width: none; width: 100%; margin: 0; padding: var(--space-10) var(--space-4);
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius-large);
}
.series-tabs .empty-state p { max-width: 34rem; }
.posters:has(> .empty-state) { display: block; } /* la grilla de pósters tiene columnas fijas */

@media (max-width: 640px) {
  /* Una fila que se desliza con el dedo, sin barra; la sombra a la derecha avisa que hay más pestañas
     y desaparece al llegar al final ("scroll shadows": una máscara se comería el borde de la tarjeta). */
  .series-tabs > [role="tablist"] {
    padding: 0 var(--space-4); gap: var(--space-4); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
    background:
      linear-gradient(to left, var(--card) 30%, transparent) right / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / .14), transparent) right / .9rem 100% no-repeat scroll,
      var(--card);
  }
  .series-tabs > [role="tablist"]::-webkit-scrollbar { display: none; }
  .series-tabs > [role="tablist"] > [role="tab"] { scroll-snap-align: start; flex: none; }
  .series-tabs > [role="tabpanel"] { padding-top: var(--space-4); }
}

/* ═══ Sidebar: Administración al pie ═════════════════════════════════════ */
/* Segundo <nav> del sidebar (así hereda el estilo de Oat), pegado abajo en vez de repartirse el alto */
aside[data-sidebar] > nav.sidebar-foot { flex: none; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  margin: 0; padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); }
.sidebar-user-name { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--text-7);
  color: var(--muted-foreground); }
.sidebar-user-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══ Entrar ═══════════════════════════════════════════════════════════════ */
body.login-page { min-height: 100dvh; display: grid; place-items: center; background: var(--background); padding: var(--space-4); }
.login {
  width: min(60rem, 100%); display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; padding: 0; margin: 0;
  background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: 1.25rem;
  box-shadow: 0 1px 2px oklch(0% 0 0 / 0.04), 0 18px 48px -18px oklch(0% 0 0 / 0.22);
}

/* Panel izquierdo: hebras en SVG (template "login", auth.go loginArt) sobre un fondo siempre oscuro. */
.login-art { position: relative; min-height: 29rem; background: var(--art); color: var(--art-foreground); isolation: isolate; }
.login-art svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.login-art .hebra-a { stroke: var(--art-line-a); }
.login-art .hebra-b { stroke: var(--art-line-b); }
.login-art::after { /* velo abajo para que el texto se lea sobre las hebras */
  content: ""; position: absolute; inset: 45% 0 0; z-index: -1;
  background: linear-gradient(to bottom, transparent, color-mix(in oklch, var(--art) 92%, transparent) 70%);
}
.login-art-mark {
  position: absolute; top: var(--space-5); left: var(--space-5); display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; border-radius: 0.75rem; font-size: 1.35rem;
  background: color-mix(in oklch, var(--art-foreground) 14%, transparent); color: var(--art-foreground);
}
.login-art-text { position: absolute; inset: auto var(--space-5) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.login-art-text p { margin: 0; color: var(--art-muted-foreground); font-size: var(--text-7); line-height: 1.55; max-width: 34ch; text-wrap: pretty; }
.login-art-text .brand-name { font-size: 1.6rem; color: var(--art-foreground); }
.login-art-text .brand-a { color: var(--art-line-b); }
.login-art-text .brand-b { color: var(--art-foreground); }

/* Formulario */
.login-form { display: flex; flex-direction: column; justify-content: center; gap: var(--space-4); padding: var(--space-8) var(--space-6); }
.login-form header { text-align: center; margin-bottom: var(--space-2); }
.login-form h1 { margin: 0 0 var(--space-2); font-size: 2.25rem; letter-spacing: -0.02em; }
.login-form header p { margin: 0; color: var(--muted-foreground); font-size: var(--text-7); }
.login-form label { font-weight: 600; font-size: var(--text-7); }
.login-form label input:not([type="checkbox"]) { margin-top: var(--space-2); font-weight: 400; }
.login-form .required { color: var(--danger); font-weight: 600; }
.login-form .login-remember { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.login-form .login-remember input { margin: 0; }
.login-form button[type="submit"] { width: 100%; justify-content: center; padding-block: 0.8rem; font-size: 1rem; }
.login-help { margin: 0; text-align: center; color: var(--muted-foreground); font-size: var(--text-8); }

@media (max-width: 720px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 11rem; }
  .login-art-text p:not(.brand-name) { display: none; } /* en el celular el formulario manda */
  .login-form { padding: var(--space-6) var(--space-5); }
}

/* ═══ Vista: Administración ═══════════════════════════════════════════════ */
.admin { display: flex; flex-direction: column; gap: var(--space-5); max-width: 40rem; }
.quota { display: flex; flex-direction: column; gap: 4px; }
.quota-label { display: flex; justify-content: space-between; font-size: var(--text-7); }
.quota-label strong { font-variant-numeric: tabular-nums; }
.quota-bar { height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.quota-bar span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.quota[data-level="warning"] .quota-bar span { background: var(--warning); }
.quota[data-level="danger"] .quota-bar span { background: var(--danger); }
.quota small { font-size: var(--text-8); color: var(--muted-foreground); }
.admin-calls { display: flex; flex-direction: column; margin: 0; }
.admin-calls li { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; border-top: 1px solid var(--border); font-size: var(--text-7); }
.admin-calls li:first-child { border-top: 0; padding-top: 0; }

/* Ayuda de IA bajo un campo: botón + estado ("Generando…", resultado o error) */
.ai-assist { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-top: calc(-1 * var(--space-1)); }
.ai-status { font-size: var(--text-8); color: var(--muted-foreground); }
.ai-status[data-error] { color: var(--danger); }
.ai-status button.link { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }

/* ═══ Subidas con progreso (app.js) ═══════════════════════════════════════ */
.upload-status {
  position: fixed; left: 50%; bottom: var(--space-5); z-index: 50; transform: translateX(-50%);
  width: min(26rem, 100vw - 2 * var(--space-4)); display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-large); border: 1px solid var(--border);
  background: var(--card); color: var(--card-foreground); font-size: var(--text-7); font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px oklch(0% 0 0 / 0.06), 0 16px 40px -16px oklch(0% 0 0 / 0.3);
}
.upload-status-bar { display: block; height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.upload-status-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 0.2s ease-out; }
.upload-status.is-processing .upload-status-bar span { animation: upload-pulse 1.2s ease-in-out infinite; }
@keyframes upload-pulse { 50% { opacity: 0.45; } }
.upload-status[data-error] { color: var(--danger); }
.upload-status[data-error] .upload-status-bar { display: none; }
form.is-uploading { opacity: 0.7; }
.sheet-upload label.busy { border-color: var(--primary); color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .upload-status-bar span { transition: none; } .upload-status.is-processing .upload-status-bar span { animation: none; } }

/* ═══ Avisos dentro de la página (template "notice") ══════════════════════ */
.notice {
  --_c: var(--success);
  display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-3);
  border: 1px solid color-mix(in srgb, var(--_c) 28%, var(--border)); border-radius: var(--radius-large);
  background: color-mix(in srgb, var(--_c) 5%, var(--card)); color: var(--foreground);
  box-shadow: 0 1px 2px oklch(0% 0 0 / 0.04), 0 6px 20px -12px color-mix(in srgb, var(--_c) 40%, transparent);
  animation: notice-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.notice[data-variant="error"] { --_c: var(--danger); }
.notice[data-variant="warning"] { --_c: var(--warning); }
.notice-icon {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: color-mix(in srgb, var(--_c) 15%, transparent); color: var(--_c); font-size: 1.05rem;
}
.notice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 0.3rem; font-size: var(--text-7); line-height: 1.4; }
.notice-body strong { font-weight: var(--font-semibold); }
.notice-body span { color: var(--muted-foreground); text-wrap: pretty; }
.notice[data-variant="error"] .notice-body strong { color: var(--danger); }
.notice-close {
  flex: none; margin-left: auto; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted-foreground); font-size: 1rem;
}
.notice-close:hover { background: color-mix(in srgb, var(--foreground) 8%, transparent); color: var(--foreground); }
.notice.is-leaving { animation: notice-out 0.25s ease-in forwards; }
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes notice-out { to { opacity: 0; transform: translateY(-6px); } }
.login-form .notice { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .notice, .notice.is-leaving { animation: none; } }
