/* ═══════════════════════════════════════════════════════════
   聊天记录归档 · 现代精致风
   ═══════════════════════════════════════════════════════════ */

/* ───────── 设计变量 ───────── */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;

  --bg:            #f5f3f9;
  --bg-tint:       #efeaf7;
  --surface:       #ffffff;
  --surface-2:     #fbfaff;
  --surface-3:     #f3effa;
  --rail-bg:       #faf8fd;

  --text:          #1c1a22;
  --text-2:        #4a4556;
  --text-3:        #6f6879;
  --text-4:        #a8a2b4;

  --line:          #e9e3f2;
  --line-soft:     #f1ecf8;

  --primary:       #7056c4;
  --primary-2:     #8b76f5;
  --primary-soft:  #efe9fb;
  --primary-ink:   #4b3aa2;

  --bubble-peer:   #ffffff;
  --bubble-peer-line: #ebe5f4;
  --bubble-me:     #ebe3fb;
  --bubble-me-line:#e0d5f7;

  --shadow-xs: 0 1px 2px rgba(28, 26, 34, .05);
  --shadow-sm: 0 1px 3px rgba(28, 26, 34, .05), 0 4px 14px rgba(28, 26, 34, .04);
  --shadow-md: 0 4px 12px rgba(28, 26, 34, .07), 0 12px 32px rgba(28, 26, 34, .06);
  --shadow-lg: 0 12px 32px rgba(28, 26, 34, .12), 0 32px 64px rgba(28, 26, 34, .10);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --rail-w: 236px;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --dur: .18s;
}

[data-theme="dark"] {
  --bg:            #100e15;
  --bg-tint:       #17131f;
  --surface:       #1a1721;
  --surface-2:     #201c29;
  --surface-3:     #272232;
  --rail-bg:       #141119;

  --text:          #ece9f4;
  --text-2:        #c3bdd0;
  --text-3:        #8f88a0;
  --text-4:        #6b6479;

  --line:          #2a2436;
  --line-soft:     #221d2c;

  --primary:       #a48bf0;
  --primary-2:     #b9a6f7;
  --primary-soft:  #2b2342;
  --primary-ink:   #d8ccff;

  --bubble-peer:   #221d2c;
  --bubble-peer-line: #2e2739;
  --bubble-me:     #3a2f60;
  --bubble-me-line:#463a70;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .22);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .28);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45), 0 32px 64px rgba(0, 0, 0, .35);
}

/* ───────── 基础 ───────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
kbd {
  font: 11px/1 var(--font);
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-3);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }

/* ───────── 启动画面 ───────── */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 0%, var(--bg-tint), transparent 70%),
    var(--bg);
  z-index: 100;
  transition: opacity .45s var(--ease), visibility .45s;
}
.boot.done { opacity: 0; visibility: hidden; }

.boot-inner { text-align: center; padding: 24px; }
.boot-mark {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
}
.boot-mark span {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  animation: float 2.4s var(--ease) infinite;
}
.boot-mark span:first-child { background: var(--primary-soft); border-color: var(--bubble-me-line); }
.boot-mark span:last-child { animation-delay: .5s; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

.boot-title {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text);
}
.boot-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-3);
  min-height: 1.6em;
}
.boot-bar {
  width: 200px;
  height: 3px;
  margin: 22px auto 0;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
/* ───────── 密码锁屏 ───────── */
.lock {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 0%, var(--bg-tint), transparent 70%),
    var(--bg);
  z-index: 200;
}
.lock[hidden] { display: none; }
.lock-card {
  width: min(320px, 86vw);
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.lock-title { font-size: 20px; font-weight: 600; letter-spacing: .04em; color: var(--text); }
.lock-sub { margin: 8px 0 18px; font-size: 13px; color: var(--text-3); }
.lock-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
}
.lock-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.lock-err { margin: 10px 0 0; font-size: 12px; color: #c2453f; }
.lock-btn {
  margin-top: 16px;
  width: 100%;
  padding: 10px 0;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
}
.lock-btn:active { transform: scale(.99); }

.boot-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width .2s var(--ease);
}

/* ───────── 外壳布局 ───────── */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: 100%;
}
.shell[hidden] { display: none; }

/* ───────── 左侧时间轴 ───────── */
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--rail-bg);
  border-right: 1px solid var(--line);
}

