/* 功能对话框与锚定浮层：笔盒、调色、荧光笔、书写辅助、自定义工具栏、贴纸、页面总览、识别文字、数学助手、小伙伴、魔法手指。 */

/* ── 通用：带数值的滑杆 ───────────────────────────── */
.slider-field { margin: 10px 0; }
.slider-field > span { align-items: baseline; margin-bottom: 2px; }
.slider-field small { display: block; margin-top: -2px; font-size: var(--text-xs); line-height: 1.45; }

/* ── 笔盒（悬浮工具面板优化布局，无需滚动即可全览） ─ */
.penbox { display: grid; gap: 11px; }
.penbox h3 { margin-bottom: 5px; }
.penbox .slider-field { margin: 5px 0; }
.penbox input[type='range'] { block-size: 26px; }
.penbox-preview, .pen-sample {
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.penbox-preview canvas { width: 100%; height: 84px; }
.pen-sample canvas { width: 100%; height: 84px; }
.ink-trial { position: relative; }
.ink-trial canvas { display: block; }
.ink-trial [data-trial-paper] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; touch-action: none; cursor: crosshair; }
.ink-trial.is-writing [data-trial-paper] { opacity: 1; }
.ink-trial.is-writing .trial-hint { display: none; }
.trial-hint, .trial-reset {
  position: absolute;
  right: 8px;
  bottom: 7px;
  color: var(--ink-2);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
}
.trial-hint { padding: 3px 10px; font-size: 11.5px; pointer-events: none; }
.trial-reset { width: 34px; height: 34px; display: grid; place-items: center; }
.trial-reset .icon { width: 16px; height: 16px; }

.marker-profiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.marker-profiles button {
  padding: 6px 5px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-1);
  color: var(--ink-2);
  font: inherit;
  font-size: var(--text-s);
  font-weight: 500;
  overflow-wrap: anywhere;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.marker-profiles canvas { display: block; width: min(100%, 90px); height: 23px; margin: 0 auto 3px; border-radius: 4px; }
.marker-profiles [aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent); }
.penbox label[hidden], [data-marker-stability][hidden] { display: none; }

.brush-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.brush-cards .motion-pill { border-radius: var(--radius-m); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent-line); }
.brush-card {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: var(--text-s);
  font-weight: 500;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
@media (hover: hover) {
  .brush-card:hover { background: var(--surface-3); color: var(--ink-1); }
}
.brush-card canvas { width: 100%; height: 34px; }
.brush-card[aria-pressed='true'] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }
.brush-cards.rail-ready .brush-card[aria-pressed='true'] { background: transparent; border-color: transparent; }

.penbox-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.penbox-cols .field { margin-top: 0; }
.penbox-color {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
}
.penbox-color > span:nth-child(2) { display: grid; flex: 1; line-height: 1.3; }
.penbox-color strong { font-weight: 500; font-size: var(--text-s); }
.penbox-color small { font-variant-numeric: tabular-nums; }
.penbox .dialog-foot { margin-top: 0; }
.penbox .dialog-foot .icon { width: 16px; height: 16px; }

/* ── 调色 ─────────────────────────────────────────── */
.palette { display: grid; gap: var(--space-2); }
.palette .eyebrow { margin-top: var(--space-1); }
.palette-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; justify-items: center; }
.palette-grid.short { grid-template-columns: repeat(8, 1fr); }
.palette-grid .swatch.small, .palette-recent .swatch.small { width: 24px; height: 24px; }
.palette-recent { display: flex; flex-wrap: wrap; gap: 8px; }
.palette-custom { display: flex; align-items: center; gap: var(--space-2); }
.palette-custom input[type='color'] { width: 40px; height: 34px; flex: none; }
.palette-custom .input { min-height: 34px; padding: 4px 10px; font-variant-numeric: tabular-nums; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: var(--text-s); }
.palette-tabs { margin-bottom: var(--space-4); }
.palette-body .palette-grid { gap: 12px; }
.palette-body .swatch { width: 30px; height: 30px; }
.palette-empty { padding: var(--space-5) 0; text-align: center; }
.palette-title { margin: var(--space-4) 0 var(--space-2); }
.color-hero {
  display: grid;
  place-items: end start;
  height: 96px;
  margin-bottom: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-m);
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px var(--swatch-ring);
}
.color-hero span {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-1);
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── 书写辅助 ─────────────────────────────────────── */
.setting-list { margin-bottom: var(--space-3); }

