/* ==========================================================================
   俄语 1 · 学习原型
   三档布局：桌面（≥1024 侧栏）/ 平板（640–1023 顶栏+胶囊导航）/ 手机（<640 顶栏+底部导航）
   ========================================================================== */

:root {
  --paper: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #efe9dd;
  --surface-3: #e7dfd0;
  --ink: #1e1a16;
  --ink-2: #4a423a;
  --muted: #8a7f72;
  --line: #e2dacd;
  --line-strong: #cfc4b3;

  --accent: #a83a2c;
  --accent-soft: #f5e4e0;
  --teal: #2b5f6e;
  --teal-soft: #dfeaee;
  --ok: #2f7a4f;
  --ok-soft: #e2f0e7;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", "Songti SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 26, 22, 0.06);
  --shadow: 0 2px 4px rgba(30, 26, 22, 0.05), 0 10px 30px rgba(30, 26, 22, 0.07);
  --shadow-lg: 0 8px 20px rgba(30, 26, 22, 0.1), 0 24px 60px rgba(30, 26, 22, 0.12);

  --side-w: 278px;
  --read-w: 700px;
  --gutter: 34px;
}

[data-theme="dark"] {
  --paper: #14120f;
  --surface: #1c1916;
  --surface-2: #26211c;
  --surface-3: #312a23;
  --ink: #f2ece2;
  --ink-2: #cbc0b3;
  --muted: #8d8275;
  --line: #322c26;
  --line-strong: #4a4138;

  --accent: #e2765f;
  --accent-soft: #3c2520;
  --teal: #6fb3c4;
  --teal-soft: #1d3238;
  --ok: #63b98a;
  --ok-soft: #1b2f24;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button, select, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

::selection { background: var(--accent-soft); color: var(--accent); }

/* 可见性开关（用 body 提权，压过后面的 .icon-btn 等组件规则） */
body .only-compact { display: none; }

@media (max-width: 1023px) {
  .only-wide { display: none !important; }
  body .only-compact { display: inline-flex; }
}

/* ================================================================= 布局 */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================================= 侧栏 */

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 18px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 8px;
}

.brand .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.picker-wrap { padding: 0 0 2px; }

.lesson-pick {
  display: block;
  width: 100%;
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.3;
  padding: 6px 26px 6px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% + 1px), calc(100% - 9px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: background-color 0.13s, border-color 0.13s;
}

.lesson-pick:hover { background-color: var(--surface-2); border-color: var(--line); }
.lesson-pick:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lesson-pick optgroup { font-family: var(--sans); font-size: 12.5px; color: var(--muted); }
.lesson-pick option { font-family: var(--serif); font-size: 15px; background: var(--surface); }

/* 书籍选择器（多书时出现，单书时 JS 置为 display:none） */
.book-pick {
  display: block;
  width: 100%;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  padding: 5px 24px 5px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) calc(50% + 1px), calc(100% - 8px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: background-color 0.13s, border-color 0.13s;
}
.book-pick:hover { color: var(--ink); border-color: var(--muted); }
.book-pick:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.book-pick option { font-family: var(--serif); font-size: 14px; background: var(--surface); color: var(--ink); }

.side .sub {
  font-size: 12px;
  color: var(--muted);
  padding-left: 9px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand { white-space: nowrap; }

/* 主导航（桌面竖排） */

.tabs { display: flex; flex-direction: column; gap: 2px; }

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  transition: background 0.13s, color 0.13s;
}

.tab:hover { background: var(--surface-2); }

.tab[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.tab[aria-selected="true"] .tab-count { color: rgba(255, 255, 255, 0.5); }
[data-theme="dark"] .tab[aria-selected="true"] { color: var(--paper); }

.tab .ico { width: 16px; text-align: center; font-size: 12px; opacity: 0.7; }
.tab-count { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 胶囊导航（平板） */

.pillbar { gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; }

.pillbar button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.13s, color 0.13s;
}

.pillbar button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}

/* 目录 */

