/* REVELO platform UI — brand palette: deep purple #5B21B6, violet #7C3AED,
   amber #F59E0B, midnight #14102B, ink #1F2937. */

:root {
  color-scheme: light;
  accent-color: #7C3AED;

  /* Brand colors (invariant) */
  --purple-deep: #5B21B6;
  --purple-violet: #7C3AED;
  --amber: #F59E0B;
  --midnight: #14102B;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Shadow system */
  --shadow-xs: 0 1px 2px rgba(31, 41, 55, 0.04);
  --shadow-sm: 0 2px 4px rgba(31, 41, 55, 0.06);
  --shadow-md: 0 4px 8px rgba(31, 41, 55, 0.08);
  --shadow-lg: 0 8px 16px rgba(31, 41, 55, 0.12);
  --shadow-xl: 0 16px 32px rgba(31, 41, 55, 0.16);
  --shadow-focus: 0 0 0 3px rgba(124, 58, 237, 0.2);

  /* Theme colors (light mode) */
  --bg-main: #F6F5FA;
  --bg-card: #fff;
  --bg-hover: #F3F0FF;
  --bg-input: #fff;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --border-primary: #ECEAF3;
  --border-secondary: #E2E0EC;
  --header-bg: rgba(255, 255, 255, 0.95);
  --header-border: rgba(31, 41, 55, 0.08);
  --selection-bg: #F59E0B;
  --selection-text: #1F2937;
  --shadow-card: var(--shadow-md);
  --shadow-hover: rgba(91, 33, 182, 0.1);
  --badge-pending-bg: #F3F4F6;
  --badge-pending-text: #4B5563;
  --dropzone-bg: #FAF8FF;
  --dropzone-border: #C4B5FD;
  --segment-hover: #FAF9FD;
  --focus-ring: var(--shadow-focus);

  /* Semantic text colors readable on the page/card background of each theme */
  --brand-text: #5B21B6;
  --success-text: #059669;
  --warning-text: #B45309;
  --danger-text: #DC2626;
}

[data-theme="dark"] {
  color-scheme: dark;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.7);
  --shadow-focus: 0 0 0 3px rgba(124, 58, 237, 0.4);

  --bg-main: #0F0E14;
  --bg-card: #1A1825;
  --bg-hover: #2A2438;
  --bg-input: #1A1825;
  --text-primary: #F3F1F9;
  --text-secondary: #C4BFDB;
  --text-tertiary: #978FB0;
  --border-primary: #2D2841;
  --border-secondary: #3A3450;
  --header-bg: rgba(26, 24, 37, 0.95);
  --header-border: rgba(233, 228, 248, 0.1);
  --selection-bg: #F59E0B;
  --selection-text: #0F0E14;
  --shadow-card: var(--shadow-md);
  --shadow-hover: rgba(124, 58, 237, 0.2);
  --badge-pending-bg: #2A2438;
  --badge-pending-text: #C4BFDB;
  --dropzone-bg: #1F1D2C;
  --dropzone-border: #5B21B6;
  --segment-hover: #1F1D2C;
  --focus-ring: var(--shadow-focus);

  --brand-text: #A78BFA;
  --success-text: #34D399;
  --warning-text: #FBBF24;
  --danger-text: #F87171;
}

* {
  box-sizing: border-box;
}
*:focus {
  outline: none;
}
*:focus-visible {
  outline: 2px solid var(--purple-violet);
  outline-offset: 2px;
  border-radius: 4px;
}

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

body {
  margin: 0;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .3s ease, color .3s ease;
  line-height: 1.6;
  /* Real-world data: never let a long unbroken string (filename, URL) blow up the layout */
  overflow-wrap: break-word;
}
a {
  color: inherit;
  text-decoration: none;
  transition: opacity .2s ease;
}
a:hover {
  opacity: 0.85;
}
::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}
mark {
  background: #FDE68A;
  color: #1F2937; /* explicit: inherited light text would vanish on the amber highlight in dark mode */
  border-radius: 3px;
}

.font-display { font-family: "Sora", sans-serif; }
.mono { font-family: "JetBrains Mono", monospace; }

/* ---------- Top bar ---------- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--header-border);
}
.app-header-inner {
  max-width: 1160px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 18px;
}
.app-logo { display: inline-flex; align-items: center; }
/* El wordmark del landing, COPIADO tal cual (D-109): la misma pastilla
   translúcida con desenfoque, y los mismos valores en claro y en oscuro
   (.hpill + .brand + .wordmark del home). Una sola marca significa una
   sola: sin versiones. */
