/* ==========================================================
   抽背 —— 视觉规范参照 Apple Human Interface Guidelines
   原则：一个强调色、一种层级、留白代替装饰
   · 字体：SF Pro / 苹方，沿用 iOS 标准字阶
   · 配色：中性灰阶为主，systemBlue 只用于可点击处
   · 控件：插入式分组列表、圆角卡片、底部 Sheet
   ========================================================== */

:root {
  color-scheme: light dark;

  /* 文字层级 */
  --label:        #000000;
  --label-2:      rgba(60, 60, 67, .60);
  --label-3:      rgba(60, 60, 67, .30);

  /* 背景层级 */
  --bg-grouped:   #f2f2f7;   /* systemGroupedBackground */
  --bg-card:      #ffffff;   /* secondarySystemGroupedBackground */
  --bg-sheet:     #f2f2f7;

  /* 分隔线与按压填充 */
  --separator:    rgba(60, 60, 67, .29);
  --fill:         rgba(120, 120, 128, .12);
  --fill-press:   rgba(120, 120, 128, .20);

  /* 强调色：蓝色代表"可点"，其余三色只用于自评语义 */
  --blue:         #007aff;
  --green:        #34c759;
  --orange:       #ff9500;
  --red:          #ff3b30;

  /* 圆角（iOS 标准值） */
  --r-card:       12px;
  --r-button:     12px;
  --r-sheet:      16px;
  --r-quiz-card:  20px;        /* 主卡片比列表更大一档，突出层级 */

  --pad:          16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-grouped);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;              /* iOS Body */
  line-height: 1.47;
  letter-spacing: -.01em;       /* SF Pro 的紧字距观感 */
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

/* 只给读屏用的文字：不能用 display:none 或 visibility:hidden —— 那样读屏也读不到。
   压成 1px 并裁掉，元素仍在无障碍树里。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ============ 键盘焦点 ============ */
/* 用 :focus-visible 而非 :focus：鼠标点击不该留下焦点环，键盘 Tab 必须留。
   .cb 用了 appearance:none，系统焦点环随之消失，所以这里必须补回来，
   否则 Tab 走一遍首页看不出光标在哪。 */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}
.cb:focus-visible { outline-offset: 3px; border-radius: 50%; }
.icon-btn:focus-visible { outline-offset: -3px; border-radius: 50%; }
.rate:focus-visible,
.sheet-btns-col .btn:focus-visible { outline-offset: -3px; border-radius: 0; }
.btn-lg:focus-visible { outline-offset: 3px; border-radius: var(--r-button); }

.view {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad) max(20px, env(safe-area-inset-bottom));
}

/* ============ 通用按钮 ============ */
/* 只保留两级：Filled（本页唯一主操作）与 Plain（其余全部为文字按钮） */
.btn {
  border: 0;
  background: none;
  color: var(--blue);
  border-radius: var(--r-button);
  padding: 14px 20px;
  font-size: 17px;
  transition: opacity .15s;
}
.btn:active { opacity: .4; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  font-weight: 590;            /* SF Pro Semibold */
}
.btn-primary:disabled {
  background: var(--fill);
  color: var(--label-3);
  cursor: not-allowed;
  opacity: 1;
}
/* Plain：无底色，只靠蓝字表示可点 */
.btn-ghost { color: var(--blue); }
.btn-danger { color: var(--red); }
.btn-lg { width: 100%; padding: 16px; font-weight: 590; }

.link-btn {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--blue);
  font-size: 15px;
}
.link-btn:active { opacity: .4; }

.icon-btn {
  border: 0;
  background: none;
  width: 44px;                 /* iOS 最小可点区域 */
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  color: var(--blue);
  display: grid;
  place-items: center;
  transition: opacity .15s;
}
.icon-btn:active { opacity: .35; }
/* 没有上一题可回时置灰但保留占位 —— 图标忽隐忽现会让整条导航栏跟着跳。 */
.icon-btn:disabled {
  color: var(--label-3);
  cursor: not-allowed;
  opacity: 1;
}
/* ============ 首页 · 大标题栏 ============ */
/* 参照 iOS Large Title Navigation Bar */
.home-head { padding: 14px 0 22px; }
.home-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.home-head h1 {
  margin: 0;
  font-size: 34px;             /* iOS Large Title */
  font-weight: 700;
  letter-spacing: -.026em;
  line-height: 1.12;
}
.home-head .sub {
  margin: 4px 0 0;
  color: var(--label-2);
  font-size: 15px;             /* iOS Subheadline */
  letter-spacing: -.01em;
}

