:root {
  color-scheme: light;
  --vv-ink: #27231f;
  --vv-muted: #756d65;
  --vv-paper: #f6f0e8;
  --vv-panel: rgba(255, 252, 247, 0.92);
  --vv-line: #e3d8cb;
  --vv-brand: #a64b3c;
  --vv-brand-dark: #7e3028;
  --vv-green: #3d8b5d;
  --vv-green-bg: #e9f5eb;
  --vv-yellow: #b47a13;
  --vv-yellow-bg: #fff4d5;
  --vv-red: #b3413c;
  --vv-red-bg: #fde9e7;
  --vv-shadow: 0 18px 45px rgba(81, 53, 31, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-width: 0; width: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--vv-ink);
  background:
    radial-gradient(circle at top right, rgba(224, 185, 138, 0.23), transparent 34rem),
    var(--vv-paper);
}

button, input { font: inherit; }
button { cursor: pointer; }

.vv-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.vv-kicker {
  margin: 0 0 8px;
  color: var(--vv-brand);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.vv-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.vv-hero h1 {
  max-width: 700px;
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.vv-hero p { margin: 12px 0 0; color: var(--vv-muted); line-height: 1.7; }

.vv-badge {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid #d9b2a8;
  border-radius: 999px;
  color: var(--vv-brand-dark);
  background: #fff9f6;
  font-size: 0.84rem;
  font-weight: 700;
}

.vv-panel {
  min-width: 0;
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--vv-line);
  border-radius: 20px;
  background: var(--vv-panel);
  box-shadow: var(--vv-shadow);
}

.vv-panel h2, .vv-panel h3 { margin: 0; }

.vv-howto summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--vv-brand-dark);
  cursor: pointer;
  font-weight: 800;
}

.vv-howto summary::after { content: "展开 / 收起"; color: var(--vv-muted); font-size: 0.78rem; font-weight: 600; }

.vv-howto ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 28px;
  margin: 16px 0 0;
  padding-left: 1.2em;
  color: var(--vv-muted);
  line-height: 1.7;
}

.vv-toolbar-head, .vv-section-head, .vv-unit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.vv-section-head { margin-bottom: 16px; }
.vv-section-head p, .vv-unit-head p { margin: 5px 0 0; color: var(--vv-muted); font-size: 0.88rem; }

.vv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(100%, 320px);
  padding: 9px 12px;
  border: 1px solid var(--vv-line);
  border-radius: 12px;
  background: #fffefa;
}

.vv-search span { color: var(--vv-muted); }
.vv-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--vv-ink); background: transparent; }

.vv-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.vv-filter, .vv-export-btn, .vv-reset-btn, .vv-modal-btn {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--vv-line);
  border-radius: 10px;
  color: var(--vv-ink);
  background: #fffefa;
  font-size: 0.88rem;
}

.vv-filter[aria-pressed="true"] { border-color: var(--vv-brand); color: #fff; background: var(--vv-brand); }
.vv-filter:focus-visible, .vv-status:focus-visible, .vv-export-btn:focus-visible, .vv-export-scope-btn:focus-visible, .vv-reset-btn:focus-visible, .vv-modal-btn:focus-visible, .vv-topic-card:focus-visible, .vv-topic-nav-btn:focus-visible, .vv-secondary-btn:focus-visible, .vv-primary-btn:focus-visible, .vv-search:focus-within { outline: 3px solid rgba(166, 75, 60, 0.24); outline-offset: 2px; }

.vv-count-note { margin: 14px 0 0; color: var(--vv-muted); font-size: 0.88rem; }

.vv-stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.vv-stat {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid var(--vv-line);
  border-radius: 14px;
  background: #fffefa;
}

.vv-stat strong { display: block; font-size: 1.35rem; line-height: 1.1; }
.vv-stat span { display: block; margin-top: 6px; color: var(--vv-muted); font-size: 0.78rem; }
.vv-stat[data-tone="green"] strong { color: var(--vv-green); }
.vv-stat[data-tone="yellow"] strong { color: var(--vv-yellow); }
.vv-stat[data-tone="red"] strong { color: var(--vv-red); }

.vv-topic-overview-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.vv-topic-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--vv-line);
  border-left: 4px solid transparent;
  border-radius: 14px;
  color: var(--vv-ink);
  background: #fffefa;
  text-align: left;
}