.app-wordmark {
  display: inline-flex; align-items: center; gap: .08em;
  font-family: "Sora", sans-serif; font-weight: 800; font-size: 16px;
  letter-spacing: .01em; color: #1A1330;
  background: rgba(255, 255, 255, .82); border: 1px solid rgba(26, 19, 48, .1);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 999px; padding: 9px 16px 9px 13px;
}
[data-theme="dark"] .app-wordmark {
  color: #F4F1FC;
  background: rgba(8, 5, 18, .7); border-color: rgba(255, 255, 255, .08);
}
.wm-e { display: inline-flex; flex-direction: column; gap: .14em; width: .72em; }
.wm-e i { height: .16em; border-radius: 2px; background: linear-gradient(90deg, #7C3AED, #F5A524); }
.wm-e i:nth-child(2) { width: 78%; }
/* Nav sits at the right, next to the avatar (logo alone at the left) */
.app-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.app-nav a {
  font-size: 14.5px; font-weight: 600; color: var(--text-secondary);
  padding: 8px 13px; border-radius: 10px; transition: background .2s, color .2s;
}
.app-nav a:hover { background: var(--bg-hover); color: var(--brand-text); }
.app-nav a.is-active { background: var(--bg-hover); color: var(--brand-text); }
.app-header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
/* When the nav is present it owns the auto margin — avatar stays glued to it */
.app-header-inner:has(.app-nav) .app-header-right { margin-left: 0; }
/* El plan del usuario, siempre a la vista (D-136). Discreto: informa sin
   competir con la navegación, y lleva a la página de planes de un toque. */
.plan-chip {
  font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
  color: var(--brand-text); background: var(--bg-hover);
  border: 1px solid var(--border-soft, rgba(124, 58, 237, .22));
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
  transition: background .2s, transform .2s;
}
.plan-chip:hover { background: var(--bg-active, var(--bg-hover)); transform: translateY(-1px); }
.plan-chip:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.app-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-family: "Sora", sans-serif; font-weight: 700; font-size: 13px;
}
.app-user-email { font-size: 13.5px; color: var(--text-secondary); }

/* Compact theme toggle inside the header (always visible with the menu) */
.theme-toggle {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1), border-color .2s ease;
}
.theme-toggle:hover {
  transform: scale(1.08) rotate(15deg);
  border-color: var(--purple-violet);
}
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle:focus-visible { box-shadow: var(--focus-ring); }

/* Mobile header: ONE clean sticky row — icon logo, scrollable nav,
   theme toggle and avatar. Never wraps, never overflows. */
@media (max-width: 720px) {
  .app-header-inner {
    padding: 8px 14px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .app-wordmark { font-size: 14px; padding: 7px 12px 7px 10px; }
  .app-nav {
    flex: 1;
    min-width: 0;
    margin-left: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav a {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 13.5px;
    padding: 7px 10px;
  }
  .app-header-right { margin-left: 0; gap: 8px; flex-shrink: 0; }
  /* En móvil la cabecera va justa: el plan vive en el menú del avatar,
     donde también está y con más contexto. */
  .plan-chip { display: none; }
  .tabs { top: 53px; } /* below the one-row mobile header */
}

/* ---------- User menu (avatar dropdown) ---------- */
.user-menu { position: relative; }
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 999px;
  transition: background .2s ease, box-shadow .2s ease;
}
.user-menu-btn:hover { background: var(--bg-hover); }
.user-menu-btn:focus-visible { box-shadow: var(--focus-ring); }
.user-menu-btn .app-avatar { transition: transform .2s ease; }
.user-menu-btn:hover .app-avatar { transform: scale(1.06); }
.user-menu-caret {
  font-size: 11px;
  color: var(--text-tertiary);
  transition: transform .2s ease;
}
.user-menu-btn[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  padding: 8px;
  z-index: 200;
  animation: dropdown-in .18s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top right;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: scale(0.96) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.dropdown-header-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dropdown-user-name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.dropdown-user-email {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-divider { height: 1px; background: var(--border-primary); margin: 6px 4px; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 9px;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--brand-text); opacity: 1; }
.dropdown-item:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.dropdown-item-danger { color: var(--danger-text); }
.dropdown-item-danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger-text); }
.dropdown form { margin: 0; }

/* Theme toggle FAB: fixed bottom-right, HIGH CONTRAST per mode —
   in light mode it's a midnight button (a "switch to dark" hint),
   in dark mode it's a bright amber button (a "switch to light" hint). */
