/* ==========================================================================
   一页纸 · 视觉系统
   纸 + 墨 + 荧光笔。不用大色块和大圆角堆层次，靠纸纹、细线、叠纸阴影。
   ========================================================================== */

:root {
  /* 纸面 */
  --bg: #f4f1ea;
  --bg-2: #ece8de;
  --paper: #fffdf8;
  --paper-2: #faf6ee;

  /* 墨色 */
  --ink: #1e1c19;
  --ink-2: #423d35;
  --ink-3: #6b6459;
  --muted: #8d8578;

  /* 线条 */
  --line: #e2dbcd;
  --line-2: #efeade;
  --line-strong: #cfc6b4;

  /* 强调 */
  --accent: #2f6b57;
  --accent-2: #245546;
  --accent-soft: #e4efe8;
  --marker: rgba(240, 192, 74, .42);
  --wrong: #a83c2c;
  --wrong-soft: #f8e9e5;
  --good: #2f6b57;
  --good-soft: #e4efe8;

  /* 立体 */
  --r-card: 14px;
  --r-ctl: 10px;
  --shadow-sheet:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 1px 1px rgba(30, 28, 25, .04),
    0 2px 4px -2px rgba(30, 28, 25, .06),
    0 18px 32px -26px rgba(30, 28, 25, .5);
  --shadow-pop:
    0 1px 2px rgba(30, 28, 25, .06),
    0 12px 28px -16px rgba(30, 28, 25, .35);

  --fs: 1;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  --bg: #151310;
  --bg-2: #100e0c;
  --paper: #201d19;
  --paper-2: #1a1815;

  --ink: #ece5d7;
  --ink-2: #c6bdab;
  --ink-3: #9b9282;
  --muted: #837a6b;

  --line: #2e2a24;
  --line-2: #262219;
  --line-strong: #3d382f;

  --accent: #85c3a5;
  --accent-2: #a5d6bd;
  --accent-soft: #22302a;
  --marker: rgba(240, 192, 74, .26);
  --wrong: #de8b7b;
  --wrong-soft: #2e211d;
  --good: #85c3a5;
  --good-soft: #22302a;

  --shadow-sheet:
    0 1px 0 rgba(255, 255, 255, .03) inset,
    0 1px 2px rgba(0, 0, 0, .4),
    0 18px 34px -26px rgba(0, 0, 0, .9);
  --shadow-pop:
    0 1px 2px rgba(0, 0, 0, .5),
    0 14px 30px -18px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--ink); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt" 1;
  overscroll-behavior-y: none;
}

/* 纸纹 + 轻微暗角，让纯色背景不那么"塑料" */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 180px 180px;
  opacity: .5;
  mix-blend-mode: multiply;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, transparent 55%, rgba(60, 50, 35, .06) 100%);
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .18; }
[data-theme="dark"] body::after { background: radial-gradient(120% 90% at 50% 0%, transparent 45%, rgba(0, 0, 0, .5) 100%); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ============================ 骨架 ============================ */
.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(158px + var(--safe-b));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(var(--bg) 68%, color-mix(in srgb, var(--bg) 0%, transparent));
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.12; font-weight: 650; letter-spacing: .06em; }
.brand-text small { font-weight: 400; font-size: 10.5px; color: var(--muted); letter-spacing: .18em; margin-top: 4px; }

.top-actions { display: flex; gap: 2px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--ink-3);
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }

/* ============================ 科目 ============================ */
.chips {
  display: flex;
  gap: 7px;
  padding: 4px 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 58px;
  z-index: 20;
  background: linear-gradient(var(--bg) 76%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .02em;
  white-space: nowrap;
  transition: border-color .16s, color .16s, background .16s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink-2); }
.chip[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.chip .n { opacity: .5; margin-left: 5px; font-size: 10.5px; font-variant-numeric: tabular-nums; }

/* ============================ 视图 ============================ */
.view { flex: 1; padding: 0 20px; }

/* 背诵页：卡片在剩余空间里垂直居中，操作按钮沉到底部 */
#view-study { display: flex; flex-direction: column; }
#view-study .card-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 220px;
}
#view-study .swipe-actions { margin-top: 6px; }

/* ============================ 背诵进度 ============================ */
.study-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0 14px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.study-progress .bar {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.study-progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink-3);
  border-radius: 99px;
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
#sectionTag { min-width: 62px; text-align: right; }

/* ============================ 卡片舞台 ============================ */
.card-stage {
  position: relative;
  touch-action: pan-y;
  padding-bottom: 14px;
}

