/*
 * Design Token：所有颜色、字号、间距、圆角、阴影都从这里取值，页面与组件不写裸值。
 * 第一层是原始色板（palette），第二层是语义 Token（surface / text / border / status），
 * 第三层把语义 Token 映射到 daisyUI 主题变量，让组件库与自定义样式共用同一套数值。
 */
:root {
  color-scheme: light;

  /* 原始色板：像素池 PixelPool 黑白极简精密体系 + 克制语义状态色 */
  --palette-white: #ffffff;
  --palette-gray-25: #fbfbfc;
  --palette-gray-50: #f5f5f7;
  --palette-gray-100: #eeeff2;
  --palette-gray-200: #e4e6eb;
  --palette-gray-300: #cdd1da;
  --palette-gray-400: #9ca3af;
  --palette-gray-500: #6b7280;
  --palette-gray-700: #374151;
  --palette-gray-900: #0d0f14;
  --palette-obsidian: #111318;
  --palette-green-50: #ecfdf5;
  --palette-green-500: #10b981;
  --palette-amber-500: #d97706;
  --palette-red-500: #dc2626;
  --palette-blue-500: #0284c7;
  --palette-zinc-600: #52525b;

  /* 语义色：双层画布（微像素点阵浅灰底 + 纯白圆润卡片） */
  --color-canvas: var(--palette-gray-50);
  --color-sidebar: var(--palette-gray-25);
  --color-surface: var(--palette-white);
  --color-surface-muted: #f2f3f6;
  --color-surface-chip: #eaecf0;
  --color-surface-hover: var(--palette-gray-100);
  --color-surface-inverse: var(--palette-gray-900);
  --color-border: var(--palette-gray-200);
  --color-border-strong: var(--palette-gray-300);
  --color-text: var(--palette-gray-900);
  --color-text-secondary: var(--palette-gray-700);
  --color-text-muted: var(--palette-gray-500);
  --color-text-subtle: var(--palette-gray-400);
  --color-text-inverse: var(--palette-white);
  --color-brand: var(--palette-obsidian);
  --color-brand-contrast: var(--palette-white);
  --color-grid-dot: rgb(13 15 20 / 6.5%);
  --color-success: var(--palette-green-500);
  --color-success-soft: var(--palette-green-50);
  --color-warning: var(--palette-amber-500);
  --color-danger: var(--palette-red-500);
  --color-info: var(--palette-blue-500);
  --color-overlay: rgb(13 15 20 / 42%);
  --color-scrim: rgb(9 10 13 / 90%);

  /* 图表序列色：黑白精密基调 + 克制语义色 */
  --chart-1: #10b981;
  --chart-2: #ef4444;
  --chart-3: #9ca3af;
  --chart-4: #3f3f46;
  --chart-grid: #eceef2;

  /* 字体 */
  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 15px;
  --text-xl: 18px;
  --text-display: 24px;
  --leading-tight: 1.3;
  --leading-normal: 1.55;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* 间距 */
  --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;

  /* 控件高度 */
  --control-xs: 24px;
  --control-sm: 32px;

  /* 呼应超椭圆 Logo 的柔和圆润几何圆角 */
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius-md: 11px;
  --radius-xl: 18px;
  --radius-full: 999px;
  --radius-control: 9px;
  --radius-panel: 14px;
  --radius-dialog: 16px;

  /* 层次阴影 */
  --shadow-card: 0 1px 2px rgb(13 15 20 / 4%), 0 1px 1px rgb(13 15 20 / 2%);
  --shadow-card-hover: 0 10px 24px -14px rgb(13 15 20 / 18%), 0 1px 2px rgb(13 15 20 / 5%);
  --shadow-popover: 0 16px 36px -12px rgb(13 15 20 / 22%), 0 0 0 1px var(--color-border);
  --shadow-dialog: 0 26px 64px -22px rgb(13 15 20 / 30%);

  --motion-fast: 130ms;
  --motion-base: 200ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --layout-sidebar: 218px;
  --layout-content: 100%;

  /* daisyUI 主题映射 */
  --color-base-100: var(--color-surface);
  --color-base-200: var(--color-surface-muted);
  --color-base-300: var(--color-border);
  --color-base-content: var(--color-text);
  --color-primary: var(--palette-obsidian);
  --color-primary-content: var(--palette-white);
  --color-secondary: var(--palette-zinc-600);
  --color-secondary-content: var(--palette-white);
  --color-accent: var(--palette-green-500);
  --color-accent-content: var(--palette-white);
  --color-neutral: var(--palette-obsidian);
  --color-neutral-content: var(--palette-white);
  --color-info-content: var(--palette-white);
  --color-success-content: var(--palette-white);
  --color-warning-content: var(--palette-white);
  --color-error: var(--color-danger);
  --color-error-content: var(--palette-white);
  --radius-selector: var(--radius-xs);
  --radius-field: var(--radius-control);
  --radius-box: var(--radius-panel);
  --size-selector: 0.25rem;
  --size-field: 0.25rem;
  --border: 1px;
  --depth: 0;
  --noise: 0;
}

