
/* 与 tokens.css 完全一致，内联以支持 file:// 单文件双击与离线零请求 */
:root {
  --paper-bg: #f4efe4;
  --paper-surface: #fffdf7;
  --paper-sunk: #ebe4d5;
  --paper-hover: #efe9dc;

  --ink-primary: #2b2622;
  --ink-secondary: #544a41;
  --ink-muted: #6e6358;  /* B: 小字对比度提到 ~4.5:1 */
  --ink-faint: #afa497;
  --ink-on-dark: #f7f3ea;

  --line-hairline: #dcd1bd;
  --line-strong: #c8b99e;

  --seal-red: #b23a2f;
  --seal-red-hover: #962f26;
  --seal-red-soft: #f5e4e1;
  --seal-red-border: #d99b94;

  --rope-wood: #b08a5a;
  --rope-wood-dark: #87663e;
  --rope-wood-light: #d2b48c;

  --warn-amber: #a86b24;
  --warn-amber-soft: #f7ecd9;

  --scrim-light: rgba(43, 38, 34, 0.34);
  --scrim-dark: rgba(20, 17, 15, 0.94);

  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC",
    "Source Han Serif SC", "SimSun", "NSimSun", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --text-display: 2.125rem;
  --leading-display: 1.28;
  --text-year: 2.5rem;
  --leading-year: 1.05;
  --text-h2: 1.375rem;
  --leading-h2: 1.38;
  --text-h3: 1.0625rem;
  --leading-h3: 1.45;
  --text-body: 0.9375rem;
  --leading-body: 1.65;
  --text-narrative: 1.0625rem;
  --leading-narrative: 1.92;
  --text-meta: 0.8125rem;
  --leading-meta: 1.5;
  --text-tag: 0.75rem;
  --leading-tag: 1.3;
  --text-sub: 0.84375rem;   /* B: 对话气泡 13.5px，448px 面板更耐读 */
  --leading-sub: 1.62;
  --text-micro: 0.6875rem;
  --leading-micro: 1.2;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-none: 0px;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-pill: 999px;

  --shadow-paper:
    0 1px 2px rgba(43, 38, 34, 0.08),
    0 3px 8px -2px rgba(43, 38, 34, 0.07);
  --shadow-lift:
    0 6px 16px -4px rgba(43, 38, 34, 0.16),
    0 2px 5px -1px rgba(43, 38, 34, 0.10);
  --shadow-overlay:
    0 18px 42px -10px rgba(43, 38, 34, 0.24),
    0 4px 12px -2px rgba(43, 38, 34, 0.12);

  --dur-fast: 140ms;
  --dur-base: 240ms;
  --dur-slow: 360ms;
  --ease-paper: cubic-bezier(0.22, 0.68, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --focus-ring: 0 0 0 2px var(--paper-surface), 0 0 0 4px var(--seal-red);
  --focus-ring-dark: 0 0 0 2px #1c1917, 0 0 0 4px #e57a6f;

  --topbar-h: 56px;
  --chat-w: 448px;
  --detail-w: 600px;
  --nav-w: 300px;
  --picker-w: 940px;

  --z-base: 1;
  --z-sticky: 20;
  --z-topbar: 30;
  --z-chat: 40;
  --z-detail: 50;
  --z-nav: 60;
  --z-modal: 70;
  --z-viewer: 80;
  --z-toast: 90;

  /* B: 照片墙内部层级 */
  --z-wall-rope: 2;
  --z-wall-photo: 3;
  --z-wall-clip: 5;
  --z-wall-hover: 12;

  /* 安全区 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --status-ok: #3f6a47;
}

@media (max-width: 767px) {
  :root {
    --text-display: 1.625rem;
    --leading-display: 1.32;
    --text-year: 1.875rem;
    --text-h2: 1.25rem;
    --text-h3: 1rem;
    --text-body: 0.9375rem;
    --text-narrative: 1rem;
    --leading-narrative: 1.88;
    --topbar-h: 52px;
  }
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   基础重置与中文排版规则（标点挤压、避头尾、等宽数字）
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 16px;
  background: var(--paper-bg);
  color: var(--ink-primary);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  background-color: var(--paper-bg);
  background-image:
    radial-gradient(rgba(135, 102, 62, 0.055) 1px, transparent 0),
    linear-gradient(180deg, rgba(255, 253, 247, 0.35) 0%, rgba(244, 239, 228, 0) 240px);
  background-size: 24px 24px, 100% 100%;
  color: var(--ink-primary);
  line-break: strict;
  hanging-punctuation: allow-end;  /* B: 中文标点悬挂 */
  overflow-wrap: break-word;
  font-feature-settings: "kern" 1, "halt" 1;
}
h1, h2, h3, .serif {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tnum { font-variant-numeric: tabular-nums; }
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* 通用按钮与印章样式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper-surface);
  color: var(--ink-primary);
  font-size: var(--text-meta);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-paper),
              border-color var(--dur-fast) var(--ease-paper),
              color var(--dur-fast) var(--ease-paper);
}
.btn:hover:not(:disabled) {
  background: var(--paper-hover);
  border-color: var(--ink-muted);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--seal-red);
  border-color: var(--seal-red);
  color: var(--ink-on-dark);
}
.btn-primary:hover:not(:disabled) {
  background: var(--seal-red-hover);
  border-color: var(--seal-red-hover);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--paper-sunk);
  color: var(--ink-primary);
  border-color: transparent;
}
.btn-danger-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--seal-red);
}
.btn-danger-ghost:hover:not(:disabled) {
  background: var(--seal-red-soft);
}
.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: var(--text-tag);
}
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-secondary);
}
.btn-icon:hover {
  background: var(--paper-sunk);
  color: var(--ink-primary);
}

