:root {
  --bg: #ffffff;
  --surface: #f6f5fb;
  --border: #e3e0ef;
  --text: #1d1b2e;
  --muted: #6b6787;
  --accent: #6d4aff;
  --accent-ink: #ffffff;
  --danger: #c62f4b;
  --ok: #1f8a5b;
  --learn: #c2410c;
  --review: #1f8a5b;
  --new: #2563eb;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151f;
    --surface: #211e2c;
    --border: #34304a;
    --text: #f1effa;
    --muted: #a19cc0;
    --accent: #9b85ff;
    --accent-ink: #120f1c;
    --danger: #ff7189;
    --ok: #58d39c;
    --learn: #fb923c;
    --review: #58d39c;
    --new: #7aa7ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; }
h1, h2 { margin: 0 0 8px; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
p { margin: 0 0 10px; }
.ko { font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
a { color: var(--accent); }
code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
kbd { font: 11px system-ui; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: 0.6; margin-left: 6px; }

button, .button-like {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-block;
}
button:hover, .button-like:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.big { padding: 12px 22px; font-size: 16px; font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 4px 6px; }
button:disabled { opacity: 0.5; cursor: default; }
select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; max-width: 100%;
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); }
.account { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

main { max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.narrow { max-width: 560px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.hero { max-width: 620px; margin: 40px auto; text-align: center; }
.hero h1 { font-size: 32px; line-height: 1.2; margin-bottom: 14px; }
.lead { font-size: 17px; color: var(--muted); margin-bottom: 24px; }
.fine { margin-top: 18px; }

.banner {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px;
}

.steps { padding-left: 20px; margin: 12px 0 18px; }
.steps li { margin-bottom: 6px; }
.drop {
  display: grid; place-items: center; min-height: 120px; padding: 16px; text-align: center;
  border: 2px dashed var(--border); border-radius: 14px; cursor: pointer; background: var(--bg);
}
.drop.over, .drop:hover { border-color: var(--accent); }

.study-card { text-align: center; }
.counts { display: flex; justify-content: center; gap: 36px; margin-bottom: 18px; }
.counts div { display: flex; flex-direction: column; }
.num { font-size: 30px; font-weight: 700; }
.num.learn { color: var(--learn); }
.num.review { color: var(--review); }
.num.new { color: var(--new); }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.lookups { list-style: none; padding: 0; margin: 0; }
.lookups li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.lookups li:last-child { border-bottom: none; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 12px; }

.type { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 10px 0; display: grid; gap: 8px; grid-template-columns: 1fr 1fr; background: var(--bg); }
.type-name { grid-column: 1 / -1; }
.type label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.study-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.flash {
  min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 20px; text-align: center;
}
.flash.is-new { border-color: var(--new); }
.say { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.say svg { width: 22px; height: 22px; }
.sound { color: var(--muted); font-size: 16px; margin-top: -8px; }
.sound .ko { color: var(--text); }
.front { font-size: 56px; font-weight: 600; line-height: 1.2; word-break: keep-all; }
.back { font-size: 22px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 18px; width: 100%; max-width: 480px; }
.answer-bar { display: flex; justify-content: center; margin-top: 18px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; max-width: 560px; }
.rate button { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; font-weight: 600; }
.rate .ivl { font-size: 12px; font-weight: 500; color: var(--muted); }
.rate .again { border-color: var(--danger); }
.rate .good { border-color: var(--ok); }

.status { min-height: 1.5em; margin-top: 12px; }
.status.center { text-align: center; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }

@media (max-width: 520px) {
  .front { font-size: 42px; }
  .counts { gap: 20px; }
  .hero h1 { font-size: 26px; }
  .type { grid-template-columns: 1fr; }
  .brand { white-space: nowrap; }
  .rate kbd, .answer-bar kbd { display: none; }
}

/* Legal pages and footer */
.legal { max-width: 720px; }
.legal h2 { margin-top: 24px; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
a.brand.plain { color: var(--text); text-decoration: none; }
.foot { text-align: center; padding: 24px 16px 32px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); margin: 0 8px; }

/* Pricing */
.pricing-hero { margin-bottom: 24px; }
.period { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.period button { border: none; background: none; padding: 6px 14px; border-radius: 9px; }
.period button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.save { font-size: 12px; font-weight: 600; margin-left: 4px; opacity: 0.9; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 760px; margin: 0 auto; }
.plan { display: flex; flex-direction: column; gap: 10px; position: relative; }
.plan.premium { border: 2px solid var(--accent); }
.badge { position: absolute; top: -12px; right: 16px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.price .amount { font-size: 34px; font-weight: 700; }
.features { padding-left: 20px; margin: 4px 0 8px; flex: 1; }
.features li { margin-bottom: 6px; }
.button-like.full { text-align: center; text-decoration: none; }
.button-like.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button-like.disabled { opacity: 0.55; cursor: default; }
.center { text-align: center; }
.faq { max-width: 620px; margin: 36px auto 0; }

/* ---------- Navigation ---------- */
.nav { display: flex; align-items: center; gap: 4px; }
.nav .sync { margin-right: 8px; }
.nav-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid transparent; color: var(--muted); padding: 6px 12px; border-radius: 9px; }
.nav-btn:hover { color: var(--text); border-color: var(--border); }
.nav-btn[aria-current] { color: var(--text); background: var(--surface); border-color: var(--border); font-weight: 600; }

/* ---------- Home ---------- */
.today { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px; }
.today h1 { font-size: 26px; margin-bottom: 4px; }
.today p { margin-bottom: 12px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 6px !important; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.pill b { font-weight: 700; }
.pill.learn b { color: var(--learn); }
.pill.review b { color: var(--review); }
.pill.new b { color: var(--new); }
.today .big { flex-shrink: 0; min-width: 160px; }

.checklist { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.check li { display: flex; gap: 12px; align-items: flex-start; }
.check li div { display: flex; flex-direction: column; gap: 2px; }
.tick { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); margin-top: 1px; display: grid; place-items: center; }
.check li.done .tick { background: var(--ok); border-color: var(--ok); }
.check li.done .tick::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.check li.done b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; }
.stat b { font-size: 24px; font-weight: 700; }
.stat span { font-size: 13px; color: var(--muted); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.actions { display: grid; gap: 8px; margin-top: 4px; }
.action { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); text-decoration: none; cursor: pointer; font: inherit; }
.action:hover { border-color: var(--accent); }

/* ---------- Settings ---------- */
.settings { max-width: 680px; margin: 0 auto; }
.settings-head { margin-bottom: 16px; }
.group { margin-bottom: 16px; padding: 4px 20px 12px; }
.group h2 { margin: 16px 0 4px; }
.group-note { margin: 0 0 4px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); }
.group h2 + .field, .group-note + .field { border-top: none; }
.field > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field small { color: var(--muted); font-size: 13px; }
.field.column { flex-direction: column; align-items: stretch; }
.field input[type="number"] { width: 90px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; text-align: right; }
.field select { flex-shrink: 0; }
.value { color: var(--muted); overflow-wrap: anywhere; text-align: right; }
.seg { display: inline-flex; flex-shrink: 0; padding: 3px; gap: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.seg button { border: none; background: none; padding: 6px 12px; border-radius: 7px; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.seg button small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button[aria-checked="true"] small { color: inherit; opacity: 0.85; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.export-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.export-actions button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; }
.export-actions small { color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .export-actions { grid-template-columns: 1fr; } }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); }
a.button-like { text-decoration: none; flex-shrink: 0; }

@media (max-width: 640px) {
  .today { flex-direction: column; align-items: stretch; text-align: left; }
  .today .big { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .field { flex-direction: column; align-items: stretch; gap: 8px; }
  .field input[type="number"] { width: 100%; text-align: left; }
  .seg { align-self: flex-start; }
  .value { text-align: left; }
  .nav .sync { display: none; }
}
.today h1 { word-break: keep-all; }

/* Words looked up (settings) */
.look-table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 14px; }
.look-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border); }
.look-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.look-table tr:last-child td { border-bottom: none; }
.look-table .num { text-align: right; white-space: nowrap; }

/* Decks */
.decks-card { margin-top: 16px; }
.add-deck { color: var(--accent); cursor: pointer; }
.deck-list { list-style: none; padding: 0; margin: 8px 0 0; }
.deck { border-top: 1px solid var(--border); padding: 12px 0; }
.deck:first-child { border-top: none; }
.deck-main { display: flex; align-items: center; gap: 14px; }
.deck-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.deck-title { overflow-wrap: anywhere; }
.deck.paused .deck-title { color: var(--muted); }
.deck-actions { display: flex; gap: 6px; flex-shrink: 0; }
.deck-actions button { padding: 6px 12px; }
button.ghost { background: none; letter-spacing: 1px; }
button.danger { color: var(--danger); border-color: var(--danger); }
.deck-opts { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check-list { display: grid; gap: 2px; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex-shrink: 0; color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 34px; height: 20px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.15s; flex-shrink: 0; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 0.15s; }
.switch-row input:checked + .switch-ui { background: var(--accent); }
.switch-row input:checked + .switch-ui::after { transform: translateX(14px); }
.switch-row input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row input:checked ~ .small { color: var(--text); }
@media (max-width: 640px) {
  .deck-main { flex-wrap: wrap; }
  .deck-text { flex-basis: 100%; }
  .deck-actions { margin-left: auto; }
}
.deck-switches { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
@media (max-width: 640px) { .deck-switches { flex-direction: row; gap: 14px; } }
.with-unit { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.with-unit input[type="number"] { width: 70px; }
@media (max-width: 640px) { .with-unit input[type="number"] { width: 100%; } .with-unit { width: 100%; } }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
@media (max-width: 640px) { .plan-actions { justify-content: flex-start; } }
.plans.three { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); max-width: 1000px; }
.plans.three + .center { margin-top: 14px; }