/* 暗色主题：与黑底像素 P 图标同源的曜石黑精密层次 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-canvas: #090a0d;
  --color-sidebar: #0c0e13;
  --color-surface: #12141b;
  --color-surface-muted: #181b24;
  --color-surface-chip: #1e222d;
  --color-surface-hover: #1b1f29;
  --color-surface-inverse: #f4f5f7;
  --color-border: #222631;
  --color-border-strong: #323846;
  --color-text: #f4f5f7;
  --color-text-secondary: #d1d5db;
  --color-text-muted: #8b92a1;
  --color-text-subtle: #5c6370;
  --color-text-inverse: #090a0d;
  --color-brand: #f4f5f7;
  --color-brand-contrast: #090a0d;
  --color-grid-dot: rgb(255 255 255 / 5.5%);
  --color-success: #34d399;
  --color-success-soft: rgb(16 185 129 / 14%);
  --color-warning: #fbbf24;
  --color-danger: #f87171;
  --color-info: #38bdf8;
  --color-overlay: rgb(0 0 0 / 64%);
  --chart-1: #34d399;
  --chart-2: #f87171;
  --chart-3: #6b7280;
  --chart-4: #a1a1aa;
  --chart-grid: #1e222d;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 32%);
  --shadow-card-hover: 0 12px 28px -12px rgb(0 0 0 / 62%);
  --shadow-popover: 0 16px 36px -10px rgb(0 0 0 / 70%), 0 0 0 1px var(--color-border);
  --shadow-dialog: 0 28px 64px -18px rgb(0 0 0 / 80%);

  --color-base-100: var(--color-surface);
  --color-base-200: var(--color-surface-muted);
  --color-base-300: var(--color-border);
  --color-base-content: var(--color-text);
  --color-primary: #f4f5f7;
  --color-primary-content: #090a0d;
  --color-neutral: #e5e7eb;
  --color-neutral-content: #090a0d;
}

:root[data-theme="dark"] .btn:disabled,
:root[data-theme="dark"] .btn[disabled] {
  color: var(--color-text-muted);
  border-color: var(--color-border);
  background: var(--color-surface-muted);
  opacity: 0.68;
}

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

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

[x-cloak], [hidden] {
  display: none !important;
}

::selection {
  background: var(--palette-gray-200);
}

.code ::selection, .code::selection {
  background: rgb(255 255 255 / 0.22);
  color: inherit;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

/* ---------- 图标 ---------- */
ui-icon {
  display: inline-flex;
  flex: none;
  width: 16px;
  height: 16px;
}

ui-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

ui-icon.icon-sm {
  width: 14px;
  height: 14px;
}

ui-icon.icon-lg {
  width: 20px;
  height: 20px;
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 布局原语 ---------- */
.vstack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.vstack-xs { gap: var(--space-1); }
.vstack-sm { gap: var(--space-2); }
.vstack-md { gap: var(--space-3); }
.vstack-lg { gap: var(--space-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.row-xs { gap: var(--space-1); }
.row-lg { gap: var(--space-4); }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-start { align-items: flex-start; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.shrink-0 { flex: none; }

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 文本 ---------- */
.title-page {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.title-section {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }
.text-strong { font-weight: var(--weight-medium); }
.text-right { text-align: right; }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.pre-wrap { white-space: pre-wrap; }
.break-all { word-break: break-all; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.copyable {
  cursor: copy;
  border-radius: var(--radius-xs);
}

.copyable:hover {
  background: var(--color-surface-hover);
}

/* ---------- 应用外壳 ---------- */
.app {
  height: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: var(--layout-sidebar);
  height: 100%;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  user-select: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 54px;
  border-bottom: 1px solid var(--color-border);
  flex: none;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  flex: none;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgb(15 23 42 / 18%));
}

.brand-logo-img.brand-logo-sm {
  width: 26px;
  height: 26px;
}

.brand-name-en {
  font-size: 12px;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  letter-spacing: -0.01em;
}

.brand-meta {
  min-width: 0;
  flex: 1;
}

.brand-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-name {
  font-size: 13.5px;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--color-text-muted);
  line-height: 1.2;
}

.brand-version {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 0 5px;
  height: 16px;
  border-radius: 5px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 14px;
  cursor: pointer;
  position: relative;
}

.brand-version:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.brand-version[data-new]::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-success);
}

/* 左侧导航：图标与名称紧密对齐（gap: 8px），紧凑高级 */
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.nav-group {
  padding: 12px 8px 4px;
  color: var(--color-text-subtle);
  font-size: 11px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.02em;
}

.nav > div:first-of-type .nav-group {
  padding-top: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--color-text-secondary);
  font-size: 12.5px;
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.nav-item ui-icon {
  width: 15px;
  height: 15px;
  opacity: 0.82;
}

.nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-item[aria-current="page"] {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

:root[data-theme="dark"] .nav-item[aria-current="page"] {
  background: var(--color-surface-muted);
  border-color: var(--color-border-strong);
}

.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--color-brand);
}

.nav-item[aria-current="page"] ui-icon {
  color: var(--color-brand);
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  padding: 0 6px;
  height: 18px;
  line-height: 16px;
  border-radius: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.nav-item[aria-current="page"] .nav-badge {
  background: var(--color-brand);
  color: var(--color-brand-contrast);
  border-color: transparent;
}

.sidebar-bottom {
  padding: 10px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 侧栏底部号池脉搏微卡（模块化像素圆角指示灯与分段条） */
.pool-pulse {
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-decoration: none;
  transition: border-color var(--motion-fast) var(--ease);
}

.pool-pulse:hover {
  border-color: var(--color-border-strong);
}

.pool-pulse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.pool-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 2.5px;
  background: var(--color-success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-success) 18%, transparent);
}

.pool-pulse-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--color-surface-muted);
  overflow: hidden;
  display: flex;
  gap: 2px;
  padding: 1px;
}

