/* ═══════════════════════════════════════════════════════════════════════════
   GLUCO · portal.css
   Menú lateral de escritorio, Estadísticas en pantalla ancha, calculadora y Vídeos.
   Se carga DESPUÉS de styles.css. En móvil (≤ 960 px) todo sigue igual que antes.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --sn-w: 272px;
  --sn-w-collapsed: 84px;
  --sn-bg: #ffffff;
  --sn-border: #dbe6f5;
  --sn-text: #0f172a;
  --sn-muted: #5f7189;
  --sn-accent: #0ea5e9;
  --sn-accent-2: #10b981;
  --sn-accent-soft: rgba(14, 165, 233, 0.1);
  --sn-accent-line: rgba(14, 165, 233, 0.42);
  --sn-hover: rgba(15, 23, 42, 0.045);
  --sn-card: #f6f9ff;
}

body.theme-dark {
  --sn-bg: #070b15;
  --sn-border: #16233c;
  --sn-text: #f1f5f9;
  --sn-muted: #8b9cb8;
  --sn-accent: #38bdf8;
  --sn-accent-2: #34d399;
  --sn-accent-soft: rgba(56, 189, 248, 0.13);
  --sn-accent-line: rgba(56, 189, 248, 0.46);
  --sn-hover: rgba(255, 255, 255, 0.05);
  --sn-card: rgba(255, 255, 255, 0.025);
}

/* ─── Menú lateral ──────────────────────────────────────────────────────── */

.side-nav {
  display: none;
}

@media (min-width: 961px) {
  .side-nav {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    flex: 0 0 var(--sn-w);
    width: var(--sn-w);
    height: 100vh;
    height: 100dvh;
    padding: 22px 14px 0;
    background: var(--sn-bg);
    border-right: 1px solid var(--sn-border);
    color: var(--sn-text);
    z-index: 40;
    transition: width 0.22s ease, flex-basis 0.22s ease;
  }

  /* En escritorio la navegación es el menú lateral, no la barra flotante de abajo. */
  .bottom-nav {
    display: none;
  }

  .side-nav-brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 26px;
    min-height: 74px;
  }

  .side-nav-mark {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(140deg, #38bdf8 0%, #0ea5e9 48%, #10b981 100%);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.32);
  }

  .side-nav-mark svg {
    width: 22px;
    height: 22px;
  }

  .side-nav-brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .side-nav-brand-text strong {
    font-size: 15px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--sn-text);
  }

  .side-nav-brand-text small {
    font-size: 13px;
    line-height: 1.2;
    color: var(--sn-muted);
    white-space: nowrap;
  }

  .side-nav-collapse {
    position: absolute;
    right: -28px;
    top: 14px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--sn-border);
    background: var(--sn-bg);
    color: var(--sn-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, transform 0.22s ease;
  }

  .side-nav-collapse:hover {
    color: var(--sn-text);
    border-color: var(--sn-accent-line);
  }

  .side-nav-collapse svg {
    width: 16px;
    height: 16px;
  }

  .side-nav-menu {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding: 2px 0 12px;
  }

  .side-nav-label {
    margin: 4px 12px 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--sn-muted);
    opacity: 0.85;
  }

  .side-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--sn-muted);
    font: inherit;
    font-size: 15.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }

  .side-nav-item svg {
    flex: none;
    width: 22px;
    height: 22px;
  }

  .side-nav-item:hover {
    background: var(--sn-hover);
    color: var(--sn-text);
  }

  .side-nav-item.active {
    color: var(--sn-text);
    font-weight: 700;
    border-color: var(--sn-accent-line);
    background: linear-gradient(180deg, var(--sn-accent-soft), rgba(56, 189, 248, 0.035));
  }

  .side-nav-item.active svg {
    color: var(--sn-accent);
  }

  .side-nav-item:focus-visible,
  .side-nav-icon-btn:focus-visible,
  .side-nav-collapse:focus-visible {
    outline: 2px solid var(--sn-accent);
    outline-offset: 2px;
  }

  /* Pie: tarjeta de usuario */
  .side-nav-foot {
    margin: 0 -14px;
    padding: 14px 14px 16px;
    border-top: 1px solid var(--sn-border);
  }

  .side-nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 10px;
    border: 1px solid var(--sn-border);
    border-radius: 16px;
    background: var(--sn-card);
  }

  .side-nav-avatar {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: linear-gradient(140deg, #0ea5e9 0%, #10b981 100%);
  }

  .side-nav-user-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .side-nav-user-text strong {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--sn-text);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
  }

  .side-nav-user-text small {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--sn-muted);
  }

  .side-nav-icon-btn {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--sn-muted);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .side-nav-icon-btn:hover {
    background: var(--sn-hover);
    color: var(--sn-text);
  }

  .side-nav-icon-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Menú contraído (solo iconos) */
  .app.side-collapsed .side-nav {
    flex-basis: var(--sn-w-collapsed);
    width: var(--sn-w-collapsed);
  }

  .app.side-collapsed .side-nav-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .app.side-collapsed .side-nav-brand-text,
  .app.side-collapsed .side-nav-label,
  .app.side-collapsed .side-nav-item span,
  .app.side-collapsed .side-nav-user-text {
    display: none;
  }

  .app.side-collapsed .side-nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .app.side-collapsed .side-nav-user {
    flex-direction: column;
    padding: 10px 4px;
    gap: 6px;
  }

  .app.side-collapsed .side-nav-collapse svg {
    transform: rotate(180deg);
  }

  /* ─── Página con menú lateral ─── */
  .content {
    flex: 1 1 0;
    min-width: 0;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 22px 36px 64px;
  }

  /* El botón flotante «calcular» se centra en el área de contenido, no en toda la ventana. */
  .main-action-fab {
    left: calc(50% + var(--sn-w) / 2);
    bottom: 28px;
  }

  .main-action-fab.is-chat-open {
    bottom: 28px;
  }

  .app.side-collapsed ~ .main-action-fab {
    left: calc(50% + var(--sn-w-collapsed) / 2);
  }
}

/* ─── Calculadora: de dónde sale «Glucosa actual» ──────────────────────── */

.calc-glucose-source {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted, #8b9cb8);
}

.calc-glucose-source:empty {
  display: none;
}