.rail-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.duo { position: relative; width: 42px; height: 30px; flex: none; }
.duo img {
  position: absolute;
  top: 0;
  width: 29px; height: 29px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--rail-bg);
  background: var(--surface-3);
}
.duo img:first-child { left: 0; z-index: 1; }
.duo img:last-child  { right: 0; }

.rail-who { min-width: 0; }
.rail-names {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-meta {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.rail .rail-close { display: none; margin-left: auto; }

.rail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 10px 10px;
}

.rail-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 0 8px 8px;
}

.timeline { display: flex; flex-direction: column; gap: 1px; }

.month-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 8px;
  margin-top: 6px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background var(--dur) var(--ease);
}
.month-btn:hover { background: var(--surface-3); }
.month-btn .chev {
  width: 13px; height: 13px;
  color: var(--text-4);
  transition: transform var(--dur) var(--ease);
}
.month-btn.collapsed .chev { transform: rotate(-90deg); }
.month-btn .mcount {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.month-days { display: flex; flex-direction: column; gap: 1px; }
.month-days.collapsed { display: none; }

.day-btn {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.day-btn::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--primary) 13%, transparent),
    color-mix(in srgb, var(--primary) 4%, transparent));
  pointer-events: none;
  transition: width .3s var(--ease);
}
.day-btn:hover { background: var(--surface-3); }
.day-btn .dnum {
  position: relative;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: right;
}
.day-btn .dwk { position: relative; color: var(--text-4); font-size: 11px; }
.day-btn .dcnt {
  position: relative;
  margin-left: auto;
  font-size: 11px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}
.day-btn.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.day-btn.active::before { width: 0 !important; }
.day-btn.active .dwk, .day-btn.active .dcnt { color: var(--primary-ink); opacity: .75; }

.rail-foot {
  display: flex;
  gap: 6px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--line-soft);
}
.rail-foot .ghost-btn { flex: 1; }

/* ───────── 主区域 ───────── */
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(70% 40% at 50% 0%, var(--bg-tint), transparent 65%),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  min-height: 62px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  z-index: 20;
  flex: none;
}

.topbar-title { min-width: 0; flex: 1; }
.topbar-day {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-tools { display: flex; align-items: center; gap: 6px; }

.tool-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 12.5px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.tool-btn:hover, .icon-btn:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.tool-btn kbd { margin-left: 2px; }

.icon-btn { width: 34px; padding: 0; justify-content: center; }
.icon-btn.small { width: 28px; height: 28px; }

.tool-icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.tool-icon svg { width: 100%; height: 100%; }

.only-mobile { display: none; }

/* ───────── 消息流 ───────── */
.stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  overflow-anchor: none;   /* 关闭浏览器滚动锚定，翻页时由脚本精确补偿 */
  position: relative;
}

.stream-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 8px 24px 40px;
}

.stream-end {
  text-align: center;
  font-size: 12px;
  color: var(--text-4);
  padding: 24px 0 60px;
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.stream-end.show { opacity: 1; }

/* 日期分隔 */
.day-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 14px 0 12px;
  pointer-events: none;
}
.day-head span {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 11.5px;
  color: var(--text-3);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-variant-numeric: tabular-nums;
}
.day-head b { font-weight: 600; color: var(--text-2); }
.day-head i { font-style: normal; color: var(--text-4); }

/* 消息组 */
.group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
}
.group + .group { margin-top: 18px; }

.group-time {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  padding: 0 4px 2px;
  margin-left: 40px; /* avatar 30 + gap 10，对齐气泡列 */
}
.group.me .group-time {
  margin-left: 0;
  margin-right: 40px;
  text-align: right;
}

.group-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.group.me .group-row { flex-direction: row-reverse; }

.group-av {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  margin-top: 2px;
}
.group-av.blank { visibility: hidden; }