.flashcard {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sheet);
  padding: 22px 22px 18px;
  animation: sheet-in .34s cubic-bezier(.2,.75,.3,1);
  will-change: transform, opacity;
}

/* 下面压着的一张纸：暗示还有下一张 */
.flashcard::before {
  content: "";
  position: absolute;
  left: 9px; right: 9px;
  bottom: -7px;
  height: 12px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 calc(var(--r-card) + 1px) calc(var(--r-card) + 1px);
  background: var(--paper-2);
  z-index: -1;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(9px) scale(.994); }
  to { opacity: 1; transform: none; }
}

.flashcard.dragging { cursor: grabbing; }
.flashcard.fly-left, .flashcard.fly-right {
  transition: transform .17s ease-out, opacity .17s ease-out;
}

.fc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }

.fc-tag {
  font-size: 10.5px;
  letter-spacing: .1em;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}
[data-theme="dark"] .fc-tag { border-color: #2b3a33; }

.fc-idx { font-size: 10.5px; color: var(--muted); margin-left: auto; letter-spacing: .04em; }

.fc-title {
  font-size: calc(21px * var(--fs));
  line-height: 1.5;
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0 0 4px;
  text-wrap: pretty;
  color: var(--ink);
}

.fc-body {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
  font-size: calc(15.5px * var(--fs));
  line-height: 1.95;
  color: var(--ink-2);
}

.fc-line { margin: 0 0 .55em; text-wrap: pretty; }
.fc-line:last-child { margin-bottom: 0; }

.fc-line.rule {
  margin-top: 1em;
  padding-top: .75em;
  border-top: 1px dashed var(--line);
}

/* 荧光笔：贴着字的下半部分，不是整块背景 */
em.hl {
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  box-shadow: inset 0 -.42em 0 var(--marker);
  border-radius: 2px;
  padding: 0 1px;
  margin: 0 -1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* 遮住关键词 */
.fc-body.masked .kw {
  color: transparent;
  box-shadow: none;
  background: var(--line);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.fc-body.masked .kw.kw-shown { color: var(--ink); background: none; box-shadow: inset 0 -.42em 0 var(--marker); }

.fc-foot { margin-top: 16px; display: flex; gap: 10px; align-items: center; }

.link-btn {
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--ink-3);
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.link-btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* 滑动时的印章（贴在卡片上，跟着一起动） */
.swipe-badge {
  position: absolute;
  top: 20px;
  z-index: 3;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .16em;
  opacity: 0;
  transition: opacity .12s ease, transform .12s ease;
  pointer-events: none;
  border: 1.5px solid currentColor;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
}
.swipe-badge.left { left: 16px; color: var(--wrong); transform: scale(.94) rotate(-7deg); }
.swipe-badge.right { right: 16px; color: var(--good); transform: scale(.94) rotate(7deg); }
.card-stage.swiping-left .swipe-badge.left { opacity: 1; transform: scale(1) rotate(-7deg); }
.card-stage.swiping-right .swipe-badge.right { opacity: 1; transform: scale(1) rotate(7deg); }

/* ============================ 左滑右滑按钮 ============================ */
.swipe-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
}

.swipe-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--paper);
  transition: transform .12s, border-color .16s, background .16s;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset;
}
.swipe-btn b { font-size: 15px; font-weight: 650; letter-spacing: .06em; }
.swipe-btn small { font-size: 10.5px; color: var(--muted); letter-spacing: .06em; }
.swipe-btn:active { transform: scale(.975); }

.swipe-btn.again { color: var(--wrong); border-color: color-mix(in srgb, var(--wrong) 26%, var(--line)); }
.swipe-btn.again:hover { background: var(--wrong-soft); }
.swipe-btn.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, var(--line)); }
.swipe-btn.good:hover { background: var(--good-soft); }
.swipe-btn.undo { color: var(--ink-3); background: transparent; box-shadow: none; min-width: 58px; }
.swipe-btn.undo b { font-size: 12.5px; font-weight: 500; }
.swipe-btn.undo:hover { border-color: var(--line-strong); color: var(--ink-2); }

/* ============================ 信息条 ============================ */
.meta-strip {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.meta-strip b { font-weight: 600; color: var(--ink-3); }
.meta-strip .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* ============================ 本节检查点 ============================ */
.checkpoint, .finish {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sheet);
  padding: 34px 26px 30px;
  text-align: center;
  animation: sheet-in .3s cubic-bezier(.2,.75,.3,1);
}