.toc-box { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.toc-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 11px;
  margin-bottom: 6px;
}

.toc { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; padding-bottom: 8px; }

.toc a {
  display: flex;
  gap: 9px;
  padding: 6px 11px;
  border-radius: 7px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.12s;
}

.toc a:hover { background: var(--surface-2); }
.toc a.is-current { background: var(--accent-soft); color: var(--accent); }
.toc a .n { flex: 0 0 24px; color: var(--muted); font-family: var(--serif); font-size: 12px; padding-top: 1px; }
.toc a.is-current .n { color: var(--accent); }

.side-foot {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chip-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip-btn:hover { background: var(--surface-2); }

.chip-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: background 0.12s;
}

.icon-btn:hover { background: var(--surface-2); }

/* ============================================== 平板 / 手机：侧栏变顶栏 */

@media (max-width: 1023px) {
  .side {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    background: var(--surface);
  }

  .picker-wrap { flex: 0 1 auto; min-width: 0; }
  .lesson-pick { font-size: 15px; width: auto; max-width: 46vw; padding: 4px 24px 4px 4px; }
  .book-pick { flex: 0 1 auto; width: auto; max-width: 28vw; margin-bottom: 0; }

  .pillbar { flex: 0 0 auto; }
  .side-foot { margin-left: auto; padding-top: 0; border-top: 0; flex-wrap: nowrap; }
  .chip-btn { padding: 5px 10px; font-size: 11.5px; }
}

@media (max-width: 639px) {
  body .pillbar { display: none; }
  .side { gap: 8px; padding: 9px 12px; }
  .picker-wrap { flex: 1 1 auto; }
  .lesson-pick { width: 100%; max-width: none; font-size: 14px; }
  .book-pick { flex: 0 0 auto; max-width: 34vw; }
  .side-foot { flex: 0 0 auto; }
  .chip-btn { padding: 5px 9px; font-size: 11px; }
}

/* ================================================================= 主体 */

.main { min-width: 0; padding: 0 0 120px; }

.wrap {
  max-width: var(--read-w);
  margin: 0 auto;
  padding: 0 32px;
}

@media (max-width: 1023px) { .wrap { padding: 0 24px; } }
@media (max-width: 639px) { .wrap { padding: 0 16px; } .main { padding-bottom: 92px; } }

.view { display: none; }
.view.is-active { display: block; }

.view-head { padding: 40px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }

.view-head .kicker {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 7px;
}

.view-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 400;
  margin: 0 0 6px;
  letter-spacing: 0.005em;
}

.view-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 639px) {
  .view-head { padding: 24px 0 16px; margin-bottom: 22px; }
  .view-head h1 { font-size: 23px; }
  .view-head p { font-size: 12.5px; }
}

/* ================================================================= 阅读 */

.sec { margin-bottom: 44px; scroll-margin-top: 78px; }

@media (min-width: 1024px) { .sec { scroll-margin-top: 24px; } }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 9px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.sec-no {
  flex: 0 0 auto;
  font-family: var(--serif);
  font-size: 12.5px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 1.6;
}

.sec-head h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.005em;
}

.sec-head .ru-title { color: var(--muted); font-size: 13px; }

.sec-head .pg {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 639px) {
  .sec-head h2 { font-size: 17.5px; }
  .sec-head .ru-title { display: none; }
  .sec { margin-bottom: 34px; }
}

/* 课文工具条 */

.text-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.tool:hover { background: var(--surface-2); }

.tool[aria-pressed="true"] {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}