.pool-pulse-bar > i {
  display: block;
  height: 100%;
  border-radius: 2.5px;
}

.pool-pulse-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.sidebar-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--color-brand);
  color: var(--color-brand-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  flex: none;
}

.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background-color: var(--color-canvas);
  background-image: radial-gradient(var(--color-grid-dot) 1px, transparent 1px);
  background-size: 18px 18px;
}

.shell-content {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--color-canvas);
}

.mobile-bar {
  display: none;
}

@media (max-width: 1023px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 50px;
    padding: 0 var(--space-3);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }
}

/* 内容页：自适应全宽流式布局，宽屏 / 2K / 4K 下不留大块左右空白 */
.page {
  width: 100%;
  max-width: var(--layout-content);
  margin: 0;
  padding: var(--space-6) clamp(20px, 2.2vw, 36px) var(--space-10);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.page-head-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-head-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* 全高工作区（创作台） */
.workspace {
  display: flex;
  height: 100%;
  min-height: 0;
}

@media (max-width: 720px) {
  .page {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }
}

/* ---------- 面板：清晰白底 + 1px 柔和边框 + 微阴影 ---------- */
.panel {
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

/* 表格类主体面板：同样收束在精致白底卡片容器内，彻底告别裸表格 */
.panel-flush {
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-sm);
  margin-bottom: var(--space-3);
}

.panel-flush > .panel-head {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.panel-flush > ui-pager {
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-canvas) 45%, var(--color-surface));
}

.tile {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
}

/* ---------- 指标卡：图标徽章 + 迷你趋势线 + 交互筛选态 ---------- */
.metric-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.metric-tile.is-clickable {
  cursor: pointer;
}

.metric-tile.is-clickable:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.metric-tile.is-active {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-brand) 16%, transparent), var(--shadow-card-hover);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.metric-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.metric-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
}

.metric-icon.tone-brand {
  background: var(--color-brand);
  border-color: transparent;
  color: var(--color-brand-contrast);
}
.metric-icon.tone-success {
  background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-success) 24%, var(--color-border));
  color: var(--color-success);
}
.metric-icon.tone-warning {
  background: color-mix(in srgb, var(--color-warning) 13%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-warning) 26%, var(--color-border));
  color: var(--color-warning);
}
.metric-icon.tone-info {
  background: color-mix(in srgb, var(--color-info) 12%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-info) 24%, var(--color-border));
  color: var(--color-info);
}
.metric-icon.tone-violet {
  background: var(--color-surface-muted);
  border-color: var(--color-border);
  color: var(--color-text);
}

.metric-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.metric-value {
  font-size: var(--text-display);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.metric-meta {
  color: var(--color-text-muted);
  font-size: 11.5px;
  margin-top: 4px;
}

.metric-spark {
  width: 68px;
  height: 24px;
  flex: none;
  overflow: visible;
}

.metric-active-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--color-brand);
  color: var(--color-brand-contrast);
  font-weight: var(--weight-medium);
}

/* ---------- 快捷状态胶囊与批量条 ---------- */
.pill-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.status-pill {
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--motion-fast) var(--ease);
}

