/* ==========================================================================
   今日支线 SideQuest · PWA 样式表
   --------------------------------------------------------------------------
   三条纪律（与设计报告 §9.4 一致，违反即回退）：
     1. 只有一条缓动曲线 —— var(--ease)，全站不出现第二条
     2. 只有两处动效 —— .compass（"正在寻找…"）与 #boot（首屏兜底），
        两者都是"状态指示"而非装饰；装饰性动效为零
     3. 只有一种字体来源 —— 系统字体栈，绝不加载 Web Font（中文字体包 2MB+，
        与"离线可用 + 首屏 <100KB"的预算直接冲突）

   设计公式：纸的质感 + 一条缓动曲线 + 一个等待动画 + 零装饰性动效。
   ========================================================================== */

/* ---------- 1. Token ---------- */
:root {
  /* 色：原型 app.wxss 的资产，逐字继承 */
  --paper: #f6f2e9;
  --paper-2: #efe9db;
  --paper-3: #e6dfcd;
  --ink: #1f2b24;
  --ink-soft: #5c6b61;
  --ink-faint: #96a29a;
  --vermillion: #c8543a;
  --pine: #2f4f47;
  --pine-deep: #223a34;
  --gold: #c49a4f;
  --line: rgba(31, 43, 36, 0.12);
  --line-soft: rgba(31, 43, 36, 0.06);
  --shadow-paper: 0 12px 36px rgba(31, 43, 36, 0.05);
  --shadow-lift: 0 18px 48px rgba(31, 43, 36, 0.1);

  /* 字：系统栈。Songti 用于标题（纸质票据的衬线感），PingFang 用于正文 */
  --font-display: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --font-body: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* 流体字号：Nixtio 的做法 —— 用 clamp() 代替断点媒体查询 */
  --fs-hero: clamp(1.75rem, 1.35rem + 2vw, 2.5rem);
  --fs-title: clamp(1.25rem, 1.1rem + 0.75vw, 1.625rem);
  --fs-lead: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --fs-body: clamp(0.9375rem, 0.91rem + 0.14vw, 1rem);
  --fs-small: clamp(0.8125rem, 0.79rem + 0.11vw, 0.875rem);
  --fs-tiny: 0.75rem;

  /* 间距：4 的倍数，尺度统一 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* 圆角：只有两个值 */
  --r-card: 16px;
  --r-pill: 28px;

  /* 动效：全站唯一一条曲线 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 0.18s;
  --t-base: 0.32s;
  --t-slow: 0.6s;
  --t-wait: 2s;

  /* z-index 阶梯：层级也是设计系统的一部分 */
  --z-base: 0;
  --z-sticky: 10;
  --z-overlay: 40;
  --z-modal: 50;
  --z-toast: 60;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 深色模式：只改色，不改结构。纸质票据在灯下变暗，不是变黑 */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171c1a;
    --paper-2: #1e2523;
    --paper-3: #262e2b;
    --ink: #ece7db;
    --ink-soft: #a3aea7;
    --ink-faint: #6d7972;
    --vermillion: #e0704f;
    --pine: #7fae9f;
    --pine-deep: #a8ccbf;
    --gold: #d4ad63;
    --line: rgba(236, 231, 219, 0.14);
    --line-soft: rgba(236, 231, 219, 0.07);
    --shadow-paper: 0 12px 36px rgba(0, 0, 0, 0.3);
    --shadow-lift: 0 18px 48px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- 2. 复位 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* 网点纸：原型 .dotfield 的做法，用径向渐变点阵。低不透明度，是纸不是图案 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-base);
  background-image: radial-gradient(
    circle at center,
    rgba(31, 43, 36, 0.055) 0.5px,
    transparent 0.5px
  );
  background-size: 6px 6px;
}

