/* ================================================================
   VocabDeck — Phase 1 UI
   Design tokens & base
   ================================================================ */
:root {
  --bg: #f7f5ef;
  --bg-alt: #f2efe6;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --text: #20302a;
  --text-soft: #4d5e55;
  --muted: #7b8a81;
  --border: #e8e4d9;
  --border-strong: #d9d4c7;

  --primary: #1e5b40;
  --primary-hover: #174a34;
  --primary-soft: #e7f1ea;
  --primary-soft-2: #d7e9de;
  --primary-ring: #c7dfd0;

  --amber: #b87524;
  --amber-soft: #fbf1e2;
  --blue-soft: #e9f0f5;
  --danger: #b4433b;
  --danger-soft: #fbeae8;
  --success: #1e744e;
  --success-soft: #e4f3ea;

  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;

  --shadow-xs: 0 1px 2px rgba(28, 46, 37, .05);
  --shadow-sm: 0 2px 6px rgba(28, 46, 37, .04), 0 8px 20px rgba(28, 46, 37, .04);
  --shadow-md: 0 4px 12px rgba(28, 46, 37, .06), 0 16px 36px rgba(28, 46, 37, .05);
  --shadow-lg: 0 24px 60px rgba(28, 46, 37, .14);

  --sidebar-w: 268px;
  --topbar-h: 88px;
  --sidebar-w-collapsed: 292px;

  --font-ui: "Cairo", "Inter", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-es: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #101a16;
  --bg-alt: #0c1411;
  --surface: #17231e;
  --surface-2: #1c2a24;
  --text: #e9efe9;
  --text-soft: #c1cdc4;
  --muted: #93a59a;
  --border: #293a31;
  --border-strong: #374c40;

  --primary: #57b98a;
  --primary-hover: #6dcb9d;
  --primary-soft: #1e3a2d;
  --primary-soft-2: #274a39;
  --primary-ring: #2f5a44;

  --amber: #e0a85c;
  --amber-soft: #3a2e1c;
  --blue-soft: #1e303c;
  --danger: #ef8d84;
  --danger-soft: #3d2422;
  --success: #77d6a5;
  --success-soft: #1e3a2c;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .22);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .45);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
ul { list-style: none; margin: 0; padding: 0; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }

:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; }

/* Directional icons adapt to document direction */
html[dir="rtl"] .icon-next { transform: scaleX(-1); }
html[dir="ltr"] .icon-prev { transform: scaleX(-1); }

/* Mixed text support */
.ltr-text, [lang="es"] {
  direction: ltr;
  text-align: left;
  font-family: var(--font-es);
  unicode-bidi: isolate;
}