.status-pill:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.status-pill.is-active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-brand-contrast);
  font-weight: var(--weight-medium);
}

.status-pill.is-active .status-pill-count {
  color: inherit;
  opacity: 0.78;
}

.status-pill-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border-strong);
  background: var(--color-surface-muted);
  font-size: 12px;
}

/* ---------- 表格：清晰表头、首字母头像、可视化额度与成功率条 ---------- */
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.table {
  font-size: var(--text-sm);
}

.table :where(thead tr) {
  background: color-mix(in srgb, var(--color-canvas) 65%, var(--color-surface));
  border-color: var(--color-border);
}

.table :where(th) {
  color: var(--color-text-muted);
  font-size: 11.5px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

.table :where(th.sortable) {
  cursor: pointer;
  user-select: none;
}

.table :where(th.sortable:hover) {
  color: var(--color-text);
}

.table :where(tbody tr) {
  transition: background var(--motion-fast) var(--ease);
}

.table :where(tbody tr:not(:last-child)) {
  border-color: var(--color-border);
}

.table :where(tbody tr):hover {
  background: color-mix(in srgb, var(--color-canvas) 70%, var(--color-surface));
}

.table :where(tbody tr.row-clickable) {
  cursor: pointer;
}

.table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.table .col-check {
  width: 1%;
}

/* 账号单元格：头像 + 状态圆点 + 副标题 */
.acct-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.acct-avatar {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: var(--weight-semibold);
  flex: none;
  border: 1px solid transparent;
}

.acct-avatar.t0 { background: rgb(17 19 24 / 9%); color: #111318; border-color: rgb(17 19 24 / 18%); }
.acct-avatar.t1 { background: rgb(16 185 129 / 11%); color: #059669; border-color: rgb(16 185 129 / 24%); }
.acct-avatar.t2 { background: rgb(2 132 199 / 11%); color: #0284c7; border-color: rgb(2 132 199 / 24%); }
.acct-avatar.t3 { background: rgb(82 82 91 / 11%); color: #3f3f46; border-color: rgb(82 82 91 / 22%); }
.acct-avatar.t4 { background: rgb(217 119 6 / 11%); color: #d97706; border-color: rgb(217 119 6 / 24%); }

:root[data-theme="dark"] .acct-avatar.t0 { background: rgb(244 245 247 / 13%); color: #f4f5f7; border-color: rgb(244 245 247 / 24%); }
:root[data-theme="dark"] .acct-avatar.t1 { background: rgb(52 211 153 / 15%); color: #6ee7b7; border-color: rgb(52 211 153 / 28%); }
:root[data-theme="dark"] .acct-avatar.t2 { background: rgb(56 189 248 / 15%); color: #7dd3fc; border-color: rgb(56 189 248 / 28%); }
:root[data-theme="dark"] .acct-avatar.t3 { background: rgb(161 161 170 / 16%); color: #d4d4d8; border-color: rgb(161 161 170 / 28%); }
:root[data-theme="dark"] .acct-avatar.t4 { background: rgb(251 191 36 / 15%); color: #fcd34d; border-color: rgb(251 191 36 / 28%); }

.acct-status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1.5px solid var(--color-surface);
  background: var(--color-text-subtle);
}

.acct-status-dot.s-ok { background: var(--color-success); }
.acct-status-dot.s-warn { background: var(--color-warning); }
.acct-status-dot.s-err { background: var(--color-danger); }

.acct-email {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: var(--weight-medium);
  color: var(--color-text);
  line-height: 1.3;
}

.acct-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* 迷你进度条（额度 / 成功率 / 模型占比） */
.mini-meter {
  width: clamp(132px, 11vw, 200px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-meter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.mini-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--color-surface-muted);
  overflow: hidden;
}

.mini-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width var(--motion-base) var(--ease);
}

.mini-bar.bar-split {
  background: color-mix(in srgb, var(--color-danger) 28%, var(--color-surface-muted));
}

.status-dot-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-dot-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

/* 右侧滑出诊断抽屉（替代打断式大弹窗） */
.side-drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}

.side-drawer-mask {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(2px);
}

.side-drawer {
  position: relative;
  z-index: 1;
  width: min(460px, 94vw);
  height: 100%;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
  animation: drawerSlideIn 190ms var(--ease);
}

@keyframes drawerSlideIn {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.side-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
}

.side-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-drawer-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-canvas) 60%, var(--color-surface));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.drawer-stat-box {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-canvas);
  text-align: center;
}

.drawer-stat-label {
  font-size: 11px;
  color: var(--color-text-muted);
}

.drawer-stat-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.field-help {
  color: var(--color-text-subtle);
  cursor: help;
}

.field-error {
  color: var(--color-danger);
  font-size: var(--text-xs);
}

/* 设置项：一行一个，左侧名称与说明，右侧控件 */
.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: center;
  gap: var(--space-4) var(--space-8);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border);
}

.setting-row-block {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

.setting-name {
  font-size: var(--text-md);
}

.setting-desc {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.segmented {
  justify-self: end;
}

@media (max-width: 720px) {
  .setting-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .segmented {
    justify-self: start;
  }
}

.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-sm);
  cursor: pointer;
}

.input, .select, .textarea {
  width: 100%;
  font-size: var(--text-sm);
}

.textarea {
  line-height: var(--leading-normal);
}

.input-group {
  display: flex;
  gap: var(--space-2);
}

/* ---------- 下拉选择 ---------- */
ui-select {
  display: inline-flex;
  min-width: 0;
}

ui-select > option {
  display: none;
}

ui-date {
  display: block;
  min-width: 0;
}

/* 日历浮层：周一开始，选中范围浅灰底，起止日期深色 */
.date-panel {
  width: 272px;
  max-height: none;
  padding: var(--space-3);
}

.date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-weight: var(--weight-medium);
}

.date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  row-gap: 2px;
}

.date-week {
  padding: var(--space-1) 0;
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  text-align: center;
}

.date-day {
  height: var(--control-sm);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.date-day:hover {
  background: var(--color-surface-hover);
}

.date-day.outside {
  color: var(--color-text-subtle);
}

.date-day.today {
  font-weight: var(--weight-semibold);
}

.date-day.in-range {
  border-radius: 0;
  background: var(--color-surface-hover);
}

.date-day.edge {
  border-radius: var(--radius-sm);
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
}

.date-clear {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-xs);
  color: var(--color-text-subtle);
}

.date-clear:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-warning);
}

