/* =========================================================================
   Craic — estilos. Sin frameworks. Tokens en :root; modo oscuro abajo.
   ========================================================================= */

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --border: #e3e1da;
  --text: #151714;
  --text-2: #55584f;
  --muted: #7d8078;
  --brand: #16955a;
  --brand-strong: #0d7a49;
  --brand-soft: #e3f4ea;
  --on-brand: #ffffff;
  --flame: #e8660c;
  --flame-soft: #fdeede;
  --ice: #3b8fd4;
  --ice-soft: #e2effa;

  /* Botones de calificación (siempre con texto: el color nunca va solo) */
  --again: #c93c3c;
  --hard: #b86e0a;
  --good: #16955a;
  --easy: #2a6fc4;

  /* Gráficos: rampa ordinal verde validada (learning → young → mature) */
  --viz-new: #d9d7cf;
  --viz-1: #6fc995;
  --viz-2: #16955a;
  --viz-3: #0a5f39;
  --viz-bar: #16955a;
  --heat-0: #ebeae4;
  --heat-1: #b9e4c9;
  --heat-2: #6fc995;
  --heat-3: #16955a;
  --heat-4: #0a5f39;
  --grid: #ecebe6;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(20 30 25 / 6%), 0 4px 16px rgb(20 30 25 / 6%);
  --shadow-lg: 0 8px 32px rgb(20 30 25 / 12%);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1311;
    --surface: #171c19;
    --surface-2: #1f2622;
    --border: #2a322d;
    --text: #eef2ef;
    --text-2: #b3bdb6;
    --muted: #87928b;
    --brand: #34b877;
    --brand-strong: #5fd497;
    --brand-soft: #173325;
    --on-brand: #04130b;
    --flame: #ff8a3d;
    --flame-soft: #3a2415;
    --ice: #6cb4ef;
    --ice-soft: #16293a;
    --again: #ec6a6a;
    --hard: #e9a23b;
    --good: #34b877;
    --easy: #6aa5ef;
    --viz-new: #3a423d;
    --viz-1: #1f7a4d;
    --viz-2: #34b877;
    --viz-3: #8fe0b3;
    --viz-bar: #2a9d63;
    --heat-0: #222a25;
    --heat-1: #1d4a33;
    --heat-2: #1f7a4d;
    --heat-3: #34b877;
    --heat-4: #8fe0b3;
    --grid: #252c28;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    --shadow-lg: 0 8px 32px rgb(0 0 0 / 45%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1311;
  --surface: #171c19;
  --surface-2: #1f2622;
  --border: #2a322d;
  --text: #eef2ef;
  --text-2: #b3bdb6;
  --muted: #87928b;
  --brand: #34b877;
  --brand-strong: #5fd497;
  --brand-soft: #173325;
  --on-brand: #04130b;
  --flame: #ff8a3d;
  --flame-soft: #3a2415;
  --ice: #6cb4ef;
  --ice-soft: #16293a;
  --again: #ec6a6a;
  --hard: #e9a23b;
  --good: #34b877;
  --easy: #6aa5ef;
  --viz-new: #3a423d;
  --viz-1: #1f7a4d;
  --viz-2: #34b877;
  --viz-3: #8fe0b3;
  --viz-bar: #2a9d63;
  --heat-0: #222a25;
  --heat-1: #1d4a33;
  --heat-2: #1f7a4d;
  --heat-3: #34b877;
  --heat-4: #8fe0b3;
  --grid: #252c28;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
  --shadow-lg: 0 8px 32px rgb(0 0 0 / 45%);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--brand-strong); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

