/* ==========================================
   全站基础样式（浅色简洁风 · 悬浮岛式侧边栏）
   - 全部颜色走 CSS 变量，暗色主题一键切换
   - 兼容：不支持 backdrop-filter / 变量的老浏览器
     仅损失毛玻璃与主题色，布局不受影响
   ========================================== */

/* ---------- 浅色主题变量（默认） ---------- */
:root {
  /* 颜色 */
  --bg-page: #f6f6f4;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.08);    /* 玻璃弹窗底：近纯透明 */
  --glass-border: rgba(255, 255, 255, 0.6); /* 玻璃亮边 */
  --glass-input: rgba(255, 255, 255, 0.66); /* 玻璃输入框 */
  --glass-hover: rgba(255, 255, 255, 0.55); /* 玻璃悬停底 */
  --glass-menu: rgba(255, 255, 255, 0.74);  /* 浮层菜单实底（下拉/详情面板） */
  --bg-code: #fafaf9;                    /* 代码块底 */
  --bg-bubble: #ececeb;                  /* 用户消息气泡 */
  --bg-hover-tint: rgba(0, 0, 0, 0.045); /* 通用悬停底色 */
  --bg-hover-strong: rgba(0, 0, 0, 0.08);

  --text-main: #1f1e1b;
  --text-sub: #6f6d66;
  --text-faint: #a6a49c;
  --text-placeholder: #b3b0a6;

  --border: rgba(0, 0, 0, 0.07);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --grad-accent: linear-gradient(135deg, #2563eb, #4f8cf7); /* 主按钮渐变 */
  --ring: rgba(37, 99, 235, 0.4);        /* 键盘焦点柔光 */

  --overlay: rgba(20, 20, 20, 0.3);      /* 弹窗遮罩 */

  /* 阴影 */
  --shadow-island: 0 12px 40px rgba(20, 20, 20, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --shadow-card: 0 1px 3px rgba(20, 20, 20, 0.05);
  --shadow-card-hover: 0 10px 30px rgba(20, 20, 20, 0.1);
  --shadow-glow: rgba(37, 99, 235, 0.3); /* 主按钮光晕 */
  --inline-code-tint: rgba(0, 0, 0, 0.055);

  /* 布局 */
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --nav-height: 56px;
}

/* ---------- 暗色主题变量（手动切换，中性炭灰，不偏蓝） ---------- */
:root[data-theme="dark"] {
  --bg-page: #141416;
  --bg-glass: rgba(28, 28, 31, 0.78);
  --bg-card: #1c1c1f;
  --bg-input: #1c1c1f;
  --bg-modal: #202024;
  --glass-bg: rgba(255, 255, 255, 0.04);    /* 玻璃弹窗底：近纯透明 */
  --glass-border: rgba(255, 255, 255, 0.14); /* 玻璃亮边 */
  --glass-input: rgba(0, 0, 0, 0.25);        /* 玻璃输入框 */
  --glass-hover: rgba(255, 255, 255, 0.09);  /* 玻璃悬停底 */
  --glass-menu: rgba(26, 26, 30, 0.78);      /* 浮层菜单实底（下拉/详情面板） */
  --bg-code: #17171a;
  --bg-bubble: #26262a;
  --bg-hover-tint: rgba(255, 255, 255, 0.06);
  --bg-hover-strong: rgba(255, 255, 255, 0.11);

  --text-main: #e8e8e6;
  --text-sub: #9b9b97;
  --text-faint: #6b6b68;
  --text-placeholder: #5a5a58;

  --border: rgba(255, 255, 255, 0.08);
  --accent: #4d8df2;
  --accent-soft: rgba(77, 141, 242, 0.14);
  --grad-accent: linear-gradient(135deg, #3d7cf0, #5a97f8);
  --ring: rgba(90, 140, 240, 0.4);

  --overlay: rgba(0, 0, 0, 0.55);

  --shadow-island: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: rgba(70, 120, 230, 0.35);
  --inline-code-tint: rgba(255, 255, 255, 0.07);
}

/* ---------- 暗色主题（无 JS 时跟随系统，兼容后备） ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-page: #141416;
    --bg-glass: rgba(28, 28, 31, 0.78);
    --bg-card: #1c1c1f;
    --bg-input: #1c1c1f;
    --bg-modal: #202024;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-input: rgba(0, 0, 0, 0.25);
    --glass-hover: rgba(255, 255, 255, 0.09);
    --glass-menu: rgba(26, 26, 30, 0.78);
    --bg-code: #17171a;
    --bg-bubble: #26262a;
    --bg-hover-tint: rgba(255, 255, 255, 0.06);
    --bg-hover-strong: rgba(255, 255, 255, 0.11);

    --text-main: #e8e8e6;
    --text-sub: #9b9b97;
    --text-faint: #6b6b68;
    --text-placeholder: #5a5a58;

    --border: rgba(255, 255, 255, 0.08);
    --accent: #4d8df2;
    --accent-soft: rgba(77, 141, 242, 0.14);
    --grad-accent: linear-gradient(135deg, #3d7cf0, #5a97f8);
    --ring: rgba(90, 140, 240, 0.4);

--overlay: rgba(0, 0, 0, 0.55);
  --shadow-island: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: rgba(70, 120, 230, 0.35);
    --inline-code-tint: rgba(255, 255, 255, 0.07);
  }
}

/* ---------- 基础 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 主题切换时整体平滑过渡 */
html,
body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

/* v45：宽屏背景装饰（两团柔和光晕，填充两侧空白，随主题色联动） */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: clamp(480px, 55vw, 880px);
  height: clamp(480px, 55vw, 880px);
  top: -22%;
  right: -12%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 62%);
}

body::after {
  width: clamp(420px, 45vw, 720px);
  height: clamp(420px, 45vw, 720px);
  bottom: -18%;
  left: -8%;
  background: radial-gradient(circle, rgba(128, 128, 138, 0.09) 0%, transparent 62%);
}

[data-theme="dark"] body::after {
  background: radial-gradient(circle, rgba(128, 128, 138, 0.14) 0%, transparent 62%);
}

::selection {
  background: var(--accent-soft);
}

/* 键盘焦点柔光（替代浏览器默认边框）
   鼠标点击不显示，避免出现"细线" */
button,
a,
input,
textarea {
  outline: none;
}

button:focus-visible:not(:active),
a:focus-visible:not(:active) {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

/* 背景纯色 */

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ==========================================
   悬浮岛式侧边栏
   ========================================== */
.sidebar {
  position: fixed;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 216px;
  z-index: 100;

  display: flex;
  flex-direction: column;
  gap: 24px;

  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  /* 无边框：去掉"新对话"与聊天区之间的细线，靠阴影体现悬浮感 */
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-island);
  padding: 22px 14px 16px;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 站标 */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  padding: 4px 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--grad-accent);
  border-radius: 10px;
  box-shadow: 0 4px 12px var(--shadow-glow);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* 导航链接 */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.3s ease;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 侧边栏底部 */
.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  transition: border-color 0.3s ease;
}