.vv-topic-card:hover { border-color: var(--vv-brand); }
.vv-topic-card[data-current="true"] { border-color: var(--vv-brand); border-left-color: var(--vv-brand); background: rgba(255, 247, 242, 0.72); }
.vv-topic-card-title { font-weight: 800; }
.vv-topic-card-meta, .vv-topic-card-status { color: var(--vv-muted); font-size: 0.82rem; }
.vv-topic-card-status { font-weight: 700; }
.vv-topic-card-status[data-tone="red"] { color: var(--vv-red); }
.vv-topic-card-status[data-tone="yellow"] { color: var(--vv-yellow); }
.vv-topic-card-status[data-tone="green"] { color: var(--vv-green); }

.vv-topic-nav {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(0, 1fr) minmax(130px, auto);
  align-items: center;
  gap: 16px;
}

.vv-current-topic-heading { min-width: 0; text-align: center; }
.vv-current-topic-heading h2 { overflow-wrap: anywhere; }
.vv-current-topic-heading p:last-child { margin: 6px 0 0; color: var(--vv-muted); }

.vv-topic-nav-btn, .vv-secondary-btn, .vv-primary-btn {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--vv-line);
  border-radius: 10px;
  color: var(--vv-ink);
  background: #fffefa;
  font-size: 0.88rem;
}

.vv-topic-nav-btn { white-space: nowrap; }
.vv-topic-nav-btn:hover, .vv-secondary-btn:hover { border-color: var(--vv-brand); }
.vv-topic-nav-btn:disabled { cursor: not-allowed; opacity: 0.42; }
.vv-primary-btn { border-color: var(--vv-brand); color: #fff; background: var(--vv-brand); }
.vv-primary-btn:hover { background: var(--vv-brand-dark); }

.vv-completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1060px;
  margin: 18px auto 0;
  padding: 15px 16px;
  border: 1px solid var(--vv-line);
  border-left: 4px solid var(--vv-green);
  border-radius: 14px;
  background: rgba(255, 254, 250, 0.75);
}

.vv-completion[data-tone="red"] { border-left-color: var(--vv-red); }
.vv-completion[data-tone="yellow"] { border-left-color: var(--vv-yellow); }
.vv-completion h3 { margin: 0; }
.vv-completion p:last-child { margin: 6px 0 0; color: var(--vv-muted); }
.vv-completion-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.vv-reset-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.vv-word-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  max-width: 1060px;
  margin: 16px auto 0;
}

.vv-word-row {
  display: flex;
  flex-direction: column;
  align-self: start;
  min-width: 0;
  min-height: 148px;
  padding: 14px;
  border: 1px solid var(--vv-line);
  border-radius: 14px;
  background: #fffefa;
}

.vv-word-row[data-selected="know"] { border-color: rgba(42, 127, 91, 0.34); background: rgba(234, 248, 240, 0.42); }
.vv-word-row[data-selected="fuzzy"] { border-color: rgba(184, 130, 21, 0.34); background: rgba(255, 248, 224, 0.42); }
.vv-word-row[data-selected="unknown"] { border-color: rgba(180, 65, 54, 0.34); background: rgba(255, 239, 236, 0.42); }

.vv-word-main { min-width: 0; }
.vv-word-kana { overflow-wrap: anywhere; font-size: 1.08rem; font-weight: 800; }
.vv-word-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(91, 75, 63, 0.16); line-height: 1.45; }
.vv-word-answer-kanji { overflow-wrap: anywhere; color: var(--vv-muted); font-family: Georgia, "Yu Mincho", serif; font-size: 0.92rem; }
.vv-word-answer-meaning { overflow-wrap: anywhere; color: var(--vv-ink); font-size: 0.9rem; }

.vv-status-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: auto;
  padding-top: 16px;
}

