/* =====================================================================
   ISEF · Sistema de diseño
   Tokens, tema claro/oscuro y primitivas compartidas (sitio + panel)
   ===================================================================== */

/* ---------- Tipografías ---------- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,500;0,600;0,700;1,6..72,400&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* =====================================================================
   1. TOKENS
   ===================================================================== */

:root {
  /* Tipografía */
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-eyebrow: 0.6875rem;
  --fs-micro: 0.75rem;
  --fs-small: 0.8125rem;
  --fs-body: 0.9375rem;
  --fs-lead: 1.0625rem;

  --ls-eyebrow: 0.16em;
  --ls-tight: -0.022em;

  /* Radios */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Ritmo vertical */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 88px;

  /* Marca (constante en ambos temas) */
  --brand-solid: #a41519;
  --brand-solid-700: #7c0e12;
  --brand-solid-900: #560a0d;

  /* Curvas */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Alto de barras */
  --nav-h: 68px;
  --sidebar-w: 264px;
  --sidebar-w-mini: 76px;

  color-scheme: light;
}

/* ---------- Tema claro ---------- */
:root,
[data-theme='light'] {
  --paper: #f5f6f9;
  --paper-2: #eceff4;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --surface-3: #e7eaf1;
  --surface-inv: #11151c;

  --ink: #10141b;
  --body: #3a4250;
  --muted: #6a7383;
  --faint: #98a0ae;

  --line: #dfe3ea;
  --line-strong: #c9cfda;
  --line-soft: #eaedf2;

  --brand: #a41519;
  --brand-hover: #7c0e12;
  --brand-tint: rgba(164, 21, 25, 0.08);
  --brand-tint-2: rgba(164, 21, 25, 0.14);
  --on-brand: #ffffff;

  --brass: #8a6d33;
  --brass-tint: rgba(138, 109, 51, 0.11);

  --ok: #0f7a53;
  --ok-tint: rgba(15, 122, 83, 0.1);
  --warn: #a3690a;
  --warn-tint: rgba(163, 105, 10, 0.11);
  --danger: #b4232a;
  --danger-tint: rgba(180, 35, 42, 0.1);
  --info: #1c5d8f;
  --info-tint: rgba(28, 93, 143, 0.1);

  --shadow-1: 0 1px 2px rgba(16, 20, 27, 0.05), 0 1px 3px rgba(16, 20, 27, 0.04);
  --shadow-2: 0 4px 14px rgba(16, 20, 27, 0.07), 0 1px 3px rgba(16, 20, 27, 0.05);
  --shadow-3: 0 18px 44px rgba(16, 20, 27, 0.13), 0 2px 8px rgba(16, 20, 27, 0.06);
  --shadow-brand: 0 8px 22px rgba(164, 21, 25, 0.22);

  --overlay: rgba(12, 15, 21, 0.55);
  --glass: rgba(255, 255, 255, 0.82);

  color-scheme: light;
}

/* ---------- Tema oscuro ---------- */
[data-theme='dark'] {
  --paper: #0a0c11;
  --paper-2: #0e1117;
  --surface: #12161e;
  --surface-2: #181d27;
  --surface-3: #212734;
  --surface-inv: #f0f2f6;

  --ink: #eef0f4;
  --body: #b6becc;
  --muted: #838c9c;
  --faint: #626b7b;

  --line: #232a37;
  --line-strong: #333c4d;
  --line-soft: #1b212b;

  --brand: #e8595e;
  --brand-hover: #f27b7f;
  --brand-tint: rgba(232, 89, 94, 0.13);
  --brand-tint-2: rgba(232, 89, 94, 0.2);
  --on-brand: #ffffff;

  --brass: #c9a35e;
  --brass-tint: rgba(201, 163, 94, 0.14);

  --ok: #3ec48d;
  --ok-tint: rgba(62, 196, 141, 0.13);
  --warn: #e0a63c;
  --warn-tint: rgba(224, 166, 60, 0.14);
  --danger: #f4676d;
  --danger-tint: rgba(244, 103, 109, 0.13);
  --info: #5aa9e0;
  --info-tint: rgba(90, 169, 224, 0.13);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 20px 50px rgba(0, 0, 0, 0.68);
  --shadow-brand: 0 8px 24px rgba(164, 21, 25, 0.4);

  --overlay: rgba(4, 6, 10, 0.74);
  --glass: rgba(18, 22, 30, 0.86);

  color-scheme: dark;
}

