/* 360EduSync — dashboard styles. Dark-first, indigo/teal palette, mobile-first. */

:root {
  color-scheme: dark;
  --bg: #0a0f1e;
  --surface: #121a2e;
  --surface-2: #182238;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e7ecf6;
  --muted: #93a0b8;
  --indigo: #7c88ff;
  --indigo-deep: #5b5ff0;
  --teal: #2fd6c0;
  --ok: #34d399;
  --fail: #fb7185;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --idle: #64748b;
  --shadow: 0 14px 40px rgba(3, 7, 18, 0.45);
  --shadow-2: 0 14px 40px rgba(3, 7, 18, 0.45);
  --shadow-1: 0 1px 2px rgba(3, 7, 18, 0.4), 0 8px 24px rgba(3, 7, 18, 0.28);
  --radius: 18px;
  --radius-lg: 22px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-pill: 999px;
  --focus: var(--teal);
  --topbar-h: 61px;
  /* Escala de espaciado — base 8px */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  /* Escala tipográfica */
  --fs-h1: clamp(1.6rem, 5vw, 2.1rem);
  --fs-h2: 1.5rem;
  --fs-h3: 1.15rem;
  --fs-body: 1rem;
  --fs-caption: 0.8rem;
  --lh-tight: 1.2;
  --lh-body: 1.5;
  --lh-relaxed: 1.65;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #eef1f8;
    --surface: #ffffff;
    --surface-2: #f3f5fc;
    --border: rgba(30, 41, 59, 0.1);
    --text: #1a2338;
    --muted: #5c677e;
    --indigo: #5157e8;
    --indigo-deep: #4338ca;
    --teal: #0d9488;
    --ok: #059669;
    --fail: #e11d48;
    --amber: #b45309;
    --blue: #2563eb;
    --idle: #94a3b8;
    --shadow: 0 12px 32px rgba(30, 41, 59, 0.1);
    --shadow-2: 0 12px 32px rgba(30, 41, 59, 0.1);
    --shadow-1: 0 1px 2px rgba(30, 41, 59, 0.06), 0 6px 18px rgba(30, 41, 59, 0.08);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, color-mix(in srgb, var(--indigo) 15%, transparent), transparent 60%),
    radial-gradient(900px 520px at -10% 105%, color-mix(in srgb, var(--teal) 11%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h2, h3 { margin: 0; letter-spacing: -0.01em; }

.hidden { display: none !important; }

/* Class display rules must not defeat the hidden attribute */
[hidden] { display: none !important; }

/* ---------- Logo & badge ---------- */

.logo {
  margin: 0;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.logo b {
  background: linear-gradient(92deg, var(--indigo), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.logo-lg { font-size: 2.1rem; }

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--teal) 40%, transparent);
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ---------- Buttons & fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-deep), var(--indigo) 55%, var(--teal) 130%);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--indigo-deep) 35%, transparent);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn.ghost:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, transparent); }

.btn-block { width: 100%; }

:is(a, button, textarea, input):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Foco visible accesible en cualquier elemento interactivo (select, summary, tabs…) */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Selección de texto con el acento de la marca */
::selection { background: color-mix(in srgb, var(--indigo) 32%, transparent); }

/* Barras de scroll discretas y coherentes */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 62%, transparent); }

.field { display: block; text-align: left; }

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease;
}

.field input:focus { border-color: var(--indigo); outline: none; }

/* ---------- Gate ---------- */

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: min(380px, 100%);
  display: grid;
  gap: 18px;
  padding: 40px 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease both;
}

.gate-subtitle {
  margin: -12px 0 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.gate-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--fail) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--fail) 35%, transparent);
  color: var(--fail);
  font-size: 0.88rem;
}

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 12px clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px) 48px;
}

/* ---------- Navegación: sidebar agrupada (escritorio) · drawer (móvil) ---------- */

.nav-toggle {
  display: none; /* solo visible en móvil */
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.nav-toggle:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.nav-toggle-icon { width: 20px; height: 20px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent;
}

.nav-group { display: grid; gap: 2px; margin-top: 16px; }

.nav-group-title {
  margin: 0 0 4px;
  padding: 0 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.72;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-icon { flex: none; width: 18px; height: 18px; opacity: 0.85; }

.nav-link:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }

/* Estado activo: píldora índigo suave con texto de acento */
.nav-link.active {
  color: var(--indigo);
  background: color-mix(in srgb, var(--indigo) 14%, transparent);
}
.nav-link.active .nav-icon { opacity: 1; }

/* Móvil (≤820px): la sidebar se vuelve un drawer deslizante desde la izquierda */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }

  .nav {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 45;
    width: min(280px, 82vw);
    padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 20px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .nav-group:first-of-type { margin-top: 6px; }

  .layout.nav-open .nav { transform: translateX(0); }

  /* Overlay oscuro detrás del drawer (pseudo-elemento, no requiere markup nuevo) */
  .layout::before {
    content: "";
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: rgba(2, 6, 20, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.26s ease, visibility 0.26s;
  }
  .layout.nav-open::before { opacity: 1; visibility: visible; }
}

.content { display: grid; gap: 40px; padding-top: 20px; }

.section { scroll-margin-top: 130px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 { font-size: 1.35rem; }

.kicker {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.footer {
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------- Status ---------- */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.status-card {
  padding: 16px;
  display: grid;
  gap: 10px;
  transition: transform 0.15s ease;
}

.status-card:hover { transform: translateY(-2px); }

.status-top { display: flex; align-items: center; gap: 10px; }
.status-top h3 { font-size: 0.95rem; font-weight: 600; }

.dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--idle) 16%, transparent);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.dot[data-state="ok"] {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent);
}

.dot[data-state="fail"] {
  background: var(--fail);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--fail) 18%, transparent);
}