.tool.is-playing {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* 段落 */

.para {
  position: relative;
  padding-left: var(--gutter);
  margin-bottom: 16px;
  border-radius: 8px;
  transition: background 0.2s;
}

.para .say {
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.para:hover .say { opacity: 1; border-color: var(--accent); color: var(--accent); }

.para.is-speaking { background: var(--accent-soft); }
.para.is-speaking .say {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.para .prose { margin: 0; }

.prose {
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
}

@media (max-width: 639px) {
  :root { --gutter: 27px; }
  .prose { font-size: 15.5px; line-height: 1.8; }
  .para .say { width: 21px; height: 21px; font-size: 8px; }
}

/* 译文 */

.para .tr {
  display: none;
  margin-top: 8px;
  padding-left: 11px;
  border-left: 2px solid var(--teal);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.sec.show-tr .para .tr { display: block; }

.tr-note {
  font-size: 11.5px;
  color: var(--muted);
  margin: -6px 0 16px;
  font-style: italic;
}

/* 俄语词 */

.w {
  font-family: var(--serif);
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.w:hover { background: var(--accent-soft); }
.w.is-hit { background: var(--teal-soft); box-shadow: inset 0 -2px 0 var(--teal); }

.uncertain {
  display: inline-block;
  vertical-align: super;
  font-size: 8.5px;
  line-height: 1;
  padding: 1px 3px;
  margin: 0 1px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 600;
  cursor: help;
}

/* 列表 */

ul.plain, ol.plain { margin: 0 0 16px; padding-left: 0; list-style: none; }

ul.plain > li, ol.plain > li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
  line-height: 1.8;
}

ul.plain.own > li { padding-left: 4px; }
ul.plain.own > li::before { display: none; }

ul.plain > li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
}

ol.plain { counter-reset: item; }
ol.plain > li { counter-increment: item; }
ol.plain > li::before {
  content: counter(item) ".";
  position: absolute;
  left: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

li .cont { display: block; color: var(--ink-2); font-size: 14px; margin-top: 2px; }

/* 注意框 */

.note-box {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  margin: 0 0 18px;
  background: var(--teal-soft);
  border-left: 3px solid var(--teal);
  border-radius: 0 9px 9px 0;
  font-size: 14px;
  line-height: 1.75;
}

.note-box .tag {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--teal);
  font-weight: 600;
  padding-top: 3px;
}

/* 表格 */

.tbl-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.tbl th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

table.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.6;
}

table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--surface-2); }
table.tbl td:first-child { color: var(--ink-2); }

@media (max-width: 639px) {
  table.tbl { font-size: 13px; }
  table.tbl th, table.tbl td { padding: 7px 9px; }
}

.tbl-note {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
  margin: -12px 0 20px;
  padding-left: 11px;
  border-left: 2px solid var(--line);
}

/* 生词表 */

.vocab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 26px;
  margin-bottom: 20px;
}

.vocab-grid .pair {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14.5px;
}

.vocab-grid .pair .ru { font-family: var(--serif); }
.vocab-grid .pair .zh { color: var(--muted); text-align: right; font-size: 13px; }

@media (max-width: 639px) {
  .vocab-grid { grid-template-columns: 1fr; }
}

/* 练习卡 */

.ex {
  margin: 0 0 14px;
  padding: 13px 15px 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ex-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; flex-wrap: wrap; }

.ex-no {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 2px 7px;
  white-space: nowrap;
}

.ex-instr { font-size: 13px; color: var(--ink-2); line-height: 1.5; }

.ex-items { margin: 0; padding: 0; list-style: none; }

.ex-items li {
  padding: 5px 0 5px 14px;
  position: relative;
  font-size: 15px;
  line-height: 1.75;
  border-bottom: 1px solid var(--line);
}

.ex-items li:last-child { border-bottom: 0; }

.ex-items li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.85em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
}

.ex.is-pattern .ex-items li::before { display: none; }
.ex.is-pattern .ex-items li { padding-left: 0; }

.ex-empty { color: var(--muted); font-size: 12.5px; font-style: italic; }