/* 工具入口降为文字按钮，不与主操作抢注意力 */
.home-tools { display: flex; gap: 18px; flex: 0 0 auto; }
.tool-btn {
  border: 0;
  background: none;
  padding: 2px 0;
  font-size: 17px;
  color: var(--blue);
  white-space: nowrap;
  transition: opacity .15s;
}
.tool-btn:active { opacity: .4; }

/* ============ 首页 · 分组列表 ============ */
.scope { flex: 1; }
.scope-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 8px;
}
.scope-title {
  font-size: 13px;             /* iOS Footnote，分组标题 */
  font-weight: 400;
  color: var(--label-2);
  letter-spacing: -.005em;
}
.scope-actions { display: flex; gap: 18px; }

/* 整个科目列表是一张圆角卡片，内部用分隔线切分 */
#subject-list {
  background: var(--bg-card);
  border-radius: var(--r-card);
  overflow: hidden;
}
.subject + .subject .subject-row { border-top: .5px solid var(--separator); }

/* 题库加载失败时占据科目列表的位置。整张卡片就这一段字，
   给足内边距免得贴边，字号比正文小一档 —— 它是故障说明，不是内容。 */
#subject-list.load-error {
  padding: 18px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--label-3);
}

.subject-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: background .12s;
}
.subject-row:active { background: var(--fill); }
.subject-row .name {
  flex: 1;
  font-size: 17px;
  letter-spacing: -.01em;
}
.subject-row .count,
.chapter-row .count {
  color: var(--label-3);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}
/* 「已背会 / 总数」：分子是进度、分母是题库属性，故分子提亮一档。
   一道都没背会时整个分数保持灰色，不去强调那个 0。 */
.count.has-done b { color: var(--green); font-weight: 590; }

/* Disclosure indicator：iOS 的 chevron */
.caret {
  border: 0;
  background: none;
  padding: 6px 2px 6px 10px;
  color: var(--label-3);
  font-size: 15px;
  font-weight: 600;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.caret[aria-expanded="true"] { transform: rotate(90deg); }

/* 编标题：章节列表里的分组说明，不可勾选，只作结构提示。
   用插入式列表的分组标题规格（13px 二级灰 + 灰底），与首页「抽题范围」同一档。 */
.part-row {
  padding: 7px 16px 6px 50px;
  background: var(--bg-grouped);
  border-top: .5px solid var(--separator);
  color: var(--label-2);
  font-size: 13px;
  letter-spacing: -.005em;
}

/* 子层级不换底色，只靠缩进区分 */
.chapter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px 11px 50px;
  min-height: 44px;
  cursor: pointer;
  border-top: .5px solid var(--separator);
}
.chapter-row:active { background: var(--fill); }
.chapter-row .name {
  flex: 1;
  font-size: 16px;
  color: var(--label-2);
  letter-spacing: -.01em;
}
/* ============ 勾选框 ============ */
/* 参照 iOS 圆形勾选标记（systemBlue 填充 + 白色对勾） */
.cb {
  appearance: none;
  margin: 0;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1.5px solid var(--label-3);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s;
}
.cb:checked, .cb:indeterminate {
  background: var(--blue);
  border-color: var(--blue);
}
.cb:checked::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.cb:indeterminate::after {
  content: '';
  width: 10px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

/* ============ 「还没背会」入口 ============ */
.wrong-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--r-card);
}
.wrong-info {
  flex: 1;
  font-size: 15px;
  color: var(--label-2);
  letter-spacing: -.01em;
}
.wrong-info strong {
  color: var(--label);
  font-size: 17px;
  font-weight: 590;
  font-variant-numeric: tabular-nums;
}
.wrong-entry .btn { padding: 6px 0; flex: 0 0 auto; }

/* 底部这一块吸底。
   首页高度是会变的：展开某一科的章节、出现「还没背会」那张卡、切到自定义题量，
   每一样都往下顶。实测 SE 一档（可视高 580px）三样凑齐时「开始抽背」被顶出屏幕
   92px —— 主操作得先滚动才按得到。吸底后不论列表多长它都在原处。
   底色必须实心，否则滚动的列表会从按钮底下透出来。
   下方留白从 .view 挪到这里：吸住时 .view 的 padding 在屏幕外，垫不出安全区。 */