.dot[data-state="checking"] { animation: pulse 1.1s ease-in-out infinite; }

.status-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.status-meta .ms { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.status-meta .time { color: var(--muted); font-size: 0.74rem; white-space: nowrap; }

/* ---------- Chat ---------- */

.chat { padding: 16px; display: grid; gap: 12px; }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 160px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
  overscroll-behavior: contain;
}

.chat-empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 82%;
  animation: rise 0.25s ease both;
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--indigo-deep), var(--indigo));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.assistant .bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.msg.error .bubble {
  background: color-mix(in srgb, var(--fail) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--fail) 30%, transparent);
  color: var(--fail);
}

.msg-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.typing .bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.typing .dots { display: inline-flex; gap: 3px; }

.typing .dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s ease-in-out infinite;
}
.typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.typing .dots i:nth-child(3) { animation-delay: 0.3s; }

.chat-composer { display: flex; gap: 10px; align-items: flex-end; }

.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: none;
  transition: border-color 0.15s ease;
}

.chat-composer textarea:focus { border-color: var(--indigo); outline: none; }

.hint { margin: -4px 0 0; color: var(--muted); font-size: 0.72rem; }

/* ---------- Dictation ---------- */

.stt { padding: 20px; display: grid; gap: 16px; }

.stt-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.btn.record {
  padding: 14px 26px;
  font-size: 1.02rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.btn.record .rec-icon { font-size: 1.2rem; }

.btn.record[data-state="recording"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #e11d48, #f43f5e);
  animation: ring 1.4s ease-out infinite;
}

.rec-timer {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fail);
}

.stt-status { margin: 0; color: var(--muted); font-size: 0.9rem; }
.stt-status.error { color: var(--fail); }

.stt-result {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: rise 0.25s ease both;
}

.stt-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

.stt-result blockquote {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--teal);
  line-height: 1.6;
}

/* ---------- Modules ---------- */

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.module-card {
  padding: 18px;
  display: grid;
  gap: 10px;
  opacity: 0.62;
  cursor: not-allowed;
  user-select: none;
}

.module-top { display: flex; align-items: center; justify-content: space-between; }

.module-level {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--indigo) 16%, transparent);
  color: var(--indigo);
  font-size: 0.72rem;
  font-weight: 700;
}

.module-lock { font-size: 1rem; filter: grayscale(0.4); }

.module-card h3 { font-size: 1rem; font-weight: 600; }

.module-tag {
  justify-self: start;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

/* Módulo activo (enlace a su sección) */

.module-card.unlocked {
  opacity: 1;
  cursor: pointer;
  user-select: auto;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.module-card.unlocked:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
}

.module-arrow { color: var(--teal); font-size: 1.05rem; font-weight: 700; }

.module-tag.on {
  border-style: solid;
  border-color: color-mix(in srgb, var(--teal) 40%, transparent);
  background: color-mix(in srgb, var(--teal) 12%, transparent);
  color: var(--teal);
}

/* ---------- Vocabulario (SRS) ---------- */

.srs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.srs-stat { padding: 14px 16px; display: grid; gap: 2px; }

.srs-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.srs-stat-label { color: var(--muted); font-size: 0.74rem; font-weight: 600; }

.srs-view { display: grid; gap: 14px; }

.srs-note { margin: 0; color: var(--muted); font-size: 0.88rem; }
.srs-note.error { color: var(--fail); }

/* Mazos */

.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.deck-card { padding: 18px; display: grid; gap: 10px; align-content: start; }
.deck-card h3 { font-size: 1.05rem; }
.deck-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.deck-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Progreso por unidades (mazo y encabezado de la vista de unidades) */

.deck-progress-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.deck-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--idle) 22%, transparent);
  overflow: hidden;
}

.deck-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--teal));
  transition: width 0.2s ease;
}

/* Vista de unidades */

.units-head { padding: 18px; display: grid; gap: 8px; }
.units-head h3 { font-size: 1.05rem; }

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.unit-chip {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px 14px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.unit-chip:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--indigo) 45%, transparent);
}

.unit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 20px;
}

.unit-label { font-weight: 700; font-size: 0.88rem; white-space: nowrap; }

.unit-check { color: var(--ok); font-weight: 800; }

.unit-next {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.unit-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--idle) 22%, transparent);
  overflow: hidden;
}

.unit-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--teal));
  transition: width 0.2s ease;
}

.unit-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.unit-chip.complete { opacity: 0.72; }
.unit-chip.complete .unit-fill { background: var(--ok); }

.unit-chip.next {
  border-color: color-mix(in srgb, var(--teal) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--teal) 30%, transparent), var(--shadow);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip.due { background: color-mix(in srgb, var(--indigo) 16%, transparent); color: var(--indigo); }