/* 手写批注式标签纸片 */
.tag-slip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-tag);
  line-height: var(--leading-tag);
  color: var(--ink-secondary);
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-left: 2px solid var(--rope-wood);
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.tag-slip.is-active {
  background: var(--seal-red-soft);
  border-color: var(--seal-red-border);
  border-left-color: var(--seal-red);
  color: var(--seal-red);
}
.tag-slip-remove {
  font-size: 13px;
  line-height: 1;
  color: var(--ink-muted);
  padding: 0 2px;
}
.tag-slip-remove:hover { color: var(--seal-red); }

/* 印章标记 */
.seal-stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1.5px solid var(--seal-red);
  border-radius: var(--radius-xs);
  color: var(--seal-red);
  font-family: var(--font-serif);
  font-size: var(--text-tag);
  font-weight: 700;
  letter-spacing: 0.12em;
  transform: rotate(-4deg);
  user-select: none;
  background: rgba(255, 253, 247, 0.72);
}

/* ==========================================================================
   应用外壳：顶栏 + 主画布 + 右侧 AI 对话停靠栏
   ========================================================================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--paper-bg);
  border-bottom: 1px solid var(--line-hairline);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: 0.06em;
}
.brand-seal {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: var(--seal-red);
  color: var(--ink-on-dark);
  font-family: var(--font-serif);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  flex-shrink: 0;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: var(--space-3);
}
.topbar-tab {
  position: relative;
  height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-meta);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.topbar-tab:hover { background: var(--paper-sunk); color: var(--ink-primary); }
.topbar-tab[aria-current="page"] {
  color: var(--ink-primary);
  font-weight: 600;
  background: var(--paper-surface);
  box-shadow: inset 0 -2px 0 var(--seal-red);
}
.badge-count {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--paper-sunk);
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.topbar-tab[aria-current="page"] .badge-count {
  background: var(--seal-red-soft);
  color: var(--seal-red);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.workspace {
  display: flex;
  flex: 1;
  min-height: calc(100dvh - var(--topbar-h));
}
.main-stage {
  flex: 1;
  min-width: 0;
  padding: var(--space-6) var(--space-8) var(--space-16);
  transition: margin-right var(--dur-base) var(--ease-paper);
}
body.chat-open .main-stage {
  margin-right: var(--chat-w);
}

@media (max-width: 1080px) {
  body.chat-open .main-stage { margin-right: 0; }
}
@media (max-width: 767px) {
  .topbar { padding: 0 var(--space-3); }
  .topbar-nav { display: none; }
  .main-stage { padding: var(--space-4) var(--space-3) var(--space-12); }
  .btn-label-desktop { display: none; }
}

/* ==========================================================================
   4.7 汉堡侧栏 + 手机左缘右滑手势（原生 popover="manual" + scroll-snap）
   ========================================================================== */
.nav-drawer-popover {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
  z-index: var(--z-nav);
}
.nav-drawer-popover:not(:popover-open) { display: none; }

.nav-snap-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-snap-track::-webkit-scrollbar { display: none; }

.nav-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim-light);
  opacity: var(--drawer-progress, 0);
  pointer-events: none;
  transition: opacity var(--dur-fast) linear;
}

