:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e3e6ee;
  --primary: #3b5bdb;
  --primary-soft: #e8edff;
  --ok: #2b8a3e;
  --ok-soft: #e6f6ea;
  --half: #c77700;
  --half-soft: #fff4de;
  --bad: #d6336c;
  --bad-soft: #ffe8ef;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --card: #1e2129;
    --text: #e8eaf0;
    --muted: #9aa1ad;
    --line: #2e323d;
    --primary: #7b93ff;
    --primary-soft: #262d4a;
    --ok: #63c77b;
    --ok-soft: #1d3324;
    --half: #f0b040;
    --half-soft: #3a2e17;
    --bad: #ff7aa2;
    --bad-soft: #3c1f2a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
.container { max-width: 860px; margin: 0 auto; padding: 16px 16px 64px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; gap: 14px; }
.topbar nav a { font-weight: 600; }

h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { justify-content: center; text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 130px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.4rem; font-weight: 800; color: var(--text);
}
.tile .emoji { font-size: 2.2rem; }
.tile small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.tile.disabled { opacity: .55; }
a.tile:hover { border-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--half); border-color: var(--half); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 54px; padding: 10px 26px; font-size: 1.1rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.icon { border: none; background: none; font-size: 1.3rem; cursor: pointer; padding: 4px 6px; }

.round-title { font-size: 1.15rem; font-weight: 800; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 16px; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-weight: 600;
}
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }

form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
input, select {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.answer { width: 100%; font-size: 1.35rem; padding: 14px; margin-top: 16px; text-align: center; }

.flash { text-align: center; padding: 24px 16px; }
.flash-meta { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.flash-word { font-size: 2.3rem; font-weight: 800; word-break: break-word; }
.flash-ko { font-size: 1.7rem; font-weight: 800; }
.flash-back { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }
.meaning { font-size: 1.35rem; font-weight: 700; }
.def { color: var(--muted); font-style: italic; margin-top: 6px; }
.ex { margin-top: 10px; font-size: 1.05rem; }
.ex-ko { color: var(--muted); font-size: .95rem; }
mark { background: var(--half-soft); color: inherit; padding: 0 2px; border-radius: 4px; font-weight: 700; }
.blank { display: inline-block; min-width: 70px; border-bottom: 2px solid var(--text); }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; flex: 1; }
.progress > div { height: 100%; background: var(--primary); }
.test-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-weight: 700; }
.q-dir { color: var(--muted); font-weight: 600; }
.q-prompt { font-size: 2rem; font-weight: 800; margin-top: 8px; word-break: keep-all; }
.q-prompt.ko2en { font-size: 1.6rem; }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.qnav button {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.qnav button.filled { background: var(--primary-soft); border-color: var(--primary); }
.qnav button.cur { outline: 2px solid var(--primary); }

.feedback { min-height: 32px; margin-top: 12px; font-weight: 700; }
.feedback.good { color: var(--ok); }
.feedback.bad { color: var(--bad); }

.score-box { text-align: center; }
.score { font-size: 3rem; font-weight: 900; }
.score small { font-size: 1.3rem; color: var(--muted); }
.res { border-left: 6px solid var(--line); }
.res.correct { border-left-color: var(--ok); }
.res.half { border-left-color: var(--half); background: var(--half-soft); }
.res.wrong { border-left-color: var(--bad); background: var(--bad-soft); }
.res-head { display: flex; gap: 8px; align-items: center; font-size: .88rem; color: var(--muted); }
.res-label { margin-left: auto; font-weight: 800; }
.res.correct .res-label { color: var(--ok); }
.res.half .res-label { color: var(--half); }
.res.wrong .res-label { color: var(--bad); }
.res-q { font-size: 1.2rem; font-weight: 700; margin: 4px 0; }
.res-correct { margin-top: 6px; font-weight: 700; }
.note { margin-top: 6px; font-size: .9rem; color: var(--half); font-weight: 600; }
details.override { margin-top: 8px; font-size: .85rem; color: var(--muted); }
details.override button { margin: 6px 4px 0 0; }

.wl-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.wl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wl-head .no { color: var(--muted); font-size: .85rem; min-width: 28px; }
.wl-head b { font-size: 1.15rem; }
.hidden-cell { filter: blur(6px); cursor: pointer; user-select: none; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--half-soft); color: var(--half); font-weight: 700; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

.tag.ok { background: var(--ok-soft); color: var(--ok); }
.auth-card { max-width: 420px; margin: 32px auto; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .btn { width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600;
  max-width: calc(100% - 32px);
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .flash-word { font-size: 1.9rem; }
  .q-prompt { font-size: 1.6rem; }
  .q-prompt.ko2en { font-size: 1.3rem; }
}