/* =====================================================================
   2. BASE
   ===================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.62;
  color: var(--body);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1, 'ss03' 1;
  transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: var(--ls-tight);
  margin: 0 0 var(--sp-3);
}

p { margin: 0 0 var(--sp-4); }

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.2s var(--ease-out);
}
a:hover { color: var(--brand-hover); }

img, svg, video, iframe { max-width: 100%; }
img { height: auto; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-5) 0;
  opacity: 1;
}

::selection {
  background: var(--brand-tint-2);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid var(--paper);
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* =====================================================================
   3. TIPOGRAFÍA DE APOYO
   ===================================================================== */

/* Etiqueta monoespaciada: el motivo que recorre todo el sitio */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--brand);
  flex: 0 0 auto;
}

.eyebrow--plain::before { display: none; }
.eyebrow--brand { color: var(--brand); }

/* Encabezado de sección: eyebrow + título + regla animada */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.section-head__text { min-width: 0; flex: 1 1 320px; }

.section-title {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 600;
  margin: var(--sp-2) 0 0;
  color: var(--ink);
}

.section-sub {
  color: var(--muted);
  font-size: var(--fs-small);
  margin: var(--sp-2) 0 0;
  max-width: 60ch;
}

.rule {
  height: 1px;
  background: var(--line);
  position: relative;
  margin: var(--sp-3) 0 0;
  transform-origin: left center;
}

.rule::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 1px;
  background: var(--brand);
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-display); }
.text-muted-2 { color: var(--muted) !important; }
.text-faint { color: var(--faint) !important; }
.text-brand { color: var(--brand) !important; }

.clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* =====================================================================
   4. BOTONES
   ===================================================================== */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--body);
  --btn-bd: var(--line-strong);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1;
  padding: 0.72rem 1.15rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out),
              color 0.2s var(--ease-out), transform 0.14s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.btn:active { transform: translateY(1px) scale(0.995); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; pointer-events: none; }

.btn i, .btn svg { font-size: 1.05em; }

