/* ============================================
   KAITO · DESIGN SYSTEM v2
   Mobile-first · Desktop adaptativo · Dark mode
   Paleta: Cream #F9F7F2 · Charcoal #111827
           Terracotta #E87A3C · Forest #2E7D5A
   Tipografía: Space Grotesk
   ============================================ */

/* ============ TOKENS · TEMA CLARO ============ */
:root {
  color-scheme: light;

  /* --- Brand --- */
  --cream: #F9F7F2;
  --charcoal: #111827;
  --terracotta: #E87A3C;
  --terracotta-dark: #C9612A;
  --terracotta-ink: #B85A24;      /* terracotta legible sobre cream */
  --forest: #2E7D5A;
  --forest-dark: #256B4C;
  --forest-bright: #43A06F;

  /* --- Superficies --- */
  --bg-base: #F9F7F2;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F4EFE3;
  --bg-hover: #EFE8D8;
  --bg-hover-soft: #FFFDF8;       /* hover sutil de filas/cards */

  /* --- Chrome translúcido (header / nav) --- */
  --header-bg: rgba(249, 247, 242, 0.88);
  --nav-bg: rgba(249, 247, 242, 0.92);

  /* --- Aliases (los usa el JS en estilos inline) --- */
  --accent: #E87A3C;
  --accent-light: #B85A24;
  --accent-glow: rgba(232, 122, 60, 0.22);
  --accent-dim: rgba(232, 122, 60, 0.12);

  --success: #2E7D5A;
  --success-dim: rgba(46, 125, 90, 0.12);
  --warning: #B45309;
  --warning-dim: rgba(180, 83, 9, 0.12);
  --danger: #D64545;
  --danger-dim: rgba(214, 69, 69, 0.10);

  --text-primary: #111827;
  --text-secondary: #5C6470;
  --text-muted: #9AA1AD;

  --border: #E9E2D2;
  --border-hover: #DED4BC;
  --border-accent: rgba(232, 122, 60, 0.45);
  --border-focus: rgba(232, 122, 60, 0.55);

  /* --- Checks (checkbox / hábitos) --- */
  --check-border: #C9C0AC;
  --check-bg: #FFFFFF;

  /* --- Toast & banners --- */
  --toast-bg: #111827;
  --toast-color: #FFFFFF;

  /* --- Degradé tarjeta "hoy" (vista semana) --- */
  --today-gradient: linear-gradient(180deg, #FFFDF8 0%, #FFF9EF 100%);

  /* --- Scrollbar --- */
  --scroll-thumb: #D8CFBB;
  --scroll-thumb-hover: #C6B99F;

  /* --- Forma y ritmo --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  --nav-height: 66px;
  --header-height: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --shadow-card: 0 4px 18px -4px rgba(17, 24, 39, 0.10);
  --shadow-pop: 0 12px 32px -8px rgba(17, 24, 39, 0.18);
  --shadow-glow: 0 4px 14px var(--accent-glow);

  --transition: 0.18s cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Layout --- */
  --content-max: 680px;
}

/* ============ TOKENS · TEMA OSCURO ============ */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-base: #111827;
  --bg-surface: #1B2436;
  --bg-elevated: #232E45;
  --bg-hover: #2A3752;
  --bg-hover-soft: #1E2740;

  --header-bg: rgba(17, 24, 39, 0.84);
  --nav-bg: rgba(17, 24, 39, 0.9);

  --text-primary: #F9F7F2;
  --text-secondary: #B9C0CE;
  --text-muted: #7E8798;

  --border: #2E3A54;
  --border-hover: #3D4B6B;

  --terracotta-ink: #F2995C;
  --forest: #4CAF7D;
  --forest-dark: #3A9A68;
  --forest-bright: #6FD598;

  --accent-light: #F2995C;
  --accent-glow: rgba(232, 122, 60, 0.35);
  --accent-dim: rgba(232, 122, 60, 0.16);

  --success: #4CAF7D;
  --success-dim: rgba(76, 175, 125, 0.16);
  --warning: #E8A33C;
  --warning-dim: rgba(232, 163, 60, 0.16);
  --danger: #E87373;
  --danger-dim: rgba(232, 115, 115, 0.14);

  --check-border: #4A5A7A;
  --check-bg: #232E45;

  --toast-bg: #232E45;
  --toast-color: #F9F7F2;

  --today-gradient: linear-gradient(180deg, #232E45 0%, #1E2740 100%);

  --scroll-thumb: #3D4B6B;
  --scroll-thumb-hover: #4A5A7A;

  --shadow-card: 0 4px 18px -4px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

::selection {
  background: var(--accent-dim);
}

.hidden {
  display: none !important;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* ============================================
   HEADER
   ============================================ */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--header-height) + var(--safe-top));
  background: var(--header-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-height);
  padding: 0 20px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(232, 122, 60, 0.35);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Campanita de notificaciones (anuncios premium). */
.notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.header-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.header-date.clickable {
  cursor: pointer;
  user-select: none;
}
.header-date.clickable:hover {
  color: var(--terracotta-ink);
  border-color: var(--border-accent);
}

/* Botón del selector de tema */
.theme-toggle {
  font-size: 15px;
  line-height: 1;
}

/* --- Navegación desktop (oculta en móvil) --- */
#desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.dnav-item {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  transition: all var(--transition);
  position: relative;
}

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

.dnav-item.active {
  color: var(--terracotta-ink);
  background: var(--accent-dim);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
#app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: calc(var(--header-height) + var(--safe-top));
  margin-bottom: calc(var(--nav-height) + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

#view-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 20px 20px 8px;
  min-height: 100%;
  animation: fadeIn 0.25s ease-out;
}

/* v170: refresco suave al volver a la pestaña — mientras se re-renderiza no
   hay animaciones ni transiciones (ni la del contenedor), así no se nota la
   recarga. El router agrega/quita la clase .sin-anim automáticamente. */
#view-container.sin-anim,
#view-container.sin-anim *,
#view-container.sin-anim *::before,
#view-container.sin-anim *::after {
  animation: none !important;
  transition: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   BOTTOM NAV (móvil)
   ============================================ */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-height) + var(--safe-bottom));
  display: flex;
  justify-content: center;
}

#bottom-nav .nav-inner {
  width: 100%;
  max-width: var(--content-max);
  display: flex;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  transition: color var(--transition);
  position: relative;
}

.nav-item svg {
  width: 21px;
  height: 21px;
  transition: transform var(--transition);
}

.nav-item:active svg {
  transform: scale(0.9);
}

.nav-item.active {
  color: var(--terracotta-ink);
}

.nav-item.active svg {
  filter: drop-shadow(0 2px 5px var(--accent-glow));
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 3px;
  background: var(--terracotta);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}