#view-home { padding-bottom: 0; }
.home-foot {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-top: 12px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--bg-grouped);
}
/* 上沿加一段渐隐，让列表是「滑到按钮下面去」而不是被生硬切断。 */
.home-foot::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 16px;
  background: linear-gradient(to top, var(--bg-grouped), transparent);
  pointer-events: none;
}
.pool-hint {
  text-align: center;
  color: var(--label-2);
  font-size: 13px;
  padding-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

/* ============ 每轮题量 · 分段控件 ============ */
/* 参照 iOS Segmented Control：灰槽 + 白色滑块，选中项抬起一层。
   放在「开始抽背」上方、池子提示之前 —— 它是对主操作的限定，不是独立功能。 */
.size-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px 14px;
}
.size-label {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--label-2);
  letter-spacing: -.005em;
}
.seg {
  flex: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--fill);
  border-radius: 9px;
}
.seg-btn {
  border: 0;
  background: none;
  padding: 6px 4px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--label);
  font-variant-numeric: tabular-nums;
  transition: background .15s, box-shadow .15s;
}
/* 选中项用白色滑块抬起，而不是蓝底 —— 蓝色在这一页只留给「开始抽背」。 */
.seg-btn[aria-checked="true"] {
  background: var(--bg-card);
  font-weight: 590;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
}
.seg-btn:focus-visible { outline-offset: -2px; border-radius: 7px; }

/* 自定义题量的输入行。只在选中「自定义」那一格时才出现，
   平时不占高度 —— 矮屏首页的余量只有几十像素。 */
.size-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 2px 12px;
  font-size: 13px;
  color: var(--label-2);
}
.size-custom input {
  width: 76px;
  border: 0;
  background: var(--fill);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 15px;
  color: var(--label);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.size-custom input:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
/* 数字输入框右侧的上下箭头在手机上点不准，且会挤掉本就不宽的输入区。 */
.size-custom input::-webkit-outer-spin-button,
.size-custom input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.size-custom input[type="number"] { -moz-appearance: textfield; }

@media (prefers-color-scheme: dark) {
  /* 深色下白滑块要提一档才看得出，投影几乎无效，改用更亮的底色区分。 */
  .seg-btn[aria-checked="true"] {
    background: #636366;
    box-shadow: none;
  }
  /* 深色下 --fill 与卡片底色几乎同色，输入框会看不出边界。 */
  .size-custom input { background: rgba(120, 120, 128, .32); }
}

/* ============ 快捷键提示 ============ */
/* 仅在存在真实鼠标/触控板时显示，手机与平板隐藏 */
.rate-key { display: none; }

@media (hover: hover) and (pointer: fine) {
  .rate-key {
    display: block;
    font-size: 12px;
    color: var(--label-3);
    font-weight: 400;
  }
  .key-inline {
    display: inline;
    margin-left: 6px;
    color: var(--label-3);
    font-size: 12px;
  }
}
/* ============ 抽背页 ============ */
/* 整页定高不滚动：头部与自评条钉死，只有卡片内部滚动。
   这样自评按钮永远在拇指位置，长题也不会把它顶到屏幕外。 */
#view-quiz {
  height: 100%;
  height: 100dvh;              /* 移动端浏览器地址栏收放时不跳动 */
  max-height: 100dvh;
  overflow: hidden;
  padding-top: max(2px, env(safe-area-inset-top));
}

/* 左侧一个返回、右侧两个动作，两边宽度不等。
   用 1fr auto 1fr 的三栏栅格，计数器永远落在屏幕正中，不随右侧按钮增减而偏移。 */