.btn-brand {
  --btn-bg: var(--brand-solid);
  --btn-fg: #fff;
  --btn-bd: var(--brand-solid);
  box-shadow: var(--shadow-1);
}
.btn-brand:hover {
  --btn-bg: var(--brand-solid-700);
  --btn-bd: var(--brand-solid-700);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

/* Alias por compatibilidad con el marcado anterior */
.btn-accent { --btn-bg: var(--brand-solid); --btn-fg: #fff; --btn-bd: var(--brand-solid); }
.btn-accent:hover { --btn-bg: var(--brand-solid-700); color: #fff; }

.btn-outline { --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--line-strong); }
.btn-outline:hover { --btn-bg: var(--surface-2); --btn-bd: var(--muted); color: var(--ink); }

.btn-ghost { --btn-bd: transparent; --btn-fg: var(--muted); }
.btn-ghost:hover { --btn-bg: var(--surface-2); --btn-fg: var(--ink); }

.btn-soft { --btn-bg: var(--brand-tint); --btn-fg: var(--brand); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--brand-tint-2); color: var(--brand); }

.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger:hover { filter: brightness(1.08); color: #fff; }

.btn-danger-soft { --btn-bg: var(--danger-tint); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-danger-soft:hover { --btn-bg: var(--danger); --btn-fg: #fff; }

.btn-ok-soft { --btn-bg: var(--ok-tint); --btn-fg: var(--ok); --btn-bd: transparent; }
.btn-ok-soft:hover { --btn-bg: var(--ok); --btn-fg: #fff; }

.btn-sm { padding: 0.48rem 0.8rem; font-size: var(--fs-micro); border-radius: var(--r-xs); }
.btn-lg { padding: 0.95rem 1.6rem; font-size: var(--fs-body); border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-icon {
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  flex: 0 0 auto;
}
.btn-icon.btn-sm { width: 32px; height: 32px; }

/* Estado cargando */
.btn.is-loading { pointer-events: none; position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnspin 0.62s linear infinite;
  color: var(--btn-fg);
}
@keyframes btnspin { to { transform: rotate(360deg); } }

/* =====================================================================
   5. SUPERFICIES
   ===================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color 0.24s var(--ease-out), box-shadow 0.24s var(--ease-out),
              transform 0.24s var(--ease-out), background-color 0.3s var(--ease-out);
}

.card-pad { padding: var(--sp-5); }
.card-hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }

/* Alias del marcado anterior */
.card-soft {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

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

.panel__title {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.panel__sub {
  font-size: var(--fs-micro);
  color: var(--muted);
  margin: 3px 0 0;
  line-height: 1.5;
}

.panel__body { padding: var(--sp-5); }
.panel__foot {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* =====================================================================
   6. INSIGNIAS Y ETIQUETAS
   ===================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chip--brand { background: var(--brand-tint); color: var(--brand); border-color: transparent; }
.chip--ok { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.chip--warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.chip--danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.chip--info { background: var(--info-tint); color: var(--info); border-color: transparent; }
.chip--brass { background: var(--brass-tint); color: var(--brass); border-color: transparent; }
.chip--solid { background: var(--brand-solid); color: #fff; border-color: transparent; }

/* Insignias por plataforma */
.chip--youtube { background: rgba(255, 0, 0, 0.11); color: #d9232a; border-color: transparent; }
.chip--facebook { background: rgba(24, 119, 242, 0.12); color: #1877f2; border-color: transparent; }
.chip--instagram { background: rgba(214, 41, 118, 0.12); color: #d62976; border-color: transparent; }
.chip--tiktok { background: rgba(0, 0, 0, 0.08); color: var(--ink); border-color: transparent; }
[data-theme='dark'] .chip--tiktok { background: rgba(255, 255, 255, 0.1); color: #eef0f4; }
.chip--vimeo { background: rgba(26, 183, 234, 0.13); color: #1ab7ea; border-color: transparent; }

/* Punto de estado en vivo */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex: 0 0 auto;
  position: relative;
}
.live-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--danger);
  opacity: 0;
  animation: pulseRing 2s var(--ease-out) infinite;
}
.live-dot--off { background: var(--faint); }
.live-dot--off::after { display: none; }

@keyframes pulseRing {
  0% { transform: scale(0.7); opacity: 0.85; }
  75%, 100% { transform: scale(1.7); opacity: 0; }
}

/* =====================================================================
   7. FORMULARIOS
   ===================================================================== */

.field { margin-bottom: var(--sp-4); }

.label {
  display: block;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: 0.005em;
}

.label .req { color: var(--brand); margin-left: 2px; }

.hint {
  display: block;
  font-size: var(--fs-micro);
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.input,
.select,
.textarea,
input.form-control,
select.form-select,
textarea.form-control {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.66rem 0.85rem;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out),
              background-color 0.3s var(--ease-out);
  appearance: none;
}

.input::placeholder,
.textarea::placeholder,
.form-control::placeholder { color: var(--faint); }

.input:focus,
.select:focus,
.textarea:focus,
.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-tint);
  background: var(--surface);
  color: var(--ink);
}

.textarea { min-height: 120px; resize: vertical; }

.select,
select.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a7383' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
}

.input.is-invalid,
.textarea.is-invalid,
.select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3.5px var(--danger-tint);
}

.field-error {
  display: block;
  font-size: var(--fs-micro);
  color: var(--danger);
  margin-top: 5px;
  font-weight: 500;
}

/* Interruptor */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
  width: 42px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  position: relative;
  flex: 0 0 auto;
  transition: background-color 0.24s var(--ease-out), border-color 0.24s var(--ease-out);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform 0.26s var(--ease-out);
}

.switch input:checked + .switch__track {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
}
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3.5px var(--brand-tint); }

.switch__label { font-size: var(--fs-small); color: var(--body); font-weight: 500; }

/* Casilla */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-small);
  color: var(--body);
}

.check input[type='checkbox'] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  flex: 0 0 auto;
  margin-top: 2px;
  cursor: pointer;
  transition: background-color 0.16s, border-color 0.16s;
  position: relative;
}

.check input[type='checkbox']:checked {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
}

.check input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check input[type='checkbox']:focus-visible { box-shadow: 0 0 0 3.5px var(--brand-tint); }

/* Grid de formulario */
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(12, 1fr); }
.form-grid > * { grid-column: span 12; }
.col-6 { grid-column: span 6 !important; }
.col-4 { grid-column: span 4 !important; }
.col-8 { grid-column: span 8 !important; }
.col-3 { grid-column: span 3 !important; }

@media (max-width: 720px) {
  .col-6, .col-4, .col-8, .col-3 { grid-column: span 12 !important; }
}

/* =====================================================================
   8. TABLAS
   ===================================================================== */

.tbl-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-small);
}

.tbl thead th {
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tbl tbody td {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  color: var(--body);
  vertical-align: middle;
}

.tbl tbody tr { transition: background-color 0.15s var(--ease-out); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.is-removing { background: var(--danger-tint); }

.tbl .td-title {
  font-weight: 600;
  color: var(--ink);
  max-width: 380px;
}

.tbl .td-actions { text-align: right; white-space: nowrap; }
.tbl .td-actions .btn + .btn { margin-left: 5px; }

.tbl-empty {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--muted);
}

.tbl-empty__icon {
  font-size: 2.2rem;
  color: var(--faint);
  margin-bottom: var(--sp-3);
  display: block;
}

/* =====================================================================
   9. PAGINACIÓN
   ===================================================================== */

.pager {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.pager__link {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--body);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  transition: all 0.18s var(--ease-out);
}

.pager__link:hover { border-color: var(--brand); color: var(--brand); }

.pager__link.is-active {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
  color: #fff;
}

.pager__link.is-disabled { opacity: 0.4; pointer-events: none; }
.pager__gap { color: var(--faint); padding: 0 4px; }

/* =====================================================================
   10. AVATAR
   ===================================================================== */

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
  color: #fff;
  background: var(--brand-solid);
  flex: 0 0 auto;
  overflow: hidden;
  letter-spacing: 0.02em;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 30px; height: 30px; font-size: 0.65rem; }
.avatar--lg { width: 60px; height: 60px; font-size: 1.05rem; }

/* =====================================================================
   11. RELACIÓN DE ASPECTO / MEDIOS
   ===================================================================== */

.ratio { position: relative; width: 100%; background: var(--surface-2); overflow: hidden; }
.ratio::before { content: ''; display: block; }
.ratio--16x9::before { padding-top: 56.25%; }
.ratio--9x16::before { padding-top: 177.78%; }
.ratio--4x3::before { padding-top: 75%; }
.ratio--1x1::before { padding-top: 100%; }

.ratio > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.ratio > img { object-fit: cover; }

/* =====================================================================
   12. CAMBIO DE TEMA
   ===================================================================== */

.theme-toggle {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); }