/* Separador inferior de vistas (reemplaza divs con style inline). */
.view-spacer {
  height: 20px;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title-icon {
  font-size: 14px;
}

/* Tarjeta del día actual (vista semana) */
.today-card {
  border-color: var(--border-accent);
  background: var(--today-gradient);
  box-shadow: var(--shadow-glow);
}

/* Tarjeta "Destacado del día": degradé terracotta sutil */
.destacado-card {
  background: linear-gradient(180deg, rgba(232, 122, 60, 0.10) 0%, rgba(232, 122, 60, 0.03) 100%);
}

[data-theme="dark"] .destacado-card {
  background: linear-gradient(180deg, rgba(232, 122, 60, 0.20) 0%, rgba(232, 122, 60, 0.06) 100%);
  border-color: rgba(232, 122, 60, 0.30);
  box-shadow: 0 4px 18px -4px rgba(232, 122, 60, 0.28);
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  margin-top: 24px;
}

.section-header:first-child {
  margin-top: 0;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================
   TASK ITEMS
   ============================================ */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.task-item:hover {
  border-color: var(--border-accent);
  background: var(--bg-hover-soft);
}

.task-item:active {
  transform: scale(0.99);
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--check-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  background: var(--check-bg);
}

.task-item:hover .task-checkbox {
  border-color: var(--terracotta);
}

.task-item.completed .task-checkbox {
  background: var(--forest);
  border-color: var(--forest);
  box-shadow: 0 0 0 4px var(--success-dim);
}

.task-item.completed .task-checkbox::after {
  content: '✓';
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.task-item.completed .task-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Anti-farming: en días distintos de hoy los toggles se ven bloqueados
   (el click muestra un toast; el backend rechaza de todos modos). */
.task-item.locked,
.habit-item.locked {
  cursor: not-allowed;
}
.task-item.locked .task-checkbox,
.habit-item.locked .habit-toggle {
  opacity: 0.3;
}
.task-item.locked:hover .task-checkbox {
  border-color: var(--border);
}
/* Insignia sutil de "modo planificación" cuando se navega a otro día. */
.plan-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.task-content {
  flex: 1;
  min-width: 0;
}

.task-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

/* v138: descripción de la tarea (debajo del título) + icono de tipo */
.task-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* v213: ningún texto de usuario desborda su tarjeta (links largos sin
   espacios, p. ej. URLs pegadas). Antes solo .task-text/.task-desc existían
   sin corte; en móvil (~360px) el link se salía de los bordes. */
.habit-name,
.nota-md,
.destacado-texto {
  overflow-wrap: anywhere;
}
.tipo-icon {
  margin-right: 4px;
  font-size: 13px;
}

/* v138: badge "vencido/a" en Admin (plan y códigos promo) */
.badge-vencido {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #e8a13c;
  background: rgba(232, 161, 60, 0.12);
  border: 1px solid rgba(232, 161, 60, 0.35);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 4px;
  white-space: nowrap;
}

/* v138: celda de la matriz semanal en un día donde el hábito no aplica */
.grid-dot-off {
  opacity: 0.22;
  transform: scale(0.8);
  cursor: default;
}

.task-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

/* ============================================
   HABIT ITEMS & XP BARS
   ============================================ */
.habit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.habit-item:hover {
  border-color: var(--border-accent);
}

.habit-item.done {
  background: var(--success-dim);
  border-color: rgba(46, 125, 90, 0.35);
}

.habit-toggle {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--check-border);
  background: var(--check-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.habit-item.done .habit-toggle {
  background: var(--forest);
  border-color: var(--forest);
  box-shadow: 0 0 0 4px var(--success-dim);
}

.habit-item.done .habit-toggle::after {
  content: '✓';
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

/* Barra de progreso — limpia, con brillo superior sutil */
.progress-bar-wrap {
  position: relative;
  background: var(--bg-elevated);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  position: relative;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--forest) 0%, var(--forest-bright) 100%);
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Highlight superior para darle profundidad */
.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.30) 0%, rgba(255,255,255,0) 60%);
}

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--terracotta), var(--forest-bright));
  opacity: 0.85;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Donaciones (Perfil): tarjeta interna con aire propio. */
.don-card {
  background: linear-gradient(180deg, rgba(232, 122, 60, 0.10), rgba(232, 122, 60, 0.03));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin: 18px 0 20px;
}
.don-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
}
.don-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  line-height: 1.6;
}
.don-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.don-preset {
  width: 100%;
  padding: 12px 4px;
  font-size: 14px;
  font-weight: 700;
}
.don-preset.active {
  background: var(--terracotta);
  color: #ffffff;
  border-color: var(--terracotta);
  box-shadow: 0 3px 12px var(--accent-glow);
}
.don-input {
  margin-bottom: 10px;
}
.don-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  margin-top: 4px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: saturate(0.35);
}

/* Validación preventiva de formularios: marcar en el campo, no después con un error */
.req {
  color: var(--danger);
  font-weight: 800;
}
.form-input.invalid {
  border-color: var(--danger);
}
.form-error {
  display: none;
  font-size: 12px;
  color: var(--danger);
  margin: 6px 0 0;
  font-weight: 600;
}
/* v137: aviso de solapamiento de horarios (advertencia, no error: no bloquea). */
.solap-aviso {
  font-size: 12px;
  line-height: 1.5;
  color: var(--warning);
  background: var(--warning-dim);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 0 0 12px;
}
.solap-aviso[hidden] {
  display: none;
}

.btn-primary {
  background: var(--terracotta);
  color: #ffffff;
  box-shadow: 0 3px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--terracotta-dark);
}

.btn-ghost {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--terracotta-ink);
  border-color: var(--border-accent);
  background: var(--bg-hover-soft);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================
   FORMS & MODAL
   ============================================ */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="checkbox"].toggle-objetivo {
  width: 20px;
  height: 20px;
  accent-color: var(--terracotta);
  cursor: pointer;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow-pop);
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* v149: los textarea de los modales solo se estiran en vertical y nunca más
   anchos que el modal — antes, agrandarlos arrastraba el mouse fuera del modal
   y el modal se cerraba solo. */
.modal-box textarea {
  resize: vertical;
  max-width: 100%;
}