/* ================================================================
   App shell & sidebar
   ================================================================ */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 40;
  width: var(--sidebar-w);
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px; }
.brand-mark {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #26734f, #16452f);
  box-shadow: 0 8px 18px rgba(30, 91, 64, .25);
}
html[data-theme="dark"] .brand-mark { background: linear-gradient(145deg, #2c8a61, #20513b); }
.brand-mark .icon { width: 25px; height: 25px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-copy strong { font-family: var(--font-es); font-size: 19px; letter-spacing: -.4px; }
.brand-copy small { color: var(--muted); font-size: 10.5px; font-weight: 600; white-space: nowrap; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-heading {
  padding: 0 12px;
  margin: 10px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  transition: background-color .18s, color .18s, transform .18s;
}
.nav-item .icon { width: 19px; height: 19px; color: var(--muted); transition: color .18s; }
.nav-item:hover { background: var(--bg-alt); color: var(--text); transform: translateX(-2px); }
html[dir="ltr"] .nav-item:hover { transform: translateX(2px); }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-item.is-active .icon { color: var(--primary); }
.nav-pill {
  margin-inline-start: auto;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--primary-soft-2);
  color: var(--primary);
  font-size: 11px;
  font-family: var(--font-es);
}

.side-tip {
  margin-top: auto;
  display: flex;
  gap: 11px;
  padding: 15px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  border: 1px solid var(--primary-ring);
}
.tip-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  color: var(--primary);
}
.side-tip strong { display: block; font-size: 13px; margin-bottom: 2px; }
.side-tip p { color: var(--text-soft); font-size: 11.5px; line-height: 1.6; }

/* ================================================================
   Topbar
   ================================================================ */
.content-column {
  margin-inline-start: var(--sidebar-w);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  padding: 16px clamp(20px, 3.2vw, 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-heading h1 { font-size: 22px; line-height: 1.3; font-weight: 800; letter-spacing: -.3px; }
.topbar-heading p { color: var(--muted); font-size: 12.5px; }
.menu-btn { display: none !important; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.lang-toggle {
  display: flex;
  gap: 3px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.lang-btn {
  padding: 5px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: all .18s;
}
.lang-btn[data-lang="es"] { font-family: var(--font-es); }
.lang-btn:hover { color: var(--text); }
.lang-btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-soft);
  transition: all .18s;
  position: relative;
}
.icon-btn:hover { border-color: var(--primary-ring); color: var(--primary); background: var(--primary-soft); }
.icon-btn:active { transform: scale(.94); }

.theme-btn .icon-sun { display: none; }
html[data-theme="dark"] .theme-btn .icon-sun { display: block; }
html[data-theme="dark"] .theme-btn .icon-moon { display: none; }



/* ================================================================
   Main content & pages
   ================================================================ */
.main-content {
  padding: 28px clamp(20px, 3.2vw, 44px) 60px;
  max-width: 1440px;
  margin-inline: auto;
}
.page { display: none; animation: pageIn .3s ease both; }
.page.is-active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-head.compact { margin-bottom: 14px; align-items: center; }
.card-head h3 { font-size: 16px; font-weight: 800; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }

.icon-tile {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
}
.icon-tile-soft { background: var(--primary-soft); color: var(--primary); }
.icon-tile-warm { background: var(--amber-soft); color: var(--amber); }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px;
  border-radius: 8px;
  font-family: var(--font-es);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
}
.chip-green { background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform .16s, background-color .18s, border-color .18s, box-shadow .18s, color .18s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(30, 91, 64, .18); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 10px 24px rgba(30, 91, 64, .26); }
html[data-theme="dark"] .btn-primary { color: #0f1d16; }
.btn-outline { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-ghost { color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }
.btn-ghost-light { color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .3); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .2); }
.btn-block { width: 100%; }

.text-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--primary); font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.text-link:hover { text-decoration: underline; }
.text-link .icon { width: 15px; height: 15px; }

.mini-progress { height: 7px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; }
.mini-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* ================================================================
   1. Home dashboard
   ================================================================ */
.hero-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  min-height: 246px;
  padding: 38px 44px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: linear-gradient(115deg, #154a34 0%, #1e5b40 52%, #2b7a55 100%);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}
html[data-theme="dark"] .hero-card { background: linear-gradient(115deg, #16382a 0%, #1d513a 55%, #276d4c 100%); }
.hero-shape { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .12); pointer-events: none; }
.hero-shape-one { width: 340px; height: 340px; inset-block-start: -180px; inset-inline-end: -80px; background: rgba(255, 255, 255, .05); }
.hero-shape-two { width: 240px; height: 240px; inset-block-end: -150px; inset-inline-start: 32%; background: rgba(255, 255, 255, .04); }
.hero-content { position: relative; z-index: 2; max-width: 520px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; margin-bottom: 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .15);
  font-size: 11.5px; font-weight: 700;
}
.eyebrow .icon { width: 14px; height: 14px; }
.hero-content h2 { font-size: clamp(25px, 3vw, 36px); line-height: 1.3; font-weight: 800; letter-spacing: -.6px; margin-bottom: 8px; }
.hero-content p { color: rgba(255, 255, 255, .82); font-size: 14px; max-width: 440px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.hero-art { position: relative; z-index: 1; width: 250px; height: 180px; flex: none; }
.hero-card-stack { position: absolute; width: 190px; height: 128px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .25); }
.stack-back { inset-block-start: 6px; inset-inline-start: 8px; transform: rotate(-9deg); background: rgba(255, 255, 255, .08); }
.stack-mid { inset-block-start: 12px; inset-inline-start: 32px; transform: rotate(5deg); background: rgba(255, 255, 255, .13); }
.hero-flashcard {
  position: absolute;
  inset-block-start: 26px; inset-inline-start: 18px;
  width: 214px; padding: 18px;
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .22);
  transform: rotate(-3deg);
}
.flashcard-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-family: var(--font-es); font-size: 10px; font-weight: 800; }
.hero-flashcard p { font-family: var(--font-es); font-size: 17px; font-weight: 700; margin: 10px 0 4px; direction: ltr; text-align: left; }
.hero-flashcard small { color: var(--muted); font-size: 11.5px; }

.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.home-main { display: flex; flex-direction: column; gap: 24px; }
.home-side { display: flex; flex-direction: column; gap: 20px; }

.progress-body { display: flex; align-items: center; gap: 30px; }
.progress-ring {
  --pct: 0;
  width: 132px; height: 132px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--primary-ring) 0);
  box-shadow: inset 0 0 0 1px var(--border);
}
.progress-ring-inner {
  width: 104px; height: 104px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.progress-ring-inner strong { font-family: var(--font-es); font-size: 29px; line-height: 1; letter-spacing: -1px; }
.progress-ring-inner strong span { font-size: 14px; color: var(--muted); }
.progress-ring-inner small { color: var(--muted); font-size: 11px; margin-top: 4px; }
.progress-stats { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-label { color: var(--text-soft); font-size: 13px; }
.stat-row strong { font-family: var(--font-es); font-size: 16px; white-space: nowrap; }
.stat-row strong small { font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--muted); }
.inline-progress { height: 7px; border-radius: 99px; background: var(--bg-alt); overflow: hidden; margin-top: 18px; }
.inline-progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #3b9c6d); }
.progress-foot { display: flex; align-items: center; gap: 6px; color: var(--success); font-size: 12px; font-weight: 600; margin-top: 12px; }
.progress-foot .icon { width: 15px; height: 15px; }

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.recent-item:first-child { border-top: 0; padding-top: 0; }
.recent-item:last-child { padding-bottom: 0; }
.recent-info { min-width: 0; }
.es-text { font-family: var(--font-es); direction: ltr; text-align: left; font-size: 14px; font-weight: 600; line-height: 1.5; }
.ar-text { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.recent-meta { display: flex; align-items: center; gap: 10px; flex: none; }
.recent-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.side-card { padding: 18px; }
.level-summary-main { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.level-badge-lg {
  width: 54px; height: 54px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-es);
  font-size: 19px; font-weight: 800;
}
html[data-theme="dark"] .level-badge-lg { color: #0f1d16; }
.level-summary-main strong { display: block; font-size: 16px; }
.level-summary-main small { color: var(--muted); font-size: 11.5px; }
.mini-progress-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin: 8px 0 16px; }
.mini-progress-label strong { font-family: var(--font-es); color: var(--primary); font-size: 12.5px; }

.goal-number { display: flex; align-items: baseline; gap: 6px; }
.goal-number strong { font-family: var(--font-es); font-size: 40px; line-height: 1; letter-spacing: -1.5px; color: var(--primary); }
.goal-number span { font-family: var(--font-es); font-size: 18px; color: var(--muted); }
.goal-caption { color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
.goal-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--amber); font-size: 11.5px; font-weight: 700; }
.goal-foot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.quick-links { display: flex; flex-direction: column; gap: 4px; }
.quick-links a { display: flex; align-items: center; gap: 11px; padding: 9px 8px; border-radius: 11px; font-size: 13px; font-weight: 600; transition: background-color .18s; }
.quick-links a:hover { background: var(--bg-alt); }
.quick-links a > span:nth-child(2) { flex: 1; }
.quick-links .icon-next { width: 15px; height: 15px; color: var(--muted); }
.quick-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; }
.quick-icon .icon { width: 17px; height: 17px; }
.quick-icon-green { background: var(--primary-soft); color: var(--primary); }
.quick-icon-amber { background: var(--amber-soft); color: var(--amber); }
.quick-icon-slate { background: var(--blue-soft); color: #4c7291; }

/* ================================================================
   Section intro (levels, saved)
   ================================================================ */
.section-intro {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 24px;
}
.section-intro h2 { font-size: clamp(23px, 2.6vw, 30px); font-weight: 800; letter-spacing: -.5px; }
.section-intro p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.count-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.count-badge .icon { width: 15px; height: 15px; }

/* ================================================================
   2. Level selection
   ================================================================ */
.levels-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.level-card {
  position: relative;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s, background-color .2s;
  outline: none;
}
.level-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary-ring); }
.level-card.is-selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 12px 30px rgba(30, 91, 64, .14); }
.level-card:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 3px; }
.level-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.level-code {
  font-family: var(--font-es);
  font-size: 24px; font-weight: 800; letter-spacing: -1px;
  color: var(--primary);
}
.level-check {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  color: transparent;
  transition: all .2s;
}
.level-check .icon { width: 15px; height: 15px; }
.level-card.is-selected .level-check { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .level-card.is-selected .level-check { color: #0f1d16; }
.level-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 5px; }
.level-card > p { color: var(--text-soft); font-size: 12.5px; line-height: 1.65; min-height: 42px; }
.difficulty { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; }
.difficulty > span { color: var(--muted); font-size: 11.5px; }
.dots { display: flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); display: block; }
.dots i.on { background: var(--primary); }
.level-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.level-card-foot .icon { width: 16px; height: 16px; }
.level-card.is-selected .level-card-foot { color: var(--primary); border-color: var(--primary-ring); }
.level-card.is-selected .selected-label { font-weight: 800; }
.level-footer-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-top: 22px; }
.level-footer-note .icon { width: 16px; height: 16px; }

