/* ============================================================================
   言ノ葉 — 建築的語学誌 (Architectural Editorial Monograph)
   严格遵循 DESIGN.md：四级字号 · 现代等宽数字 · 像素级网格对齐 · 零发光零卡顿
   ============================================================================ */

:root,
html[data-theme="paper"] {
  --bg: #F4F1EA;
  --bg-alt: #EAE6DC;
  --fg: #141413;
  --fg-muted: #6E6A63;
  --line: rgba(20, 20, 19, 0.14);
  --line-strong: rgba(20, 20, 19, 0.36);
  --accent: #C8321E;
  --accent-fg: #FAF8F5;
  --ok: #266847;
  --ok-bg: rgba(38, 104, 71, 0.09);
  --err: #B83227;
  --err-bg: rgba(184, 50, 39, 0.09);
}

html[data-theme="ink"] {
  --bg: #111110;
  --bg-alt: #191917;
  --fg: #EDEAE2;
  --fg-muted: #8C8880;
  --line: rgba(237, 234, 226, 0.13);
  --line-strong: rgba(237, 234, 226, 0.36);
  --accent: #D6402B;
  --accent-fg: #FAF8F5;
  --ok: #52A87C;
  --ok-bg: rgba(82, 168, 124, 0.12);
  --err: #E05A4E;
  --err-bg: rgba(224, 90, 78, 0.12);
}

:root {
  --font-serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", "Songti SC", serif;
  --font-sans: "Inter", "PingFang SC", "Hiragino Sans", "Noto Sans JP", "Microsoft YaHei", sans-serif;
  --font-num: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  /* 全站严格四档字号（最小 12px） */
  --fs-display: 44px;
  --fs-title: 20px;
  --fs-body: 15px;
  --fs-meta: 12px;
}