.nav-panel {
  position: relative;
  z-index: 2;
  flex: 0 0 var(--nav-w);
  width: var(--nav-w);
  max-width: 84vw;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--paper-surface);
  border-right: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-dismiss-spacer {
  position: relative;
  z-index: 1;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: end;
  scroll-snap-stop: always;
}
.nav-header {
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-hairline);
}
.nav-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}
.nav-group { margin-bottom: var(--space-6); }
.nav-group-label {
  font-size: var(--text-micro);
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  padding: 0 var(--space-3) var(--space-2);
  border-bottom: 1px dashed var(--line-hairline);
  margin-bottom: var(--space-2);
}
.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--ink-secondary);
  font-size: var(--text-body);
  text-align: left;
  transition: background var(--dur-fast);
}
.nav-item:hover { background: var(--paper-hover); color: var(--ink-primary); }
.nav-item[aria-current="page"] {
  background: var(--paper-sunk);
  color: var(--ink-primary);
  font-weight: 600;
  border-left: 3px solid var(--seal-red);
  padding-left: calc(var(--space-3) - 3px);
}
.nav-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--line-hairline);
  background: var(--paper-bg);
  font-size: var(--text-tag);
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-stats {
  display: flex;
  gap: var(--space-4);
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

/* 手机左缘隐形滑出感应条 */
.mobile-edge-grab {
  display: none;
}
@media (max-width: 767px) {
  .mobile-edge-grab {
    display: block;
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    bottom: 0;
    width: 18px;
    z-index: calc(var(--z-topbar) - 1);
    touch-action: pan-x;
  }
}

/* ==========================================================================
   4.1 绳索照片墙（最重要）
   ========================================================================== */
.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line-hairline);
}
.view-title {
  margin: 0;
  font-size: var(--text-h2);
  line-height: var(--leading-h2);
}
.view-subtitle {
  margin: 4px 0 0;
  font-size: var(--text-meta);
  color: var(--ink-muted);
}

.wall-year-block {
  margin-bottom: var(--space-10);
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
}
.wall-year-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.wall-year-num {
  font-family: var(--font-serif);
  font-size: var(--text-year);
  line-height: var(--leading-year);
  font-weight: 700;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.wall-year-meta {
  font-size: var(--text-meta);
  color: var(--ink-muted);
}

/* 单行晾衣绳舞台 */
.rope-row {
  position: relative;
  margin-bottom: var(--space-8);
  padding-top: 26px;
  padding-bottom: 16px;
  /* 宽度由 layoutWall 根据本行照片数量动态设定，1-2张不拉满整屏 */
}
.rope-svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 76px;
  pointer-events: none;
  z-index: var(--z-wall-rope);
  overflow: visible;
}
.rope-photos {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 0 28px;
  min-height: 220px;
}

/* 挂在绳子上的相纸单元 */
.hanging-photo {
  position: relative;
  width: var(--photo-w, 206px);
  flex: 0 0 auto;
  margin-top: var(--sag-y, 0px);
  margin-left: var(--stagger-x, 0px);
  transform: rotate(var(--tilt, 0deg));
  transform-origin: 50% 8px;
  transition: transform var(--dur-base) var(--ease-paper), z-index 0s;
  z-index: var(--z-wall-photo);
}
.hanging-photo:hover,
.hanging-photo:focus-within {
  transform: translateY(-7px) rotate(0deg) scale(1.02);
  z-index: var(--z-wall-hover);
}