.theme-fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 1200; /* above content, below modals (2500) and lightbox (3000) */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #14102B, #3B1378);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow .3s ease;
  box-shadow: 0 10px 26px rgba(20, 16, 43, 0.45);
}
[data-theme="dark"] .theme-fab {
  background: linear-gradient(135deg, #F59E0B, #FBBF24);
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.4);
}
.theme-fab:hover {
  transform: scale(1.08) rotate(15deg);
}
.theme-fab:active {
  transform: scale(0.94) rotate(-15deg);
}
.theme-fab:focus-visible {
  box-shadow: var(--focus-ring);
}
/* Back-to-top FAB: appears after scrolling, fixed bottom-LEFT */
.top-fab {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  color: #fff;
  font-size: 19px;
  box-shadow: 0 10px 26px rgba(91, 33, 182, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease, visibility .3s ease;
}
.top-fab.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.top-fab:hover { transform: translateY(-2px); }
.top-fab:focus-visible { box-shadow: var(--focus-ring); }

@media print {
  .theme-fab, .top-fab { display: none !important; }
}

@media (max-width: 720px) { .app-user-email { display: none; } }

/* ---------- Layout ---------- */
/* Un solo ancho de contenido (D-110): .app-main es el único marco, el
   mismo 1160px de la cabecera. Ninguna plantilla se pone su propio
   max-width encima; si a una página le sobra ancho, lo rellena con
   columnas (.page-cols-2 o una rejilla propia), no encogiéndose. */
.app-main { max-width: 1160px; margin: 0 auto; padding: 34px 24px 80px; }
.page-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .page-cols-2 { grid-template-columns: 1fr; } }
.page-title { font-family: "Sora", sans-serif; font-weight: 800; font-size: 30px; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
.page-subtitle { color: var(--text-secondary); font-size: 15.5px; margin: 6px 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 15px;
  transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow .2s cubic-bezier(0.4, 0, 0.2, 1),
              background .2s ease,
              opacity .2s ease;
  position: relative;
  outline: none;
}
.btn:focus-visible {
  box-shadow: var(--focus-ring);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}
.btn.is-loading {
  pointer-events: none;
  opacity: 0.8;
}
.btn.is-loading::before {
  content: '';
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--purple-deep), var(--amber));
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-outline {
  background: var(--bg-card);
  color: var(--brand-text);
  border: 2px solid var(--brand-text);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--bg-card);
  color: var(--danger-text);
  border: 1.5px solid rgba(239, 68, 68, 0.35);
  box-shadow: var(--shadow-xs);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.55);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--bg-card);
  color: var(--warning-text);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  box-shadow: var(--shadow-xs);
}
.btn-warning:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.6);
  transform: translateY(-1px);
}

.btn-small { padding: 7px 13px; font-size: 13.5px; border-radius: 9px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .3s cubic-bezier(0.4, 0, 0.2, 1),
              transform .3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color .3s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
}
.stat-value {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: 32px;
  color: var(--purple-deep);
  line-height: 1;
  background: linear-gradient(135deg, var(--brand-text), var(--purple-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label {
  font-size: 13.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ---------- Status badges ----------
   Copiadas del prototipo aprobado de «Mis análisis» (D-111): mono en
   mayúsculas sobre fondo teñido del mismo color, nada de rellenos
   sólidos ni degradados. Un solo estilo de estado en toda la casa. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-pending {
  color: var(--text-tertiary);
  background: color-mix(in srgb, var(--text-tertiary) 12%, transparent);
}
.badge-processing {
  color: var(--brand-text);
  background: color-mix(in srgb, var(--purple-violet) 14%, transparent);
}
.badge-completed {
  color: var(--success-text);
  background: color-mix(in srgb, var(--success-text) 12%, transparent);
}
.badge-failed {
  color: var(--danger-text);
  background: color-mix(in srgb, var(--danger-text) 12%, transparent);
}
.badge-demo {
  color: var(--brand-text);
  background: color-mix(in srgb, var(--purple-violet) 14%, transparent);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-smooth 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  box-shadow: 0 0 4px currentColor;
}
@keyframes pulse-smooth {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* ---------- Upload table ---------- */
.upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}
.upload-row:hover {
  border-color: var(--purple-violet);
  box-shadow: 0 8px 24px var(--shadow-hover);
  transform: translateY(-2px);
  background-image: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(91, 33, 182, 0.02));
}
.upload-row:active {
  transform: translateY(0);
}
/* Media slot: SAME footprint for every row (video cover, audio, no cover) */
.upload-thumb {
  width: 92px;
  height: 58px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background: #14102B;
}
.upload-icon {
  width: 92px;
  height: 58px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform .3s ease;
}
.upload-row:hover .upload-icon {
  transform: scale(1.05) rotate(-2deg);
}
/* Audio sin portada: carátula por defecto (lupa dorada sobre cuarto oscuro) */
.upload-cover {
  width: 92px;
  height: 58px;
  border-radius: 10px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 140% at 20% 0%, rgba(124, 58, 237, 0.32), transparent 55%),
    linear-gradient(150deg, #1D1537, #0E0B1C);
  border: 1px solid rgba(124, 58, 237, 0.28);
}
.upload-cover .uc-ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--amber);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4), inset 0 0 6px rgba(245, 158, 11, 0.18);
  position: relative;
  margin-bottom: 8px;
}
.upload-cover .uc-ring::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FCD34D, #F59E0B);
}
.upload-cover .uc-bars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 3px;
  height: 10px;
}
.upload-cover .uc-bars i {
  width: 2px;
  border-radius: 99px;
  background: rgba(196, 181, 253, 0.75);
}
.upload-cover .uc-bars i:nth-child(1) { height: 40%; }
.upload-cover .uc-bars i:nth-child(2) { height: 75%; }
.upload-cover .uc-bars i:nth-child(3) { height: 55%; }
.upload-cover .uc-bars i:nth-child(4) { height: 100%; }
.upload-cover .uc-bars i:nth-child(5) { height: 60%; }
.upload-cover .uc-bars i:nth-child(6) { height: 85%; }
.upload-cover .uc-bars i:nth-child(7) { height: 45%; }