.cp-eyebrow {
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--accent-2);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.checkpoint h2, .finish h2 {
  font-size: 21px;
  margin: 0 0 10px;
  letter-spacing: .01em;
}
.checkpoint p, .finish p {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-3);
  margin: 0 auto 20px;
  max-width: 26em;
}
.cp-actions, .finish-actions { display: flex; flex-direction: column; gap: 9px; max-width: 300px; margin: 0 auto; }

.finish-mark {
  width: 46px; height: 46px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--accent);
  font-size: 20px;
}
.finish-sub { font-size: 12.5px; color: var(--muted); }

/* ============================ 题目 ============================ */
.qcard {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sheet);
  padding: 22px 22px 20px;
  animation: sheet-in .3s cubic-bezier(.2,.75,.3,1);
}
.qcard.inline { padding: 20px 20px 18px; }

.q-tag { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.q-kind {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--line-2);
  color: var(--ink-3);
}
.q-topic { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .03em; }

.q-stem {
  font-size: calc(16.5px * var(--fs));
  line-height: 1.8;
  font-weight: 550;
  color: var(--ink);
  text-wrap: pretty;
}

.blank {
  padding: 0 .3em;
  border-bottom: 1.5px solid var(--accent);
  color: transparent;
  user-select: none;
}
.blank.done {
  color: var(--accent-2);
  font-weight: 650;
  border-bottom-color: transparent;
  background: var(--accent-soft);
  border-radius: 3px;
}

.options { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: calc(14.5px * var(--fs));
  line-height: 1.65;
  color: var(--ink-2);
  transition: border-color .16s, background .16s, transform .1s;
}
.opt:active { transform: scale(.995); }
.opt .k {
  flex: 0 0 auto;
  width: 21px; height: 21px;
  display: grid; place-items: center;
  border-radius: 5px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.opt:hover:not(:disabled) { border-color: var(--line-strong); }
.opt:disabled { cursor: default; }

.opt.correct { border-color: var(--good); background: var(--good-soft); color: var(--ink); }
.opt.correct .k { background: var(--good); border-color: var(--good); color: var(--paper); }
.opt.wrong { border-color: var(--wrong); background: var(--wrong-soft); color: var(--ink); }
.opt.wrong .k { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.opt.dim { opacity: .45; }

.explain {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: calc(14px * var(--fs));
  line-height: 1.85;
  color: var(--ink-2);
}
.explain .verdict { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.explain .verdict.ok { color: var(--good); }
.explain .verdict.no { color: var(--wrong); }
.explain .ex-src { font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin: 0 0 8px; }

.quiz-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--muted);
  padding-bottom: 12px;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

.quizbar {
  position: fixed; left: 0; right: 0;
  bottom: calc(60px + var(--safe-b)); z-index: 44;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: var(--r-ctl);
  background: var(--ink);
  color: var(--bg);
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: .04em;
  transition: transform .12s, opacity .2s;
  box-shadow: 0 1px 0 rgba(255,255,255,.14) inset;
}
.btn-primary:active { transform: scale(.988); }
.btn-primary.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn-primary.ghost:hover { background: var(--paper); }

/* ============================ 空态 ============================ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 2;
}
.empty .big { font-size: 30px; margin-bottom: 10px; opacity: .35; }

.section-title {
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--muted);
  margin: 24px 0 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.section-title:first-child { margin-top: 6px; }

/* ============================ 错题 ============================ */
.wrong-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  margin-bottom: 9px;
  transition: border-color .16s;
}
.wrong-item:hover { border-color: var(--line-strong); }
.wrong-item .wt { font-size: 10.5px; color: var(--muted); margin-bottom: 6px; letter-spacing: .05em; }
.wrong-item .wq { font-size: 14px; line-height: 1.7; color: var(--ink-2); }
.wrong-item .wa { font-size: 12.5px; color: var(--accent-2); margin-top: 7px; }

/* ============================ 统计 ============================ */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 10px;
  text-align: center;
}
.stat .v { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .l { font-size: 10.5px; color: var(--muted); margin-top: 3px; letter-spacing: .06em; }

.chapter-row { margin-bottom: 15px; }
.chapter-row .cr-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 7px; }
.chapter-row .cr-head b { font-weight: 600; letter-spacing: .03em; }
.chapter-row .cr-head span { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chapter-row .bar { height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.chapter-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s; }

/* ============================ 底部导航 ============================ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 46;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 640px;
  margin: 0 auto;
  padding: 9px 12px calc(9px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 5px 0 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
  border-radius: 9px;
  position: relative;
  transition: color .18s;
}
.tab svg { width: 20px; height: 20px; }
.tab.is-active { color: var(--ink); }
.tab.is-active svg { stroke-width: 2; }

.badge {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(7px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--wrong);
  color: #fff;
  font-size: 9.5px;
  font-style: normal;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ============================ 弹层 ============================ */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(24, 20, 14, .4); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 640px;
  margin: 0 auto;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 22px calc(26px + var(--safe-b));
  max-height: 88dvh;
  overflow-y: auto;
  animation: slideUp .28s cubic-bezier(.2,.8,.25,1);
  box-shadow: 0 -20px 50px -30px rgba(0, 0, 0, .5);
}
@keyframes slideUp { from { transform: translateY(22px); opacity: .5; } }