/* ── 自定义工具栏 ─────────────────────────────────── */
.toolbar-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.toolbar-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}
.toolbar-row-icon { display: grid; place-items: center; width: 32px; color: var(--ink-2); }
.toolbar-row-name { display: flex; align-items: center; gap: var(--space-2); flex: 1; }
.toolbar-row .switch { margin-left: var(--space-2); }
.icon-btn.flip .icon { transform: rotate(180deg); }

/* ── 贴纸 ─────────────────────────────────────────── */
.sticker-packs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}
.sticker-tab {
  flex: none;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
@media (hover: hover) {
  .sticker-tab:hover { background: var(--surface-3); color: var(--ink-1); }
}
.sticker-tab[aria-pressed='true'] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.sticker-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.sticker-tile {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px 8px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  color: var(--ink-2);
  font-size: var(--text-xs);
  transition: background var(--fast), border-color var(--fast), transform var(--fast) var(--ease);
}
@media (hover: hover) {
  .sticker-tile:hover { background: var(--surface-3); border-color: var(--line); transform: translateY(-2px); }
}
.sticker-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-subtle);
}
:root[data-theme='dark'] .sticker-frame {
  background: rgba(255, 250, 240, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 240, 0.08);
}
.sticker-tile img {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}
.sticker-tile > .truncate {
  white-space: normal;
  overflow-wrap: anywhere;
}
.sticker-tile:disabled { opacity: .5; }
.sticker-hint { margin-top: var(--space-3); }

/* ── 页面总览与查找 ───────────────────────────────── */
.overview-bar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.overview-dialog .dialog-body { display: flex; flex-direction: column; overflow: hidden; }
.overview-bar, .overview-foot, [data-page-jump-host] { flex: none; flex-wrap: wrap; }
.page-jump {
  display: grid;
  gap: 8px;
  margin: -4px 0 var(--space-3);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
}
.page-jump-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.page-jump-mode { flex: 0 1 auto; max-width: 100%; }
.page-jump-mode > button { padding: 0 10px; min-height: 30px; }
.page-jump-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 170px;
  min-width: 0;
}
.page-jump-input {
  flex: 1 1 84px;
  min-width: 0;
  min-height: 34px;
  height: 34px;
  padding: 4px 11px;
  font-size: var(--text-s);
}
.page-jump-go { flex: none; min-height: 34px; }
.btn.page-jump-return {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  padding: 5px 11px;
  gap: 6px;
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  white-space: normal;
  line-height: 1.3;
  text-align: start;
}
.btn.page-jump-return .icon { width: 15px; height: 15px; flex: none; }
.page-jump-return-label { min-width: 0; overflow-wrap: anywhere; }
@media (hover: hover) {
  .btn.page-jump-return:hover:not(:disabled) {
    background: color-mix(in oklab, var(--accent-soft) 72%, var(--surface-3));
    border-color: var(--accent);
  }
}
.page-jump-status {
  margin: 0;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--ink-2);
}
.page-jump-status.is-error { color: var(--danger); }
.page-jump-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 138px;
  padding: 3px;
  margin: -3px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.page-jump-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 36px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--ink-1);
  font-size: var(--text-s);
  text-align: start;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.page-jump-choice:hover, .page-jump-choice:focus-visible {
  background: var(--surface-3);
  border-color: var(--accent-line);
}
.page-jump-choice[aria-current='page'] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.page-jump-choice-main { font-weight: 600; white-space: nowrap; }
.page-jump-choice-meta {
  color: var(--ink-3);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-jump-choice[aria-current='page'] .page-jump-choice-meta { color: var(--accent-ink); }
@media (pointer: coarse) {
  .page-jump-mode > button { min-height: 38px; }
  .page-jump-input { min-height: 44px; height: 44px; }
  .btn.page-jump-go { min-height: 44px; padding: 0 14px; }
  .btn.page-jump-return { min-height: 44px; padding: 6px 12px; }
  .page-jump-choice { min-height: 44px; }
}
@media (max-width: 600px) {
  .page-jump-mode { flex: 1 1 100%; display: flex; }
  .page-jump-mode > button { min-height: 38px; }
  .page-jump-input { min-height: 44px; height: 44px; }
  .btn.page-jump-go { min-height: 44px; padding: 0 14px; }
  .btn.page-jump-return { flex: 1 1 100%; justify-content: center; min-height: 44px; padding: 6px 12px; text-align: center; }
  .page-jump-choice { min-height: 44px; }
}
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-5) var(--space-4);
  align-items: start;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.overview-grid .empty-state { grid-column: 1 / -1; }