@keyframes modalScale {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 30px;
  height: 30px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ============================================
   DATE NAV & BADGES
   ============================================ */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.date-nav-label {
  display: block;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.01em;
}

.date-nav-sub {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.date-nav-btn {
  width: 34px;
  height: 34px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.date-nav-btn:hover {
  color: var(--terracotta-ink);
  border-color: var(--border-accent);
  background: var(--bg-hover-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.badge-top3 {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(180, 83, 9, 0.3);
}

/* ============================================
   HABIT WEEK MATRIX (vista semana)
   ============================================ */
.habit-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.habit-grid-table th {
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 2px;
  text-align: center;
  font-size: 11px;
}

.habit-grid-table td {
  padding: 5px 2px;
  text-align: center;
}

.habit-grid-name {
  text-align: left !important;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-dot {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  margin: 0 auto;
  transition: all var(--transition);
}

.grid-dot.done {
  background: var(--forest);
  border-color: var(--forest);
  box-shadow: 0 0 0 3px var(--success-dim);
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
  filter: saturate(0.85);
}

.empty-state-text {
  font-size: 13px;
  font-weight: 500;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(12px);
  z-index: 3000;
  max-width: calc(100vw - 40px);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--toast-color);
  background: var(--toast-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  background: var(--forest);
  border-color: transparent;
  color: #fff;
}

.toast-error {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

/* ============================================
   LOADING
   ============================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 4px solid var(--accent-dim);
  border-top-color: var(--terracotta);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   SYNC BANNER (offline / sincronización)
   ============================================ */
.sync-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 10px;
  letter-spacing: 0.02em;
}

.sync-banner.offline {
  background: var(--toast-bg);
  color: var(--toast-color);
}

.sync-banner.syncing {
  background: var(--terracotta);
  color: #fff;
}

/* v209: banner de email sin verificar (fijo arriba, ámbar). */
.verify-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 10px;
  background: var(--warning-bg, #fef3c7);
  color: var(--warning-fg, #92400e);
  border-bottom: 1px solid var(--warning-border, #fcd34d);
}
.verify-banner button {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.verify-banner button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ============================================
   AUTH GATE (branding Kaito)
   ============================================ */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  text-align: center;
}

.auth-brand .brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(232, 122, 60, 0.4);
}

.auth-brand h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0;
}

.auth-brand .tagline {
  font-size: 13px;
  font-weight: 600;
  color: var(--terracotta-ink);
}

/* ============================================
   SCROLLBAR & MOTION
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   TABLET · pantallas medianas
   ============================================ */
@media (min-width: 700px) {
  :root {
    --content-max: 860px;
  }

  .stats-grid {
    gap: 14px;
  }

  .stat-card {
    padding: 20px;
  }

  .stat-value {
    font-size: 32px;
  }
}

/* ============================================
   DESKTOP · pantallas grandes
   - Contenido ancho, nav superior, grillas por vista
   - El móvil queda intacto: todo esto solo aplica ≥1024px
   ============================================ */
@media (min-width: 1024px) {
  :root {
    --content-max: 1120px;
    --header-height: 68px;
  }

  /* --- Chrome desktop --- */
  .header-inner {
    padding: 0 32px;
  }

  /* --- Greedy nav desktop (priority+): el nav muestra los ítems que
         entran y los que sobran van al menú "Más ▾". Evita el corte del
         menú en pantallas de 1024–1280px sin sidebar. --- */
  .header-actions {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
  }

  #desktop-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 1 auto;
    min-width: 0;
    margin-right: 6px;
  }

  /* Los ítems no se achican: si no entran, el JS los mueve a "Más". */
  #desktop-nav > .dnav-item,
  #desktop-nav > .dnav-more {
    flex-shrink: 0;
  }

  /* Botón "Más": misma pill que los ítems. */
  .dnav-more {
    position: relative;
  }

  .dnav-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
  }

  .dnav-more-caret {
    font-size: 11px;
    line-height: 1;
    transition: transform var(--transition);
  }

  .dnav-more-btn[aria-expanded="true"] .dnav-more-caret {
    transform: rotate(180deg);
  }

  /* Dropdown de "Más": menú absoluto bajo el header.
     NOTA: el `display` base es `none` a propósito — la regla de autor
     `display:flex` pisaría el `[hidden]` del UA stylesheet y el menú
     quedaría siempre visible (el toggle parecía "trabado"). Solo se muestra
     con :not([hidden]). */
  .dnav-more-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 190px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    z-index: 120;
  }

  .dnav-more-menu:not([hidden]) {
    display: flex;
  }

  .dnav-more-menu .dnav-item {
    white-space: nowrap;
    text-align: left;
  }


  #bottom-nav {
    display: none;
  }

  #app-main {
    margin-bottom: 0;
  }

  #view-container {
    padding: 28px 32px 48px;
  }

  .app-title {
    font-size: 23px;
  }

  .toast {
    bottom: 28px;
  }

  .modal-box {
    max-width: 520px;
  }

  /* --- Vista DÍA: dos columnas --- */
  .dia-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 22px;
    align-items: start;
  }

  .dia-grid .dia-col > .section-header:first-child {
    margin-top: 0 !important;
  }

  /* --- Vista RESUMEN: Hoy | Mes lado a lado --- */
  .resumen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
    grid-template-areas:
      "hoy mes"
      "semana semana";
    margin-bottom: 14px;
  }

  .resumen-grid .resumen-hoy {
    grid-area: hoy;
    margin-bottom: 0;
    height: 100%;
  }

  .resumen-grid .resumen-mes {
    grid-area: mes;
    margin-bottom: 0;
    height: 100%;
  }

  .resumen-grid .stats-grid {
    grid-area: semana;
    margin-bottom: 0;
  }

  .consejos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .consejos-grid .card {
    margin-bottom: 0;
  }

  /* --- Vista SEMANA: días en grilla --- */
  .days-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
  }

  .days-grid .card {
    margin-bottom: 0;
  }

  /* --- Vista MES: objetivos | proyectos --- */
  .mes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
  }

  .mes-grid > div > .section-header:first-child {
    margin-top: 0 !important;
  }

  /* v139 · Vista MES en escritorio (pedido de Leo, solo desktop):
     - La reflexión de la evaluación baja a su propia fila (antes quedaba
       como tercer ítem flex al lado del puntaje/texto, desalineada).
     - "Cumplimiento de Hábitos" ocupa ambas columnas: evita el hueco vacío
       a la derecha cuando las columnas de arriba tienen distinta altura. */
  .mes-eval-row { flex-wrap: wrap; }
  .mes-eval-reflexion { flex: 1 1 100%; margin-top: 4px; }
  .mes-habitos-full { grid-column: 1 / -1; }
  .mes-habitos-full > .section-header:first-child { margin-top: 0 !important; }

  /* --- Vista STATS: hábitos en dos columnas --- */
  .habit-rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 18px;
  }

  /* --- Vista BACKLOG: tareas en dos columnas --- */
  #backlog-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #backlog-list .task-item {
    margin-bottom: 0;
  }

  #backlog-list .empty-state {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  /* --- Stat cards más aireadas --- */
  .stat-card {
    padding: 22px;
  }

  /* v101: se revierten las grillas desktop de Perfil/Notas/Metas del v100
     (rompían el layout: Notas agrupa por día con headers intercalados y
     Perfil/Metas no son listas planas). Vuelven a una columna.
     Las grillas de Día/Resumen/Semana/Mes/Stats/Backlog se mantienen. */
}

/* Pantallas muy anchas: el contenido respira más. */
@media (min-width: 1600px) {
  :root {
    --content-max: 1280px;
  }
}

/* ============================================
   Greedy nav · ajustes de ancho
   - El header estaba limitado a 1120px también a 1920px de viewport, así
     que el nav se encogía por flexbox y el greedy escondía ítems sin
     necesidad. En pantallas grandes el header respira (el contenido de la
     página sigue en 1120px).
   - En 1024–1499px los ítems van apenas más compactos para que "Más ▾"
     aparezca solo con desborde real. La estética no cambia.
   ============================================ */
@media (min-width: 1500px) {
  .header-inner {
    max-width: 1440px;
  }
}

