/* ====== LIGHT TOKENS ====== */
:root {
  --bg:         #FBF7F2;
  --surface:    #FFFFFF;
  --surface2:   #FEF5EA;
  --border:     #EDE4D8;
  --ink:        #1C140A;
  --muted:      #8A7566;
  --primary:    #E8622A;
  --primary-dk: #C44D1A;
  --primary-lt: #FEF0E8;
  --green:      #2D7A50;
  --green-lt:   #E6F5EC;
  --amber:      #C88A00;
  --amber-lt:   #FFF8E1;
  --red:        #C0392B;
  --red-lt:     #FDECEA;
  --known:      #2D7A50;
  --learning:   #C88A00;
  --new:        #E8622A;
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --shadow:     0 2px 12px rgba(0,0,0,.07);
  --shadow-md:  0 4px 24px rgba(0,0,0,.10);
  --nav-h:      68px;
  --header-h:   60px;
  --font:       'Inter', -apple-system, 'Segoe UI', sans-serif;
}

/* ====== DARK TOKENS ====== */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg:         #18120D;
    --surface:    #241C15;
    --surface2:   #2C221A;
    --border:     #3A2E22;
    --ink:        #F2EBE2;
    --muted:      #9A8878;
    --primary-lt: #3D2010;
    --green-lt:   #152B1F;
    --amber-lt:   #2E2600;
    --red-lt:     #2E1010;
  }
}
:root[data-theme="dark"] {
  --bg:         #18120D;
  --surface:    #241C15;
  --surface2:   #2C221A;
  --border:     #3A2E22;
  --ink:        #F2EBE2;
  --muted:      #9A8878;
  --primary-lt: #3D2010;
  --green-lt:   #152B1F;
  --amber-lt:   #2E2600;
  --red-lt:     #2E1010;
}
:root[data-theme="light"] {
  --bg:         #FBF7F2;
  --surface:    #FFFFFF;
  --surface2:   #FEF5EA;
  --border:     #EDE4D8;
  --ink:        #1C140A;
  --muted:      #8A7566;
  --primary-lt: #FEF0E8;
  --green-lt:   #E6F5EC;
  --amber-lt:   #FFF8E1;
  --red-lt:     #FDECEA;
}

/* ====== RESET ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--ink); line-height: 1.5;
  overscroll-behavior: none;
  transition: background .25s, color .25s;
}
button { font-family: var(--font); cursor: pointer; border: none; }
select, input { font-family: var(--font); outline: none; }

/* ====== HEADER ====== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #E8622A 0%, #C44D1A 100%);
  height: var(--header-h);
  box-shadow: 0 2px 16px rgba(232,98,42,.3);
  transition: opacity .2s;
}
.header-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 100%;
}
.header-brand  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo   { font-size: 1.7rem; line-height: 1; flex-shrink: 0; }
.header-title  { font-weight: 700; font-size: 1rem; color: #fff; white-space: nowrap; }
.header-sub    { font-size: 0.7rem; color: rgba(255,255,255,.8); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-streak { font-size: 0.82rem; color: rgba(255,255,255,.9); background: rgba(255,255,255,.18); padding: 4px 9px; border-radius: 20px; white-space: nowrap; }
.theme-toggle  {
  background: rgba(255,255,255,.18); border: none; border-radius: 50%;
  width: 34px; height: 34px; font-size: 1rem; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,.28); }

/* ====== BOTTOM NAV ====== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: transparent; color: var(--muted);
  font-size: 0.64rem; font-weight: 500; padding: 8px 0;
  transition: color .2s; position: relative; overflow: hidden;
}
.nav-item .nav-icon { font-size: 1.25rem; transition: transform .2s; }
.nav-item.active    { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.18); filter: drop-shadow(0 0 6px rgba(232,98,42,.5)); }
.nav-indicator {
  position: absolute; top: 0; height: 3px;
  background: var(--primary); border-radius: 0 0 3px 3px;
  width: 20%; transition: left .28s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}

/* ====== MAIN ====== */
main {
  max-width: 760px; margin: 0 auto;
  padding: 16px 14px calc(var(--nav-h) + 20px);
}
.view { display: none; }
.view.active { display: block; animation: fadeUp .2s ease; }
.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.slide-in-right { animation: slideInRight .18s ease; }
.slide-in-left  { animation: slideInLeft  .18s ease; }