.overview-outline { min-height: 0; overflow: auto; overscroll-behavior: contain; }
@media (max-width: 600px), (max-height: 540px) {
  .overview-dialog .dialog-body { overflow-y: auto; }
  .overview-dialog .overview-grid, .overview-dialog .overview-outline { min-height: min(128px, 30dvh); }
  .overview-dialog .overview-foot { position: static; }
}
.document-find .dialog-body { display: flex; flex-direction: column; gap: var(--space-3); overflow: hidden; }
.document-find [data-find-status]:empty { display: none; }
.document-find [data-find-input], .document-find [data-find-more] { flex: none; }
.document-find .scan-coverage { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex: none; }
.document-find .scan-coverage[hidden] { display: none; }
.scan-coverage .btn { flex: none; }
.find-results { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.find-results:empty { display: none; }
.find-result { display: grid; width: 100%; gap: 4px; text-align: start; padding: 10px 12px; min-height: 48px; border-radius: var(--radius-s); overflow-wrap: anywhere; }
.find-result:hover, .find-result:focus-visible { background: var(--surface-3); }
.find-result mark { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.find-location { position: absolute; z-index: 2; pointer-events: none; border: 2px solid var(--accent); border-radius: 4px; background: var(--accent-soft); opacity: .72; mix-blend-mode: multiply; }
.find-return { max-width: 100%; padding: 0 4px; gap: 0; color: var(--ink-1); }
.find-return button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 44px; border-radius: var(--radius-pill); }
.find-return button:hover:not(:disabled), .find-return button:focus-visible { background: var(--surface-3); }
.find-return button:disabled { opacity: .35; }
.find-return [data-find-back] { padding-inline: 8px; }
.find-return output { white-space: nowrap; font-size: var(--text-s); text-align: center; min-width: 3em; }
@media (max-width: 540px) { .find-return [data-find-back] span { display: none; } }
.find-return .icon { width: 18px; height: 18px; }
.overview-outline ul { list-style: none; padding: 0; margin: 0; }
.overview-outline ul ul { margin-inline-start: clamp(8px, 2vw, 22px); border-inline-start: 1px solid var(--line); }
.outline-row { display: flex; align-items: stretch; margin-block: 2px; }
.outline-label, .outline-toggle { min-height: 44px; border-radius: var(--radius-s); }
.outline-toggle { width: 44px; flex: none; display: grid; place-items: center; color: var(--ink-2); }
.outline-toggle .icon { width: 16px; height: 16px; }
.outline-toggle[aria-expanded='true'] .icon { transform: rotate(90deg); }
.outline-label { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px; text-align: start; overflow-wrap: anywhere; min-width: 0; }
.outline-label:first-child { margin-inline-start: 44px; }
.outline-label .num { flex: none; color: var(--ink-2); font-size: var(--text-s); }
.outline-label:hover, .outline-toggle:hover { background: var(--surface-3); }
.outline-label[aria-current] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.chapter-heading { margin: 12px 0 4px; font-size: var(--text-s); color: var(--ink-2); }
.outline-label.chapter-link { margin-inline-start: 0; }
.chapter-edit { flex: none; width: 44px; min-height: 44px; }
.chapter-add { margin-block: 6px; min-height: 44px; }
.chapter-remove { margin-inline-end: auto; }
.overview-grid .empty-state .btn, .side-empty .btn { margin-top: var(--space-3); }
.overview-tile {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding: 8px;
  border-radius: var(--radius-m);
  text-align: center;
  transition: background var(--fast);
}
.overview-tile:hover { background: var(--surface-3); }
.overview-tile .thumb { width: 100%; max-height: 300px; }
.overview-tile .thumb canvas { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.overview-tile[aria-current='page'] .thumb { box-shadow: 0 0 0 2.2px var(--accent), var(--shadow-1); }
.overview-meta { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--text-s); color: var(--ink-2); }
.overview-tile[aria-current='page'] .overview-meta { color: var(--accent-ink); font-weight: 600; }
.bookmark-mark { display: inline-grid; color: var(--accent); }
.bookmark-mark .icon { width: 14px; height: 14px; fill: var(--accent-soft); }
.pick-mark {
  position: absolute;
  top: 14px;
  right: 14px;
  display: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: transparent;
}
.pick-mark .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.overview-dialog.picking .pick-mark { display: grid; }
.overview-tile[aria-pressed='true'] .pick-mark { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.overview-tile[aria-pressed='true'] .thumb { box-shadow: 0 0 0 2px var(--accent-line), var(--shadow-1); }
.overview-foot { align-items: center; }
.overview-foot .icon { width: 16px; height: 16px; }

/* ── 识别文字 ─────────────────────────────────────── */
.ocr-status { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: 6px; font-size: var(--text-s); color: var(--ink-2); }
.ocr-status.is-error { color: var(--danger); }
.ocr-dialog .field textarea { min-height: 180px; }
.ocr-dialog .dialog-foot .icon { width: 16px; height: 16px; }

/* ── 数学助手 ─────────────────────────────────────── */
.math-input { font-size: var(--text-l); font-variant-numeric: tabular-nums; }
.math-keys { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.math-keys .btn { padding: 0; font-variant-numeric: tabular-nums; }
.math-result {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-height: 64px;
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
}
.math-result output { font: 500 var(--text-2xl)/1.2 var(--font-serif); color: var(--ink-1); overflow-wrap: anywhere; }
.math-result .muted { font-size: var(--text-s); }
.math-result.is-error .muted { color: var(--danger); }

/* ── 小伙伴 ───────────────────────────────────────── */
.pet-art { position: relative; display: block; width: 100%; aspect-ratio: 1; }
.pet-art img, .pet-art svg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pet-rest, .pet-sprout, .pet-leaf, .pet-bloom { display: none; }
[data-mood='rest'] .pet-awake { display: none; }
[data-mood='rest'] .pet-rest { display: block; }
[data-growth='1'] .pet-sprout, [data-growth='2'] .pet-sprout, [data-growth='3'] .pet-sprout,
[data-growth='2'] .pet-leaf, [data-growth='3'] .pet-leaf, [data-growth='3'] .pet-bloom { display: initial; }

.companion-sheet {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-1);
}
.companion-sheet > svg { width: 100%; max-height: 96px; }
.companion-sheet strong { display: block; font: 500 var(--text-xl)/1.3 var(--font-serif); color: var(--ink-1); }
.companion-sheet p { margin-top: 4px; color: var(--ink-2); font-size: var(--text-s); }
.companion-title { margin: var(--space-5) 0 var(--space-2); }
.companion-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-4); }
.companion-choice {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--text-xs);
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
@media (hover: hover) {
  .companion-choice:hover { background: var(--surface-3); transform: translateY(-1px); }
}
.companion-choice > :is(svg, .pet-art) { width: 52px; height: 52px; }
.companion-choice[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ── 魔法手指面板 ─────────────────────────────────── */
.gesture-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(132px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(260px, calc(100vw - 32px));
  padding: var(--space-3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-l);
  background: var(--glass-strong);
  color: var(--ink-1);
  box-shadow: var(--shadow-3), var(--glass-specular);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  font-size: var(--text-s);
}
.gesture-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-2); }
.gesture-head b { display: block; font-size: var(--text-m); font-weight: 600; }
.gesture-head div span { display: block; color: var(--ink-3); font-size: var(--text-xs); }
.gesture-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--accent-ink); }
.gesture-icon svg { width: 24px; height: 24px; }
.gesture-panel button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  font-size: var(--text-s);
}
.gesture-panel button:hover:not(:disabled) { background: var(--surface-3); }
.gesture-panel .gesture-close { width: 34px; margin-left: auto; padding: 0; border-color: transparent; color: var(--ink-2); font-size: 20px; }
.bones-wrap { position: relative; height: 128px; overflow: hidden; border-radius: var(--radius-m); background: radial-gradient(ellipse at 60% 30%, #3c4941, #26312b); }
.bones-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; pointer-events: none; }
.camera-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 94%;
  max-width: 92%;
  aspect-ratio: var(--camera-aspect, 4 / 3);
  border: 1px dashed rgb(198 226 209 / .42);
  border-radius: 10px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.gesture-panel[data-phase='holding'] .camera-guide { border-color: #ffe0b0; border-style: solid; }
.gesture-panel[data-phase='released'] .camera-guide { border-color: #c7e6d5; }
.gesture-status { min-height: 24px; margin: var(--space-2) 0; font-weight: 600; line-height: 1.45; }
.gesture-actions { display: flex; gap: 6px; }
.gesture-actions button { flex: 1; }
.gesture-steps {
  display: grid;
  grid-template-columns: .8fr 1.2fr 1.2fr;
  gap: 4px;
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-3);
  font-size: var(--text-xs);
}
.gesture-steps li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 0; border: 1px solid transparent; border-radius: var(--radius-s); line-height: 1.2; }
.gesture-steps svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gesture-steps [aria-current='step'] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.gesture-panel[data-phase='released'] .gesture-steps [aria-current='step'] { border-color: transparent; background: var(--green-soft); color: var(--green); }
.gesture-panel [hidden] { display: none; }
@media (max-height: 580px) { .gesture-panel .bones-wrap { height: 88px; } }

/* ── 窄屏 ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .penbox-cols { grid-template-columns: 1fr; }
  .brush-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .companion-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .math-keys { grid-template-columns: repeat(4, 1fr); }
  .gesture-panel { bottom: calc(112px + env(safe-area-inset-bottom)); }
}

.deleted-sheet-list { max-height: 54dvh; overflow: auto; }
.deleted-sheet-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.deleted-sheet-row .thumb { height: 53px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); }
.deleted-sheet-row canvas { width: 100%; }
.deleted-sheet-row small { display: block; color: var(--ink-2); }

/* ── 专业多图层面板 ───────────────────────────────── */
.layers-panel { display: grid; gap: 10px; }
.layers-tip { margin: 0; color: var(--ink-3); font-size: var(--text-xs); line-height: 1.5; }
.layers-list { display: grid; gap: 6px; }
.layer-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-1);
  transition: background var(--fast), border-color var(--fast);
}
.layer-row.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.layer-row.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.layer-row.is-hidden { opacity: .62; }
.layer-select {
  display: grid;
  flex: 1;
  min-width: 0;
  text-align: left;
  gap: 1px;
}
.layer-select strong { font-size: var(--text-s); font-weight: 600; color: var(--ink-1); }
.layer-select small { font-size: 11px; color: var(--ink-3); }
.layer-actions { display: flex; align-items: center; gap: 1px; flex-wrap: nowrap; }
.layers-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; border-top: 1px solid var(--line); }