@media (min-width: 1024px) and (max-width: 1499px) {
  #desktop-nav {
    gap: 2px;
  }

  .dnav-item {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* ============================================
   Fase 1: perfil + gamificación + admin
   Solo variables CSS (dark mode automático).
   Mobile-first.
   ============================================ */

/* --- Tarjeta de compañero (perfil) --- */
.companion-card {
  padding: 18px;
}

.companion-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.companion-img {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  background: var(--bg-elevated);
  border: 2px solid var(--border-accent);
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.companion-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.companion-info {
  min-width: 0;
}

.companion-stage {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.companion-level {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* v124 · poder pasivo del compañero activo (héroe del perfil). */
.companion-power {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent, #ffb020);
}

/* v124 · compañero bloqueado: silueta negra + "Se desbloquea en nivel X". */
.companion-silhouette {
  filter: brightness(0);
}

/* v210 · barra y etiqueta de XP propia del compañero (héroe del perfil). */
.companion-xp-bar {
  height: 8px;
}
.companion-xp-label {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Barra XP: reutiliza .progress-bar-wrap/.progress-bar-fill, más fina */
.xp-bar {
  height: 8px;
}

/* --- Grilla de insignias --- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.badge-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition);
}

.badge-item .badge-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

.badge-item.locked {
  filter: grayscale(1);
  opacity: 0.55;
}

.badge-item.locked .badge-img {
  opacity: 0.5;
}

.badge-lock {
  font-size: 26px;
  line-height: 52px;
  height: 52px;
  margin-bottom: 8px;
}

.badge-name {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.badge-date {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.badge-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.companion-slot-active {
  border: 2px solid var(--border-accent);
  box-shadow: var(--shadow-glow);
}

/* --- Badge de plan --- */
.plan-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

.plan-badge-free {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.plan-badge-premium {
  background: var(--accent-dim);
  color: var(--accent-light);
  border: 1px solid var(--border-accent);
}

/* --- Tabs de admin --- */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.admin-tab {
  flex: 1;
  white-space: nowrap;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.admin-tab.active {
  color: var(--text-primary);
  background: var(--accent-dim);
  border-color: var(--border-accent);
}

/* --- Layout propio del admin (v105, opción B): sidebar + contenido --- */
.admin-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.admin-sidebar {
  position: sticky;
  top: 76px;
  flex: 0 0 232px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.admin-side-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  padding: 6px 10px 12px;
}

.admin-side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-side-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
}

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

.admin-side-item.active {
  color: var(--text-primary);
  background: var(--accent-dim);
  border-color: var(--border-accent);
}

.admin-main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
    /* v139: causa raíz del scroll horizontal roto en la tabla de usuarios
       (móvil). Con align-items:flex-start heredado del desktop, .admin-main
       se achicaba al contenido (fit-content) en vez de llenar el ancho: la
       tabla con min-width agrandaba el contenedor en lugar de desbordar el
       wrap, y las columnas quedaban cortadas sin scroll. Con stretch,
       .admin-main llena el ancho y el scroll del .admin-table-wrap funciona. */
    align-items: stretch;
  }
  /* v107: en móvil el sidebar horizontal con scroll se veía mal.
     Se reemplaza por una grilla compacta de 3 columnas, sin scroll. */
  .admin-sidebar {
    position: static;
    flex: none;
    width: 100%;
    padding: 10px;
  }
  .admin-side-title {
    padding: 2px 4px 8px;
    font-size: 13px;
  }
  .admin-side-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    overflow: visible;
    padding-bottom: 0;
  }
  .admin-side-item {
    white-space: normal;
    text-align: center;
    padding: 9px 6px;
    font-size: 12px;
    line-height: 1.25;
    background: var(--bg);
    border-color: var(--border);
  }
  .admin-side-item.active {
    background: var(--accent-dim);
    border-color: var(--border-accent);
  }
}

@media (max-width: 420px) {
  .admin-side-nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* v107 · bloque "¿Cómo gano monedas?" en Perfil → Mi compañero. */
.monedas-ayuda {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.monedas-ayuda strong {
  color: var(--text-primary);
}
.monedas-ayuda p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Tablas de admin --- */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* v139: scroll táctil con inercia en iOS */
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.admin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

/* --- Filas de configuración --- */
.admin-config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

.admin-config-row:last-child {
  border-bottom: none;
}

.admin-config-key {
  flex: 0 0 110px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- v143: interruptor (toggle) --- */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .slider {
  background: var(--accent);
  border-color: transparent;
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
}
.switch input:focus-visible + .slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- v143: Configuración rediseñada (mobile-first) --- */
.cfg-search-wrap {
  margin-bottom: 10px;
}
.cfg-search-wrap .form-input {
  width: 100%;
}
.cfg-group {
  margin-bottom: 10px;
  overflow: hidden;
}
.cfg-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
  font-family: inherit;
}
.cfg-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.cfg-chevron {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.2s;
  font-size: 13px;
}
.cfg-group.closed .cfg-group-body {
  display: none;
}
.cfg-group.closed .cfg-chevron {
  transform: rotate(-90deg);
}
.cfg-group-body {
  padding: 0 12px 6px;
}
.cfg-field {
  padding: 10px 2px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.cfg-field:last-child {
  border-bottom: none;
}
.cfg-label {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}
.cfg-key {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.cfg-help {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 8px;
  line-height: 1.45;
}
.cfg-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.cfg-row .form-input {
  flex: 1 1 100%;
  min-width: 0;
}
.cfg-row .btn {
  flex: 1 1 auto;
}
@media (min-width: 640px) {
  .cfg-row {
    flex-wrap: nowrap;
  }
  .cfg-row .form-input {
    flex: 1 1 auto;
  }
  .cfg-row .btn {
    flex: 0 0 auto;
  }
}
.cfg-state {
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 0;
}
.cfg-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 12px;
}
.cfg-link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  font-size: 13px;
  color: var(--text-secondary);
}
.cfg-link-card p {
  margin: 0;
  flex: 1;
}

/* --- Modal de evolución / subida de nivel --- */
.evolution-modal {
  text-align: center;
  padding: 8px 0 4px;
}

.evolution-img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-xl);
  border: 3px solid var(--border-accent);
  box-shadow: var(--shadow-glow);
  margin-bottom: 14px;
}

.evolution-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px;
  line-height: 1.5;
}

/* --- Overlay de logro: insignia desbloqueada --- */
#badge-achievement-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 20, 0.82);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

#badge-achievement-overlay.show {
  opacity: 1;
}

.badge-achievement-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-accent, #f97316);
  border-radius: var(--radius-xl, 20px);
  box-shadow: var(--shadow-glow, 0 0 40px rgba(249, 115, 22, 0.35));
  padding: 32px 24px 24px;
  transform: scale(0.85) translateY(16px);
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#badge-achievement-overlay.show .badge-achievement-card {
  transform: scale(1) translateY(0);
}

.badge-achievement-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 24px;
  border: 3px solid var(--border-accent, #f97316);
  box-shadow: var(--shadow-glow, 0 0 40px rgba(249, 115, 22, 0.35));
  margin-bottom: 16px;
}

.badge-achievement-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: var(--bg-elevated);
}

.badge-achievement-kicker {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, #f97316);
  margin: 0 0 8px;
}

.badge-achievement-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.badge-achievement-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

.badge-achievement-card .btn {
  width: 100%;
}

@media (min-width: 768px) {
  .badge-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .companion-img {
    width: 104px;
    height: 104px;
  }

  .evolution-img {
    width: 200px;
    height: 200px;
  }
}