/* ================================================================
   3. Learning page
   ================================================================ */
.learn-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.learn-card { padding: 28px 30px; }
.learn-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.lesson-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px; font-weight: 700;
}
.lesson-badge .icon { width: 15px; height: 15px; }
.save-btn.is-saved { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .save-btn.is-saved { color: #0f1d16; }

.field-label { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; margin-bottom: 10px; }
.big-sentence {
  font-family: var(--font-es);
  direction: ltr; text-align: left;
  font-size: clamp(24px, 3.4vw, 38px);
  font-weight: 700; line-height: 1.35;
  letter-spacing: -.8px;
  color: var(--text);
  margin-bottom: 18px;
}
.audio-btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid var(--primary-ring);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px; font-weight: 700;
  transition: all .18s;
}
.audio-btn:hover { background: var(--primary-soft-2); }
.audio-btn.is-playing { background: var(--primary); color: #fff; transform: scale(.97); }
html[data-theme="dark"] .audio-btn.is-playing { color: #0f1d16; }
.audio-btn .icon { width: 17px; height: 17px; }
.audio-btn.is-playing .icon { animation: pulse .5s ease; }
@keyframes pulse { 50% { transform: scale(1.25); } }

.translation-block {
  margin: 26px 0;
  padding: 18px 20px;
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
}
.translation-text { font-size: 18px; font-weight: 600; line-height: 1.8; }

.learn-section { margin-top: 26px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; margin-bottom: 14px; }
.section-title .icon { width: 17px; height: 17px; color: var(--primary); }
.vocab-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.vocab-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13.5px;
}
.vocab-es { font-family: var(--font-es); direction: ltr; text-align: left; font-weight: 700; min-width: 0; }
.vocab-eq { color: var(--muted); font-family: var(--font-es); }
.vocab-ar { color: var(--text-soft); font-weight: 600; }
.explanation-box { padding: 18px 20px; border-radius: var(--radius-sm); background: var(--blue-soft); border: 1px solid var(--border); }
.explanation-box .section-title .icon { color: #4c7291; }
.explanation-box p { color: var(--text-soft); font-size: 13.5px; line-height: 1.9; }

.learn-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 28px; padding-top: 22px;
  border-top: 1px solid var(--border);
}
.learn-progress { text-align: center; flex: 1; max-width: 220px; }
.learn-progress > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }

.learn-side { display: flex; flex-direction: column; gap: 20px; }
.session-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.session-row span { color: var(--muted); }
.session-row strong { font-family: var(--font-es); font-size: 13px; }
.session-row strong span { font-family: var(--font-ui); color: var(--text); }
.session-card .mini-progress { margin-top: 16px; }
.hint-card { border-color: var(--primary-ring); background: var(--primary-soft); }
.hint-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); color: var(--primary); margin-bottom: 12px; }
.hint-card h3 { font-size: 14px; margin-bottom: 6px; }
.hint-card p { color: var(--text-soft); font-size: 12.5px; line-height: 1.75; }
.quiz-cta { display: flex; align-items: center; gap: 12px; transition: transform .18s, box-shadow .18s; }
.quiz-cta:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.quiz-cta-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--amber-soft); color: var(--amber); }
.quiz-cta div { display: flex; flex-direction: column; flex: 1; line-height: 1.4; }
.quiz-cta strong { font-size: 13.5px; }
.quiz-cta small { color: var(--muted); font-size: 11.5px; }
.quiz-cta > .icon { color: var(--muted); width: 17px; height: 17px; }