ui-select.block {
  display: flex;
}

ui-select > button, ui-date > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  height: var(--control-sm);
  padding: 0 var(--space-2) 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

ui-select[icon] > button > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

ui-select[variant="ghost"] > button {
  border-color: transparent;
  background: transparent;
}

ui-select > button:hover, ui-date > button:hover {
  border-color: var(--color-border-strong);
}

ui-select > button:disabled, ui-date > button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.dropdown-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-1);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--control-sm);
  padding: var(--space-1) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dropdown-option:hover, .dropdown-option:focus-visible {
  background: var(--color-surface-hover);
  outline: none;
}

.dropdown-option[aria-selected="true"] {
  font-weight: var(--weight-medium);
}

.dropdown-check {
  visibility: hidden;
}

.dropdown-option[aria-selected="true"] .dropdown-check {
  visibility: visible;
}

/* ---------- 分页 ---------- */
ui-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

/* ---------- 空状态与加载 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-subtle);
  text-align: center;
}

.empty ui-icon {
  width: 24px;
  height: 24px;
}

.center-fill {
  display: grid;
  place-items: center;
  min-height: 40vh;
}

/* ---------- 缩略图 ---------- */
.thumb {
  display: block;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  cursor: zoom-in;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- 键值列表 ---------- */
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
}

.kv dt {
  color: var(--color-text-muted);
}

.kv dd {
  min-width: 0;
  word-break: break-all;
}

/* ---------- 代码块 ---------- */
.code {
  margin: 0;
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inverse);
  color: var(--palette-gray-100);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- daisyUI 组件适配 ---------- */
.btn {
  font-weight: var(--weight-medium);
  gap: var(--space-1);
  box-shadow: none;
}

.btn-sm {
  font-size: var(--text-sm);
  padding-inline: var(--space-3);
}

.btn-xs {
  font-size: var(--text-xs);
  padding-inline: var(--space-2);
}

.btn-square.btn-xs, .btn-square.btn-sm {
  padding: 0;
}

.btn-ghost {
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}


.btn.btn-active {
  --btn-bg: var(--color-surface);
  --btn-border: var(--color-text-subtle);
}

/* 控件一律使用淡色描边：聚焦只加深边框颜色，不叠加粗轮廓 */
.input, .textarea, .select {
  --input-color: var(--color-border);
  box-shadow: none;
}

.input:hover, .textarea:hover {
  --input-color: var(--color-border-strong);
}

.input:focus, .input:focus-within, .textarea:focus, .select:focus {
  --input-color: var(--color-text-subtle);
  outline: none;
  box-shadow: none;
}

.checkbox, .toggle {
  --input-color: var(--color-border-strong);
}

:where(.btn, .tab, .checkbox, .toggle, .nav-item, ui-select > button, ui-date > button, .date-day, .copyable):focus-visible {
  outline: 2px solid var(--color-border-strong);
  outline-offset: 1px;
}