/* 参考答案（AI 生成，可折叠） */
.ex-answer {
  margin-top: 10px;
  border: 1px dashed var(--accent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  overflow: hidden;
}
.ex-answer-sum {
  cursor: pointer;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ex-answer-sum::-webkit-details-marker { display: none; }
.ex-answer-sum::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.ex-answer[open] .ex-answer-sum::before { transform: rotate(90deg); }
.ex-answer-tag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.ex-answer-body {
  padding: 4px 14px 12px 26px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
}

/* ================================================================= 语法卡 */

.gcard {
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.gcard:hover { box-shadow: var(--shadow-sm); }

.gcard-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.gcard-head .no {
  font-family: var(--serif);
  font-size: 12.5px;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 4px;
  padding: 0 5px;
  flex: 0 0 auto;
}

.gcard-head h3 {
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 400;
  margin: 0;
}

.gcard-head .chev {
  margin-left: auto;
  color: var(--ink-2);
  font-size: 12px;
  opacity: 0.6;
  transition: transform 0.18s;
}

.gcard[data-open="false"] .gcard-head .chev { transform: rotate(-90deg); }

.gcard-body { padding: 17px; }
.gcard[data-open="false"] .gcard-body { display: none; }
.gcard-body > *:last-child { margin-bottom: 0; }
.gcard-body .tbl-wrap { margin-bottom: 14px; }

/* ================================================================= 单词卡 */

.deck-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.deck-progress {
  flex: 1;
  min-width: 90px;
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.deck-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.deck-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.card-stage { perspective: 1600px; margin-bottom: 18px; }

.fcard {
  position: relative;
  width: 100%;
  min-height: 268px;
  border: 0;
  padding: 0;
  background: transparent;
  display: block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fcard-inner {
  position: relative;
  width: 100%;
  min-height: 268px;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.3, 1);
  transform-style: preserve-3d;
}

.fcard.is-flipped .fcard-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 34px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face.back { transform: rotateY(180deg); background: var(--surface-2); }

.face .word {
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1.15;
  letter-spacing: 0.005em;
  text-align: center;
  word-break: break-word;
  max-width: 100%;
}

.face .word.small { font-size: 30px; }

.face .trans {
  font-size: 24px;
  line-height: 1.45;
  text-align: center;
  color: var(--ink);
  max-width: 100%;
}

.face .pos {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.face .hint {
  position: absolute;
  bottom: 15px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.face .must {
  position: absolute;
  top: 13px;
  right: 15px;
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
}

.face .speak-btn {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s, color 0.13s, border-color 0.13s, transform 0.1s;
}

.face .speak-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.face .speak-btn:active { transform: scale(0.94); }
.face .speak-btn.is-playing { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 639px) {
  .fcard, .fcard-inner { min-height: 224px; }
  .face { padding: 30px 20px; border-radius: 16px; }
  .face .word { font-size: 32px; }
  .face .trans { font-size: 20px; }
}

.deck-actions { display: flex; gap: 9px; }

.btn {
  flex: 1;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 13px 16px;
  border-radius: 11px;
  font-size: 14px;
  transition: transform 0.08s, background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.985); }

.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
[data-theme="dark"] .btn.primary { color: var(--paper); }
.btn.primary:hover { opacity: 0.92; background: var(--ink); }

.btn.ghost { flex: 0 0 auto; padding: 13px 17px; }

.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.ok:hover { background: var(--ok-soft); }

.btn.bad { border-color: var(--accent); color: var(--accent); }
.btn.bad:hover { background: var(--accent-soft); }

@media (max-width: 639px) {
  .deck-actions { flex-wrap: wrap; }
  .btn.ghost { flex: 1 1 100%; order: 3; padding: 10px; font-size: 13px; }
}

.deck-tip {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* 完成面板 */

.done-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 40px 26px;
  text-align: center;
}

.done-panel .big {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.done-panel .lbl { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.done-panel .row { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

/* ================================================================= 测验 */

.drill-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.drill-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow);
}

@media (max-width: 639px) { .drill-q { padding: 20px 16px; } }

.q-kicker {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 13px;
}

.q-stem {
  font-family: var(--serif);
  font-size: 36px;
  line-height: 1.25;
  margin-bottom: 8px;
  word-break: break-word;
}

@media (max-width: 639px) { .q-stem { font-size: 27px; } }

.q-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; line-height: 1.6; }

.q-stem .vopt {
  border: 0;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  padding: 0 2px;
  margin: 0 -1px;
  border-bottom: 2px dashed var(--accent);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.q-stem .vopt:hover { background: var(--accent-soft); }
.q-stem .vopt[data-state="ok"] { color: var(--ok); background: var(--ok-soft); border-bottom-color: var(--ok); }
.q-stem .vopt[data-state="bad"] { color: var(--accent); background: var(--accent-soft); border-bottom-color: var(--accent); }
.q-stem .vopt:disabled { cursor: default; }

.opts { display: flex; flex-wrap: wrap; gap: 9px; }

.opt {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 17px;
  font-size: 15.5px;
  font-family: var(--serif);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.opt:hover { background: var(--surface-2); }

.opt[data-state="ok"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.opt[data-state="bad"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.opt:disabled { cursor: default; opacity: 1; }
.opt:disabled:hover { background: var(--surface); }
.opt[data-state="ok"]:disabled:hover { background: var(--ok-soft); }
.opt[data-state="bad"]:disabled:hover { background: var(--accent-soft); }

table.tbl input.cell-input {
  width: 100%;
  min-width: 84px;
  padding: 4px 7px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  outline: none;
}

table.tbl input.cell-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
table.tbl input.cell-input[data-state="ok"] { border-color: var(--ok); color: var(--ok); }
table.tbl input.cell-input[data-state="bad"] { border-color: var(--accent); color: var(--accent); }

.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  display: none;
}

.feedback.show { display: block; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--accent-soft); color: var(--accent); }

.feedback .ans { font-family: var(--serif); font-size: 18px; font-weight: 600; }

.drill-foot { margin-top: 18px; display: flex; gap: 9px; justify-content: flex-end; }

.score-panel { text-align: center; padding: 36px 18px; }

.score-panel .big {
  font-family: var(--serif);
  font-size: 60px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.score-panel .lbl { color: var(--muted); margin-bottom: 24px; }

/* ================================================================= 浮层 */

.pop {
  position: fixed;
  z-index: 60;
  max-width: 300px;
  padding: 10px 12px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.13s, transform 0.13s;
  pointer-events: none;
}

[data-theme="dark"] .pop { background: #322c26; color: var(--ink); }

.pop.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

.pop .pw { font-family: var(--serif); font-size: 17px; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.pop .pm { color: rgba(255, 255, 255, 0.55); font-size: 11.5px; margin-top: 2px; }
[data-theme="dark"] .pop .pm { color: var(--muted); }

.pop .say-inline {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
  transition: background 0.12s;
}

.pop .say-inline:hover { background: rgba(255, 255, 255, 0.28); }

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--surface);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  white-space: nowrap;
}

[data-theme="dark"] .toast { background: #322c26; color: var(--ink); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 目录抽屉 */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 45;
}

.scrim.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 84vw);
  background: var(--surface);
  border-right: 1px solid var(--line);
  transform: translateX(-102%);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  box-shadow: var(--shadow-lg);
}

.drawer.show { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

/* 底部导航（手机） */

.tabbar { display: none; }

@media (max-width: 639px) {
  .tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 40;
  }

  .tabbar button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 10px 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    transition: color 0.13s;
  }

  .tabbar button .ico { font-size: 15px; }
  .tabbar button[aria-selected="true"] { color: var(--accent); }
}

/* ================================================================= 补充件 */

/* 列表小标题 */
.list-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 9px;
  letter-spacing: 0.01em;
}

/* 译文说明：只在显示译文时出现 */
.tr-note { display: none; }
.sec.show-tr .tr-note { display: block; }

/* 语法卡页码 */
.gcard-head .pg {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 空状态 */
.deck-empty {
  text-align: center;
  padding: 56px 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* 卡片正面的朗读按钮不被「翻面」遮住 */
.fcard .face .speak-btn { z-index: 2; }

/* 减少动效 */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