/* ============================================================
   Tour de onboarding (Fase 2) — spotlight propio, sin librerías
   ============================================================ */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 2000;
}
.tour-spotlight {
  position: fixed;
  z-index: 2001;
  border: 2px solid var(--terracotta, #E87A3C);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transition: all 0.3s ease;
}
.tour-tip {
  position: fixed;
  z-index: 2002;
  width: min(340px, calc(100vw - 32px));
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  border-radius: 16px;
  padding: 20px 18px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: tour-pop 0.25s ease;
}
@keyframes tour-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.tour-tip-center {
  /* centrado via transform inline; la animación se desactiva para no pelear */
  animation: tour-pop-center 0.25s ease;
}
@keyframes tour-pop-center {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
.tour-skip {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted, #6b7280);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
}
.tour-skip:hover { color: var(--text-primary, #111827); }
.tour-step-count {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--terracotta-ink, #B85A24);
  margin-bottom: 6px;
}
.tour-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 8px;
  padding-right: 52px; /* lugar para "Saltar" */
}
.tour-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary, #374151);
  margin: 0 0 8px;
}
.tour-cta {
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg-elevated, #F4EFE3);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0 0 10px;
  color: var(--text-primary, #111827);
}
/* v114: pill de espera mientras el usuario crea su meta/hábito en el tour */
.tour-espera {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2002;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  border-radius: 999px;
  padding: 10px 10px 10px 16px;
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: tour-pop-center 0.25s ease;
}
/* v115: hints de descubrimiento progresivo — notificación flotante estilo
   "push-up" (ya no barra pegada arriba de la vista). Solo presentación: la
   lógica (triggers, localStorage, checks) vive en client/js/hints.js y no se toca. */
.hint-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900; /* por encima del contenido, por debajo de modales (2000+) */
  width: min(360px, calc(100vw - 48px));
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid var(--terracotta, #E87A3C);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary, #111827);
  animation: hint-in-desktop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.hint-bar p {
  margin: 0;
  flex: 1;
}
/* v138: link "Más en Ayuda →" dentro del hint. */
.hint-link {
  color: var(--terracotta, #E87A3C);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.hint-link:hover {
  text-decoration: underline;
}
.hint-x {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.hint-x:hover {
  background: var(--bg-elevated, #F4EFE3);
  color: var(--text-primary, #111827);
}
@keyframes hint-in-desktop {
  from {
    opacity: 0;
    transform: translate(28px, 28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Móvil: banner flotante anclado abajo, con márgenes y bordes redondeados
   (no pegado al borde), por encima de la bottom-nav. */
@media (max-width: 767px) {
  /* v130: utilidad para ocultar en móvil (la fila "Hoy" de Preferencias
     se veía rara en pantallas chicas; en escritorio queda). */
  .solo-escritorio { display: none !important; }
  /* v137: la tabla de usuarios (admin) en móvil necesita un ancho mínimo
     para que el scroll horizontal del .admin-table-wrap funcione: con
     width:100% las columnas se comprimen en vez de desbordar y el scroll
     nunca aparece. Solo móvil; desktop no se toca. */
  .admin-table { min-width: 640px; }
  .hint-bar {
    right: 12px;
    left: 12px;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
    width: auto;
    animation-name: hint-in-mobile;
  }
  .hint-x {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }
}
@keyframes hint-in-mobile {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hint-bar {
    animation: none;
  }
}
.tour-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 4px 0 12px;
}
.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-hover, #EFE8D8);
}
.tour-dot.active { background: var(--terracotta, #E87A3C); }
.tour-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* --- Fase 3: Resumen renovado --- */
.resumen-hero {
  border-left: 3px solid var(--accent);
  margin-bottom: 12px;
}

.resumen-fecha {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.resumen-frase {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px;
  line-height: 1.4;
}

.xp-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-light);
  background: rgba(232, 122, 60, 0.12);
  border: 1px solid var(--border-accent);
  border-radius: 999px;
  padding: 4px 12px;
}

.resumen-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.resumen-trio .stat-card {
  padding: 12px 8px;
}

.mini-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 44px;
  margin-bottom: 2px;
}

.mini-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 2px;
}

.mini-bar-fill {
  width: 10px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--accent), var(--accent-light));
  min-height: 3px;
}

.mini-bar-label {
  font-size: 8px;
  color: var(--text-muted);
  line-height: 1;
}

/* --- Fase 3: Evaluación mensual --- */
.eval-textarea {
  width: 100%;
  height: 150px;
  max-height: 150px;
  resize: none;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.5;
}

.eval-reflexion-leida {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 12px;
  white-space: pre-wrap;
}

/* ============ Fase 4: UI a prueba de "muchos datos" ============ */

/* Skeletons de carga */
.skel {
  border-radius: 10px;
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s infinite linear;
  opacity: 0.8;
}
@keyframes skel-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Grupos de hábitos colapsables */
.habit-group { margin-bottom: 4px; }
.habit-group-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 4px;
  background: none; border: none; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.habit-group-head .chev { transition: transform 0.15s ease; font-size: 10px; }
.habit-group.collapsed .chev { transform: rotate(-90deg); }
.habit-group-head .count { margin-left: auto; font-weight: 600; }
.habit-group.collapsed .habit-group-body { display: none; }

/* Scroll interno por sección (listas que crecen sin romper el layout) */
.scroll-list {
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

/* Botón "Mostrar más" de paginación */
.ui-more { width: 100%; margin-top: 8px; }

/* Buscador del backlog */
.backlog-search { margin-bottom: 10px; }

/* Toggle "ver más" en tarjetas de día (semana) */
.day-rest { margin-top: 4px; }
.day-more { margin-top: 4px; padding: 2px 8px; font-size: 12px; }

/* --- Árbol de habilidades (Fase 4.5) --- */
.skill-node { margin-bottom: 10px; }
.skill-node-head { display: flex; align-items: center; gap: 10px; }
.skill-level {
  flex: 0 0 auto;
  font-size: 12px; font-weight: 800;
  color: #fff; background: var(--accent);
  border-radius: 999px; padding: 4px 10px;
}
.skill-node-title { flex: 1; min-width: 0; }
.skill-name { font-size: 15px; font-weight: 700; margin: 0; color: var(--text-primary); }
.skill-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.skill-xp { font-size: 13px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.skill-bar {
  height: 8px; border-radius: 999px;
  background: var(--bg-elevated, #eee);
  margin-top: 10px; overflow: hidden;
}
.skill-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f0a35e);
  transition: width 0.4s ease;
}
.skill-next { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.mision-card { margin-bottom: 10px; }
.mision-tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin: 0 0 4px; }
.mision-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; color: var(--text-primary); }
.mision-detail { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; line-height: 1.5; }

/* Contador de límite del plan gratuito (ej: "2/3") */
.plan-counter {
  font-size: 11px; font-weight: 800;
  color: var(--text-muted);
  background: var(--bg-elevated, #eee);
  border-radius: 999px; padding: 2px 8px;
  vertical-align: 2px; white-space: nowrap;
}

/* ---- Fase 5: estadísticas avanzadas (barras CSS puras, móvil primero) ---- */
.adv-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 12px;
  min-height: 110px;
}
.adv-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}
.adv-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-soft, #b79df5));
  transition: height 0.3s ease;
}
.adv-bar-green {
  background: linear-gradient(180deg, #34c77b, #1f9d5c);
}
.adv-bar-lbl {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Menú móvil: tab "Menú" + bottom sheet (Fase 5)                      */
/* ------------------------------------------------------------------ */
button.nav-item {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay.open {
  opacity: 1;
}

.sheet {
  width: 100%;
  max-width: var(--content-max);
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(16px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.22s ease;
  max-height: 70vh;
  overflow-y: auto;
}

.sheet-overlay.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 4px auto 10px;
  cursor: pointer;
}

/* v138: menú móvil agrupado por intención (ítem 87) — headers de grupo. */
.menu-grupo { margin-top: 6px; }
.menu-grupo:first-child { margin-top: 0; }
.menu-grupo-titulo {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px 6px;
  font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.menu-grupo-ico { font-size: 14px; }

/* Breadcrumbs (v138, ítem 87) — barra sobre la vista, sobrevive re-renders. */
.crumb-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 4px;
  font-size: 13px; color: var(--text-muted);
}
.crumb-back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; font: inherit;
  color: var(--terracotta-ink); font-weight: 700;
  cursor: pointer; padding: 4px 0;
}
.crumb-current { color: var(--text-primary); font-weight: 600; }
.crumb-home { color: var(--text-muted); text-decoration: none; }
.crumb-home:hover { text-decoration: underline; }

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 8px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.sheet-item:last-child {
  border-bottom: none;
}

.sheet-item:active {
  opacity: 0.6;
}

.sheet-item-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.sheet-item-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.sheet-item-chev {
  color: var(--text-muted);
  font-size: 18px;
}

.sheet-item-check {
  color: var(--terracotta-ink);
  font-size: 12px;
}

/* v140: acordeón + accesos rápidos en el sheet móvil (pedido de Leo). */
.menu-grupo-titulo.menu-grupo-toggle {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.menu-grupo-nombre { flex: 1; }
.menu-grupo-chev {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.menu-grupo.cerrado .menu-grupo-chev { transform: rotate(-90deg); }
.menu-grupo.cerrado .menu-grupo-items { display: none; }
.sheet-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row .sheet-item { border-bottom: none; flex: 1; min-width: 0; }
.sheet-pin {
  background: none;
  border: none;
  font-size: 16px;
  padding: 10px 6px;
  cursor: pointer;
  opacity: 0.45;
  flex-shrink: 0;
}
.sheet-pin[aria-pressed="true"] { opacity: 1; }
.sheet-pin:active { transform: scale(1.2); }
.menu-qa .menu-grupo-titulo { color: var(--text-primary); }

@media (min-width: 1024px) {
  .sheet-overlay {
    display: none;
  }
}

/* ============================================
   FORMULARIOS (.fld) y EDITOR DE PASOS (metas)
   ============================================ */
.fld {
  display: block;
  margin: 0 0 12px;
}
.fld > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.fld > span em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-muted);
}
.fld-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.fld-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 2px 0 12px;
}

/* Filas colapsables del editor de pasos (flujo de meta con IA) */
.paso-fila {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.paso-fila-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.paso-fila-icon {
  font-size: 18px;
  flex: 0 0 auto;
}
.paso-fila-titulo {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paso-fila-badge {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.paso-fila-del {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  flex: 0 0 auto;
}
.paso-fila-del:hover {
  color: #e5484d;
}
.paso-fila-chevron {
  color: var(--text-muted);
  font-size: 12px;
  flex: 0 0 auto;
}
.paso-fila.abierta .paso-fila-head {
  border-bottom: 1px dashed var(--border);
}
.paso-fila-body {
  padding: 12px;
}
.paso-fila-body .fld-hint {
  margin-bottom: 0;
}

/* Fase 4 (punto 18): chips de días para frecuencia de hábitos */
.frec-dia.frec-dia-on,
/* v101-hotfix (reportado por Leo): los botones de duración del modo foco usan
   la clase frec-dia-on pero no tienen la clase frec-dia, así que el resaltado
   nunca se aplicaba y parecía que el clic no hacía nada */
.foco-dur.frec-dia-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Fase 4 (punto 28): vista calendario.
   v138: rediseño visual — dos columnas en desktop, celdas con jerarquía y
   estados, detalle con barras de progreso. */
.cal-top { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.cal-top .date-nav { margin-bottom:0; }
.cal-quicknav { display:flex; gap:8px; }
.cal-layout { display:grid; gap:12px; }
@media (min-width:1024px) {
  .cal-layout { grid-template-columns:minmax(0, 1fr) 370px; align-items:start; }
  .cal-detalle { position:sticky; top:12px; }
}
.cal-card { padding:14px; }
.cal-grid { display:grid; grid-template-columns:repeat(7, 1fr); gap:6px; }
.cal-dow { font-size:11px; font-weight:700; color:var(--text-muted); text-align:center; padding:6px 0; text-transform:uppercase; letter-spacing:.04em; }
.cal-celda { background:var(--bg-elevated); border:1px solid var(--border-accent); border-radius:12px; min-height:56px; padding:8px 4px; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; gap:5px; cursor:pointer; color:var(--text-primary); transition:border-color .15s, transform .15s, background .15s; font:inherit; }
.cal-celda:hover { border-color:var(--accent); transform:translateY(-1px); }
.cal-vacia { background:transparent; border:none; cursor:default; min-height:56px; }
.cal-vacia:hover { transform:none; }
.cal-num { font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }
.cal-dots { display:flex; gap:4px; min-height:8px; }
.cal-dot { width:8px; height:8px; border-radius:50%; display:inline-block; }
.cal-hoy { border-color:var(--accent); }
.cal-hoy .cal-num { background:var(--accent); color:#fff; border-radius:50%; width:26px; height:26px; display:flex; align-items:center; justify-content:center; font-size:12px; }
.cal-full { background:color-mix(in srgb, var(--success) 10%, var(--bg-elevated)); border-color:color-mix(in srgb, var(--success) 45%, transparent); }
.cal-sel { border-color:var(--accent); box-shadow:0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
/* Detalle del día */
.cal-detalle-card { border-left:3px solid var(--accent); }
.cal-detalle-actions { display:flex; gap:8px; margin-bottom:12px; flex-wrap:wrap; }
.cal-detalle-sec { margin:10px 0 6px; }
.cal-detalle-sectitulo { font-size:13px; font-weight:700; margin:0 0 2px; }
.cal-detalle-item { font-size:14px; padding:4px 0; display:flex; align-items:center; gap:6px; }
.cal-progress { height:6px; border-radius:999px; background:var(--bg-elevated); border:1px solid var(--border); overflow:hidden; margin:2px 0 8px; }
.cal-progress-fill { height:100%; border-radius:999px; background:linear-gradient(90deg, var(--accent), var(--accent-light, var(--accent))); transition:width .3s ease; }

/* v96 (item 37): banner descartable de instalación PWA */
.pwa-banner { display:flex; align-items:center; justify-content:space-between; gap:12px; border-left:3px solid var(--accent); margin-bottom:12px; }
.pwa-banner-txt { font-size:13px; line-height:1.4; }
.pwa-banner-actions { display:flex; gap:8px; align-items:center; flex-shrink:0; }

/* v112 (item 39): time picker estilo reloj analógico 24 h.
   Reemplaza los dos <select> de v96 (listas enormes en escritorio). */
.tp-wrap { display:inline-block; }
.tp-trigger { display:inline-flex; align-items:center; gap:8px; cursor:pointer; width:auto; min-width:0; font-variant-numeric:tabular-nums; }
.tp-trigger .tp-ico { font-size:16px; }
.tp-trigger .tp-val { font-weight:700; font-size:15px; letter-spacing:1px; }
.tp-backdrop { position:fixed; inset:0; z-index:5000; display:flex; align-items:center; justify-content:center; padding:20px; background:rgba(5,8,20,.72); backdrop-filter:blur(2px); }
.tp-backdrop[hidden] { display:none; }
.tp-dialog { width:min(340px, 94vw); background:var(--card, #141a2e); border:1px solid var(--border); border-radius:18px; padding:18px 16px 14px; box-shadow:0 18px 50px rgba(0,0,0,.5); outline:none; }
.tp-title { font-size:14px; font-weight:700; color:var(--text-secondary); margin-bottom:8px; }
.tp-display { display:flex; align-items:baseline; justify-content:center; gap:6px; margin-bottom:6px; }
.tp-digit { background:none; border:none; color:var(--text-primary); font-size:40px; font-weight:800; font-variant-numeric:tabular-nums; cursor:pointer; padding:2px 8px; border-radius:10px; line-height:1; }
.tp-digit.tp-active { color:var(--accent); background:color-mix(in srgb, var(--accent) 14%, transparent); }
.tp-colon { font-size:32px; font-weight:800; color:var(--text-muted); }
.tp-steps { display:flex; justify-content:center; gap:8px; margin-bottom:10px; }
.tp-steps button { background:none; border:1px solid var(--border); color:var(--text-secondary); font-size:12px; font-weight:700; padding:6px 14px; border-radius:999px; cursor:pointer; }
.tp-steps button.tp-active { color:#fff; background:var(--accent); border-color:var(--accent); }
.tp-dial { display:block; width:100%; height:auto; touch-action:none; cursor:pointer; user-select:none; -webkit-user-select:none; }
.tp-face { fill:var(--bg, #0d1226); stroke:var(--border); stroke-width:1.5; }
.tp-ring { fill:none; stroke:var(--border); stroke-width:1; opacity:.55; }
.tp-num { fill:var(--text-secondary); font-size:15px; font-weight:600; text-anchor:middle; dominant-baseline:central; pointer-events:none; }
.tp-num-in { font-size:13px; opacity:.85; }
.tp-num.tp-sel { fill:var(--text-muted); }
.tp-sel-txt { fill:#fff; font-weight:800; }
.tp-dot { fill:var(--accent); }
.tp-hand { stroke:var(--accent); stroke-width:3; stroke-linecap:round; }
.tp-center { fill:var(--accent); }
.tp-hint { text-align:center; font-size:11px; color:var(--text-muted); margin:8px 0 0; }
.tp-foot { display:flex; align-items:center; gap:8px; margin-top:10px; }
.tp-spacer { flex:1; }

/* v101 (item 53): pantalla de login dedicada */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(232, 122, 60, 0.22), transparent 60%),
    radial-gradient(700px 500px at 85% 110%, rgba(124, 58, 237, 0.18), transparent 60%),
    linear-gradient(180deg, #0b1220 0%, #0f172a 55%, #0b1220 100%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 48px 20px 40px;
}

.auth-screen.hidden {
  display: none;
}

.auth-screen-inner {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-logo {
  display: block;
  width: 88px;
  height: 88px;
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 24px;
  box-shadow: 0 10px 32px rgba(232, 122, 60, 0.45);
}

.auth-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0;
}

.auth-tagline {
  font-size: 14px;
  font-weight: 600;
  color: var(--terracotta-ink, #e87a3c);
  margin: 0;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-pop);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 18px;
  text-align: center;
}

.auth-bullets {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-bullets li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-bullet-icon {
  font-size: 16px;
  flex-shrink: 0;
}

@media (max-width: 420px) {
  .auth-screen {
    padding: 32px 16px 32px;
  }

  .auth-logo {
    width: 72px;
    height: 72px;
  }

  .auth-title {
    font-size: 32px;
  }

  .auth-card {
    padding: 20px 16px;
  }
}

/* v106 · tienda: píldora con el saldo de monedas en "Mi compañero". */
.monedas-saldo {
  font-size: 13px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* ============================================
   v118 · Pack pulido UX
   ============================================ */

/* --- Ítem 40: sidebar desktop (≥1024px), ocultable.
   Reemplaza la barra superior con 12 ítems estirados.
   En móvil se mantiene la bottom-nav (este aside queda oculto). --- */
#sidebar {
  display: none;
}
#btn-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  #sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: calc(var(--header-height) + var(--safe-top));
    left: 0;
    bottom: 0;
    width: 244px;
    z-index: 90;
    background: var(--header-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
    padding: 18px 12px 24px;
    overflow-y: auto;
    transition: width var(--transition);
  }

  #btn-sidebar {
    display: inline-flex;
  }

  /* La nav superior estirada se reemplaza por el sidebar. */
  #desktop-nav {
    display: none;
  }

  #app-main {
    margin-left: 244px;
    transition: margin-left var(--transition);
  }

  /* Estado colapsado: riel de iconos (preferencia en localStorage). */
  body.sidebar-colapsado #sidebar {
    width: 68px;
    padding: 18px 8px 24px;
  }
  body.sidebar-colapsado #app-main {
    margin-left: 68px;
  }
  body.sidebar-colapsado .snav-label,
  body.sidebar-colapsado .snav-group-title {
    display: none;
  }
  body.sidebar-colapsado .snav-item {
    justify-content: center;
    padding: 10px 0;
  }
  body.sidebar-colapsado .snav-icon {
    margin: 0;
    font-size: 20px;
  }
  /* v139 · ítem 3: en modo riel el acordeón no aplica (se ven todos los
     iconos) y se ocultan los 📌 y la sección de accesos rápidos. */
  body.sidebar-colapsado .snav-group[data-grupo]:not(.abierto) .snav-group-items {
    display: block;
  }
  body.sidebar-colapsado .snav-pin {
    display: none;
  }
  body.sidebar-colapsado #snav-qa {
    display: none !important;
  }

  .snav-group {
    margin-bottom: 20px;
  }
  .snav-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 6px;
    padding: 0 12px;
  }
  .snav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
  }
  .snav-item:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
  }
  .snav-item.active {
    color: var(--terracotta-ink);
    background: var(--accent-dim);
  }
  .snav-icon {
    font-size: 17px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
  }
  .snav-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- v139 · ítem 3a: acordeón de grupos del sidebar --- */
  /* El título del grupo es un <button>: reset para que parezca el <p> de antes. */
  button.snav-group-title {
    background: none;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    border-radius: 8px;
  }
  button.snav-group-title:hover {
    color: var(--text-secondary);
  }
  button.snav-group-title:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .snav-chevron {
    display: inline-block;
    font-size: 9px;
    line-height: 1;
    transition: transform var(--transition);
  }
  .snav-group.abierto .snav-chevron {
    transform: rotate(90deg);
  }
  /* Colapsado por default: solo el grupo con la ruta activa (o preferencia
     manual en localStorage) lleva .abierto y muestra sus destinos. */
  .snav-group[data-grupo]:not(.abierto) .snav-group-items {
    display: none;
  }

  /* --- v139 · ítem 3b: filas link + 📌 y sección de accesos rápidos --- */
  .snav-row {
    display: flex;
    align-items: center;
  }
  .snav-row .snav-item {
    flex: 1;
    min-width: 0;
  }
  .snav-pin {
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    opacity: 0.3;
    padding: 7px 6px;
    border-radius: 8px;
    transition: opacity var(--transition), background var(--transition);
  }
  .snav-row:hover .snav-pin,
  .snav-pin:focus-visible {
    opacity: 0.85;
  }
  .snav-pin[aria-pressed="true"] {
    opacity: 1;
    background: var(--accent-dim);
  }
  /* La sección de accesos rápidos va arriba del todo, separada. */
  #snav-qa {
    padding-bottom: 6px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }
}

/* --- Ítem 43: barra de XP siempre visible ("subir de nivel" es el eslogan) --- */
.xp-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.xp-pill[hidden] {
  display: none;
}
.xp-pill-nivel {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}
.xp-pill-bar {
  width: 84px;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-surface);
  overflow: hidden;
}
.xp-pill-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.5s ease;
}
@media (max-width: 480px) {
  .xp-pill-bar {
    width: 44px;
  }
  .xp-pill {
    padding: 5px 9px;
    gap: 6px;
  }
}

/* --- Ítem 42: flechas de navegación de fecha pegadas al texto --- */
.date-nav {
  gap: 6px;
}
.date-nav-mid {
  min-width: 148px;
}

/* --- Ítem 44: microinteracciones al completar (respeta reduced-motion) --- */
.task-item,
.habit-item {
  transition: background-color 0.3s ease;
}
@media (prefers-reduced-motion: no-preference) {
  .recien-tildado {
    animation: kaito-flash 0.9s ease;
  }
  .recien-tildado .task-checkbox,
  .recien-tildado .habit-toggle {
    animation: kaito-pop 0.35s ease;
  }
}
@keyframes kaito-flash {
  0% {
    background-color: var(--accent-dim);
  }
  100% {
    background-color: transparent;
  }
}
@keyframes kaito-pop {
  0% {
    transform: scale(0.55);
  }
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

/* --- Ítem 41: CTA de estados vacíos más llamativo (fondo naranja) --- */
.empty-state .btn-cta {
  background: linear-gradient(135deg, var(--accent), #d96a2b);
  color: #fff;
  border: none;
  font-weight: 800;
  padding: 10px 22px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(232, 122, 60, 0.35);
}
.empty-state .btn-cta:hover {
  filter: brightness(1.08);
  color: #fff;
}

/* --- Ítem 47: notas en desktop (grilla + grupos colapsables) --- */
.notas-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}
.notas-grid .card {
  margin-bottom: 0;
}
.notas-grupo-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}
.notas-grupo-toggle .notas-caret {
  transition: transform var(--transition);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.notas-grupo[data-colapsado="1"] .notas-caret {
  transform: rotate(-90deg);
}
.notas-grupo[data-colapsado="1"] .notas-grid {
  display: none;
}
@media (min-width: 1024px) {
  .notas-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
  }
}

/* ============================================
   v119 — Pantalla de Preferencias (pedido de Leo 2026-09-26).
   En móvil (<1024px) el header queda minimalista: marca + XP + campana + engranaje.
   v137: la campana (#btn-notifs) vuelve a verse en móvil (pedido de Leo);
   los demás controles (fecha, tema, idioma, salir) viven en #/preferencias.
   En desktop el header no cambia.
   ============================================ */
#btn-prefs {
  display: none;
}

@media (max-width: 1023px) {
  #btn-prefs {
    display: inline-flex;
  }
  /* !important: pisa el display inline que el JS setea en btn-logout. */
  #header-date,
  #theme-toggle,
  #btn-lang,
  #btn-logout {
    display: none !important;
  }
}

/* Filas y segmentados de la pantalla de Preferencias. */
.pref-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
}
.pref-row + .pref-row {
  border-top: 1px solid var(--border);
}
a.pref-link {
  text-decoration: none;
  color: inherit;
}
.pref-ico {
  font-size: 20px;
  flex-shrink: 0;
}
.pref-row-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.pref-row-desc {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.pref-chev {
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
}
.pref-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 8px;
}
.seg {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.seg-opt {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex: 1;
}
.seg-opt.active {
  background: var(--accent);
  color: #fff;
}
@media (prefers-reduced-motion: no-preference) {
  .pref-seg button {
    transition: background var(--transition), color var(--transition);
  }
}

/* v125 · Dictado por voz: botón 🎙️ sobre el borde derecho del campo. */
.dictado-wrap {
  position: relative;
  display: block;
}
.dictado-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: var(--bg-elevated, rgba(255, 255, 255, 0.06));
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}
.dictado-btn:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}
.dictado-btn.dictado-grabando {
  border-color: #ef4444;
  animation: dictado-pulse 1.2s ease-in-out infinite;
}
@keyframes dictado-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .dictado-btn.dictado-grabando { animation: none; }
}