.tabs-border .tab-active::before {
  --tab-border-color: var(--color-text-secondary);
  border-top-width: 2px;
}

.badge {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.tabs-box {
  padding: var(--space-1);
  background: var(--color-surface-muted);
  box-shadow: none;
}

.tabs-box .tab {
  height: var(--control-xs);
  font-size: var(--text-xs);
}

.tabs-box .tab-active, .tabs-box .tab.tab-active:not(.tab-disabled, [disabled]) {
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
}

.tabs-border .tab {
  font-size: var(--text-sm);
}

.toggle {
  --radius-selector: var(--radius-full);
}

.toggle:checked {
  --input-color: var(--color-success);
  background-color: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-success-content);
}

.tooltip::before {
  font-size: var(--text-xs);
  max-width: 280px;
  white-space: normal;
}

/* 弹窗不铺满屏幕：限制宽高，内容多时分 Tab，超出部分在弹窗内滚动 */
.modal-box {
  max-width: 560px;
  max-height: min(720px, calc(100dvh - 160px));
  padding: var(--space-6);
  border-radius: var(--radius-dialog);
  box-shadow: var(--shadow-dialog);
}

.modal-box.modal-wide {
  max-width: 880px;
}

.modal-box.modal-md {
  max-width: 720px;
  max-height: min(640px, calc(100dvh - 160px));
}

.modal-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.modal-head .modal-title {
  flex: 1;
  margin: 0;
}

.inline-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}

.inline-stats dt {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.inline-stats dd {
  min-width: 0;
  margin-top: var(--space-1);
}

.modal-title {
  margin-bottom: var(--space-4);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-action {
  margin-top: var(--space-6);
  gap: var(--space-2);
}

.modal-backdrop {
  background: var(--color-overlay);
}

.alert {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  gap: var(--space-2);
}

.toast {
  z-index: 100;
}

.progress {
  height: 6px;
}

/* ---------- 图片查看器 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--color-scrim);
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
  transition: transform var(--motion-base) var(--ease);
  cursor: zoom-in;
}

.lightbox img.zoomed {
  transform: scale(2);
  cursor: zoom-out;
}

.lightbox-bar {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev { left: var(--space-4); }
.lightbox-next { right: var(--space-4); }

.lightbox .btn {
  background: rgb(0 0 0 / 50%);
  border: 0;
  color: var(--color-text-inverse);
}

.lightbox .chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: rgb(0 0 0 / 50%);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
}

/* ---------- Markdown 正文 ---------- */
.markdown > * + * {
  margin-top: var(--space-3);
}

.markdown ul, .markdown ol {
  padding-left: var(--space-6);
}

.markdown pre {
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inverse);
  color: var(--palette-gray-100);
  font-size: var(--text-xs);
}

.markdown :not(pre) > code {
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
  background: var(--color-surface-hover);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.markdown a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown table {
  border-collapse: collapse;
}

.markdown th, .markdown td {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
}

/* ---------- 页面专用 ---------- */
.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  min-height: 100%;
  padding: var(--space-8);
  background-color: var(--color-canvas);
  background-image:
    radial-gradient(640px circle at 50% 18%, color-mix(in srgb, var(--color-brand) 6%, transparent), transparent 62%),
    radial-gradient(var(--color-grid-dot) 1px, transparent 1px);
  background-size: 100% 100%, 18px 18px;
}

.login-github {
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.login-github:hover {
  color: var(--color-text);
}

.login-card {
  gap: var(--space-6);
  width: min(410px, 100%);
  padding: 28px 28px 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-dialog);
}

.login-hero {
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

ui-icon.login-logo {
  width: var(--space-10);
  height: var(--space-10);
}

.login-logo-img {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgb(15 23 42 / 22%));
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.login-title-en {
  font-size: 15px;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  letter-spacing: -0.01em;
}

.login-sub {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.chart-box {
  position: relative;
  height: 240px;
}

.metric-skeleton {
  height: 112px;
  border-radius: var(--radius-panel);
}

.search-input {
  width: clamp(220px, 18vw, 340px);
}

/* ---------- 号池 ---------- */
.option-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}

.option-card:hover {
  background: var(--color-surface-hover);
}

ui-model {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  height: var(--control-xs);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-surface-chip);
  color: var(--color-text);
  font: inherit;
  cursor: copy;
}

.model-chip:hover {
  background: var(--color-surface-hover);
}

/* 创作台：左侧创作记录 + 右侧记录内容，输入框固定在底部 */
.chat-page {
  position: relative;
}

.chat-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: none;
  width: 260px;
  padding: var(--space-4) var(--space-3);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-new {
  justify-content: flex-start;
}

.chat-side-head {
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  border-radius: var(--radius-control);
  color: var(--color-text-secondary);
}

.chat-item:hover {
  background: var(--color-surface-hover);
}

.chat-item[aria-current] {
  background: var(--color-surface-hover);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

.chat-item-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  height: var(--control-sm);
  padding: 0 var(--space-3);
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-item-delete {
  margin-right: var(--space-1);
}

.btn-plain:hover {
  background: none;
  border-color: transparent;
  box-shadow: none;
}

.chat-item-delete ui-icon {
  opacity: 0;
}

.chat-item:hover .chat-item-delete ui-icon, .chat-item-delete:focus-visible ui-icon {
  opacity: 1;
}

@media (hover: none) {
  .chat-item-delete ui-icon {
    opacity: 1;
  }
}

.chat-main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background-color: var(--color-canvas);
  background-image:
    radial-gradient(680px circle at 50% 0%, color-mix(in srgb, var(--color-brand) 5%, transparent), transparent 60%),
    radial-gradient(var(--color-grid-dot) 1px, transparent 1px);
  background-size: 100% 100%, 18px 18px;
}

.chat-menu, .chat-scrim {
  display: none;
}

.chat-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-thread {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.chat-dock {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-6);
}

/* ---------- 消息 ---------- */
.chat-msg.user {
  display: flex;
  justify-content: flex-end;
}

.chat-user {
  align-items: flex-end;
  max-width: 80%;
}

.bubble {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-xl);
  background: var(--color-surface-hover);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-markdown {
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  word-break: break-word;
}

.chat-user-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.chat-user-image {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.chat-user-image img {
  display: block;
  max-width: 96px;
  max-height: 96px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.chat-zoom {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* ---------- 图片任务 ---------- */
.chat-tasks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.chat-tasks.single {
  grid-template-columns: minmax(0, 240px);
}

.chat-task-media {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-panel);
  background: var(--color-surface-hover);
}

.chat-task-badge {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  opacity: 0.75;
  pointer-events: none;
}

.chat-task-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.65) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: chat-task-sweep 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes chat-task-sweep {
  to {
    transform: translateX(100%);
  }
}

.chat-task-image, .chat-task-state {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.chat-task-image img, .chat-result-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-task-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--color-text-muted);
  text-align: center;
  word-break: break-word;
}

.chat-task-foot {
  padding: var(--space-2) var(--space-1) 0;
}

.chat-user-meta {
  align-items: center;
  justify-content: flex-end;
}

/* ---------- 文件与语音结果 ---------- */
.chat-audio {
  width: 100%;
  max-width: 560px;
}

.chat-audio-file {
  max-width: 320px;
}

/* ---------- 输入区 ---------- */
.chat-dock {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: none;
  padding: 0 var(--space-6) var(--space-4);
}

.chat-dock-center {
  flex: 1;
  justify-content: center;
  padding-bottom: 8vh;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 12px 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-card-hover);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--color-brand) 45%, var(--color-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 10%, transparent), var(--shadow-card-hover);
}