/* 纸纹：叠在网点之上、内容之下。
   两张图都是 tools/make-textures.cjs 生成的，都是无缝的（环面噪声采样），
   所以平铺看不出接缝。刻意压得很淡 —— 纹理一旦重了就是脏，不是纸。
   顺序有讲究：列表里靠前的在上层，所以 128 的细颗粒盖在 512 的云斑上面。 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-base);
  background-image: url("../../assets/tex/paper-grain.png"),
    url("../../assets/tex/paper-cloud.png");
  background-size: 128px 128px, 512px 512px;
  background-repeat: repeat, repeat;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

/* 无障碍：键盘焦点必须可见（安全性之外，这是可用性底线） */
:focus-visible {
  outline: 2px solid var(--vermillion);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 尊重系统的"减少动态效果"。全站只有三处会动：
   .view 的入场、.compass 的等待、#boot 的兜底呼吸 —— 前一个是转场，后两个是状态指示，
   装饰性动效为零。这条规则把它们一起停掉，不需要逐处维护。 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 3. 布局骨架 ---------- */
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 手机上满宽，桌面上居中成一张纸。max-width 卡在 480px —— 这是"手机 App"的尺度 */
.shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + var(--sp-5)) var(--sp-4)
    calc(var(--safe-bottom) + var(--sp-6));
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.view {
  display: none;
  flex-direction: column;
  gap: var(--sp-5);
  animation: rise var(--t-base) var(--ease) both;
}

.view.is-active {
  display: flex;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.center {
  text-align: center;
}

.muted {
  color: var(--ink-soft);
}

.faint {
  color: var(--ink-faint);
}

.tiny {
  font-size: var(--fs-tiny);
}

.small {
  font-size: var(--fs-small);
}

/* 视觉隐藏但保留给读屏软件 —— 无障碍标签用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 4. 纸片与票据 ---------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  padding: var(--sp-4);
  box-shadow: var(--shadow-paper);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
}

/* 标签 / 芯片 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--fs-tiny);
  color: var(--ink-soft);
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* 页头 */
.head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.head h1 {
  font-size: var(--fs-hero);
}

/* 眉标：小号大写字距，用来给段落定调 */
.eyebrow {
  font-size: var(--fs-tiny);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- 5. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-pill);
  font-size: var(--fs-lead);
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--pine);
  color: var(--paper);
}

.btn-accent {
  background: var(--vermillion);
  color: #fff;
}

.btn-ghost {
  border-color: var(--line);
  color: var(--ink);
  background: transparent;
}

.btn-quiet {
  color: var(--ink-soft);
  min-height: 44px;
  padding: 0 var(--sp-3);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 40px;
  font-size: var(--fs-small);
  padding: 0 var(--sp-4);
}

.btn-row {
  display: flex;
  gap: var(--sp-2);
}

.btn-row > .btn {
  flex: 1;
}

/* 底部固定操作条：拇指可达区 */
.dock {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) 0 calc(var(--safe-bottom) + var(--sp-3));
  background: linear-gradient(
    to top,
    var(--paper) 62%,
    color-mix(in srgb, var(--paper) 0%, transparent)
  );
}

/* ---------- 6. 选择器（滑块 / 卡组 / 开关） ---------- */
/* 时间 / 预算：横排数字，选中项填充松绿 */
.seg {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg-item {
  flex: 1 0 auto;
  min-width: 64px;
  min-height: 48px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.seg-item .v {
  font-family: var(--font-display);
  font-size: var(--fs-lead);
  line-height: 1.2;
}

.seg-item .k {
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}

.seg-item[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: var(--paper);
}

.seg-item[aria-pressed="true"] .k {
  color: color-mix(in srgb, var(--paper) 70%, transparent);
}

/* 心情 / 模式：带符号的大卡 */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.tile {
  position: relative;
  min-height: 76px;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-1);
  text-align: left;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.tile .mark {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink-faint);
}

.tile .label {
  font-size: var(--fs-small);
}

.tile[aria-pressed="true"] {
  background: var(--pine);
  border-color: var(--pine);
  color: var(--paper);
}

.tile[aria-pressed="true"] .mark {
  color: var(--gold);
}

/* 多选：右上角一个对勾 */
.tile-check[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
}

/* 滑杆：新鲜度 1–5 */
.range {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.range input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
}

.range input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}