/* Mini-onda de la fila: barras finas, ámbar solo en momentos clave */
.upload-wave {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  margin-top: 7px;
}
.upload-wave i {
  width: 2px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--purple-violet) 72%, transparent);
  min-height: 2px;
}
.upload-wave i.rest { background: var(--border-secondary); }
.upload-wave i.key {
  width: 3px;
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.55);
}
.upload-wave[data-state="failed"] i,
.upload-wave[data-state="pending"] i {
  background: var(--border-secondary);
  box-shadow: none;
  opacity: 0.6;
}
.upload-content { flex: 1; min-width: 0; }

/* Mobile rows: grid so the title spans the FULL width next to the thumb,
   with the status badge on its own line below (no more half-cut titles). */
@media (max-width: 640px) {
  .upload-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px 14px;
    padding: 14px 16px;
  }
  .upload-row .badge {
    grid-column: 2;
    justify-self: start;
  }
  .upload-thumb, .upload-icon, .upload-cover { width: 100px; height: 62px; }
}
.upload-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Progress ---------- */
.progress-track {
  height: 10px;
  border-radius: 99px;
  background: var(--bg-hover);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--purple-deep), var(--purple-violet), var(--amber));
  background-size: 200% 100%;
  transition: width .6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  animation: progress-shimmer 2s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}
@keyframes progress-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.step-list li { display: flex; align-items: center; gap: 11px; font-size: 14.5px; color: var(--text-secondary); }
.step-list li.is-done { color: var(--success-text); }
.step-list li.is-current { color: var(--warning-text); font-weight: 600; }
.step-icon { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: var(--badge-pending-bg); flex-shrink: 0; }
.is-done .step-icon { background: #D1FAE5; color: #065F46; }
.is-current .step-icon { background: #FEF3C7; color: #92400E; }

/* ---------- Transcript ---------- */
.segment { display: flex; gap: 14px; padding: 10px 12px; border-radius: 12px; }
.segment:hover { background: var(--segment-hover); }
.segment-time { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; padding-top: 3px; width: 52px; }
.segment-body { font-size: 15px; line-height: 1.6; }
.speaker-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-bottom: 4px;
}
.speaker-0 { background: #EDE9FE; color: #5B21B6; }
.speaker-1 { background: #FEF3C7; color: #92400E; }
.speaker-2 { background: #D1FAE5; color: #065F46; }
.speaker-3 { background: #DBEAFE; color: #1E40AF; }
.speaker-4 { background: #FCE7F3; color: #9D174D; }
.speaker-5 { background: #FFEDD5; color: #9A3412; }

/* ---------- Key moments ---------- */
.moment-card { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.moment-card img { width: 100%; border-radius: 12px; border: 1px solid var(--border-primary); display: block; }
@media (max-width: 760px) { .moment-card { grid-template-columns: 1fr; } }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border-primary);
  margin-bottom: 22px;
  flex-wrap: wrap;
  /* Stay visible below the sticky app header while scrolling long panels */
  position: sticky;
  top: 61px;
  z-index: 90;
  background: var(--bg-main);
  padding-top: 6px;
}
@media (max-width: 720px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }
}
.tab {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-secondary);
  padding: 12px 18px;
  border-radius: 10px 10px 0 0;
  margin-bottom: -2px;
  position: relative;
  transition: all .2s ease;
  outline: none;
}
.tab:hover:not(.is-active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tab.is-active {
  color: var(--brand-text);
  background: var(--bg-hover);
}
.tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--purple-deep), var(--amber));
  border-radius: 99px 99px 0 0;
}
.tab:focus-visible {
  box-shadow: var(--focus-ring);
}
.tab-panel {
  display: none;
  animation: tab-fade-in .3s ease;
}
.tab-panel.is-active {
  display: block;
}
@keyframes tab-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Forms ---------- */
.form-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.form-field label {
  font-weight: 700; font-size: 14px;
  transition: color .2s ease;
}
.form-field:focus-within label {
  color: var(--purple-violet);
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="search"],
.form-field select,
.form-field textarea {
  width: 100%; min-width: 0; /* selects have intrinsic width and overflow grids on mobile otherwise */
  font-family: inherit; font-size: 15px; padding: 12px 14px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 11px;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color .2s ease,
              box-shadow .2s ease,
              background .2s ease;
  outline: none;
}
.form-field input:hover:not(:focus),
.form-field select:hover:not(:focus),
.form-field textarea:hover:not(:focus) {
  border-color: var(--border-primary);
  background: var(--bg-card);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--purple-violet);
  box-shadow: var(--focus-ring);
  background: var(--bg-card);
}
.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-main);
}
.form-help {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.form-errors {
  color: var(--danger-text);
  font-size: 13.5px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.dropzone {
  border: 2px dashed var(--dropzone-border);
  border-radius: 16px;
  background: var(--dropzone-bg);
  padding: 42px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.dropzone::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet), var(--amber));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .3s ease;
}
.dropzone.is-dragover,
.dropzone:hover {
  border-color: transparent;
  background: var(--bg-hover);
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}
.dropzone.is-dragover::before,
.dropzone:hover::before {
  opacity: 1;
}
.dropzone.is-dragover {
  transform: scale(1.02);
}
.dropzone input[type="file"] { display: none; }