/* 木夹子：后片在绳后(z:1)，前片压住相纸上沿与绳子(z:5) */
.clothespin {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 16px;
  height: 36px;
  transform: translateX(-50%) rotate(var(--pin-tilt, 0deg));
  pointer-events: none;
  z-index: var(--z-wall-clip);
}
.clothespin-body {
  position: absolute;
  inset: 0;
  border-radius: 2px 2px 3px 3px;
  background: linear-gradient(
    90deg,
    var(--rope-wood-dark) 0%,
    var(--rope-wood-light) 35%,
    var(--rope-wood) 72%,
    var(--rope-wood-dark) 100%
  );
  border: 1px solid rgba(87, 63, 35, 0.55);
  box-shadow: 1px 3px 5px rgba(43, 38, 34, 0.24);
  transition: box-shadow var(--dur-base) var(--ease-paper);
}
.clothespin-spring {
  position: absolute;
  left: -1px;
  right: -1px;
  top: 15px;
  height: 4px;
  background: linear-gradient(180deg, #9b9389, #4a433c);
  border-radius: 1px;
}
.clothespin-groove {
  position: absolute;
  left: 50%;
  top: 3px;
  bottom: 4px;
  width: 1px;
  background: rgba(54, 38, 20, 0.35);
}
.hanging-photo:hover .clothespin-body,
.hanging-photo:focus-within .clothespin-body {
  box-shadow: 2px 6px 10px rgba(43, 38, 34, 0.38);
}

/* 相纸卡片（白边 + 纸面投影） */
.photo-print {
  display: block;
  width: 100%;
  padding: 8px 8px 26px;
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-paper);
  text-align: left;
  transition: box-shadow var(--dur-base) var(--ease-paper);
}
.hanging-photo:hover .photo-print,
.hanging-photo:focus-within .photo-print {
  box-shadow: var(--shadow-lift);
}
.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--aspect, 4 / 3);
  overflow: hidden;
  background: var(--paper-sunk);
  border: 1px solid rgba(43, 38, 34, 0.08);
}
.photo-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}
.photo-kind-pill {
  position: absolute;
  right: 6px;
  top: 6px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(43, 38, 34, 0.72);
  color: var(--ink-on-dark);
  font-size: 10px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.photo-foot {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: var(--text-micro);
  color: var(--ink-muted);
}
.photo-date-corner {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.photo-event-link {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-secondary);
  font-family: var(--font-serif);
  font-size: 11px;
  border-bottom: 1px dotted transparent;
}
.photo-event-link:hover {
  color: var(--seal-red);
  border-bottom-color: var(--seal-red);
}

@media (max-width: 767px) {
  .rope-photos {
    padding: 0 12px;
    min-height: 168px;
  }
  .hanging-photo {
    width: var(--photo-w-mobile, 154px);
  }
  .photo-print {
    padding: 6px 6px 22px;
  }
  .clothespin {
    width: 14px;
    height: 30px;
    top: -18px;
  }
  .photo-event-link { max-width: 78px; }
}

/* ==========================================================================
   4.2 AI 对话面板（桌面右侧停靠 448px / 手机全屏）
   ========================================================================== */
.chat-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--chat-w);
  background: var(--paper-surface);
  border-left: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  z-index: var(--z-chat);
  transform: translateX(0);
  transition: transform var(--dur-base) var(--ease-paper);
}
.chat-panel[hidden] { display: none !important; }
.chat-panel.is-closed {
  transform: translateX(100%);
  pointer-events: none;
}
.chat-mobile-handle {
  display: none;
}
.chat-head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  background: var(--paper-bg);
}
.chat-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  font-weight: 600;
}
.chat-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  overscroll-behavior: contain;
}
.chat-jump-latest {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-3);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--ink-primary);
  color: var(--ink-on-dark);
  font-size: var(--text-tag);
  box-shadow: var(--shadow-lift);
  z-index: 4;
}
.chat-empty {
  margin: auto 0;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--ink-secondary);
}
.chat-empty-quote {
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  color: var(--ink-primary);
  margin: 0 0 var(--space-2);
}
.chat-empty-sub {
  font-size: var(--text-meta);
  color: var(--ink-muted);
  margin: 0 0 var(--space-5);
}
.chat-empty-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
}

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg-row.is-user { align-items: flex-end; }
.msg-row.is-assistant { align-items: flex-start; }

.msg-bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sub);
  line-height: var(--leading-sub);
  white-space: pre-wrap;
}
.msg-row.is-user .msg-bubble {
  background: var(--paper-sunk);
  border: 1px solid var(--line-hairline);
  color: var(--ink-primary);
}
.msg-row.is-assistant .msg-bubble {
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-left: 3px solid var(--rope-wood);
  color: var(--ink-primary);
  max-width: 100%;
}
.msg-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  justify-content: flex-end;
}
.msg-thumb-item {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--line-hairline);
  background: var(--paper-surface);
}
.msg-thumb-num {
  position: absolute;
  left: 3px;
  top: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  background: var(--seal-red);
  color: var(--ink-on-dark);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.msg-expand-btn {
  display: inline-block;
  margin-top: 6px;
  font-size: var(--text-tag);
  color: var(--seal-red);
  border-bottom: 1px dotted var(--seal-red-border);
}

/* 流式打字点 */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: dotPulse 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* 记忆卡（非后台表单，像旧相册便笺卡） */
.memory-card {
  position: relative;
  width: 100%;
  background: var(--paper-bg);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--seal-red);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  box-shadow: var(--shadow-paper);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.memory-card.is-committed {
  border-top-color: var(--rope-wood);
  background: var(--paper-surface);
}
.memory-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.mcard-title-input {
  width: 100%;
  border: 0;
  border-bottom: 1px dashed transparent;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink-primary);
  padding: 2px 0;
}
.mcard-title-input:hover,
.mcard-title-input:focus {
  border-bottom-color: var(--line-strong);
  outline: none;
  box-shadow: none;
}
.mcard-title-input:focus-visible {
  border-bottom: 1.5px solid var(--seal-red);
}
.mcard-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.mcard-date-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mcard-date-field label {
  font-size: var(--text-micro);
  color: var(--ink-muted);
}
.mcard-date-field input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  background: var(--paper-surface);
  font-size: var(--text-tag);
  color: var(--ink-primary);
}
.mcard-summary-input {
  width: 100%;
  border: 0;
  border-left: 2px solid var(--line-strong);
  padding: 2px 0 2px 10px;
  background: transparent;
  font-size: var(--text-meta);
  color: var(--ink-secondary);
}
.mcard-summary-input:focus {
  outline: none;
  border-left-color: var(--seal-red);
}
.mcard-details {
  border-top: 1px dashed var(--line-hairline);
  padding-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.mcard-narrative {
  width: 100%;
  min-height: 82px;
  padding: 8px 10px;
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  background: var(--paper-surface);
  font-family: var(--font-serif);
  font-size: var(--text-meta);
  line-height: 1.75;
  resize: vertical;
}
.mcard-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.mcard-tag-add {
  width: 92px;
  padding: 2px 6px;
  font-size: var(--text-tag);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xs);
  background: transparent;
}
.mcard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line-hairline);
}