.calc-glucose-source::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.calc-glucose-source.is-manual::before {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.calc-glucose-source.is-stale {
  color: #f59e0b;
}

.calc-glucose-source.is-stale::before {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* ─── Estadísticas en escritorio ───────────────────────────────────────── */
/* Prefijo .content para ganar a las reglas de tema oscuro/claro de styles.css. */

@media (min-width: 961px) {
  .content .stats-section.panel-section {
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .content .stats-section .stats-heading {
    margin: 6px 0 22px;
  }

  .content .stats-section .stats-heading h2 {
    margin: 0 0 6px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.01em;
  }

  .content .stats-section .stats-heading p {
    margin: 0;
    font-size: 15px;
  }

  /* Tarjeta principal: título, lectura en vivo, rangos y curva a todo el ancho */
  .content .stats-section .dexcom-embed {
    max-width: none;
    margin: 0 0 20px;
    padding: 24px 26px 26px;
    border-width: 1px;
    border-radius: 20px;
    background: var(--panel, #111827);
    border-color: var(--border, #1e3a5f);
    box-shadow: 0 18px 40px rgba(2, 8, 23, 0.28);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px 24px;
    align-items: center;
  }

  body.theme-light .content .stats-section .dexcom-embed {
    background: #ffffff;
    border-color: #dbeafe;
    box-shadow: 0 10px 30px rgba(14, 165, 233, 0.1);
  }

  .content .stats-section .dexcom-embed > .dexcom-embed-header { grid-column: 1 / -1; grid-row: 1; }
  .content .stats-section .dexcom-embed > .stats-live-strip    { grid-column: 1 / -1; grid-row: 2; }
  .content .stats-section .dexcom-embed > .range-legend        { grid-column: 1 / -1; grid-row: 3; }
  .content .stats-section .dexcom-embed > #dexcom-status       { grid-column: 1 / -1; grid-row: 4; }
  .content .stats-section .dexcom-embed > .dexcom-frame-wrapper { grid-column: 1 / -1; grid-row: 5; }

  .content .stats-section .dexcom-embed-header .stat-label {
    margin: 0;
  }

  .content .stats-section .dexcom-embed-header .stat-value {
    margin: 4px 0 0;
    font-size: 24px;
    line-height: 1.2;
  }

  .content .stats-section .live-indicator {
    flex: none;
    white-space: nowrap;
  }

  .content .stats-section .range-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .content .stats-section #dexcom-status {
    margin: 0;
  }

  .content .stats-section .dexcom-frame-wrapper {
    height: 340px !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .content .stats-section .dexcom-frame-wrapper canvas {
    width: 100% !important;
  }

  /* «Lectura actual»: franja dentro de la tarjeta, ya no una caja suelta */
  .content .stats-section .stats-live-strip {
    margin: 0;
    padding: 16px 22px 18px;
    border-radius: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 14px;
    row-gap: 2px;
    align-items: center;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.14), rgba(16, 185, 129, 0.09));
    border: 1px solid rgba(56, 189, 248, 0.3);
  }

  body.theme-light .content .stats-section .stats-live-strip {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(16, 185, 129, 0.08));
    border-color: rgba(14, 165, 233, 0.28);
  }

  .content .stats-section .stats-live-main {
    display: contents;
  }

  .content .stats-section .stats-live-main > p.muted {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }

  .content .stats-section .stats-live-main > .stats-live-value {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 2px 0 0;
    font-size: 44px;
    letter-spacing: -0.02em;
  }

  .content .stats-section .stats-live-side {
    grid-column: 2;
    grid-row: 1;
  }

  .content .stats-section .stats-live-trend {
    font-size: 16px;
    white-space: nowrap;
  }

  /* Tarjetas de métricas */
  .content .stats-section .stats-grid,
  .content .stats-section .stats-grid.stats-standard-only {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 0;
    overflow: visible;
    padding-bottom: 0;
  }

  .content .stats-section .stat-card,
  .content .stats-section .stat-card.wide {
    min-width: 0;
    padding: 18px 20px 20px;
    border-radius: 16px;
  }

  .content .stats-section .stat-card .stat-value {
    margin: 8px 0 12px;
    font-size: 28px;
    line-height: 1.15;
  }

  .content .stats-section #stats-events-value {
    font-size: 24px;
  }

  .content .stats-section .stats-note {
    margin: 18px 2px 0;
  }
}

/* Con ancho de sobra: lectura en vivo y rangos en la misma fila, curva debajo */
@media (min-width: 1100px) {
  .content .stats-section .dexcom-embed {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .content .stats-section .dexcom-embed > .stats-live-strip { grid-column: 1; grid-row: 2; }
  .content .stats-section .dexcom-embed > .range-legend     { grid-column: 2; grid-row: 2; }
  .content .stats-section .dexcom-embed > #dexcom-status    { grid-column: 1 / -1; grid-row: 3; }
  .content .stats-section .dexcom-embed > .dexcom-frame-wrapper { grid-column: 1 / -1; grid-row: 4; }
}

@media (min-width: 1440px) {
  .content .stats-section .stats-grid,
  .content .stats-section .stats-grid.stats-standard-only {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .content .stats-section #stats-events-value {
    font-size: 20px;
  }
}

/* ─── Móvil y tablet: la página no puede ser más ancha que la pantalla ─────────
   `.content` se centra con margin:auto dentro de una columna flex. Sin ancho propio toma el
   tamaño mínimo de lo que lleva dentro (la tira de pestañas de Perfil, las tarjetas de
   Estadísticas…) y empuja toda la página fuera de la pantalla. */

@media (max-width: 960px) {
  .content {
    width: 100%;
    min-width: 0;
  }

  /* Estadísticas: las 4 métricas en cuadrícula 2×2 en vez de una tira que se sale de la pantalla */
  .content .stats-section .stats-grid,
  .content .stats-section .stats-grid.stats-standard-only {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
    overflow: visible;
    padding-bottom: 0;
  }

  .content .stats-section .stat-card,
  .content .stats-section .stat-card.wide {
    min-width: 0;
    padding: 14px 14px 16px;
  }

  .content .stats-section .stat-card .stat-label {
    font-size: 13px;
  }

  .content .stats-section .stat-card .stat-value {
    font-size: 22px;
  }

  .content .stats-section #stats-events-value {
    font-size: 17px;
    line-height: 1.3;
  }

  /* Una sola tarjeta (sin la caja exterior) para que la curva use todo el ancho */
  .content .stats-section.panel-section {
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .content .stats-section .stats-heading {
    margin: 4px 0 16px;
  }

  .content .stats-section .stats-heading h2 {
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1.15;
  }

  .content .stats-section .stats-heading p {
    margin: 0;
    font-size: 14px;
  }

  .content .stats-section .dexcom-embed {
    max-width: none;
    margin: 0 0 14px;
    padding: 16px 14px;
    border-width: 1px;
    border-radius: 18px;
    background: var(--panel, #111827);
    border-color: var(--border, #1e3a5f);
    box-shadow: 0 14px 30px rgba(2, 8, 23, 0.25);
  }

  body.theme-light .content .stats-section .dexcom-embed {
    background: #ffffff;
    border-color: #dbeafe;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.1);
  }

  .content .stats-section .live-indicator {
    flex: none;
    white-space: nowrap;
  }

  .content .stats-section .dexcom-embed-header .stat-value {
    margin: 2px 0 0;
    font-size: 21px;
  }

  .content .stats-section .stats-live-strip {
    flex-wrap: wrap;
    margin: 0;
  }

  .content .stats-section .stats-live-value,
  .content .stats-section .stats-live-trend {
    white-space: nowrap;
  }

  .content .stats-section .stats-note {
    margin: 10px 2px 0;
  }
}

/* ─── Vídeos · portal de módulos ─────────────────────────────────────────────
   Portada de cada módulo = curva de glucosa (CGM) generada por módulo, en azul/verde GLUCO. */

.videos-section {
  --vp-radius: 18px;
}

.videos-section .vp-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 4px 0 26px;
}

.videos-section .vp-head-text {
  flex: 1 1 320px;
  min-width: 0;
}

.videos-section .vp-head h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.videos-section .vp-head p.muted {
  margin: 6px 0 0;
  font-size: 15px;
}

.vp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 6px 14px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.vp-back:hover {
  color: var(--text);
  border-color: var(--accent);
}

.vp-back svg {
  width: 16px;
  height: 16px;
}

.vp-new {
  flex: none;
  padding: 12px 20px;
  font-size: 15px;
}

.vp-new svg {
  width: 18px;
  height: 18px;
}

.videos-login a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.videos-notice:not(:empty) {
  margin: 0 0 16px;
}

.videos-notice.is-error,
.videos-form-status.is-error {
  color: #ef4444;
}

.videos-notice.is-ok,
.videos-form-status.is-ok {
  color: var(--accent-2);
}

/* ── Formulario de subida / edición ── */

.vp-form {
  margin: 0 0 28px;
  /* Al abrirlo con scrollIntoView, deja sitio a la burbuja de glucosa fija arriba. */
  scroll-margin-top: 76px;
  padding: 22px 24px 24px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(2, 8, 23, 0.28);
}

body.theme-light .vp-form {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 10px 30px rgba(14, 165, 233, 0.1);
}

.vp-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.vp-form-head h3 {
  margin: 0;
  font-size: 20px;
}

.vp-form-close {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.vp-form-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

.vp-form-close:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.videos-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  margin: 0 0 14px;
}

.videos-form-grid .videos-field-wide {
  grid-column: 1 / -1;
}

.videos-form-grid textarea {
  resize: vertical;
  font: inherit;
}

.videos-form-grid small {
  color: var(--muted);
}

.videos-form-grid input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-light);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.videos-form-status {
  min-height: 1.4em;
  margin: 8px 0 0;
}

.videos-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.videos-form-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.videos-progress {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  overflow: hidden;
}

.videos-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.15s linear;
}

.videos-empty {
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--vp-radius);
}