/* ---------- Messages ---------- */
.messages { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.message { padding: 13px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 600; }
.message-success { background: #D1FAE5; color: #065F46; }
.message-info { background: #DBEAFE; color: #1E40AF; }
.message-warning { background: #FEF3C7; color: #92400E; }
.message-error { background: #FEE2E2; color: #991B1B; }

/* ---------- Misc ---------- */
.empty-state {
  text-align: center;
  padding: 80px 32px;
  color: var(--text-secondary);
  animation: fade-in .6s ease;
}
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.empty-state > * {
  animation: fade-in-up .6s ease backwards;
}
.empty-state > *:nth-child(1) { animation-delay: 0.1s; }
.empty-state > *:nth-child(2) { animation-delay: 0.2s; }
.empty-state > *:nth-child(3) { animation-delay: 0.3s; }
.empty-state > *:nth-child(4) { animation-delay: 0.4s; }
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.demo-banner {
  background: linear-gradient(90deg, #3B1378, #5B21B6 45%, #7C3AED);
  color: #fff; border-radius: 14px; padding: 16px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-bottom: 26px;
}
.log-line { display: flex; gap: 10px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid var(--border-primary); }
.log-line:last-child { border-bottom: none; }
.log-step { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--purple-violet); min-width: 105px; }
.log-warning { color: var(--warning-text); }
.log-error { color: var(--danger-text); }

/* ---------- Lightbox (frame zoom) ---------- */
.frame-zoom {
  position: relative; display: block; width: 100%;
  padding: 0; border: none; background: none; cursor: zoom-in; border-radius: 12px;
}
.frame-zoom img { width: 100%; border-radius: 12px; border: 1px solid var(--border-primary); display: block; transition: transform .2s; }
.frame-zoom:hover img { transform: scale(1.015); }
.frame-zoom-hint {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(20, 16, 43, 0.82); color: #FBBF24;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 8px;
  opacity: 0; transition: opacity .2s;
}
.frame-zoom:hover .frame-zoom-hint { opacity: 1; }

.lightbox {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(10, 7, 25, 0.92);
  display: flex; align-items: center; justify-content: center; padding: 30px;
  cursor: zoom-out;
}
.lightbox figure { margin: 0; max-width: min(1200px, 94vw); cursor: default; }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 14px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); display: block; }
.lightbox figcaption { color: #E9E4F8; font-size: 14.5px; text-align: center; margin-top: 14px; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 17px;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.24); }

/* Seek buttons */
.seek-btn { cursor: pointer; }
button.segment-time {
  background: none; border: none; padding: 3px 0 0; text-align: left;
  color: var(--purple-violet); text-decoration: underline dotted; text-underline-offset: 3px;
}
button.segment-time:hover { color: var(--brand-text); }

/* ---------- Capability chips (upload page) ---------- */
.capability-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.capability-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 700; padding: 7px 13px; border-radius: 999px;
}
.capability-on { background: #D1FAE5; color: #065F46; }
.capability-off { background: #FEE2E2; color: #991B1B; }

.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 600px at 50% -10%, var(--purple-violet) 0%, var(--purple-deep) 45%, #3B1378 100%);
  padding: 40px 20px;
}

[data-theme="dark"] .auth-shell {
  background: radial-gradient(1100px 600px at 50% -10%, #2D1B69 0%, #1E1340 45%, var(--midnight) 100%);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  width: 100%;
  pointer-events: none;
}
@media (max-width: 640px) {
  .toast-container {
    left: 16px;
    right: 16px;
    top: 70px;
    max-width: none;
    width: auto; /* width:100% + left/right would overflow the viewport */
  }
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  animation: toast-in .4s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform .2s ease, opacity .2s ease;
}
.toast.is-leaving {
  animation: toast-out .3s cubic-bezier(0.4, 0, 1, 1) forwards;
}
.toast::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  transform-origin: left;
  animation: toast-progress 5s linear forwards;
}
.toast.is-paused::before {
  animation-play-state: paused;
}

@keyframes toast-in {
  from {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes toast-out {
  to {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
  }
}
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.toast-content {
  flex: 1;
  min-width: 0;
}
.toast-title {
  font-weight: 700;
  font-size: 14.5px;
  margin: 0 0 2px;
  color: var(--text-primary);
}
.toast-message {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  border-radius: 6px;
  transition: background .2s ease, color .2s ease;
  flex-shrink: 0;
}
.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toast-success {
  border-left: 3px solid #10B981;
  color: #10B981;
}
.toast-success .toast-icon {
  background: #D1FAE5;
  color: #065F46;
}
.toast-error {
  border-left: 3px solid #EF4444;
  color: #EF4444;
}
.toast-error .toast-icon {
  background: #FEE2E2;
  color: #991B1B;
}
.toast-warning {
  border-left: 3px solid #F59E0B;
  color: #F59E0B;
}
.toast-warning .toast-icon {
  background: #FEF3C7;
  color: #92400E;
}
.toast-info {
  border-left: 3px solid #3B82F6;
  color: #3B82F6;
}
.toast-info .toast-icon {
  background: #DBEAFE;
  color: #1E40AF;
}

/* ---------- Skeleton Loaders ---------- */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-card) 0%,
    var(--bg-hover) 50%,
    var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}
.skeleton-text:last-child {
  margin-bottom: 0;
  width: 60%;
}
.skeleton-title {
  height: 2em;
  width: 40%;
  margin-bottom: 1em;
}
.skeleton-card {
  height: 120px;
}
.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

/* ---------- Dashboard sections & toolbar ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.section-head h2 {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin: 0;
  letter-spacing: -0.01em;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
  padding: 0 12px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 10px;
  background: var(--bg-input);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.toolbar-search:focus-within {
  border-color: var(--purple-violet);
  box-shadow: var(--focus-ring);
}
.toolbar-search span { font-size: 14px; opacity: .7; }
.toolbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text-primary);
  padding: 10px 0;
}
.toolbar select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  max-width: 220px;
}
.toolbar select:focus-visible { box-shadow: var(--focus-ring); outline: none; }
@media (max-width: 640px) {
  .toolbar-search { flex-basis: 100%; }
  .toolbar select { flex: 1; max-width: none; min-width: 0; }
}

/* ---------- Dashboard insights charts ---------- */
.stat-icon { font-size: 17px; line-height: 1; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  height: 100%;
  min-width: 0;
  cursor: default;
}
.chart-bar-track {
  flex: 1;
  width: 100%;
  max-width: 26px;
  display: flex;
  align-items: flex-end;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}
.chart-bar-fill {
  width: 100%;
  min-height: 2px;
  background: var(--purple-violet);
  border-radius: 4px 4px 0 0;
  transition: height .4s cubic-bezier(0.4, 0, 0.2, 1), background .2s ease;
}
.chart-bar-col:hover .chart-bar-fill { background: var(--purple-deep); }
[data-theme="dark"] .chart-bar-col:hover .chart-bar-fill { background: #A78BFA; }
.chart-bar-label {
  font-size: 10.5px;
  color: var(--text-tertiary);
  font-family: "JetBrains Mono", monospace;
}
@media (max-width: 560px) {
  .chart-bar-col:nth-child(odd) .chart-bar-label { visibility: hidden; }
}

.format-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
}
.format-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}
.format-track {
  height: 10px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}
.format-fill {
  height: 100%;
  min-width: 2px;
  background: var(--purple-violet);
  border-radius: 4px;
  transition: width .4s cubic-bezier(0.4, 0, 0.2, 1);
}
.format-count {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 18px;
  text-align: right;
}

/* ---------- Upload metadata grid ---------- */
.upload-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 16px;
  margin: 0;
  align-items: baseline;
}
.upload-meta-grid dt {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.upload-meta-grid dd {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}
.upload-meta-grid dd.is-highlight {
  color: var(--brand-text);
}

/* ---------- Tags ---------- */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  transition: all .2s ease;
}
.tag-chip:hover {
  border-color: var(--purple-violet);
  color: var(--brand-text);
  opacity: 1;
}
.tag-chip.is-active {
  background: var(--bg-hover);
  border-color: var(--purple-violet);
  color: var(--brand-text);
}
.tag-chip-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  border-radius: 999px;
  padding: 1px 7px;
}
.tag-chip.is-active .tag-chip-count {
  background: var(--bg-card);
  color: var(--brand-text);
}
.tag-mini {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--brand-text);
}