@media (max-width: 640px) {
  :root {
    --fs-display: 32px;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: var(--fs-body);
  color: inherit;
}

code {
  font-family: Consolas, monospace;
  font-size: var(--fs-meta);
  background: var(--bg-alt);
  padding: 2px 6px;
}

.num-tabular {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ==================== 建筑网格外框 ==================== */
.frame {
  max-width: 1320px;
  margin: 0 auto;
  min-height: 100vh;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

@media (max-width: 1320px) {
  .frame {
    border-left: none;
    border-right: none;
  }
}

/* ==================== 顶部刊头 Masthead（等高像素对齐） ==================== */
.masthead {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
}

.masthead-brand {
  padding: 0 28px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-kanji {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

.brand-meta {
  font-family: var(--font-num);
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  letter-spacing: 0.12em;
  line-height: 1;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  flex: 1;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.primary-nav::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0 18px;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.06em;
  transition: color 120ms ease-out, border-color 120ms ease-out;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  color: var(--fg);
}

.nav-tab.active {
  color: var(--fg);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

.nav-count {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-meta);
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0 6px;
  line-height: 18px;
  border-radius: 2px;
}

.masthead-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-left: 1px solid var(--line);
  flex-shrink: 0;
}

.level-strip {
  display: inline-flex;
  height: 30px;
  border: 1px solid var(--line);
}

.lvl-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 0 11px;
  height: 100%;
  font-family: var(--font-num);
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.lvl-btn:last-child {
  border-right: none;
}

.lvl-btn:hover {
  color: var(--fg);
  background: var(--bg-alt);
}

.lvl-btn.active {
  background: var(--fg);
  color: var(--bg);
}

.theme-switch {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0 12px;
  height: 30px;
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  cursor: pointer;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease-out, color 120ms ease-out;
}

.theme-switch:hover {
  color: var(--fg);
  border-color: var(--line-strong);
}

@media (max-width: 1020px) {
  .masthead {
    flex-wrap: wrap;
    min-height: auto;
  }
  .masthead-brand {
    border-right: none;
    height: 48px;
    padding: 0 20px;
    width: 100%;
    justify-content: space-between;
  }
  .primary-nav {
    width: 100%;
    height: 44px;
    border-top: 1px solid var(--line);
    padding: 0 12px;
  }
  .nav-tab {
    padding: 0 12px;
  }
  .masthead-controls {
    width: 100%;
    height: 48px;
    justify-content: space-between;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 0 20px;
  }
}

/* ==================== 通用排版原语与现代数字字体 ==================== */
.stage {
  flex: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.meta-label {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  letter-spacing: 0.08em;
}

.display-heading {
  font-family: var(--font-serif);
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* 现代几何无衬线等宽大数字 */
.display-num {
  font-family: var(--font-num);
  font-size: var(--fs-display);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.03em;
  line-height: 1;
}

.num-sep {
  color: var(--fg-muted);
  font-weight: 300;
  margin: 0 4px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.body-muted {
  font-size: var(--fs-body);
  color: var(--fg-muted);
}

/* 按钮与统一高度控件 */
.btn {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  padding: 0 20px;
  height: 38px;
  border-radius: 2px;
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease-out, color 120ms ease-out, border-color 120ms ease-out;
}

.btn:hover:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-accent:hover:not(:disabled) {
  opacity: 0.9;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.text-action {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  padding: 2px 0;
  font-size: var(--fs-meta);
  color: var(--fg);
  cursor: pointer;
  letter-spacing: 0.06em;
}

.text-action:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.control-box {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0 12px;
  height: 32px;
  font-size: var(--fs-meta);
  color: var(--fg);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  display: inline-flex;
  align-items: center;
  transition: border-color 120ms ease-out, background-color 120ms ease-out;
}

.control-box:hover {
  border-color: var(--line-strong);
  background: var(--bg-alt);
}

.control-box.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

select.control-box option {
  background: var(--bg);
  color: var(--fg);
}

.input-minimal {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  padding: 6px 4px;
  font-size: var(--fs-body);
  color: var(--fg);
  outline: none;
  border-radius: 0;
}

.input-minimal:focus {
  border-bottom-color: var(--accent);
}

.textarea-minimal {
  width: 100%;
  min-height: 140px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: 14px;
  font-family: Consolas, monospace;
  font-size: var(--fs-body);
  color: var(--fg);
  outline: none;
  border-radius: 2px;
  margin: 16px 0;
}

.textarea-minimal:focus {
  border-color: var(--fg);
}

/* 次级工具栏（等高对齐） */
.subbar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  min-height: 52px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
  flex-wrap: wrap;
}

.subbar-tabs {
  display: flex;
  align-items: stretch;
  gap: 24px;
}

.sub-link {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0 2px;
  min-height: 52px;
  font-size: var(--fs-body);
  color: var(--fg-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 120ms ease-out;
}

.sub-link:hover {
  color: var(--fg);
}

.sub-link.active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--fg);
}

.subbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 640px) {
  .subbar {
    padding: 0 20px;
  }
  .sub-link {
    min-height: 44px;
  }
  .section-bar {
    padding: 14px 20px;
  }
}

/* ==================== 1. 総覧 (3:2 分栏严格对齐下方 5 等分网格第3列竖线) ==================== */
.poster-hero {
  display: grid;
  grid-template-columns: 3fr 2fr;
  border-bottom: 1px solid var(--line);
}

.poster-lead {
  padding: 56px 44px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}

.poster-desc {
  max-width: 560px;
  color: var(--fg-muted);
}

.poster-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.poster-metrics {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
}

.metric-cell {
  padding: 24px 36px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.metric-cell:last-child {
  border-bottom: none;
}

@media (max-width: 860px) {
  .poster-hero {
    grid-template-columns: 1fr;
  }
  .poster-lead {
    padding: 36px 20px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .metric-cell {
    padding: 20px;
  }
}

/* 五段位画廊竖栏 */
.roadmap-columns {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--line);
}

.stage-col {
  padding: 28px 24px;
  border-right: 1px solid var(--line);
  border-top: 2px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 240px;
  transition: background-color 120ms ease-out;
}

.stage-col:last-child {
  border-right: none;
}

.stage-col:hover {
  background: var(--bg-alt);
}

.stage-col.active {
  background: var(--bg-alt);
  border-top-color: var(--accent);
}

.stage-col-code {
  font-family: var(--font-num);
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stage-col-title {
  font-family: var(--font-serif);
  font-weight: 700;
  margin-top: 12px;
}

.stage-col-desc {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  margin-top: 6px;
  line-height: 1.6;
}

.stage-rule {
  width: 100%;
  height: 2px;
  background: var(--line);
  margin: 24px 0 12px;
}

.stage-rule-fill {
  height: 100%;
  background: var(--fg);
  transition: width 200ms ease-out;
}

.stage-col.active .stage-rule-fill {
  background: var(--accent);
}

.stage-col-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-meta);
  color: var(--fg-muted);
}

@media (max-width: 960px) {
  .roadmap-columns {
    grid-template-columns: 1fr;
  }
  .stage-col {
    min-height: auto;
    padding: 24px 20px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .stage-col:last-child {
    border-bottom: none;
  }
}

/* ==================== 2. 講義 书册式双栏 ==================== */
.monograph-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 58px);
}

.monograph-index {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.lesson-item {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease-out;
}

.lesson-item:hover {
  background: var(--bg-alt);
}

.lesson-item.active {
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  padding-left: 21px;
}

.lesson-item-top {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.lesson-item.done .lesson-status {
  color: var(--ok);
  font-weight: 600;
}

.lesson-item-title {
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.4;
}

.monograph-article {
  padding: 48px 60px 72px;
  max-width: 880px;
}

.article-head {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.article-head > div {
  flex: 1;
}

.article-head > .btn {
  flex-shrink: 0;
}

.article-title {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.4;
}

.article-summary {
  color: var(--fg-muted);
  margin-top: 10px;
}

.article-sec {
  margin-top: 36px;
}

.article-sec h3 {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 600;
  margin-bottom: 14px;
}

.article-body {
  white-space: pre-line;
  line-height: 1.9;
}

.example-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.example-jp {
  font-family: var(--font-serif);
  font-weight: 600;
}

.example-cn {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  margin-top: 2px;
}

.notes-block {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg-alt);
}

.notes-block ul {
  padding-left: 18px;
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.article-pager {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
}

@media (max-width: 860px) {
  .monograph-layout {
    grid-template-columns: 1fr;
  }
  .monograph-index {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 240px;
    overflow-y: auto;
  }
  .monograph-article {
    padding: 32px 20px 56px;
  }
  .article-head {
    flex-direction: column;
  }
}

/* ==================== 3. 語彙 工作区：词卡舞台 + 右侧可收起五十音键盘 ==================== */
.vocab-workspace {
  max-width: 820px;
  margin: 40px auto 56px;
  padding: 0 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.vocab-workspace.with-keypad {
  max-width: 1180px;
  grid-template-columns: minmax(0, 1fr) 336px;
}

.flashcard-stage {
  border: 1px solid var(--line);
  min-height: 503px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg);
}

.fc-topbar {
  height: 48px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.fc-meta-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fc-center {
  padding: 40px 36px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.fc-kanji {
  font-family: var(--font-serif);
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.25;
}

/* 学习模式顶部展示的假名提示栏 */
.fc-study-hint {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.kana-badge {
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 2px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
}

/* 假名拼写输入区 */
.spell-box {
  width: 100%;
  max-width: 520px;
  margin-top: 28px;
  text-align: left;
}

.spell-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.spell-target-group {
  display: inline-flex;
  border: 1px solid var(--line);
}

.mini-tab {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 4px 10px;
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.mini-tab:last-child {
  border-right: none;
}

.mini-tab:hover {
  color: var(--fg);
  background: var(--bg-alt);
}

.mini-tab.active {
  background: var(--fg);
  color: var(--bg);
}

.romaji-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}

.romaji-toggle input {
  accent-color: var(--accent);
}

.spell-input-row {
  display: flex;
  gap: 8px;
}

.spell-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-alt);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-size: var(--fs-body);
  letter-spacing: 0.06em;
  outline: none;
}

.spell-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}

.spell-feedback {
  margin-top: 10px;
  padding: 8px 12px;
  font-size: var(--fs-meta);
  font-weight: 600;
}

.spell-feedback.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.spell-feedback.err {
  background: var(--err-bg);
  color: var(--err);
}

.fc-answer {
  width: 100%;
  max-width: 560px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.fc-kana {
  font-size: var(--fs-body);
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}

.fc-mean {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 700;
  margin-top: 4px;
}

.fc-example {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--bg-alt);
  text-align: left;
}

.fc-ex-jp {
  font-family: var(--font-serif);
}

.fc-ex-cn {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  margin-top: 4px;
}

.fc-reveal-bar {
  padding: 20px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.srs-rating-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}

.study-nav-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  border-top: 1px solid var(--line);
}

.rate-cell {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.rate-cell:last-child {
  border-right: none;
}

.rate-cell:hover,
.rate-cell.recommended {
  background: var(--fg);
  color: var(--bg);
}

.rate-cell:hover .meta-label,
.rate-cell.recommended .meta-label {
  color: var(--bg);
  opacity: 0.78;
}

.study-primary-cell {
  background: var(--bg-alt);
}

.rate-title {
  font-weight: 600;
}

/* 右侧可收起日语五十音输入盘 */
.kana-keypad {
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.vocab-workspace:not(.with-keypad) .kana-keypad {
  display: none;
}

.keypad-head {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.keypad-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
}

.keypad-mods {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
}

.mod-key {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  height: 34px;
  font-size: var(--fs-meta);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 100ms ease-out, color 100ms ease-out;
}

.mod-key:last-child {
  border-right: none;
}

.mod-key:hover {
  background: var(--fg);
  color: var(--bg);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  flex: 1;
}

.kana-key {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 36px;
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 90ms ease-out, color 90ms ease-out;
}

.kana-key:nth-child(5n) {
  border-right: none;
}

.kana-key:nth-last-child(-n + 5) {
  border-bottom: none;
}

.kana-key:hover {
  background: var(--fg);
  color: var(--bg);
}

.keypad-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.keypad-foot .btn {
  height: 34px;
  padding: 0 8px;
  font-size: var(--fs-meta);
}

@media (max-width: 960px) {
  .vocab-workspace,
  .vocab-workspace.with-keypad {
    grid-template-columns: 1fr;
    margin: 0;
    padding: 0;
  }
  .flashcard-stage,
  .kana-keypad {
    border-left: none;
    border-right: none;
    border-top: none;
  }
  .fc-center {
    padding: 32px 20px;
  }
  .srs-rating-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .rate-cell:nth-child(2) {
    border-right: none;
  }
  .rate-cell:nth-child(1),
  .rate-cell:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }
}

/* 词库目录与表格 */
.index-toolbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.index-toolbar .input-minimal {
  width: 320px;
  max-width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

.editorial-table {
  width: 100%;
  border-collapse: collapse;
}

.editorial-table th,
.editorial-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: var(--fs-body);
}

.editorial-table th {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  font-weight: 500;
  letter-spacing: 0.08em;
  background: var(--bg-alt);
}

.editorial-table tbody tr:hover {
  background: var(--bg-alt);
}

.kanji-cell {
  font-family: var(--font-serif);
  font-weight: 600;
}

.load-more-bar {
  padding: 24px;
  text-align: center;
}

.import-sheet {
  max-width: 740px;
  padding: 48px 28px;
  margin: 0 auto;
}

/* ==================== 4. 文法 瑞士细线网格目录 ==================== */
.grammar-catalogue {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--line);
  gap: 1px;
  border-bottom: 1px solid var(--line);
}

.g-cell {
  background: var(--bg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.g-cell-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.g-cell-actions {
  display: flex;
  gap: 16px;
}

.g-title {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 700;
}

.g-formula {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.g-mean {
  font-weight: 600;
}

.g-ex-jp {
  font-family: var(--font-serif);
}

.g-ex-cn {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
}

.g-note {
  font-size: var(--fs-meta);
  color: var(--fg-muted);
  background: var(--bg-alt);
  padding: 10px 12px;
  margin-top: auto;
}

@media (max-width: 860px) {
  .grammar-catalogue {
    grid-template-columns: 1fr;
  }
  .g-cell {
    padding: 24px 20px;
  }
}

/* 纵向谱系矩阵 */
.chain-row {
  border-bottom: 1px solid var(--line);
  padding: 32px 28px;
}

.chain-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--line);
  margin-top: 18px;
}

.chain-step {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.chain-step:last-child {
  border-right: none;
}

.chain-form {
  font-family: var(--font-serif);
  font-weight: 700;
  margin: 8px 0 4px;
}

@media (max-width: 860px) {
  .chain-steps {
    grid-template-columns: 1fr;
  }
  .chain-step {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .chain-step:last-child {
    border-bottom: none;
  }
}

/* ==================== 5. 演習 & 特训试卷 ==================== */
.sheet-toolbar {
  max-width: 820px;
  margin: 32px auto 0;
  padding: 0 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.exam-sheet {
  max-width: 820px;
  margin: 36px auto 64px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.sheet-meta {
  height: 46px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-prompt {
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 600;
  padding: 36px 28px;
  line-height: 1.75;
}

.sheet-prompt u {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 6px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line);
}

.exam-opt {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 20px 28px;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease-out;
}

.exam-opt:nth-child(2n) {
  border-right: none;
}

.exam-opt:hover:not(:disabled) {
  background: var(--bg-alt);
}

.exam-opt.correct {
  background: var(--ok-bg);
  color: var(--ok);
  font-weight: 600;
}

.exam-opt.wrong {
  background: var(--err-bg);
  color: var(--err);
}

@media (max-width: 640px) {
  .exam-sheet {
    margin: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }
  .option-grid {
    grid-template-columns: 1fr;
  }
  .exam-opt {
    border-right: none;
  }
}

.star-slots {
  padding: 24px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: var(--fs-title);
}

.star-slot {
  min-width: 108px;
  min-height: 40px;
  padding: 4px 14px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  font-size: var(--fs-body);
  cursor: pointer;
}

.star-slot.is-star {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

.star-slot.filled {
  border-style: solid;
  border-color: var(--fg);
  background: var(--bg-alt);
  color: var(--fg);
}

.star-slot.is-star.filled {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.sheet-actions {
  padding: 20px 28px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.feedback-panel {
  padding: 24px 28px;
  background: var(--bg-alt);
  border-top: 1px solid var(--line);
  display: none;
}

.feedback-panel.show {
  display: block;
}

.feedback-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.feedback-desc {
  color: var(--fg-muted);
}

.feedback-panel .sheet-actions {
  padding: 16px 0 0;
}

/* ==================== 6. 記録 档案双栏 ==================== */
.archive-split {
  display: grid;
  grid-template-columns: 3fr 2fr;
  min-height: calc(100vh - 58px);
}

.archive-main {
  border-right: 1px solid var(--line);
}

.mistake-list {
  display: flex;
  flex-direction: column;
}

.mistake-row {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.mistake-row-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.mistake-ans {
  color: var(--ok);
  font-weight: 600;
  font-size: var(--fs-meta);
}

.mistake-prompt {
  font-family: var(--font-serif);
  font-weight: 600;
  margin-bottom: 6px;
}

.archive-side {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sync-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sync-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.sync-head .meta-label.is-ok {
  color: var(--ok);
}

.sync-head .meta-label.is-err {
  color: var(--accent);
}

.sync-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sync-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sync-field .control-box {
  width: 100%;
  box-sizing: border-box;
}

.sync-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sync-actions-grid .btn {
  width: 100%;
  text-align: center;
}

.archive-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 0;
}

.archive-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

@media (max-width: 860px) {
  .archive-split {
    grid-template-columns: 1fr;
  }
  .archive-main {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