/* ── 闪卡背诵浮条与 1 键自评胶囊 ─────────────────────── */
.study-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 7;
  flex-wrap: nowrap;
  gap: 4px;
  max-width: calc(100% - 16px);
  padding: 4px 6px 4px 10px;
  white-space: nowrap;
  transform: translateX(-50%);
  overflow-x: auto;
  scrollbar-width: none;
}
.study-bar::-webkit-scrollbar { display: none; }
.study-bar > * { flex: none; }
.study-bar .label {
  font-size: var(--text-xs);
  color: var(--ink-2);
  white-space: nowrap;
  padding: 0 2px;
}
.study-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-ink);
  font-size: var(--text-s);
  white-space: nowrap;
}
.study-badge .icon { width: 16px; height: 16px; }
.study-grade {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  padding: 3px 4px;
  gap: 2px;
  transition: opacity var(--fast) var(--ease);
}
.study-grade .btn.is-picked { background: var(--green-soft); color: var(--green); }
.study-grade .btn.is-hard { background: var(--accent-soft); color: var(--accent-ink); }

/* ── 课堂录音与笔迹时间轴同步条 ─────────────────────── */
.audio-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 6;
  flex-wrap: nowrap;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  transform: translateX(-50%);
}
.editor.studying .audio-bar { top: 60px; }
.audio-bar > :not(.audio-seek) { flex: none; }
.audio-rec-btn { gap: 6px; padding: 0 11px; border-radius: var(--radius-pill); }
.audio-rec-btn[aria-pressed='true'] { background: var(--danger); color: #fff; }
.audio-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  flex: none;
}
select.audio-clip-select {
  flex: none;
  width: auto;
  min-width: 84px;
  max-width: 136px;
  min-height: 28px;
  height: 28px;
  padding: 0 24px 0 10px;
  font-size: var(--text-xs);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  @supports (appearance: base-select) {
    select.audio-clip-select {
      padding: 0 9px;
      gap: 5px;
    }
  }
}
.audio-seek { flex: 1 1 110px; min-width: 64px; width: clamp(86px, 16vw, 170px); block-size: 26px; }
.audio-time { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; padding: 0 4px; }
.favorite-empty { margin: 0; padding: 14px 4px; text-align: center; }