/* Chip-style tag editor */
.tag-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 260px;
  padding: 7px 10px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 10px;
  background: var(--bg-input);
  cursor: text;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.tag-editor:focus-within {
  border-color: var(--purple-violet);
  box-shadow: var(--focus-ring);
}
.tag-editor input {
  flex: 1;
  min-width: 140px;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  padding: 4px 2px;
}
.tag-editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 6px 3px 11px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--brand-text);
}
.tag-editor-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
  transition: color .15s ease, background .15s ease;
}
.tag-editor-chip button:hover {
  color: var(--danger-text);
  background: var(--bg-card);
}

/* ---------- PDF preview modal ---------- */
.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(10, 7, 25, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pdf-modal[hidden] { display: none; }
.pdf-modal-box {
  width: min(920px, 96vw);
  height: min(86vh, 1100px);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dropdown-in .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.pdf-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-primary);
}
#pdf-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff; /* the print view is always light */
}

/* ---------- Image loading shimmer ---------- */
/* Thumbnails and key-moment frames show a subtle shimmer while bytes arrive */
.img-loading {
  background: linear-gradient(90deg,
    var(--bg-hover) 0%,
    var(--border-primary) 50%,
    var(--bg-hover) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ---------- Print safety ---------- */
/* Printing an app page (Ctrl+P) must come out light and clean, even from dark mode */
@media print {
  :root, [data-theme="dark"] {
    --bg-main: #fff;
    --bg-card: #fff;
    --bg-hover: #F3F0FF;
    --bg-input: #fff;
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-tertiary: #6B7280;
    --border-primary: #D1D5DB;
    --border-secondary: #D1D5DB;
    --brand-text: #5B21B6;
    --success-text: #065F46;
    --warning-text: #92400E;
    --danger-text: #991B1B;
    color-scheme: light;
  }
  body { background: #fff !important; }
  .app-header,
  .theme-toggle,
  .toast-container,
  .btn,
  .tabs,
  form { display: none !important; }
  .tab-panel { display: block !important; }
  .card { box-shadow: none !important; border-color: #D1D5DB !important; break-inside: avoid; }
  a { opacity: 1 !important; }
}
.auth-card { width: 100%; max-width: 430px; background: var(--bg-card); border-radius: 22px; padding: 38px 36px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }

/* Detail header: title (+ inline rename) → badge + tags grouped + icon actions */
.detail-header { margin-bottom: 16px; }
.detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-title {
  font-size: 26px;
  margin: 0;
  overflow-wrap: anywhere;
  min-width: 0;
}
.detail-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.detail-header-row .detail-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}
.detail-header-row .detail-actions form { margin: 0; display: flex; }
.detail-header-row .badge { font-size: 12px; padding: 4px 11px; }

.detail-tags-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ---------- Icon buttons: square, semantic-colored, self-explanatory ---------- */
.icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1.5px solid var(--border-secondary);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--purple-violet);
  opacity: 1;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }

.icon-btn-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 14px; }

