/* ============================================================
   LinguaIQ — Estilos globales
   ============================================================ */
:root {
  /* Paleta del logo LinguaIQ: azul #023BA2 -> morado #4E0997 */
  --bg:        #ffffff;   /* fondo de pagina */
  --bg2:       #ffffff;   /* tarjetas, menu, modales */
  --bg3:       #f3f5fb;   /* hover, zonas suaves */
  --bg-soft:   #fafbfe;   /* fondos muy suaves (zona principal, casillas) */
  --border:    #e3e7f1;
  --text:      #13183a;
  --text2:     #5b6178;
  --accent:    #0448b9;   /* azul del logo */
  --accent2:   #5b10a6;   /* morado del logo */
  --brand-blue:   #023ba2;
  --brand-purple: #4e0997;
  --brand-grad:   linear-gradient(135deg, #0448b9 0%, #3b2bb0 55%, #5b10a6 100%);
  --brand-soft:   #eef2fd;
  --success:   #16a34a;
  --danger:    #dc2626;
  --warning:   #d97706;
  --fr:        #2D6A4F;
  --en:        #1B4332;
  --radius:    12px;
  --shadow:    0 10px 30px rgba(4,72,185,.08), 0 2px 6px rgba(19,24,58,.04);
  --font:      'Inter', system-ui, sans-serif;
  --mono:      'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Tipografía ---------- */
h1 { font-size: 2rem;   font-weight: 700; color: var(--text); }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--text2); }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ---------- Card ---------- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(19,24,58,.04);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: #c9d4f3; box-shadow: var(--shadow); }
.card-sm { padding: 1rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.2rem;
  border: none; border-radius: 8px;
  font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.btn-primary  { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 14px rgba(4,72,185,.25); }
.btn-primary:hover  { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(91,16,166,.3); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { filter: brightness(1.1); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { filter: brightness(1.1); }
.btn-ghost    { background: var(--bg2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg3); color: var(--text); }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.8rem; font-size: 1rem; }

/* ---------- Formularios ---------- */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
label { font-size: .85rem; color: var(--text2); font-weight: 500; }
input, select, textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem .9rem;
  font-size: .95rem;
  font-family: var(--font);
  transition: border-color .2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(4,72,185,.12);
}
textarea { resize: vertical; min-height: 80px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .55rem; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.badge-nuevo        { background: #eef1f7; color: #5b6178; }
.badge-reconocido   { background: #e6eefc; color: #0448b9; }
.badge-recuperable  { background: #fef3c7; color: #b45309; }
.badge-productivo   { background: #dcfce7; color: #15803d; }
.badge-automatizado { background: #f1e8fb; color: #5b10a6; }

.badge-A1 { background: #dcfce7; color: #15803d; }
.badge-A2 { background: #e6eefc; color: #0448b9; }
.badge-B1 { background: #fee2e2; color: #b91c1c; }
.badge-B2 { background: #f1e8fb; color: #5b10a6; }
.badge-C1 { background: #ffedd5; color: #c2410c; }
.badge-C2 { background: #e8eaf3; color: #13183a; }

/* ---------- Sidebar ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform .3s;
}
.sidebar-logo {
  padding: 1.5rem 1.2rem;
  font-size: 1.3rem; font-weight: 800;
  color: var(--accent2);
  letter-spacing: -.5px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { display: block; padding: 1.1rem 1rem; }

/* Logo sobre fondo blanco (sin placa) */
.brand-badge { display: inline-flex; align-items: center; justify-content: center; }
.brand-badge img { display: block; width: 100%; height: auto; }
.sidebar-logo .brand-badge { width: 100%; }
.brand-badge-lg { width: 100%; max-width: 280px; margin-bottom: 1rem; }
.mobile-brand { display: none; }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 1.2rem;
  color: var(--text2); font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: all .2s;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: var(--accent); background: var(--brand-soft); font-weight: 600;
  border-left-color: var(--accent2);
}
a.nav-item { text-decoration: none; }
#sidebar-toggle { display: none; }
.nav-item .icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: .6rem;
  font-size: .85rem;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.main-content { margin-left: 220px; padding: 2rem; min-height: 100vh; background: var(--bg-soft); flex: 1; min-width: 0; }

/* ---------- Header de página ---------- */
.page-header { margin-bottom: 2rem; }
.page-header h1 { margin-bottom: .3rem; }

/* ---------- Stat tiles ---------- */
.stat-tile {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(19,24,58,.04);
  padding: 1.2rem 1.5rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--brand-blue); }
.stat-label { font-size: .8rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.stat-sub   { font-size: .8rem; color: var(--success); }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: .75rem 1rem;
  font-size: .78rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ---------- Progress bar ---------- */
.progress-bar {
  height: 8px; background: var(--bg3);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--brand-grad);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ---------- Flashcard ---------- */
.flashcard-scene {
  perspective: 1200px;
  width: 100%; max-width: 560px; height: 300px;
  margin: 2rem auto;
}
.flashcard {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.flashcard-front {
  background: linear-gradient(135deg, #ffffff, #f2f5fd);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
}
.flashcard-back {
  background: linear-gradient(135deg, #ffffff, #effaf2);
  border: 2px solid var(--success);
  box-shadow: var(--shadow);
  transform: rotateY(180deg);
}
.flashcard-word { font-size: 2rem; font-weight: 800; margin-bottom: .5rem; color: var(--brand-blue); }
.flashcard-hint { font-size: .85rem; color: var(--text2); }
.flashcard-translation { font-size: 1.3rem; font-weight: 600; color: var(--success); }
.flashcard-example { font-size: .9rem; color: var(--text2); margin-top: .5rem; font-style: italic; }
.flashcard-layer { font-size: .7rem; color: var(--accent2); text-transform: uppercase; letter-spacing: .1em; }

.answer-btns { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(19,24,58,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 480px;
  box-shadow: 0 20px 50px rgba(19,24,58,.18);
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 1.3rem; cursor: pointer; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem 1.2rem; box-shadow: var(--shadow);
  font-size: .88rem; font-weight: 500;
  animation: slideIn .3s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: .6rem 1.2rem; background: none; border: none;
  color: var(--text2); font-size: .9rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .2s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Selector de idioma ---------- */
.lang-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .8rem; border-radius: 20px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 2px solid transparent; transition: all .2s;
}
.lang-pill.fr { background: #eef2fd; color: #0448b9; }
.lang-pill.en { background: #f4ecfc; color: #5b10a6; }
.lang-pill.active.fr { border-color: #0448b9; }
.lang-pill.active.en { border-color: #5b10a6; }

/* ---------- Level timeline ---------- */
.level-timeline { display: flex; gap: 0; }
.level-node {
  flex: 1; text-align: center; padding: .8rem .3rem;
  font-size: .78rem; font-weight: 700;
  position: relative; transition: all .2s;
}
.level-node::after {
  content: ''; position: absolute; top: 50%; right: -1px;
  width: 2px; height: 60%; transform: translateY(-50%);
  background: var(--border);
}
.level-node:last-child::after { display: none; }
.level-node.done   { opacity: 1; }
.level-node { color: var(--text2); }
.level-node:hover { color: var(--text); }
.level-node.active { background: var(--brand-soft); border-radius: 8px; color: var(--brand-blue); box-shadow: inset 0 -2px 0 var(--accent2); }
.level-node.locked { opacity: .35; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  #sidebar-toggle { display: inline-flex; position: fixed; top: .6rem; left: .8rem; z-index: 101; background: var(--bg2); }
  .sidebar.open { box-shadow: 0 0 40px rgba(19,24,58,.2); }
  .mobile-brand { display: flex; justify-content: center; position: fixed; top: 0; left: 0; right: 0; z-index: 99;
    padding: .7rem 0; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .mobile-brand .brand-badge { width: 130px; }
  .main-content { padding-top: 4.4rem !important; }
  .main-content { margin-left: 0; padding: 1rem; }
  .main-content .container { padding: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .stat-tile { padding: .9rem 1rem; }
  .stat-value { font-size: 1.5rem; }
  h1 { font-size: 1.5rem; }
  .page-header { flex-wrap: wrap; gap: .8rem; }
  .level-node div:last-child { display: none; }
  .flashcard-scene { height: 250px; }
  .flashcard-word { font-size: 1.5rem; }
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 15% 10%, #eaf0fd 0%, transparent 55%), radial-gradient(ellipse at 90% 90%, #f3eafc 0%, transparent 55%), #fff;
  padding: 1rem;
}
.login-box {
  width: 100%; max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 2.5rem;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 2.2rem; color: var(--brand-blue); }
.login-logo p  { color: var(--text2); font-size: .9rem; }

/* =====================================================================
   v2 — componentes compartidos (audio, universos, barra tipo app)
   ===================================================================== */
.say-btn { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg2);
  cursor: pointer; font-size: .9rem; display: inline-grid; place-items: center; transition: .15s; vertical-align: middle; padding: 0; }
.say-btn:hover { border-color: var(--accent); background: var(--brand-soft); }
.say-btn.speaking { background: var(--brand-grad); border-color: transparent; animation: sayPulse 1s infinite; }
.say-btn.lg { width: 46px; height: 46px; font-size: 1.2rem; }
@keyframes sayPulse { 50% { transform: scale(1.08); } }

/* Universos temáticos */
.uni-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .7rem; }
.uni-card { position: relative; text-align: left; display: flex; flex-direction: column; gap: .2rem; padding: .9rem 1rem;
  border: 2px solid var(--border); border-radius: 14px; background: var(--bg2); cursor: pointer; font: inherit; color: var(--text); transition: .15s; }
.uni-card:hover { border-color: #c9d4f3; }
.uni-card.on { border-color: var(--accent); background: var(--brand-soft); box-shadow: 0 6px 16px rgba(4,72,185,.12); }
.uni-icon { font-size: 1.6rem; line-height: 1; }
.uni-name { font-weight: 700; font-size: .92rem; }
.uni-desc { font-size: .78rem; color: var(--text2); line-height: 1.35; }
.uni-words { margin-top: .3rem; font-size: .72rem; font-weight: 700; color: var(--accent2); }
.uni-words.soon { color: var(--text2); font-weight: 500; }
.uni-check { position: absolute; top: .6rem; right: .7rem; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: .75rem; color: #fff; background: var(--border); }
.uni-card.on .uni-check { background: var(--brand-grad); }
.uni-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.uni-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .75rem; border-radius: 99px; background: var(--brand-soft);
  color: var(--brand-blue); font-size: .82rem; font-weight: 600; }

/* Segmentos (pestañas tipo píldora) */
.seg { display: inline-flex; background: var(--bg3); border-radius: 12px; padding: .25rem; gap: .2rem; flex-wrap: wrap; }
.seg button { border: none; background: none; padding: .45rem .9rem; border-radius: 9px; font: inherit; font-size: .86rem; font-weight: 600;
  color: var(--text2); cursor: pointer; }
.seg button.on { background: var(--bg2); color: var(--accent); box-shadow: 0 1px 4px rgba(19,24,58,.1); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .9rem; flex-wrap: wrap; }
.section-title h3 { display: flex; align-items: center; gap: .45rem; margin: 0; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; font-size: .85rem; cursor: pointer; padding: 0; }
.empty-state { text-align: center; padding: 1.5rem 1rem; color: var(--text2); font-size: .9rem; }

/* Menú lateral en teléfono: fondo para cerrar */
.sidebar-backdrop { display: none; }
.tabbar { display: none; }

@media (max-width: 768px) {
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(19,24,58,.35); z-index: 99; }
  .sidebar { z-index: 100; }
  #sidebar-toggle { display: none !important; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 98;
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom, 0px)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .68rem; font-weight: 600;
    color: var(--text2); text-decoration: none; padding: .25rem 0; border-radius: 10px; }
  .tabbar a span { font-size: 1.25rem; line-height: 1.2; filter: grayscale(.6); opacity: .8; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a.active span { filter: none; opacity: 1; }
  body.has-tabbar .main-content { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)) !important; }
  body.has-tabbar .toast-container { bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }
  .toast-container { left: 1rem; right: 1rem; align-items: stretch; }
  .toast { max-width: 100%; animation-name: toastFade; }
  .uni-grid { grid-template-columns: 1fr 1fr; }
  .uni-desc { display: none; }
  .modal { max-height: 92vh; overflow: auto; padding: 1.3rem; margin: 0 .6rem; }

  /* Tablas → tarjetas en teléfono (añadir class="table-cards" a la tabla) */
  table.table-cards thead { display: none; }
  table.table-cards, table.table-cards tbody, table.table-cards tr, table.table-cards td { display: block; width: 100%; }
  table.table-cards tr { border-bottom: 1px solid var(--border); padding: .7rem 1rem; }
  table.table-cards td { border: none; padding: .15rem 0; }
  table.table-cards td[data-label]::before { content: attr(data-label) ': '; color: var(--text2); font-size: .78rem; font-weight: 600; }
}

@keyframes toastFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Roles: el estudiante aprende, el administrador gestiona
   (app.js pone <html class="role-admin"> o "role-student")
   ============================================================ */
.nav-label { font-size: .66rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text2); opacity: .8; padding: .95rem 1.35rem .3rem; }
.sidebar-nav .nav-label:first-child { padding-top: .1rem; }
.sidebar-nav .nav-item { padding-top: .55rem; padding-bottom: .55rem; }
html:not(.role-admin) .nav-admin, html:not(.role-admin) .nav-admin-inline, html:not(.role-admin) .admin-mode { display: none !important; }
html.role-admin .nav-student, html.role-admin .student-only { display: none !important; }
.role-tag { font-size: .62rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--brand-grad); color: #fff; padding: .1rem .45rem; border-radius: 99px; }
.admin-banner { display: flex; gap: .8rem; align-items: center; background: linear-gradient(135deg, #eef3ff, #f6f0fd); border: 1px solid #d9e2fb; border-radius: 16px; padding: .85rem 1rem; margin-bottom: 1.2rem; font-size: .88rem; color: var(--text); }
.admin-banner .ab-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0; }
.admin-banner p { margin: 0; color: var(--text2); font-size: .82rem; }
.admin-banner .ab-act { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
@media (max-width: 640px) { .admin-banner { flex-wrap: wrap; } .admin-banner .ab-act { margin-left: 0; width: 100%; } .admin-banner .ab-act .btn { flex: 1; justify-content: center; } }
    .lang-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
    .lang-dot.fr { background: linear-gradient(90deg, #1d4ed8 33%, #fff 33% 66%, #ef4444 66%); box-shadow: 0 0 0 1px #c9d4f3; }
    .lang-dot.en { background: radial-gradient(circle, #ef4444 30%, #fff 31% 45%, #1e3a8a 46%); box-shadow: 0 0 0 1px #c9d4f3; }

/* Menú lateral: la lista hace scroll y «Cerrar sesión» queda siempre visible abajo (también en teléfonos pequeños) */
.sidebar { height: 100vh; height: 100dvh; min-height: 0; }
.sidebar-logo { flex-shrink: 0; }
.sidebar-nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sidebar-footer { flex-shrink: 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); background: var(--bg2); }
.logout-btn { display: flex; align-items: center; justify-content: center; gap: .45rem; width: 100%; margin-top: .7rem; padding: .6rem .8rem;
  border: 1px solid #f3c4c4; background: #fff5f5; color: #b42318; border-radius: 12px; font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.logout-btn:hover { background: #fee2e2; border-color: #ef9a9a; }

/* ============================================================
   Modo oscuro (Mi perfil → Apariencia). app.js pone <html class="dark">.
   Los fondos usan variables, así que basta con redefinirlas.
   ============================================================ */
html.dark {
  --bg: #0d1120; --bg2: #161b2f; --bg3: #20263f; --bg-soft: #10152a; --border: #2b3252;
  --text: #e8ebf7; --text2: #a3aac5; --accent: #7fa7ff; --accent2: #b58dff;
  --brand-blue: #8fb2ff; --brand-soft: #1c2950;
  --shadow: 0 10px 30px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.25);
  color-scheme: dark;
}
html.dark body { background: var(--bg); }
html.dark input, html.dark select, html.dark textarea { background: var(--bg3); color: var(--text); border-color: var(--border); }
html.dark input::placeholder, html.dark textarea::placeholder { color: #7d84a3; }
html.dark .card:hover { border-color: #3a4370; }
html.dark .mobile-brand { background: rgba(22,27,47,.94); }
html.dark .tabbar { background: rgba(22,27,47,.97); border-top-color: var(--border); }
/* El logo tiene letras azul oscuro: va sobre una placa blanca */
html.dark .sidebar-logo .brand-badge, html.dark .mobile-brand .brand-badge { background: #fff; border-radius: 12px; padding: .3rem .55rem; }
html.dark .mobile-brand .brand-badge { padding: .15rem .5rem; }
/* Etiquetas de estado: tintes oscuros en lugar de pastel */
html.dark .badge-nuevo        { background: #262c47; color: #b9bfd8; }
html.dark .badge-reconocido, html.dark .badge-A2 { background: #1b2c55; color: #9dbcff; }
html.dark .badge-recuperable  { background: #3a2c10; color: #f6c35b; }
html.dark .badge-productivo, html.dark .badge-A1 { background: #123524; color: #6ee59a; }
html.dark .badge-automatizado, html.dark .badge-B2 { background: #2d1c4a; color: #cfa8ff; }
html.dark .badge-B1 { background: #45191b; color: #ff9b9b; }
html.dark .badge-C1 { background: #43260f; color: #ffb37a; }
html.dark .badge-C2 { background: #262c47; color: #e8ebf7; }
html.dark .toast { background: var(--bg2); }
html.dark .logout-btn { background: #2a1517; border-color: #5c2a2e; color: #ff9b9b; }
html.dark .admin-banner { background: linear-gradient(135deg, #18213f, #221a3d); border-color: #313a66; }
html.dark ::-webkit-scrollbar-thumb { background: #2f3658; }
/* Fondos pastel escritos a mano en las páginas → versión oscura */
html.dark [style*="background:#fee2e2"], html.dark [style*="background: #fee2e2"] { background: #3a1719 !important; }
html.dark [style*="background:#dcfce7"], html.dark [style*="background: #dcfce7"] { background: #113222 !important; }
html.dark [style*="background:#fff8eb"], html.dark [style*="background:#fef3c7"] { background: #352a12 !important; }

/* Selector de apariencia */
.theme-seg { display: flex; gap: .4rem; flex-wrap: wrap; }
.theme-seg button { flex: 1; min-width: 90px; border: 2px solid var(--border); background: var(--bg2); color: var(--text); border-radius: 12px; padding: .6rem .5rem; font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; }
.theme-seg button.on { border-color: var(--accent); background: var(--brand-soft); }
.theme-btn { border: 1px solid var(--border); background: var(--bg2); color: var(--text); border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; flex-shrink: 0; }
/* Botones blancos sobre fondos de color: texto azul oscuro también en modo oscuro */
html.dark .btn-white { background: #fff !important; color: #023ba2 !important; }
html.dark .count-pill { background: #2d1c4a !important; color: #cfa8ff !important; }
html.dark .lq-streak { background: #3a2210 !important; color: #ffb37a !important; }
html.dark .lq-streak.off { background: #262c47 !important; color: #a3aac5 !important; }
html.dark .lang-pill.fr { background: #1b2c55; color: #9dbcff; }
html.dark .lang-pill.en { background: #2d1c4a; color: #cfa8ff; }
html.dark .how, html.dark .help-box { background: var(--bg-soft) !important; border-color: var(--border) !important; }
html.dark .task.done { background: #11281c !important; border-color: #1f5136 !important; }
html.dark .lh-states { background: rgba(22,27,47,.96) !important; }
html.dark .act .min, html.dark .ws-btn { background: #1c2950 !important; border-color: #2b3a6b !important; color: #9dbcff !important; }
html.dark .ach.lock .medal, html.dark .ach.locked .medal { background: #262c47 !important; box-shadow: 0 0 0 5px #1b2036 !important; }
html.dark .pill { background: var(--bg3) !important; color: var(--text) !important; box-shadow: inset 0 0 0 1px var(--border); }
html.dark { --danger: #f87171; --success: #4ade80; --warning: #fbbf24; }
html.dark .flame .hint { color: #ffb37a; }

/* Aviso «sin conexión» (api.js) */
.offline-chip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 9998;
  background: #13183a; color: #fff; font-size: .8rem; font-weight: 600; padding: .5rem .95rem; border-radius: 99px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 2rem); text-align: center; }
.offline-chip[hidden] { display: none; }
body.has-tabbar .offline-chip { bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px)); }
html.dark .offline-chip { background: #2b3252; }