@media (max-width: 640px) {
  .pack-grid { grid-template-columns: 1fr; }
  .pro-offer-bar { flex-direction: column; align-items: stretch; }
  .pro-cta-group { justify-content: flex-end; }
  .study-bar .btn span { display: none; }
  .study-bar .btn.small { min-width: 30px; padding: 0 6px; }
  .study-badge strong { display: none; }
  .audio-bar { width: calc(100% - 16px); gap: 3px; padding: 4px 6px; }
  .audio-bar .bar-sep { display: none; }
  .audio-rec-btn { min-width: 30px; padding: 0 8px; }
  .audio-rec-btn span { display: none; }
  .audio-clip-select { display: none; }
  .audio-seek { width: auto; flex: 1 1 60px; min-width: 56px; }
  .audio-time { font-size: 11px; padding: 0 2px; }
}

.pdf-export-options { margin: 0; padding: 0; border: 0; }
.pdf-export-options legend { padding: 0 0 6px; font-size: var(--text-s); color: var(--ink-2); }
.pdf-export-options label { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.pdf-export-options input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.pdf-export-options small { margin-inline-start: auto; color: var(--ink-2); }
.pdf-export-options label:has(input:disabled) { opacity: .55; }
.pdf-export-preview {
  margin-top: var(--space-2);
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-1);
}
.pdf-export-preview-list { margin: 0; padding: 0; list-style: none; }
.pdf-export-preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-subtle);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.pdf-export-preview-row:last-child { border-bottom: 0; }
.pdf-export-preview-page { font-weight: 500; color: var(--ink-1); min-width: 0; overflow-wrap: break-word; }
.pdf-export-preview-target { color: var(--ink-2); min-width: 0; overflow-wrap: break-word; }
.pdf-export-preview-row.is-more { justify-content: flex-start; color: var(--ink-3); }