.store-stats {
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

/* v47：悬浮在（被截断的）字数显示上，弹出完整「会话 · 字数」小气泡 */
.store-wrap {
  position: relative;
  display: inline-flex;
}

.store-tip {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #26262b;
  color: #f2f2f0;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 5px 11px;
  border-radius: 9px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  z-index: 60;
}

.store-tip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #26262b;
}

.store-wrap:hover .store-tip:not([hidden]) {
  display: block;
  animation: tip-in 0.14s ease both;
}

@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 会话统计仅在 AI 聊天界面显示 */
body:not(.chat-active) .store-stats {
  display: none;
}

/* ==========================================
   按钮体系
   ========================================== */

/* 主按钮：渐变底 + 光晕 + 悬停提亮 + 按下收缩 */
.new-chat-btn,
.primary-btn {
  border: none;
  background: var(--grad-accent);
  color: #ffffff;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--shadow-glow);
  transition: box-shadow 0.25s ease, filter 0.25s ease, transform 0.15s ease,
    background-color 0.3s ease;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.primary-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.new-chat-btn svg {
  width: 15px;
  height: 15px;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.new-chat-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 22px var(--shadow-glow);
}

.new-chat-btn:hover svg {
  transform: rotate(90deg);
}

.new-chat-btn:active:not(:disabled),
.primary-btn:active:not(:disabled) {
  transform: scale(0.97);
}

/* 图标按钮：透明底 + 悬停圆底 + 图标旋转 + 按下收缩 */
.icon-btn,
.theme-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover,
.theme-btn:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.icon-btn:active,
.theme-btn:active {
  transform: scale(0.88);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.icon-btn:hover svg {
  transform: rotate(25deg);
}

/* 主题切换按钮：日/月双图标叠加，旋转淡入切换 */
.theme-btn {
  position: relative;
}

.theme-btn svg {
  position: absolute;
  width: 17px;
  height: 17px;
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.theme-btn .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}

[data-theme="dark"] .theme-btn .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.4);
}

