/* ==========================================================================
   复古顶部导航 + 笔记 / 题目档 / 网页问题申诉 三大功能的样式
   ========================================================================== */

:root {
  --retro-teal: #6ba3a8;
  --retro-teal-dark: #3c676e;
  --retro-cream: #f6efdd;
  --retro-coral: #e1614c;
  /* 白字压在 coral 上只有 3.49:1，按钮底色另外用深一档的 */
  --retro-coral-deep: #b34a37;
  --retro-dark: #3f3e3c;
  --retro-sand: #ded9c8;
}

/* ---------- 顶部复古导航栏 ---------- */
/* 顶栏改成「浮起来的玻璃药丸」：不再是贴边的整条实心色块，
   而是离开边缘、带圆角与投影的独立元件 —— 这是最一眼可见的改变 */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 600;
  background: transparent;
  border-bottom: none;
  box-shadow: none;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 12px;
}
.nav-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 6px rgba(15, 23, 42, 0.05),
    0 18px 44px -20px rgba(15, 23, 42, 0.35);
}
.nav-item {
  font-family: var(--font-display);
  background: transparent;
  border: none;
  color: #1f3d36;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.4px;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 6px;
  position: relative;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-item::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary, #059669);
  transform: scaleX(0);
  transition: transform 0.22s ease;
}
.nav-item:hover::after, .nav-item.active::after { transform: scaleX(1); }
@media (prefers-reduced-motion: reduce) { .nav-item::after { transition: none; } }
.nav-item:hover { color: var(--primary, #059669); }
.nav-item.active { color: var(--primary, #059669); }

/* 中央徽章：纯装饰的网站图标（学士帽），不可点击 */
.nav-logo {
  width: 64px; height: 64px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fffdf8;
  border: 2px solid rgba(31, 61, 54, 0.85);
  box-shadow:
    0 0 0 5px rgba(255, 255, 255, 0.75),
    inset 0 2px 4px rgba(255, 255, 255, 0.9),
    0 10px 24px -10px rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  margin: 0 6px;
  cursor: default;
  user-select: none;
}
.nav-logo .brand-logo { width: 88%; height: 88%; }   /* 学士帽是扁的：放大到帽板尖角贴近圆框 */

@media (max-width: 640px) {
  .nav-item { font-size: 12px; letter-spacing: 0.8px; padding: 6px 8px; }
  .nav-logo { width: 48px; height: 48px; margin: 0 2px; }
}
/* 320px 的旧机型：药丸左右留白与间距再收，四个按钮与中间的图标才放得进一行 */
@media (max-width: 340px) {
  .nav-inner { padding: 8px 8px; gap: 2px; }
  .nav-item { letter-spacing: 0; padding: 6px 6px; }
}

/* ---------- 工具条（面包屑 + 音效开关） ---------- */
.util-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 14px 0 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}
.util-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 手机上工具列放不下第五颗：护眼只留月亮（字还在，只是藏起来给读屏念），开著时整颗按钮上色 */
/* 开关的「开著」状态统一由 .is-on 上色，见 index.html 的功能色 */
/* 手机放不下五组「图标＋文字」：只留图标，文字仍在 DOM 里给读屏念。
   开／关看得出来——开著是绿的，关著是灰的，音效与音乐关掉时图标还多一道斜线 */
@media (max-width: 560px) {
  .util-actions { gap: 6px; }
  .util-actions .sound-toggle { padding: 8px 10px; }
  .util-actions .sound-toggle .ic { width: 18px; height: 18px; }
  .util-actions .btn-txt, #themeBtn .theme-txt {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}
@media (max-width: 340px) {
  .util-actions { gap: 4px; }
  .util-actions .sound-toggle { padding: 8px; }
}

/* ---------- 首页复古标题横幅 ---------- */
.retro-hero { text-align: center; padding: 10px 0 24px; }
.retro-hero-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 9vw, 64px);
  font-weight: 800;
  color: var(--retro-teal-dark);
  letter-spacing: 4px;
  line-height: 1.2;
  text-shadow: 3px 3px 0 rgba(246, 239, 221, 0.9), 5px 5px 0 rgba(77, 129, 137, 0.18);
}
.retro-ribbon {
  display: inline-block;
  margin-top: 14px;
  background: var(--retro-cream);
  border: 2px solid var(--retro-teal-dark);
  color: var(--retro-dark);
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700; letter-spacing: 2px;
  padding: 8px 24px;
  position: relative;
  box-shadow: 0 4px 0 rgba(77, 129, 137, 0.25);
}
.retro-ribbon::before, .retro-ribbon::after {
  content: '';
  position: absolute; top: 50%; width: 26px; height: 2px;
  background: var(--retro-teal-dark);
}
.retro-ribbon::before { left: -30px; }
.retro-ribbon::after { right: -30px; }
@media (max-width: 480px) {
  .retro-ribbon::before, .retro-ribbon::after { display: none; }
}

/* ---------- 题目卡角落的"笔记"按钮 ---------- */
.card-note-btn {
  position: absolute;
  right: 14px; bottom: 12px;
  background: var(--retro-cream);
  border: 1.5px solid var(--retro-teal-dark);
  color: var(--retro-teal-dark);
  font-size: 12px; font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.1);
  transition: all 0.2s;
}
.card-note-btn:hover { background: var(--retro-teal-dark); color: var(--retro-cream); transform: translateY(-2px); }
.card-note-btn.has-note { background: var(--retro-coral-deep); border-color: var(--retro-coral-deep); color: #fff; }
/* 有笔记的题：「看笔记」开关与「编辑笔记」一起放在右下角 */
.card-note-actions { position: absolute; right: 14px; bottom: 12px; z-index: 3; display: flex; gap: 8px; }
.card-note-actions .card-note-btn { position: static; }
.note-inline-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--retro-cream); border: 1.5px solid var(--retro-teal-dark); color: var(--retro-teal-dark);
  font: inherit; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 20px; cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.1); transition: all 0.2s;
}
.note-inline-toggle:hover, .note-inline-toggle[aria-expanded="true"] { background: var(--retro-teal-dark); color: var(--retro-cream); }
.note-inline {
  margin-top: 14px; padding: 12px 14px; border-radius: 14px;
  background: #fffbea; border: 1.5px solid #f3d27a; animation: softFadeIn 0.2s ease;
}
.note-inline-head { font-size: 12px; font-weight: 800; color: #a16207; margin-bottom: 6px; }
.note-inline-text { font-size: 14px; line-height: 1.75; color: #3f3f46; white-space: pre-wrap; word-break: break-word; }
.note-inline-ink { display: block; max-width: 100%; margin-top: 8px; border-radius: 10px; background: #fff; border: 1px solid #f1e3b3; }
.flashcard, .form-question-card { position: relative; }
.flashcard { padding-bottom: 56px; }
.form-question-card .form-card-body { padding-bottom: 56px; }

/* ---------- 笔记编辑器弹窗 ---------- */
.note-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.62);
  z-index: 1400;
  padding: 16px;
  overflow-y: auto;
}
.note-modal.active { display: block; animation: softFadeIn 0.2s ease; }
.note-dialog {
  max-width: 880px;
  margin: 20px auto;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.45);
}
.note-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  background: var(--retro-teal);
  color: var(--retro-cream);
  padding: 14px 16px;
}
.note-dialog-title { font-family: var(--font-display); font-size: 16px; font-weight: 800; letter-spacing: 1px; }
.note-close-btn {
  background: transparent; border: none; color: var(--retro-cream);
  font-size: 23px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.note-close-btn:hover { background: rgba(0,0,0,0.15); }

.note-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.note-tool-btn {
  background: #fff; border: 1.5px solid #cbd5e1; color: #334155;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: all 0.18s;
}
.note-tool-btn:hover { border-color: var(--retro-teal-dark); }
.note-tool-btn.active { background: var(--fn-go); border-color: var(--fn-go); color: #fff; }

/* ---------- 功能色：按钮的颜色说明它会做什么 ---------- */
/* 会删掉东西的：红字红边。颜色不是唯一讯号——图标是垃圾桶，文字写著「清空」「删除」 */
.btn-danger, .note-mini-btn.danger {
  color: var(--fn-danger); border-color: rgba(185, 28, 28, .45); background: #fff;
}
.btn-danger:hover, .note-mini-btn.danger:hover {
  background: var(--fn-danger-soft); border-color: var(--fn-danger); color: var(--fn-danger);
}
/* 跟资料、时间有关的次要动作用青色 */
.note-mini-btn.is-time { color: var(--fn-time); border-color: rgba(14, 116, 144, .4); }
.note-pen-colors { display: flex; gap: 6px; align-items: center; }
.note-color-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; transition: transform 0.15s;
}
.note-color-dot.selected { border-color: #0f172a; transform: scale(1.2); }
.note-size-range { width: 96px; accent-color: var(--retro-teal-dark); }
.note-toolbar-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }

.note-stage-scroll { padding: 16px; background: #eef2f7; max-height: 62vh; overflow-y: auto; }
.note-stage {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.note-question-snapshot {
  padding: 20px 20px 8px;
  pointer-events: none;
  user-select: none;
}
.note-snapshot-tag {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  background: var(--primary-light); color: var(--primary-dark);
  padding: 4px 8px; border-radius: 10px; margin-bottom: 10px;
}
.note-snapshot-q { font-size: 16px; font-weight: 700; color: #1e293b; line-height: 1.75; white-space: pre-line; }
.note-snapshot-opts { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.note-snapshot-opt { font-size: 13px; color: #475569; padding: 4px 10px; border: 1px solid #e2e8f0; border-radius: 7px; }
.note-snapshot-hint { margin-top: 10px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.note-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.note-text-area { padding: 14px 16px; border-top: 1px solid #e2e8f0; }
.note-text-area textarea {
  width: 100%; min-height: 70px; resize: vertical;
  border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 10px 12px;
  font-size: 14px; line-height: 1.6; color: #334155;
}
.note-text-area textarea:focus { outline: none; border-color: var(--retro-teal-dark); }
.note-dialog-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; background: #f8fafc; border-top: 1px solid #e2e8f0; flex-wrap: wrap;
}
.note-save-hint { font-size: 12px; color: var(--text-muted); }
/* 存下来、送出去这类「确认」动作一律绿色。珊瑚红是身份色，放在按钮上会被读成「危险／会出事」，
   跟它实际做的事相反。（以前绿色写在前面一条、这里又写回珊瑚红，後写的赢，所以一直是红的） */
.btn-primary-retro {
  background: var(--fn-go); border: none; color: #fff;
  padding: 10px 20px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px -2px rgba(4, 120, 87, .45); transition: all 0.2s;
}
.btn-primary-retro:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-ghost-retro {
  background: #fff; border: 1.5px solid #cbd5e1; color: #475569;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-ghost-retro:hover { border-color: var(--retro-teal-dark); color: var(--retro-teal-dark); }

/* ---------- 笔记列表页 ---------- */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 16px; }
.note-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column;
}
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.note-card-preview { height: 130px; background: #fff; border-bottom: 1px solid #e2e8f0; position: relative; overflow: hidden; }
.note-card-preview canvas { width: 100%; height: 100%; object-fit: contain; }
.note-card-body { padding: 12px 16px; flex: 1; }
.note-card-chapter { font-size: 11px; font-weight: 700; color: var(--primary-dark); background: var(--primary-light); padding: 4px 8px; border-radius: 9px; display: inline-block; margin-bottom: 8px; }
.note-card-q { font-size: 13px; color: #334155; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-time { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.note-card-actions { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.note-mini-btn {
  flex: 1; background: #fff; border: 1px solid #cbd5e1; color: #475569;
  padding: 6px 4px; border-radius: 7px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.note-mini-btn:hover { border-color: var(--retro-teal-dark); color: var(--retro-teal-dark); }
.note-mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 题目档（下载）页 ---------- */
.archive-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 12px 16px; margin: 16px 0 16px;
  position: sticky; top: 92px; z-index: 300; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.archive-subject-tabs { display: flex; gap: 6px; background: rgba(255,255,255,0.7); padding: 4px; border-radius: 10px; border: 1px solid #e2e8f0; }
.archive-tab {
  background: transparent; border: none; color: var(--text-muted);
  padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.archive-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.archive-count { font-size: 13px; font-weight: 700; color: var(--retro-teal-dark); margin-left: auto; }

.archive-chapter {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 14px; margin-bottom: 14px; overflow: hidden;
}
.archive-chapter-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #f1f5f9; cursor: pointer; user-select: none;
}
.archive-chapter-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: #1e293b; flex: 1; }
.archive-chapter-count { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.archive-chapter-body { padding: 6px 0; display: none; }
.archive-chapter-body.open { display: block; }
.archive-q-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer;
}
.archive-q-row:last-child { border-bottom: none; }
.archive-q-row:hover { background: #f8fafc; }
.archive-q-row input[type="checkbox"] { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--primary); flex: 0 0 auto; }
.archive-q-text { font-size: 13px; color: #334155; line-height: 1.6; flex: 1; }
.archive-q-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; margin-right: 6px; }
.archive-q-badge.mcq { background: #e0f2fe; color: #075985; }
.archive-q-badge.subj { background: #fef3c7; color: #92400e; }
.archive-empty { text-align: center; padding: 40px; color: var(--text-muted); }

.pdf-progress {
  position: fixed; inset: 0; background: rgba(15,23,42,0.6); z-index: 1500;
  display: none; align-items: center; justify-content: center;
}
.pdf-progress.active { display: flex; }
.pdf-progress-box {
  background: #fff; border-radius: 16px; padding: 28px 36px; text-align: center;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.4); max-width: 320px;
}
.pdf-spinner {
  width: 38px; height: 38px; margin: 0 auto 14px;
  border: 4px solid #e2e8f0; border-top-color: var(--retro-coral);
  border-radius: 50%; animation: pdfSpin 0.9s linear infinite;
}
@keyframes pdfSpin { to { transform: rotate(360deg); } }
.pdf-progress-text { font-size: 14px; font-weight: 700; color: #1e293b; }
.pdf-progress-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* 离屏 PDF 渲染台：不可见但必须真实布局，否则 html2canvas 量不到高度 */
#pdfStage {
  position: fixed; left: -10000px; top: 0;
  width: 760px; background: #fff;
}
.pdf-block { background: #fff; padding: 16px 20px; font-family: "Noto Sans SC", sans-serif; color: #111; }
.pdf-title-block { text-align: center; padding: 28px 20px; }
.pdf-title-block h1 { font-size: 28px; font-weight: 800; color: #111; margin-bottom: 8px; }
.pdf-title-block p { font-size: 13px; color: #555; }
.pdf-chapter-head { font-size: 16px; font-weight: 800; color: #111; border-bottom: 2px solid #111; padding-bottom: 6px; }
.pdf-q-num { font-size: 14px; font-weight: 800; color: #111; margin-bottom: 6px; }
.pdf-q-text { font-size: 14px; line-height: 1.75; color: #111; white-space: pre-line; }
.pdf-q-opts { margin-top: 8px; }
.pdf-q-opt { font-size: 13px; line-height: 1.75; color: #222; }
.pdf-q-answer { margin-top: 10px; padding: 8px 12px; background: #f2f2f2; border-left: 3px solid #666; font-size: 13px; line-height: 1.75; color: #222; white-space: pre-line; }
.pdf-q-figure { margin-top: 10px; text-align: center; }
.pdf-q-figure img, .pdf-q-figure svg { max-width: 100%; max-height: 260px; }

/* ---------- 网页问题申诉页 ---------- */
.feedback-form-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 20px 20px; box-shadow: var(--shadow-sm); margin-top: 16px;
}
.fb-field { margin-bottom: 14px; }
.fb-label { display: block; font-size: 12px; font-weight: 700; color: #334155; margin-bottom: 6px; }
.fb-input, .fb-textarea, .fb-select {
  width: 100%; border: 1.5px solid #e2e8f0; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; color: #334155; background: #fff;
}
.fb-textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.fb-input:focus, .fb-textarea:focus, .fb-select:focus { outline: none; border-color: var(--retro-teal-dark); }
.fb-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }

.fb-done { margin-top: 4px; }
.fb-done > summary { cursor: pointer; padding: 8px 4px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.fb-done > summary:hover { color: var(--text-main); }
.fb-done[open] > summary { margin-bottom: 8px; }
.fb-report-item {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.fb-report-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fb-status {
  font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 9px;
}
.fb-status.pending { background: #fef3c7; color: #92400e; }
.fb-status.resolved { background: #dcfce7; color: #166534; }
.fb-report-id { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; }
.fb-report-text { font-size: 13px; color: #334155; line-height: 1.6; white-space: pre-line; }
.fb-report-reply {
  margin-top: 8px; padding: 8px 12px; background: #f0fdf4;
  border-left: 3px solid var(--primary); border-radius: 6px;
  font-size: 13px; color: #166534; line-height: 1.6;
}

/* ---------- 通知小精灵 ---------- */
.sprite-wrap {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 1300;
  display: none;
  align-items: flex-end;
  gap: 0;
}
.sprite-wrap.active { display: flex; animation: spriteIn 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
/* 图还没载好：位置先占好（导览找得到），但看不见、点不到，飞入动画停在第一格 */
.sprite-wrap.active.is-loading { opacity: 0; pointer-events: none; animation-play-state: paused; }
.sprite-wrap.leaving { animation: spriteOut 0.55s ease forwards; }
.sprite-wrap.is-done { pointer-events: none; }
.sprite-wrap.is-done .sprite-char { cursor: default; }
/* 从右下方沿弧线飞进来，机头先压低、到位时微微冲过头再回正 */
@keyframes spriteIn {
  0% { opacity: 0; transform: translate(60px, 40px) rotate(8deg) scale(0.8); }
  60% { opacity: 1; transform: translate(-6px, -8px) rotate(-4deg) scale(1.02); }
  100% { opacity: 1; transform: none; }
}
@keyframes spriteOut {
  0% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
  40% { opacity: 1; transform: translateY(-16px) scale(1.06) rotate(-6deg); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.5) rotate(12deg); }
}

.sprite-panel {
  background: var(--retro-cream);
  border: 2px solid var(--retro-teal-dark);
  border-radius: 14px;
  padding: 12px 16px;
  max-width: 250px;
  box-shadow: 0 12px 28px -8px rgba(15, 23, 42, 0.35);
  display: none;
  margin-right: 0;
}
.sprite-panel.open { display: block; animation: softFadeIn 0.22s ease; }
.sprite-panel-title { font-size: 12px; font-weight: 800; color: var(--retro-dark); line-height: 1.6; margin-bottom: 8px; }
.sprite-panel-title em { font-style: normal; color: var(--retro-coral-deep); }
.sprite-panel-actions { display: flex; flex-direction: column; gap: 6px; }
.sprite-btn {
  background: #fff; border: 1.5px solid var(--retro-teal-dark); color: var(--retro-teal-dark);
  padding: 8px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer;
  text-align: left; transition: all 0.18s;
}
.sprite-btn:hover { background: var(--retro-teal-dark); color: var(--retro-cream); }
.sprite-btn.ok { border-color: var(--primary); color: var(--primary-dark); }
.sprite-btn.ok:hover { background: var(--primary); color: #fff; }
.sprite-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--retro-teal-dark);
}
.sprite-toggle-label { font-size: 12px; font-weight: 700; color: var(--retro-dark); line-height: 1.4; }
.sprite-toggle {
  flex: 0 0 auto;
  width: 40px; height: 22px; border-radius: 12px;
  background: #cbd5e1; border: none; cursor: pointer; position: relative; transition: background 0.22s;
}
.sprite-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.22s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.sprite-toggle.on { background: var(--retro-coral); }
.sprite-toggle.on::after { transform: translateX(18px); }

.sprite-connector { width: 16px; height: 2px; background: var(--retro-teal-dark); margin-bottom: 56px; flex: 0 0 auto; }
.sprite-connector.hidden { visibility: hidden; }

/* 姿势图是透明底的 WebP（scripts/sprite/build.py 产出），换姿势 = 换哪一张显示。
   直接换、不交叉淡变：两张同时半透明时背景会透出来，整只泛白一下 */
.sprite-char {
  width: 128px; height: 128px; flex: 0 0 auto;
  cursor: pointer; position: relative;
}
/* 地上的影子：飞器升高时变小变淡，看得出它是浮在空中，不是一张贴纸在上下移 */
.sprite-char::before {
  content: ''; position: absolute; left: 24%; right: 24%; bottom: -8px; height: 10px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(15, 23, 42, .3), rgba(15, 23, 42, 0));
  animation: spriteShadow 2.6s ease-in-out infinite;
}
.sprite-char:focus-visible { outline: 2px solid var(--retro-teal-dark); outline-offset: 4px; border-radius: 12px; }
.sprite-poses {
  position: absolute; inset: 0;
  filter: drop-shadow(0 4px 5px rgba(15, 23, 42, 0.2));
  animation: spriteHover 2.6s ease-in-out infinite;
}
.sprite-pose {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; transform-origin: 50% 85%;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.sprite-pose.on { opacity: 1; }
/* 换姿势时轻轻弹一下（眨眼、回到发呆不弹，不然每几秒就抖一次）；开心时跳起来 */
.sprite-pose.on:is([data-pose="wave"], [data-pose="present"], [data-pose="talk"], [data-pose="write"]) {
  animation: spritePop .32s cubic-bezier(.34, 1.56, .64, 1);
}
.sprite-pose.on[data-pose="happy"] { animation: spriteHop .7s cubic-bezier(.3, .7, .4, 1); }
/* 悬浮：上下之外带一点前後倾，像飞器在空中稳住平衡。translate / rotate 分开写，才不会盖掉姿势的 scale */
@keyframes spriteHover {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  30% { rotate: -1.5deg; }
  50% { translate: 0 -7px; }
  75% { rotate: 1deg; }
}
@keyframes spriteShadow {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  50% { transform: scaleX(.82); opacity: .6; }
}
@keyframes spritePop {
  0% { scale: .94; }
  60% { scale: 1.03; }
  100% { scale: 1; }
}
@keyframes spriteHop {
  0% { translate: 0 0; scale: 1 1; }
  15% { translate: 0 0; scale: 1.04 .94; }
  45% { translate: 0 -16px; scale: .97 1.04; }
  75% { translate: 0 0; scale: 1.03 .96; }
  100% { translate: 0 0; scale: 1 1; }
}
.sprite-char:hover .sprite-poses, .sprite-char:hover::before { animation-play-state: paused; }

/* 尊重系统的「减少动态效果」设定；持续跳动的元素对前庭敏感的人不友好，也更难点中 */
@media (prefers-reduced-motion: reduce) {
  .sprite-char::before, .sprite-poses, .sprite-pose.on { animation: none !important; }
  .sprite-wrap.active { animation: none; }
  .sprite-wrap.leaving { animation: spriteOut 0.3s ease forwards; }
  .blob { animation: none; }
}
.sprite-badge {
  position: absolute; top: 2px; right: 6px;
  min-width: 20px; height: 20px; border-radius: 10px;
  background: #dc2626; color: #fff;   /* --danger（#ef4444）配白字只有 3.8:1，小字要 4.5:1 */
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.sprite-bubble {
  position: absolute; bottom: 132px; right: 0;
  background: var(--retro-coral-deep); color: #fff;
  padding: 8px 14px; border-radius: 12px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 8px 18px -6px rgba(225, 97, 76, 0.6);
  display: none;
}
.sprite-bubble.show { display: block; animation: softFadeIn 0.2s ease; }
.sprite-bubble::after {
  content: ''; position: absolute; bottom: -6px; right: 20px;
  width: 12px; height: 12px; background: var(--retro-coral); transform: rotate(45deg);
}

@media (max-width: 480px) {
  .sprite-panel { max-width: 200px; padding: 12px 12px; }
  .sprite-char { width: 104px; height: 104px; }
  .sprite-bubble { bottom: 108px; }
}

/* 新问题输入对话框 */
.sprite-new-issue {
  position: fixed; inset: 0; background: rgba(15,23,42,0.6); z-index: 1450;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.sprite-new-issue.active { display: flex; animation: softFadeIn 0.2s ease; }
.sprite-new-issue-box {
  background: #fff; border-radius: 16px; max-width: 460px; width: 100%;
  overflow: hidden; box-shadow: 0 22px 50px -12px rgba(0,0,0,0.45);
}