/* ── 慢 PDF 导入进度 ─────────────────────────────── */
.pdf-import-sheet { display: grid; gap: var(--space-3); }
.pdf-import-file {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-1);
}
.pdf-import-icon { display: inline-grid; place-items: center; color: var(--accent-ink); flex: none; }
.pdf-import-icon .icon { width: 17px; height: 17px; }
.pdf-import-name { flex: 1; min-width: 0; font-size: var(--text-s); font-weight: 500; color: var(--ink-1); }
.pdf-import-file small { flex: none; font-size: var(--text-xs); white-space: nowrap; }
.pdf-import-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-s);
  color: var(--ink-2);
}
.pdf-import-status [data-import-status] { min-width: 0; overflow-wrap: anywhere; }
.pdf-import-status [data-import-count] { flex: none; white-space: nowrap; }
.pdf-import-bar {
  position: relative;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
}
.pdf-import-progress { display: block; width: 100%; height: 100%; background: transparent; }
.pdf-import-bar[data-indeterminate='true'] .pdf-import-progress { opacity: 0; }
.pdf-import-bar[data-indeterminate='true']::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  animation: pdf-import-slide 1.45s var(--ease) infinite;
}
@keyframes pdf-import-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}
@media (prefers-reduced-motion: reduce) {
  .pdf-import-bar[data-indeterminate='true']::after { width: 100%; opacity: .55; animation: none; }
}
.glass-off .pdf-import-bar[data-indeterminate='true']::after { width: 100%; opacity: .55; animation: none; }
.pdf-import-hint { margin: 0; font-size: var(--text-xs); line-height: 1.55; }
.pdf-import-sheet .dialog-foot { margin-top: var(--space-2); }