#view {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  outline: none;
  min-height: 100dvh;
}
body.no-tabbar #view { padding-bottom: calc(var(--safe-bottom) + 24px); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.75rem; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px;
  color: var(--muted); font-size: 0.7rem; font-weight: 600;
}
.tabbar a .ti { font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: 0.7; transition: filter .2s, opacity .2s, transform .2s; }
.tabbar a.active { color: var(--brand-strong); }
.tabbar a.active .ti { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

/* ---------- cards & surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title .hint { font-size: 0.8rem; color: var(--muted); }
.section-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 8px 4px -4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 650; font-size: 0.95rem;
  transition: transform .08s ease, background .15s, box-shadow .15s;
  white-space: nowrap;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--again); }
.btn.big { min-height: 58px; font-size: 1.1rem; border-radius: 18px; width: 100%; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn.icon { width: 44px; padding: 0; }
.link-btn { background: none; border: none; padding: 0; color: var(--brand-strong); font-weight: 600; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.input, select.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: none; padding-top: 4px; }
.setting .label { flex: 1; min-width: 0; }
.setting .label b { display: block; font-weight: 600; }
.setting .label small { display: block; color: var(--muted); font-size: 0.82rem; line-height: 1.35; margin-top: 2px; }
.setting .control { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.setting.col { flex-direction: column; align-items: stretch; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: none; background: var(--surface-2); font-size: 1.2rem; font-weight: 700; }
.stepper output { min-width: 48px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; padding: 7px 12px; border-radius: 9px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }

/* ---------- chips & badges ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; border: 1.5px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 99px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: var(--brand-strong); }
.badge.new { background: var(--ice-soft); color: var(--ice); }
.badge.flame { background: var(--flame-soft); color: var(--flame); }

/* ---------- auth ---------- */
.auth { min-height: 90dvh; display: flex; flex-direction: column; justify-content: center; gap: 28px; max-width: 400px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo img { width: 52px; height: 52px; border-radius: 14px; box-shadow: var(--shadow); }
.logo b { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; font-family: var(--font-display); }
.auth .tagline { color: var(--text-2); font-size: 1.05rem; }
.error-box { background: color-mix(in srgb, var(--again) 12%, var(--surface)); color: var(--again); border-radius: 12px; padding: 10px 14px; font-size: 0.9rem; font-weight: 600; }

/* ---------- home ---------- */
.greeting { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.greeting .date { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: var(--on-brand); border: none;
}
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #1b5e3d 0%, #0f3d27 100%); color: #eafff2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(135deg, #1b5e3d 0%, #0f3d27 100%); color: #eafff2; } }
.hero .big-num { font-size: 3rem; font-weight: 800; line-height: 1; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.hero .label { opacity: 0.85; font-weight: 600; }
.hero .btn { background: #fff; color: #0d6b40; border: none; box-shadow: 0 6px 18px rgb(0 0 0 / 18%); margin-top: 14px; }
.hero .btn.secondary { background: rgb(255 255 255 / 16%); color: inherit; box-shadow: none; }
.ring { position: relative; width: 96px; height: 96px; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .ring-label b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ring .ring-label small { font-size: 0.68rem; opacity: 0.85; }

.streak { display: flex; align-items: center; gap: 14px; }
.flame { font-size: 2.4rem; line-height: 1; filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--flame) 40%, transparent)); }
.flame.off { filter: grayscale(1); opacity: 0.45; }
.streak .count { font-size: 1.8rem; font-weight: 800; font-family: var(--font-display); line-height: 1; font-variant-numeric: tabular-nums; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 700; color: var(--muted); }
.week .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 0.85rem; border: 2px solid transparent; }
.week .dot.met { background: var(--flame); color: #fff; }
.week .dot.partial { background: var(--flame-soft); color: var(--flame); }
.week .dot.frozen { background: var(--ice-soft); color: var(--ice); }
.week .dot.today { border-color: var(--text); }
.freezes { display: inline-flex; gap: 2px; align-items: center; font-size: 0.85rem; color: var(--ice); font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .tiles.four { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.tile .v { font-size: 1.6rem; font-weight: 800; font-family: var(--font-display); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .k { font-size: 0.8rem; color: var(--text-2); font-weight: 600; margin-top: 4px; }
.tile .s { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.countdown { display: flex; align-items: center; gap: 14px; }
.countdown .days { font-size: 2rem; font-weight: 800; font-family: var(--font-display); color: var(--brand-strong); font-variant-numeric: tabular-nums; }
.tip { display: flex; gap: 12px; align-items: flex-start; }
.tip .ico { font-size: 1.5rem; line-height: 1.2; }
.tip b { display: block; margin-bottom: 2px; }
.tip p { color: var(--text-2); font-size: 0.9rem; }

/* ---------- study ---------- */
.study { display: flex; flex-direction: column; min-height: calc(100dvh - 60px); gap: 14px; }
.study-top { display: flex; align-items: center; gap: 12px; }
.progress { flex: 1; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.study-count { font-size: 0.85rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.offline-pill { font-size: 0.72rem; font-weight: 700; color: var(--hard); background: color-mix(in srgb, var(--hard) 14%, var(--surface)); padding: 3px 8px; border-radius: 99px; }

.flashcard {
  flex: 1; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: var(--shadow-lg); padding: 18px 20px 22px; min-height: 340px;
  animation: cardIn .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
.fc-meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); min-width: 0; }
.fc-meta .pack-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.fc-meta .kind, .fc-meta .badge, .fc-meta .btn { flex-shrink: 0; }
.fc-meta .kind { font-weight: 700; color: var(--text-2); }
.fc-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 14px; padding: 18px 0; }
.fc-prompt { font-size: clamp(1.6rem, 6vw, 2.3rem); font-weight: 750; font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.fc-prompt.es { color: var(--text); }
.fc-sub { color: var(--text-2); font-size: 1rem; }
.fc-cloze { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; font-size: 0.98rem; color: var(--text-2); font-style: italic; max-width: 100%; }
.fc-cloze .gap { display: inline-block; min-width: 3.5em; border-bottom: 2px solid var(--brand); margin: 0 2px; }
.fc-divider { width: 100%; height: 1px; background: var(--border); margin: 4px 0; }
.fc-answer { font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 700; color: var(--brand-strong); overflow-wrap: anywhere; }
.fc-example { font-size: 0.98rem; color: var(--text); }
.fc-example small { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.fc-note { font-size: 0.88rem; color: var(--text-2); background: color-mix(in srgb, var(--hard) 9%, var(--surface)); border-radius: 12px; padding: 8px 12px; text-align: left; }
.audio-btn { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface-2); font-size: 1.35rem; display: inline-grid; place-items: center; }
.audio-btn.big { width: 96px; height: 96px; font-size: 2.4rem; background: var(--brand-soft); border-color: transparent; }
.audio-btn.playing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); box-shadow: 0 0 0 10px color-mix(in srgb, var(--brand) 12%, transparent); } }
.answer-input { text-align: center; font-size: 1.15rem; font-weight: 600; min-height: 56px; border-radius: 16px; }
.answer-input.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
.answer-input.almost { border-color: var(--hard); background: color-mix(in srgb, var(--hard) 8%, var(--surface)); }
.answer-input.wrong { border-color: var(--again); background: color-mix(in srgb, var(--again) 8%, var(--surface)); }
.verdict { font-weight: 800; font-size: 1.05rem; display: inline-flex; gap: 6px; align-items: center; }
.verdict.correct { color: var(--good); } .verdict.almost { color: var(--hard); } .verdict.wrong { color: var(--again); }
.diff { font-size: 1rem; line-height: 1.8; }
.diff .miss { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--text); border-radius: 4px; padding: 1px 3px; font-weight: 700; }
.diff .extra { text-decoration: line-through; color: var(--again); padding: 0 2px; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 64px; padding: 6px 4px; border-radius: 16px;
  border: 2px solid color-mix(in srgb, var(--c) 30%, var(--border));
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  color: var(--c); font-weight: 750; font-size: 0.92rem;
  transition: transform .08s, background .15s;
}
.rate:active { transform: scale(0.95); }
.rate small { font-size: 0.72rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rate kbd { display: none; }
@media (hover: hover) { .rate kbd { display: inline; font: 600 0.65rem var(--font); color: var(--muted); } }
.rate.suggested { background: var(--c); color: #fff; border-color: var(--c); box-shadow: 0 4px 14px color-mix(in srgb, var(--c) 35%, transparent); }
.rate.suggested small, .rate.suggested kbd { color: rgb(255 255 255 / 88%); }
.rate[data-r="1"] { --c: var(--again); } .rate[data-r="2"] { --c: var(--hard); } .rate[data-r="3"] { --c: var(--good); } .rate[data-r="4"] { --c: var(--easy); }
.kbd-hint { text-align: center; font-size: 0.75rem; color: var(--muted); }
@media (hover: none) { .kbd-hint { display: none; } }

.done { text-align: center; align-items: center; justify-content: center; min-height: 70dvh; }
.done .emoji { font-size: 4rem; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- packs ---------- */
.pack-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .pack-grid { grid-template-columns: 1fr 1fr; } }
.pack { display: flex; flex-direction: column; gap: 10px; padding: 16px; cursor: pointer; transition: transform .12s, box-shadow .15s; }
.pack:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pack.active { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.pack-head { display: flex; gap: 12px; align-items: flex-start; }
.pack-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-size: 1.6rem; }
.pack.active .pack-icon { background: var(--brand-soft); }
.pack-desc { font-size: 0.85rem; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; gap: 2px; }
.bar i { display: block; height: 100%; }
.bar i:first-child { border-radius: 99px 0 0 99px; }
.bar i:last-child { border-radius: 0 99px 99px 0; }
.bar i:only-child { border-radius: 99px; }
.note-list { display: flex; flex-direction: column; }
.note-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-top: 1px solid var(--border); }
.note-row:first-child { border-top: none; }
.note-row .en { font-weight: 650; }
.note-row .es { color: var(--text-2); font-size: 0.92rem; }
.note-row .ex { color: var(--muted); font-size: 0.82rem; font-style: italic; margin-top: 2px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; background: var(--viz-new); }
.status-dot.learning { background: var(--viz-1); }
.status-dot.mature { background: var(--viz-3); }
.status-dot.suspended { background: transparent; border: 2px solid var(--muted); }
.code { font: 0.8rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border-radius: 12px; padding: 12px; overflow-x: auto; white-space: pre; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 40%); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
@media (min-width: 640px) { .modal-back { align-items: center; } }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 22px 18px calc(22px + var(--safe-bottom)); animation: slideUp .25s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 640px) { .modal { border-radius: 24px; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }

/* ---------- charts ---------- */
.viz { width: 100%; overflow: visible; display: block; }
.viz text { fill: var(--muted); font: 600 10px var(--font); }
.viz .gridline { stroke: var(--grid); stroke-width: 1; }
.viz .bar-mark { fill: var(--viz-bar); }
.viz .hit { fill: transparent; cursor: default; }
.viz .hit:hover + .bar-mark, .viz g.hov .bar-mark { opacity: 0.75; }
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.viz.heat { width: auto; max-width: none; }
.heat-cell { stroke: var(--surface); stroke-width: 2; }
.heat-cell:hover { stroke: var(--text); stroke-width: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.8rem; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.viz-tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 10px; padding: 7px 10px;
  font-size: 0.8rem; line-height: 1.35; box-shadow: var(--shadow-lg); max-width: 220px;
}
.viz-tooltip b { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.viz-tooltip .tl { opacity: 0.75; }
.stacked { display: flex; height: 18px; gap: 2px; border-radius: 6px; overflow: hidden; }
.stacked i { display: block; height: 100%; min-width: 3px; }
.kind-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 64px; gap: 10px; align-items: center; padding: 6px 0; font-size: 0.88rem; }
.table-toggle { font-size: 0.78rem; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 10px; }
table.data th, table.data td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- toast & misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px;
  font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 32px 16px; color: var(--text-2); }
.empty .emoji { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
details.science summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.science summary::after { content: "＋"; color: var(--muted); }
details.science[open] summary::after { content: "－"; }
details.science p { color: var(--text-2); font-size: 0.9rem; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.audio-btn.mini { width: 32px; height: 32px; font-size: 0.95rem; vertical-align: middle; margin-right: 6px; border-width: 1px; }
.voice-status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.voice-status.neural { background: var(--brand-soft); color: var(--brand-strong); }
.voice-status.browser { background: color-mix(in srgb, var(--hard) 14%, var(--surface)); color: var(--hard); }

/* ---------- música ---------- */
.song-card { display: block; color: inherit; }
.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); font-size: 0.92rem; }
.howto b { color: var(--text); }
.embed { border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); }
.embed iframe { display: block; width: 100%; border: 0; }
.embed.youtube iframe { aspect-ratio: 16 / 9; }
.embed.spotify { background: transparent; box-shadow: none; }
.embed.spotify iframe { height: 152px; border-radius: 12px; }
.lyrics { padding: 8px 6px; }
.lyric { border-radius: 12px; padding: 2px 4px; transition: background .15s; }
.lyric.open { background: var(--surface-2); padding: 6px 10px 12px; margin: 4px 0; }
.lyric-text {
  display: block; width: 100%; text-align: left; background: none; border: none; padding: 6px 4px;
  font-size: 1.05rem; line-height: 1.45; font-weight: 550; color: var(--text); border-radius: 8px;
}
.lyric-text:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.lyric-tr { padding: 0 4px 6px; color: var(--brand-strong); font-size: 0.92rem; line-height: 1.4; }
.lyric-tr.hidden-tr { filter: blur(6px); cursor: pointer; user-select: none; }
.lyric-tools { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.lyric-tools textarea { min-height: 64px; resize: vertical; font-size: 0.98rem; }
.stanza-gap { height: 14px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.small-chip { padding: 4px 10px; font-size: 0.82rem; }
.lyrics-input { min-height: 220px; resize: vertical; font-size: 0.95rem; line-height: 1.45; }
.lyric.open .lyric-tr { display: none; }