.chat-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  text-align: center;
}

.chat-hero-title {
  font-size: var(--text-display);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chat-hero-sub {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.composer-input {
  width: 100%;
  max-height: 160px;
  padding: var(--space-1) var(--space-2);
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-md);
  resize: none;
  outline: none;
  field-sizing: content;
  min-height: calc(4lh + var(--space-2));
}

.composer-chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1);
}

.composer-add {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 56px;
  margin: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  color: var(--color-text-muted);
  transform: rotate(-6deg);
  cursor: pointer;
  transition: transform var(--motion-base) var(--ease);
}

.composer-add:hover {
  color: var(--color-text);
  transform: rotate(0);
}

.composer-refs {
  padding: 0 var(--space-1);
}

.composer-chip {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
}

.composer-chip img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.composer-chip button {
  position: absolute;
  top: calc(var(--space-1) * -1);
  right: calc(var(--space-1) * -1);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-surface-inverse);
  color: var(--color-text-inverse);
  cursor: pointer;
}

.composer-chip ui-icon {
  width: 12px;
  height: 12px;
}

.composer-foot {
  align-items: flex-end;
}

.composer-foot .tab {
  gap: var(--space-1);
}

.composer-audio {
  padding: var(--space-1) var(--space-2);
}

/* 图像设置浮层：在触发按钮上方展开 */
.chat-pop-wrap {
  position: relative;
}

.chat-pop {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  z-index: 20;
  gap: var(--space-5);
  width: min(400px, calc(100vw - var(--space-8)));
  padding: var(--space-5);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

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

.chat-ratio-active {
  background: var(--color-surface-muted);
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
  color: var(--color-text);
}

.chat-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}

