:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #17202a;
  --muted: #6f7783;
  --line: #e7e9ef;
  --accent: #5b54e8;
  --accent-soft: #eeedff;
  --success: #239c69;
  --success-soft: #e9f7f0;
  --danger: #d94d52;
  --danger-soft: #fff0f0;
  --warning: #b7791f;
  --shadow: 0 16px 40px rgba(32, 37, 48, .08);
  --radius: 24px;
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background:var(--bg); color:var(--text); }
button, select, input { font: inherit; }
button { cursor:pointer; }
.app-shell { width:min(100%, 760px); min-height:100vh; margin:0 auto; padding:22px 18px 104px; }
.topbar { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.eyebrow { color:var(--accent); font-size:12px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; }
h1 { margin:4px 0 0; font-size:26px; letter-spacing:-.03em; }
.streak-pill { border:0; background:#fff; border-radius:999px; padding:10px 14px; font-weight:800; box-shadow:0 8px 24px rgba(32,37,48,.07); }
.view { display:none; }
.view.active { display:block; animation:fade .2s ease; }
@keyframes fade { from { opacity:.55; transform:translateY(4px);} to { opacity:1; transform:none;} }
.card { background:var(--card); border:1px solid rgba(231,233,239,.9); border-radius:var(--radius); box-shadow:var(--shadow); }
.hero-card { padding:24px; background:linear-gradient(145deg, #ffffff, #f1f0ff); }
.hero-row { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }
.korean-hello { font-size:34px; font-weight:900; margin:6px 0 2px; }
.muted { color:var(--muted); }
.mastery-ring { width:90px; height:90px; border-radius:50%; display:grid; place-items:center; background:conic-gradient(var(--accent) calc(var(--pct,0)*1%), #e9e8f9 0); position:relative; flex:0 0 auto; }
.mastery-ring::after { content:""; position:absolute; inset:10px; background:#fff; border-radius:50%; }
.mastery-ring strong { position:relative; z-index:1; font-size:21px; }
.progress-track { width:100%; height:9px; background:#e8e9ef; border-radius:999px; overflow:hidden; margin-top:18px; }
.progress-bar { height:100%; background:var(--accent); border-radius:inherit; }
.stats-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:16px 0; }
.stat-card { padding:17px; }
.stat-card .value { font-size:23px; font-weight:900; margin-top:5px; }
.stat-card .label { color:var(--muted); font-size:12px; font-weight:700; }
.section-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:22px 4px 12px; }
.section-title h2 { font-size:17px; margin:0; }
.action-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.action-card { border:0; text-align:left; padding:18px 14px; border-radius:20px; background:#fff; box-shadow:0 9px 28px rgba(32,37,48,.06); }
.action-card .icon { display:block; font-size:24px; margin-bottom:16px; }
.action-card strong { display:block; font-size:15px; }
.action-card small { display:block; color:var(--muted); margin-top:4px; line-height:1.35; }
.primary-btn, .secondary-btn, .ghost-btn { border:0; border-radius:15px; padding:13px 17px; font-weight:800; }
.primary-btn { background:var(--accent); color:#fff; }
.secondary-btn { background:var(--accent-soft); color:var(--accent); }
.ghost-btn { background:#f2f3f6; color:var(--text); }
.full { width:100%; }
.view-heading { margin:4px 3px 14px; }
.view-heading h2 { margin:0; font-size:22px; }
.view-heading p { margin:5px 0 0; color:var(--muted); }
.filter-chip { display:inline-flex; align-items:center; gap:6px; padding:7px 10px; background:#fff; border:1px solid var(--line); border-radius:999px; color:var(--muted); font-size:12px; font-weight:700; }
.learn-card { padding:22px; position:relative; overflow:hidden; }
.slide-meta { display:flex; align-items:center; justify-content:space-between; color:var(--muted); font-size:12px; font-weight:800; }
.favorite-btn { width:42px; height:42px; border:0; background:#f5f5f8; border-radius:50%; font-size:21px; }
.favorite-btn.active { background:#fff3c8; }
.word-wrap { text-align:center; padding:26px 8px 20px; }
.word { font-size:48px; line-height:1.05; font-weight:950; letter-spacing:-.035em; }
.translation { font-size:18px; color:var(--accent); font-weight:800; margin-top:9px; }
.audio-btn { margin-top:16px; border:0; background:var(--accent-soft); color:var(--accent); width:46px; height:46px; border-radius:50%; font-size:20px; }
.sentence-box { background:#f7f7fa; border-radius:18px; padding:17px; margin:8px 0 16px; }
.sentence-ko { font-size:18px; font-weight:750; line-height:1.55; }
.sentence-en { color:var(--muted); margin-top:7px; line-height:1.5; }
.mini-heading { font-size:11px; color:var(--muted); font-weight:900; text-transform:uppercase; letter-spacing:.1em; margin-bottom:8px; }
.forms-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.form-cell { background:#fafafa; border:1px solid var(--line); padding:10px; border-radius:13px; min-width:0; }
.form-cell span { display:block; color:var(--muted); font-size:10px; font-weight:800; text-transform:uppercase; }
.form-cell strong { display:block; margin-top:3px; font-size:13px; overflow-wrap:anywhere; }
.related { display:flex; flex-wrap:wrap; gap:7px; }
.related span { background:var(--accent-soft); color:#4640bc; border-radius:999px; padding:7px 10px; font-size:12px; font-weight:700; }
.slide-actions { display:grid; grid-template-columns:1fr 1.25fr 1fr; gap:8px; margin-top:18px; }
.slide-actions button { padding-inline:8px; }
.test-card { padding:24px; min-height:510px; display:flex; flex-direction:column; }
.test-progress { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-weight:800; }
.test-prompt { text-align:center; margin:38px 0 26px; }
.test-prompt .label { color:var(--muted); font-size:12px; font-weight:800; text-transform:uppercase; }
.test-word { font-size:46px; font-weight:950; margin-top:12px; overflow-wrap:anywhere; }
.choices { display:grid; gap:10px; }
.choice { border:1px solid var(--line); background:#fff; border-radius:16px; padding:15px 16px; text-align:left; font-weight:750; transition:.15s ease; }
.choice:hover { transform:translateY(-1px); border-color:#cbc8ff; }
.choice.correct { background:var(--success-soft); border-color:#8ad5b3; color:#126a47; }
.choice.wrong { background:var(--danger-soft); border-color:#f0a1a4; color:#a4292e; }
.feedback { margin-top:15px; padding:14px; border-radius:15px; font-weight:750; display:none; }
.feedback.success { display:block; background:var(--success-soft); color:#146c49; }
.feedback.error { display:block; background:var(--danger-soft); color:#a82e33; }
.test-footer { margin-top:auto; padding-top:20px; }
.review-grid { display:grid; gap:10px; }
.review-item { padding:15px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.review-word { font-size:20px; font-weight:900; }
.review-right { text-align:right; }
.badge { display:inline-flex; padding:6px 9px; border-radius:999px; font-size:10px; font-weight:900; text-transform:uppercase; }
.badge.hard { background:var(--danger-soft); color:var(--danger); }
.badge.medium { background:#fff6dd; color:var(--warning); }
.badge.new { background:var(--accent-soft); color:var(--accent); }
.review-score { color:var(--muted); font-size:11px; margin-top:4px; }
.settings-card { padding:8px 18px; }
.setting-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px 2px; border-bottom:1px solid var(--line); }
.setting-row:last-child { border-bottom:0; }
.setting-row strong { display:block; font-size:14px; }
.setting-row small { display:block; color:var(--muted); margin-top:3px; }
.switch { width:48px; height:28px; position:relative; flex:0 0 auto; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; inset:0; background:#dfe1e7; border-radius:999px; transition:.2s; }
.slider:before { content:""; position:absolute; width:22px; height:22px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; box-shadow:0 2px 6px rgba(0,0,0,.14); }
.switch input:checked + .slider { background:var(--accent); }
.switch input:checked + .slider:before { transform:translateX(20px); }
select { border:1px solid var(--line); background:#fff; border-radius:12px; padding:9px 10px; min-width:110px; }
.bottom-nav { position:fixed; left:50%; bottom:12px; transform:translateX(-50%); width:min(calc(100% - 24px), 730px); background:rgba(255,255,255,.96); backdrop-filter:blur(18px); border:1px solid var(--line); border-radius:22px; box-shadow:0 14px 44px rgba(32,37,48,.14); display:grid; grid-template-columns:repeat(5,1fr); padding:7px; z-index:20; }
.nav-btn { border:0; background:transparent; color:#8b919b; border-radius:16px; padding:7px 3px; }
.nav-btn span { display:block; font-size:17px; line-height:1.2; font-weight:900; }
.nav-btn small { display:block; font-size:10px; margin-top:3px; font-weight:800; }
.nav-btn.active { background:var(--accent-soft); color:var(--accent); }
.empty-state { padding:34px 22px; text-align:center; color:var(--muted); }
.empty-state strong { color:var(--text); display:block; margin-bottom:6px; }
.result-card { text-align:center; padding:28px; }
.result-score { font-size:62px; font-weight:950; color:var(--accent); margin:18px 0 5px; }
.result-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:20px 0; }
.result-cell { background:#f7f7fa; border-radius:14px; padding:12px 8px; }
.result-cell strong { display:block; font-size:18px; }
.result-cell span { display:block; color:var(--muted); font-size:10px; margin-top:3px; }
@media (max-width:520px) {
  .app-shell { padding-inline:13px; }
  .word, .test-word { font-size:40px; }
  .hero-card { padding:20px; }
  .action-grid { grid-template-columns:1fr; }
  .action-card { display:grid; grid-template-columns:34px 1fr; column-gap:9px; align-items:center; }
  .action-card .icon { margin:0; grid-row:1 / span 2; }
  .action-card small { margin-top:1px; }
  .forms-grid { grid-template-columns:1fr; }
}

/* v2 additions */
button:disabled { cursor:not-allowed; opacity:.48; }
.compact { padding:9px 12px; border-radius:12px; white-space:nowrap; }
.audio-notice, .settings-note {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  margin:0 0 12px; padding:12px 14px; border:1px solid #d9d7ff;
  border-radius:16px; background:#f2f1ff; color:#4c46b8; font-size:12px; font-weight:700;
}
.settings-note { display:block; line-height:1.5; }

.learn-card { padding-left:64px; padding-right:64px; }
.edge-nav {
  position:absolute; top:50%; transform:translateY(-50%); z-index:5;
  width:48px; height:48px; padding:0; border-radius:50%; border:1px solid var(--line);
  display:grid; place-items:center; background:#fff; color:var(--accent);
  box-shadow:0 8px 22px rgba(32,37,48,.12); font-size:35px; font-weight:500; line-height:1;
  -webkit-tap-highlight-color:transparent;
}
.edge-nav.prev { left:11px; }
.edge-nav.next { right:11px; }
.edge-nav:active { transform:translateY(-50%) scale(.94); }
.word-button, .test-word-button {
  display:inline-block; border:0; background:transparent; color:inherit; padding:0;
  -webkit-tap-highlight-color:transparent;
}
.word-button { font-family:inherit; }
.inline-audio { border:0; background:transparent; padding:2px 4px; cursor:pointer; }
.muted-tag { background:#f2f3f6 !important; color:var(--muted) !important; }
.knowledge-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:20px; }
.knowledge-actions button { border-radius:15px; padding:13px 14px; font-weight:850; border:0; }
.dont-know-btn { background:var(--danger-soft); color:#b5383e; }
.dont-know-btn.pressed { background:#ffdede; box-shadow:inset 0 0 0 1px #f1a4a7; }
#knowWord.pressed { background:#dcd9ff; }

.test-word-button { width:auto; max-width:100%; text-align:center; }
.test-word-button.static { cursor:default; }
.test-word-button.speak { cursor:pointer; }

.small-copy { font-size:12px; margin-top:3px; }
.priority-grid { margin-bottom:6px; }
.list-panels { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.list-card { padding:16px; min-width:0; }
.list-card-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.list-card-head strong { display:block; font-size:16px; }
.list-card-head small { display:block; color:var(--muted); margin-top:3px; font-size:11px; }
.list-add-row { display:grid; grid-template-columns:1fr auto; gap:8px; }
.word-list-input {
  width:100%; min-width:0; border:1px solid var(--line); border-radius:13px; background:#fff;
  padding:11px 12px; outline:none;
}
.word-list-input:focus { border-color:#aaa5ff; box-shadow:0 0 0 3px rgba(91,84,232,.08); }
.list-message { min-height:17px; font-size:11px; color:var(--muted); margin:5px 2px 2px; }
.error-text { color:var(--danger); }
.editable-word-list { max-height:360px; overflow:auto; border-top:1px solid var(--line); margin-top:7px; }
.editable-word-row { display:flex; align-items:center; gap:8px; padding:10px 0; border-bottom:1px solid var(--line); }
.editable-word-row:last-child { border-bottom:0; }
.list-word-main { flex:1; min-width:0; text-align:left; border:0; background:transparent; padding:0; }
.list-word-main strong { display:block; font-size:15px; }
.list-word-main small { display:block; color:var(--muted); margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.remove-list-word {
  flex:0 0 auto; width:34px; height:34px; border:0; border-radius:50%;
  background:#f3f4f6; color:#7d8490; font-size:21px; line-height:1;
}
.remove-list-word:hover { background:var(--danger-soft); color:var(--danger); }
.list-empty { color:var(--muted); font-size:12px; padding:15px 0 6px; text-align:center; }

@media (max-width:620px) {
  .list-panels { grid-template-columns:1fr; }
}

@media (max-width:520px) {
  .learn-card { padding-left:52px; padding-right:52px; }
  .edge-nav { width:42px; height:42px; font-size:31px; }
  .edge-nav.prev { left:7px; }
  .edge-nav.next { right:7px; }
  .word-wrap { padding-left:0; padding-right:0; }
  .knowledge-actions { gap:8px; }
  .knowledge-actions button { padding:12px 8px; font-size:13px; }
  .audio-notice { align-items:flex-start; flex-direction:column; }
  .audio-notice .compact { width:100%; }
}
@supports (padding: max(0px)) {
  .bottom-nav { bottom:max(12px, env(safe-area-inset-bottom)); }
  .app-shell { padding-bottom:max(104px, calc(92px + env(safe-area-inset-bottom))); }
}

/* v3 audio & voice settings */
.settings-section-title {
  margin:18px 4px 8px;
  color:var(--muted);
  font-size:12px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.setting-row-stack { align-items:stretch; flex-direction:column; gap:10px; }
.setting-row-stack > div:first-child { width:100%; }
.wide-control { width:100%; min-height:44px; }
.range-setting input[type="range"] { width:100%; accent-color:var(--accent); }
.range-label { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; width:100%; }
.range-value {
  flex:0 0 auto;
  min-width:46px;
  padding:5px 8px;
  border-radius:999px;
  background:var(--accent-soft);
  color:var(--accent);
  font-size:12px;
  font-weight:800;
  text-align:center;
}
.voice-preview-row {
  display:flex;
  align-items:center;
  gap:12px;
  padding:16px 2px 8px;
}
.voice-test-btn { white-space:nowrap; }
.voice-preview-text { color:var(--muted); font-size:13px; line-height:1.4; }
@media (max-width:520px) {
  .voice-preview-row { align-items:stretch; flex-direction:column; }
  .voice-test-btn { width:100%; }
}
\n\n/* v4 source-priority difficult words */\n.stat-note { color:var(--accent); font-size:11px; font-weight:800; margin-top:3px; }\n.slide-meta-right { display:flex; align-items:center; gap:9px; }\n.priority-flag, .priority-test-label {\n  display:inline-flex; align-items:center; gap:5px; border-radius:999px;\n  background:#eee8ff; color:#6d3fd1; font-size:10px; font-weight:900;\n  letter-spacing:.02em; padding:6px 9px;\n}\n.priority-test-label { margin:9px auto 0; width:max-content; max-width:100%; }\n.badge.priority { background:#eee8ff; color:#6d3fd1; box-shadow:inset 0 0 0 1px #d9ccff; }\n@media (max-width:520px) {\n  .slide-meta-right { gap:6px; }\n  .priority-flag { font-size:9px; padding:5px 7px; }\n}\n