.icon-btn-ghost { border-color: transparent; background: transparent; }
.icon-btn-ghost:hover { background: var(--bg-hover); border-color: transparent; box-shadow: none; }

.icon-btn-brand { background: rgba(124, 58, 237, 0.12); border-color: rgba(124, 58, 237, 0.35); }
.icon-btn-brand:hover { background: rgba(124, 58, 237, 0.2); }

.icon-btn-info { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); }
.icon-btn-info:hover { background: rgba(59, 130, 246, 0.2); border-color: #3B82F6; }
.icon-btn-info.is-on { background: rgba(59, 130, 246, 0.28); border-color: #3B82F6; }

.icon-btn-warning { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.4); }
.icon-btn-warning:hover { background: rgba(245, 158, 11, 0.24); border-color: var(--amber); }

.icon-btn-danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.38); }
.icon-btn-danger:hover { background: rgba(239, 68, 68, 0.22); border-color: #EF4444; }

/* ---------- Download accordion (collapsible download section) ---------- */
.download-accordion {
  margin: 0 0 24px;
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  background: var(--bg-card);
  overflow: hidden;
}
.download-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.download-accordion-trigger::-webkit-details-marker { display: none; }
.download-accordion-trigger:hover { background: var(--bg-hover); }
.download-accordion-caret {
  font-size: 12px;
  transition: transform .2s ease;
}
.download-accordion[open] .download-accordion-caret { transform: rotate(180deg); }
.download-accordion-content {
  padding: 0 18px 18px;
  animation: dropdown-in .2s ease;
}

.download-item-primary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  color: #fff;
  margin-bottom: 12px;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: var(--shadow-sm);
}
.download-item-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  opacity: 1;
}
.download-item-icon { font-size: 24px; flex-shrink: 0; }
.download-item-text { flex: 1; }
.download-item-title { font-weight: 700; font-size: 14.5px; margin-bottom: 2px; }
.download-item-desc { font-size: 12.5px; opacity: .85; }

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.download-item-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-secondary);
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: border-color .2s ease, background .2s ease;
}
.download-item-compact:hover {
  border-color: var(--purple-violet);
  background: var(--bg-hover);
  opacity: 1;
}
.download-item-compact span:first-child { font-size: 16px; }
@media (max-width: 560px) {
  .download-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== Detail page layout ===== */
.detail-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.detail-sidebar {
  position: sticky;
  top: 76px; /* header (~61px) + breathing room */
  /* Must fit above the page's 80px bottom padding: otherwise, near the end of
     the page the sticky "releases" and slides up under the header. */
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.detail-sidebar::-webkit-scrollbar { display: none; }

.detail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  padding: 8px;
}

.detail-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
  width: 100%;
}