/* 失败态原位重试 */
.chat-error-bar {
  margin: 0 var(--space-4) var(--space-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--seal-red-soft);
  border: 1px solid var(--seal-red-border);
  color: var(--seal-red);
  font-size: var(--text-tag);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* 附件带 + 输入区 */
.chat-composer {
  border-top: 1px solid var(--line-hairline);
  background: var(--paper-bg);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.attach-strip-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attach-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
}
.attach-item {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--paper-surface);
  overflow: hidden;
}
.attach-num {
  position: absolute;
  left: 3px;
  top: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  background: var(--seal-red);
  color: var(--ink-on-dark);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.attach-remove {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(43, 38, 34, 0.78);
  color: var(--ink-on-dark);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}
.attach-hint {
  font-size: var(--text-micro);
  color: var(--ink-muted);
}
.composer-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--paper-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.composer-box:focus-within {
  border-color: var(--seal-red);
}
.composer-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 132px;
  border: 0;
  background: transparent;
  resize: none;
  font-size: var(--text-body);
  line-height: 1.5;
}
.composer-textarea:focus { outline: none; box-shadow: none; }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

@media (max-width: 767px) {
  .chat-panel {
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--vvh, 100dvh);
    border-left: 0;
    transform: translateY(0);
  }
  .chat-panel.is-closed {
    transform: translateY(100%);
  }
  .chat-mobile-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 0 4px;
    background: var(--paper-bg);
    touch-action: none;
    cursor: grab;
  }
  .chat-handle-bar {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
  }
  .chat-handle-hint {
    font-size: 10px;
    color: var(--ink-muted);
  }
}

/* ==========================================================================
   4.3 事件详情抽屉（桌面 600px / 手机全屏）
   ========================================================================== */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim-light);
  z-index: var(--z-detail);
  display: flex;
  justify-content: flex-end;
}
.detail-drawer {
  width: var(--detail-w);
  max-width: 100%;
  height: 100dvh;
  background: var(--paper-surface);
  border-left: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
}
.detail-top {
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--line-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--paper-bg);
}
.detail-date-folio {
  font-family: var(--font-serif);
  font-size: var(--text-meta);
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-8) var(--space-10);
}
.detail-title {
  margin: 0 0 var(--space-3);
  font-family: var(--font-serif);
  font-size: var(--text-display);
  line-height: var(--leading-display);
  color: var(--ink-primary);
}
.detail-summary {
  margin: 0 0 var(--space-6);
  padding-left: var(--space-3);
  border-left: 2px solid var(--seal-red);
  font-size: var(--text-body);
  color: var(--ink-secondary);
}
/* 自适应照片排版（1大图 / 2并排错落 / 3一大两小 / 4+拼贴） */
.detail-gallery {
  margin-bottom: var(--space-6);
  display: grid;
  gap: 10px;
}
.detail-gallery.count-1 { grid-template-columns: 1fr; }
.detail-gallery.count-2 {
  grid-template-columns: 1.08fr 0.92fr;
  align-items: start;
}
.detail-gallery.count-2 .dg-item:nth-child(2) { margin-top: 18px; }
.detail-gallery.count-3 {
  grid-template-columns: 1.35fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.detail-gallery.count-3 .dg-item:first-child { grid-row: span 2; }
.detail-gallery.count-4 {
  grid-template-columns: repeat(6, 1fr);
}
.detail-gallery.count-4 .dg-item:nth-child(1) { grid-column: span 4; }
.detail-gallery.count-4 .dg-item:nth-child(2) { grid-column: span 2; }
.detail-gallery.count-4 .dg-item:nth-child(3) { grid-column: span 3; }
.detail-gallery.count-4 .dg-item:nth-child(4) { grid-column: span 3; }
.detail-gallery.count-4 .dg-item:nth-child(n+5) { grid-column: span 2; }

.dg-item {
  position: relative;
  padding: 5px;
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  box-shadow: var(--shadow-paper);
  border-radius: var(--radius-xs);
  overflow: hidden;
  display: block;
  width: 100%;
  text-align: left;
}
.dg-media-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--paper-sunk);
}
.detail-gallery.count-1 .dg-media-box { aspect-ratio: 16 / 10; }
.detail-gallery.count-3 .dg-item:first-child .dg-media-box { height: 100%; aspect-ratio: auto; min-height: 220px; }