.quiz-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin: 0 -10px;
  min-height: 40px;            /* 顶部只占一条导航栏，不留额外空档 */
}
.quiz-head > .icon-btn { justify-self: start; }
.quiz-actions {
  justify-self: end;
  display: flex;
  align-items: center;
}
.quiz-progress {
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  color: var(--label-2);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.mode-tag {
  color: var(--orange);
  font-size: 14px;
}
.mode-tag::after {
  content: '·';
  margin-left: 8px;
  color: var(--label-3);
}

/* ---- 卡片区 ----
   卡片高度贴合内容，但有下限高度：题目间尺寸稳定，形成栅格感，
   短题也不会缩成一条，长题按内容长高直到填满可用空间。
   卡片在 region 内居中，region 的下内边距再把它整体上提，
   使标题组落在视觉黄金区（约 40% 高处）而不是几何中线。
   偏移量放在 region 上而非卡片内部，因此不计入 scrollHeight，
   不会与溢出判定互为因果。 */
.card-region {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  padding-bottom: clamp(10px, 4.5vh, 42px);
}

/* 卡片贴合内容但有下限高度，避免忽大忽小。内容居中排版，故上下内边距接近对称，
   仅下方多留 8px 作光学补偿（视觉重心略高于几何中心才显得稳）。
   两处内边距都是常量，不随溢出状态变化，故不影响 scrollHeight 判定。 */
.card {
  flex: 0 1 auto;
  width: 100%;
  min-height: clamp(200px, 40vh, 360px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--r-quiz-card);
  padding: 34px 22px 42px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.card::-webkit-scrollbar { display: none; }

/* 溢出提示：卡片底部渐隐到卡片自身底色，暗示"还有下文"。
   用绝对定位覆盖层而非 mask，卡片的圆角与底色才不会一起被吃掉。
   卡片高度不定，故渐隐层跟着卡片底边定位（由 JS 写入 --card-bottom）。 */
.card-region::after {
  content: '';
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: var(--card-bottom, 0px);
  height: 46px;
  border-radius: 0 0 var(--r-quiz-card) var(--r-quiz-card);
  background: linear-gradient(to bottom, transparent, var(--bg-card) 70%);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.card-region.has-more::after { opacity: 1; }

/* margin:auto 在有余量时把内容居中，无余量时按规范归零 —— 长内容不会被裁掉顶部
   （justify-content:center 做不到，那样会把溢出的顶部推到滚动区外）。
   auto 外边距不计入 scrollHeight，所以不干扰溢出判定。 */
.card-body {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;             /* 居中轴线：徽章、章节、标题共用一条中线 */
}

/* ---- 标题信息组 ----
   居中两层：一行「科目 · 编 · 章」的定位行，下面是主标题。
   定位行整体弱化到二级灰，只作定位用，不与标题争视觉。 */
.tag-chapter {
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 400;
  color: var(--label-2);
  letter-spacing: .04em;
}

/* ---- 题干字号按字数反向分档 ----
   短题必须够大才压得住四周留白，长题必须够小才不会变成一堵墙。
   字号同时随视口高度浮动。居中排版行距要比左对齐更开，否则两行会糊成一块。 */
.card-q {
  margin: 0;
  font-size: clamp(27px, 4.5vh, 34px);
  line-height: 1.44;
  font-weight: 700;
  letter-spacing: -.026em;
  text-wrap: balance;          /* 短句按语义断行，不留孤字 */
}
/* ≤8 字：当作大标题处理，撑满一到两行 */
.card-q.q-short {
  font-size: clamp(32px, 5.6vh, 42px);
  line-height: 1.32;
  letter-spacing: -.03em;
}
.card-q.q-long {
  font-size: clamp(23px, 3.6vh, 28px);
  line-height: 1.5;
  text-wrap: pretty;
}
.card-q.q-xlong {
  font-size: clamp(20px, 3vh, 24px);
  line-height: 1.56;
  letter-spacing: -.018em;
  text-wrap: pretty;
}
/* 超长题干退化为"读文章"：字重降到 600，行距放开，改左对齐——
   居中排版超过四行就会因为每行起点不齐而难读。 */
.card-q.q-huge {
  font-size: clamp(18px, 2.6vh, 21px);
  line-height: 1.62;
  font-weight: 600;
  letter-spacing: -.01em;
  text-align: left;
  text-wrap: pretty;
}

/* 笔记是成段文字，一律左对齐；分隔线撑满卡片宽度 */
.card-note {
  align-self: stretch;
  margin-top: 24px;
  padding-top: 16px;
  border-top: .5px solid var(--separator);
  color: var(--label-2);
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  white-space: pre-wrap;
}

/* ============ 自评按钮 ============ */
/* 三个自评并进同一张白卡，用发丝线切成三格 —— 与首页的分组列表同一套组件语言。
   卡片本身不着色，只有文字带语义色，所以整体权重仍低于题干标题。 */
.rate-bar {
  flex: 0 0 auto;
  padding-top: 4px;
}
.rate-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-card);
  border-radius: var(--r-card);
  overflow: hidden;
}
.rate {
  border: 0;
  background: none;
  padding: 15px 6px 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 500;
  transition: background .12s;
}
.rate + .rate { box-shadow: inset .5px 0 0 var(--separator); }
.rate:active { background: var(--fill-press); }
.rate-label { font-size: 17px; font-weight: 600; }
.rate-bad  { color: var(--red); }
.rate-mid  { color: var(--orange); }
.rate-good { color: var(--green); }

.skip-btn {
  display: block;
  margin: 10px auto 0;
  color: var(--label-2);
  font-size: 14px;
}

/* ============ 底部 Sheet ============ */
/* 参照 iOS Modal Sheet：底部升起、顶部圆角、抓手条 */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fade .25s ease-out;
}
.sheet {
  position: relative;
  background: var(--bg-sheet);
  width: 100%;
  max-width: 540px;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 24px var(--pad) max(16px, env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slide-up .32s cubic-bezier(.32, .72, 0, 1);
}
/* 抓手条（grabber） */
.sheet::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 5px;
  background: var(--label-3);
  border-radius: 3px;
}
.sheet h3 {
  margin: 2px 0 6px;
  font-size: 22px;             /* iOS Title 2 */
  font-weight: 700;
  letter-spacing: -.024em;
  text-align: center;
}
.sheet-sub {
  margin: 0 0 18px;
  color: var(--label-2);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}