.detail-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-nav-item.is-active {
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.detail-nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.detail-nav-count {
  margin-left: auto;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.detail-nav-item.is-active .detail-nav-count {
  background: rgba(255, 255, 255, 0.25);
}

.detail-downloads {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 14px;
  overflow: hidden;
}

.detail-downloads-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.detail-downloads-title::-webkit-details-marker { display: none; }
.detail-downloads-title:hover { background: var(--bg-hover); }

.detail-downloads-caret {
  font-size: 12px;
  color: var(--text-tertiary);
  transition: transform .2s ease;
}
.detail-downloads[open] .detail-downloads-caret { transform: rotate(180deg); }

.detail-downloads-body {
  padding: 4px 16px 16px;
  animation: dropdown-in .2s ease;
}

.detail-download-primary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  color: #fff;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 13.5px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.detail-download-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  opacity: 1;
}

.detail-download-primary span:first-child {
  font-size: 20px;
}

.detail-download-hint {
  font-size: 12px;
  opacity: .85;
  font-weight: 400;
}

.detail-download-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-download-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  transition: background .2s ease;
}

.detail-download-list a:hover {
  background: var(--bg-hover);
  opacity: 1;
}

.detail-download-list a span {
  font-size: 16px;
}

.detail-main {
  min-width: 0;
}

.detail-tags-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-violet));
  width: 26px;
  height: 26px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Responsive: the sidebar dissolves — the section menu becomes a sticky
   horizontal bar at the top and downloads a compact accordion below it. */
@media (max-width: 980px) {
  .detail-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* base rule says start (for the desktop grid) — here it must stretch */
    gap: 14px;
  }
  .detail-layout > *, .detail-sidebar > * { max-width: 100%; min-width: 0; }

  .detail-sidebar { display: contents; }

  .detail-nav {
    order: -2;
    position: sticky;
    top: 54px; /* right below the sticky app header */
    z-index: 90;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    box-shadow: var(--shadow-md);
  }
  .detail-nav::-webkit-scrollbar { display: none; }

  .detail-nav-item {
    width: auto; /* desktop rule stretches items to the sidebar width */
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 13px;
    font-size: 13.5px;
    gap: 7px;
  }
  .detail-nav-count { margin-left: 4px; }

  .detail-downloads { order: -1; }

  .detail-download-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .rv-meta-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .rv-meta-grid > .card { padding: 10px 12px !important; }

  /* Section panels land below the sticky header + nav when scrolled to */
  .tab-panel { scroll-margin-top: 112px; }
}

/* Hide old .tabs/.tab system if it still exists anywhere */
.tabs { display: none; }

/* ============================================================
   Móvil como app (D-112): en pantalla chica manda la acción, no el
   discurso. Los subtítulos de página se callan, los textos largos
   tienen versión corta (.hide-m se oculta en móvil, .solo-m solo
   aparece en móvil) y todo aprieta un punto.
   ============================================================ */
.solo-m { display: none; }
@media (max-width: 640px) {
  .hide-m { display: none !important; }
  .solo-m { display: inline; }
  .app-main { padding: 22px 16px 70px; }
  .page-title { font-size: 24px; }
  .page-subtitle { display: none; }
  .card { padding: 18px 16px; border-radius: 16px; }
  .section-head { margin-top: 22px; }
  .capability-row { gap: 6px; margin-bottom: 16px; }
  .capability-chip { font-size: 11.5px; padding: 5px 10px; gap: 5px; }
  .dropzone { padding: 30px 14px; }
}