.group-body {
  min-width: 0;
  max-width: min(78%, 620px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.group.me .group-body { align-items: flex-end; }

.group-name {
  font-size: 11.5px;
  color: var(--text-3);
  padding: 0 4px 1px;
}

/* 单条消息 */
.msg { position: relative; display: flex; align-items: flex-end; gap: 8px; }
.group.me .msg { flex-direction: row-reverse; }

.msg-time {
  font-size: 10.5px;
  color: var(--text-4);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity .2s var(--ease);
  padding-bottom: 3px;
}
.msg:hover .msg-time { opacity: 1; }

/* 气泡 */
.bubble {
  position: relative;
  max-width: 100%;
  padding: 9px 13px;
  border-radius: var(--r-lg);
  background: var(--bubble-peer);
  border: 1px solid var(--bubble-peer-line);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14.5px;
  line-height: 1.6;
}
.group.me .bubble {
  background: var(--bubble-me);
  border-color: var(--bubble-me-line);
}
/* 首尾气泡的“尾巴” */
.group:not(.me) .msg:last-child .bubble { border-bottom-left-radius: 6px; }
.group.me .msg:last-child .bubble { border-bottom-right-radius: 6px; }

.bubble a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.bubble.flash {
  animation: flash 2s var(--ease);
}
@keyframes flash {
  0%, 30% { background: color-mix(in srgb, var(--primary) 30%, var(--surface)); }
  100%    { background: var(--bubble-peer); }
}

/* 系统消息 */
.sys {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.sys span {
  max-width: 78%;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-4);
  padding: 3px 12px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
}

/* 纯图/表情消息去掉气泡 */
.msg.media .bubble { padding: 0; border: 0; background: none; box-shadow: none; }

/* 单独一个表情：保留一圈紧凑的图像背景 */
.msg.emoji-solo .bubble {
  padding: 5px 7px;
  border-radius: 12px;
  background: var(--bubble-peer);
  border: 1px solid var(--bubble-peer-line);
  box-shadow: var(--shadow-xs);
}
.group.me .msg.emoji-solo .bubble {
  background: var(--bubble-me);
  border-color: var(--bubble-me-line);
}

/* 微信内置表情 */
.emoji-inline {
  display: inline-block;
  width: 22px;
  height: 22px;
  vertical-align: -5px;
  margin: 0 1px;
  object-fit: contain;
}
.emoji-lone {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* 图片 */
.img-wrap {
  position: relative;
  display: inline-block;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--bubble-peer-line);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  max-width: 100%;
}
.img-wrap:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.img-wrap img {
  display: block;
  max-width: min(280px, 60vw);
  max-height: 320px;
  object-fit: cover;
  background: var(--surface-3);
}
.img-wrap.emoji {
  border-radius: 10px;
  border-color: transparent;
  box-shadow: none;
  background: none;
  cursor: default;
}
.img-wrap.emoji img { max-width: 132px; max-height: 132px; }
.img-wrap.emoji:hover { transform: none; box-shadow: none; }

.img-broken {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 168px;
  height: 112px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line);
  background: var(--surface-2);
  color: var(--text-4);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.5;
}
.img-broken svg { width: 20px; height: 20px; opacity: .6; }

/* 语音 */
.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 148px;
  padding: 4px 2px;
}
.voice-btn {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.voice-btn:hover { transform: scale(1.06); }
.voice-btn svg { width: 13px; height: 13px; }
.voice-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  flex: 1;
}
.voice-wave i {
  display: block;
  width: 2.5px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--primary) 45%, transparent);
  transition: background .15s;
}
.voice-wave i.on { background: var(--primary); }
.voice-dur {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: right;
}

/* 通话 */
.voip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px;
  white-space: nowrap;
}
.voip i {
  display: grid;
  place-items: center;
  color: var(--primary);
}
.voip i svg { display: block; }
.voip span { font-size: 14px; }

/* 视频 */
.video-wrap {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--bubble-peer-line);
  box-shadow: var(--shadow-sm);
  background: #000;
}
.video-wrap video { display: block; max-width: min(340px, 70vw); max-height: 400px; }

/* 卡片类（链接/小程序/文件/转账/位置/红包/通话） */
.card {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 13px;
  min-width: 210px;
  max-width: 340px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--bubble-peer-line);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
a.card:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }

.card-ico {
  width: 36px; height: 36px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.card-ico svg { width: 18px; height: 18px; }
.card-ico img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }

.card-main { min-width: 0; flex: 1; }
.card-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-src {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-src svg { width: 11px; height: 11px; }

.card-thumb {
  width: 54px; height: 54px;
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-3);
}