.range input[type="range"]::-moz-range-track {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}

.range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--vermillion);
  border: 3px solid var(--paper);
  box-shadow: var(--shadow-paper);
}

.range input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--vermillion);
  border: 3px solid var(--paper);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}

/* ---------- 7. 校准（onboarding） ---------- */
.progress {
  height: 2px;
  background: var(--line-soft);
  border-radius: 1px;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--vermillion);
  border-radius: 1px;
  transition: width var(--t-base) var(--ease);
}

.q-num {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.q-title {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  line-height: 1.4;
}

.q-hint {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

/* ---------- 8. 支线卡（核心产物） ---------- */
.quest-kicker {
  font-size: var(--fs-tiny);
  letter-spacing: 0.1em;
  color: var(--vermillion);
}

.quest-title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: 1.3;
}

.quest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.quest-meta b {
  font-weight: 500;
  color: var(--ink);
}

/* 步骤：编号用票据序号的样子 */
.steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  counter-reset: step;
}

.steps li {
  display: flex;
  gap: var(--sp-3);
  font-size: var(--fs-body);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 理由：为什么是这条 */
.why {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

.why p::before {
  content: "— ";
  color: var(--ink-faint);
}

/* 安全提示：必须显眼，但不是报错 */
.safety {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--gold);
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  font-size: var(--fs-small);
  color: var(--ink);
}

.safety::before {
  content: "!";
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 色带：场景族的颜色，出现在卡片左缘 */
.family-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--pine);
}

/* ---------- 9. 等待态：全站仅有的两处动效之一，且是状态指示不是装饰 ---------- */
/* 指南针加载器。技法来自 uiverse.io/Nawsome/ancient-yak-42（MIT），
   重绘为纸质配色；保留了它最值得学的两点：
     · 单一 --dur 变量统摄全组动画
     · 负 animation-delay 造相位差（刻度依次亮起，而不是一起闪）
   SVG viewBox 160×160，圆心 (80,80)，环半径 72 —— 周长 452 与 dashoffset 对应。 */
.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-7) 0;
  text-align: center;
}

.compass {
  --dur: var(--t-wait);
  display: block;
  width: 84px;
  height: 84px;
  overflow: visible;
  color: var(--ink-faint);
}

.compass__arrows,
.compass__ring-rotate,
.compass__ring-stroke,
.compass__tick {
  animation-duration: var(--dur);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.compass__arrows {
  animation-name: compass-arrows;
  transform-origin: 80px 80px;
}

.compass__ring-rotate,
.compass__ring-stroke {
  transform-origin: 80px 80px;
}

.compass__ring-rotate {
  animation-name: compass-ring-rotate;
}

.compass__ring-stroke {
  animation-name: compass-ring-stroke;
  stroke: var(--vermillion);
}

.compass__tick {
  animation-name: compass-tick;
  stroke: var(--gold);
}

/* 负延迟错峰：8 个刻度依次点亮（nth-of-type 只数 line，不受 circle 干扰） */
.compass__tick:nth-of-type(2) { animation-delay: -1.75s; }
.compass__tick:nth-of-type(3) { animation-delay: -1.5s; }
.compass__tick:nth-of-type(4) { animation-delay: -1.25s; }
.compass__tick:nth-of-type(5) { animation-delay: -1s; }
.compass__tick:nth-of-type(6) { animation-delay: -0.75s; }
.compass__tick:nth-of-type(7) { animation-delay: -0.5s; }
.compass__tick:nth-of-type(8) { animation-delay: -0.25s; }

@keyframes compass-arrows {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes compass-ring-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(720deg); }
}

/* 扫描弧：452 是整圈周长，收放之间形成"呼吸"的弧长 */
@keyframes compass-ring-stroke {
  from,
  to { stroke-dashoffset: 452; }
  50% { stroke-dashoffset: 169.5; }
}

@keyframes compass-tick {
  from,
  3%,
  47%,
  to { stroke-dashoffset: -12; }
  14%,
  36% { stroke-dashoffset: 0; }
}