/* ====== HOME HERO ====== */
.home-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.hero-top { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.hero-ring-wrap { position: relative; flex-shrink: 0; }
.hero-ring { width: 76px; height: 76px; transform: rotate(-90deg); }
.hero-ring-bg  { fill: none; stroke: var(--border); stroke-width: 7; }
.hero-ring-fg  {
  fill: none; stroke: var(--primary); stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 213.6;
  transition: stroke-dashoffset .9s cubic-bezier(.4,0,.2,1);
}
.hero-ring-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: var(--primary);
}
.hero-stats { flex: 1; min-width: 0; }
.hero-title  { font-size: .95rem; font-weight: 700; margin-bottom: 5px; }
.hero-chips  { display: flex; flex-direction: column; gap: 3px; }
.hero-chip   { font-size: 0.78rem; color: var(--muted); }
.hero-chip strong { color: var(--ink); }

.hero-bar-row { margin-bottom: 10px; }
.big-bar {
  height: 8px; border-radius: 4px; background: var(--border);
  overflow: hidden; display: flex;
}
.big-bar .known    { background: var(--known);    transition: width .7s ease; }
.big-bar .learning { background: var(--learning); transition: width .7s ease; }
.big-bar .new      { background: var(--new);      transition: width .7s ease; }

/* ====== WEEKLY ACTIVITY CHART ====== */
.weekly-chart { margin-top: 12px; }
.weekly-chart-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 6px; }
.weekly-bars { display: flex; align-items: flex-end; gap: 5px; height: 38px; }
.wbar-wrap   { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.wbar        { width: 100%; border-radius: 3px 3px 0 0; background: var(--border); min-height: 3px; transition: height .5s ease; }
.wbar.has-activity { background: var(--primary); opacity: .7; }
.wbar.today  { background: var(--primary); opacity: 1; }
.wday        { font-size: 0.6rem; color: var(--muted); }

/* ====== DAILY GOAL ====== */
.daily-goal {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 9px 12px; margin-top: 10px;
}
.goal-icon { font-size: 1.1rem; flex-shrink: 0; }
.goal-text { flex: 1; min-width: 0; }
.goal-title { font-size: 0.78rem; font-weight: 600; }
.goal-sub   { font-size: 0.7rem; color: var(--muted); }
.goal-bar-wrap { width: 60px; flex-shrink: 0; }
.goal-bar-bg { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.goal-bar-fg { height: 100%; background: var(--primary); border-radius: 3px; transition: width .5s ease; }
.goal-pct { font-size: 0.65rem; color: var(--muted); text-align: right; margin-top: 2px; }

.legend-row   { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.legend-chip  { font-size: 0.73rem; padding: 3px 10px; border-radius: 20px; font-weight: 500; }
.legend-chip.known    { background: var(--green-lt);   color: var(--green); }
.legend-chip.learning { background: var(--amber-lt);   color: var(--amber); }
.legend-chip.new      { background: var(--primary-lt); color: var(--primary-dk); }

/* ====== CATEGORY GRID ====== */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow);
}
.cat-card:hover   { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.cat-card:active  { transform: translateY(0); }
.cat-card-header  { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.cat-emoji        { font-size: 1.4rem; }
.cat-card h3      { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.cat-card .cat-vi { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.cat-bar  { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; display: flex; margin-bottom: 7px; }
.cat-bar .known    { background: var(--known); }
.cat-bar .learning { background: var(--learning); }
.cat-bar .new      { background: var(--new); }
.cat-footer { display: flex; justify-content: space-between; align-items: center; }
.cat-count  { font-size: 0.73rem; color: var(--muted); }
.cat-known  { font-size: 0.73rem; font-weight: 600; color: var(--known); }

/* ====== CONTROLS ====== */
.select-pill {
  padding: 8px 12px; border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 0.86rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A7566'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}
.select-full {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 0.9rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238A7566'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.icon-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  transition: background .15s;
}
.icon-btn:hover { background: var(--primary-lt); }
.primary-btn {
  display: block; width: 100%; padding: 14px;
  background: var(--primary); color: #fff;
  border-radius: var(--radius); font-size: 0.97rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(232,98,42,.3);
  transition: background .15s, transform .1s, box-shadow .15s;
  text-align: center;
}
.primary-btn:hover  { background: var(--primary-dk); box-shadow: 0 6px 18px rgba(232,98,42,.4); }
.primary-btn:active { transform: scale(.98); }
.ghost-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 18px;
  font-size: 0.88rem; color: var(--ink);
  transition: background .15s;
}
.ghost-btn:hover { background: var(--surface2); }
.toggle-chip {
  padding: 6px 13px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 0.8rem; color: var(--muted);
  transition: all .15s;
}
.toggle-chip.active { background: var(--primary-lt); color: var(--primary-dk); border-color: var(--primary); font-weight: 600; }

/* ====== FLASHCARD ====== */
.fc-controls { margin-bottom: 14px; display: flex; flex-direction: column; gap: 9px; }
.fc-controls-row { display: flex; align-items: center; gap: 8px; }
.fc-counter { font-size: 0.8rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.toggle-row { display: flex; gap: 7px; flex-wrap: wrap; }

/* ====== SESSION BAR ====== */
.fc-session-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border-radius: 10px;
  padding: 7px 12px; font-size: 0.76rem; color: var(--muted);
}
.session-stat { display: flex; align-items: center; gap: 4px; }
.session-stat strong { color: var(--ink); font-size: 0.82rem; }
.session-divider { width: 1px; height: 14px; background: var(--border); }
.session-timer   { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 0.76rem; color: var(--muted); }
.session-timer.active { color: var(--primary); font-weight: 600; }

/* Focus mode button */
.btn-focus {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 5px 10px; font-size: .78rem;
  color: var(--muted); transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.btn-focus:hover { border-color: var(--primary); color: var(--primary); }

/* ====== FLASHCARD CARD ====== */
.fc-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 10px;
}
.fc-question-block { padding: 20px 18px 16px; }

/* Progress dots */
.fc-dots {
  display: flex; justify-content: center; gap: 5px;
  padding: 10px 0 0;
}
.fc-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border); transition: background .2s, transform .2s;
}
.fc-dot.known    { background: var(--known); }
.fc-dot.learning { background: var(--learning); }
.fc-dot.current  { background: var(--primary); transform: scale(1.4); }
.fc-dot.new      { background: var(--border); }

.fc-reveal-btn {
  display: block; width: 100%;
  padding: 14px 20px;
  background: var(--primary-lt);
  color: var(--primary-dk);
  font-size: 0.95rem; font-weight: 600;
  border: none; border-top: 1.5px dashed var(--border);
  border-radius: 0; cursor: pointer;
  transition: background .15s;
  text-align: center;
  letter-spacing: .01em;
}
.fc-reveal-btn:hover    { background: #fad4b8; }
.fc-reveal-btn.revealed { background: var(--green-lt); color: var(--green); border-color: var(--green-lt); }

.fc-answer-block {
  padding: 16px 18px 20px;
  border-top: 1.5px solid var(--border);
  animation: fadeUp .18s ease;
}
.fc-answer-divider { height: 1px; background: var(--border); margin: 14px 0; }

.card-cat-label {
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--primary); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.card-question-text { font-size: 1.1rem; font-weight: 600; line-height: 1.55; }
.card-vi-question {
  font-size: 0.95rem; color: var(--ink); margin-top: 8px; line-height: 1.5;
  padding: 8px 12px; background: var(--surface2);
  border-radius: var(--radius-sm); border-left: 3px solid var(--border);
  opacity: 0.88;
}
.card-vi-text  { font-size: 0.87rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.card-no-answer { font-size: 0.8rem; color: var(--primary); margin-top: 10px; background: var(--primary-lt); padding: 7px 12px; border-radius: var(--radius-sm); }
.card-answer-label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--green); margin-bottom: 10px;
}
.card-answer-text { font-size: 0.96rem; line-height: 1.65; }

/* Compact vocab inside flashcard */
.vocab-inline { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 4px; }
.vocab-inline-title { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.vocab-inline-row {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  font-size: 0.83rem; padding: 5px 0; border-bottom: 1px solid var(--border);
}
.vocab-inline-row:last-child { border-bottom: none; }
.vocab-inline-term { font-weight: 700; color: var(--primary-dk); }
.vocab-inline-ipa  { font-family: monospace; font-size: 0.75rem; color: var(--muted); }
.vocab-inline-sep  { color: var(--border); }
.vocab-inline-vi   { color: var(--ink); }

/* Vocab panel inside card */
.vocab-panel { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.vocab-panel-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.vocab-list { display: flex; flex-direction: column; gap: 6px; }
.vocab-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.vocab-row1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.vocab-term    { font-weight: 700; font-size: 0.95rem; color: var(--primary-dk); }
.vocab-ipa     { font-family: monospace; font-size: 0.76rem; color: var(--muted); }
.vocab-meaning { font-size: 0.85rem; color: var(--ink); }
.vocab-example { font-size: 0.79rem; color: var(--muted); font-style: italic; margin-top: 2px; }

/* Explanation panel */
.expl-panel { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.expl-panel-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.expl-content {
  background: var(--green-lt); border-left: 3px solid var(--green);
  padding: 10px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.87rem; line-height: 1.65; color: var(--ink);
}
.expl-grammar {
  background: var(--amber-lt); border-left: 3px solid var(--amber);
  padding: 10px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem; line-height: 1.6; color: var(--ink);
}
.expl-grammar-label { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); display: block; margin-bottom: 3px; }

.fc-hint { text-align: center; font-size: 0.72rem; color: var(--muted); margin: 6px 0 12px; }
kbd { background: var(--border); color: var(--ink); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: .85em; }

/* Rate buttons — bigger touch targets */
.rate-bar  { display: flex; gap: 8px; padding: 0 0 4px; }
.rate-btn  {
  flex: 1; padding: 13px 6px; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600;
  transition: transform .1s, filter .1s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.rate-btn-icon { font-size: 1.15rem; }
.rate-btn:active { transform: scale(.94); }
.rate-new      { background: var(--primary-lt); color: var(--primary-dk); }
.rate-new:hover{ filter: brightness(.93); }
.rate-learning { background: var(--amber-lt);  color: var(--amber); }
.rate-learning:hover { filter: brightness(.93); }
.rate-known    { background: var(--green-lt);   color: var(--green); }
.rate-known:hover { filter: brightness(.93); }

.fc-nav { display: flex; gap: 10px; justify-content: center; }

/* ====== FOCUS MODE ====== */
body.focus-mode .header     { opacity: 0; pointer-events: none; height: 0; overflow: hidden; }
body.focus-mode .bottom-nav { transform: translateY(100%); }
body.focus-mode main        { padding-top: 10px; }
body.focus-mode .fc-controls { display: none; }
body.focus-mode .fc-hint    { display: none; }
.focus-exit {
  display: none; position: fixed; top: 10px; right: 10px; z-index: 500;
  background: rgba(0,0,0,.5); color: #fff; border: none;
  border-radius: 20px; padding: 6px 14px; font-size: .8rem; cursor: pointer;
  backdrop-filter: blur(6px);
}
body.focus-mode .focus-exit { display: block; }

/* ====== QUIZ ====== */
.quiz-setup { display: flex; flex-direction: column; gap: 14px; max-width: 420px; margin: 0 auto; padding-top: 8px; }
.quiz-setup-hero  { font-size: 3.2rem; text-align: center; }
.quiz-setup-title { font-size: 1.35rem; font-weight: 700; text-align: center; }
.quiz-setup-fields { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: -4px; }

.quiz-header  { margin-bottom: 14px; }
.quiz-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 7px; }
.quiz-bar      { height: 100%; background: var(--primary); transition: width .3s; width: 0%; }
.quiz-meta     { font-size: 0.78rem; color: var(--muted); }
.quiz-card     { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 16px; box-shadow: var(--shadow); }
.quiz-question { font-size: 1.02rem; font-weight: 600; line-height: 1.55; margin-bottom: 14px; }
.quiz-options  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.quiz-option {
  text-align: left; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 0.88rem; color: var(--ink); line-height: 1.45;
  transition: border-color .12s, background .12s;
  white-space: pre-wrap;
}
.quiz-option:hover:not(:disabled)  { border-color: var(--primary); background: var(--primary-lt); }
.quiz-option.correct   { background: var(--green-lt);  border-color: var(--green); color: var(--green); font-weight: 600; }
.quiz-option.incorrect { background: var(--red-lt);    border-color: var(--red);   color: var(--red); }
.quiz-reveal {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px; margin-bottom: 12px; font-size: 0.88rem; line-height: 1.65;
}
.quiz-result { text-align: center; padding: 36px 0; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.result-emoji { font-size: 3.8rem; }
.result-score { font-size: 1.15rem; font-weight: 600; }

/* ====== BROWSE ====== */
.browse-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1rem; pointer-events: none; }
.search-input {
  width: 100%; padding: 12px 14px 12px 40px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: 0.93rem;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,98,42,.1); }
.browse-count { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }
.browse-list  { display: flex; flex-direction: column; gap: 10px; }
.browse-item  {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 15px; box-shadow: var(--shadow);
  transition: border-color .15s;
}
.browse-item:hover { border-color: var(--primary); }
.browse-cat   { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); margin-bottom: 7px; }
.browse-q     { font-weight: 600; font-size: 0.94rem; line-height: 1.5; margin-bottom: 3px; }
.browse-qvi   { font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; line-height: 1.45; }
.browse-ans   { font-size: 0.88rem; line-height: 1.65; color: var(--ink); }
.browse-ans.empty { color: var(--muted); font-style: italic; }
.browse-ansvi {
  font-size: 0.86rem; color: var(--ink); margin-top: 7px; line-height: 1.55;
  padding: 7px 11px; background: var(--surface2);
  border-radius: var(--radius-sm); border-left: 3px solid var(--border);
  opacity: 0.88;
}
.browse-divider { height: 1px; background: var(--border); margin: 10px 0; }
.browse-vocab  { margin-top: 10px; }
.browse-vocab-title { font-size: 0.67rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.browse-vocab-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.browse-vocab-chip {
  background: var(--primary-lt); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; font-size: 0.77rem;
}
.bvc-term    { font-weight: 700; color: var(--primary-dk); }
.bvc-ipa     { color: var(--muted); margin-left: 4px; font-family: monospace; font-size: .9em; }
.bvc-meaning { color: var(--ink); margin-left: 4px; }

/* Search highlight */
mark {
  background: rgba(232,98,42,.22); color: var(--primary-dk);
  padding: 0 2px; border-radius: 2px;
}

/* ====== THEORY ====== */
.theory-intro { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; line-height: 1.55; }
.theory-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px,1fr)); gap: 10px; }

.theory-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 7px;
}
.theory-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.theory-card-top   { display: flex; align-items: center; gap: 10px; }
.theory-card-emoji { font-size: 1.5rem; }
.theory-card h3    { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.theory-card-vi    { font-size: 0.73rem; color: var(--muted); }
.theory-card-meta  { font-size: 0.73rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.theory-read-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: var(--green-lt); color: var(--green); font-weight: 600; align-self: flex-start; }

.theory-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; color: var(--primary);
  font-size: 0.88rem; font-weight: 600; padding: 0; margin-bottom: 16px; cursor: pointer;
}
.theory-back:hover { text-decoration: underline; }

