/* ---------- tokens ---------- */
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f3eee4;
  --bg-deep: #ece3d5;
  --surface: #fffdf8;
  --surface-2: #faf5ec;
  --ink: #1e1c18;
  --ink-soft: #3d3932;
  --muted: #756d61;
  --line: #ded3c2;
  --line-strong: #c9bba6;
  --accent: #1f6b58;
  --accent-strong: #155142;
  --accent-soft: #dcebe4;
  --warm: #c8663b;
  --warm-soft: #f6e3d8;
  --danger: #b34736;
  --danger-soft: #f6dfda;
  --amber: #a87321;
  --amber-soft: #f7ecd4;
  --blue: #3d6688;
  --blue-soft: #e1ebf2;
  --shadow: 0 24px 70px rgba(74, 58, 36, 0.10);
  --shadow-soft: 0 10px 30px rgba(74, 58, 36, 0.07);
  --radius: 24px;
  --radius-sm: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171714;
  --bg-deep: #11110f;
  --surface: #211f1a;
  --surface-2: #292620;
  --ink: #f4efe4;
  --ink-soft: #d8d1c3;
  --muted: #a49b8b;
  --line: #3a352c;
  --line-strong: #514a3e;
  --accent: #78c3a8;
  --accent-strong: #9ad8c1;
  --accent-soft: #233a32;
  --warm: #e2956b;
  --warm-soft: #3b2a20;
  --danger: #e18b7a;
  --danger-soft: #3a2420;
  --amber: #d9b36f;
  --amber-soft: #38301f;
  --blue: #8eb6d2;
  --blue-soft: #22313c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.24);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(200, 102, 59, 0.08), transparent 34rem),
    radial-gradient(circle at 88% 10%, rgba(31, 107, 88, 0.09), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.25;
  background-image: radial-gradient(rgba(30, 28, 24, 0.13) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  z-index: -1;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--surface); }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.view { width: min(1120px, calc(100% - 40px)); margin: 0 auto; flex: 1; padding: 18px 0 72px; }