.waiting-text {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

/* ---------- 9.5 附近雷达图 ----------
   纯自绘，无底图、无第三方 SDK。三条边界在这里兑现：
     · 不放开任何一条 CSP（地图 SDK 至少要放开四条）
     · 不消耗任何地图额度（画多少次都是 0）
     · 坐标只用于本次计算，画完即弃，不落库（报告 §5.4）
   颜色一律走 token，改主题只改一处。 */
.radar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0 var(--sp-1);
}

/* 作者写的 display 会盖掉 [hidden] 的 display:none，得自己补一条 */
.radar-wrap[hidden] {
  display: none;
}

.radar {
  display: block;
  width: 200px;
  height: 200px;
  color: var(--ink-faint);
}

/* 距离环与准线用 currentColor，颜色只在这一处决定 */
.radar__labels text,
.radar__north {
  fill: var(--ink-faint);
  font-family: inherit;
}

.radar__north {
  fill: var(--ink-soft);
}

.radar__me-dot {
  fill: var(--ink);
}

/* 分类配色：吃的=朱红、逛的=松绿、公交=金、其余=淡墨 */
.radar__dot--food { fill: var(--vermillion); }
.radar__dot--scenic { fill: var(--pine); }
.radar__dot--transit { fill: var(--gold); }
.radar__dot--other { fill: var(--ink-soft); }

.radar__dot {
  stroke: var(--paper);
  stroke-width: 1;
}

.radar-caption {
  font-size: var(--fs-small);
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}

/* 图例：四个小圆点 + 文字，说明颜色代表什么 */
.radar-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-1) var(--sp-3);
}

.radar-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}

.radar-legend__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.radar-legend__dot--food { background: var(--vermillion); }
.radar-legend__dot--scenic { background: var(--pine); }
.radar-legend__dot--transit { background: var(--gold); }

/* ---------- 10. 票根 ---------- */
.ticket {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

/* 票根自己的纸：墨点（手工纸里偶见的杂质）。
   只在这一张卡上出现 —— 它是"一张纸"，不是整个 App 的背景。 */
.ticket::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("../../assets/tex/paper-flecks.png");
  background-size: 96px 96px;
}

/* 内容要盖在纸纹上面，否则墨点会浮在文字上 */
.ticket > * {
  position: relative;
  z-index: 1;
}

.ticket-body {
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.ticket-serial {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.ticket-title {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  line-height: 1.35;
}

/* 票根底部的传播位：一行链接 + 人格标签。这是唯一的传播资产 */
.ticket-foot {
  padding: var(--sp-4);
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}

.ticket-foot .brand {
  font-family: var(--font-display);
  color: var(--ink-soft);
}

/* ---------- 11. 档案页 ---------- */
.persona {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.persona-title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
}

/* 12 维条形图：纯 CSS，无依赖 */
.vector {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.vector-row {
  display: grid;
  grid-template-columns: 3.5em 1fr 2em;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-tiny);
}

.vector-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
}

.vector-bar > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--pine);
  transition: width var(--t-slow) var(--ease);
}