[data-theme="dark"] .theme-btn .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ==========================================
   首页内容
   ========================================== */
.main-content {
  max-width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 40px;
}

.hero {
  text-align: center;
  padding: clamp(84px, 11vw, 140px) 0 clamp(48px, 6vw, 72px);
}

.hero-title {
  font-size: clamp(38px, 5.6vw, 66px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 18px;
}

.hero-subtitle {
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--text-sub);
  max-width: 560px;
  margin: 0 auto;
}

/* 页脚 */
.site-footer {
  padding: 28px 0 56px;
  border-top: 1px solid var(--border);
  text-align: center;
  transition: border-color 0.3s ease;
}

.site-footer p {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* 提示浮层 */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text-main);
  color: #ffffff;
  font-size: 13.5px;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15, 15, 15, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.3s ease;
  z-index: 300;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================
   响应式
   ========================================== */
@media (max-width: 1100px) {
  .sidebar {
    left: 20px;
    top: 20px;
    transform: none;
    width: 200px;
  }

  /* v64：.app 基础定义在文件后部，需提高特异性才能覆盖 */
  body .app {
    left: 244px;
  }
}

@media (max-width: 780px) {
  .sidebar {
    left: 12px;
    right: 12px;
    top: 12px;
    transform: none;
    width: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
  }

  .sidebar-brand {
    padding: 2px 4px;
  }

  .brand-text {
    display: none;
  }

  .sidebar-foot {
    border: none;
    padding: 0;
  }

  .sidebar-foot span {
    display: none;
  }

  /* 小屏：聊天区整体淡入（高度动画受限，改为透明度过渡） */
  .sidebar-chat-wrap {
    display: none;
  }

  body.chat-active .sidebar-chat-wrap {
    display: flex;
    flex: 1;
    align-items: center;
  }

  .sidebar-chat-inner {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
  }

  body.chat-active .sidebar-chat-inner > * {
    animation: fade-up 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  body.chat-active .sidebar-chat-inner > *:nth-child(2) { animation-delay: 0.1s; }

  .sidebar-nav {
    flex-direction: row;
    gap: 2px;
  }

  .nav-link {
    padding: 8px 10px;
    font-size: 13px;
  }

  /* v64：提高特异性覆盖后部基础定义 */
  body .app {
    left: 12px;
    right: 12px;
    top: 62px;
    bottom: 0;
    transition: top 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.3s ease;
  }

  body.chat-active .app {
    top: 118px;
  }

  .main-content {
    margin: 0;
    padding: 84px 20px 0;
  }

  .hero {
    padding: 56px 0 48px;
  }

  .hero-title {
    font-size: 36px;
  }
}

/* ==========================================
   应用区（单页视图切换）
   ========================================== */
.app {
  position: fixed;
  top: 0;
  right: 24px;
  bottom: 0;
  left: 264px;
  overflow-y: auto;
  z-index: 1;
  /* v45：背景交给 body（透出装饰光晕） */
  transition: background-color 0.3s ease;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.leaving {
  animation: view-out 0.16s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes view-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ==========================================
   侧边栏聊天区：切换 AI 聊天时平滑展开
   （height 从 0 弹性过渡，为新按钮让出位置）
   ========================================== */
.sidebar-chat-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.3s ease;
}

.sidebar-chat-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-active .sidebar-chat-wrap {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* 展开时内部元素依次浮现 */
.chat-active .sidebar-chat-inner > * {
  animation: fade-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.chat-active .sidebar-chat-inner > *:nth-child(1) { animation-delay: 0.08s; }
.chat-active .sidebar-chat-inner > *:nth-child(2) { animation-delay: 0.16s; }

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 细滚动条（全局，暗色/亮色通吃） ---------- */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 138, 0.28);
  border-radius: 999px;
  border: 2.5px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(128, 128, 138, 0.5);
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 128, 138, 0.35) transparent;
}

/* ========== 交互动效（v40）：按压反馈 ========== */
.nav-link:active,
.note-op:active,
.notes-tool:active,
.bb-tool:active,
.bb-plus:active,
.tool-btn:active,
.effort-btn:active,
.session-del:active,
.notes-menu-item:active,
.bb-plus-option:active,
.note-ref-item:active,
.note-item:active,
.note-search:active,
.note-title-input:active {
  filter: brightness(0.93);
}

/* 尊重系统「减弱动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================
   统计视图（v44）：KPI / 趋势图 / 明细表
   ========================================== */
.stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 40px 0 22px;
  flex-wrap: wrap;
}