.chip.new { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }
.chip.zero { background: color-mix(in srgb, var(--idle) 14%, transparent); color: var(--muted); }
.chip.pos { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.chip.cefr { background: color-mix(in srgb, var(--indigo) 16%, transparent); color: var(--indigo); }
.chip.newbadge { background: linear-gradient(135deg, var(--indigo-deep), var(--teal)); color: #fff; }

/* Añadir desde texto */

.extract-card { padding: 16px 18px; }

.extract-card summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.extract-card summary::marker { color: var(--teal); }

.extract-body { display: grid; gap: 12px; padding-top: 14px; }

.extract-body textarea {
  width: 100%;
  min-height: 120px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
  transition: border-color 0.15s ease;
}

.extract-body textarea:focus { border-color: var(--indigo); outline: none; }

.extract-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.extract-actions .hint { margin: 0; }

.extract-result { display: grid; gap: 8px; }

.term-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.term-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--teal) 30%, transparent);
  background: color-mix(in srgb, var(--teal) 10%, transparent);
  font-size: 0.82rem;
  animation: rise 0.25s ease both;
}

.term-chip b { color: var(--teal); font-weight: 700; }

/* Sesión de repaso */

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.srs-progress {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.review-card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 32px);
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
}

.card-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
}

.srs-term {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.srs-back {
  width: 100%;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  animation: rise 0.3s ease both;
}

.srs-back-es {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--teal);
  overflow-wrap: anywhere;
}

.srs-secondary { margin: 0; color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.srs-example { font-style: italic; }

.rating-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.btn.rate {
  padding: 10px 4px;
  font-size: 0.86rem;
  border: 1px solid transparent;
}

.btn.rate kbd {
  font: inherit;
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid currentColor;
  opacity: 0.55;
}

.btn.rate.again {
  background: color-mix(in srgb, var(--fail) 13%, transparent);
  border-color: color-mix(in srgb, var(--fail) 32%, transparent);
  color: var(--fail);
}

.btn.rate.hard {
  background: color-mix(in srgb, var(--amber) 13%, transparent);
  border-color: color-mix(in srgb, var(--amber) 38%, transparent);
  color: var(--amber);
}

.btn.rate.good {
  background: color-mix(in srgb, var(--ok) 13%, transparent);
  border-color: color-mix(in srgb, var(--ok) 34%, transparent);
  color: var(--ok);
}

.btn.rate.easy {
  background: color-mix(in srgb, var(--blue) 13%, transparent);
  border-color: color-mix(in srgb, var(--blue) 36%, transparent);
  color: var(--blue);
}

@media (max-width: 480px) {
  .btn.rate { padding: 10px 2px; font-size: 0.78rem; gap: 4px; }
  .btn.rate kbd { display: none; }
}

/* Audio de pronunciación (TTS) */

.srs-term-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 100%;
}

.btn.audio-btn {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
}

.btn.audio-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 25%, transparent);
}

.btn.audio-btn.audio-slow {
  width: auto;
  min-width: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.btn.audio-btn.playing {
  opacity: 1; /* gana a .btn:disabled mientras suena */
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  background: color-mix(in srgb, var(--teal) 10%, transparent);
  animation: pulse 1.1s ease-in-out infinite;
}

.btn.audio-btn.muted { opacity: 0.4; }

.srs-toast {
  text-align: center;
  color: var(--teal);
  font-size: 0.85rem;
  font-weight: 600;
  animation: rise 0.25s ease both;
}

#srs-session-error { text-align: center; }
.srs-retry { justify-self: center; }

.srs-done {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 36px 24px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  animation: rise 0.3s ease both;
}

.srs-done-emoji { margin: 0; font-size: 2.4rem; }

/* ---------- Escritorio: sidebar fija + rejilla de dos columnas ---------- */

@media (min-width: 821px) {
  .layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }

  .nav {
    position: sticky;
    top: calc(var(--topbar-h) + 12px);
    max-height: calc(100dvh - var(--topbar-h) - 24px);
    padding: 4px 4px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .section { scroll-margin-top: calc(var(--topbar-h) + 12px); }

  .section-head h2 { font-size: 1.5rem; }
}

/* ---------- Animations ---------- */

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.45); }
  100% { box-shadow: 0 0 0 14px rgba(244, 63, 94, 0); }
}

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

/* ---------- L1.b: sesión de usuario y administración de miembros ---------- */

.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 14px; white-space: nowrap; }

.linklike {
  background: none;
  border: 0;
  color: var(--indigo);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  margin-top: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: var(--teal); }

.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.table-scroll { overflow-x: auto; }
.members-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.members-table th,
.members-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.members-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.members-table tr:last-child td { border-bottom: 0; }

.member-form-card { margin-top: 16px; }
.member-form { display: grid; gap: 12px; max-width: 460px; }

.member-cred {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px dashed var(--indigo);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--indigo) 8%, transparent);
}
.cred-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cred-row code { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; word-break: break-all; }

/* ---------- Mi nivel (colocación MCER) ---------- */

.placement-view { display: grid; gap: 14px; }

.placement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.placement-card { padding: 20px; display: grid; gap: 6px; align-content: start; }
.placement-card h3 { font-size: 1rem; font-weight: 600; }

.placement-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.placement-level {
  margin: 4px 0 0;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(92deg, var(--indigo), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.placement-level.empty { background: none; color: var(--idle); }

.placement-detail { margin: 0; color: var(--muted); font-size: 0.85rem; }

.placement-card .btn { justify-self: start; margin-top: 8px; }

/* Runner del test de reconocimiento */

.lex-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--idle) 22%, transparent);
  overflow: hidden;
}