/* ================================================================
   4. Quiz page
   ================================================================ */
.quiz-wrap { max-width: 780px; margin-inline: auto; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.quiz-counter { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.quiz-segments { display: flex; gap: 6px; margin-bottom: 20px; }
.quiz-segments span { flex: 1; height: 6px; border-radius: 99px; background: var(--border); }
.quiz-segments .is-done { background: var(--primary); }
.quiz-segments .is-current { background: var(--amber); }

.quiz-card { padding: 32px; }
.quiz-question { font-family: var(--font-es); direction: ltr; text-align: left; font-size: clamp(24px, 3vw, 34px); font-weight: 700; letter-spacing: -.7px; margin-bottom: 10px; }
.quiz-hint { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.quiz-hint .icon { width: 15px; height: 15px; }

.options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 26px 0; }
.option {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: start;
  transition: all .18s;
}
.option:hover { border-color: var(--primary-ring); background: var(--primary-soft); }
.option.is-selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.option-key {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-es); font-size: 13px; font-weight: 800; color: var(--muted);
}
.option.is-selected .option-key { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .option.is-selected .option-key { color: #0f1d16; }
.option-text { font-family: var(--font-es); direction: ltr; text-align: left; font-size: 19px; font-weight: 700; flex: 1; }
.option-state { width: 22px; height: 22px; display: none; place-items: center; border-radius: 50%; }
.option-state .icon { width: 15px; height: 15px; }
.option.is-correct .option-state { display: grid; background: var(--success-soft); color: var(--success); }
.option.is-wrong .option-state { display: grid; background: var(--danger-soft); color: var(--danger); }
.option.is-correct { border-color: var(--success); background: var(--success-soft); }
.option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }

.feedback { display: none; align-items: flex-start; gap: 12px; padding: 16px 18px; border-radius: var(--radius-sm); margin-bottom: 22px; }
.feedback.is-visible { display: flex; animation: pageIn .25s ease both; }
.feedback.is-correct { background: var(--success-soft); border: 1px solid var(--success); }
.feedback.is-wrong { background: var(--danger-soft); border: 1px solid var(--danger); }
.feedback-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.feedback.is-correct .feedback-icon { background: var(--success); color: #fff; }
.feedback.is-wrong .feedback-icon { background: var(--danger); color: #fff; }
.feedback-icon .icon { width: 18px; height: 18px; }
.icon-fb-wrong, .is-wrong .icon-fb-correct { display: none; }
.is-wrong .icon-fb-wrong { display: block; }
.feedback strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.feedback.is-correct strong { color: var(--success); }
.feedback.is-wrong strong { color: var(--danger); }
.feedback p { font-size: 12px; color: var(--text-soft); }

.quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ================================================================
   5. Saved sentences
   ================================================================ */
.saved-toolbar, .saved-toolbar { display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 22px; }
.search-field {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color .18s, box-shadow .18s;
}
.search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-field .icon { width: 18px; height: 18px; }
.search-field input { width: 100%; height: 100%; border: 0; outline: 0; background: transparent; font-size: 13.5px; color: var(--text); }
.search-field input::placeholder { color: var(--muted); }
.filter-field { display: flex; align-items: center; gap: 10px; padding-inline-start: 14px; border-inline-start: 1px solid var(--border); }
.filter-field > span { color: var(--muted); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.filter-field select {
  height: 46px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  outline: none;
}
.filter-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.saved-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.saved-card { display: flex; flex-direction: column; transition: transform .18s, box-shadow .18s; }
.saved-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.saved-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.bookmark-btn { width: 34px; height: 34px; border-radius: 10px; }
.bookmark-btn.is-saved { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .bookmark-btn.is-saved { color: #0f1d16; }
.bookmark-btn:not(.is-saved) .icon { fill: none; }
.saved-card .es-text { font-size: 16px; font-weight: 700; }
.saved-card .ar-text { font-size: 13px; margin-top: 6px; }
.saved-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 11.5px;
}
.saved-card-foot > span, .saved-card-foot a { display: inline-flex; align-items: center; gap: 6px; }
.saved-card-foot .icon { width: 14px; height: 14px; }
.saved-card-foot a { color: var(--primary); font-weight: 700; }

/* ================================================================
   6. Settings
   ================================================================ */
.settings-wrap { max-width: 780px; margin-inline: auto; display: flex; flex-direction: column; gap: 18px; }
.settings-card { padding: 24px 26px; }
.setting-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.setting-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.setting-head h3 { font-size: 16px; font-weight: 800; margin-bottom: 3px; }
.setting-head p { color: var(--muted); font-size: 12.5px; }

.segmented { display: flex; gap: 6px; padding: 5px; border-radius: 13px; background: var(--bg-alt); border: 1px solid var(--border); }
.segment { flex: 1; padding: 10px; border-radius: 9px; color: var(--text-soft); font-size: 13px; font-weight: 700; transition: all .18s; }
.segment:hover { color: var(--text); }
.segment.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

.theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.theme-option {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  transition: all .18s;
}
.theme-option:hover { border-color: var(--primary-ring); }
.theme-option.is-active { border-color: var(--primary); background: var(--primary-soft); }
.theme-option > .icon { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; width: 20px; height: 20px; color: var(--primary); opacity: 0; }
.theme-option.is-active > .icon { opacity: 1; }
.theme-option strong { font-size: 13px; }
.theme-preview { width: 100%; height: 72px; border-radius: 10px; border: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.theme-preview span { display: block; border-radius: 5px; }
.preview-light { background: #f7f5ef; }
.preview-light span:nth-child(1) { width: 45%; height: 10px; background: #1e5b40; }
.preview-light span:nth-child(2) { width: 90%; height: 8px; background: #d9d4c7; }
.preview-light span:nth-child(3) { width: 70%; height: 8px; background: #e8e4d9; }
.preview-dark { background: #101a16; }
.preview-dark span:nth-child(1) { width: 45%; height: 10px; background: #57b98a; }
.preview-dark span:nth-child(2) { width: 90%; height: 8px; background: #374c40; }
.preview-dark span:nth-child(3) { width: 70%; height: 8px; background: #293a31; }

.level-select { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.level-option {
  padding: 12px 4px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  font-family: var(--font-es); font-size: 14px; font-weight: 800;
  color: var(--text-soft);
  transition: all .18s;
}
.level-option:hover { border-color: var(--primary-ring); color: var(--primary); }
.level-option.is-active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
html[data-theme="dark"] .level-option.is-active { color: #0f1d16; }
.setting-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-top: 14px; }
.setting-note .icon { width: 15px; height: 15px; }

.settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 6px; }
.settings-actions p { color: var(--muted); font-size: 12px; }

/* ================================================================
   Phase 2 additions — real data, speech, quiz results, empty states
   ================================================================ */
.data-notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; margin-bottom: 18px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: var(--text-soft);
  font-size: 12.5px;
}
.data-notice .icon { color: var(--amber); width: 18px; height: 18px; }
.data-notice[hidden] { display: none; }

.empty-inline {
  padding: 18px 4px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.empty-inline[hidden] { display: none; }

.audio-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.stop-btn { width: 38px; height: 38px; border-radius: 11px; background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.stop-btn:hover { background: var(--danger); color: #fff; }
.stop-btn[hidden] { display: none; }
.speech-message { color: var(--muted); font-size: 12px; }
.speech-message[hidden] { display: none; }
.speech-message.is-error { color: var(--danger); }

.feedback-answer { margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--text); }
.feedback-answer span { font-family: var(--font-es); direction: ltr; text-align: left; display: inline-block; }
.feedback-answer[hidden] { display: none; }

.quiz-results { text-align: center; padding: 36px 30px; }
.quiz-results[hidden] { display: none; }
.results-icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 20px;
  background: var(--amber-soft); color: var(--amber);
}
.results-icon .icon { width: 32px; height: 32px; }
.quiz-results h2 { font-size: 22px; font-weight: 800; margin-bottom: 18px; }
.results-score { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 18px; }
.results-score strong { font-family: var(--font-es); font-size: 44px; line-height: 1; letter-spacing: -1.5px; color: var(--primary); }
.results-score span { color: var(--muted); font-size: 12.5px; }
.quiz-results .mini-progress { max-width: 360px; margin-inline: auto; }
.results-message { color: var(--text-soft); font-size: 14px; font-weight: 600; margin: 20px 0 24px; }
.results-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; }

.saved-empty { text-align: center; padding: 48px 24px; }
.saved-empty[hidden] { display: none; }
.saved-empty-icon {
  width: 62px; height: 62px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--primary-soft); color: var(--primary);
}
.saved-empty h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.saved-empty p { color: var(--muted); font-size: 13px; max-width: 380px; margin: 0 auto 20px; }

/* ================================================================
   Phase 3 — Español para el trabajo (cleaning)
   ================================================================ */
.nav-pill[hidden] { display: none; }

.work-entry-sub {
  display: flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  margin: 2px 0 14px;
}
.work-entry-sub .icon { width: 15px; height: 15px; color: var(--primary); }

.work-summary { padding: 18px 22px; margin-bottom: 16px; }
.work-summary-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.work-summary-head .field-label { margin-bottom: 4px; }
.work-summary-head strong { font-size: 15px; font-weight: 800; }
.work-summary-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.work-summary-score strong { font-family: var(--font-es); font-size: 22px; color: var(--primary); letter-spacing: -.5px; }
.work-summary-score span { color: var(--muted); font-size: 11.5px; }

.work-filters {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 16px 20px; margin-bottom: 22px;
}
.work-filter-group { min-width: 0; flex: 1; }
.work-filter-group .field-label { margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11.5px; font-weight: 700;
  transition: all .18s;
}
.filter-chip:hover { border-color: var(--primary-ring); color: var(--primary); }
.filter-chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .filter-chip.is-active { color: #0f1d16; }
.filter-chip-count {
  display: inline-grid; place-items: center;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 99px;
  background: var(--bg-alt);
  color: var(--muted);
  font-family: var(--font-es); font-size: 10.5px; font-weight: 800;
}
.filter-chip.is-active .filter-chip-count { background: rgba(255, 255, 255, .22); color: inherit; }
.work-level-filter { flex: none; }

.work-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.work-card { min-height: 430px; }
.work-term { font-size: clamp(26px, 3.6vw, 40px); }

.work-term-row { display: flex; align-items: center; gap: 28px; }
.work-term-main { flex: 1 1 auto; min-width: 0; }
.work-media {
  flex: 0 0 240px;
  width: 240px;
  margin: 0;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
  position: relative;
}
.work-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.work-media[hidden], .work-media-fallback[hidden] { display: none; }
.work-media-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; text-align: center;
  color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.6;
}
.work-media-fallback .icon { width: 26px; height: 26px; opacity: .7; }

.done-btn { width: 40px; height: 40px; border-radius: 12px; color: var(--muted); }
.done-btn:hover { border-color: var(--primary-ring); color: var(--primary); }
.done-btn.is-done { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .done-btn.is-done { color: #0f1d16; }
.done-btn:disabled { opacity: .5; cursor: not-allowed; }

.example-box {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.example-es {
  font-family: var(--font-es); direction: ltr; text-align: left;
  font-size: 17px; font-weight: 700; line-height: 1.55;
  color: var(--text); margin-bottom: 8px;
}
.example-ar { color: var(--text-soft); font-size: 14px; font-weight: 600; line-height: 1.8; }

/* ================================================================
   Mobile bottom navigation
   ================================================================ */
.bottom-nav { display: none; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 1180px) {
  :root { --sidebar-w: 236px; }
  .home-layout { grid-template-columns: minmax(0, 1fr) 270px; }
  .learn-layout, .work-layout { grid-template-columns: minmax(0, 1fr) 250px; }
  .work-media { flex-basis: 200px; width: 200px; }
  .levels-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .sidebar {
    z-index: 60;
    width: min(300px, 84vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform .26s ease;
  }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: translateX(0); }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(16, 30, 22, .42);
  }
  .content-column { margin-inline-start: 0; }
  .menu-btn { display: grid !important; }
  .bottom-nav { display: none; }
  .topbar { padding: 14px 24px; }
  .main-content { padding: 24px 24px 50px; }
  .home-layout, .learn-layout, .work-layout { grid-template-columns: minmax(0, 1fr); }
  .home-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .learn-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .home-side, .learn-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-art { display: none; }
  .saved-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767px) {
  :root { --topbar-h: 72px; }
  body { font-size: 14px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar-heading h1 { font-size: 18px; }
  .topbar-heading p { font-size: 11px; }
  .main-content { padding: 20px 16px 100px; }
  .lang-btn { padding: 5px 9px; font-size: 11px; }

  .bottom-nav {
    position: fixed;
    inset-block-end: 0; inset-inline: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(28, 46, 37, .06);
  }
  .bottom-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 10px; font-weight: 700;
    transition: color .18s, background-color .18s;
  }
  .bottom-item .icon { width: 21px; height: 21px; }
  .bottom-item.is-active { color: var(--primary); background: var(--primary-soft); }

  .hero-card { padding: 28px 24px; min-height: 0; border-radius: var(--radius-lg); }
  .hero-content h2 { font-size: 25px; }
  .hero-content p { font-size: 13px; }
  .home-side, .learn-side { grid-template-columns: minmax(0, 1fr); }
  .levels-grid { grid-template-columns: minmax(0, 1fr); }
  .section-intro { flex-direction: column; align-items: flex-start; gap: 12px; }
  .card { padding: 18px; }
  .progress-body { gap: 18px; }
  .progress-ring { width: 108px; height: 108px; }
  .progress-ring-inner { width: 84px; height: 84px; }
  .progress-ring-inner strong { font-size: 23px; }
  .stat-row strong { font-size: 14px; }
  .recent-item { flex-direction: column; align-items: flex-start; gap: 8px; }
  .learn-card, .quiz-card { padding: 20px; }
  .vocab-list, .options-grid, .theme-options { grid-template-columns: minmax(0, 1fr); }
  .learn-controls { flex-wrap: wrap; }
  .learn-progress { order: -1; flex-basis: 100%; max-width: none; }
  .saved-toolbar, .saved-toolbar { flex-direction: column; align-items: stretch; }
  .filter-field { padding: 0; border: 0; }
  .filter-field select { flex: 1; }
  .work-filters { flex-direction: column; align-items: stretch; }
  .work-summary { padding: 16px; }
  .work-summary-head { align-items: center; }
  .work-summary-score { align-items: flex-end; }
  .work-term-row { flex-direction: column; align-items: stretch; gap: 16px; }
  .work-media { flex: none; width: min(100%, 360px); align-self: center; }
  .bottom-item { font-size: 9.5px; }
  .bottom-item .icon { width: 20px; height: 20px; }
  .level-select { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-actions { flex-direction: column; align-items: stretch; }
  .settings-actions .btn { width: 100%; }
  .quiz-actions { flex-direction: column-reverse; align-items: stretch; }
  .quiz-actions .btn { width: 100%; }
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
  .progress-body { flex-direction: column; text-align: center; }
  .progress-stats { width: 100%; }
  .stat-row { text-align: start; }
  .hero-actions .btn { width: 100%; }
  .lang-toggle { padding: 3px; }
  .lang-btn { padding: 4px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