.videos-empty p {
  margin: 0;
  color: var(--muted);
}

/* ── Módulos (portada) ── */

.vm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 22px;
}

.vm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--vp-radius);
  background: var(--panel);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.vm-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 22px 44px rgba(2, 8, 23, 0.38);
}

body.theme-light .vm-card {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.1);
}

body.theme-light .vm-card:hover {
  box-shadow: 0 18px 38px rgba(14, 165, 233, 0.2);
}

.vm-cover {
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--c1, #0b7fc2), var(--c2, #0e9f6e));
}

.vm-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(2, 8, 23, 0.1) 0%, rgba(2, 8, 23, 0) 30%, rgba(2, 8, 23, 0.78) 100%);
  pointer-events: none;
}

.vm-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.vm-name {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  z-index: 2;
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 14px rgba(2, 8, 23, 0.55);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.vm-open {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Toda la tarjeta es el botón */
.vm-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: var(--vp-radius);
}

.vm-open:focus-visible {
  outline: none;
}

.vm-open:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.vm-draft {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.95);
  color: #2b1700;
  font-size: 11.5px;
  font-weight: 700;
}

.vm-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  padding: 16px 18px 18px;
}

.vm-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.vm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.vm-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vm-meta svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

/* ── Lecciones (dentro de un módulo) ── */

.vl-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vl-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px 14px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.vl-row:hover {
  border-color: rgba(56, 189, 248, 0.5);
}

body.theme-light .vl-row {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.07);
}