/* 轻音频条 */
.audio-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  margin-bottom: var(--space-5);
  background: var(--paper-bg);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-sm);
}
.audio-play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--ink-primary);
  color: var(--ink-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}
.audio-play-btn.is-playing {
  background: var(--seal-red);
  border-color: var(--seal-red);
  color: var(--ink-on-dark);
}
.audio-meta {
  flex: 1;
  min-width: 0;
}
.audio-title {
  font-size: var(--text-meta);
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  margin-top: 4px;
}
.audio-wave span {
  flex: 1;
  background: var(--line-strong);
  border-radius: 1px;
  transition: background 120ms;
}
.audio-wave span.is-passed { background: var(--seal-red); }
.audio-time {
  font-size: var(--text-micro);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.detail-narrative {
  font-family: var(--font-serif);
  font-size: var(--text-narrative);
  line-height: var(--leading-narrative);
  color: var(--ink-primary);
  white-space: pre-wrap;
  margin: 0 0 var(--space-6);
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line-hairline);
}

/* 就地编辑态 */
.edit-field {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-field label {
  font-size: var(--text-tag);
  color: var(--ink-muted);
}
.edit-input, .edit-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--paper-bg);
  color: var(--ink-primary);
}
.edit-textarea {
  min-height: 150px;
  font-family: var(--font-serif);
  font-size: var(--text-narrative);
  line-height: 1.8;
  resize: vertical;
}
.date-parse-preview {
  font-size: var(--text-tag);
  color: var(--ink-secondary);
  background: var(--paper-sunk);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}
.detail-mobile-bar {
  display: none;
}

@media (max-width: 767px) {
  .detail-drawer { width: 100%; border-left: 0; }
  .detail-top { padding: var(--space-3) var(--space-4); }
  .detail-scroll { padding: var(--space-4) var(--space-4) var(--space-10); }
  .detail-gallery.count-2,
  .detail-gallery.count-3,
  .detail-gallery.count-4 {
    grid-template-columns: 1fr;
  }
  .detail-gallery.count-2 .dg-item:nth-child(2) { margin-top: 0; }
  .detail-gallery.count-3 .dg-item:first-child,
  .detail-gallery.count-4 .dg-item { grid-column: auto !important; grid-row: auto !important; }
  .detail-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--space-4) calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line-hairline);
    background: var(--paper-bg);
  }
  .detail-edit-desktop { display: none; }
}