.lex-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--teal));
  transition: width 0.2s ease;
}

.lex-card {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 40px);
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
}

.lex-card h3 { font-size: 1.15rem; }

.lex-word {
  margin: 8px 0;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.lex-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.lex-answers .btn {
  padding: 18px 12px;
  font-size: 1.02rem;
  border: 1px solid transparent;
}

.lex-answers kbd {
  font: inherit;
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid currentColor;
  opacity: 0.55;
}

.btn.lex-yes {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border-color: color-mix(in srgb, var(--ok) 36%, transparent);
  color: var(--ok);
}

.btn.lex-no {
  background: color-mix(in srgb, var(--fail) 11%, transparent);
  border-color: color-mix(in srgb, var(--fail) 28%, transparent);
  color: var(--fail);
}

.lex-score {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lex-error { text-align: center; }
.lex-retry { justify-self: center; }

@media (max-width: 480px) {
  .lex-answers { grid-template-columns: 1fr; }
  .lex-answers kbd,
  .lex-hint { display: none; }
}

/* Resultado de escritura */

.writing-result { display: grid; gap: 10px; padding-top: 4px; }
.writing-result .placement-level { margin: 0; }
.writing-feedback { margin: 0; line-height: 1.6; }
.writing-list { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- Lectura (módulo L2) ---------- */

.reader-view { display: grid; gap: 14px; }

.reader-form-card,
.reader-history-card { padding: 18px; display: grid; gap: 12px; align-content: start; }
.reader-form-card h3,
.reader-history-card h3 { font-size: 1.05rem; }

.reader-form { display: grid; gap: 12px; }

.reader-form textarea {
  width: 100%;
  min-height: 150px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
  transition: border-color 0.15s ease;
}
.reader-form textarea:focus { border-color: var(--indigo); outline: none; }

/* Historial */

.reader-history { list-style: none; margin: 0; padding: 0; display: grid; }

.reader-history-item {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.reader-history-item:first-child { padding-top: 0; }
.reader-history-item:last-child { border-bottom: 0; padding-bottom: 0; }

.rh-title { font-weight: 600; overflow-wrap: anywhere; }
.rh-meta { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* Vista de lectura */

.reader-timer {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.reader-doc-title { font-size: 1.15rem; overflow-wrap: anywhere; }
.reader-hint { margin: 0; }

.reader-paragraphs { display: grid; gap: 10px; }

.reader-p { padding: 14px 16px; display: grid; gap: 8px; }
.reader-p-row { display: flex; align-items: flex-start; gap: 10px; }

.reader-p-en {
  margin: 0;
  flex: 1;
  font-size: 1.02rem;
  line-height: 1.75; /* párrafos cómodos de leer en móvil */
  overflow-wrap: anywhere;
}

.reader-es-btn {
  flex: none;
  margin-top: 3px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.reader-es-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.reader-es-btn:disabled { opacity: 0.6; cursor: default; }
.reader-es-btn.loading { animation: pulse 1.1s ease-in-out infinite; }
.reader-es-btn.open {
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  background: color-mix(in srgb, var(--teal) 10%, transparent);
}

.reader-p-es {
  margin: 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  animation: rise 0.2s ease both;
}
.reader-p-es.error { color: var(--fail); font-style: normal; }

.reader-finish-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding-top: 4px;
}

/* Botón flotante «＋ Vocabulario» sobre la selección */

.reader-float-add {
  position: absolute;
  z-index: 60;
  transform: translateX(-50%);
  padding: 9px 15px;
  border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--teal);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow);
  animation: rise 0.15s ease both;
}

/* Tarjeta de palabra: hoja inferior fija, usable con el pulgar */

.reader-word-pop {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  width: min(480px, calc(100vw - 20px));
  max-height: 60vh;
  overflow-y: auto;
  z-index: 70;
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  animation: rise 0.2s ease both;
}

.rw-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rw-term { font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.rw-es { margin: 0; color: var(--teal); font-weight: 700; overflow-wrap: anywhere; }

.rw-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.rw-added {
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 700;
  animation: rise 0.2s ease both;
}
.rw-added.dup {
  background: color-mix(in srgb, var(--idle) 16%, transparent);
  color: var(--muted);
}

/* Quiz de comprensión */

.reader-quiz-fallback { display: flex; gap: 10px; flex-wrap: wrap; }

.reader-quiz-form { display: grid; gap: 12px; }
.reader-questions { display: grid; gap: 12px; }

.quiz-q { padding: 16px 18px; display: grid; gap: 8px; }
.quiz-q-text { margin: 0; font-weight: 700; line-height: 1.45; }

.quiz-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.quiz-opt:hover { border-color: color-mix(in srgb, var(--indigo) 45%, transparent); }
.quiz-q.graded .quiz-opt { cursor: default; }
.quiz-q.graded .quiz-opt:hover { border-color: var(--border); }

.quiz-opt input { margin: 3px 0 0; accent-color: var(--indigo); }

.quiz-opt.correct {
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}
.quiz-q.graded .quiz-opt.correct:hover { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }

.quiz-opt.wrong {
  border-color: color-mix(in srgb, var(--fail) 50%, transparent);
  background: color-mix(in srgb, var(--fail) 10%, transparent);
}
.quiz-q.graded .quiz-opt.wrong:hover { border-color: color-mix(in srgb, var(--fail) 50%, transparent); }

.quiz-expl {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  color: var(--amber);
  font-size: 0.88rem;
  animation: rise 0.2s ease both;
}

#reader-grade { justify-self: center; }
#reader-grade-status { text-align: center; }

.srs-note.busy { animation: pulse 1.1s ease-in-out infinite; }

/* Resumen de la lectura */

.reader-summary {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  animation: rise 0.3s ease both;
}

.reader-wpm {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(92deg, var(--indigo), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.reader-wpm-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.reader-summary-quiz { margin: 6px 0 0; font-weight: 700; }
.reader-summary .btn { margin-top: 10px; }

#reader-finish-error { text-align: center; }
#reader-finish-retry { justify-self: center; }

/* Desktop: inicio a dos columnas (formulario + historial) */
@media (min-width: 960px) {
  #reader-home {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }
}

/* ---------- Práctica oral (módulo L3) ---------- */

.oral-view { display: grid; gap: 14px; }

/* Catálogo */

.oral-profiles { display: grid; gap: 24px; }
.oral-profile-block { display: grid; gap: 12px; }

.oral-profile-head {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}

.oral-sc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.oral-sc-card {
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.oral-sc-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.oral-best {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--amber) 16%, transparent);
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.oral-sc-title { margin: 0; font-size: 1.02rem; font-weight: 700; overflow-wrap: anywhere; }
.oral-sc-cando { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }

.oral-sc-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.oral-sc-done { color: var(--muted); font-size: 0.74rem; font-weight: 600; }

/* Intro del escenario */

.oral-intro-card { padding: clamp(18px, 4vw, 26px); display: grid; gap: 12px; }
.oral-intro-head { display: flex; flex-wrap: wrap; gap: 6px; }
.oral-intro-card h3 { font-size: 1.2rem; overflow-wrap: anywhere; }

.oral-cando {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--teal);
  background: var(--surface-2);
  font-size: 0.92rem;
  line-height: 1.5;
}

.oral-desc { line-height: 1.55; }

.oral-phases { display: grid; gap: 8px; }

.oral-phase-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  gap: 4px;
}

.oral-phase-name {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.oral-phase-min {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.oral-phase-goal { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.oral-trend {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--indigo) 8%, transparent);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.oral-mic-note {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--teal) 35%, transparent);
  background: color-mix(in srgb, var(--teal) 7%, transparent);
  font-size: 0.85rem;
}

.oral-intro-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* Conversación */

.oral-phase-tag {
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--indigo) 14%, transparent);
  color: var(--indigo);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.oral-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px;
  overscroll-behavior: contain;
}

.oral-msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 88%;
  animation: rise 0.25s ease both;
}

.oral-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.oral-msg.interlocutor { align-self: flex-start; }

.oral-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.oral-msg.user .oral-bubble {
  background: linear-gradient(135deg, var(--indigo-deep), var(--indigo));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.oral-msg.interlocutor .oral-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.oral-speak {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.oral-speak:hover { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, transparent); }

.oral-msg.thinking .oral-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.oral-msg.thinking .dots { display: inline-flex; gap: 3px; }
.oral-msg.thinking .dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s ease-in-out infinite;
}
.oral-msg.thinking .dots i:nth-child(2) { animation-delay: 0.15s; }
.oral-msg.thinking .dots i:nth-child(3) { animation-delay: 0.3s; }

/* Composer de la conversación */

.oral-composer { display: grid; gap: 12px; }

.oral-transcribing { text-align: center; }

.oral-draft {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--indigo) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: rise 0.2s ease both;
}

.oral-draft textarea {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: none;
  transition: border-color 0.15s ease;
}
.oral-draft textarea:focus { border-color: var(--indigo); outline: none; }

.oral-draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.oral-rec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Botón de grabar grande, cómodo con el pulgar en móvil */
.btn.record.oral-record {
  padding: 15px 24px;
  font-size: 1rem;
}

.oral-write { margin-left: auto; }

.oral-finish-row { display: flex; justify-content: center; }
.oral-finish { min-width: 220px; }

/* Evaluación (rúbrica MCER) */

.oral-eval-result { display: grid; gap: 14px; }

.oral-band-card {
  padding: 24px;
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.oral-band {
  margin: 0;
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(92deg, var(--indigo), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.oral-band-cefr {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.02em;
}

.oral-criteria { display: grid; gap: 10px; }

.oral-crit { padding: 14px 16px; display: grid; gap: 8px; }

.oral-crit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.oral-crit-name { font-weight: 700; font-size: 0.95rem; }

.oral-crit-dots { display: inline-flex; gap: 6px; }

.oral-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--idle) 26%, transparent);
}

/* Color por banda alcanzada: 0 rojo, 1 ámbar, 2 verde, 3 teal */
.oral-dot.on.band-0 { background: var(--fail); }
.oral-dot.on.band-1 { background: var(--amber); }
.oral-dot.on.band-2 { background: var(--ok); }
.oral-dot.on.band-3 { background: var(--teal); }

.oral-crit-evidence {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.oral-crit-evidence li { overflow-wrap: anywhere; }

.oral-feedback-card { padding: 16px 18px; display: grid; gap: 6px; }
.oral-feedback { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }

.oral-eval-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 4px;
}

.oral-eval-retry { justify-self: center; }
#oral-eval-status,
#oral-eval-error { text-align: center; }

@media (max-width: 480px) {
  .oral-write { margin-left: 0; }
  .oral-rec-row .btn.record.oral-record { flex: 1 1 auto; }
}

/* ---------- Pronunciación (módulo L3.b) ---------- */

.pron-view { display: grid; gap: 14px; }

/* Unidades (focos) */

.pron-units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.pron-unit-card {
  padding: 16px 18px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.pron-unit-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.pron-best {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: color-mix(in srgb, var(--idle) 16%, transparent);
  color: var(--muted);
}
.pron-best.good { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pron-best.mid { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.pron-best.low { background: color-mix(in srgb, var(--fail) 16%, transparent); color: var(--fail); }

.pron-unit-title { margin: 0; font-size: 1.02rem; font-weight: 700; overflow-wrap: anywhere; }
.pron-unit-meta { margin: 0; color: var(--muted); font-size: 0.8rem; }
.pron-unit-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* Práctica */

.pron-line-card { padding: clamp(18px, 4vw, 26px); display: grid; gap: 14px; }

.pron-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pron-line-count { color: var(--muted); font-size: 0.78rem; font-weight: 600; }

.pron-target {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  padding-left: 14px;
  border-left: 3px solid var(--teal);
}

.pron-hint { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.pron-rec-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn.record.pron-record { padding: 15px 24px; font-size: 1rem; }

.pron-rec-note { margin: 0; }
.pron-rec-note.busy { animation: pulse 1.1s ease-in-out infinite; }
.pron-retry-rec { justify-self: start; }

/* Resultado */

.pron-result { display: grid; gap: 14px; animation: rise 0.25s ease both; }

.pron-score-card {
  padding: 22px;
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.pron-accuracy {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.pron-accuracy.good { color: var(--ok); }
.pron-accuracy.mid { color: var(--amber); }
.pron-accuracy.low { color: var(--fail); }

.pron-accuracy-label { margin: 0; color: var(--muted); font-size: 0.82rem; }

.pron-words-card { padding: 16px 18px; display: grid; gap: 8px; }

.pron-words {
  margin: 0;
  font-size: 1.15rem;
  line-height: 2.1;
  overflow-wrap: anywhere;
}

.pron-word {
  display: inline;
  padding: 2px 4px;
  border-radius: 6px;
  font-weight: 600;
}
.pron-word.ok {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}
.pron-word.bad {
  background: color-mix(in srgb, var(--fail) 14%, transparent);
  color: var(--fail);
}
.pron-word.bad .pron-word-exp { text-decoration: line-through; text-decoration-thickness: 1.5px; }

.pron-word-heard {
  margin-left: 2px;
  font-size: 0.62em;
  font-weight: 700;
  color: var(--amber);
  vertical-align: super;
}

.pron-issues-card { padding: 16px 18px; display: grid; gap: 8px; }

.pron-issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }

.pron-issue {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pron-issue-pair {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.pron-issue-exp { color: var(--ok); overflow-wrap: anywhere; }
.pron-issue-arrow { color: var(--muted); }
.pron-issue-heard { color: var(--fail); overflow-wrap: anywhere; }

.pron-issue-note { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; overflow-wrap: anywhere; }

.pron-result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 4px;
}

@media (max-width: 480px) {
  .pron-rec-row .btn.record.pron-record { flex: 1 1 auto; }
  .pron-result-actions .btn { flex: 1 1 auto; }
}

/* ---------- Retos (módulo L4: motivación familiar) ---------- */

.game-view { display: grid; gap: 14px; }

/* 1 · Racha — tarjeta destacada */

.streak-card {
  padding: 22px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--amber) 14%, transparent), transparent 60%),
    var(--surface);
  border-color: color-mix(in srgb, var(--amber) 30%, var(--border));
}

.streak-flame { display: flex; align-items: center; gap: 14px; }
.streak-emoji { font-size: 3.2rem; line-height: 1; filter: saturate(1.1); }
.streak-count-block { display: grid; gap: 2px; }

.streak-count {
  margin: 0;
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.streak-count-label { margin: 0; color: var(--muted); font-size: 0.82rem; font-weight: 600; }

.streak-meta { display: grid; gap: 6px; justify-items: end; text-align: right; }
.streak-record { margin: 0; color: var(--muted); font-size: 0.84rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.streak-today { margin: 0; font-size: 0.88rem; font-weight: 600; }
.streak-today.active { color: var(--ok); }
.streak-today.at-risk { color: var(--amber); }

.streak-freeze {
  position: relative;
  gap: 4px;
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  color: var(--blue);
  cursor: help;
}

.streak-freeze .tip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-width: 220px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 500;
  white-space: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 5;
}

.streak-freeze:hover .tip,
.streak-freeze:focus-visible .tip { opacity: 1; visibility: visible; transform: translateY(0); }

/* 2 · Esfuerzo de la semana */

.effort-card { padding: 20px; display: grid; gap: 14px; }

.effort-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.effort-goal-text { margin: 4px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.effort-goal-pct {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(92deg, var(--indigo), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.effort-spark { display: grid; gap: 4px; }

.spark-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 6px;
  height: 56px;
}

.spark-bar {
  align-self: end;
  min-height: 3px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--indigo) 45%, transparent);
  transition: height 0.2s ease;
}

.spark-bar.today { background: linear-gradient(180deg, var(--indigo), var(--teal)); }
.spark-bar.empty { background: color-mix(in srgb, var(--idle) 20%, transparent); }

.spark-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
}

.effort-today { display: grid; gap: 8px; }

.effort-today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.effort-metric {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.effort-metric b { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.effort-metric span { color: var(--muted); font-size: 0.74rem; font-weight: 600; }

/* 3 · Competencia real (CEFR) — visualmente distinta de los puntos */

.cefr-card {
  padding: 20px;
  display: grid;
  gap: 8px;
  align-content: start;
  border-left: 3px solid var(--indigo);
}

.cefr-summary {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
}
.cefr-summary .cefr-band { color: var(--indigo); font-weight: 800; }
.cefr-summary.empty { color: var(--muted); font-weight: 600; font-size: 1rem; }

.cefr-note { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.cefr-card .btn { justify-self: start; margin-top: 4px; }

/* 4 · Reto familiar cooperativo */

.challenge-card {
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: start;
  border-color: color-mix(in srgb, var(--teal) 28%, var(--border));
  background:
    radial-gradient(120% 130% at 100% 0%, color-mix(in srgb, var(--teal) 10%, transparent), transparent 55%),
    var(--surface);
}

.challenge-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.challenge-tag {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.01em;
}

.challenge-days { color: var(--muted); font-size: 0.82rem; font-weight: 600; }

.challenge-label { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.3; }

.challenge-celebrate {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  color: var(--teal);
  font-weight: 700;
  font-size: 0.92rem;
}

.challenge-progress-row { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.challenge-total { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.challenge-goal { color: var(--muted); font-size: 1rem; font-weight: 600; }

.challenge-contrib-title { margin: 4px 0 0; color: var(--muted); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

.challenge-contrib { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.challenge-contrib li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.9rem;
}
.challenge-contrib .contrib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.challenge-contrib .contrib-value { color: var(--teal); font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.challenge-contrib .contrib-empty { color: var(--muted); font-size: 0.85rem; }

.challenge-admin { margin-top: 6px; }
.challenge-admin summary { color: var(--muted); }

@media (max-width: 480px) {
  .streak-card { padding: 18px; }
  .streak-meta { justify-items: start; text-align: left; }
  .streak-emoji { font-size: 2.6rem; }
  .streak-count { font-size: 2.3rem; }
}

@media (min-width: 960px) {
  .game-view {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .effort-card { grid-row: span 2; }
}

/* ---------- Inmersivo (módulo LX) ---------- */

.lx-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 16px;
}
.lx-tabs::-webkit-scrollbar { display: none; }

.lx-tab {
  flex: 1 0 auto;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.lx-tab:hover { color: var(--text); }
.lx-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-deep), var(--indigo) 55%, var(--teal) 130%);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--indigo-deep) 30%, transparent);
}

.lx-mode { display: grid; gap: 14px; }

/* Modo 1 · cámara / foto */

.lx-cam-card { padding: 16px; display: grid; gap: 14px; }

.lx-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--idle) 12%, var(--surface-2));
  display: grid;
  place-items: center;
}

.lx-video,
.lx-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.lx-stage-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}
.lx-stage-emoji { font-size: 2.6rem; }

.lx-cam-controls { display: flex; flex-wrap: wrap; gap: 8px; }

.lx-upload-btn { cursor: pointer; }
.lx-upload-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.lx-labels-wrap { display: grid; gap: 8px; }
.lx-labels { display: flex; flex-wrap: wrap; gap: 8px; }
.lx-approx { font-size: 0.8rem; font-style: italic; }

/* Chips tappables (reutilizan .term-chip) */
.lx-chip {
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.lx-chip:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--teal) 55%, transparent); }
.lx-chip:disabled { cursor: default; transform: none; }
.lx-chip.busy { opacity: 0.7; }
.lx-chip.added {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
}
.lx-chip.added b { color: var(--ok); }
.lx-chip.added.dup {
  border-color: color-mix(in srgb, var(--idle) 35%, transparent);
  background: color-mix(in srgb, var(--idle) 16%, transparent);
  color: var(--muted);
}

.lx-text-card { padding: 16px; display: grid; gap: 8px; }
.lx-text-en { margin: 0; line-height: 1.6; }
.lx-text-es { margin: 0; color: var(--muted); line-height: 1.55; }

/* Modo 2 · galería 3D */

.lx-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.lx-model-card { padding: 12px; display: grid; gap: 10px; align-content: start; }

.lx-model-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--idle) 12%, var(--surface-2));
}