.theme-toggle__icon {
  position: absolute;
  font-size: 1.05rem;
  line-height: 1;
  display: block;
}

.theme-toggle__icon--moon { opacity: 0; transform: rotate(-70deg) scale(0.4); }
[data-theme='dark'] .theme-toggle__icon--sun { opacity: 0; transform: rotate(70deg) scale(0.4); }
[data-theme='dark'] .theme-toggle__icon--moon { opacity: 1; transform: none; }

.theme-toggle__icon { transition: opacity 0.34s var(--ease-out), transform 0.44s var(--ease-out); }

/* =====================================================================
   13. ALERTAS GSAP (reemplazan a SweetAlert)
   ===================================================================== */

#isef-toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  width: min(388px, calc(100vw - 40px));
  pointer-events: none;
}

.isef-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  will-change: transform, opacity;
}

.isef-toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brand);
}

.isef-toast--success::before { background: var(--ok); }
.isef-toast--error::before { background: var(--danger); }
.isef-toast--warning::before { background: var(--warn); }
.isef-toast--info::before { background: var(--info); }

.isef-toast__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1rem;
  background: var(--brand-tint);
  color: var(--brand);
}

.isef-toast--success .isef-toast__icon { background: var(--ok-tint); color: var(--ok); }
.isef-toast--error .isef-toast__icon { background: var(--danger-tint); color: var(--danger); }
.isef-toast--warning .isef-toast__icon { background: var(--warn-tint); color: var(--warn); }
.isef-toast--info .isef-toast__icon { background: var(--info-tint); color: var(--info); }

.isef-toast__body { flex: 1 1 auto; min-width: 0; }

.isef-toast__title {
  font-weight: 600;
  color: var(--ink);
  font-size: var(--fs-small);
  line-height: 1.3;
}