.sheet-grip { width: 36px; height: 3px; border-radius: 99px; background: var(--line-strong); margin: 4px auto 14px; }
.sheet h2 { font-size: 16.5px; margin: 0 0 16px; letter-spacing: .04em; }

.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
}
.row.stacked { flex-direction: column; align-items: stretch; gap: 10px; }

.seg { display: flex; gap: 2px; background: var(--line-2); padding: 2px; border-radius: 8px; }
.seg button {
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--paper-2);
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: .03em;
}
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-ghost.danger { color: var(--wrong); }
.btn-ghost.primary { border-color: var(--accent); color: var(--accent-2); font-weight: 600; background: var(--accent-soft); }

.fineprint { font-size: 11px; line-height: 1.9; color: var(--muted); margin: 16px 0 0; }
.fineprint b { color: var(--ink-3); }
.fineprint.credit { font-size: 10.5px; opacity: .72; margin-top: 8px; }

/* 账号 */
.cloud-tip { display: block; font-size: 12px; line-height: 1.75; color: var(--muted); margin-bottom: 10px; }
.cloud-line { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; font-size: 13.5px; }
.cloud-line b { font-weight: 650; color: var(--ink); }
.cloud-sub { font-size: 11px; color: var(--muted); }

.auth-hint { font-size: 12px; line-height: 1.75; color: var(--muted); margin: -4px 0 16px; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: .08em; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }

.auth-switch { display: block; margin: 14px auto 0; color: var(--ink-3); font-size: 12.5px; }
.auth-switch:hover { color: var(--accent-2); }

/* ============================ 搜索 ============================ */
.search-wrap { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: flex; flex-direction: column; }
.search-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: var(--bg);
}
.search-head input {
  flex: 1;
  padding: 10px 13px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  outline: none;
}
.search-head input:focus { border-color: var(--accent); }
.text-btn { font-size: 12.5px; color: var(--accent-2); padding: 6px; }

.search-results { overflow-y: auto; padding: 12px 20px 40px; flex: 1; max-width: 640px; margin: 0 auto; width: 100%; }

.sr {
  display: block; width: 100%; text-align: left;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--paper);
  margin-bottom: 8px;
}
.sr:hover { border-color: var(--line-strong); }
.sr .srt { font-size: 13px; font-weight: 650; display: flex; gap: 8px; align-items: center; letter-spacing: .02em; }
.sr .srt i { font-style: normal; font-size: 9.5px; color: var(--muted); font-weight: 500; letter-spacing: .1em; }
.sr .srs {
  font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sr mark { background: none; color: var(--ink); box-shadow: inset 0 -.42em 0 var(--marker); border-radius: 2px; }

/* ============================ toast ============================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + var(--safe-b));
  transform: translate(-50%, 10px);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 17px;
  border-radius: 8px;
  font-size: 12.5px;
  letter-spacing: .03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 100;
  max-width: 88vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow-pop);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 700px) {
  .view { padding: 0 24px; }
  .flashcard { padding: 26px 28px 22px; }
  .qcard { padding: 26px 28px 24px; }
}

@media (max-width: 400px) {
  .topbar { padding: 13px 16px 8px; }
  .chips { padding: 4px 16px 10px; }
  .view { padding: 0 16px; }
  .flashcard { padding: 18px 17px 15px; }
  .qcard { padding: 17px 16px 15px; }
  .fc-title { font-size: calc(19px * var(--fs)); }
  .fc-body { font-size: calc(14.8px * var(--fs)); }
  .q-stem { font-size: calc(15.8px * var(--fs)); }
  .opt { padding: 11px 12px; font-size: calc(14px * var(--fs)); }
  .meta-strip { gap: 10px; font-size: 10px; }
  .swipe-btn b { font-size: 14px; }
  .swipe-btn small { font-size: 9.5px; }
  .stat .v { font-size: 20px; }
  .stat-grid { gap: 7px; }
}