/* 引用 */
.quote-box {
  display: flex;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-left: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.quote-box:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.quote-who { font-size: 11px; color: var(--primary); font-weight: 500; flex: none; }
.quote-txt {
  font-size: 12.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 未知/占位 */
.muted-line {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}
.muted-line span {
  font-size: 11px;
  color: var(--text-4);
  padding: 2px 10px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface-3) 50%, transparent);
}

/* 加载指示 */
.day-loading {
  display: flex;
  justify-content: center;
  padding: 18px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── 通用按钮 ───────── */
.ghost-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.ghost-btn:hover { border-color: var(--primary-2); color: var(--primary-ink); background: var(--primary-soft); }

/* ───────── 搜索面板 ───────── */
.palette {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 20px 20px;
  background: color-mix(in srgb, #14111c 32%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade .16s var(--ease);
}
.palette[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

.palette-card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: rise .22s var(--ease);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
@keyframes rise {
  from { transform: translateY(-8px) scale(.99); opacity: 0; }
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.palette-input .tool-icon { color: var(--text-4); }
.palette-input input {
  flex: 1;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
  min-width: 0;
}
.palette-input input::placeholder { color: var(--text-4); }

.palette-body { overflow-y: auto; padding: 6px; flex: 1; min-height: 0; }

.result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.result:hover, .result.sel { background: var(--surface-3); }
.result.sel { box-shadow: inset 2px 0 0 var(--primary); }

.result-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  flex: none;
  margin-top: 1px;
  background: var(--surface-3);
}
.result-body { min-width: 0; flex: 1; }
.result-top {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}
.result-who { color: var(--text-3); font-weight: 500; }
.result-txt {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
mark {
  background: color-mix(in srgb, var(--primary) 26%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.empty-hint {
  padding: 34px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-4);
}

.palette-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--text-4);
  flex: none;
}
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }
.palette-count { margin-left: auto; }

/* ───────── 日期选择 ───────── */
.popover-wrap {
  position: fixed;
  inset: 0;
  z-index: 55;
}
.popover-wrap[hidden] { display: none; }

.popover {
  position: absolute;
  top: 70px;
  right: 22px;
  width: 260px;
  padding: 15px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: rise .16s var(--ease);
}

/* 顶部栏里的日期按钮 */
#btnJump {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  padding-right: 9px;
}
#btnJump:hover, #btnJump.is-open {
  border-color: var(--primary-2);
  background: var(--primary-soft);
  color: var(--primary-ink);
  box-shadow: var(--shadow-sm);
}
#btnJump.is-open { box-shadow: inset 0 1px 3px rgba(28, 26, 34, .06); }
#btnJump .tool-icon { color: var(--primary); }
#btnJump .tool-label { font-variant-numeric: tabular-nums; letter-spacing: .005em; }
#btnJump .tool-caret {
  display: inline-flex;
  margin-left: -2px;
  color: currentColor;
  opacity: .55;
  transition: transform var(--dur) var(--ease);
}
#btnJump.is-open .tool-caret { transform: rotate(180deg); }

/* 日历面板 */
.cal-pop {
  width: 296px;
  padding: 12px 12px 10px;
  overflow: hidden;
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}
.cal-nav {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.cal-nav:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.cal-nav:disabled { opacity: .28; cursor: default; }

.cal-title {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
}
.cal-sel {
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.cal-sel:hover { background: var(--surface-3); color: var(--primary-ink); }

.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-week { margin: 2px 0 3px; }
.cal-week span {
  text-align: center;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-4);
  padding: 3px 0;
}
.cal-grid { gap: 2px; grid-auto-rows: 34px; }

.cal-day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-4);
  outline: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              transform .1s var(--ease), box-shadow var(--dur) var(--ease);
}
.cal-day.is-blank { visibility: hidden; }

/* 无数据：灰掉、不可点 */
.cal-day.no-data {
  color: var(--text-3);
  opacity: .42;
  cursor: not-allowed;
}

/* 键盘焦点圈 */
.cal-day.has-data:focus-visible {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary-2);
}

/* 有数据：亮起来，条数越多底色越明显 */
.cal-day.has-data {
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  background: color-mix(in srgb, var(--primary) var(--tint, 12%), transparent);
}
.cal-day.has-data:hover {
  background: var(--primary-soft);
  color: var(--primary-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-2) 45%, transparent);
}
.cal-day.has-data:active { transform: scale(.93); }