.vv-status {
  display: inline-grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 4px;
  border: 1px solid #d5cbc0;
  border-radius: 9px;
  color: var(--vv-ink);
  background: #fffefa;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.vv-status[data-status="know"][aria-pressed="true"] { border-color: var(--vv-green); color: #fff; background: var(--vv-green); }
.vv-status[data-status="fuzzy"][aria-pressed="true"] { border-color: var(--vv-yellow); color: #fff; background: var(--vv-yellow); }
.vv-status[data-status="unknown"][aria-pressed="true"] { border-color: var(--vv-red); color: #fff; background: var(--vv-red); }
.vv-status:hover { border-color: var(--vv-brand); }

.vv-empty { grid-column: 1 / -1; padding: 22px; color: var(--vv-muted); text-align: center; }

.vv-export-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.vv-export-scope {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.vv-export-scope-label { color: var(--vv-muted); font-size: 0.88rem; font-weight: 700; }
.vv-export-scope-btn { min-width: 120px; min-height: 40px; padding: 8px 13px; border: 1px solid var(--vv-line); border-radius: 10px; color: var(--vv-ink); background: #fffefa; font-size: 0.88rem; font-weight: 700; }
.vv-export-scope-btn[aria-pressed="true"] { border-color: var(--vv-brand); color: #fff; background: var(--vv-brand); }
.vv-export-scope-btn:hover { border-color: var(--vv-brand); }
.vv-export-note { margin: 10px 0 0; color: var(--vv-muted); font-size: 0.82rem; line-height: 1.55; }

.vv-export-btn { text-align: left; }
.vv-export-btn strong { display: block; }
.vv-export-btn small { display: block; margin-top: 4px; color: var(--vv-muted); }
.vv-export-btn:hover { border-color: var(--vv-brand); }

.vv-data-management {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.vv-data-management p { margin: 7px 0 0; color: var(--vv-muted); font-size: 0.85rem; line-height: 1.6; }
.vv-reset-btn { border-color: #e1b4af; color: var(--vv-red); background: #fff8f7; }

.vv-modal {
  width: min(92vw, 430px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--vv-ink);
  background: #fffefa;
  box-shadow: 0 25px 80px rgba(44, 25, 15, 0.25);
}

.vv-modal::backdrop { background: rgba(40, 27, 18, 0.42); }
.vv-modal-body { padding: 24px; }
.vv-modal h2 { margin: 0; font-size: 1.25rem; }
.vv-modal p { color: var(--vv-muted); line-height: 1.65; }
.vv-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.vv-modal-btn[data-action="confirm"] { border-color: var(--vv-red); color: #fff; background: var(--vv-red); }

.vv-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 5;
  max-width: min(90vw, 380px);
  padding: 12px 15px;
  border: 1px solid var(--vv-line);
  border-radius: 12px;
  color: var(--vv-ink);
  background: #fffefa;
  box-shadow: var(--vv-shadow);
}

.vv-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .vv-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .vv-word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .vv-shell { padding: 18px 14px 44px; }
  .vv-hero { display: block; }
  .vv-badge { display: inline-block; margin-top: 16px; }
  .vv-panel { padding: 15px; border-radius: 16px; }
  .vv-howto ul { grid-template-columns: 1fr; gap: 6px; }
  .vv-toolbar-head, .vv-section-head, .vv-data-management { display: block; }
  .vv-search { min-width: 0; margin-top: 14px; }
  .vv-topic-overview-list { display: flex; gap: 10px; overflow-x: auto; margin-right: -2px; padding: 2px 2px 6px; }
  .vv-topic-card { flex: 0 0 min(78vw, 250px); }
  .vv-topic-nav { grid-template-columns: 1fr 1fr; gap: 10px; }
  .vv-current-topic-heading { grid-column: 1 / -1; grid-row: 1; }
  .vv-topic-nav-btn { grid-row: 2; width: 100%; }
  .vv-topic-nav-btn[data-topic-next] { grid-column: 2; }
  .vv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vv-stat:last-child { grid-column: 1 / -1; }
  .vv-word-list { grid-template-columns: 1fr; }
  .vv-word-row { gap: 10px; }
  .vv-completion { display: block; }
  .vv-completion-actions { justify-content: flex-start; margin-top: 14px; }
  .vv-export-scope { align-items: stretch; }
  .vv-export-scope-label { flex: 1 0 100%; }
  .vv-export-scope-btn { flex: 1 1 0; min-width: 0; }
  .vv-export-grid { grid-template-columns: 1fr; }
  .vv-reset-actions { justify-content: stretch; margin-top: 14px; }
  .vv-reset-btn { flex: 1 1 100%; }
  .vv-toast { right: 14px; bottom: 14px; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --vv-ink: #f3e9df; --vv-muted: #b9aaa0; --vv-paper: #201b18; --vv-panel: rgba(47, 39, 34, 0.94); --vv-line: #594a40; --vv-shadow: 0 18px 45px rgba(0, 0, 0, 0.18); }
  .vv-badge, .vv-search, .vv-filter, .vv-export-btn, .vv-export-scope-btn, .vv-reset-btn, .vv-stat, .vv-topic-card, .vv-topic-nav-btn, .vv-secondary-btn, .vv-completion, .vv-word-row, .vv-status, .vv-modal, .vv-toast { background: #2d2520; }
  .vv-badge { border-color: #805147; color: #f0c6bc; }
  .vv-reset-btn { background: #382321; }
}

/* V1.2 all-level candidate view */
.vv-loading, .vv-error { text-align: center; }
.vv-loading h1, .vv-error h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.3rem); }
.vv-loading p:last-child, .vv-error p:last-child { color: var(--vv-muted); line-height: 1.7; }

.vv-level-switch {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.vv-level-tab {
  min-height: 44px;
  border: 1px solid var(--vv-line);
  border-radius: 10px;
  color: var(--vv-ink);
  background: #fffefa;
  font-weight: 800;
}

.vv-level-tab[aria-selected="true"] { border-color: var(--vv-brand); color: #fff; background: var(--vv-brand); }
.vv-level-tab:hover { border-color: var(--vv-brand); }

.vv-level-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.vv-topic-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style-position: inside;
}

.vv-topic-details > summary > span:first-child { display: inline-flex; flex-direction: column; min-width: 0; }
.vv-topic-details > summary strong { font-size: 1.25rem; }
.vv-topic-summary { color: var(--vv-muted); font-size: 0.86rem; text-align: right; }
.vv-topic-details[open] > summary { margin-bottom: 2px; }
.vv-topic-overview-list { max-height: 430px; overflow: auto; }

.vv-word-card {
  display: flex;
  flex-direction: column;
  align-self: start;
  min-width: 0;
  min-height: 156px;
  padding: 15px;
  border: 1px solid var(--vv-line);
  border-radius: 14px;
  background: #fffefa;
}

.vv-word-card[data-selected="know"] { border-color: rgba(42, 127, 91, 0.34); background: rgba(234, 248, 240, 0.42); }
.vv-word-card[data-selected="fuzzy"] { border-color: rgba(184, 130, 21, 0.34); background: rgba(255, 248, 224, 0.42); }
.vv-word-card[data-selected="unknown"] { border-color: rgba(180, 65, 54, 0.34); background: rgba(255, 239, 236, 0.42); }
.vv-word-card-content { min-width: 0; }
.vv-word-card .vv-word-kana { min-height: 1.6em; font-size: 1.2rem; }
.vv-word-card .vv-reading-review { color: var(--vv-yellow); font-size: 1rem; }
.vv-word-card[data-reading-review="true"] { border-style: dashed; }
.vv-word-card .vv-word-answer { margin-top: 10px; padding-top: 9px; }
.vv-word-card .vv-status-group { margin-top: auto; padding-top: 18px; }
.vv-word-card .vv-status { min-height: 44px; height: 44px; }
.vv-word-card .vv-status:disabled { cursor: not-allowed; opacity: 0.48; }

@media (max-width: 900px) {
  .vv-level-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vv-word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .vv-level-switch { grid-template-columns: repeat(5, minmax(62px, 1fr)); overflow-x: auto; }
  .vv-level-tab { min-width: 62px; }
  .vv-level-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vv-topic-details > summary { align-items: flex-start; }
  .vv-topic-summary { max-width: 48%; }
  .vv-topic-overview-list { max-height: 360px; }
  .vv-word-list { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  .vv-level-tab, .vv-word-card { background: #2d2520; }
}