.lx-model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background: transparent;
}

.lx-model-fail {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.lx-model-body { display: grid; gap: 8px; }
.lx-model-term { margin: 0; font-size: 0.95rem; }
.lx-model-term b { color: var(--teal); font-weight: 700; }
.lx-model-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lx-model-credit { font-size: 0.74rem; opacity: 0.85; }
.lx-model-note { color: var(--fail); }
.lx-added { align-self: start; }

/* Modo 3 · placeholder */

.lx-soon {
  padding: 40px 24px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.lx-soon-emoji { font-size: 2.6rem; opacity: 0.85; }

/* Modo 3 · Hablar en público (WebXR / A-Frame) */

.pub-view { display: grid; gap: 14px; }

.pub-intro-card { padding: 20px; display: grid; gap: 12px; justify-items: start; }
.pub-intro-emoji { font-size: 2.4rem; }
.pub-intro-card h3 { margin: 0; font-size: 1.15rem; }
.pub-intro-lead { line-height: 1.55; }

.pub-field { display: grid; gap: 6px; width: 100%; }
.pub-field-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.pub-field input,
.pub-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease;
}
.pub-field textarea { resize: vertical; min-height: 84px; }
.pub-field input:focus,
.pub-field textarea:focus { border-color: var(--indigo); outline: none; }
.pub-intro-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }

/* Escenario: contenedor de la escena A-Frame + HUD sobrepuesto */
.pub-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 68vh;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(120% 100% at 50% 0%, #16223e, #0a1120 70%);
}

.pub-scene-host { position: absolute; inset: 0; }
.pub-scene-host a-scene,
.pub-scene-host canvas { width: 100% !important; height: 100% !important; }

/* Teleprompter HTML (modo degradado sin escena) */
.pub-teleprompter-html {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 30px 22px 66px;
  text-align: center;
  overflow-y: auto;
}
.pub-tele-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}
.pub-tele-text {
  margin: 0;
  max-width: 640px;
  justify-self: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  color: var(--text);
}

.pub-hud-timer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, #0a1120 70%, transparent);
  color: var(--teal);
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.btn.record.pub-record {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 13px 22px;
  font-size: 0.98rem;
  box-shadow: var(--shadow);
}

.pub-transcribing { text-align: center; }

/* Borrador editable de la transcripción */
.pub-draft {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--indigo) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: rise 0.2s ease both;
}
.pub-draft textarea {
  width: 100%;
  min-height: 96px;
  max-height: 240px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
  transition: border-color 0.15s ease;
}
.pub-draft textarea:focus { border-color: var(--indigo); outline: none; }
.pub-draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pub-eval-retry { justify-self: center; }
#pub-eval-status,
#pub-eval-error { text-align: center; }