.isef-toast__text {
  color: var(--muted);
  font-size: var(--fs-micro);
  line-height: 1.5;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.isef-toast__close {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: var(--r-xs);
  flex: 0 0 auto;
  transition: color 0.16s, background-color 0.16s;
}
.isef-toast__close:hover { color: var(--ink); background: var(--surface-2); }

.isef-toast__bar {
  position: absolute;
  left: 3px;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--brand);
  opacity: 0.35;
  transform-origin: left center;
}
.isef-toast--success .isef-toast__bar { background: var(--ok); }
.isef-toast--error .isef-toast__bar { background: var(--danger); }
.isef-toast--warning .isef-toast__bar { background: var(--warn); }
.isef-toast--info .isef-toast__bar { background: var(--info); }

/* Diálogo modal */
.isef-dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 4100;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
}

.isef-dialog {
  width: min(452px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--sp-6);
  text-align: center;
  will-change: transform, opacity;
}

.isef-dialog__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto var(--sp-4);
  font-size: 1.6rem;
  background: var(--brand-tint);
  color: var(--brand);
}

.isef-dialog--success .isef-dialog__icon { background: var(--ok-tint); color: var(--ok); }
.isef-dialog--error .isef-dialog__icon { background: var(--danger-tint); color: var(--danger); }
.isef-dialog--warning .isef-dialog__icon { background: var(--warn-tint); color: var(--warn); }
.isef-dialog--question .isef-dialog__icon { background: var(--info-tint); color: var(--info); }

.isef-dialog__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 var(--sp-2);
  line-height: 1.2;
}

.isef-dialog__text {
  color: var(--muted);
  font-size: var(--fs-small);
  margin: 0 0 var(--sp-5);
  line-height: 1.6;
}

.isef-dialog__input { margin-bottom: var(--sp-5); text-align: left; }

.isef-dialog__actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  flex-wrap: wrap;
}

.isef-dialog__actions .btn { min-width: 116px; }

/* Cargando en pantalla completa */
.isef-loader-scrim {
  position: fixed;
  inset: 0;
  z-index: 4200;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  opacity: 0;
}

.isef-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  color: #fff;
}

.isef-loader__mark { display: flex; gap: 5px; }

.isef-loader__bar {
  width: 4px;
  height: 26px;
  background: var(--brand-solid);
  border-radius: 2px;
}

.isef-loader__text {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

/* =====================================================================
   14. UTILIDADES
   ===================================================================== */

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.row-flex { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

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

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* Estado inicial de las animaciones GSAP (se limpia al animar) */
.reveal { opacity: 0; }
.no-js .reveal { opacity: 1; }

/* =====================================================================
   15. MOVIMIENTO REDUCIDO
   ===================================================================== */

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

/* =====================================================================
   16. IMPRESIÓN
   ===================================================================== */

@media print {
  .site-nav, .site-footer, .theme-toggle, .btn, #isef-toasts, .player-scrim { display: none !important; }
  body { background: #fff; color: #000; }
}

/* =====================================================================
   17. REPRODUCTOR
   ===================================================================== */

.player-scrim {
  position: fixed;
  inset: 0;
  z-index: 3800;
  background: rgba(6, 8, 12, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
  opacity: 0;
}

.player-scrim.is-open { display: grid; }

.player {
  position: relative;
  /* El ancho sale de la altura disponible: así el marco 16:9 más la barra
     de información caben SIEMPRE en pantalla y el video se ve lo más
     grande posible, sin franjas negras arriba y abajo. */
  width: min(1240px, 100%, calc((92vh - 132px) * 16 / 9));
  max-height: 94vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
}

/* Los verticales (TikTok, reels, shorts) piden un marco angosto y alto */
.player.is-vertical {
  width: min(460px, 100%, calc((90vh - 132px) * 9 / 16));
}

.player__stage {
  background: #000;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden;
  flex: 0 0 auto;
}

.player__stage.ratio--9x16 { border-radius: var(--r-lg) var(--r-lg) 0 0; }

.player__info { flex: 1 1 auto; overflow-y: auto; }

.player__info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-5);
  padding: var(--sp-5);
  flex-wrap: wrap;
}

.player__info-main { flex: 1 1 320px; min-width: 0; }

.player__title {
  font-size: 1.28rem;
  margin: 0 0 var(--sp-3);
  color: var(--ink);
  line-height: 1.22;
}

.player__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.player__date,
.player__pos {
  font-size: var(--fs-micro);
  color: var(--muted);
  letter-spacing: 0.04em;
}

.player__pos {
  padding: 3px 8px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
}

.player__desc {
  margin: var(--sp-3) 0 0;
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 1.6;
}

.player__nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.player__nav .btn:disabled { opacity: 0.32; pointer-events: none; }

.player__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: rgba(10, 12, 17, 0.62);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  backdrop-filter: blur(6px);
  transition: background-color 0.2s, transform 0.2s;
}

.player__close:hover { background: var(--brand-solid); transform: rotate(90deg); }

/* --- Reproductor propio (MP4) --- */

.vp { position: relative; width: 100%; height: 100%; background: #000; }
.vp--embed { display: block; }
.vp--embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.vp__video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }

.vp__big {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 0;
  background: rgba(164, 21, 25, 0.94);
  color: #fff;
  font-size: 2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.24s var(--ease-out), opacity 0.24s;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42);
}

