/* 沿用生词本的色板、内容边界和控件尺寸，保留说写的阅读结构。 */
:root {
  --content-width: 1120px;
  --chrome: color-mix(in srgb, var(--surface) 88%, transparent);
  --chrome-shadow: 0 6px 22px rgb(20 30 50 / 9%);
  scrollbar-gutter: stable;
  scroll-padding-top: 96px;
}
body { min-width: 0; min-height: 100svh; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button {
  transition: transform 140ms var(--ease), background-color 160ms ease-out, color 160ms ease-out, border-color 160ms ease-out;
}
button:active:not(:disabled):not(:focus-visible) { transform: scale(.97); }
input, textarea { caret-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: 1; }
.skip { z-index: 50; }
.topbar, body:has(#library:not([hidden])) .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  width: min(var(--content-width), calc(100% - 32px));
  max-width: none;
  height: 80px;
  min-height: 80px;
  padding: 18px 20px;
  align-items: center;
  gap: 24px;
  background: transparent;
  transition: transform 240ms var(--ease), border-radius 240ms var(--ease), background-color 180ms ease, box-shadow 240ms var(--ease);
}
.topbar[data-floating='true'], body:has(#library:not([hidden])) .topbar[data-floating='true'] {
  transform: translateY(12px);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(20 30 50 / 14%);
}
@supports (backdrop-filter: blur(16px)) {
  .topbar[data-floating='true'], body:has(#library:not([hidden])) .topbar[data-floating='true'] {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
  }
}
#brand {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  min-height: 44px;
}
.phosphor-icon { fill: currentColor; stroke: none; }
#brand svg { box-sizing: content-box; padding: 7px; border-radius: 10px; color: var(--accent-ink); background: var(--soft); }
.topbar-actions { grid-column: 3; grid-row: 1; justify-self: end; display: flex; align-items: center; gap: 8px; }
#settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  transition: transform 140ms var(--ease), background-color 180ms ease, color 180ms ease;
}
#settings svg { width: 18px; height: 18px; }
#exit { grid-column: 1; grid-row: 1; justify-self: start; }
#mode-name { position: static; grid-column: 2; grid-row: 1; transform: none; }
.page-nav { grid-column: 2; grid-row: 1; display: flex; gap: 6px; align-items: center; justify-content: center; }
.page-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  transition: transform 140ms var(--ease), background-color 180ms ease, color 180ms ease;
}
.page-nav button > svg { display: none; }
.page-nav button[aria-current='page'] { color: var(--surface); background: var(--accent); border-color: var(--accent); }
.page-nav button:active:not(:disabled):not(:focus-visible), #settings:active:not(:disabled):not(:focus-visible) { transform: none; }
.topbar :is(button, a):focus-visible { outline-offset: 4px; }
main { width: min(784px, calc(100% - 32px)); max-width: none; padding: 0 20px 40px; }
main:has(#library:not([hidden])) { width: min(var(--content-width), calc(100% - 32px)); max-width: none; padding: 0 20px 40px; }
#home { margin-top: clamp(48px, 10svh, 100px); }
#home h1 { font-size: 32px; line-height: 1.25; margin-bottom: 32px; }
.training button { min-height: 76px; border-radius: 14px; }
.scope-options { padding: 4px; border: 0; background: #eef0f4; border-radius: 14px; }
.scope-options label { border-radius: 10px; }
.scope-options label:has(input:checked) { background: var(--surface); box-shadow: 0 2px 5px rgb(20 30 50 / 6%); }
#begin { min-height: 52px; margin-top: 28px; }
#library { margin-top: 24px; }
.library-head { margin-bottom: 24px; }
.library-head h1 { font-size: 32px; }
.library-layout { grid-template-columns: minmax(260px, 29%) minmax(0, 1fr); }
.library-index { top: 96px; }
#library-list { max-height: calc(100dvh - 180px); }
.part-switch { padding: 4px; border-radius: 14px; background: #eef0f4; }
.part-switch button { border-radius: 10px; }
.part-switch button[aria-pressed='true'] { background: var(--surface); box-shadow: 0 2px 5px rgb(20 30 50 / 6%); }
.library-query { border-radius: 12px; }
.library-reading { scroll-margin-top: 96px; }
.library-detail { padding: 28px 32px 40px; }
.library-detail-nav { padding-inline: 24px; }
.detail-title { font-size: clamp(24px, 2.2vw, 28px); }
.full-answer { line-height: 1.85; }
.answer-keypoints { line-height: 1.9; }
.study-section :is(h3, h4, h5) { font-size: 15px; }
.editable-section-head { flex-wrap: wrap; row-gap: 0; }
.section-edit { margin-left: auto; }
.editor-actions { justify-content: space-between; }
.editor-actions > .primary { min-width: 100px; }
.library-row { border-radius: 10px; }
.library-row[aria-current='true'] { background: var(--soft); }
.reference-popup { scroll-padding: 16px; }
dialog { scroll-padding: 20px; }
@media (hover: hover) and (pointer: fine) {
  .page-nav button:hover:not([aria-current='page']) { background: var(--soft); color: var(--accent-ink); }
  .page-nav button[aria-current='page']:hover { background: var(--accent-deep); color: var(--surface); }
  #settings:hover { background: var(--soft); color: var(--accent-ink); }
}
/* 触屏不留下鼠标悬停样式，选中与按压状态仍清楚可见。 */
@media (hover: none) {
  .icon:hover { background: none; color: var(--muted); }
  .quiet:hover:not(:disabled) { background: none; color: var(--muted); }
  .primary:hover:not(:disabled) { background: var(--accent); }
  .secondary:hover:not(:disabled) { border-color: var(--line); background: var(--surface); color: var(--muted); }
  .library-row:hover:not([aria-current='true']) { background: none; }
  .text-link:hover { text-decoration: none; }
  .part-switch button:hover:not([aria-pressed='true']) { background: none; color: var(--muted); }
  .training button:hover:not([aria-pressed='true']) { background: var(--surface); }
  .scope-options label:hover:not(:has(input:checked)) { background: none; color: var(--muted); }
}
@media (max-width: 1000px) {
  .library-toolbar { flex-wrap: wrap; gap: 12px; }
  .library-query { flex-grow: 1; }
}
@media (max-width: 900px) {
  .library-layout { grid-template-columns: 1fr; }
  .library-index { position: static; }
  #library-list { max-height: none; padding-right: 0; }
  .library-reading { scroll-margin-top: 96px; }
  .library-detail-nav { top: 96px; }
  .library-head { margin-bottom: 20px; }
}
/* 手机主入口下沉到拇指区；列表与正文各占完整宽度。 */
@media (max-width: 767px) {
  :root {
    --safe-left: max(16px, env(safe-area-inset-left));
    --safe-right: max(16px, env(safe-area-inset-right));
    --safe-top: max(12px, env(safe-area-inset-top));
    scroll-padding-top: 80px;
    scrollbar-gutter: auto;
  }
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .topbar, body:has(#library:not([hidden])) .topbar {
    position: relative;
    width: 100%;
    height: auto;
    min-height: calc(var(--safe-top) + 56px);
    padding: var(--safe-top) var(--safe-right) 12px var(--safe-left);
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  #brand { display: none; }
  #settings, #exit {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--chrome);
    box-shadow: var(--chrome-shadow);
    -webkit-backdrop-filter: blur(14px) saturate(125%);
    backdrop-filter: blur(14px) saturate(125%);
  }
  #settings > span { display: none; }
  #settings svg { width: 20px; height: 20px; }
  .page-nav {
    position: fixed;
    left: var(--safe-left);
    right: var(--safe-right);
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 4px;
    height: 68px;
    border-radius: 24px;
    background: var(--chrome);
    box-shadow: var(--chrome-shadow);
    -webkit-backdrop-filter: blur(36px) saturate(135%);
    backdrop-filter: blur(36px) saturate(135%);
  }
  .page-nav button {
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    min-height: 60px;
    padding: 5px 2px;
    border: 0;
    border-radius: 20px;
    background: transparent;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.4;
  }
  .page-nav button > svg { display: block; width: 22px; height: 22px; stroke-width: 1.7; }
  .page-nav button[aria-current='page'] { background: var(--soft); color: var(--accent-ink); font-weight: 600; }
  @media (hover: hover) and (pointer: fine) {
    .page-nav button[aria-current='page']:hover { background: var(--soft); color: var(--accent-ink); }
  }
  main, main:has(#library:not([hidden])) {
    width: 100%;
    padding: 0 var(--safe-right) 24px var(--safe-left);
  }
  #home { margin-top: clamp(24px, 5svh, 48px); padding: 0; }
  #home h1 { font-size: 28px; margin-bottom: 28px; }
  .training { gap: 12px; margin-bottom: 28px; }
  .training button { min-height: 76px; font-size: 16px; gap: 10px; }
  input, select, textarea { font-size: 16px; }
  #library { margin-top: 4px; }
  .library-head { margin: 0; }
  .library-head h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .library-toolbar { padding-bottom: 12px; gap: 16px; }
  .part-switch { overflow: auto; }
  .part-switch button { font-size: 13px; min-height: 44px; padding-inline: 10px; }
  .library-query { min-height: 48px; }
  .library-query input { min-height: 46px; }
  .library-result-bar { padding-bottom: 16px; row-gap: 4px; }
  .material-status { justify-content: space-between; gap: 2px; }
  .material-status button { padding-inline: 10px; font-size: 13px; border-radius: 10px; }
  .library-count { font-size: 12px; }
  .library-index { padding-top: 0; }
  .library-row { padding: 14px 12px; margin-block: 4px; row-gap: 6px; }
  .entry-title { font-size: 16px; line-height: 1.6; }
  .entry-number { line-height: 25px; }
  .entry-meta { font-size: 12px; line-height: 1.7; }
  .keyword-list { gap: 20px 16px; }
  .keyword-list dt { font-size: 15px; }
  .keyword-list dd { font-size: 13px; }
  body:has(#library[data-view='detail']:not([hidden])) .topbar { min-height: 0; padding: 0; }
  body:has(#library[data-view='detail']:not([hidden])) #settings { display: none; }
  #library[data-view='detail'] { margin-top: 0; }
  #library[data-view='detail'] > :is(.library-head, .library-toolbar, .library-result-bar) { display: none; }
  .library-reading { background: transparent; overflow: visible; scroll-margin-top: 0; }
  .library-detail-nav {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 15;
    min-height: calc(var(--safe-top) + 60px);
    margin-inline: calc(-1 * var(--safe-left)) calc(-1 * var(--safe-right));
    padding: var(--safe-top) var(--safe-right) 12px var(--safe-left);
    border: 0;
    background: var(--chrome);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    backdrop-filter: blur(20px) saturate(135%);
  }
  .library-detail-nav .quiet { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
  .library-detail-nav svg { width: 20px; height: 20px; }
  #library-back { display: inline-flex; margin: 0; color: var(--accent-ink); }
  .library-detail-nav .control-label, #exit .control-label { display: none; }
  #library-position { justify-self: center; margin: 0; font-size: 12px; }
  .library-return-question { grid-column: 1 / -1; width: auto !important; justify-self: start; padding-inline: 12px !important; border-radius: 10px !important; }
  .library-detail { padding: 12px 0 32px; }
  .detail-title { max-width: none; font-size: 26px; line-height: 1.4; }
  .detail-meta { margin-top: 10px; line-height: 1.7; }
  .question-prompt { margin-top: 24px; font-size: 18px; line-height: 1.7; }
  .question-cues { font-size: 15px; line-height: 1.8; }
  .study-section { margin-top: 28px; }
  .answer-keypoints { font-size: 16px; line-height: 1.9; }
  .full-answer { font-size: 18px; line-height: 1.8; }
  .full-answer p + p { margin-top: 20px; }
  .followup-section .followup-title { font-size: 18px; }
  .section-editor textarea { min-height: 160px; padding: 14px; line-height: 1.8; }
  .reference-popup { max-height: calc(100dvh - 32px); }
  body[data-page='practice'] { padding-bottom: env(safe-area-inset-bottom); }
  #mode-name { font-size: 14px; color: var(--ink); }
  #practice { margin-top: 16px; }
  .sheet { padding: 28px 20px; border-radius: 16px; }
  .question-top { min-height: 0; margin-bottom: 28px; }
  #question { font-size: 25px; line-height: 1.55; }
  textarea { min-height: 220px; padding: 16px 16px 56px; font-size: 18px; line-height: 1.8; }
  .action-bar { gap: 12px; }
  .action-bar > button { flex: 1; min-width: 0 !important; min-height: 48px; }
  .question-nav { margin-top: 16px; gap: 8px; }
  dialog { width: calc(100% - var(--safe-left) - var(--safe-right)); max-height: calc(100dvh - 32px); padding: 24px 20px; }
}
@media (max-width: 374px) {
  .part-switch button { padding-inline: 8px; font-size: 12px; }
  .material-status button { padding-inline: 7px; gap: 5px; font-size: 12px; }
  .keyword-list { grid-template-columns: 1fr; }
  .sheet { padding: 24px 16px; }
  #question { font-size: 23px; }
  .detail-title { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
  button:active:not(:disabled):not(:focus-visible) { transform: none; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .topbar[data-floating='true'], body:has(#library:not([hidden])) .topbar[data-floating='true'], #settings, #exit, .library-detail-nav {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  @media (max-width: 767px) { .page-nav { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
}
@media (prefers-contrast: more) {
  .page-nav, #settings, #exit { outline: 1px solid var(--ink); }
}