@media (max-width: 480px) {
  .lx-tab { flex: 1 0 auto; padding: 8px 12px; font-size: 0.84rem; }
  .lx-model-actions .btn { flex: 1 1 auto; }
  .pub-stage { aspect-ratio: 4 / 5; }
  .btn.record.pub-record { width: calc(100% - 28px); justify-content: center; }
}

/* ==========================================================================
   Refinamientos del sistema visual (Inicio, estados, encabezados)
   ========================================================================== */

/* ---------- Encabezados de sección con más aire ---------- */

.section-head { margin-bottom: 20px; }

/* ---------- Inicio (aterrizaje) ---------- */

.home { display: grid; gap: 28px; }

/* Hero: saludo + chips de resumen del día */
.home-hero { display: grid; gap: 14px; }

.home-greeting {
  margin: 0;
  font-size: var(--fs-h1);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

.home-daystats { display: flex; flex-wrap: wrap; gap: 10px; }

.home-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: 0.9rem;
}

.home-stat-emoji { font-size: 1.15rem; line-height: 1; }
.home-stat-text b { font-weight: 800; font-variant-numeric: tabular-nums; }
.home-stat-unit { color: var(--muted); }
.home-stat-chip.streak b { color: var(--amber); }
.home-stat-chip.effort b { color: var(--indigo); }