/* ==========================================================================
   4.4 时间轴
   ========================================================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  margin-bottom: var(--space-6);
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-sm);
  flex-wrap: nowrap;
  overflow-x: auto;
}
.filter-input {
  min-width: 150px;
  flex: 0 1 200px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  background: var(--paper-bg);
  font-size: var(--text-meta);
}
.filter-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  background: var(--paper-bg);
  font-size: var(--text-meta);
  flex-shrink: 0;
}
.filter-tags-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  min-width: 100px;
  scrollbar-width: none;
}
.filter-tags-scroll::-webkit-scrollbar { display: none; }

.timeline-shell {
  position: relative;
}
.tl-spy-indicator {
  position: sticky;
  top: calc(var(--topbar-h) + 10px);
  float: right;
  z-index: var(--z-sticky);
  padding: 3px 10px;
  background: var(--paper-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  font-family: var(--font-serif);
  font-size: var(--text-tag);
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-paper);
  pointer-events: none;
}
.tl-list {
  position: relative;
  padding-left: 112px;
}
.tl-list::before {
  content: "";
  position: absolute;
  left: 96px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line-strong);
}
.tl-year-marker {
  position: relative;
  margin: var(--space-8) 0 var(--space-4);
  display: flex;
  align-items: center;
}
.tl-year-marker:first-child { margin-top: 0; }
.tl-year-marker::before {
  content: "";
  position: absolute;
  left: -36px;
  width: 24px;
  height: 2px;
  background: var(--ink-primary);
}
.tl-year-label {
  position: absolute;
  left: -112px;
  width: 72px;
  text-align: right;
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}
.tl-day-group {
  position: relative;
  margin-bottom: var(--space-5);
  content-visibility: auto;
  contain-intrinsic-size: auto 210px;
}
.tl-day-group.is-multi {
  padding-left: 12px;
  border-left: 2px solid var(--rope-wood-light);
}
.tl-date-tick {
  position: absolute;
  left: -112px;
  top: 14px;
  width: 84px;
  text-align: right;
  font-size: var(--text-tag);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.tl-day-group.is-multi .tl-date-tick { left: -126px; }
.tl-date-tick::after {
  content: "";
  position: absolute;
  right: -12px;
  top: 50%;
  width: 10px;
  height: 1px;
  background: var(--line-strong);
}
.tl-event-card {
  width: 100%;
  text-align: left;
  display: block;
  padding: var(--space-4) var(--space-5);
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-paper);
  margin-bottom: var(--space-3);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.tl-event-card:hover {
  border-color: var(--rope-wood);
  box-shadow: var(--shadow-lift);
}
.tl-card-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  color: var(--ink-primary);
}
.tl-card-summary {
  margin: 0 0 var(--space-3);
  font-size: var(--text-meta);
  color: var(--ink-secondary);
}
.tl-thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 96px));
  gap: 8px;
  margin-bottom: var(--space-3);
}
.tl-thumb {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--line-hairline);
}
.tl-audio-entry {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  background: var(--paper-bg);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xs);
  margin-bottom: var(--space-3);
}

@media (max-width: 767px) {
  .tl-list { padding-left: 68px; }
  .tl-list::before { left: 56px; }
  .tl-year-marker::before { left: -20px; width: 14px; }
  .tl-year-label { left: -68px; width: 46px; font-size: 1.0625rem; }
  .tl-date-tick { left: -68px; width: 48px; font-size: 11px; }
  .tl-day-group.is-multi .tl-date-tick { left: -82px; }
  .tl-date-tick::after { right: -8px; width: 6px; }
  .tl-thumbs { grid-template-columns: repeat(4, 1fr); }
}

/* ==========================================================================
   4.5 未归档收件箱（鞋盒 / 底片袋）
   ========================================================================== */
.inbox-bar {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 10px 14px;
  margin-bottom: var(--space-5);
  background: var(--paper-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-paper);
}
.inbox-group {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--paper-sunk);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-sm);
}
.inbox-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px dashed var(--line-strong);
}
.inbox-group-title {
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  color: var(--ink-primary);
}
.inbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: var(--space-3);
}
.inbox-card {
  position: relative;
  background: var(--paper-surface);
  border: 1px solid var(--line-hairline);
  border-radius: var(--radius-xs);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity var(--dur-fast), border-color var(--dur-fast);
}
.inbox-card.is-selected {
  border-color: var(--seal-red);
  box-shadow: 0 0 0 1px var(--seal-red);
}
.inbox-card.is-dimmed {
  opacity: 0.42;
}
.inbox-select-hit {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(43, 38, 34, 0.08);
  cursor: pointer;
}
.select-order-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--seal-red);
  color: var(--ink-on-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}
.inbox-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: var(--text-micro);
  color: var(--ink-muted);
}
.filetime-warn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--warn-amber-soft);
  color: var(--warn-amber);
  font-size: 10px;
}
.inbox-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px dotted var(--line-hairline);
}

@media (max-width: 767px) {
  .inbox-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==========================================================================
   4.6 素材选择器（940px 原生 dialog）
   ========================================================================== */
dialog.picker-dialog {
  width: min(var(--picker-w), calc(100vw - 24px));
  max-height: min(86dvh, 720px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}
dialog.picker-dialog::backdrop { background: var(--scrim-light); }
.picker-shell {
  display: flex;
  flex-direction: column;
  height: min(86dvh, 720px);
}
.picker-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-hairline);
  background: var(--paper-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.picker-filter-row {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-hairline);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.picker-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 276px;
}
.picker-grid-pane {
  overflow-y: auto;
  padding: 14px 18px;
}
.picker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.picker-cell {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-xs);
  border: 2px solid var(--line-hairline);
  overflow: hidden;
  background: var(--paper-sunk);
  cursor: pointer;
  padding: 0;
}
.picker-cell.is-selected { border-color: var(--seal-red); }
.picker-cell.is-dimmed { opacity: 0.4; }
.picker-archived-mark {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(43, 38, 34, 0.72);
  color: var(--ink-on-dark);
  font-size: 10px;
}
.picker-preview-pane {
  border-left: 1px solid var(--line-hairline);
  background: var(--paper-bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.picker-preview-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--line-hairline);
  background: var(--paper-surface);
}
.picker-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--line-hairline);
  background: var(--paper-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
@media (max-width: 767px) {
  dialog.picker-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .picker-shell { height: 100dvh; }
  .picker-body { grid-template-columns: 1fr; }
  .picker-preview-pane { display: none; }
  .picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ==========================================================================
   4.8 查看器（全屏暗房原生 dialog）
   ========================================================================== */
dialog.viewer-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--scrim-dark);
  color: var(--ink-on-dark);
  overflow: hidden;
}
dialog.viewer-dialog::backdrop { background: var(--scrim-dark); }
.viewer-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.viewer-top {
  height: 52px;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-on-dark);
}
.viewer-btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(247, 243, 234, 0.24);
  color: var(--ink-on-dark);
  font-size: var(--text-tag);
}
.viewer-btn:hover { background: rgba(247, 243, 234, 0.14); }
.viewer-btn:focus-visible { box-shadow: var(--focus-ring-dark); }

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.viewer-canvas {
  width: min(82vw, 920px);
  max-height: 70dvh;
  aspect-ratio: 4 / 3;
  transform-origin: center center;
  cursor: grab;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}