.sheet textarea {
  display: block;
  width: 100%;
  border: 0;
  background: var(--bg-card);
  border-radius: var(--r-card);
  padding: 14px;
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
  color: var(--label);
  resize: vertical;
}
.sheet textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
/* 「还能写 N 字」。默认不显示（app.js 只在快满时才 hidden=false），所以这一格
   出现本身就是信号，不必再配图标。右对齐贴着输入框右下角 —— 数字跟着一起长，
   居中的话每敲一个字整行都在动。tabular-nums 同理：不等宽数字会让这一行抖。 */
.note-count {
  margin: 6px 2px 0;
  text-align: right;
  font-size: 13px;
  color: var(--label-3);
  font-variant-numeric: tabular-nums;
}
/* 真写满了才变橙。橙色在这套配色里是「模糊 / 注意」，不是「错」——
   写满不是个错误，只是不能再写了，用 --red 就过重了。 */
.note-count.is-full { color: var(--orange); }

/* 说明页正文。别处的 sheet 内容都是居中的短句，这里是成段的解释，
   居中读起来费劲，故左对齐并把行高放宽一档。 */
.help-body {
  text-align: left;
  font-size: 15px;
  line-height: 1.62;
  color: var(--label-2);
}
.help-body h4 {
  margin: 22px 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.014em;
  color: var(--label);
}
.help-body h4:first-child { margin-top: 4px; }
.help-body p { margin: 0 0 8px; }
.help-body p:last-child { margin-bottom: 0; }
/* 关键词加重但不变色：这一屏里已经有绿色分数和蓝色按钮了，再加一种颜色就花了。 */
.help-body b { color: var(--label); font-weight: 600; }

/* 说明页开头的致谢和结尾的入群邀请。这两段不是操作说明，是写给人看的话，
   所以给一层浅底色和圆角，把它们和中间的「什么叫背会」在视觉上分开 ——
   照着 iOS 分组列表的做法，用底色分区而不是加线或换字色。
   不用 --fill：深色下 --fill 和卡片底色几乎同色（同 .size-custom input 那条注释）。 */
.help-body .help-hello {
  margin: 4px 0 6px;
  padding: 14px;
  border-radius: var(--r-card);
  background: rgba(120, 120, 128, .10);
}
.help-body .help-hello p:last-child { margin-bottom: 0; }
/* 第一句单独提一档字号并转成正文色：整份说明里就这一句是「标题」的分量，
   但它不该用 h4 —— 它不是一节的名字，下面没有属于它的内容。 */
.help-body .hello-lead {
  color: var(--label);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}
/* 底色块里的小标题不需要上方那 22px 留白，padding 已经把它顶开了。 */
.help-body .hello-h4 { margin-top: 0; }
.help-body .hello-foot {
  margin-top: 10px;
  text-align: right;
  color: var(--label-3);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  /* 深色下 10% 的灰几乎看不见，提到 18%。 */
  .help-body .help-hello { background: rgba(120, 120, 128, .18); }
}
/* 补充说明比正文再轻一档，缩进并加一道竖线，读的时候可以跳过。
   说明页现在不用它了：每节的第四段讲的是笔记 1000 字上限、别倒着用 Anki
   这类要紧事，竖线加浅字看上去像可跳过的注脚，反而不该用这个样式。
   规则留着，别处（后加的小节）还可能需要「这一段可以跳过」这个层级。 */
.help-body .help-note {
  margin: 10px 0 8px;
  padding-left: 10px;
  border-left: 2px solid var(--separator);
  color: var(--label-3);
  font-size: 14px;
}