/* Bloques (Continúa / Explora todo) */
.home-block { display: grid; gap: 14px; }

.home-block-title {
  margin: 0;
  font-size: var(--fs-h3);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Fila «Continúa» — tarjetas destacadas con acento índigo */
.home-continue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.home-action {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 18px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  border-color: color-mix(in srgb, var(--indigo) 22%, var(--border));
  background:
    radial-gradient(130% 130% at 0% 0%, color-mix(in srgb, var(--indigo) 9%, transparent), transparent 60%),
    var(--surface);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-action:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--indigo) 45%, transparent);
  box-shadow: var(--shadow-2);
}

.home-action-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--indigo) 16%, transparent);
  color: var(--indigo);
}
.home-action-icon svg { width: 22px; height: 22px; }

.home-action-body { display: grid; gap: 3px; min-width: 0; }
.home-action-name { font-size: 1rem; font-weight: 700; }
.home-action-detail { color: var(--muted); font-size: 0.86rem; line-height: 1.4; }

.home-action-track { display: block; margin-top: 8px; }
.home-action-track .deck-fill { display: block; }

/* «Explora todo» — grupos con tarjetas legibles */
.home-explore { display: grid; gap: 22px; }
.home-group { display: grid; gap: 12px; }

.home-group-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.home-card {
  display: grid;
  gap: 8px;
  align-content: start;
  width: 100%;
  padding: 16px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--teal) 40%, transparent);
  box-shadow: var(--shadow-2);
}

.home-card-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--teal);
}
.home-card-icon svg { width: 20px; height: 20px; }

.home-card-name { font-size: 0.98rem; font-weight: 700; }
.home-card-desc { color: var(--muted); font-size: 0.83rem; line-height: 1.45; }

/* ---------- Miembros: la tarjeta envuelve la tabla ---------- */

.members-card { padding: 8px 10px; }

/* ---------- Estados reutilizables: carga y vacío ---------- */

/* Skeleton (placeholder animado) */
.skeleton {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 9%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* Spinner sutil */
.spinner {
  display: inline-block;
  vertical-align: middle;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-top-color: var(--indigo);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Estado vacío centrado con texto guía */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state-emoji { font-size: 2rem; opacity: 0.8; }
.empty-state-title { margin: 0; font-weight: 700; color: var(--text); }
.empty-state-text { margin: 0; font-size: 0.9rem; line-height: 1.5; }