.chat-ratio {
  flex-direction: column;
  gap: var(--space-2);
  height: auto;
  padding: var(--space-3) var(--space-1) var(--space-2);
  border-radius: var(--radius-control);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
}

.chat-ratio-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.chat-ratio-shape {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

/* 窄屏：对话记录收进左侧抽屉 */
@media (max-width: 720px) {
  .chat-side {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 30;
    box-shadow: var(--shadow-dialog);
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease);
  }

  .chat-side.open {
    transform: none;
  }

  .chat-scrim {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: block;
    background: var(--color-overlay);
  }

  .chat-menu {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 10;
    display: inline-flex;
  }

  .chat-thread {
    padding: var(--space-12) var(--space-4) var(--space-6);
  }

  .chat-dock {
    padding: 0 var(--space-3) var(--space-3);
  }

  .chat-user {
    max-width: 92%;
  }
}

/* API 文档：左侧吸顶目录 + 右侧内容，整页只保留主内容区一层滚动 */
.docs {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-8);
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.docs-nav .nav-group:first-child {
  padding-top: 0;
}

button.nav-item {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.docs-method {
  flex: none;
  width: 36px;
  font-size: 10px;
  font-weight: var(--weight-semibold);
}

.docs-section {
  scroll-margin-top: var(--space-8);
}

.docs-section + .docs-section {
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.code.copyable:hover {
  background: var(--color-surface-inverse);
}

@media (max-width: 1023px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }

  .docs-nav .nav-group {
    display: none;
  }

  .docs-nav .nav-item {
    width: auto;
    flex: none;
  }
}

/* 图库：卡片网格与缩略图尺寸 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  padding: 0;
}

.gallery-card {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
}

.gallery-card.selected {
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
}

.gallery-media {
  position: relative;
}

.gallery-thumb {
  width: 100%;
  border-radius: 0;
}

.gallery-check {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  background: var(--color-surface);
}

.gallery-meta {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 11px;
  pointer-events: none;
}

.gallery-thumb img {
  height: auto;
  aspect-ratio: 1;
}

.gallery-thumb-sm {
  width: 40px;
  height: 40px;
}

.gallery-name {
  max-width: 320px;
}

.gallery-name .copyable {
  display: block;
}

.gallery-range {
  width: 260px;
}

/* 日志：进度列、缩略图与详情弹窗 */

.logs-range {
  width: 260px;
}

.logs-progress {
  min-width: 360px;
}

.logs-duration {
  flex: none;
  text-align: right;
}

.logs-modal {
  width: min(1120px, 100%);
  max-width: min(1120px, calc(100vw - 32px));
  height: min(880px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
}

.logs-refresh {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.logs-bar {
  height: 4px;
}

.logs-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
}

.logs-endpoint {
  max-width: 280px;
}

.logs-endpoint .truncate {
  display: block;
}

/* kv 行用 contents 让 dt / dd 直接参与 kv 网格 */
.logs-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3) var(--space-6);
  margin: 0;
}

.logs-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-4);
}

.logs-item-long {
  grid-column: 1 / -1;
}

.logs-item dt {
  color: var(--color-text-muted);
}

.logs-item dd {
  min-width: 0;
  margin: 0;
  word-break: break-all;
}

.logs-kv-row {
  display: contents;
}

.logs-steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.logs-step {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: var(--space-3);
  padding-bottom: var(--space-4);
}

.logs-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 24px;
  bottom: 4px;
  left: 7px;
  width: 2px;
  background: var(--color-border);
}

.logs-step-icon {
  margin-top: 2px;
}

.logs-step-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.logs-step-head {
  min-height: 20px;
}

.logs-elapsed {
  display: inline-block;
  min-width: 64px;
  text-align: right;
}

.logs-event-kv {
  grid-template-columns: 180px minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
}

.logs-event-kv dd {
  white-space: pre-wrap;
}

.logs-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.logs-image {
  aspect-ratio: 1;
}

/* ---------- 设置 ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-10);
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.settings-title {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.settings-alert {
  margin: var(--space-2) 0;
}

/* 左侧导航 + 右侧内容的页面：整页固定高度，只滚动右侧内容 */
@media (min-width: 1024px) {
  .page-split {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-bottom: 0;
  }

  .page-split > .settings-layout {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .docs {
    height: 100%;
    padding-bottom: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  .settings-body, .docs-body {
    height: 100%;
    max-width: 1120px;
    overflow-y: auto;
    padding-right: var(--space-2);
    padding-bottom: var(--space-8);
  }
}

@media (max-width: 1023px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .settings-nav .nav-item {
    width: auto;
    flex: none;
  }
}