/* 底部动作区：一条分隔线之上排文字按钮，主操作加粗 */
.sheet-btns {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 8px;
  border-top: .5px solid var(--separator);
}
.sheet-btns .btn { flex: 1; }
.sheet-btns-col {
  flex-direction: column;
  gap: 0;
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
  background: var(--bg-card);
  border-radius: var(--r-card);
  overflow: hidden;
}
.sheet-btns-col .btn { text-align: center; }
.sheet-btns-col .btn + .btn { border-top: .5px solid var(--separator); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@media (min-width: 640px) {
  .sheet-mask { align-items: center; }
  .sheet {
    border-radius: var(--r-sheet);
    animation: pop .25s cubic-bezier(.32, .72, 0, 1);
  }
  .sheet::before { display: none; }
  @keyframes pop {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1); }
  }
}
/* ============ 本轮成绩 ============ */
/* 会 / 模糊 / 不会 三个数字放进同一张卡片，用细分隔线切分，不做三块浮岛 */
.stat-top {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-card);
  border-radius: var(--r-card);
  overflow: hidden;
  margin-bottom: 4px;
}
.stat-cell {
  text-align: center;
  padding: 16px 4px;
}
.stat-cell + .stat-cell { box-shadow: inset .5px 0 0 var(--separator); }
.stat-cell .num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.024em;
  font-variant-numeric: tabular-nums;
}
.stat-cell .cap {
  font-size: 13px;
  color: var(--label-2);
  margin-top: 2px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(40px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .8);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  font-size: 15px;
  font-weight: 400;
  padding: 11px 20px;
  border-radius: 22px;
  z-index: 90;
  animation: rise .25s cubic-bezier(.32, .72, 0, 1);
  pointer-events: none;
}
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 10px) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ============ 深色模式 ============ */
/* 跟随系统设置，配色取自 iOS Dark Mode 系统色 */
@media (prefers-color-scheme: dark) {
  :root {
    --label:       #ffffff;
    --label-2:     rgba(235, 235, 245, .60);
    --label-3:     rgba(235, 235, 245, .30);
    --bg-grouped:  #000000;
    --bg-card:     #1c1c1e;
    --bg-sheet:    #1c1c1e;
    --separator:   rgba(84, 84, 88, .60);
    --fill:        rgba(118, 118, 128, .18);
    --fill-press:  rgba(118, 118, 128, .32);
    --blue:        #0a84ff;
    --green:       #30d158;
    --orange:      #ff9f0a;
    --red:         #ff453a;
  }
  /* Sheet 与卡片同色时，卡片提一档避免糊在一起 */
  .sheet { background: #1c1c1e; }
  .sheet .stat-top,
  .sheet textarea,
  .sheet-btns-col { background: #2c2c2e; }
  .toast { background: rgba(58, 58, 60, .9); }
}

/* ============ 小屏适配 ============ */
@media (max-width: 380px) {
  .home-head h1 { font-size: 30px; }
  .tool-btn { font-size: 16px; }
  .home-tools { gap: 14px; }
  /* 窄屏每行装的字更少，整体再降一档，避免长题变成一堵墙 */
  .card-q          { font-size: clamp(25px, 4.3vh, 30px); }
  .card-q.q-short  { font-size: clamp(30px, 5.4vh, 38px); }
  .card-q.q-long   { font-size: clamp(22px, 3.4vh, 26px); }
  .card-q.q-xlong  { font-size: clamp(19px, 2.9vh, 22px); }
  .card-q.q-huge   { font-size: clamp(17px, 2.5vh, 20px); }
}

/* 横屏或矮窗口：垂直空间紧张时压缩上下留白与标题组内的间距 */
@media (max-height: 560px) {
  .card-region { padding-bottom: 8px; }
  .card { min-height: 0; padding: 18px 18px 20px; }
  .tag-chapter { margin-bottom: 10px; }
  .rate { padding: 11px 6px 9px; }
  .skip-btn { margin-top: 6px; }
}

/* 矮屏首页：底部吸底后主按钮不会再被顶出屏幕，但可视区本就小，
   留白仍要收一档，否则章节列表只剩两三行可见。 */
@media (max-height: 700px) {
  .home-head { padding: 8px 0 12px; }
  .scope-bar { padding-bottom: 4px; }
  .home-foot { padding-top: 10px; }
  .size-bar { padding-bottom: 10px; }
  .size-custom { padding-bottom: 8px; }
  .pool-hint { padding-bottom: 8px; }
  .wrong-entry { margin-top: 12px; padding: 11px 16px; }
}

/* ============ 降低动态效果 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