.theory-header { margin-bottom: 18px; }
.theory-header-top { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.theory-header-emoji { font-size: 2.2rem; }
.theory-header h2    { font-size: 1.25rem; font-weight: 700; }
.theory-header-vi    { font-size: 0.88rem; color: var(--muted); }
.theory-intro-text   {
  font-size: 0.93rem; color: var(--ink); line-height: 1.65;
  background: var(--primary-lt); border-left: 3px solid var(--primary);
  padding: 11px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-top: 10px;
}

.theory-sections { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.theory-section  {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.theory-section-header {
  padding: 13px 15px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; background: var(--surface); transition: background .15s;
}
.theory-section-header:hover { background: var(--surface2); }
.theory-section-title { font-size: 0.94rem; font-weight: 600; }
.theory-section-arrow { font-size: 0.8rem; color: var(--muted); transition: transform .25s; flex-shrink: 0; }
.theory-section.open .theory-section-arrow { transform: rotate(180deg); }
.theory-section-body  { padding: 0 15px; max-height: 0; overflow: hidden; transition: max-height .35s ease, padding .25s; }
.theory-section.open .theory-section-body  { max-height: 2000px; padding: 0 15px 15px; }

.theory-section-content { font-size: 0.88rem; line-height: 1.7; color: var(--ink); margin-bottom: 12px; }
.theory-key-points { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.theory-key-points li { display: flex; gap: 8px; font-size: 0.86rem; line-height: 1.5; }
.theory-key-points li::before { content: "✦"; color: var(--primary); flex-shrink: 0; margin-top: 2px; }

.theory-vocab { margin-bottom: 18px; }
.theory-vocab h3  { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 9px; }
.theory-vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 8px; }
.theory-vocab-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.tv-row1    { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.tv-term    { font-weight: 700; color: var(--primary-dk); font-size: 0.93rem; }
.tv-ipa     { font-family: monospace; font-size: 0.74rem; color: var(--muted); }
.tv-meaning { font-size: 0.83rem; color: var(--ink); }
.tv-example { font-size: 0.76rem; color: var(--muted); font-style: italic; margin-top: 2px; }

.theory-tips { background: var(--amber-lt); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; margin-bottom: 18px; }
.theory-tips h3  { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--amber); margin-bottom: 7px; }
.theory-tips ul  { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.theory-tips li  { font-size: 0.86rem; line-height: 1.5; display: flex; gap: 8px; }
.theory-tips li::before { content: "💡"; flex-shrink: 0; }

.theory-action-bar { display: flex; gap: 10px; margin-top: 8px; }
.theory-action-bar .primary-btn { flex: 1; font-size: 0.88rem; padding: 12px 8px; }

/* ====== RESPONSIVE ====== */
@media (max-width: 480px) {
  .category-grid { grid-template-columns: 1fr 1fr; }
  .rate-btn { font-size: 0.75rem; padding: 12px 4px; }
  .hero-ring { width: 68px; height: 68px; }
  .fc-card { border-radius: 14px; }
  .weekly-bars { gap: 3px; }
}
@media (max-width: 360px) {
  .category-grid { grid-template-columns: 1fr; }
}

/* ====== TOAST ====== */
.toast {
  position: fixed; top: calc(var(--header-h) + 10px); left: 50%; transform: translateX(-50%) translateY(-8px);
  z-index: 200; padding: 9px 18px; border-radius: 20px;
  font-size: 0.86rem; font-weight: 600; white-space: nowrap;
  background: var(--ink); color: var(--bg);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.known    { background: var(--green);   color: #fff; }
.toast.learning { background: var(--amber);   color: #fff; }
.toast.new      { background: var(--primary); color: #fff; }

/* ====== QUICK RESUME ====== */
.quick-resume {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dk) 100%);
  border-radius: var(--radius); padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(232,98,42,.3);
  transition: transform .15s, box-shadow .15s;
}
.quick-resume:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232,98,42,.4); }
.qr-left  { display: flex; flex-direction: column; gap: 2px; }
.qr-label { font-size: 0.67rem; color: rgba(255,255,255,.75); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.qr-title { font-size: 0.94rem; font-weight: 700; color: #fff; }
.qr-meta  { font-size: 0.76rem; color: rgba(255,255,255,.8); margin-top: 1px; }
.qr-arrow { font-size: 1.3rem; color: rgba(255,255,255,.7); flex-shrink: 0; }

/* ====== BROWSE COLLAPSIBLE ====== */
.browse-item { cursor: default; }
.browse-item-body { display: none; }
.browse-item.open .browse-item-body { display: block; }
.browse-expand {
  margin-top: 7px; font-size: 0.77rem; font-weight: 600; color: var(--primary);
  background: none; border: none; padding: 3px 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.browse-expand::after { content: ' ▼'; font-size: 0.63rem; }
.browse-item.open .browse-expand::after { content: ' ▲'; }

/* ====== THEORY NAV BADGE ====== */
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 18px);
  background: var(--primary); color: #fff;
  font-size: 0.58rem; font-weight: 700;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}

/* ====== FLASHCARD COMPLETE ====== */
.fc-complete {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 28px 16px; text-align: center;
}
.fc-complete-emoji { font-size: 3rem; }
.fc-complete-title { font-size: 1.15rem; font-weight: 700; }
.fc-complete-stats { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 4px 0; }
.fc-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fc-stat-num  { font-size: 1.4rem; font-weight: 700; }
.fc-stat-lbl  { font-size: 0.7rem; color: var(--muted); }
.fc-complete .primary-btn { width: auto; padding: 11px 28px; font-size: 0.9rem; }

/* ====== LOGIN SCREEN ====== */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px 26px;
  box-shadow: 0 8px 40px rgba(0,0,0,.13);
}
.login-logo  { font-size: 2.4rem; text-align: center; margin-bottom: 6px; }
.login-title { font-size: 1.35rem; font-weight: 700; text-align: center; margin: 0 0 3px; }
.login-sub   { font-size: .8rem; color: var(--muted); text-align: center; margin: 0 0 18px; }
.auth-tabs { display: flex; gap: 0; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; background: none; cursor: pointer;
  border-radius: 8px; font-size: .86rem; color: var(--muted); font-weight: 500; transition: all .2s;
}
.auth-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.13); }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-label { font-size: .76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-input {
  padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: .93rem;
  outline: none; transition: border-color .2s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,98,42,.1); }
.login-error { color: #d63; font-size: .82rem; min-height: 18px; margin: -4px 0 6px; }

.header-user {
  font-size: .75rem; color: rgba(255,255,255,.85);
  padding: 3px 8px; background: rgba(255,255,255,.18);
  border-radius: 8px; max-width: 90px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
  background: rgba(255,255,255,.18); border: none; border-radius: 8px;
  padding: 5px 8px; cursor: pointer; font-size: .88rem; color: rgba(255,255,255,.9);
  transition: background .2s;
}
.logout-btn:hover { background: rgba(255,255,255,.3); }

@media (prefers-reduced-motion: reduce) {
  *, .hero-ring-fg, .big-bar div { transition: none !important; animation: none !important; }
}