/* ============ v134 · Pills de diseños del resumen compartible ============ */
.tpl-pill {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tpl-pill:hover { border-color: var(--accent); }
.tpl-pill.sel {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(139, 124, 246, 0.16));
  font-weight: 700;
}

/* ============ v139 · Jerarquía de títulos en el modal de planificación ============ */
.ritual-sec-titulo {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 20px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
}
.ritual-sec-titulo:first-of-type {
  margin-top: 12px;
  padding-top: 0;
  border-top: none;
}

/* v150: agenda de bloques — la "línea de tiempo" del día.
   Los bloques se dibujan como eventos de agenda (hora protagonista,
   altura proporcional a la duración) en vez de tarjetas comunes. */
.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agenda-item {
  border-left: 3px solid var(--accent);
}
.agenda-item.en-curso {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent);
}
.agenda-hora {
  min-width: 74px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  line-height: 1.25;
}
.agenda-hora strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}
.agenda-hora span {
  font-size: 11px;
  color: var(--text-muted);
}
.agenda-ahora {
  display: block;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-top: 2px;
}

/* v150: banner "ahora" — el bloque en curso como protagonista del Día */
.ahora-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  background: var(--accent-glow);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-primary);
}
.ahora-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: ahora-pulse 1.6s ease-in-out infinite;
}
@keyframes ahora-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