/* ---------- topbar ---------- */
.topbar {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 4px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
  box-shadow: 4px 4px 0 var(--warm);
  transform: translate(-2px, -2px);
}
.brand-text {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.08em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.brand-sub {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}
.nav-link {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.nav-link:hover { color: var(--ink); background: var(--surface-2); }
.nav-link.is-active { color: var(--surface); background: var(--accent); }
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  position: relative;
  transition: transform 160ms ease, border-color 160ms ease;
}
.icon-btn:hover { transform: rotate(-8deg); border-color: var(--accent); }
.icon-sun, .icon-moon { position: absolute; width: 18px; height: 18px; border-radius: 50%; transition: opacity 160ms ease, transform 160ms ease; }
.icon-sun { background: var(--warm); box-shadow: 0 0 0 4px var(--warm-soft); }
.icon-moon { background: var(--blue); transform: translate(4px, -3px); box-shadow: -4px 3px 0 0 var(--surface); opacity: 0; }
[data-theme="dark"] .icon-sun { opacity: 0; transform: scale(0.5); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: translate(0, 0); box-shadow: -3px 2px 0 0 var(--surface); }

/* ---------- typography ---------- */
h1, h2, h3, p { margin: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--warm);
}
.page-head { margin: 26px 0 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-title {
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.page-sub { color: var(--muted); max-width: 58ch; margin-top: 10px; }
.section-title { font-family: var(--serif); font-size: 23px; line-height: 1.2; letter-spacing: -0.01em; }
.section-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); color: var(--surface); box-shadow: 0 8px 0 var(--accent-strong); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 6px 0 var(--accent-strong); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-warm { background: var(--warm); color: #fff; box-shadow: 0 8px 0 #8f4426; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 15px 26px; font-size: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-arrow { font-size: 18px; line-height: 1; }
.btn-text { border: 0; background: transparent; color: var(--accent); font-weight: 700; padding: 4px; }
.btn-text:hover { text-decoration: underline; }
kbd {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 1px 5px;
  opacity: 0.65;
  line-height: 1.4;
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(190px, 0.65fr);
  gap: 28px;
  align-items: center;
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--surface) 94%, var(--warm) 6%), var(--surface) 58%),
    var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after {
  content: "Aa";
  position: absolute;
  right: 22%;
  bottom: -34px;
  font-family: var(--serif);
  font-size: 210px;
  line-height: 1;
  color: color-mix(in srgb, var(--accent) 7%, transparent);
  pointer-events: none;
  letter-spacing: -0.08em;
}
.hero-copy { position: relative; z-index: 1; }
.hero-title {
  font-family: var(--serif);
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.05em;
  margin: 14px 0 18px;
  max-width: 12ch;
}
.hero-title em { font-style: normal; color: var(--accent); position: relative; white-space: nowrap; }
.hero-title em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.04em;
  height: 0.12em;
  border-radius: 99px;
  background: var(--warm);
  opacity: 0.55;
  z-index: -1;
}
.hero-sub { color: var(--muted); max-width: 46ch; margin-bottom: 26px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-ring {
  --progress: 0;
  position: relative;
  z-index: 1;
  width: min(190px, 100%);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--line) 0);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent);
}
.hero-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.hero-ring-inner { position: relative; text-align: center; }
.ring-value { font-family: var(--serif); font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.ring-label { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 6px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat {
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  box-shadow: var(--shadow-soft);
}
.stat-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.stat-value { font-family: var(--serif); font-size: 32px; line-height: 1.2; letter-spacing: -0.03em; margin-top: 4px; }
.stat-value small { font-family: var(--sans); font-size: 12px; color: var(--muted); letter-spacing: 0; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- panels / queue ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 24px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.queue-list { display: grid; gap: 2px; }
.queue-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
}
.queue-row:first-child { border-top: 0; }
.queue-term { min-width: 0; }
.queue-term strong { display: block; font-family: var(--serif); font-size: 18px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; }
.queue-term span { display: block; color: var(--muted); font-size: 12px; }
.queue-meaning { color: var(--ink-soft); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-more { color: var(--muted); font-size: 13px; padding-top: 10px; }
.empty-queue { text-align: center; padding: 28px 12px; }
.empty-queue .empty-mark { font-family: var(--serif); font-size: 52px; color: var(--accent); line-height: 1; }
.empty-queue p { color: var(--muted); margin-top: 8px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-new { background: var(--warm-soft); color: var(--warm); }
.badge-review { background: var(--accent-soft); color: var(--accent); }
.badge-learning { background: var(--blue-soft); color: var(--blue); }
.badge-mastered { background: var(--amber-soft); color: var(--amber); }
.badge-quiet { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- empty state ---------- */
.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 32px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  padding: clamp(34px, 7vw, 80px) 28px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.empty-glyph {
  font-family: var(--serif);
  font-size: clamp(72px, 12vw, 120px);
  line-height: 0.9;
  color: var(--accent);
  letter-spacing: -0.08em;
}
.empty-state h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 48px); line-height: 1.1; margin: 20px 0 10px; letter-spacing: -0.03em; }
.empty-state p { color: var(--muted); max-width: 48ch; margin: 0 auto 24px; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.empty-note { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* ---------- feature cards ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.feature { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-soft); }
.feature-number { font-family: var(--serif); color: var(--warm); font-size: 14px; font-weight: 700; }
.feature h3 { font-family: var(--serif); font-size: 20px; margin: 8px 0 4px; }
.feature p { color: var(--muted); font-size: 13px; line-height: 1.55; }

/* ---------- review ---------- */
.review-shell { max-width: 780px; margin: 28px auto 0; }
.review-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.progress-track { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 240ms ease; }
.review-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 58px; text-align: right; }
.flashcard {
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, var(--accent) 8%), var(--surface) 40%);
  box-shadow: var(--shadow);
  padding: clamp(26px, 5vw, 46px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
  animation: card-in 260ms ease both;
}
.flashcard::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 44px;
  opacity: 0.22;
  pointer-events: none;
}
.flashcard > * { position: relative; z-index: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 34px; }
.stage-dots { display: inline-flex; gap: 5px; }
.stage-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.stage-dot.is-on { background: var(--accent); }
.term { font-family: var(--serif); font-size: clamp(44px, 9vw, 82px); line-height: 1; letter-spacing: -0.045em; word-break: break-word; }
.phonetic-row { display: flex; align-items: center; gap: 12px; min-height: 34px; margin-top: 10px; }
.phonetic { color: var(--muted); font-size: 17px; letter-spacing: 0.02em; }
.speak-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; font-size: 15px;
  transition: transform 160ms ease, border-color 160ms ease;
}
.speak-btn:hover { transform: scale(1.08); border-color: var(--accent); }
.answer { display: none; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.answer.is-visible { display: block; animation: answer-in 220ms ease both; }
.meaning { font-size: clamp(20px, 3vw, 27px); font-weight: 700; line-height: 1.45; color: var(--ink); }
.example { margin-top: 14px; font-family: var(--serif); font-size: 17px; color: var(--ink-soft); font-style: italic; }
.translation { margin-top: 2px; color: var(--muted); font-size: 14px; }
.btn-reveal { margin-top: 32px; align-self: flex-start; }
.btn-reveal.is-hidden { display: none; }
.grades { display: none; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 28px; }
.grades.is-visible { display: grid; animation: answer-in 220ms ease both; }
.grade {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.grade:hover { transform: translateY(-2px); }
.grade kbd { opacity: 0.45; }
.grade-again:hover { border-color: var(--danger); background: var(--danger-soft); }
.grade-hard:hover { border-color: var(--amber); background: var(--amber-soft); }
.grade-good:hover { border-color: var(--accent); background: var(--accent-soft); }
.grade-easy:hover { border-color: var(--blue); background: var(--blue-soft); }
.review-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ---------- review summary ---------- */
.summary-card {
  max-width: 700px; margin: 46px auto 0; text-align: center;
  border: 1px solid var(--line); border-radius: 32px; background: var(--surface);
  box-shadow: var(--shadow); padding: clamp(32px, 6vw, 64px);
}
.summary-glyph { font-family: var(--serif); font-size: 64px; line-height: 1; color: var(--accent); }
.summary-card h1 { font-family: var(--serif); font-size: clamp(34px, 6vw, 54px); line-height: 1.08; letter-spacing: -0.04em; margin: 14px 0 8px; }
.summary-card > p { color: var(--muted); }
.summary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.summary-stat { padding: 16px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.summary-stat strong { display: block; font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.summary-stat span { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.summary-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }

/* ---------- quiz ---------- */
.quiz-shell { max-width: 780px; margin: 28px auto 0; }
.quiz-card {
  border: 1px solid var(--line); border-radius: 32px; background: var(--surface);
  box-shadow: var(--shadow); padding: clamp(26px, 5vw, 46px);
}
.quiz-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.quiz-word { font-family: var(--serif); font-size: clamp(38px, 7vw, 64px); line-height: 1.05; letter-spacing: -0.04em; margin: 24px 0 6px; }
.quiz-options { display: grid; gap: 10px; margin-top: 28px; }
.quiz-option {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  line-height: 1.45;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.quiz-option:hover:not(:disabled) { transform: translateX(3px); border-color: var(--accent); }
.quiz-option:disabled { cursor: default; }
.quiz-option.is-correct { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.option-key {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line-strong); font-size: 12px; font-weight: 700; color: var(--muted);
}
.quiz-option.is-correct .option-key { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.quiz-option.is-wrong .option-key { background: var(--danger); border-color: var(--danger); color: #fff; }
.quiz-feedback { margin-top: 18px; min-height: 26px; font-weight: 700; font-size: 14px; }
.quiz-feedback.is-correct { color: var(--accent); }
.quiz-feedback.is-wrong { color: var(--danger); }

/* ---------- library ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1 1 240px; }
.search-wrap input { width: 100%; padding-left: 38px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.input, .select, .textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { min-width: 130px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-soft); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-weight: 800; padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 32%, transparent); }
.word-cell strong { display: block; font-family: var(--serif); font-size: 18px; line-height: 1.25; }
.word-cell span { color: var(--muted); font-size: 12px; }
.meaning-cell { max-width: 300px; color: var(--ink-soft); }
.actions-cell { text-align: right; white-space: nowrap; }
.actions-cell .btn { margin-left: 4px; }
.table-empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.table-count { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ---------- import ---------- */
.import-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 18px; align-items: start; }
.textarea { width: 100%; min-height: 240px; resize: vertical; line-height: 1.7; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.import-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.checkbox input { accent-color: var(--accent); }
.format-help { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.format-help h3 { font-size: 13px; margin-bottom: 8px; }
.code-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.code-list code {
  display: block; padding: 7px 10px; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--line); font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.preview-count { font-family: var(--serif); font-size: 34px; line-height: 1; }
.preview-sub { color: var(--muted); font-size: 12px; }
.preview-list { display: grid; gap: 2px; max-height: 280px; overflow: auto; margin: 12px 0; }
.preview-row { padding: 9px 0; border-top: 1px solid var(--line); }
.preview-row:first-child { border-top: 0; }
.preview-term { font-family: var(--serif); font-weight: 700; }
.preview-meaning { color: var(--muted); font-size: 13px; }
.error-list { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.error-list li { color: var(--danger); font-size: 12px; }
.preview-empty { color: var(--muted); font-size: 13px; padding: 28px 0; text-align: center; }
.import-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-group h2 { font-family: var(--serif); font-size: 24px; margin-bottom: 4px; }
.settings-group > p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; padding-top: 0; }
.setting-label strong { display: block; font-size: 14px; }
.setting-label span { display: block; color: var(--muted); font-size: 12px; }
.number-input { width: 92px; text-align: center; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.storage-note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.storage-note.is-warning { color: var(--danger); }
.about-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.about-list strong { color: var(--ink); }

/* ---------- modal ---------- */
.modal {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(560px, calc(100% - 32px));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(22, 20, 16, 0.48); backdrop-filter: blur(3px); }
.modal-inner { padding: 26px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-title { font-family: var(--serif); font-size: 27px; line-height: 1.2; }
.modal-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-close { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; font-size: 18px; color: var(--muted); }
.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field .input, .field .textarea { width: 100%; }
.field .textarea { min-height: 74px; font-family: var(--sans); font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-message { color: var(--muted); line-height: 1.65; }
.confirm-message strong { color: var(--ink); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: var(--ink); color: var(--surface);
  padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease; z-index: 50;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */
.footer {
  width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 30px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 11px;
  display: flex; gap: 8px; flex-wrap: wrap; letter-spacing: 0.04em;
}
.footer-dot { opacity: 0.5; }
.noscript { padding: 20px; background: var(--danger-soft); color: var(--danger); text-align: center; }

/* ---------- animations ---------- */
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.995); } to { opacity: 1; transform: none; } }
@keyframes answer-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-ring { width: 150px; margin: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .feature-grid { grid-template-columns: 1fr; }
  .import-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .queue-row { grid-template-columns: minmax(120px, 1fr) minmax(0, 1.4fr) auto; }
}
@media (max-width: 680px) {
  .topbar { min-height: 72px; gap: 10px; flex-wrap: wrap; padding: 10px 0; }
  .brand-text { font-size: 19px; }
  .brand-sub { display: none; }
  .nav { order: 3; width: 100%; justify-content: space-between; }
  .nav-link { flex: 1; padding: 8px 6px; }
  .view { width: calc(100% - 28px); padding-top: 8px; }
  .hero { padding: 24px; border-radius: 24px; }
  .hero-title { font-size: clamp(38px, 12vw, 58px); }
  .hero::after { font-size: 140px; right: 8%; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 27px; }
  .panel { padding: 18px; }
  .queue-row { grid-template-columns: 1fr auto; gap: 8px; }
  .queue-meaning { grid-column: 1 / -1; grid-row: 2; }
  .flashcard { min-height: 400px; border-radius: 24px; padding: 24px; }
  .card-top { margin-bottom: 26px; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .summary-stats { grid-template-columns: 1fr; }
  .page-head { margin-top: 14px; }
  .footer { width: calc(100% - 28px); }
  .table-wrap { border-radius: 18px; }
  thead { display: none; }
  tbody tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  tbody td { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border: 0; text-align: right; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; flex: none; }
  tbody td.word-cell { display: block; text-align: left; }
  tbody td.word-cell::before { display: none; }
  tbody td.actions-cell { justify-content: flex-end; }
  .meaning-cell { max-width: none; }
}

/* ---------- sync ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.sync-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.sync-pill:hover { border-color: var(--accent); color: var(--ink); }
.sync-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
.sync-pill[data-state="synced"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.sync-pill[data-state="syncing"],
.sync-pill[data-state="connecting"],
.sync-pill[data-state="auth"] { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.sync-pill[data-state="offline"],
.sync-pill[data-state="error"] { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.sync-pill[data-state="syncing"] .sync-dot,
.sync-pill[data-state="connecting"] .sync-dot { animation: sync-pulse 1s ease-in-out infinite; }

@keyframes sync-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1.15); }
}

.sync-state-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 10px 0 2px; font-size: 12px; color: var(--muted);
}
.sync-state-line .sync-dot { background: var(--accent); }
.sync-state-line strong { color: var(--ink); font-size: 13px; }
.sync-url-box {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0; padding: 10px 12px;
  border: 1px dashed var(--line-strong); border-radius: 12px;
  background: var(--surface-2); min-width: 0;
}
.sync-url-box code {
  flex: 1; min-width: 0; overflow: auto; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px; color: var(--ink);
}
.sync-group .data-actions { margin-top: 12px; }
.sync-group .storage-note { line-height: 1.6; }
.sync-key-box {
  margin: 12px 0 4px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.sync-key-label {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; color: var(--ink);
}
.sync-key-row { display: flex; align-items: center; gap: 8px; }
.sync-key-row .input { flex: 1; min-width: 0; }
.sync-key-box .storage-note { margin-top: 6px; }

@media (max-width: 520px) {
  .sync-key-row { flex-direction: column; align-items: stretch; }
  .sync-key-row .btn { width: 100%; }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 64px; flex-wrap: nowrap; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 0 8px;
  }
  .brand { gap: 8px; padding: 2px; }
  .brand-mark { width: 36px; height: 36px; font-size: 20px; border-radius: 10px; box-shadow: 3px 3px 0 var(--warm); }
  .brand-text { font-size: 19px; }
  .brand-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .sync-pill { height: 34px; padding: 0 10px; font-size: 11px; }
  .icon-btn { width: 36px; height: 36px; }

  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    width: 100%; order: initial; gap: 2px; justify-content: space-between;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    box-shadow: 0 -8px 30px rgba(74, 58, 36, 0.12);
  }
  .nav-link { flex: 1; min-height: 46px; padding: 8px 4px; border-radius: 12px; font-size: 12px; }
  .nav-link.is-active { color: var(--surface); background: var(--accent); }

  .view { width: calc(100% - 24px); padding-top: 6px; padding-bottom: 96px; }
  .footer { width: calc(100% - 24px); padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }

  input, select, textarea, .input, .textarea { font-size: 16px; }
  .field .textarea { font-size: 16px; }

  .flashcard {
    min-height: 400px;
    min-height: clamp(360px, calc(100dvh - 210px), 470px);
    border-radius: 24px; padding: 22px 20px;
  }
  .term { font-size: clamp(38px, 14vw, 64px); }
  .card-top { margin-bottom: 22px; }

  .modal {
    position: fixed; inset: auto 0 0 0; margin: 0;
    width: 100%; max-width: none; max-height: 90dvh;
    border-radius: 20px 20px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    overflow-y: auto;
  }
  .modal-inner { padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; min-width: 118px; }
  .sync-url-box { padding: 9px 10px; }
  .sync-url-box code { font-size: 11px; }
  .page-title { font-size: clamp(32px, 10vw, 44px); }
  .hero { padding: 22px 18px; }
  .data-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 380px) {
  .sync-pill { width: 34px; padding: 0; }
  .sync-pill .sync-label { display: none; }
}