.vp__big:hover { transform: scale(1.08); }
.vp.is-playing .vp__big { opacity: 0; pointer-events: none; transform: scale(0.7); }

.vp__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 14px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.86), transparent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.24s var(--ease-out), transform 0.24s var(--ease-out);
}

.vp:hover .vp__controls,
.vp:focus-within .vp__controls,
.vp:not(.is-playing) .vp__controls { opacity: 1; transform: none; }

.vp__btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: var(--r-xs);
  flex: 0 0 auto;
  transition: background-color 0.16s, transform 0.16s;
}

.vp__btn:hover { background: rgba(255, 255, 255, 0.16); }
.vp__btn--rate { width: auto; padding: 0 9px; font-size: var(--fs-micro); font-weight: 600; }

.vp__seek {
  flex: 1 1 auto;
  height: 16px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.vp__seek::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 2px;
}

.vp__seek-buffer,
.vp__seek-fill {
  position: absolute;
  left: 0;
  height: 3px;
  border-radius: 2px;
  width: 0;
}

.vp__seek-buffer { background: rgba(255, 255, 255, 0.34); }
.vp__seek-fill { background: var(--brand-solid); }

.vp__seek-head {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  left: 0;
  transform: translateX(-50%) scale(0);
  transition: transform 0.18s var(--ease-out);
}

.vp__seek:hover .vp__seek-head,
.vp__seek:focus-visible .vp__seek-head { transform: translateX(-50%) scale(1); }

.vp__time {
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--fs-micro);
  white-space: nowrap;
  flex: 0 0 auto;
}

.vp__vol {
  width: 74px;
  accent-color: var(--brand-solid);
  flex: 0 0 auto;
  height: 3px;
}

@media (max-width: 560px) {
  .vp__vol, .vp__btn--rate { display: none; }
  .player__info { padding: var(--sp-4); }
  .player__title { font-size: 1.08rem; }
}

/* =====================================================================
   AVISOS EN LÍNEA
   Reemplazan al antiguo .login-error reutilizado para todo.
   ===================================================================== */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  border-left-width: 3px;
  background: var(--surface);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--body);
  flex-wrap: wrap;
}

.notice strong { color: var(--ink); }
.notice__icon { font-size: 1.1rem; margin-top: 1px; flex: 0 0 auto; }
.notice code { font-family: var(--font-mono); font-size: 0.86em; }

.notice--warn { background: var(--warn-tint); border-left-color: var(--warn); }
.notice--warn .notice__icon, .notice--warn strong { color: var(--warn); }

.notice--danger { background: var(--danger-tint); border-left-color: var(--danger); }
.notice--danger .notice__icon, .notice--danger strong { color: var(--danger); }

.notice--ok { background: var(--ok-tint); border-left-color: var(--ok); }
.notice--ok .notice__icon, .notice--ok strong { color: var(--ok); }

.notice--info { background: var(--info-tint); border-left-color: var(--info); }
.notice--info .notice__icon, .notice--info strong { color: var(--info); }

/* =====================================================================
   CORRECCIÓN DEL REPRODUCTOR
   `.vp` traía `position: relative` con la misma especificidad que
   `.ratio > *` y, al ir después en el archivo, ganaba. El iframe salía
   del marco 16:9 y quedaba en su alto por defecto (150 px): el video se
   veía como una franja diminuta bajo un rectángulo negro enorme.
   ===================================================================== */

.ratio > .vp {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