/* v157 (admin C): grupos del sidebar + paleta de comandos */
.admin-side-group {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 12px 4px;
}
.admin-side-group:first-child {
  padding-top: 2px;
}
#admin-palette {
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.admin-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.admin-palette-box {
  position: absolute;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.admin-palette-list {
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-palette-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}
.admin-palette-item.sel {
  background: var(--accent-dim);
  border-color: var(--border-accent);
}
.admin-palette-grupo {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 52px;
}
.admin-palette-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.admin-palette-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
@media (max-width: 900px) {
  /* En móvil los grupos ocupan la fila completa de la grilla del nav */
  .admin-side-group {
    grid-column: 1 / -1;
    padding: 8px 4px 2px;
  }
  .admin-palette-box {
    top: 8vh;
  }
}

/* v192: pantalla de Compañeros (maestro-detalle con sub-navegación;
   reemplaza el modal largo de edición). */
.comp-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.comp-list {
  flex: 0 0 264px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}
.comp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
}
.comp-row:hover { background: var(--bg-hover); }
.comp-row.active {
  border-color: var(--border-accent);
  background: var(--accent-dim);
}
.comp-row img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--bg-hover);
}
.comp-row-txt { min-width: 0; flex: 1; }
.comp-row-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-row-id { font-size: 11px; color: var(--text-muted); }
.comp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 auto;
}
.comp-dot.off { background: var(--text-muted); opacity: .5; }
.comp-editor {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.comp-editor-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}
.comp-editor-head img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}
.comp-editor-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}
.comp-editor-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.comp-subnav {
  display: flex;
  gap: 4px;
  margin: 12px 0 16px;
  border-bottom: 1px solid var(--border);
}
.comp-subnav button {
  border: none;
  background: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}
.comp-subnav button:hover { color: var(--text-primary); }
.comp-subnav button.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent, #E87A3C);
}
.comp-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  flex: 1;
}
@media (max-width: 900px) {
  .comp-layout { flex-direction: column; align-items: stretch; }
  .comp-list { flex: none; width: 100%; max-height: 240px; }
}
