/* Collapsible sections */
.section-toggle { display:flex; justify-content:space-between; align-items:center; cursor:pointer; user-select:none; }
.section-toggle:hover .toggle-chevron { color:var(--primary); }
.toggle-chevron { font-size:.75rem; color:var(--text-secondary); transition:transform .3s; padding:4px; }
.collapsible.collapsed .toggle-chevron { transform:rotate(-90deg); }
.collapsible.collapsed .section-body { display:none; }
.collapsible.collapsed .section-subtitle { display:none; }

/* Grammar Exercises */
.ex-tense-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:16px; }
.ex-tab { padding:8px 16px; border:1px solid var(--border); border-radius:20px; background:var(--bg-card); font-size:.85rem; font-weight:600; cursor:pointer; transition:.2s; font-family:inherit; }
.ex-tab:hover { border-color:var(--primary); color:var(--primary); }
.ex-tab-active { background:var(--primary); color:#fff; border-color:var(--primary); }
.ex-header { display:flex; justify-content:space-between; font-size:.85rem; color:var(--text-secondary); margin-bottom:12px; font-weight:600; }
.ex-question { font-size:1.05rem; font-weight:600; margin-bottom:16px; line-height:1.6; }
.ex-options { display:grid; gap:8px; }
.ex-opt { padding:12px 16px; border:2px solid var(--border); border-radius:var(--radius); font-size:.92rem; cursor:pointer; text-align:left; transition:.15s; background:var(--bg-card); font-family:inherit; }
.ex-opt:hover { border-color:var(--primary); }
.ex-correct { border-color:var(--success)!important; background:#dcfce7!important; color:#15803d!important; }
.ex-wrong { border-color:#ef4444!important; background:#fee2e2!important; color:#dc2626!important; }
.ex-fill { display:flex; gap:8px; align-items:center; }
.ex-input { flex:1; padding:10px 14px; border:2px solid var(--border); border-radius:var(--radius); font-size:1rem; font-family:inherit; }
.ex-input:focus { outline:none; border-color:var(--primary); }
.ex-fb { padding:10px 14px; border-radius:var(--radius); margin-top:12px; font-size:.9rem; font-weight:600; }
.ex-fb-ok { background:#dcfce7; color:#15803d; }
.ex-fb-no { background:#fee2e2; color:#dc2626; }
.ex-result { text-align:center; padding:24px; }
.ex-score { font-size:1.8rem; font-weight:800; color:var(--primary); }
.ex-msg { font-size:1rem; color:var(--text-secondary); margin:8px 0 16px; }

:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-light: #06b6d4;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --accent: #f0fdfa;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}
.dark {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-nav: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --accent: #0f2a2a;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.3);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}
nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
  transition: background 0.3s;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); white-space: nowrap; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  text-decoration: none; color: var(--text-secondary);
  padding: 6px 14px; border-radius: 6px; font-size: 0.9rem; font-weight: 500;
  transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active { background: var(--accent); color: var(--primary); }
.nav-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  padding: 7px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); cursor: pointer;
  font-size: 0.85rem; font-weight: 500; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
main { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.section { margin-bottom: 48px; }
.section-title {
  font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.section-subtitle { color: var(--text-secondary); margin-bottom: 24px; font-size: 1rem; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow); transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
/* IPA */
.ipa-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 24px;
  grid-auto-rows: 1fr;
}
.ipa-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
  transition: all 0.2s; cursor: default;
  display: flex; flex-direction: column;
  height: 100%;
}
.ipa-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.ipa-symbol { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.ipa-word { font-size: 0.95rem; font-weight: 600; }
.ipa-desc { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; min-height: 2.8em; }
.ipa-vn { font-size: 0.78rem; color: #c2410c; margin-top: 3px; font-style: italic; line-height: 1.4; min-height: 2.8em; }
.dark .ipa-vn { color: #fb923c; }
.word-vn { font-size: 0.82rem; color: #c2410c; font-style: italic; margin-bottom: 4px; }
.dark .word-vn { color: #fb923c; }

.speak-btn {
  background: none; border: none; cursor: pointer; font-size: 1.2rem;
  color: var(--primary); padding: 4px; border-radius: 50%;
  transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
}
.speak-btn:hover { background: var(--accent); transform: scale(1.1); }
.speak-btn:active { transform: scale(0.95); }
.ipa-card { cursor: default; }
.ipa-section-label { font-size: 1.1rem; font-weight: 600; margin: 20px 0 12px; color: var(--primary-dark); }
.minimal-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mp-card { display: flex; gap: 16px; align-items: center; }
.mp-vs { font-weight: 700; color: var(--primary); font-size: 0.85rem; }
/* Vocab */
.vocab-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; align-items: center; }
.search-box {
  flex: 1; min-width: 200px; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.95rem; background: var(--bg-card);
  color: var(--text); outline: none; transition: border 0.2s;
}
.search-box:focus { border-color: var(--primary); }
.topic-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip {
  padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.chip:hover, .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip .chip-count { margin-left: 4px; opacity: 0.7; font-size: 0.75rem; }
.progress-bar-container { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; }
.progress-bar-fill { height: 100%; background: var(--success); border-radius: 2px; transition: width 0.3s; }
.vocab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media(max-width:900px) { .vocab-grid { grid-template-columns: repeat(2, 1fr); } }
@media(max-width:550px) { .vocab-grid { grid-template-columns: 1fr; } }
.word-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; transition: all 0.2s;
  position: relative; cursor: pointer;
}
.word-card:hover { box-shadow: var(--shadow-lg); border-color: var(--primary); }
.word-card.learned { border-left: 3px solid var(--success); }
.word-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.word-term { font-size: 0.95rem; font-weight: 700; }
.word-ipa { font-size: 0.72rem; color: var(--primary); font-family: var(--font-mono); }
.word-pos { font-size: 0.68rem; color: var(--text-secondary); font-style: italic; margin-bottom: 2px; }
.word-def { font-size: 0.8rem; margin-bottom: 3px; line-height: 1.3; }
.word-vn { font-size: 0.78rem; }
.word-ex { font-size: 0.72rem; color: var(--text-secondary); font-style: italic; line-height: 1.3; }
.word-extra { font-size: 0.72rem; color: var(--primary-dark); margin-top: 3px; line-height: 1.3; }
.word-extra span { display: inline-block; padding: 1px 5px; background: var(--accent); border-radius: 4px; margin: 1px 2px; font-size: 0.68rem; }
.word-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.learn-dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border); font-size: 0.65rem; cursor: pointer; background: var(--bg-card); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.learn-dot:hover { border-color: var(--success); color: var(--success); }
.learn-dot.learned-dot { background: var(--success); color: #fff; border-color: var(--success); }
/* Grammar */
.grammar-block { margin-bottom: 16px; }
.grammar-header {
  padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; transition: all 0.2s;
  font-weight: 600; font-size: 1rem;
}
.grammar-header:hover { border-color: var(--primary); }
.grammar-header .arrow { transition: transform 0.3s; font-size: 0.8rem; color: var(--text-secondary); }
.grammar-header.open .arrow { transform: rotate(180deg); }
.grammar-body {
  max-height: 0; overflow: hidden; transition: max-height 0.4s ease;
  border: 1px solid transparent;
}
.grammar-body.open {
  max-height: 5000px; border-color: var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
}
.grammar-content { padding: 18px; background: var(--bg-card); }
.grammar-content h4 { color: var(--primary); margin: 14px 0 6px; font-size: 0.95rem; }
.grammar-content h4:first-child { margin-top: 0; }
.formula-box {
  background: var(--accent); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 14px; font-family: var(--font-mono); font-size: 0.9rem;
  margin: 8px 0;
}
.example-list { list-style: none; padding: 0; }
.example-list li { padding: 4px 0; font-size: 0.9rem; }
.example-list li::before { content: ""; display: inline-block; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; margin-right: 8px; }
.mistake-box {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  padding: 10px 14px; margin: 8px 0; font-size: 0.88rem;
}
.dark .mistake-box { background: #2a1515; border-color: #5a2020; }
.tense-timeline {
  background: var(--accent); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin: 12px 0; text-align: center;
}
.tense-timeline svg { max-width: 100%; height: auto; }
.tense-timeline svg text { fill: var(--text); font-family: var(--font); }
.tense-timeline svg .timeline-line { stroke: var(--border); stroke-width: 2; }
.tense-timeline svg .timeline-marker { fill: var(--primary); }
.tense-timeline svg .timeline-action { fill: var(--success); }
.tense-timeline svg .timeline-range { fill: var(--primary); opacity: 0.15; }
.tense-timeline svg .timeline-label { font-size: 11px; fill: var(--text-secondary); }
.tense-timeline svg .timeline-now { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 4; }
.vietnamese-box {
  background: linear-gradient(135deg, #fff7ed, #fef3c7); border: 1px solid #fed7aa;
  border-radius: 8px; padding: 14px 16px; margin: 12px 0; font-size: 0.9rem;
}
.dark .vietnamese-box {
  background: linear-gradient(135deg, #2a1f0a, #2a250a); border-color: #5a4020;
}
.vietnamese-box .vn-flag { font-size: 1rem; margin-right: 6px; }
.vietnamese-box .vn-title { font-weight: 700; color: #c2410c; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.dark .vietnamese-box .vn-title { color: #fb923c; }
.vietnamese-box p { margin: 4px 0; line-height: 1.6; }
.tip-box {
  background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #93c5fd;
  border-radius: 8px; padding: 14px 16px; margin: 12px 0; font-size: 0.88rem;
}
.dark .tip-box { background: linear-gradient(135deg, #0a1a2a, #0a1530); border-color: #1e40af; }
.tip-box .tip-icon { font-size: 1rem; margin-right: 6px; }
.tip-box .tip-title { font-weight: 700; color: #1d4ed8; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.dark .tip-box .tip-title { color: #60a5fa; }
.correct { color: var(--success); }
.incorrect { color: var(--danger); text-decoration: line-through; }
/* Flashcard Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: 200; display: flex;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 32px; max-width: 500px; width: 90%; box-shadow: var(--shadow-lg);
  text-align: center; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: var(--text-secondary);
}
.flashcard {
  min-height: 180px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; margin: 20px 0;
}
.flashcard-word { font-size: 2rem; font-weight: 700; }
.flashcard-ipa { font-size: 1.1rem; color: var(--primary); margin-top: 4px; }
.flashcard-reveal { margin-top: 16px; }
.flashcard-pos { font-style: italic; color: var(--text-secondary); }
.flashcard-def { font-size: 1.1rem; margin-top: 6px; }
.flashcard-ex { font-size: 0.9rem; color: var(--text-secondary); font-style: italic; margin-top: 8px; }
.flashcard-counter { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }
.quiz-option {
  display: block; width: 100%; padding: 10px 16px; margin: 6px 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text); cursor: pointer;
  font-size: 0.95rem; text-align: left; transition: all 0.2s;
}
.quiz-option:hover { border-color: var(--primary); }
.quiz-option.correct-answer { background: #d1fae5; border-color: var(--success); }
.quiz-option.wrong-answer { background: #fee2e2; border-color: var(--danger); }
.dark .quiz-option.correct-answer { background: #064e3b; }
.dark .quiz-option.wrong-answer { background: #7f1d1d; }
.quiz-score { font-size: 1.1rem; font-weight: 600; margin: 12px 0; }
/* Stats bar */
.stats-bar {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.88rem;
}
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-num { font-weight: 700; color: var(--primary); }
/* Daily Dashboard */
.dashboard {
  background: linear-gradient(135deg, var(--bg-card), var(--accent));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 32px; box-shadow: var(--shadow);
}
.dashboard-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.dashboard-title { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.dashboard-date { font-size: 0.85rem; color: var(--text-secondary); }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.dash-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.dash-card-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.dash-card-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.dash-card-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.streak-fire { color: #f59e0b; }
.daily-progress-bar { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; margin: 8px 0; }
.daily-progress-fill { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.daily-progress-fill.incomplete { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.daily-progress-fill.complete { background: linear-gradient(90deg, var(--success), #34d399); }
.target-setting { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.target-input {
  width: 60px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 0.9rem; text-align: center; background: var(--bg-card); color: var(--text);
}
.daily-words-btn { margin-top: 12px; }
.heatmap { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 12px; }
.heatmap-day {
  width: 14px; height: 14px; border-radius: 2px; border: 1px solid var(--border);
  position: relative;
}
.heatmap-day[title]:hover::after {
  content: attr(title); position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-size: 0.7rem; white-space: nowrap; z-index: 10;
}
.heat-0 { background: var(--border); }
.heat-1 { background: #bbf7d0; }
.heat-2 { background: #4ade80; }
.heat-3 { background: #16a34a; }
.heat-4 { background: #166534; }
.dark .heat-1 { background: #14532d; }
.dark .heat-2 { background: #166534; }
.dark .heat-3 { background: #15803d; }
.dark .heat-4 { background: #22c55e; }
.getting-started {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 32px;
}
.getting-started h3 { color: var(--primary); margin-bottom: 8px; font-size: 1.1rem; }
.getting-started ol { padding-left: 20px; margin: 8px 0; }
.getting-started li { padding: 4px 0; font-size: 0.9rem; color: var(--text-secondary); }
.getting-started li strong { color: var(--text); }
.welcome-msg { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.6; }
.dismiss-btn { font-size: 0.8rem; color: var(--text-secondary); background: none; border: none; cursor: pointer; text-decoration: underline; margin-top: 8px; }
.today-words-section { margin-top: 16px; }
.today-label { font-size: 0.9rem; font-weight: 600; color: var(--primary-dark); margin-bottom: 8px; }
/* Mobile */
/* Tablet — iPad 11" (820px) and similar */
@media (max-width: 880px) {
  .nav-links { display: none; }
  .mobile-menu-btn { display: block !important; }
  main { padding: 20px 16px; }
  .section-title { font-size: 1.5rem; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .ipa-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .vocab-grid { grid-template-columns: repeat(2, 1fr); }
  .minimal-pairs { grid-template-columns: 1fr; }
  .formula-box { font-size: 0.82rem; overflow-x: auto; }
  .formula-box code { word-break: break-word; }
}
/* Phone — iPhone 17 Pro (393px) and similar */
@media (max-width: 480px) {
  nav { padding: 0 10px; height: 50px; }
  .nav-brand { font-size: 0.9rem; }
  main { padding: 12px 10px; }
  .section { margin-bottom: 32px; }
  .section-title { font-size: 1.25rem; gap: 6px; }
  .section-subtitle { font-size: 0.88rem; margin-bottom: 16px; }
  /* Dashboard */
  .dashboard { padding: 16px 14px; margin-bottom: 20px; }
  .dashboard-title { font-size: 1.1rem; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-card { padding: 12px 8px; }
  .dash-card-value { font-size: 1.5rem; }
  .dash-card-label { font-size: 0.72rem; }
  .dash-card-sub { font-size: 0.68rem; }
  /* Timer */
  .timer-bar { gap: 8px; padding: 10px 12px; flex-direction: column; align-items: stretch; }
  .timer-display { justify-content: center; }
  .timer-digits { font-size: 1.4rem; min-width: auto; text-align: center; }
  .timer-controls { justify-content: center; }
  .timer-today-total { margin-left: 0; justify-content: center; }
  /* Getting started */
  .getting-started { padding: 14px 12px; margin-bottom: 20px; }
  .getting-started h3 { font-size: 1rem; }
  .getting-started ol { padding-left: 16px; }
  .getting-started li { font-size: 0.82rem; }
  .welcome-msg { font-size: 0.85rem; }
  /* IPA */
  .ipa-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .ipa-card { padding: 10px 8px; }
  .ipa-symbol { font-size: 1.5rem; }
  .ipa-word { font-size: 0.85rem; }
  .ipa-desc { font-size: 0.72rem; }
  .ipa-vn { font-size: 0.72rem; }
  .ipa-section-label { font-size: 1rem; margin: 14px 0 8px; }
  .speak-btn { width: 26px; height: 26px; font-size: 1rem; }
  /* Common Mistakes cards */
  .card { padding: 14px 12px; }
  .mistake-box { padding: 8px 10px; font-size: 0.82rem; }
  .vietnamese-box { padding: 10px 12px; font-size: 0.82rem; }
  .tip-box { padding: 10px 12px; font-size: 0.82rem; }
  /* Vocab */
  .vocab-controls { gap: 8px; margin-bottom: 12px; }
  .search-box { min-width: 100%; font-size: 16px; /* prevent iOS zoom */ }
  .topic-chips { gap: 4px; margin-bottom: 12px; }
  .chip { padding: 4px 10px; font-size: 0.72rem; }
  .vocab-grid { grid-template-columns: 1fr; }
  .word-card { padding: 12px 10px; }
  .word-term { font-size: 0.95rem; }
  .word-ipa { font-size: 0.78rem; }
  .word-def { font-size: 0.82rem; }
  .word-vn { font-size: 0.78rem; }
  .word-ex { font-size: 0.78rem; }
  /* Grammar */
  .grammar-header { padding: 12px 14px; font-size: 0.9rem; }
  .grammar-content { padding: 14px 12px; }
  .grammar-content h4 { font-size: 0.88rem; }
  .formula-box { padding: 8px 10px; font-size: 0.8rem; overflow-x: auto; }
  .formula-box code { font-size: 0.78rem; word-break: break-word; }
  .example-list li { font-size: 0.82rem; }
  .tense-timeline { padding: 10px; }
  /* ChatGPT Guide */
  .formula-box code { display: block; white-space: pre-wrap; }
  /* Stats */
  .stats-bar { gap: 10px; padding: 10px 12px; font-size: 0.82rem; flex-direction: column; }
  /* Target setting */
  .target-setting { width: 100%; justify-content: center; }
  /* Buttons */
  .daily-words-btn { width: 100%; justify-content: center; }
  /* Heatmap */
  .heatmap { justify-content: center; }
  .heatmap-day { width: 12px; height: 12px; }
  /* Modal */
  .modal { padding: 20px 16px; width: 95%; }
  .flashcard-word { font-size: 1.5rem; }
  .flashcard-ipa { font-size: 0.95rem; }
  .flashcard-counter { font-size: 0.78rem; }
  .quiz-option { padding: 10px 12px; font-size: 0.88rem; }
  /* Progress bars */
  .progress-bar-container { height: 5px; }
  .daily-progress-bar { height: 8px; }
  /* Notes panel */
  .notes-panel { width: 100vw; height: 80vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .notes-fab { bottom: 16px; right: 16px; width: 46px; height: 46px; font-size: 1.2rem; }
}
/* Prevent iOS input zoom (font-size must be >= 16px) */
@media (max-width: 480px) {
  input[type="text"], input[type="number"], textarea, select {
    font-size: 16px !important;
  }
}
/* Safe area for notched phones (iPhone 17 Pro) */
@supports (padding: env(safe-area-inset-bottom)) {
  .notes-fab { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .notes-panel { padding-bottom: env(safe-area-inset-bottom); }
  nav { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
}
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); }
.mobile-nav {
  display: none; position: fixed; top: 56px; left: 0; right: 0;
  background: var(--bg-nav); border-bottom: 1px solid var(--border);
  padding: 12px; z-index: 99; box-shadow: var(--shadow-lg);
}
.mobile-nav.show { display: flex; flex-direction: column; gap: 4px; }
.mobile-nav a {
  padding: 10px 14px; text-decoration: none; color: var(--text);
  border-radius: var(--radius); font-size: 0.95rem;
}
.mobile-nav a:hover { background: var(--accent); }
.hidden { display: none !important; }
.topic-progress-label { font-size: 0.78rem; color: var(--text-secondary); display: flex; justify-content: space-between; }
/* Study Timer */
.timer-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px; margin-bottom: 16px;
}
.timer-display { display: flex; align-items: center; gap: 8px; }
.timer-icon { font-size: 1.3rem; }
.timer-digits {
  font-size: 1.6rem; font-weight: 800; font-family: var(--font-mono);
  color: var(--text); letter-spacing: 2px; min-width: 110px;
}
.timer-digits.running { color: var(--primary); }
.timer-controls { display: flex; gap: 6px; }
.timer-today-total { margin-left: auto; display: flex; align-items: center; gap: 6px; }
/* Notes */
.notes-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 90;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.notes-fab:hover { background: var(--primary-dark); transform: scale(1.08); }
.notes-fab .fab-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff; font-size: 0.65rem; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.notes-panel {
  position: fixed; bottom: 0; right: 0; z-index: 150;
  width: 500px; max-width: 100vw; height: 75vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform 0.3s ease;
}
.notes-panel.open { transform: translateY(0); }
.notes-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notes-panel-header h3 { font-size: 1rem; color: var(--text); }
.notes-panel-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-secondary); }
.notes-panel-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.notes-panel-footer { padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; }
.note-input-row { display: flex; gap: 8px; align-items: flex-end; }
.note-input {
  flex: 1; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.9rem; background: var(--bg); color: var(--text); resize: vertical;
  font-family: var(--font); outline: none; min-height: 80px; max-height: 200px;
}
.note-input:focus { border-color: var(--primary); }
.note-tag-select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.8rem; background: var(--bg); color: var(--text); cursor: pointer;
}
.note-item {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.note-tag {
  font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.note-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.note-tag.question { background: #dbeafe; color: #1d4ed8; }
.note-tag.issue { background: #fee2e2; color: #dc2626; }
.note-tag.tip { background: #d1fae5; color: #059669; }
.note-tag.general { background: #e2e8f0; color: #475569; }
.dark .note-tag.question { background: #1e3a5f; color: #93c5fd; }
.dark .note-tag.issue { background: #5a1a1a; color: #fca5a5; }
.dark .note-tag.tip { background: #064e3b; color: #6ee7b7; }
.dark .note-tag.general { background: #334155; color: #94a3b8; }
.note-date { font-size: 0.7rem; color: var(--text-secondary); }
.note-text { font-size: 0.88rem; color: var(--text); line-height: 1.5; }
.note-section-ref { font-size: 0.75rem; color: var(--primary); font-style: italic; margin-top: 2px; }
.note-delete {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 0.85rem; padding: 2px 6px;
}
.note-delete:hover { color: var(--danger); }
.notes-filter { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.notes-empty {
  text-align: center; color: var(--text-secondary); padding: 40px 20px;
  font-size: 0.9rem;
}
/* Voice Recording */
.ipa-rec-row { display: flex; gap: 4px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.rec-btn {
  background: none; border: 1px solid var(--border); cursor: pointer;
  border-radius: 4px; padding: 3px 7px; font-size: 0.7rem; color: var(--text-secondary);
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 3px;
}
.rec-btn:hover { border-color: var(--primary); color: var(--primary); }
.rec-btn.recording { border-color: var(--danger); color: var(--danger); animation: pulse-rec 1s infinite; }
.rec-btn.has-recording { border-color: var(--success); color: var(--success); }
@keyframes pulse-rec { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }
.rec-playback { display: flex; align-items: center; gap: 4px; margin-top: 4px; justify-content: center; }
.rec-playback audio { height: 28px; max-width: 140px; }
/* Recording Review Panel */
.rec-review-bar {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
}
.rec-review-bar .rec-count { font-size: 0.85rem; color: var(--text-secondary); }
.rec-review-bar .rec-count strong { color: var(--primary); }
.rec-review-panel { margin-bottom: 24px; }
.rec-review-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px;
}
.rec-review-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}
.rec-review-card .rec-info { flex: 1; }
.rec-review-card .rec-symbol { font-weight: 700; color: var(--primary); font-size: 1.1rem; }
.rec-review-card .rec-word { font-size: 0.82rem; color: var(--text-secondary); }
.rec-review-card audio { height: 28px; flex-shrink: 0; max-width: 150px; }
.rec-review-card .rec-delete-btn {
  background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 0.85rem;
}
.rec-review-card .rec-delete-btn:hover { color: var(--danger); }
@media (max-width: 480px) {
  .rec-review-grid { grid-template-columns: 1fr; }
  .rec-review-card audio { max-width: 120px; }
  .rec-btn { padding: 2px 5px; font-size: 0.65rem; }
}
/* Pronunciation Score */
.rec-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ipa-score-row { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.ipa-score-row .score-head {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 4px;
}
.ipa-score-row .score-overall {
  font-weight: 700; font-size: 0.95rem; padding: 1px 8px; border-radius: 10px;
  border: 1px solid var(--border);
}
.ipa-score-row .score-overall.good { color: var(--success); border-color: var(--success); }
.ipa-score-row .score-overall.mid  { color: var(--warning); border-color: var(--warning); }
.ipa-score-row .score-overall.bad  { color: var(--danger);  border-color: var(--danger); }
.ipa-score-row .score-label { font-size: 0.7rem; color: var(--text-secondary); }
.ipa-score-row .score-clear {
  background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 0.9rem;
  margin-left: auto; padding: 0 4px;
}
.ipa-score-row .score-clear:hover { color: var(--danger); }
.ipa-score-row .phoneme-row {
  display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;
}
.phoneme-pill {
  font-size: 0.68rem; padding: 1px 6px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.phoneme-pill.good { color: var(--success); border-color: var(--success); }
.phoneme-pill.mid  { color: var(--warning); border-color: var(--warning); }
.phoneme-pill.bad  { color: var(--danger);  border-color: var(--danger); }

/* ---- IPA card ---- */
.ipa-head {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.ipa-head .ipa-symbol { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.ipa-head .ipa-word  { font-size: 1.05rem; font-weight: 600; }
.ipa-speak-mini { font-size: 0.78rem; width: 22px; height: 22px; padding: 0; }

.ipa-action {
  display: flex; align-items: center; justify-content: center;
  margin-top: auto; padding-top: 10px; min-height: 38px;
}
.ipa-score-btn {
  font-size: 0.82rem; padding: 6px 14px;
  border-color: var(--primary); color: var(--primary); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.ipa-score-btn:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-icon { width: 14px; height: 14px; flex-shrink: 0; }
.btn-icon-rec { fill: #ef4444; }

.score-play {
  background: transparent; border: 1px solid var(--success);
  color: var(--success); border-radius: 50%;
  width: 22px; height: 22px; font-size: 0.7rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.score-play:hover { background: var(--success); color: #fff; }

.ipa-recording-ui {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; border: 1px solid var(--danger); border-radius: 8px;
  background: rgba(220, 38, 38, 0.06);
  width: 100%; box-sizing: border-box; min-height: 38px;
  animation: pulse-rec-bg 1.2s ease-in-out infinite;
}
@keyframes pulse-rec-bg {
  0%, 100% { background: rgba(220, 38, 38, 0.06); }
  50% { background: rgba(220, 38, 38, 0.14); }
}
.ipa-recording-label { font-size: 0.78rem; color: var(--danger); font-weight: 700; white-space: nowrap; }
.ipa-timer { font-size: 0.72rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ipa-stop-btn { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.ipa-stop-btn:hover { background: var(--danger); color: #fff; }

.ipa-analyzing {
  font-size: 0.8rem; color: var(--text-secondary);
  padding: 4px 10px; border: 1px dashed var(--border); border-radius: 8px;
  width: 100%; box-sizing: border-box; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
}

.vu-meter {
  flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; min-width: 60px;
}
.vu-fill {
  height: 100%;
  background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
  transition: width 60ms linear;
}

/* ---- Score bar (single overall) ---- */
.score-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.score-bar-label {
  font-size: 0.78rem; color: var(--text-secondary); font-weight: 600;
  min-width: 52px;
}
.score-bar-track {
  flex: 1; height: 12px; background: var(--border); border-radius: 6px; overflow: hidden;
}
.score-bar-fill {
  height: 100%; border-radius: 6px;
  transition: width 400ms ease-out;
}
.score-bar-fill.good { background: var(--success); }
.score-bar-fill.mid  { background: var(--warning); }
.score-bar-fill.bad  { background: var(--danger); }
.score-bar-num {
  font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 32px; text-align: right;
}
.score-bar-num.good { color: var(--success); }
.score-bar-num.mid  { color: var(--warning); }
.score-bar-num.bad  { color: var(--danger); }

.score-heard-row {
  font-size: 0.72rem; color: var(--text-secondary);
  font-style: italic; text-align: center; margin-top: 2px;
}

.ipa-suggestion {
  margin-top: 6px; padding: 6px 10px;
  font-size: 0.76rem; line-height: 1.4;
  border-radius: 6px; text-align: center;
  background: var(--accent); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.ipa-suggestion.good { color: var(--success); border-color: var(--success); background: rgba(34, 197, 94, 0.08); }
.ipa-suggestion.mid  { color: var(--warning); border-color: var(--warning); background: rgba(234, 179, 8, 0.08); }
.ipa-suggestion.bad  { color: var(--danger);  border-color: var(--danger);  background: rgba(220, 38, 38, 0.06); text-align: left; }
.ipa-suggestion .vn-tip { color: var(--text-secondary); font-style: italic; }

.ipa-status-warn {
  font-size: 0.78rem; color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid var(--danger); border-radius: 6px;
  padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.ipa-status-warn .score-clear { font-size: 1.1rem; line-height: 1; }

.score-heard {
  font-size: 0.72rem; color: var(--text-secondary); font-style: italic;
  margin-left: 6px;
}