.vector-val {
  text-align: right;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

/* 等级 */
.level {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}

.level-num {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  color: var(--vermillion);
}

/* 统计格 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

.stat {
  padding: var(--sp-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  text-align: center;
}

.stat .n {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  line-height: 1.2;
}

.stat .k {
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
}

/* 徽章 */
.badges {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}

.badge {
  aspect-ratio: 1;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  text-align: center;
  padding: 2px;
}

.badge .i {
  font-size: 1.125rem;
  line-height: 1;
}

.badge.is-owned {
  border-color: var(--gold);
  color: var(--ink);
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

/* ---------- 11.5 图书馆列表 ---------- */
.lib-item {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
}

.lib-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 60px;
  padding: var(--sp-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  background: var(--paper-2);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease);
}

.lib-row:hover {
  border-color: var(--line);
}

.lib-bar {
  flex: 0 0 auto;
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
}

.lib-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lib-title {
  font-size: var(--fs-body);
  line-height: 1.35;
}

/* 单条删除：小、靠边、不抢视线 —— 但不能藏起来（数据主权要可见） */
.lib-del {
  flex: 0 0 auto;
  width: 44px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  background: transparent;
  color: var(--ink-faint);
  font-size: 1.25rem;
  line-height: 1;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.lib-del:hover {
  color: var(--vermillion);
  border-color: var(--vermillion);
}

/* ---------- 12. 抽屉 / 弹层 ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(31, 43, 36, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}

.sheet-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  max-width: 480px;
  margin: 0 auto;
  max-height: 86dvh;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--safe-bottom) + var(--sp-5));
  background: var(--paper-2);
  border-radius: var(--r-card) var(--r-card) 0 0;
  box-shadow: var(--shadow-lift);
  transform: translateY(101%);
  transition: transform var(--t-base) var(--ease);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.sheet.is-open {
  transform: none;
}

.sheet-grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto;
}

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 88px);
  z-index: var(--z-toast);
  transform: translate(-50%, 12px);
  max-width: min(88vw, 420px);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--fs-small);
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 13. 空态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  text-align: center;
  color: var(--ink-soft);
}

.empty-mark {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--ink-faint);
}

/* ---------- 14. 底部导航 ---------- */
.tabbar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  padding: var(--sp-2) var(--sp-4) calc(var(--safe-bottom) + var(--sp-2));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
}

/* hidden 属性必须显式生效：UA 样式表的 [hidden]{display:none} 权重低于
   上面那条 .tabbar{display:flex}，不写这一条的话校准期间导航栏照样显示 ——
   而校准期间是不该有别的出口的。 */
.tabbar[hidden] {
  display: none;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2) 0;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  transition: color var(--t-fast) var(--ease);
}

.tab[aria-current="page"] {
  color: var(--ink);
}

.tab .i {
  font-size: 1.125rem;
  line-height: 1;
}

/* ---------- 15. 表单与开关 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field-label {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}

/* 多行输入：票根备注用。留白给足，因为这是用户唯一会写字的输入框 */
.ta {
  width: 100%;
  min-height: 92px;
  padding: var(--sp-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-small);
  line-height: 1.7;
  resize: vertical;
}

.ta::placeholder {
  color: var(--ink-faint);
}

/* 危险操作：清空数据。用朱砂，但样式克制，不诱导点击 */
.btn-danger {
  border-color: var(--vermillion);
  color: var(--vermillion);
  background: transparent;
}

/* ---------- 16. 首屏兜底 ---------- */
/* index.html 里那个 #boot，在 main.js 跑起来之后会被 remove()。
   它存在的意义是：JS 慢或加载失败时，用户看到的是一条呼吸的细线，
   而不是一张白纸。这是全站第二处也是最后一处动画 —— 它不属于"装饰"，
   它是"正在启动"的状态指示，和 compass 同类。 */
#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  z-index: 100;
}

#boot .boot-mark {
  width: 96px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0.18;
  animation: boot-breathe 1.8s var(--ease) infinite;
}

/* 加载出错：线变成朱砂色并停住。不弹窗、不报警，只是让失败可见 */
#boot[data-error] .boot-mark {
  background: var(--vermillion);
  opacity: 1;
  animation: none;
}

/* noscript 的说明。原来写在 index.html 的行内 style 上，挪到这里是为了让
   内联样式彻底归零 —— CSP 的 style-src 只要还有一处 style= 就得上 unsafe-inline，
   而 unsafe-inline 会让整条 style-src 的防护作废。 */
.noscript-note {
  padding: var(--sp-5, 24px);
  font-family: var(--font-body);
  color: var(--ink);
}

@keyframes boot-breathe {
  0%,
  100% {
    transform: scaleX(0.35);
    opacity: 0.12;
  }
  50% {
    transform: scaleX(1);
    opacity: 0.24;
  }
}

/* ---------- 17. 打印（票根另存为 PDF 的兜底路径） ---------- */
@media print {
  body::before,
  body::after,
  .tabbar,
  .dock,
  .btn {
    display: none !important;
  }
  .ticket {
    box-shadow: none;
    border: 1px solid #999;
  }
}