.video-card-thumb {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 104px;
  aspect-ratio: 16 / 10;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, var(--c1, #0b7fc2), var(--c2, #0e9f6e));
}

.video-card-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.video-card-play {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding-left: 2px;
  border-radius: 50%;
  font-size: 13px;
  background: rgba(2, 8, 23, 0.45);
  transition: transform 0.15s ease;
}

.video-card-thumb:hover .video-card-play,
.video-card-thumb:focus-visible .video-card-play {
  transform: scale(1.12);
}

.video-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vl-num {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.video-card-title {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.3;
  color: var(--text);
  overflow-wrap: anywhere;
}

.video-card-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-line;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.video-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.video-badge {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.video-badge--all {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.video-badge--assigned {
  color: var(--accent);
  border-color: var(--accent);
}

.video-badge--draft {
  color: #d97706;
  border-color: #d97706;
}

.vl-side {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
}

.video-card-duration {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.video-card-actions {
  display: flex;
  gap: 8px;
}

.video-card-actions button {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
}

.video-card-actions .is-danger:hover {
  color: #ef4444;
  border-color: #ef4444;
}

@media (max-width: 720px) {
  .vl-row {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: start;
    gap: 10px 14px;
    padding: 12px;
  }

  .video-card-thumb {
    width: 96px;
  }

  /* En móvil la duración va dentro de la miniatura y los botones ocupan su propia fila. */
  .video-card-thumb[data-duration]::after {
    content: attr(data-duration);
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
    background: rgba(2, 8, 23, 0.64);
  }

  .vl-side {
    display: contents;
  }

  .video-card-duration {
    display: none;
  }

  .video-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .videos-form-grid {
    grid-template-columns: 1fr;
  }

  .vm-grid {
    grid-template-columns: 1fr;
  }

  .videos-section .vp-head h2 {
    font-size: 26px;
  }

  .vp-form {
    padding: 18px 16px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vm-card,
  .vm-card:hover {
    transition: none;
    transform: none;
  }
}

/* ── Reproductor ── */

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
}

.video-modal-card {
  position: relative;
  width: min(900px, 100%);
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.video-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.video-modal-head h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.video-modal-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-light);
}

.video-modal-card video {
  display: block;
  width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  background: #000000;
}

.video-modal-error {
  margin: 10px 0 0;
  font-size: 14px;
  color: #ef4444;
}

.video-modal-description {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
  color: var(--muted);
}


/* ── Portadas con foto y lista de lecciones (estilo iDT) ── */

.vm-cover.has-photo,
.vl-hero-photo.has-photo {
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
}

.vm-cover.has-photo .vm-trace {
  display: none;
}

.vl-hero {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
}

body.theme-light .vl-hero {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.1);
}

.vl-hero-photo {
  flex: none;
  width: 190px;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--c1, #0b7fc2), var(--c2, #0e9f6e));
}

.vl-hero-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.vl-hero-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.vl-hero-btn {
  margin-top: 4px;
  padding: 10px 22px;
  border-radius: 12px;
}

.vl-row {
  cursor: pointer;
  gap: 16px;
  padding: 14px 18px 14px 14px;
}

.vl-row:hover {
  transform: translateX(3px);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.14);
}

.vl-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vl-row .video-card-thumb {
  width: 58px;
  height: 58px;
  aspect-ratio: auto;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.vl-chevron {
  font-size: 26px;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.vl-row:hover .vl-chevron {
  transform: translateX(3px);
}

@media (max-width: 720px) {
  .vl-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .vl-hero-photo {
    width: 100%;
  }

  .vl-row {
    display: flex;
    flex-wrap: wrap;
  }

  .vl-row .video-card-thumb {
    width: 48px;
    height: 48px;
    font-size: 13px;
  }

  .vl-row .vl-side {
    display: flex;
    margin-left: auto;
  }

  .vl-row .video-card-duration {
    display: inline;
  }

  .vl-row .video-card-actions {
    flex-basis: 100%;
  }
}

/* ── Tarjeta de módulo: marca arriba, número grande abajo, título debajo ── */

.vm-cover::after {
  background:
    linear-gradient(90deg, rgba(7, 18, 44, 0.72) 0%, rgba(7, 18, 44, 0.22) 52%, rgba(7, 18, 44, 0) 100%),
    linear-gradient(180deg, rgba(7, 18, 44, 0) 45%, rgba(7, 18, 44, 0.7) 100%);
}

.vm-brand {
  position: absolute;
  top: 14px;
  left: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(7, 18, 44, 0.45);
}

.vm-brand-dot {
  display: block;
  width: 5px;
  height: 5px;
  margin-bottom: 2px;
  background: #38bdf8;
}

.vm-num {
  position: absolute;
  left: 18px;
  bottom: 10px;
  z-index: 2;
  font-size: clamp(40px, 4.4vw, 54px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow: 0 2px 16px rgba(7, 18, 44, 0.5);
}

.vm-num--start {
  bottom: 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.vm-name {
  position: static;
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--text);
  text-shadow: none;
}

.vm-body {
  gap: 10px;
}

/* ── Progreso: lecciones completadas, barra y siguiente ── */

.vm-progress {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(100, 116, 139, 0.22);
}

.vm-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ea87a, #38bdf8);
  transition: width 0.4s ease;
}

.vm-status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.vm-status--done {
  color: #2ea87a;
}

.vl-hero-progress {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vl-hero-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.vl-row .video-card-thumb.is-done {
  background: linear-gradient(135deg, #2ea87a, #38bdf8);
  font-size: 22px;
}

.vl-row.is-done .video-card-title {
  color: var(--muted);
}

.vl-done-tag,
.vl-next-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.vl-done-tag {
  color: #1f8a63;
  background: rgba(46, 168, 122, 0.14);
}

.vl-next-tag {
  color: #ffffff;
  background: #0f172a;
}

.video-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4px 2px;
}

.video-modal-actions button {
  padding: 10px 18px;
  border-radius: 12px;
}

.video-modal-actions .is-done {
  color: #1f8a63;
  border-color: #2ea87a;
}

.video-modal-actions .is-highlight {
  animation: nextPulse 1.4s ease-in-out infinite;
}

@keyframes nextPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .video-modal-actions .is-highlight { animation: none; }
}

/* ── Cabecera del curso, «Por dónde vas» ── */

.cs-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px 40px;
  margin-bottom: 22px;
  padding: 34px 38px;
  border-radius: 28px;
  overflow: hidden;
  color: #f1f5f9;
  background: linear-gradient(120deg, #0a0f1e 0%, #0f2347 62%, #12417a 130%);
}

.cs-hero::before {
  content: "iDT.";
  position: absolute;
  right: 26%;
  bottom: -34px;
  z-index: -1;
  font-size: clamp(120px, 20vw, 240px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: rgba(148, 197, 255, 0.08);
  pointer-events: none;
}

.cs-hero-main {
  flex: 1 1 380px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cs-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.cs-tag {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffffff;
  background: linear-gradient(90deg, #2ea87a, #2f6df6);
}

.cs-stats {
  font-size: 14.5px;
  color: #9fb0cc;
}

.cs-title {
  margin: 0;
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.cs-progress {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 520px;
}

.cs-progress-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}

.cs-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2ea87a, #38bdf8);
  transition: width 0.4s ease;
}

.cs-pct {
  flex: none;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.cs-seen {
  margin: 0;
  font-size: 14px;
  color: #9fb0cc;
}

.cs-hero-side {
  flex: 0 1 300px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  text-align: center;
}

.cs-btn {
  padding: 15px 22px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cs-btn:hover {
  transform: translateY(-1px);
}

.cs-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.cs-btn--primary {
  color: #ffffff;
  background: linear-gradient(90deg, #1f7bd8, #2f6df6);
}

.cs-btn--ghost {
  padding: 8px 12px;
  font-size: 13px;
  color: #cbd5e1;
  background: none;
}

.cs-btn--ghost:hover {
  color: #ffffff;
}

.cs-next {
  margin: 0;
  font-size: 13.5px;
  color: #9fb0cc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-route {
  margin-bottom: 22px;
  padding: 22px 26px 20px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
}

body.theme-light .cs-route {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.08);
}

.cs-route-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.cs-route-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.cs-route-count {
  font-size: 14px;
  color: var(--muted);
}

.cs-route-count b {
  color: #2ea87a;
}

.cs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cs-chip {
  min-width: 56px;
  padding: 12px 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  color: var(--muted);
  background: rgba(100, 116, 139, 0.1);
  border: 1px solid var(--border);
  transition: transform 0.15s ease;
}

.cs-chip:hover {
  transform: translateY(-2px);
}

.cs-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cs-chip--current {
  color: #1f6fd0;
  border-color: #2f6df6;
  background: rgba(47, 109, 246, 0.1);
}

.cs-chip--done {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #2ea87a, #38bdf8);
}

.cs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--muted);
}

.cs-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cs-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.25);
}

.cs-dot--done {
  background: linear-gradient(135deg, #2ea87a, #38bdf8);
}

.cs-dot--current {
  background: transparent;
  border: 3px solid #2f6df6;
}

@media (max-width: 720px) {
  .cs-hero {
    padding: 24px 20px;
  }

  .cs-hero-side {
    flex-basis: 100%;
  }
}

/* ── Modo concentración ── */

.fm {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: #f1f5f9;
  background: #070d1c;
}

.fm.is-hidden {
  display: none;
}

.fm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.fm-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fm-logo {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.fm-logo i {
  display: block;
  width: 5px;
  height: 5px;
  margin-bottom: 3px;
  background: #38bdf8;
}

.fm-mode {
  font-size: 14px;
  color: #9fb0cc;
}

.fm-bar-actions {
  display: flex;
  gap: 10px;
}

.fm button {
  font: inherit;
  cursor: pointer;
}

.fm button:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.fm-ghost {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  background: none;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.fm-ghost:hover {
  background: rgba(148, 163, 184, 0.12);
}

.fm-close {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(90deg, #1f7bd8, #2f6df6);
}

.fm-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 30px 28px 40px;
}

.fm-title {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 36px);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.fm-meta {
  margin: 10px 0 22px;
  font-size: 14.5px;
  color: #9fb0cc;
}

.fm-video {
  display: block;
  width: 100%;
  max-height: 68vh;
  border-radius: 20px;
  background: #000000;
}

.fm-error {
  margin: 14px 0 0;
  color: #fca5a5;
}

.fm-desc {
  margin: 16px 0 0;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  color: #cbd5e1;
}

.fm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.7);
}

.fm-primary {
  padding: 13px 26px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(90deg, #1f7bd8, #2f6df6);
}

.fm-primary.is-highlight {
  animation: nextPulse 1.4s ease-in-out infinite;
}

.fm-actions .is-hidden {
  display: none;
}

@media (max-width: 720px) {
  .fm-bar {
    padding: 14px 16px;
  }

  .fm-mode {
    display: none;
  }

  .fm-main {
    padding: 22px 16px 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fm-primary.is-highlight { animation: none; }
}

/* ═══ Lanzamiento sin conexión de sensor ═══
   Para volver a activar el sensor: quita class="no-sensor" de <body> en index.html. */

body.no-sensor #sidebar-glucose-card,
body.no-sensor #global-glucose-header,
body.no-sensor #glucose-panel-card,
body.no-sensor #home-stats-btn,
body.no-sensor #settings-login-dexcom,
body.no-sensor #settings-login-libre,
body.no-sensor .side-nav-item[data-main-tab="Estadisticas"],
body.no-sensor .bottom-nav-item[data-main-tab="Estadisticas"],
body.no-sensor .menu-item[data-section="Estadisticas"],
body.no-sensor .serenity-tools-grid .serenity-tool-item:nth-child(n + 2) {
  display: none !important;
}

/* Con 4 pestañas en lugar de 5, la barra inferior del móvil reparte el ancho entre las que quedan. */
body.no-sensor .bottom-nav {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ── Agenda tu 1:1 ── */

.agenda-section .ag-head h2 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.agenda-section .ag-head p {
  margin: 0 0 20px;
}

.ag-card {
  padding: 14px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
}

body.theme-light .ag-card {
  background: #ffffff;
  border-color: #dbeafe;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.1);
}

.ag-frame {
  display: block;
  width: 100%;
  height: min(78vh, 760px);
  min-height: 560px;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
}

.ag-open {
  display: block;
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.ag-empty {
  padding: 40px 20px;
  text-align: center;
}

.ag-empty-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* Con Agenda añadida, vuelven a ser 5 pestañas en la barra inferior (Estadísticas está oculta). */
body.no-sensor .bottom-nav {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* ── Cuestionario inicial (intake) ─────────────────────────────── */
.in-overlay { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(7, 11, 21, 0.62); backdrop-filter: blur(4px); }
.in-card { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: var(--sn-bg); color: var(--sn-text); border: 1px solid var(--sn-border); border-radius: 18px; padding: 22px 22px 18px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.in-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.in-step { font-size: 13px; color: var(--sn-muted); }
.in-skip { background: none; border: 0; color: var(--sn-muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.in-bar { height: 4px; border-radius: 4px; background: var(--sn-hover); overflow: hidden; margin-bottom: 16px; }
.in-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sn-accent), var(--sn-accent-2)); transition: width 0.3s ease; }
.in-card h2 { margin: 0 0 4px; font-size: 22px; }
.in-hint { margin: 0 0 14px; color: var(--sn-muted); font-size: 14px; line-height: 1.45; }
.in-fields { display: grid; gap: 12px; }
.in-field { display: grid; gap: 5px; font-size: 14px; }
.in-field span { color: var(--sn-muted); }
.in-field input, .in-field select, .in-field textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--sn-text); background: var(--sn-card); border: 1px solid var(--sn-border); border-radius: 10px; }
.in-field input:focus, .in-field select:focus, .in-field textarea:focus { outline: 2px solid var(--sn-accent); outline-offset: 1px; }
.in-consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 13.5px; color: var(--sn-muted); line-height: 1.4; }
.in-consent input { margin-top: 3px; }
.in-error { min-height: 18px; margin: 10px 0 0; color: #ef4444; font-size: 13px; }
.in-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.in-actions button[disabled] { opacity: 0.4; cursor: default; }
body.in-open { overflow: hidden; }
.in-profile-card { margin-top: 14px; }
.in-profile-card h3 { margin: 0 0 8px; }
.in-evo { display: grid; gap: 2px; margin: 8px 0 12px; font-size: 14px; }
.in-evo-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--sn-border); }
.in-evo-head { color: var(--sn-muted); font-size: 12.5px; }
.in-evo-row .good { color: #10b981; font-weight: 600; }
.in-evo-row .bad { color: #f59e0b; font-weight: 600; }

/* Sensor fuera por completo: banner de glucosa del chat, origen "Del sensor" y página de Estadísticas */
body.no-sensor #chat-glucose-banner,
body.no-sensor #calc-glucose-source,
body.no-sensor .panel-section.stats-section,
body.no-sensor .panel-section[data-section="Estadisticas"] {
  display: none !important;
}

/* Inicio + iDT en una sola pantalla: el chat va bajo el saludo y los botones; la pestaña "iDT" ya no existe. */
.side-nav-item[data-main-tab="Asistente IA"],
.bottom-nav-item[data-main-tab="Asistente IA"],
.menu-item[data-section="Asistente IA"] {
  display: none !important;
}
body.no-sensor .bottom-nav {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.panel-section[data-section="Inicio"].active { gap: 10px; }
.panel-section[data-section="Inicio"].active .home-greeting { margin-bottom: 0; }
.assistant-chat.show { margin-top: 6px; }
.assistant-chat .chat-header-title { display: none; }

/* ── Soporte 1:1 ───────────────────────────────────────────── */
body.no-sensor .bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.bottom-nav-item { position: relative; }
.bottom-nav-item .nav-badge { position: absolute; top: 2px; left: 55%; margin: 0; min-width: 18px; height: 18px; font-size: 11px; }
.support-section .sp-pagehead h2 { margin: 0 0 6px; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.support-section .sp-pagehead p { margin: 0 0 16px; }
.sp-wrap { display: grid; grid-template-columns: 1fr; gap: 14px; }
.sp-wrap:has(.sp-side) { grid-template-columns: 290px 1fr; }
.sp-side, .sp-main { background: var(--sn-bg); border: 1px solid var(--sn-border); border-radius: 16px; }
.sp-side { padding: 14px; align-self: start; max-height: 70vh; overflow-y: auto; }
.sp-side h3 { margin: 0 0 10px; font-size: 15px; }
.sp-list { display: grid; gap: 6px; }
.sp-conv { text-align: left; background: transparent; border: 1px solid transparent; border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--sn-text); display: grid; gap: 3px; }
.sp-conv:hover { background: var(--sn-hover); }
.sp-conv.is-active { background: var(--sn-accent-soft); border-color: var(--sn-accent-line); }
.sp-conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.sp-conv-last { color: var(--sn-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-unread { background: #ef4444; color: #fff; border-radius: 10px; font-size: 12px; font-weight: 700; padding: 1px 7px; }
.sp-main { display: flex; flex-direction: column; min-height: 460px; height: min(70vh, 640px); overflow: hidden; }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--sn-border); }
.sp-head h3 { margin: 0; font-size: 16px; }
.sp-back { display: none; background: none; border: 0; color: var(--sn-accent); font-size: 14px; cursor: pointer; padding: 0; }
.sp-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.sp-empty { margin: auto; text-align: center; color: var(--sn-muted); font-size: 14px; max-width: 320px; line-height: 1.5; }
.sp-msg { max-width: min(78%, 460px); padding: 9px 12px; border-radius: 16px; display: grid; gap: 4px; word-break: break-word; }
.sp-msg.is-mine { align-self: flex-end; background: linear-gradient(135deg, var(--sn-accent), var(--sn-accent-2)); color: #fff; border-bottom-right-radius: 5px; }
.sp-msg.is-theirs { align-self: flex-start; background: var(--sn-card); border: 1px solid var(--sn-border); color: var(--sn-text); border-bottom-left-radius: 5px; }
.sp-text { margin: 0; white-space: pre-wrap; font-size: 15px; line-height: 1.4; }
.sp-time { font-size: 11px; opacity: 0.7; justify-self: end; }
.sp-img { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; }
.sp-file { color: inherit; font-weight: 600; text-decoration: underline; }
.sp-composer { border-top: 1px solid var(--sn-border); padding: 10px 12px; display: grid; gap: 6px; }
.sp-composer[hidden] { display: none; }
.sp-row { display: flex; gap: 8px; align-items: flex-end; }
.sp-clip { background: var(--sn-card); border: 1px solid var(--sn-border); border-radius: 12px; width: 42px; height: 42px; font-size: 18px; cursor: pointer; flex: none; }
.sp-input { flex: 1; resize: none; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--sn-border); background: var(--sn-card); color: var(--sn-text); max-height: 140px; }
.sp-input:focus { outline: 2px solid var(--sn-accent); outline-offset: 1px; }
.sp-send { flex: none; height: 42px; }
.sp-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; background: var(--sn-accent-soft); border-radius: 10px; padding: 5px 10px; width: fit-content; max-width: 100%; }
.sp-chip[hidden] { display: none; }
.sp-chip-x { background: none; border: 0; cursor: pointer; color: var(--sn-muted); }
.sp-error { margin: 0; min-height: 0; color: #ef4444; font-size: 13px; }
@media (max-width: 760px) {
  .sp-wrap:has(.sp-side) { grid-template-columns: 1fr; }
  .support-section.is-thread .sp-side { display: none; }
  .support-section:not(.is-thread) .sp-wrap:has(.sp-side) .sp-main { display: none; }
  .support-section.is-thread .sp-back { display: inline; }
  .sp-main { height: calc(100vh - 260px); min-height: 380px; }
  .sp-msg { max-width: 88%; }
}

/* ══ Inicio: nuevo aspecto (solo estética; el funcionamiento no cambia) ══ */
body {
  --hm-ink: #0f1b3d;
  --hm-muted: #5b6b8a;
  --hm-card: #ffffff;
  --hm-line: rgba(37, 99, 235, 0.14);
  --hm-shadow: 0 10px 30px rgba(37, 99, 235, 0.10);
  --hm-blue: #1d6df2;
  --hm-blue-2: #0a5cf0;
  --hm-soft: #dbeafe;
}
body.theme-dark {
  --hm-ink: #f1f5f9;
  --hm-muted: #9fb0cc;
  --hm-card: #101a2e;
  --hm-line: rgba(96, 165, 250, 0.22);
  --hm-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --hm-soft: rgba(56, 189, 248, 0.16);
}

/* Fondo suave con ola abajo a la derecha (solo en Inicio, tema claro) */
body:not(.theme-dark):has(.panel-section[data-section="Inicio"].active) {
  background:
    radial-gradient(ellipse 55% 38% at 108% 104%, rgba(96, 165, 250, 0.38), transparent 70%),
    radial-gradient(ellipse 45% 30% at 100% 112%, rgba(37, 99, 235, 0.18), transparent 70%),
    radial-gradient(ellipse 45% 30% at -6% -6%, rgba(186, 215, 255, 0.55), transparent 70%),
    linear-gradient(160deg, #f6faff, #eaf3ff) fixed;
}

/* Cabecera: solo la marca «iDT» */
body:has(.panel-section[data-section="Inicio"].active) .content-header {
  text-align: left; border: 0; padding: 0 0 4px; margin: 0;
}
body:has(.panel-section[data-section="Inicio"].active) .content-header .subtitle { display: none; }
body:has(.panel-section[data-section="Inicio"].active) .content-header h1 {
  margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--hm-ink);
  display: flex; align-items: center; gap: 8px;
}
body:has(.panel-section[data-section="Inicio"].active) .content-header h1::before {
  content: ""; width: 30px; height: 30px; flex: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%231d6df2' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='M16 3C11 10 6 14.5 6 20a10 10 0 0 0 20 0c0-5.5-5-10-10-17Z'/><path d='M16 24a4.5 4.5 0 0 1-4.5-4.5'/></svg>") center / contain no-repeat;
}

/* Saludo + controles arriba a la derecha */
body .panel-section[data-section="Inicio"] .home-greeting { position: relative; padding: 18px 0 4px; }
body .panel-section[data-section="Inicio"] .home-greeting-text {
  font-size: clamp(1.8rem, 3.4vw, 2.5rem); font-weight: 800; letter-spacing: -0.02em; color: var(--hm-ink); margin: 0 0 6px;
}
body .panel-section[data-section="Inicio"] .home-greeting-sub { font-size: clamp(1rem, 1.6vw, 1.2rem); color: var(--hm-muted); }
.home-top-controls { position: absolute; top: -52px; right: 0; display: flex; gap: 8px; align-items: center; }
.home-topic-select {
  appearance: none; -webkit-appearance: none; cursor: pointer; font: inherit; font-size: 15px; font-weight: 500; color: var(--hm-ink);
  background: var(--hm-card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d3b6f' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") right 14px center / 16px no-repeat;
  border: 1px solid var(--hm-line); border-radius: 999px; padding: 10px 40px 10px 20px; box-shadow: var(--hm-shadow);
}
.home-top-controls #chat-food-scan-btn {
  border-radius: 999px; padding: 10px 16px; font-size: 14px; background: var(--hm-card); border: 1px solid var(--hm-line); color: var(--hm-ink); box-shadow: var(--hm-shadow); cursor: pointer;
}
.assistant-chat .chat-header { display: none; }

/* Botones grandes de acción */
body .panel-section[data-section="Inicio"] .home-actions-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 14px 0 6px;
}
body .panel-section[data-section="Inicio"] .home-actions-wrap > button {
  display: flex; align-items: center; gap: 18px; width: 100%; min-height: 92px; padding: 0 22px; border-radius: 28px;
  font: inherit; font-size: clamp(1.1rem, 1.8vw, 1.45rem); font-weight: 700; text-align: left; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
body .panel-section[data-section="Inicio"] .home-actions-wrap > button:hover { transform: translateY(-2px); }
body .panel-section[data-section="Inicio"] .home-btn-primary {
  color: #fff; border: 0; background: radial-gradient(120% 160% at 85% 120%, #0a5cf0 0%, transparent 60%), linear-gradient(135deg, #27a8ff, #0a66f2);
  box-shadow: 0 14px 30px rgba(10, 102, 242, 0.32);
}
body .panel-section[data-section="Inicio"] .home-btn-secondary { color: var(--hm-blue-2); background: var(--hm-card); border: 1px solid var(--hm-line); box-shadow: var(--hm-shadow); }
body.theme-dark .panel-section[data-section="Inicio"] .home-btn-secondary { color: #93c5fd; }
.home-actions-wrap .hb-icon { width: 46px; height: 46px; flex: none; }
.home-actions-wrap .hb-sep { width: 1px; align-self: stretch; margin: 26px 0; background: currentColor; opacity: .35; flex: none; }
.home-actions-wrap .hb-label { flex: 1; }
.home-actions-wrap .hb-arrow { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.home-actions-wrap .hb-arrow svg { width: 22px; height: 22px; }
.home-btn-primary .hb-arrow { background: #fff; color: #0a66f2; }
.home-btn-secondary .hb-arrow { background: var(--hm-soft); color: var(--hm-blue); }

/* Preguntas sugeridas */
body .assistant-chat.show .chat-suggestion-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; overflow: visible; padding: 4px 2px 8px;
}
body .assistant-chat .chat-suggestion-btn {
  display: flex; align-items: center; gap: 12px; text-align: left; white-space: normal; line-height: 1.3; min-height: 64px;
  padding: 10px 16px; border-radius: 26px; background: var(--hm-card); border: 1px solid var(--hm-line); box-shadow: var(--hm-shadow);
  color: var(--hm-ink); font-size: 14.5px; font-weight: 500; cursor: pointer;
}
body .assistant-chat .chat-suggestion-btn::before {
  content: "?"; flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--hm-blue); color: var(--hm-blue); font-weight: 700; font-size: 15px;
}
body .assistant-chat .chat-suggestion-btn:nth-child(n + 5) { display: none; }

/* Tarjeta de bienvenida */
body .assistant-chat .chat-empty-state {
  background: var(--hm-card); border: 1px solid var(--hm-line); border-radius: 30px; box-shadow: var(--hm-shadow);
  padding: 26px 30px; margin: 10px auto 4px; width: min(100%, 880px);
}
body .assistant-chat .chat-empty-welcome-wrap { display: flex; align-items: center; gap: 24px; }
body .assistant-chat .chat-empty-avatar {
  width: 88px; height: 88px; flex: none; font-size: 0; color: transparent; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bfe6ff, #7cc4ff 60%, #8fb2ff) center / cover;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28); position: relative;
}
body .assistant-chat .chat-empty-avatar::after {
  content: ""; position: absolute; inset: 14px 12px 12px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><line x1='32' y1='4' x2='32' y2='11' stroke='%23fff' stroke-width='3' stroke-linecap='round'/><circle cx='32' cy='4' r='3' fill='%23fff'/><rect x='6' y='14' width='52' height='40' rx='16' fill='%23fff'/><rect x='13' y='21' width='38' height='26' rx='12' fill='%231a2f55'/><circle cx='24' cy='32' r='3.2' fill='%2347d4ff'/><circle cx='40' cy='32' r='3.2' fill='%2347d4ff'/><path d='M26 39q6 4.5 12 0' stroke='%2347d4ff' stroke-width='2.6' fill='none' stroke-linecap='round'/></svg>") center / contain no-repeat;
}
body .assistant-chat .chat-empty-welcome-wrap::after { content: none; }
body .assistant-chat .chat-empty-welcome { margin: 0; flex: 1; color: var(--hm-muted); font-size: clamp(1rem, 1.5vw, 1.2rem); line-height: 1.5; border-left: 1px solid var(--hm-line); padding-left: 24px; }
body .assistant-chat .chat-empty-welcome .ce-title { display: block; margin-bottom: 4px; color: var(--hm-ink); font-size: clamp(1.4rem, 2.2vw, 1.9rem); font-weight: 800; }

/* Caja de mensaje */
body .assistant-chat .chat-input { grid-template-columns: 1fr auto; gap: 10px; }
body .assistant-chat .chat-input input {
  background: var(--hm-card); color: var(--hm-ink); border: 1px solid var(--hm-line); border-radius: 999px; padding: 15px 22px; font-size: 15px; box-shadow: var(--hm-shadow);
}
body .assistant-chat .chat-input button {
  border-radius: 999px; padding: 0 24px; color: #fff; background: linear-gradient(135deg, #27a8ff, #0a66f2); box-shadow: 0 8px 20px rgba(10, 102, 242, .28);
}

@media (max-width: 900px) {
  body .assistant-chat.show .chat-suggestion-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .home-top-controls { position: static; justify-content: flex-end; margin-bottom: 10px; }
  body .panel-section[data-section="Inicio"] .home-actions-wrap { grid-template-columns: 1fr; }
  body .panel-section[data-section="Inicio"] .home-actions-wrap > button { min-height: 76px; }
  body .assistant-chat .chat-empty-welcome-wrap { flex-direction: column; text-align: center; }
  body .assistant-chat .chat-empty-welcome { border-left: 0; padding-left: 0; }
  body .assistant-chat.show .chat-suggestion-row { grid-template-columns: 1fr; }
}

/* ── Llamadas 1:1 (programa de 90 días) ── */
.calls-card { background: var(--sn-bg); border: 1px solid var(--sn-border); border-radius: 18px; padding: 16px 18px; margin-bottom: 14px; }
.calls-card[hidden] { display: none; }
.cc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cc-head strong { font-size: 17px; color: var(--sn-text); }
.cc-day { font-size: 13px; color: var(--sn-muted); }
.cc-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cc-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--sn-border); border-radius: 14px; background: var(--sn-card); }
.cc-step.is-next { border-color: var(--sn-accent-line); background: var(--sn-accent-soft); }
.cc-step.is-done { opacity: .85; }
.cc-dot { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--sn-hover); color: var(--sn-text); }
.cc-step.is-next .cc-dot { background: var(--sn-accent); color: #fff; }
.cc-step.is-done .cc-dot { background: var(--sn-accent-2); color: #fff; }
.cc-txt { display: grid; gap: 2px; font-size: 13px; color: var(--sn-muted); }
.cc-txt strong { color: var(--sn-text); font-size: 14px; }
.cc-tip { margin: 12px 0 0; font-size: 14px; color: var(--sn-text); }
.calls-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 22px; background: var(--hm-card, #fff); border: 1px solid var(--hm-line, var(--sn-border)); box-shadow: var(--hm-shadow, none); }
.calls-banner .cb-icon { font-size: 26px; }
.calls-banner .cb-txt { flex: 1; min-width: 200px; display: grid; gap: 2px; font-size: 14px; color: var(--hm-muted, var(--sn-muted)); }
.calls-banner .cb-txt strong { color: var(--hm-ink, var(--sn-text)); font-size: 15.5px; }
.calls-banner .cb-later { background: none; border: 0; color: var(--hm-muted, var(--sn-muted)); font-size: 13px; text-decoration: underline; cursor: pointer; }
.sp-program { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--sn-border); font-size: 13px; color: var(--sn-muted); }
.sp-prog-main { font-weight: 600; color: var(--sn-text); }
.sp-prog-start input { font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--sn-border); border-radius: 8px; background: var(--sn-card); color: var(--sn-text); }
.sp-prog-btn { font: inherit; font-size: 13px; padding: 5px 10px; border-radius: 10px; border: 1px solid var(--sn-accent-line); background: var(--sn-accent-soft); color: var(--sn-text); cursor: pointer; }
.sp-prog-undo { background: none; border: 0; color: var(--sn-muted); font-size: 13px; text-decoration: underline; cursor: pointer; }
.sp-program button:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) { .cc-steps { grid-template-columns: 1fr; } }


/* Tarjeta de programa en Llamadas 1:1 (mismo estilo que el Inicio) */
.calls-card { background: var(--hm-card, #fff); border: 1px solid var(--hm-line, var(--sn-border)); border-radius: 26px; padding: 22px 24px; box-shadow: var(--hm-shadow, none); }
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cc-top-txt { display: grid; gap: 2px; }
.cc-top-txt strong { font-size: clamp(1.25rem, 2.2vw, 1.6rem); font-weight: 800; letter-spacing: -0.01em; color: var(--hm-ink, var(--sn-text)); }
.cc-top-txt span { font-size: 14px; color: var(--hm-muted, var(--sn-muted)); }
.cc-renew { font: inherit; font-size: 14px; font-weight: 600; color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; background: linear-gradient(135deg, #27a8ff, #0a66f2); box-shadow: 0 8px 20px rgba(10, 102, 242, .25); }
.cc-bar { height: 8px; border-radius: 999px; background: var(--hm-soft, #dbeafe); margin: 14px 0 20px; overflow: hidden; }
.cc-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #27a8ff, #0a66f2); }
.cc-calls-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; color: var(--hm-ink, var(--sn-text)); }
.cc-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cc-step { border-radius: 18px; border: 1px solid var(--hm-line, var(--sn-border)); background: transparent; }
.cc-step.is-next { border-color: #1d6df2; background: var(--hm-soft, #dbeafe); }
.cc-step.is-next .cc-dot { background: #1d6df2; }
.cc-step.is-done .cc-dot { background: #0ea5e9; }
body.theme-dark .cc-step.is-next { background: rgba(56, 189, 248, 0.14); }

/* Que ningún estilo antiguo aplane el degradado del botón principal del Inicio */
body .panel-section[data-section="Inicio"] .home-actions-wrap > .home-btn-primary {
  background: radial-gradient(120% 160% at 85% 120%, #0a5cf0 0%, transparent 60%), linear-gradient(135deg, #27a8ff, #0a66f2) !important;
  color: #fff !important;
  opacity: 1 !important;
}

/* Respuestas de la IA: más claras y fáciles de escanear */
body .chat-message.ai { padding: 18px 22px 18px 56px; line-height: 1.55; font-size: 15.5px; max-width: min(88%, 760px); }
body .chat-message.ai p { margin: 0 0 12px; }
body .chat-message.ai > p:first-of-type { font-size: 16.5px; font-weight: 600; color: var(--hm-ink, var(--text)); }
body .chat-message.ai strong { font-weight: 700; color: #0a56d6; }
body.theme-dark .chat-message.ai strong { color: #7cc4ff; }
body .chat-message.ai ol, body .chat-message.ai ul { margin: 6px 0 12px; padding: 0; list-style: none; counter-reset: ai-step; }
body .chat-message.ai ol > li, body .chat-message.ai ul > li {
  position: relative; margin: 0 0 8px; padding: 10px 14px 10px 46px; border-radius: 14px;
  background: var(--hm-soft, rgba(37, 99, 235, 0.07)); border: 1px solid var(--hm-line, rgba(37, 99, 235, 0.12));
}
body .chat-message.ai ol > li { counter-increment: ai-step; }
body .chat-message.ai ol > li::before {
  content: counter(ai-step); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #27a8ff, #0a66f2);
}
body .chat-message.ai ul > li::before { content: ""; position: absolute; left: 18px; top: 19px; width: 8px; height: 8px; border-radius: 50%; background: #1d6df2; }
body .chat-message.ai li p { margin: 0; }
body .chat-message.ai > p:last-child:not(:first-child) { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--hm-line, rgba(37, 99, 235, 0.15)); color: var(--hm-muted, var(--muted)); }

/* Lo que iDT ha aprendido */
.lr-card h3 { margin: 0 0 8px; }
.lr-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.lr-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--sn-border); border-radius: 14px; background: var(--sn-card); font-size: 14px; }
.lr-tag { flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--sn-accent-soft); color: var(--sn-text); }
.lr-funciona .lr-tag { background: rgba(16, 185, 129, .16); }
.lr-no_funciona .lr-tag { background: rgba(245, 158, 11, .18); }
.lr-text { flex: 1; color: var(--sn-text); }
.lr-x { background: none; border: 0; color: var(--sn-muted); cursor: pointer; font-size: 14px; }

/* ── Límite diario del chat ───────────────────────────── */
.cl-pill { margin: 0 0 8px; padding: 7px 12px; border-radius: 999px; font-size: 13px; line-height: 1.35; text-align: center; border: 1px solid rgba(128,128,128,.28); background: rgba(128,128,128,.08); }
.cl-pill[hidden], .cl-tip[hidden] { display: none; }
.cl-pill.is-low { border-color: rgba(217,150,0,.55); background: rgba(217,150,0,.12); }
.cl-pill.is-zero { border-color: rgba(200,60,60,.5); background: rgba(200,60,60,.1); }
.cl-tip { margin: 12px auto 0; max-width: 560px; padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(128,128,128,.25); background: rgba(128,128,128,.06); font-size: 14px; line-height: 1.45; }
.cl-tip summary { cursor: pointer; font-weight: 600; }
.cl-tip-body p { margin: 8px 0 0; }
.cl-tip-body ul { margin: 6px 0 0; padding-left: 20px; }
.cl-tip-body li { margin: 2px 0; }

/* Inicio unificado: las sugerencias no se quedan pegadas arriba al hacer scroll */
body .assistant-chat .chat-suggestion-row { position: static; }

/* Soporte: el cuadro de texto no recorta la primera línea en móvil */
.sp-input { box-sizing: border-box; min-height: 44px; line-height: 1.3; }

/* Escritorio: la barra del chat (contador + cuadro de escribir) queda siempre visible abajo */
@media (min-width: 961px) {
  body .assistant-chat .chat-messages { min-height: 120px; }
  body .assistant-chat .chat-input { position: sticky; bottom: 16px; z-index: 20; }
  body .assistant-chat .cl-pill { position: sticky; bottom: 74px; z-index: 20; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}

/* Perfil simplificado: ocultos Mis logros, Mis macros y Test Basal (siguen en el código por si se reactivan) */
body .profile-achievements-body,
body #profile-macros-body,
body .profile-subtab[data-profile-view="test-basal"],
body .profile-panel-view[data-profile-panel="test-basal"] { display: none !important; }

/* ── Vídeo de bienvenida ───────────────────────────── */
.wv-modal { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 14, 30, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: wv-fade .25s ease; }
.wv-modal[hidden] { display: none; }
body.wv-open { overflow: hidden; }
.wv-card { position: relative; width: min(960px, 100%); max-height: 100%; overflow: auto; background: var(--sn-bg, #fff); color: var(--sn-text, #0f172a); border-radius: 22px; padding: 26px 26px 22px; box-shadow: 0 30px 80px rgba(8, 12, 30, .45); animation: wv-pop .3s ease; }
.wv-head h2 { margin: 0 44px 6px 0; font-size: clamp(1.25rem, 2.4vw, 1.7rem); line-height: 1.2; }
.wv-head p { margin: 0 0 16px; opacity: .72; font-size: .95rem; }
.wv-player { aspect-ratio: 16 / 9; background: #101528; border-radius: 14px; overflow: hidden; }
.wv-player video { width: 100%; height: 100%; display: block; background: #101528; }
.wv-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.wv-skip { background: none; border: 0; padding: 10px 12px; font: inherit; color: inherit; opacity: .7; cursor: pointer; border-radius: 10px; }
.wv-skip:hover { opacity: 1; }
.wv-go { border: 0; cursor: pointer; font: inherit; font-weight: 700; color: #fff; padding: 12px 26px; border-radius: 12px; background: linear-gradient(90deg, #3F7FE0, #4FA58F); box-shadow: 0 8px 20px rgba(63, 127, 224, .28); }
.wv-go:hover { filter: brightness(1.05); }
.wv-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; background: rgba(120, 130, 160, .16); color: inherit; font-size: 1rem; }
.wv-close:hover { background: rgba(120, 130, 160, .3); }
.wv-modal button:focus-visible { outline: 3px solid #3F7FE0; outline-offset: 2px; }
.wv-entry { display: flex; align-items: center; gap: 16px; width: 100%; margin: 0 0 18px; padding: 16px 20px; border: 1.5px solid rgba(63, 127, 224, .28); border-radius: 18px; cursor: pointer; text-align: left; font: inherit; color: inherit; background: linear-gradient(100deg, rgba(63, 127, 224, .10), rgba(79, 165, 143, .12)); transition: transform .15s ease, box-shadow .15s ease; }
.wv-entry[hidden] { display: none; }
.wv-entry:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(63, 127, 224, .16); }
.wv-entry:focus-visible { outline: 3px solid #3F7FE0; outline-offset: 2px; }
.wv-entry-play { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #3F7FE0, #4FA58F); }
.wv-entry-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wv-entry-text strong { font-size: 1.05rem; }
.wv-entry-text small { opacity: .7; }
.wv-entry-cta { flex: none; font-weight: 700; color: #3F7FE0; }
@keyframes wv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wv-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .wv-card { padding: 18px 16px 16px; border-radius: 18px; } .wv-entry-cta { display: none; } }
@media (prefers-reduced-motion: reduce) { .wv-modal, .wv-card { animation: none; } .wv-entry { transition: none; } }