.viewer-canvas.is-dragging { cursor: grabbing; }
.viewer-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: rgba(20, 17, 15, 0.55);
  color: var(--ink-on-dark);
  font-size: 22px;
  z-index: 4;
}
.viewer-nav-arrow:hover { background: rgba(247, 243, 234, 0.18); }
.viewer-prev { left: 16px; }
.viewer-next { right: 16px; }

.viewer-bottom {
  padding: 10px var(--space-4) 14px;
  border-top: 1px solid rgba(247, 243, 234, 0.14);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(16, 14, 12, 0.86);
}
.viewer-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-tag);
  color: rgba(247, 243, 234, 0.78);
}
.viewer-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.viewer-strip-item {
  flex: 0 0 54px;
  width: 54px;
  height: 40px;
  border-radius: 2px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: 0.55;
}
.viewer-strip-item.is-active {
  border-color: var(--seal-red);
  opacity: 1;
}

/* 轻提示 Toast */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-msg {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink-primary);
  color: var(--ink-on-dark);
  font-size: var(--text-meta);
  box-shadow: var(--shadow-lift);
}

.empty-paper {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background: var(--paper-surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
}
.empty-paper h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  color: var(--ink-primary);
}

/* 时间轴 scroll spy 不再压住卡片 */
.tl-list { padding-right: 76px; }
@media (max-width: 767px) {
  .tl-list { padding-right: 0; }
  .tl-spy-indicator { display: none; }
}


/* ==========================================================================
   真数据补充：图片、查看器音频、登录、帮助
   ========================================================================== */
.photo-frame img,
.dg-media-box img,
.tl-thumb img,
.picker-cell img,
.inbox-select-hit img,
.attach-item img,
.msg-thumb-item img,
.picker-preview-stage img,
.viewer-strip-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--paper-sunk);
}

.viewer-audio {
  width: min(82vw, 720px);
  background: var(--paper-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-overlay);
}
.viewer-audio .va-title { font-family: var(--font-serif); font-size: 1.375rem; }
.viewer-audio audio { width: 100%; }

.viewer-canvas video {
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 2px;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 登录门 */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--paper-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-gate[hidden] { display: none !important; }
.login-box {
  width: min(340px, 100%);
  text-align: center;
  background: var(--paper-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 34px 26px 28px;
  box-shadow: var(--shadow-overlay);
}
.login-box .brand-seal { width: 40px; height: 40px; font-size: 22px; margin: 0 auto 14px; }
.login-box h1 { font-size: 1.5rem; letter-spacing: .12em; margin: 0 0 4px; }
.login-box p { margin: 0 0 18px; color: var(--ink-muted); font-size: var(--text-meta); }
.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-bg);
  text-align: center;
  letter-spacing: .3em;
  outline: none;
}
.login-box input:focus { border-color: var(--seal-red); }
.login-box .err { min-height: 20px; color: var(--seal-red); font-size: var(--text-tag); margin-top: 8px; }
.login-box .btn { width: 100%; margin-top: 6px; }

/* 帮助 */
dialog.help-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: 86dvh;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-overlay);
}
dialog.help-dialog::backdrop { background: var(--scrim-light); }
.help-body { padding: 22px 24px 24px; font-size: var(--text-meta); line-height: 1.9; }
.help-body h2 { font-size: 1.125rem; margin: 0 0 12px; }
.help-body h3 { font-family: var(--font-serif); font-size: var(--text-h3); margin: 16px 0 4px; }
.help-body code { background: var(--paper-sunk); padding: 1px 5px; border-radius: 2px; }
.help-body pre {
  background: var(--paper-sunk); padding: 10px 12px; border-radius: var(--radius-xs);
  overflow-x: auto; font-size: 12px; line-height: 1.6;
}