.stats-upd {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- 上层：KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-sub);
  letter-spacing: 1px;
}

.kpi-num {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- 中层：趋势图（v45 折线） ---------- */
.stats-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px 18px 14px;
  transition: box-shadow 0.3s ease;
}

.stats-panel:hover {
  box-shadow: var(--shadow-card-hover);
}

.trend-panel {
  margin-top: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
}

.panel-legend {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-sub);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: none;
  background: transparent;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.legend-item:hover {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}

.legend-item.off {
  opacity: 0.38;
  color: var(--text-faint);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-note { background: var(--accent); }
.dot-chat { background: #9ca3af; }

.legend-item.off .legend-dot {
  background: transparent !important;
  border: 1.5px dashed currentColor;
}

.trend-chart {
  padding: 6px 0 0;
}

.trend-svg {
  width: 100%;
  height: auto;
  display: block;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  shape-rendering: crispEdges;
}

.grid-label {
  font-size: 10px;
  fill: var(--text-faint);
  text-anchor: end;
}

.x-label {
  font-size: 10px;
  fill: var(--text-faint);
}

.series-g .series-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-g[data-series="note"] .series-line {
  stroke: var(--accent);
}

.series-g[data-series="chat"] .series-line {
  stroke: #9ca3af;
}

.series-dot {
  stroke: var(--bg-card);
  stroke-width: 1.5;
}

.series-g[data-series="note"] .series-dot {
  fill: var(--accent);
}

.series-g[data-series="chat"] .series-dot {
  fill: #9ca3af;
}

.trend-empty {
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
  padding: 40px 0 20px;
}

/* ---------- 下层：明细表 ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 18px;
  padding-bottom: 72px;
}

.panel-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.detail-table th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.detail-table th:nth-child(1) { width: 46%; }
.detail-table th:nth-child(2) { width: 14%; }
.detail-table th:nth-child(3) { width: 18%; }
.detail-table th:nth-child(4) { width: 22%; }

.detail-table td {
  font-size: 13px;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-table tbody tr:last-child td {
  border-bottom: none;
}

.detail-table .clickable-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.detail-table .clickable-row:hover {
  background: var(--bg-hover-tint);
}

.detail-table .cell-title { font-weight: 600; }
.detail-table .cell-num, .detail-table .cell-pin {
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
}
.detail-table .cell-time, .detail-table .cell-last {
  color: var(--text-faint);
}
.detail-table .empty-row td {
  text-align: center;
  color: var(--text-faint);
  padding: 22px 8px;
  cursor: default;
}

/* 窄屏：KPI 两列 */
@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 超大屏（≥1600px）：内容加宽，充分利用宽幅 */
@media (min-width: 1600px) {
  .main-content {
    max-width: min(1300px, 100%);
    padding: 0 56px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  }

  .trend-svg {
    max-width: 880px;
    margin: 0 auto;
  }
}

/* ==========================================
   留言板（v69）：公开留言，D1 存储
   ========================================== */
.messages-view .main-content {
  max-width: 760px;
  margin: 0 auto;
}

.msg-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.msg-author {
  width: 100%;
  max-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.msg-author:focus,
.msg-content:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.msg-content {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.msg-send {
  align-self: flex-end;
}

.msg-empty {
  text-align: center;
  color: var(--text-faint);
  padding: 48px 0;
  font-size: 14px;
}

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-card);
}

.msg-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.msg-item-author {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
}

.msg-item-time {
  font-size: 12px;
  color: var(--text-faint);
}

.msg-item-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================
   首页升级（v70）：hero 徽章/渐变标题/CTA + 功能入口卡片
   全部复用现有 CSS 变量，浅色/暗色主题自适应
   ========================================== */

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-bottom: 22px;
}

.hero-badge svg {
  width: 13px;
  height: 13px;
}

.hero-title {
  background: linear-gradient(118deg, var(--text-main) 32%, var(--accent) 88%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.btn-hero-primary,
.btn-hero-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 26px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn-hero-primary {
  background: var(--grad-accent);
  color: #ffffff;
  box-shadow: 0 4px 18px var(--shadow-glow);
}

.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 26px var(--shadow-glow);
}

.btn-hero-primary svg {
  width: 16px;
  height: 16px;
}

.btn-hero-ghost {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-hero-ghost:hover {
  transform: translateY(-2px);
  border-color: var(--ring);
  box-shadow: var(--shadow-card-hover);
}

/* ---------- 功能入口卡片 ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 6px 0 12px;
}

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px 22px 22px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  text-decoration: none;
  color: inherit;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--ring);
}

.feature-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.feature-title {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.feature-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-sub);
}

/* 窄屏：hero 与卡片区间距收紧 */
@media (max-width: 640px) {
  .hero {
    padding: clamp(64px, 16vw, 96px) 0 clamp(36px, 5vw, 52px);
  }
  .feature-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .feature-card {
    padding: 18px 16px 16px;
  }
}

/* ===== v71 云端管理区（设置面板内） ===== */
.admin-box {
  margin-top: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.admin-section {
  margin-bottom: 14px;
}
.admin-head {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}
.admin-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 640px;
}
.admin-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-sub);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-hover-tint);
  white-space: nowrap;
}
.admin-table td {
  padding: 6px 10px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-table tbody tr:hover td {
  background: var(--bg-hover-tint);
}
.admin-table input {
  width: 100%;
  min-width: 90px;
  box-sizing: border-box;
  font-size: 12.5px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: inherit;
}
.admin-table input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}
.admin-table select {
  width: 100%;
  min-width: 90px;
  box-sizing: border-box;
  font-size: 12.5px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: inherit;
}
.admin-table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--ring);
}
.admin-del {
  border: none;
  background: transparent;
  color: #e05555;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.admin-del:hover {
  background: rgba(224, 85, 85, 0.14);
}
.admin-add {
  margin-top: 10px;
}
.admin-tip {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}
.admin-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.admin-hint {
  font-size: 12px;
  color: var(--text-sub);
}
.admin-hint.ok {
  color: #3cb371;
}