/* 当前查看的那天 */
.cal-day.is-sel,
.cal-day.has-data.is-sel:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--primary) 42%, transparent);
}

/* 今天 */
.cal-day.is-today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}
.cal-day.is-sel::after { background: #fff; opacity: .9; }

.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
}
.cal-hint {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.cal-foot .ghost-btn { height: 26px; padding: 0 10px; }

/* 年 / 月 快速切换 */
.cal-picker {
  position: absolute;
  inset: 0;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade .14s var(--ease);
}
.cal-picker[hidden] { display: none; }
.cal-picker-head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-picker-head span {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cal-months {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 38px;
  gap: 7px;
  flex: 1;
  align-content: center;
}
.pick-month {
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line-soft));
  font-variant-numeric: tabular-nums;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.pick-month:hover { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary-2); }
.pick-month.is-on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
/* 整月无数据：灰掉、不可点 */
.pick-month.no-data {
  background: transparent;
  border-color: var(--line-soft);
  color: var(--text-3);
  opacity: .55;
  cursor: not-allowed;
}
.pick-month.no-data:hover {
  background: transparent;
  border-color: var(--line-soft);
  color: var(--text-3);
}

/* ───────── 统计抽屉 ───────── */
.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 58;
  background: color-mix(in srgb, #14111c 26%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade .16s var(--ease);
}
.drawer-wrap[hidden] { display: none; }

.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: slide .24s var(--ease);
}
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.drawer-head > div:first-child { flex: 1; }
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }

.stat-block { margin-bottom: 26px; }
.stat-block h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-4);
}

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi {
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.kpi b {
  display: block;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.kpi span { font-size: 11px; color: var(--text-3); }

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.bar { transition: fill .15s var(--ease), opacity .15s; cursor: pointer; }
.bar:hover { fill: var(--primary-2); }
.chart-axis { font-size: 9px; fill: var(--text-4); }

.split { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.split i { display: block; height: 100%; }
.split-a { background: var(--primary); }
.split-b { background: color-mix(in srgb, var(--primary) 35%, var(--surface-3)); }

.legend { display: flex; gap: 16px; margin-top: 9px; font-size: 11.5px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }

.kind-row {
  display: grid;
  grid-template-columns: 62px 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-2);
}
.kind-row .kbar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.kind-row .kbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.kind-row .kn { text-align: right; color: var(--text-4); font-variant-numeric: tabular-nums; font-size: 11px; }

.words { display: flex; flex-wrap: wrap; gap: 6px; }
.word {
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
}
.word b { font-weight: 600; color: var(--text); }
.word em { font-style: normal; color: var(--text-4); font-size: 10px; margin-left: 4px; }

/* ───────── 灯箱 ───────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #08060d 92%, transparent);
  animation: fade .18s var(--ease);
}
.lightbox[hidden] { display: none; }
.lb-figure {
  margin: 0;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lb-figure img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.lb-figure figcaption {
  font-size: 12px;
  color: rgba(255,255,255,.62);
  font-variant-numeric: tabular-nums;
}
.lb-btn {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
  transition: background .15s;
}
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-btn svg { width: 18px; height: 18px; }
.lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
.lb-close { top: 18px; right: 22px; }
.lb-btn[disabled] { opacity: .25; pointer-events: none; }

/* ───────── Toast ───────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(10px);
  padding: 9px 16px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  font-size: 12.5px;
  z-index: 90;
  opacity: 0;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───────── 响应式 ───────── */
@media (max-width: 860px) {
  :root { --rail-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 264px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .24s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .rail.open { transform: none; }
  .rail .rail-close { display: inline-flex; }
  .only-mobile { display: inline-flex; }

  .topbar { padding: 10px 12px; min-height: 56px; }
  .tool-btn .tool-label, .tool-btn kbd { display: none; }
  .tool-btn { width: 34px; padding: 0; justify-content: center; }
  #btnJump { padding: 0; }
  #btnJump .tool-caret { display: none; }
  .popover { right: 12px; top: 62px; }
  .cal-pop { width: min(296px, calc(100vw - 24px)); }
  .stream-inner { padding: 6px 12px 32px; }
  .group-body { max-width: 82%; }
  .img-wrap img { max-width: min(230px, 62vw); }
  .palette { padding: 8vh 10px 10px; }
  .drawer { width: 100%; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