/* ===== v72 侧边栏设置入口 ===== */
.sidebar-set-wrap {
  margin-top: 8px;
  padding: 0 10px;
}

/* ===== v73 更多下拉（统计 / 文档，复刻聊天区展开动画） ===== */
.nav-more {
  background: none;
  border: none;
  font: inherit;
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.nav-more svg {
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav-more.open svg {
  transform: rotate(180deg);
}
.nav-more.open {
  background: var(--bg-hover-tint);
  color: var(--text-main);
}
.sidebar-extra-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.25s ease;
}
.sidebar-extra-wrap.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.sidebar-extra-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.sidebar-extra-inner .extra-link {
  padding: 7px 10px;
  font-size: 13.5px;
}
.sidebar-extra-inner > * {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.sidebar-extra-wrap.open .sidebar-extra-inner > * {
  opacity: 1;
  transform: none;
}
.sidebar-extra-wrap.open .sidebar-extra-inner > *:nth-child(1) { transition-delay: 0.05s; }
.sidebar-extra-wrap.open .sidebar-extra-inner > *:nth-child(2) { transition-delay: 0.1s; }

/* ===== v72 文档视图 ===== */
.docs-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  line-height: 1.7;
  font-size: 14.5px;
}
.docs-intro {
  color: var(--text-sub);
  margin: 4px 0 24px;
}
.docs-content h3 {
  font-size: 17px;
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.docs-content p {
  margin: 8px 0;
}
.docs-content ol,
.docs-content ul {
  margin: 8px 0;
  padding-left: 24px;
}
.docs-content li {
  margin: 4px 0;
}
.docs-content code {
  font-family: Consolas, Menlo, monospace;
  font-size: 13px;
  background: var(--bg-code);
  padding: 1px 6px;
  border-radius: 5px;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 8px;
}
.docs-table th,
.docs-table td {
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--border);
}
.docs-table th {
  background: var(--bg-card);
  font-weight: 600;
}

/* ===== v75 设置独立页面（#setting） ===== */
.settings-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-page .stats-head {
  margin-bottom: 0;
}
.settings-savebar {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}