/* =============================================
       Design System - CSS Custom Properties
       ============================================= */

    /* 高级黑 (default) */
    :root {
      --bg-root: #000000;
      --bg-soft: #0a0a0a;
      --glass-bg: rgba(255, 255, 255, 0.04);
      --glass-bg-hover: rgba(255, 255, 255, 0.08);
      --glass-border: rgba(255, 255, 255, 0.08);
      --glass-border-hover: rgba(255, 255, 255, 0.18);
      --glass-shine: rgba(255, 255, 255, 0.06);

      --text-primary: #f5f5f5;
      --text-secondary: #999999;
      --text-tertiary: #666666;

      --accent: #ffffff;
      --accent-dim: #cccccc;
      --accent-glow: rgba(255, 255, 255, 0.2);
      --accent-2: #e0e0e0;
      --accent-2-glow: rgba(255, 255, 255, 0.15);

      --danger: #cc5555;
      --danger-bg: rgba(204, 85, 85, 0.10);
      --success: #999999;
      --warning: #aaaaaa;

      --shadow-panel: 0 24px 80px rgba(0, 0, 0, 0.55);
      --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.30);
      --shadow-button: 0 8px 24px rgba(255, 255, 255, 0.06);

      --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-full: 999px;
      --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;

      --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
      --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
      --duration: 0.25s; --duration-slow: 0.5s;

      --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
      --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    }

    /* 高级白 */
    body[data-color-scheme="light"] {
      --bg-root: #ffffff;
      --bg-soft: #fafafa;
      --glass-bg: rgba(255, 255, 255, 0.70);
      --glass-bg-hover: rgba(255, 255, 255, 0.88);
      --glass-border: rgba(0, 0, 0, 0.07);
      --glass-border-hover: rgba(0, 0, 0, 0.18);
      --glass-shine: rgba(255, 255, 255, 0.80);

      --text-primary: #0a0a0a;
      --text-secondary: #777777;
      --text-tertiary: #aaaaaa;

      --accent: #0a0a0a;
      --accent-dim: #333333;
      --accent-glow: rgba(0, 0, 0, 0.10);
      --accent-2: #1a1a1a;
      --accent-2-glow: rgba(0, 0, 0, 0.08);

      --danger: #cc4444;
      --danger-bg: rgba(204, 68, 68, 0.06);
      --success: #666666;
      --warning: #888888;

      --shadow-panel: 0 20px 60px rgba(0, 0, 0, 0.06);
      --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.04);
      --shadow-button: 0 6px 18px rgba(0, 0, 0, 0.08);
    }

    /* ---- 奶油米 ---- */
    body[data-theme="cream"] {
      --bg-root: #faf2e0;
      --bg-soft: #f0e8d6;
      --text-primary: #0e61ac;
      --text-secondary: #3a7abc;
      --text-tertiary: #7a9acc;
      --accent: #0e61ac;
      --accent-dim: #1a6ab5;
      --accent-glow: rgba(14, 97, 172, 0.10);
      --accent-2: #1e6eb8;
      --accent-2-glow: rgba(14, 97, 172, 0.08);
    }

    /* ---- 雾灰紫 ---- */
    body[data-theme="slate"] {
      --bg-root: #e4e4e6;
      --bg-soft: #dadadd;
      --text-primary: #4a5266;
      --text-secondary: #6f7899;
      --text-tertiary: #9a9faa;
      --accent: #6f7899;
      --accent-dim: #5a637f;
      --accent-glow: rgba(111, 120, 153, 0.10);
      --accent-2: #7f87a5;
      --accent-2-glow: rgba(111, 120, 153, 0.08);
    }

    /* ---- 抹茶糕 ---- */
    body[data-theme="matcha-cake"] {
      --bg-root: #f4f8df;
      --bg-soft: #d9edb8;
      --text-primary: #26472b;
      --text-secondary: #3f7e44;
      --text-tertiary: #7aa05f;
      --accent: #3f7e44;
      --accent-dim: #2f6535;
      --accent-glow: rgba(63, 126, 68, 0.22);
      --accent-2: #a7cf5f;
      --accent-2-glow: rgba(167, 207, 95, 0.18);
    }

    /* ---- 薄荷饮 ---- */
    body[data-theme="coconut-mint"] {
      --bg-root: #e9fcfa;
      --bg-soft: #deeeff;
      --text-primary: #174d78;
      --text-secondary: #1d8ed6;
      --text-tertiary: #67acd4;
      --accent: #1d8ed6;
      --accent-dim: #176faa;
      --accent-glow: rgba(158, 206, 255, 0.32);
      --accent-2: #55d8c9;
      --accent-2-glow: rgba(85, 216, 201, 0.22);
    }

    /* ---- 芋泥酪 ---- */
    body[data-theme="taro-mousse"] {
      --bg-root: #f5eefb;
      --bg-soft: #e3e3fa;
      --text-primary: #49336f;
      --text-secondary: #7658b6;
      --text-tertiary: #9e87cb;
      --accent: #7b5bc2;
      --accent-dim: #62429f;
      --accent-glow: rgba(189, 163, 229, 0.30);
      --accent-2: #c178d9;
      --accent-2-glow: rgba(193, 120, 217, 0.22);
    }

    /* ---- 樱花酪 ---- */
    body[data-theme="blue-sakura"] {
      --bg-root: #fceff3;
      --bg-soft: #ccdcff;
      --text-primary: #2d4c9a;
      --text-secondary: #507bdb;
      --text-tertiary: #8498d8;
      --accent: #507bdb;
      --accent-dim: #3a61b5;
      --accent-glow: rgba(158, 195, 251, 0.32);
      --accent-2: #f08fb2;
      --accent-2-glow: rgba(240, 143, 178, 0.20);
    }

    /* ---- 草莓糕 ---- */
    body[data-theme="strawberry-cake"] {
      --bg-root: #fff5ef;
      --bg-soft: #ffdce5;
      --text-primary: #742436;
      --text-secondary: #d93655;
      --text-tertiary: #e28394;
      --accent: #d93655;
      --accent-dim: #ad2941;
      --accent-glow: rgba(217, 54, 85, 0.24);
      --accent-2: #ff8aa2;
      --accent-2-glow: rgba(255, 138, 162, 0.20);
    }

    /* ---- 蓝灰调 ---- */
    body[data-theme="cool-blue-gray"] {
      --bg-root: #feffff;
      --bg-soft: #afc8da;
      --text-primary: #243a50;
      --text-secondary: #47709b;
      --text-tertiary: #7f9bb2;
      --accent: #47709b;
      --accent-dim: #36587c;
      --accent-glow: rgba(71, 112, 155, 0.14);
      --accent-2: #afc8da;
      --accent-2-glow: rgba(175, 200, 218, 0.16);
    }





    /* ---- 蜜桃茶 ---- */
    body[data-theme="peach-oolong"] {
      --bg-root: #fff0e8;
      --bg-soft: #ffd8c9;
      --text-primary: #6f2b1d;
      --text-secondary: #c65c32;
      --text-tertiary: #dc9374;
      --accent: #e4783e;
      --accent-dim: #bb5527;
      --accent-glow: rgba(228, 120, 62, 0.22);
      --accent-2: #f2a65f;
      --accent-2-glow: rgba(242, 166, 95, 0.18);
    }

    /* ---- 焦糖咖 ---- */
    body[data-theme="caramel-macchiato"] {
      --bg-root: #faf3eb;
      --bg-soft: #ead4bd;
      --text-primary: #4b2f21;
      --text-secondary: #8b5a36;
      --text-tertiary: #b58a68;
      --accent: #9b6234;
      --accent-dim: #744622;
      --accent-glow: rgba(155, 98, 52, 0.18);
      --accent-2: #d6a15d;
      --accent-2-glow: rgba(214, 161, 93, 0.16);
    }


    /* ---- 荔枝冻 ---- */
    body[data-theme="rose-lychee"] {
      --bg-root: #fff0f3;
      --bg-soft: #ffd5de;
      --text-primary: #7a243c;
      --text-secondary: #c24765;
      --text-tertiary: #df8da0;
      --accent: #d9546f;
      --accent-dim: #b33651;
      --accent-glow: rgba(217, 84, 111, 0.20);
      --accent-2: #ff9a8d;
      --accent-2-glow: rgba(255, 154, 141, 0.18);
    }

    /* ---- 薰衣草 ---- */
    body[data-theme="lavender-latte"] {
      --bg-root: #f5f0fa;
      --bg-soft: #e5ddef;
      --text-primary: #493d61;
      --text-secondary: #7d6c9d;
      --text-tertiary: #a79bbd;
      --accent: #8a75b4;
      --accent-dim: #66528d;
      --accent-glow: rgba(138, 117, 180, 0.18);
      --accent-2: #b49ad0;
      --accent-2-glow: rgba(180, 154, 208, 0.16);
    }

    /* ---- 海盐酪 ---- */
    body[data-theme="sea-salt-cheese"] {
      --bg-root: #f5f6f8;
      --bg-soft: #e2e7ee;
      --text-primary: #25303d;
      --text-secondary: #5f6f82;
      --text-tertiary: #9aa5b2;
      --accent: #6e8097;
      --accent-dim: #53647a;
      --accent-glow: rgba(110, 128, 151, 0.15);
      --accent-2: #b8c6d8;
      --accent-2-glow: rgba(184, 198, 216, 0.14);
    }

    /* =============================================
       Reset & Base
       ============================================= */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    html, body {
      height: 100vh; overflow: hidden;
      color: var(--text-primary);
      font-family: var(--font-sans);
      background: var(--bg-root);
      transition: background var(--duration-slow) var(--ease-out),
                  color var(--duration-slow) var(--ease-out);
    }

    body::before {
      content: "";
      position: fixed; inset: 0; pointer-events: none; z-index: 0;
      background:
        radial-gradient(680px 420px at 8% 6%, rgba(255,255,255,0.06), transparent 60%),
        radial-gradient(580px 380px at 92% 14%, rgba(255,255,255,0.04), transparent 58%),
        radial-gradient(520px 360px at 22% 90%, rgba(255,255,255,0.03), transparent 62%),
        radial-gradient(560px 400px at 78% 82%, rgba(255,255,255,0.04), transparent 60%);
      transition: opacity var(--duration-slow) var(--ease-out);
    }

    body[data-color-scheme="light"]::before {
      background:
        radial-gradient(680px 420px at 8% 6%, rgba(0,0,0,0.03), transparent 60%),
        radial-gradient(580px 380px at 92% 14%, rgba(0,0,0,0.02), transparent 58%),
        radial-gradient(520px 360px at 22% 90%, rgba(0,0,0,0.025), transparent 62%),
        radial-gradient(560px 400px at 78% 82%, rgba(0,0,0,0.02), transparent 60%);
      opacity: 0.7;
    }

    body::after {
      content: "";
      position: fixed; inset: 0; pointer-events: none; z-index: 0;
      background-image:
        linear-gradient(rgba(127, 127, 127, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(127, 127, 127, 0.03) 1px, transparent 1px);
      background-size: 48px 48px;
      mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%);
      opacity: 0.45;
    }

    /* ========== Layout ========== */
    .app {
      position: relative; z-index: 1;
      width: min(1600px, calc(100vw - 48px));
      height: min(calc(100vh - 48px), calc((100vw - 48px) * 0.62));
      margin: 24px auto;
      display: grid;
      grid-template-columns: 272px 1fr 388px;
      gap: 10px;
    }
    @media (min-aspect-ratio: 16/10) {
      .app { height: calc(100vh - 48px); }
    }

    /* ========== Glass Panel ========== */
    .glass {
      position: relative;
      display: flex; flex-direction: column;
      background: var(--glass-bg);
      border: 1px solid var(--glass-border);
      border-radius: var(--r-lg);
      backdrop-filter: blur(32px) saturate(1.5);
      -webkit-backdrop-filter: blur(32px) saturate(1.5);
      box-shadow: var(--shadow-panel), inset 0 1px 0 var(--glass-shine);
      overflow: hidden;
      transition: background var(--duration-slow) var(--ease-out),
                  border-color var(--duration-slow) var(--ease-out),
                  box-shadow var(--duration-slow) var(--ease-out);
    }

    .glass::before {
      content: "";
      position: absolute; inset: 0; pointer-events: none; z-index: 0;
      border-radius: inherit;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.10);
      transition: opacity var(--duration-slow) var(--ease-out);
    }

    body[data-color-scheme="light"] .glass::before {
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.50);
    }

    .glass > * { position: relative; z-index: 2; }

    /* ========== Sidebar ========== */
    .sidebar {
      padding: var(--s-5); gap: 14px; display: flex; flex-direction: column;
      overflow: visible;
      z-index: 10;
      box-shadow: 0 0 40px rgba(255,255,255,0.08), 0 0 80px rgba(255,255,255,0.04), 0 0 120px rgba(255,255,255,0.02);
    }
    body[data-color-scheme="light"] .sidebar {
      box-shadow: 0 0 40px rgba(0,0,0,0.08), 0 0 80px rgba(0,0,0,0.04), 0 0 120px rgba(0,0,0,0.02);
    }
    .brand { display: flex; gap: var(--s-3); align-items: center; }

    .logo {
      width: 44px; height: 44px; flex-shrink: 0;
      border-radius: 16px;
      object-fit: contain;
      box-shadow: 0 0 20px rgba(255,255,255,0.10);
    }

    .brand h1 { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; }
    .brand p { font-size: 12px; color: var(--text-secondary); }

    .section-title {
      font-size: 10px; font-weight: 700;
      text-transform: uppercase; letter-spacing: 1.6px;
      color: var(--text-tertiary);
      display: flex; align-items: center; gap: 7px;
      margin: 2px 0 6px;
    }

    .section-title::before {
      content: "";
      display: inline-block;
      width: 5px; height: 5px; border-radius: 50%;
      background: var(--text-primary);
      flex-shrink: 0;
    }

    .section-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: var(--s-2); margin: 2px 0 6px;
    }

    .card {
      padding: var(--s-3); border-radius: var(--r-md);
      border: 1px solid var(--glass-border);
      background: rgba(255, 255, 255, 0.03);
      box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.04);
      transition: border-color var(--duration) var(--ease-out);
    }

    /* ── 用户选择卡片 (扁平紧凑) ── */
    .user-select-card {
      padding: 10px; border-radius: var(--r-md);
      border: 1px solid var(--glass-border);
      transition: border-color var(--duration) var(--ease-out);
    }

    /* ── 用户选择 ── */
    .user-select-eyebrow {
      display: flex; align-items: center; gap: 7px;
      color: var(--text-secondary); font-size: 12px; font-weight: 700;
      margin-bottom: 8px;
    }

    .user-select-wrap { position: relative; margin-bottom: 8px; }
    .user-select-btn {
      width: 100%; height: 37px; display: flex; align-items: center; justify-content: space-between;
      padding: 0 11px; border: 1px solid var(--glass-border); border-radius: var(--r-md);
      background: rgba(255,255,255,0.04); color: var(--text-primary);
      cursor: pointer; font: inherit; font-size: 12px;
      transition: border-color var(--duration) var(--ease-out);
    }
    .user-select-btn:hover { border-color: var(--glass-border-hover); }

    .user-select-enter {
      width: 100%; height: 35px; border: 0; border-radius: var(--r-md);
      background: var(--accent); color: #000; cursor: pointer;
      font: inherit; font-size: 13px; font-weight: 800;
      transition: transform 180ms ease, filter 180ms ease;
    }
    body[data-color-scheme="light"] .user-select-enter {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: #fff;
      box-shadow: 0 10px 26px var(--accent-glow);
    }
    .user-select-enter:hover { transform: translateY(-1px); filter: brightness(1.04); }

    .expand-arrow { font-size: 8px; color: var(--text-secondary); transition: transform 200ms ease; }
    .expand-arrow.open { transform: rotate(180deg); }

    .user-select-backdrop { position: fixed; inset: 0; z-index: 9998; }
    .user-select-popover {
      background: var(--bg-soft); border: 1px solid var(--glass-border);
      border-radius: var(--r-md); padding: var(--s-3);
      box-shadow: var(--shadow-panel);
      backdrop-filter: blur(20px) saturate(1.3);
      position: relative; overflow: hidden;
    }

    .user-select-arcs::before,
    .user-select-arcs::after {
      content: ""; position: absolute; pointer-events: none;
      border: 1px solid var(--glass-border); border-radius: 50%;
    }
    .user-select-arcs::before {
      width: 260px; height: 260px; right: -140px; top: -100px;
      box-shadow: inset 0 0 0 14px rgba(255,255,255,0.016);
    }
    .user-select-arcs::after {
      width: 200px; height: 200px; left: -120px; bottom: -80px;
      box-shadow: inset 0 0 0 10px rgba(255,255,255,0.012);
    }

    .user-cards { display: grid; gap: 7px; margin-top: 10px; position: relative; z-index: 1; }

    .user-card {
      width: 100%; display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center; gap: 10px;
      padding: 10px 12px;
      border: 1px solid var(--glass-border);
      border-radius: var(--r-md);
      color: var(--text-primary);
      background: var(--glass-bg);
      cursor: pointer; text-align: left;
      font: inherit;
      transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
    }
    .user-card:hover {
      transform: translateY(-1px);
      border-color: var(--glass-border-hover);
      background: var(--glass-bg-hover);
    }
    .user-card.pressed {
      border-color: var(--glass-border-hover);
      background: var(--glass-bg-hover);
      box-shadow: inset 0 0 0 1px var(--glass-shine);
    }

    .user-card .avatar { width: 32px; height: 32px; font-size: 13px; }
    .user-card .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

    .user-card-info { min-width: 0; }
    .user-card-info b {
      display: block; overflow: hidden;
      font-size: 13px; font-weight: 700; line-height: 1.25;
      text-overflow: ellipsis; white-space: nowrap;
    }
    .user-card-info .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

    .user-card .check {
      width: 20px; height: 20px; display: grid; place-items: center;
      border: 1px solid var(--glass-border); border-radius: 50%;
      color: transparent; font-size: 12px; font-weight: 900;
      flex-shrink: 0;
    }
    .user-card.pressed .check { color: #000; background: #fff; border-color: transparent; }

    .actions {
      display: flex; align-items: center; justify-content: space-between;
      gap: 10px; margin-top: 12px; position: relative; z-index: 1;
    }
    .selected-copy { min-width: 0; color: var(--text-secondary); font-size: 11px; }
    .enter-btn {
      min-width: 80px; height: 36px; border: 0; border-radius: 12px;
      color: #000; background: #fff; cursor: pointer;
      font: inherit; font-size: 13px; font-weight: 800;
      transition: transform 180ms ease, filter 180ms ease;
    }
    .enter-btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
    .select-err { color: var(--danger); font-size: 11px; margin-top: 8px; position: relative; z-index: 1; }

    .stat {
      display: flex; justify-content: space-between; align-items: center;
      font-size: 12px;
      padding: 10px 12px; border-radius: 14px;
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.025);
      margin-bottom: 8px;
      transition: border-color var(--duration) var(--ease-out);
    }

    .stat:hover { border-color: var(--glass-border-hover); }

    /* 累计 Token 统计横向面板 */
    .tks-row { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
    .tks-chip { flex: 1 1 60px; min-width: 55px; padding: 6px 5px; border-radius: 10px;
      background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
      text-align: center; font-family: var(--font-mono); }
    .tks-chip .tks-val { font-size: 12px; font-weight: 800; color: var(--text-primary);
      line-height: 1.2; }
    .tks-chip .tks-lbl { font-size: 9px; color: var(--text-tertiary);
      margin-top: 1px; white-space: nowrap; }
    .ok { color: var(--success); font-weight: 800; }
    .ok { color: var(--success); font-weight: 800; }

    /* Conv list */
    .conv-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }

    .more-btn {
      display: block; width: 100%; margin-top: 4px;
      padding: 7px 0; border-radius: var(--r-sm);
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.03);
      color: var(--text-secondary); cursor: pointer;
      font-size: 12px; font-family: var(--font-sans);
      transition: all var(--duration) var(--ease-out);
    }
    .more-btn:hover {
      border-color: var(--glass-border-hover);
      background: rgba(255,255,255,0.06);
      color: var(--text-primary);
    }

    /* ── 对话管理二级页面 ── */
    .conv-mgr {
      position: absolute; inset: 0; z-index: 10;
      display: flex; flex-direction: column; gap: 14px;
      padding: var(--s-5);
      background: var(--bg-root);
      border-radius: var(--r-lg);
      overflow: hidden;
      animation: convMgrIn 0.25s var(--ease-out) both;
    }
    @keyframes convMgrIn {
      from { transform: translateX(20px); opacity: 0; }
      to { transform: none; opacity: 1; }
    }
    .conv-mgr-header {
      display: flex; align-items: center; gap: 10px;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--glass-border);
    }
    .conv-mgr-header h3 { font-size: 14px; font-weight: 700; flex: 1; }
    .conv-mgr-list {
      flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: 5px;
      align-content: start;
    }
    .conv-mgr-item {
      display: flex; align-items: center; gap: 8px; min-width: 0;
      padding: 9px 10px; border-radius: var(--r-sm);
      border: 1px solid rgba(255,255,255,0.05);
      background: rgba(255,255,255,0.02);
      cursor: pointer;
      transition: all var(--duration) var(--ease-out);
    }
    .conv-mgr-item:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
    .conv-mgr-item.active { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.06); }
    .conv-mgr-item-info { flex: 1; min-width: 0; }
    .conv-mgr-item-info b { font-size: 12px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .conv-mgr-item-info p { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }
    .conv-mgr-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
    body[data-color-scheme="light"] .conv-mgr { background: var(--bg-root); }

    .conv {
      position: relative; min-width: 0; overflow: hidden;
      padding: 10px 66px 10px 11px;
      border-radius: var(--r-sm);
      background: rgba(255, 255, 255, 0.02);
      border: 1px solid rgba(255, 255, 255, 0.06);
      cursor: pointer;
      transition: background var(--duration) var(--ease-out),
                  border-color var(--duration) var(--ease-out),
                  transform var(--duration) var(--ease-out);
    }

    .conv:hover {
      background: var(--glass-bg-hover);
      border-color: var(--glass-border-hover);
      transform: translateY(-1px);
    }

    .conv.active {
      background: rgba(255,255,255,0.06);
      border-color: rgba(255,255,255,0.22);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .conv.active {
      background: rgba(0,0,0,0.04);
      border-color: rgba(0,0,0,0.18);
      box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
    }

    .conv b { font-size: 12px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .conv p { font-size: 10px; color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .conv .ci-summary { color: var(--text-secondary); font-size: 10px; margin-top: 3px; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .conv-actions {
      position: absolute; right: 6px; top: 50%;
      transform: translateY(-50%);
      display: flex; gap: 4px; opacity: 0;
      transition: opacity var(--duration) var(--ease-out);
    }

    .conv:hover .conv-actions { opacity: 1; }

    .icon-btn, .tiny-btn {
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.04);
      color: var(--text-secondary);
      border-radius: var(--r-xs);
      cursor: pointer;
      transition: all var(--duration) var(--ease-out);
      font-family: var(--font-sans);
    }

    .icon-btn {
      width: 26px; height: 26px; font-size: 13px;
      display: inline-flex; align-items: center; justify-content: center;
    }

    .tiny-btn { padding: 4px 8px; font-size: 11px; }

    .icon-btn:hover, .tiny-btn:hover {
      color: var(--text-primary);
      border-color: var(--glass-border-hover);
      background: rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .icon-btn:hover,
    body[data-color-scheme="light"] .tiny-btn:hover { background: rgba(0,0,0,0.04); }

    .icon-btn.danger:hover, .tiny-btn.danger:hover {
      color: var(--danger); border-color: var(--danger);
      background: var(--danger-bg);
    }

    .mini-actions { display: flex; gap: 5px; }

    .profile {
      margin-top: auto;
      display: flex; gap: 10px; align-items: center;
      padding: var(--s-3); border-radius: var(--r-md);
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.025);
      overflow: visible;
      z-index: 60;
    }

    .avatar {
      width: 34px; height: 34px; flex-shrink: 0;
      border-radius: 50%;
      background: #ffffff;
      display: grid; place-items: center;
      color: #000; font-weight: 800; font-size: 14px;
      overflow: hidden;
    }

    body[data-color-scheme="light"] .avatar { background: var(--accent); color: #fff; box-shadow: 0 8px 18px var(--accent-glow); }

    .profile-with-theme {
      display: grid; grid-template-columns: auto minmax(0, 1fr) 72px;
      align-items: center; gap: 10px;
    }

    .theme-picker {
      position: relative; justify-self: end;
      width: 72px;
    }

    .theme-trigger {
      width: 72px; height: 30px;
      padding: 6px 12px;
      border: 1px solid var(--glass-border);
      border-radius: var(--r-full);
      background: rgba(255,255,255,0.04);
      color: var(--text-primary);
      font-size: 12px; font-weight: 700; font-family: var(--font-sans);
      cursor: pointer;
      transition: all var(--duration) var(--ease-out);
    }

    .theme-trigger:hover,
    .theme-trigger.active {
      border-color: var(--glass-border-hover);
      background: rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .theme-trigger:hover,
    body[data-color-scheme="light"] .theme-trigger.active { background: rgba(0,0,0,0.04); }

    .theme-dot {
      width: 8px; height: 8px; border-radius: 50%;
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      box-shadow: 0 0 12px var(--accent-glow);
    }

    .theme-menu {
      position: fixed; z-index: 9999;
      width: 162px; max-height: 330px; padding: 8px;
      display: grid; gap: 5px; overflow-y: auto;
      border: 1px solid var(--glass-border);
      border-radius: 18px;
      background: color-mix(in srgb, var(--bg-root) 78%, transparent);
      backdrop-filter: blur(28px) saturate(1.45);
      -webkit-backdrop-filter: blur(28px) saturate(1.45);
      box-shadow: 0 18px 52px rgba(0,0,0,0.28), inset 0 1px 0 var(--glass-shine);
      animation: themeMenuIn 0.18s var(--ease-out);
    }

    @keyframes themeMenuIn {
      from { opacity: 0; transform: translateY(8px) scale(0.97); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }

    .theme-choice {
      height: 32px; padding: 0 9px;
      display: grid; grid-template-columns: 10px 1fr auto;
      align-items: center; gap: 8px;
      border: 1px solid transparent;
      border-radius: 12px;
      background: transparent;
      color: var(--text-primary);
      font: 800 12px var(--font-sans);
      cursor: pointer; text-align: left;
      transition: all var(--duration) var(--ease-out);
    }

    .theme-choice:hover {
      background: var(--glass-bg-hover);
      border-color: var(--glass-border);
      transform: translateX(-2px);
    }

    .theme-choice.active {
      background: linear-gradient(135deg, var(--accent-glow), var(--accent-2-glow));
      border-color: var(--accent-glow);
      color: var(--text-primary);
    }

    .theme-choice-mark { color: var(--accent); font-size: 12px; }

    .refresh-btn {
      width: 30px; height: 30px; flex-shrink: 0;
      border-radius: 50%; border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.04);
      color: var(--text-secondary); cursor: pointer;
      font-size: 14px; display: grid; place-items: center;
      transition: all var(--duration) var(--ease-out);
    }
    .refresh-btn:hover {
      border-color: var(--glass-border-hover);
      background: rgba(255,255,255,0.08);
      color: var(--text-primary);
    }
    .refresh-btn:active { transform: scale(0.92); }
    @keyframes spin { to { transform: rotate(360deg); } }
    .refresh-btn.spinning { animation: spin 0.6s ease-in-out; pointer-events: none; }

    /* ========== Forms ========== */
    select, input, textarea {
      font-family: var(--font-sans); font-size: 13px;
      color: var(--text-primary);
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.04);
      border-radius: 10px;
      outline: none;
      transition: border-color var(--duration) var(--ease-out),
                  box-shadow var(--duration) var(--ease-out);
    }

    select:focus, input:focus, textarea:focus {
      border-color: rgba(255,255,255,0.25);
    }

    body[data-color-scheme="light"] select:focus,
    body[data-color-scheme="light"] input:focus,
    body[data-color-scheme="light"] textarea:focus { border-color: rgba(0,0,0,0.25); }

    select { width: 100%; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; }
    select option { background: var(--bg-soft); color: var(--text-primary); }

    /* ========== Buttons ========== */
    .btn {
      display: inline-flex; align-items: center; justify-content: center;
      border: 0; border-radius: var(--r-sm);
      padding: 9px 14px;
      font-weight: 700; font-size: 13px; font-family: var(--font-sans);
      cursor: pointer;
      transition: all var(--duration) var(--ease-out);
    }

    .btn:hover { transform: translateY(-1px); }
    .btn:active { transform: translateY(0); }

    .btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    .btn-primary {
      background: #ffffff;
      color: #000000; width: 100%;
      box-shadow: 0 8px 24px rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .btn-primary {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: #ffffff;
      box-shadow: 0 10px 26px var(--accent-glow);
    }

    .btn-primary:hover { filter: brightness(1.05); }
    .btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

    .btn-ghost {
      background: rgba(255,255,255,0.04);
      border: 1px solid var(--glass-border);
      color: var(--text-primary);
    }

    .btn-ghost:hover {
      background: rgba(255,255,255,0.08);
      border-color: var(--glass-border-hover);
    }

    .btn-danger {
      background: var(--danger-bg);
      border: 1px solid rgba(204,85,85,0.2);
      color: #cc8888;
    }

    body[data-color-scheme="light"] .btn-danger {
      border-color: rgba(204,68,68,0.15);
      color: #994444;
    }

    .btn-danger:hover { border-color: var(--danger); }
    .btn.mini, .btn-mini { padding: 6px 12px; font-size: 12px; border-radius: 10px; }
    .btn.small { padding: 6px 10px; font-size: 11px; border-radius: 9px; }

    /* ========== Main Chat ========== */
    .main { display: grid; grid-template-rows: auto 1fr auto; }

    .top {
      padding: 15px 20px;
      border-bottom: 1px solid var(--glass-border);
      display: flex; align-items: center; justify-content: space-between;
      gap: 14px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    }

    body[data-color-scheme="light"] .top {
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
    }

    .top h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); }
    .top p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
    .top-actions { display: flex; align-items: center; gap: 8px; }

    .model-badge {
      display: flex; gap: 7px; align-items: center;
      padding: 7px 12px; border-radius: var(--r-full);
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.12);
      font-size: 12px; color: var(--text-secondary);
    }

    body[data-color-scheme="light"] .model-badge {
      background: rgba(0,0,0,0.03);
      border-color: rgba(0,0,0,0.10);
    }

    .pulse {
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 14px var(--accent-glow);
      animation: pulse 2s ease-in-out infinite;
    }

    .pulse.active {
      background: var(--success);
      box-shadow: 0 0 14px var(--success);
      animation: pulseBeat 0.7s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.35; }
    }

    @keyframes pulseBeat {
      0%, 100% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.3; transform: scale(1.8); }
    }

    .top-status {
      display: flex; align-items: center; gap: 6px;
      padding: 5px 10px; border-radius: var(--r-full);
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.12);
      font-size: 11px; color: var(--text-secondary);
      max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      animation: rise 0.25s var(--ease-out) both;
    }
    .top-status.compress { border-color: rgba(56,189,248,0.3); color: var(--accent); }
    .top-status.save, .top-status.new-chat { border-color: rgba(255,255,255,0.15); }
    body[data-color-scheme="light"] .top-status {
      background: rgba(0,0,0,0.03);
      border-color: rgba(0,0,0,0.10);
    }
    .tiny-spinner {
      width: 10px; height: 10px; border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.15);
      border-top-color: var(--accent);
      animation: spin 0.6s linear infinite;
      flex-shrink: 0;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .running-tag {
      font-size: 10px; font-weight: 600;
      color: var(--success);
      animation: blink 1.2s step-start infinite;
    }

    @keyframes blink {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.25; }
    }

    .chat {
      padding: 18px 22px;
      overflow-y: auto; overflow-x: hidden;
      display: flex;
      flex-direction: column; gap: 14px;
    }

    .msg {
      display: flex; gap: 10px; max-width: 86%;
      animation: rise 0.3s var(--ease-out) both;
    }

    .msg.me { align-self: flex-end; flex-direction: row-reverse; }

    .msg-avatar {
      width: 32px; height: 32px; flex-shrink: 0;
      border-radius: 10px;
      background: rgba(255,255,255,0.06);
      border: 1px solid var(--glass-border);
      display: grid; place-items: center;
      font-size: 14px;
      box-shadow: var(--shadow-card);
    }

    .bubble {
      padding: 12px 15px; border-radius: 18px;
      font-size: 14px; line-height: 1.65;
      white-space: pre-wrap; word-wrap: break-word;
      overflow-x: auto; overflow-wrap: anywhere;
      max-width: 100%;
      background: rgba(255,255,255,0.05);
      border: 1px solid var(--glass-border);
    }
    .markdown-body {
      white-space: normal;
      overflow-x: hidden;
    }
    .markdown-body.markdown-streaming {
      white-space: normal;
    }
    .markdown-body.markdown-embedded {
      white-space: normal;
      overflow-x: hidden;
      min-width: 0;
    }
    /* ── Markdown 内容样式（react-markdown 渲染） ── */
    .markdown-body > :first-child { margin-top: 0; }
    .markdown-body > :last-child { margin-bottom: 0; }
    .markdown-body p { margin: 0 0 0.6em; }
    .markdown-body p:last-child { margin-bottom: 0; }
    .markdown-body h1,
    .markdown-body h2,
    .markdown-body h3,
    .markdown-body h4,
    .markdown-body h5,
    .markdown-body h6 {
      margin: 1em 0 0.4em; font-weight: 700; line-height: 1.3;
    }
    .markdown-body h1 { font-size: 1.3em; }
    .markdown-body h2 { font-size: 1.15em; }
    .markdown-body h3 { font-size: 1.05em; }
    .markdown-body h4, .markdown-body h5, .markdown-body h6 { font-size: 0.95em; }
    .markdown-body ul,
    .markdown-body ol {
      margin: 0 0 0.5em; padding-left: 1.6em;
    }
    .markdown-body li { margin: 0.2em 0; }
    .markdown-body li > p { margin: 0.2em 0; }
    .markdown-body blockquote {
      margin: 0.5em 0; padding: 0.4em 0.8em;
      border-left: 3px solid var(--accent-dim);
      color: var(--text-secondary);
      background: rgba(255,255,255,0.02);
      border-radius: 0 var(--r-xs) var(--r-xs) 0;
    }
    .markdown-body blockquote p:last-child { margin-bottom: 0; }
    .markdown-body pre {
      margin: 0.5em 0;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      overflow-x: auto;
      font-family: var(--font-mono);
      font-size: 13px; line-height: 1.6;
    }
    .markdown-body code {
      font-family: var(--font-mono);
      font-size: 0.88em;
      padding: 1px 5px;
      border-radius: 4px;
      background: rgba(255,255,255,0.08);
    }
    .markdown-body pre code {
      display: block;
      padding: 0;
      background: transparent;
      border-radius: 0;
      font-size: inherit;
      color: inherit;
    }
    body[data-color-scheme="light"] .markdown-body code {
      background: rgba(0,0,0,0.06);
    }
    .markdown-body hr {
      margin: 0.8em 0; border: none; height: 1px;
      background: var(--glass-border);
    }
    .markdown-body table {
      border-collapse: collapse; width: 100%;
      margin: 0.5em 0; font-size: 0.9em;
    }
    .markdown-body th,
    .markdown-body td {
      padding: 6px 10px; border: 1px solid var(--glass-border);
      text-align: left;
    }
    .markdown-body th {
      font-weight: 700;
      background: rgba(255,255,255,0.04);
    }
    body[data-color-scheme="light"] .markdown-body th {
      background: rgba(0,0,0,0.03);
    }
    .markdown-body img {
      max-width: 100%; border-radius: var(--r-sm);
      margin: 0.4em 0;
    }
    .markdown-body a {
      color: var(--accent-dim);
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .markdown-body a:hover { opacity: 0.8; }
    .markdown-body input[type="checkbox"] {
      margin-right: 4px; vertical-align: middle;
      accent-color: var(--accent-dim);
    }
    .artifact {
      margin: 10px 0;
      overflow: hidden;
      white-space: normal;
      max-width: 100%;
      border: 1px solid var(--glass-border);
      border-radius: 20px;
      padding: 14px;
      background: transparent;
      box-shadow: none;
    }
    body[data-color-scheme="light"] .artifact {
      background: transparent;
      box-shadow: none;
    }
    .artifact-normal { border-radius: 20px; }
    .artifact-compact {
      margin: 8px 0;
      padding: 12px;
      border-radius: 18px;
    }
    .artifact-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 0 2px 12px;
      font-size: 12px;
      color: var(--text-secondary);
    }
    .artifact-head-main {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }
    .artifact-label {
      font-weight: 700;
      letter-spacing: 0;
      color: var(--text-primary);
      font-size: 11px;
    }
    .artifact-hint {
      font-size: 11px;
      color: var(--text-tertiary);
    }
    .artifact-copy-btn {
      width: 24px;
      height: 24px;
      padding: 0;
      border: 1px solid var(--glass-border);
      border-radius: 8px;
      background: var(--glass-bg);
      color: var(--text-tertiary);
      display: grid;
      place-items: center;
      cursor: pointer;
      font-size: 12px;
      line-height: 1;
      transition: border-color var(--duration) var(--ease-out), color var(--duration) var(--ease-out), background var(--duration) var(--ease-out);
    }
    .artifact-copy-btn:hover {
      border-color: var(--glass-border-hover);
      color: var(--text-primary);
      background: var(--glass-bg-hover);
    }
    .artifact-copy-btn.copied {
      color: #10b981;
      border-color: rgba(16,185,129,0.3);
      background: rgba(16,185,129,0.1);
    }
    .artifact-shell {
      border: 1px solid rgba(255,255,255,0.05);
      border-radius: 16px;
      background: transparent;
      box-shadow: none;
      padding: 6px;
      overflow: auto;
    }
    body[data-color-scheme="light"] .artifact-shell {
      background: transparent;
      border-color: rgba(0,0,0,0.06);
      box-shadow: none;
    }
    .artifact-body {
      margin: 0;
      padding: 12px 14px;
      border: 0;
      border-radius: 0;
      background: transparent;
      overflow-x: auto;
      overflow-y: auto;
      white-space: pre;
      word-break: normal;
      overflow-wrap: normal;
      font-family: var(--font-mono);
      font-size: 13px;
      line-height: 1.55;
      max-height: 440px;
    }
    .artifact-body code {
      display: block;
      padding: 0;
      background: transparent;
      border: 0;
      white-space: inherit;
      font: inherit;
    }
    .artifact-shell,
    .artifact-body,
    .artifact-body code,
    .code-panel-body {
      background-color: transparent !important;
      background-image: none !important;
      box-shadow: none !important;
    }
    .artifact-normal .artifact-body {
      max-height: 460px;
    }
    .artifact-compact .artifact-head {
      font-size: 11px;
      padding-bottom: 10px;
    }
    .artifact-compact .artifact-label,
    .artifact-compact .artifact-hint {
      font-size: 10px;
    }
    .artifact-compact .artifact-shell {
      border-radius: 14px;
      padding: 4px;
    }
    .artifact-compact .artifact-body {
      padding: 8px 10px;
      font-size: 12px;
      max-height: 320px;
    }
    .artifact-label {
      color: var(--text-primary);
    }
    .code-panel {
      margin: 10px 0;
      overflow: hidden;
      white-space: normal;
      max-width: 100%;
      border: 1px solid var(--glass-border);
      border-radius: 20px;
      padding: 14px;
      background: transparent;
      box-shadow: none;
    }
    body[data-color-scheme="light"] .code-panel {
      background: transparent;
      box-shadow: none;
    }
    .code-panel-normal { border-radius: 20px; }
    .code-panel-compact {
      margin: 8px 0;
      padding: 12px;
      border-radius: 18px;
    }
    .code-panel-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 0 2px 12px;
      font-size: 12px;
      color: var(--text-secondary);
    }
    .code-panel-head-main {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }
    .code-panel-label {
      font-weight: 700;
      letter-spacing: 0;
      color: var(--text-primary);
      font-size: 11px;
    }
    .code-panel-hint {
      font-size: 11px;
      color: var(--text-tertiary);
    }
    .code-panel-copy {
      width: 24px;
      height: 24px;
      padding: 0;
      border: 1px solid var(--glass-border);
      border-radius: 8px;
      background: var(--glass-bg);
      color: var(--text-tertiary);
      display: grid;
      place-items: center;
      cursor: pointer;
      font-size: 12px;
      line-height: 1;
      transition: border-color var(--duration) var(--ease-out), color var(--duration) var(--ease-out), background var(--duration) var(--ease-out);
    }
    .code-panel-copy:hover {
      border-color: var(--glass-border-hover);
      color: var(--text-primary);
      background: var(--glass-bg-hover);
    }
    .code-panel-copy.copied {
      color: #10b981;
      border-color: rgba(16,185,129,0.3);
      background: rgba(16,185,129,0.1);
    }
    .code-panel-body,
    .bubble .code-panel-body {
      margin: 0;
      padding: 12px 14px;
      border: 1px solid var(--glass-border);
      border-radius: 16px;
      background: transparent;
      box-shadow: none;
      overflow-x: auto;
      overflow-y: auto;
      white-space: pre;
      word-break: normal;
      overflow-wrap: normal;
      font-family: var(--font-mono);
      font-size: 13px;
      line-height: 1.55;
      max-height: 440px;
    }
    body[data-color-scheme="light"] .code-panel-body,
    body[data-color-scheme="light"] .bubble .code-panel-body {
      background: transparent;
      border-color: var(--glass-border);
      box-shadow: none;
    }
    .code-panel-normal .code-panel-body {
      max-height: 460px;
    }
    .code-panel-compact .code-panel-head {
      font-size: 11px;
      padding-bottom: 10px;
    }
    .code-panel-compact .code-panel-label,
    .code-panel-compact .code-panel-hint {
      font-size: 10px;
    }
    .code-panel-compact .code-panel-body {
      padding: 10px 12px;
      font-size: 12px;
      max-height: 320px;
    }
    .md-table-wrap {
      overflow-x: auto; margin: 0.5em 0;
    }
    .markdown-body .katex-display {
      margin: 0.6em 0; overflow-x: auto; overflow-y: hidden;
      padding: 4px 0;
    }
    .bubble-wrap {
      display: flex; flex-direction: column; gap: 3px;
      min-width: 0; max-width: 100%; overflow: hidden;
    }
    .msg.me .bubble-wrap { align-items: flex-end; }
    .copy-msg {
      height: 22px; padding: 0 8px; border-radius: 6px;
      border: 1px solid var(--glass-border);
      background: var(--glass-bg);
      color: var(--text-tertiary); cursor: pointer;
      font-size: 11px; display: grid; place-items: center;
      opacity: 0.4; transition: opacity 0.15s var(--ease-out);
      font-family: var(--font-sans);
    }
    .copy-msg:hover {
      opacity: 1;
      border-color: var(--glass-border-hover);
      color: var(--text-primary);
    }
    .copy-msg.copied { opacity: 1; color: var(--success); }

    .msg.me .bubble {
      background: rgba(255,255,255,0.88);
      border-color: rgba(255,255,255,0.18);
      color: #000000;
      box-shadow: none;
    }

    .msg.me .msg-avatar { box-shadow: none; }

    body[data-color-scheme="light"] .msg.me .bubble {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      border-color: var(--accent-glow);
      color: #ffffff;
      box-shadow: none;
    }

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

    .sys-msg { text-align: center; color: var(--text-secondary); font-size: 12px; padding: 6px; font-style: italic; white-space: pre-wrap; }
    .sys-error { color: var(--danger); font-size: 12px; padding: 6px; }
    .sys-warn { color: var(--warning); font-size: 12px; padding: 6px; }

    /* ── 消息底部：统计条 + 复制按钮 ── */
    .msg-footer {
      display: flex; align-items: center; justify-content: space-between;
      padding: 4px 0 0;
    }
    .live-stats {
      display: flex; align-items: center; gap: 6px;
      font-size: 11px;
    }
    .live-stats .ls-item {
      display: flex; align-items: center; gap: 3px;
      white-space: nowrap; font-size: 11px;
      padding: 3px 7px;
      border-radius: var(--r-full);
      background: rgba(255,255,255,0.025);
      border: 1px solid var(--glass-border);
    }
    .live-stats .ls-label {
      color: var(--text-tertiary); font-size: 10px;
    }
    .live-stats .ls-val {
      font-weight: 600; font-family: var(--font-mono);
      color: var(--text-secondary); font-size: 11px;
    }

    /* Thinking block */
    .think-block {
      background: rgba(255,255,255,0.02);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 12px; margin-top: 6px;
      overflow: hidden;
      transition: border-color var(--duration) var(--ease-out);
    }
    .think-block.open { border-color: rgba(255,255,255,0.16); }
    .think-header {
      display: flex; gap: 8px; align-items: center;
      padding: 8px 12px; font-size: 12px; cursor: pointer; user-select: none;
      color: var(--text-secondary);
      transition: background var(--duration) var(--ease-out);
    }
    .think-header:hover { background: rgba(255,255,255,0.02); }
    .think-body {
      display: none;
      border-top: 1px solid rgba(255,255,255,0.06);
      padding: 9px 12px;
      font: 11px/1.6 var(--font-mono);
      color: var(--text-secondary);
      white-space: pre-wrap;
      max-height: 200px; overflow-y: auto;
    }
    .think-block.open .think-body { display: block; }

    /* Tool calls */
    .tool-call {
      background: rgba(255,255,255,0.02);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 14px; margin-top: 6px;
      overflow: hidden;
      transition: border-color var(--duration) var(--ease-out);
      overflow-x: auto;
    }

    .tool-call::-webkit-scrollbar { height: 4px; }
    .tool-call::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

    .tool-call.open { border-color: rgba(255,255,255,0.16); }
    body[data-color-scheme="light"] .tool-call.open { border-color: rgba(0,0,0,0.14); }

    .tc-header {
      display: flex; gap: 8px; align-items: center;
      padding: 8px 12px; font-size: 12px;
      cursor: pointer; user-select: none;
      transition: background var(--duration) var(--ease-out);
    }

    .tc-header:hover { background: rgba(255,255,255,0.02); }

    .tc-name {
      color: var(--text-primary);
      font-family: var(--font-mono); font-weight: 700;
    }

    .tc-status { font-size: 11px; font-weight: 700; }
    .tc-status.ok { color: var(--success); }
    .tc-status.fail { color: var(--danger); }

    .tc-param {
      color: var(--text-secondary); flex: 1;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      font-family: var(--font-mono); font-size: 11px;
    }

    .tc-time { color: var(--text-tertiary); font-size: 11px; }

    .tc-detail {
      display: none;
      border-top: 1px solid rgba(255,255,255,0.06);
      padding: 9px 12px;
      font: 11px/1.6 var(--font-mono);
      color: var(--text-secondary);
      white-space: pre-wrap;
      max-height: 200px; overflow-y: auto;
    }

    .tool-call.open .tc-detail { display: block; }

    .tc-section-label {
      font-size: 10px; color: var(--text-tertiary);
      text-transform: uppercase; letter-spacing: 0.05em;
      margin: 8px 0 4px;
    }
    .tc-section-label:first-child { margin-top: 0; }

    .tc-loading {
      font-size: 11px; color: var(--text-secondary); padding: 6px 0;
    }

    .tc-result-rendered {
      margin-top: 6px;
    }

    .tc-result-rendered > .artifact,
    .tc-result-rendered > .code-panel,
    .tc-result-rendered > .plain-result {
      margin: 0;
    }

    .plain-result {
      margin: 0;
      padding: 14px 16px;
      border: 1px solid var(--glass-border);
      border-radius: 16px;
      background: rgba(255,255,255,0.035);
      white-space: pre-wrap;
      word-break: break-word;
      overflow-wrap: anywhere;
      font: 12px/1.55 var(--font-mono);
      color: var(--text-primary);
      max-height: 300px;
      overflow-y: auto;
    }

    body[data-color-scheme="light"] .plain-result {
      background: rgba(255,255,255,0.82);
      border-color: rgba(0,0,0,0.06);
    }

    .plain-result-compact {
      padding: 12px 14px;
      font-size: 12px;
      line-height: 1.5;
    }

    .tc-copy-btn {
      margin-top: 6px; padding: 3px 10px;
      border: 1px solid var(--glass-border); border-radius: 8px;
      background: transparent; color: var(--text-secondary);
      cursor: pointer; font: inherit; font-size: 11px;
      transition: border-color var(--duration) var(--ease-out);
    }
    .tc-copy-btn:hover { border-color: var(--glass-border-hover); color: var(--text-primary); }

    .assistant-image-rail {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 8px;
      max-width: 100%;
    }

    .assistant-image-bubble {
      border: 1px solid var(--glass-border);
      border-radius: 18px;
      background: rgba(255,255,255,0.035);
      box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.04);
      overflow: hidden;
      max-width: 100%;
      padding: 12px;
    }
    body[data-color-scheme="light"] .assistant-image-bubble {
      background: rgba(255,255,255,0.84);
      box-shadow: 0 10px 22px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.82);
    }

    .assistant-image-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 10px;
    }

    .assistant-image-title {
      min-width: 0;
      font-size: 13px;
      font-weight: 600;
      line-height: 1.35;
      word-break: break-word;
      color: var(--text-primary);
    }

    .assistant-image-meta {
      margin-top: 3px;
      font-size: 12px;
      line-height: 1.45;
      color: var(--text-secondary);
      word-break: break-word;
    }

    .assistant-image-link {
      display: block;
      border-radius: 14px;
      overflow: hidden;
      border: 1px solid var(--glass-border);
      background: rgba(148,163,184,0.10);
      text-decoration: none;
    }

    .assistant-image-preview {
      display: block;
      width: 100%;
      max-height: 360px;
      object-fit: contain;
      background: transparent;
    }

    .assistant-image-placeholder {
      min-height: 160px;
      display: grid;
      place-items: center;
      padding: 16px;
      color: var(--text-secondary);
      font-size: 12px;
      text-align: center;
    }

    .assistant-image-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .assistant-image-actions a,
    .assistant-image-actions button {
      border: 1px solid var(--glass-border);
      border-radius: var(--r-full);
      background: var(--glass-bg);
      color: var(--text-primary);
      text-decoration: none;
      cursor: pointer;
      font: inherit;
      font-size: 12px;
      line-height: 1.2;
      padding: 4px 10px;
      transition: border-color var(--duration) var(--ease-out), background var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
      white-space: nowrap;
    }

    .assistant-image-actions a:hover,
    .assistant-image-actions button:hover {
      border-color: var(--glass-border-hover);
      background: var(--glass-bg-hover);
    }

    .result-artifact-list {
      display: grid;
      gap: 10px;
      margin-top: 10px;
    }

    .result-card {
      border: 1px solid var(--glass-border);
      border-radius: var(--r-sm);
      background: rgba(255,255,255,0.03);
      box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.04);
      overflow: hidden;
      padding: 12px;
      max-width: 100%;
    }

    .result-card-file {
      display: flex;
      gap: 12px;
      align-items: flex-start;
    }

    .result-card-icon {
      width: 36px;
      height: 36px;
      border-radius: 10px;
      display: grid;
      place-items: center;
      background: rgba(148,163,184,0.14);
      flex-shrink: 0;
      font-size: 16px;
    }

    .result-card-main {
      min-width: 0;
      flex: 1;
    }

    .result-card-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
    }

    .result-card-title {
      font-size: 13px;
      font-weight: 600;
      line-height: 1.35;
      word-break: break-word;
      color: var(--text-primary);
    }

    .result-card-meta {
      margin-top: 3px;
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.45;
      word-break: break-word;
    }

    .result-card-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }

    .result-card-actions a,
    .result-card-actions button {
      border: 1px solid var(--glass-border);
      border-radius: var(--r-full);
      background: var(--glass-bg);
      color: var(--text-primary);
      text-decoration: none;
      cursor: pointer;
      font: inherit;
      font-size: 12px;
      line-height: 1.2;
      padding: 4px 10px;
      transition: border-color var(--duration) var(--ease-out), background var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
      white-space: nowrap;
    }

    .result-card-actions a:hover,
    .result-card-actions button:hover {
      border-color: var(--glass-border-hover);
      background: var(--glass-bg-hover);
    }

    .result-image-link {
      display: block;
      margin-top: 10px;
      border: 1px solid var(--glass-border);
      border-radius: var(--r-sm);
      overflow: hidden;
      background-color: rgba(148,163,184,0.10);
      background-image:
        linear-gradient(45deg, rgba(255,255,255,0.08) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.08) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.08) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.08) 75%);
      background-size: 16px 16px;
    }

    .result-image-preview {
      display: block;
      width: 100%;
      max-height: 360px;
      object-fit: contain;
      background: transparent;
    }

    .result-image-placeholder {
      min-height: 160px;
      display: grid;
      place-items: center;
      padding: 16px;
      color: var(--text-secondary);
      font-size: 12px;
      text-align: center;
    }

    .raw-result-details {
      margin-top: 10px;
      border: 1px solid var(--glass-border);
      border-radius: var(--r-sm);
      background: rgba(255,255,255,0.02);
      overflow: hidden;
    }

    .raw-result-details summary {
      list-style: none;
      display: flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      padding: 8px 12px;
      font-size: 12px;
      color: var(--text-secondary);
    }

    .raw-result-details summary::-webkit-details-marker {
      display: none;
    }

    .raw-result-details summary::before {
      content: '▸';
      font-size: 10px;
      color: var(--text-tertiary);
    }

    .raw-result-details[open] summary::before {
      content: '▾';
    }

    .raw-result-details > .tc-result-rendered {
      margin: 0;
      padding: 0 16px 16px;
    }

    /* Composer */
    .composer {
      padding: 14px 18px;
      border-top: 1px solid var(--glass-border);
      box-shadow: 0 -16px 48px rgba(0,0,0,0.14);
    }

    body[data-color-scheme="light"] .composer { box-shadow: 0 -16px 48px rgba(0,0,0,0.05); }

    .quick { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }

    .context-usage-bar {
      margin-left: auto;
      height: 34px;
      min-width: 260px;
      padding: 0 16px;
      display: inline-flex;
      align-items: center;
      justify-content: space-between;
      gap: 18px;
      border-radius: 999px;
      border: 1px solid var(--glass-border);
      background: var(--glass-bg);
      box-shadow: 0 6px 18px rgba(0,0,0,0.04), inset 0 1px 0 var(--glass-shine);
      color: var(--text-secondary);
      font-size: 13px;
      font-weight: 600;
      line-height: 1;
      white-space: nowrap;
      user-select: none;
      flex-shrink: 0;
    }
    .context-usage-text {
      min-width: 96px;
      color: var(--text-secondary);
      font-size: 13px;
      font-weight: 600;
      letter-spacing: 0.01em;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }
    .context-usage-separator {
      color: var(--text-tertiary);
      font-weight: 500;
    }
    .context-usage-track {
      width: 96px;
      height: 8px;
      position: relative;
      overflow: hidden;
      border-radius: 999px;
      background: var(--glass-border);
    }
    .context-usage-fill {
      height: 100%;
      border-radius: inherit;
      background: var(--text-secondary);
      transition: width 0.25s ease;
    }
    .context-usage-percent {
      min-width: 32px;
      text-align: right;
      color: var(--text-tertiary);
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }

    .chip {
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.03);
      color: var(--text-secondary);
      border-radius: var(--r-full);
      padding: 6px 11px; font-size: 12px;
      cursor: pointer; font-family: var(--font-sans);
      transition: all var(--duration) var(--ease-out);
    }

    .chip:hover {
      color: var(--text-primary);
      border-color: var(--glass-border-hover);
      background: rgba(255,255,255,0.04);
    }

    body[data-color-scheme="light"] .chip:hover { background: rgba(0,0,0,0.03); }

    .chip:focus-visible, .btn:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    .preview-banner {
      display: flex; align-items: center; gap: 10px;
      padding: 10px 14px; margin-bottom: 10px;
      background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border);
      border-radius: 12px; font-size: 13px; color: var(--text-secondary);
    }
    .preview-banner .btn { white-space: nowrap; }

    .input-row {
      display: grid; grid-template-columns: auto 1fr auto;
      gap: 8px; padding: 7px;
      border-radius: 18px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--glass-border);
      align-items: center;
      transition: border-color var(--duration) var(--ease-out);
    }

    .input-row:focus-within {
      border-color: rgba(255,255,255,0.25);
      box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
    }

    body[data-color-scheme="light"] .input-row:focus-within {
      border-color: rgba(0,0,0,0.20);
      box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
    }

    .input-row input, .input-row textarea {
      border: 0; background: transparent;
      outline: 0; padding: 0 8px;
      font-size: 14px; color: var(--text-primary);
    }

    .input-row input::placeholder, .input-row textarea::placeholder { color: var(--text-tertiary); }
    .input-row input:disabled, .input-row textarea:disabled { opacity: 0.4; }

    .attach-chip {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 5px 10px; border-radius: var(--r-full);
      background: var(--glass-bg);
      border: 1px solid var(--glass-border);
      font-size: 12px; color: var(--text-primary);
      transition: all var(--duration) var(--ease-out);
    }
    .attach-chip:hover { border-color: var(--glass-border-hover); }
    .attach-chip .remove-file {
      cursor: pointer; font-weight: 700; color: var(--text-secondary);
      font-size: 14px; margin-left: 2px;
    }
    .attach-chip .remove-file:hover { color: var(--danger); }

    .upload-btn {
      border: 0; border-radius: 11px; padding: 8px 12px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--glass-border);
      color: var(--text-secondary);
      cursor: pointer; font-size: 15px;
      transition: all var(--duration) var(--ease-out);
    }

    .upload-btn:hover {
      color: var(--text-primary);
      border-color: var(--glass-border-hover);
    }

    .send-btn {
      border: 0; border-radius: 11px;
      padding: 9px 18px;
      background: #ffffff;
      color: #000000; font-weight: 800;
      cursor: pointer; font-size: 13px; font-family: var(--font-sans);
      box-shadow: 0 8px 22px rgba(255,255,255,0.08);
      transition: all var(--duration) var(--ease-out);
    }

    body[data-color-scheme="light"] .send-btn {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: #ffffff;
      box-shadow: 0 10px 28px var(--accent-glow);
    }

    .send-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
    .send-btn:active { transform: translateY(0); }
    .send-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }

    .send-btn.stop {
      background: #ff3b30;
      color: #ffffff;
      box-shadow: 0 8px 22px rgba(255,59,48,0.35);
    }

    .send-btn.stop:hover { filter: brightness(1.1); }

    body[data-color-scheme="light"] .send-btn.stop {
      background: #ff3b30;
      color: #ffffff;
      box-shadow: 0 8px 22px rgba(255,59,48,0.25);
    }

    /* ========== Right Panel ========== */
    .right {
      display: grid; grid-template-rows: auto 1fr;
      min-width: 0; overflow: hidden;
      box-shadow: 0 0 40px rgba(255,255,255,0.08), 0 0 80px rgba(255,255,255,0.04), 0 0 120px rgba(255,255,255,0.02);
    }
    body[data-color-scheme="light"] .right {
      box-shadow: 0 0 40px rgba(0,0,0,0.08), 0 0 80px rgba(0,0,0,0.04), 0 0 120px rgba(0,0,0,0.02);
    }

    .panel-head { padding: 16px 18px; border-bottom: 1px solid var(--glass-border); }

    .panel-head h3 {
      font-size: 14px; font-weight: 700;
      display: flex; align-items: center; gap: 6px;
    }

    .tabs {
      display: grid; grid-template-columns: repeat(4, 1fr);
      gap: 6px; margin-top: 12px;
    }

    .tab {
      border: 1px solid var(--glass-border);
      border-radius: var(--r-sm);
      padding: 7px 4px; font-size: 12px; text-align: center;
      cursor: pointer; font-family: var(--font-sans);
      background: rgba(255,255,255,0.02);
      color: var(--text-secondary);
      transition: all var(--duration) var(--ease-out);
    }

    .tab:hover {
      color: var(--text-primary);
      border-color: var(--glass-border-hover);
    }

    .tab.active {
      background: #ffffff;
      color: #000000; border-color: transparent;
      font-weight: 800;
    }

    body[data-color-scheme="light"] .tab.active {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: #ffffff;
      box-shadow: 0 8px 22px var(--accent-glow);
    }

    .panel-body { padding: 16px; overflow-y: auto; overflow-x: hidden; min-width: 0; }

    .pane { display: none; min-width: 0; max-width: 100%; }
    .pane.active { display: block; }

    /* Overview: prompt tabs */
    .prompt-tabs {
      display: grid; grid-template-columns: repeat(4, 1fr);
      gap: 6px; margin-bottom: 12px;
    }

    .prompt-tab {
      border: 1px solid var(--glass-border);
      border-radius: 10px;
      background: rgba(255,255,255,0.02);
      color: var(--text-secondary);
      font-size: 11px; font-family: var(--font-sans);
      padding: 7px 5px; cursor: pointer; text-align: center;
      transition: all var(--duration) var(--ease-out);
    }

    .prompt-tab:hover {
      color: var(--text-primary);
      border-color: var(--glass-border-hover);
    }

    .prompt-tab.active {
      background: #ffffff;
      color: #000000; font-weight: 800;
    }

    body[data-color-scheme="light"] .prompt-tab.active {
      background: linear-gradient(135deg, var(--accent), var(--accent-2));
      color: #ffffff;
      box-shadow: 0 8px 22px var(--accent-glow);
    }

    .mono {
      font: 11px/1.7 var(--font-mono);
      background: rgba(0,0,0,0.15);
      border: 1px solid var(--glass-border);
      border-radius: 15px; padding: 12px;
      color: var(--text-secondary);
      white-space: pre-wrap;
    }

    body[data-color-scheme="light"] .mono { background: rgba(0,0,0,0.03); }

    /* Debug */
    .debug-grid { display: grid; gap: 10px; }

    .toggle-card {
      display: flex; justify-content: space-between; align-items: center;
      padding: 12px 13px; border-radius: 14px;
      background: rgba(255,255,255,0.025);
      border: 1px solid var(--glass-border);
      transition: all var(--duration) var(--ease-out);
      box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,0.03);
    }

    .toggle-card:hover {
      border-color: var(--glass-border-hover);
      transform: translateY(-1px);
    }

    .toggle-card b { font-size: 13px; }
    .toggle-card p { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

    .switch {
      width: 46px; height: 25px; flex-shrink: 0;
      border-radius: var(--r-full);
      background: rgba(255,255,255,0.1);
      border: 1px solid var(--glass-border);
      position: relative; cursor: pointer;
      transition: all var(--duration) var(--ease-out);
    }

    .switch::after {
      content: ""; position: absolute;
      width: 19px; height: 19px; border-radius: 50%;
      top: 2px; left: 2px;
      background: var(--text-secondary);
      transition: all var(--duration) var(--ease-out);
    }

    .switch.on {
      background: rgba(255,255,255,0.15);
      border-color: rgba(255,255,255,0.25);
    }

    body[data-color-scheme="light"] .switch.on {
      background: rgba(0,0,0,0.08);
      border-color: rgba(0,0,0,0.20);
    }

    .switch.on::after {
      left: 23px;
      background: #ffffff;
    }

    body[data-color-scheme="light"] .switch.on::after { background: var(--accent); }

    /* Capability config */
    .capability-mode-row { display: flex; gap: var(--s-2); }
    .capability-tags { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: 6px; }
    .capability-tag {
      padding: 3px 10px; border-radius: var(--r-full); font-size: 12px;
      background: var(--glass-bg); border: 1px solid var(--glass-border);
      color: var(--text-tertiary); transition: .2s;
    }
    .capability-tag.on {
      background: var(--accent); color: #fff; border-color: var(--accent);
    }
    .capability-row {
      display: flex; align-items: center; justify-content: space-between;
      padding: 7px 0; cursor: pointer; border-bottom: 1px solid var(--glass-border);
    }
    .capability-row:last-child { border-bottom: none; }
    .capability-row span { font-size: 13px; }

    /* Form rows */
    .form-row { display: grid; gap: 5px; }

    .form-row label {
      font-size: 11px; font-weight: 600;
      color: var(--text-secondary);
    }

    .form-row input, .form-row textarea {
      width: 100%; padding: 9px 11px;
      border-radius: 10px;
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.03);
      color: var(--text-primary);
      font-family: var(--font-sans); font-size: 13px;
    }

    .key-shell { display: flex; gap: 7px; }
    .key-shell input { flex: 1; }
    .key-hint { font-size: 11px; color: var(--text-secondary); margin-top: 6px; }

    /* Lists */
    .list { display: grid; gap: 8px; min-width: 0; max-width: 100%; overflow-x: hidden; }

    .item {
      padding: 12px 13px; border-radius: 15px;
      background: rgba(255,255,255,0.025);
      border: 1px solid var(--glass-border);
      transition: all var(--duration) var(--ease-out);
      min-width: 0; max-width: 100%;
    }

    .item:hover {
      border-color: var(--glass-border-hover);
      transform: translateY(-1px);
      background: var(--glass-bg-hover);
    }

    .item-top {
      display: flex; justify-content: space-between; align-items: center;
      gap: 8px; font-size: 13px; min-width: 0;
    }

    .item p { font-size: 11px; color: var(--text-secondary); line-height: 1.45; margin-top: 4px; }

    .pill {
      padding: 3px 8px; border-radius: var(--r-full);
      background: rgba(255,255,255,0.06); flex-shrink: 0; white-space: nowrap;
      color: var(--text-secondary); font-size: 10px; font-weight: 600;
      flex-shrink: 0;
    }

    body[data-color-scheme="light"] .pill { background: rgba(0,0,0,0.05); }

    /* Logs */
    .log-row {
      font: 11px/1.55 var(--font-mono);
      border-left: 3px solid var(--text-secondary);
      padding: 8px 10px;
      background: rgba(255,255,255,0.02);
      border-radius: 10px;
      color: var(--text-secondary);
      transition: all var(--duration) var(--ease-out);
    }

    .log-row:hover {
      background: var(--glass-bg-hover);
      transform: translateX(2px);
    }

    .log-row.clickable { cursor: pointer; }
    .log-row.clickable:hover { border-left-color: var(--accent); }

    .log-loading { font-size: 10px; color: var(--text-tertiary); margin-top: 4px; }

    .log-result {
      margin-top: 6px; max-height: 200px; overflow: auto;
      font: 10px/1.5 var(--font-mono);
      color: var(--text-primary);
      background: rgba(0,0,0,0.15); border-radius: 8px;
      padding: 6px 8px;
      white-space: pre-wrap; word-break: break-all;
    }
    body[data-color-scheme="light"] .log-result { background: rgba(0,0,0,0.04); }

    .log-row.fail { border-left-color: var(--danger); }

    /* Files */
    .file-toolbar {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 6px; margin-bottom: 10px;
    }

    .file-actions { display: flex; gap: 6px; margin-top: 6px; }
    .file-row {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: flex-start;
      gap: 8px;
      min-width: 0;
      max-width: 100%;
      overflow: hidden;
    }
    .file-check-label { display: flex; align-items: center; padding-top: 2px; flex-shrink: 0; }
    .file-main { min-width: 0; max-width: 100%; overflow: hidden; }
    .file-name,
    .file-path {
      display: block;
      width: 100%;
      min-width: 0;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .file-name { font-size: 13px; font-weight: 600; }
    .file-path { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
    .file-check { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

    /* Plan bubble */
    .plan-bubble {
      margin: 0 0 10px 0;
      padding: 14px 16px;
      border-radius: 16px;
      background: rgba(255,255,255,0.04);
      border: 1px solid var(--glass-border);
      animation: planBubbleIn 0.3s var(--ease-out);
      max-height: 320px; overflow-y: auto;
    }
    @keyframes planBubbleIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
    .plan-bubble-header {
      display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
    }
    .plan-bubble-icon { font-size: 16px; }
    .plan-bubble-title { font-weight: 700; font-size: 14px; color: var(--text-primary); }
    .plan-bubble-progress { font-size: 11px; color: var(--text-secondary); margin-left: auto; }
    .plan-bubble-badge {
      font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
      background: #4caf50; color: #fff; margin-left: auto;
    }
    .plan-bubble-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 10px 0; }
    .plan-bubble-steps { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
    .plan-step-row {
      display: grid; grid-template-columns: 18px 1fr auto;
      align-items: center; gap: 6px; font-size: 12px;
      padding: 4px 6px; border-radius: 8px;
      color: var(--text-secondary);
    }
    .plan-step-row.step-in_progress { background: rgba(255,255,255,0.04); color: var(--text-primary); }
    .plan-step-row.step-completed { color: var(--text-primary); }
    .plan-step-row.step-failed { color: #f44336; background: rgba(244,67,54,0.06); }
    .plan-step-icon { font-size: 11px; flex-shrink: 0; width: 18px; text-align: center; }
    .plan-step-result { font-size: 10px; color: var(--text-tertiary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .plan-step-error { font-size: 10px; color: #f44336; }
    .plan-bubble-actions {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
      padding-top: 8px; border-top: 1px solid var(--glass-border);
    }
    .plan-bubble-actions .btn { font-size: 11px; padding: 6px 10px; }
    .plan-bubble.completed { border-color: rgba(76,175,80,0.3); }

    /* Context menu */
    .ctx-menu {
      position: fixed; display: none; z-index: 99;
      min-width: 140px; padding: 6px;
      border-radius: var(--r-sm);
      background: var(--bg-soft);
      border: 1px solid var(--glass-border);
      box-shadow: 0 16px 48px rgba(0,0,0,0.4);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
    }

    .ctx-menu button {
      width: 100%; text-align: left;
      border: 0; background: transparent;
      color: var(--text-primary);
      padding: 8px 10px; border-radius: var(--r-xs);
      cursor: pointer; font-size: 12px; font-family: var(--font-sans);
      transition: background var(--duration) var(--ease-out);
    }

    .ctx-menu button:hover { background: rgba(255,255,255,0.06); }
    .ctx-menu .danger { color: var(--danger); }

    /* Toast */
    .toast {
      position: fixed; right: 24px; bottom: 24px; z-index: 120;
      padding: 12px 18px; border-radius: 14px;
      background: var(--bg-soft);
      border: 1px solid var(--glass-border);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      box-shadow: var(--shadow-panel);
      color: var(--text-primary); font-size: 13px;
      opacity: 0; transform: translateY(12px);
      transition: all var(--duration) var(--ease-out);
      pointer-events: none;
    }

    .toast.show { opacity: 1; transform: translateY(0); }

    /* Scrollbar */
    ::-webkit-scrollbar { width: 5px; height: 5px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 99px; }
    ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

    /* KaTeX */
    .katex { color: var(--text-primary); font-size: 1.05em; }
    .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
    .katex-display > .katex { font-size: 1.1em; }
    .katex-error { color: var(--danger); }

    /* Rendered Markdown inside bubbles */
    .bubble.markdown > :first-child { margin-top: 0; }
    .bubble.markdown > :last-child { margin-bottom: 0; }
    .bubble.markdown p { margin: 0 0 8px; }
    .bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
      margin: 10px 0 6px; line-height: 1.3;
    }
    .bubble h1 { font-size: 1.4em; }
    .bubble h2 { font-size: 1.25em; }
    .bubble h3 { font-size: 1.1em; }
    .bubble blockquote {
      margin: 8px 0; padding: 6px 12px;
      border-left: 3px solid var(--glass-border);
      color: var(--text-secondary);
    }
    .bubble .md-table-wrap {
      max-width: 100%;
      overflow-x: auto;
      margin: 8px 0;
    }
    .bubble table {
      border-collapse: collapse;
      margin: 8px 0;
      width: 100%;
    }
    .bubble .md-table-wrap table {
      width: max-content;
      min-width: 100%;
      margin: 0;
    }
    .bubble th, .bubble td {
      border: 1px solid var(--glass-border);
      padding: 6px 10px; text-align: left; font-size: 0.93em;
      white-space: normal;
    }
    .bubble th { background: rgba(255,255,255,0.04); font-weight: 700; }
    .bubble ul, .bubble ol { padding-left: 22px; margin: 6px 0; }
    .bubble li { margin: 2px 0; }
    .bubble li > p { margin: 2px 0; }
    .bubble hr {
      border: 0; border-top: 1px solid var(--glass-border);
      margin: 12px 0;
    }
    .bubble pre {
      margin: 8px 0;
      padding: 0;
      max-width: 100%;
      overflow-x: auto;
      white-space: pre;
      overflow-wrap: normal;
      word-break: normal;
      border: 0;
      border-radius: 0;
      background: transparent;
      font: 12px/1.65 var(--font-mono);
    }
    body[data-color-scheme="light"] .bubble pre { background: transparent; }
    .bubble pre code {
      display: block;
      padding: 0;
      border: 0;
      background: transparent;
      white-space: pre;
      overflow-wrap: normal;
      word-break: normal;
      color: inherit;
    }
    .bubble :not(pre) > code {
      padding: 2px 5px;
      border-radius: 4px;
      border: 1px solid var(--glass-border);
      background: rgba(255,255,255,0.05);
      font: 0.9em var(--font-mono);
      overflow-wrap: anywhere;
    }
    body[data-color-scheme="light"] .bubble :not(pre) > code { background: rgba(0,0,0,0.04); }
    .bubble a {
      color: var(--accent);
      text-decoration: none;
      border-bottom: 1px solid color-mix(in srgb, var(--accent), transparent 55%);
    }
    .bubble a:hover { border-bottom-color: var(--accent); }
    .bubble img {
      max-width: 100%;
      height: auto;
      border-radius: var(--r-sm);
      display: block;
      margin: 8px 0;
    }
    .unsafe-link {
      color: var(--danger);
      text-decoration: line-through;
    }
    .bubble input[type=checkbox] {
      margin-right: 6px; accent-color: var(--accent);
      transform: translateY(1px);
    }
    .bubble mark {
      background: rgba(255,255,200,0.2); color: inherit;
      padding: 1px 3px; border-radius: 3px;
    }
    .bubble u { text-decoration: underline; }
    .bubble sub, .bubble sup { font-size: 0.8em; }
    .bubble dl { margin: 8px 0; }
    .bubble dt { font-weight: 700; margin-top: 6px; }
    .bubble dd { margin-left: 18px; color: var(--text-secondary); }
    .bubble details {
      margin: 8px 0; padding: 8px 12px;
      border: 1px solid var(--glass-border);
      border-radius: var(--r-sm);
      background: rgba(255,255,255,0.02);
    }
    .bubble summary { cursor: pointer; font-weight: 600; }
    .bubble kbd {
      padding: 2px 6px; font-family: var(--font-mono); font-size: 0.85em;
      border: 1px solid var(--glass-border);
      border-radius: 4px; background: rgba(255,255,255,0.04);
    }
    .bubble abbr[title] {
      text-decoration: underline dotted; cursor: help;
    }
    .bubble .katex {
      overflow-wrap: normal;
      word-break: normal;
    }
    .bubble .katex-display {
      max-width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
    }
    .bubble .katex-display > .katex {
      white-space: nowrap;
    }

    /* Selection */
    ::selection { background: rgba(255,255,255,0.15); color: var(--text-primary); }
    body[data-color-scheme="light"] ::selection { background: rgba(0,0,0,0.10); }

    /* Focus */
    :focus-visible {
      outline: 2px solid rgba(255,255,255,0.4);
      outline-offset: 2px;
    }

    body[data-color-scheme="light"] :focus-visible { outline-color: rgba(0,0,0,0.4); }

    input:focus-visible, textarea:focus-visible, select:focus-visible {
      outline: none;
      border-color: rgba(255,255,255,0.25);
    }

    body[data-color-scheme="light"] input:focus-visible,
    body[data-color-scheme="light"] textarea:focus-visible,
    body[data-color-scheme="light"] select:focus-visible { border-color: rgba(0,0,0,0.25); }

    /* Micro edge gloss */
    .card, .stat, .conv, .item, .toggle-card, .log-row {
      position: relative; overflow: hidden;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .card, body[data-color-scheme="light"] .stat,
    body[data-color-scheme="light"] .conv, body[data-color-scheme="light"] .item,
    body[data-color-scheme="light"] .toggle-card,
    body[data-color-scheme="light"] .log-row {
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
    }

    body::after{
      background:
        radial-gradient(420px 260px at 12% 0%, rgba(255,255,255,0.04), transparent 70%),
        radial-gradient(520px 300px at 90% 12%, rgba(255,255,255,0.03), transparent 72%),
        linear-gradient(180deg, transparent, rgba(0,0,0,0.10));
    }

    .glass::after {
      content: "";
      position: absolute; inset: 0; pointer-events: none; z-index: 1;
      border-radius: inherit;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.14),
        inset 0 0 0 1px rgba(255,255,255,0.06);
    }

    body[data-color-scheme="light"] .glass::after {
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 0 0 1px rgba(0,0,0,0.06);
    }

    /* Responsive */
    @media (max-width: 1160px) {
      .app { grid-template-columns: 250px 1fr; }
      .right { display: none; }
    }

    @media (max-width: 760px) {
      .app { grid-template-columns: 1fr; }
      .sidebar { display: none; }
      .chat { padding: 14px 12px; }
      .msg { max-width: 100%; }
      .bubble { font-size: 13px; border-radius: 14px; }
      .bubble pre { font-size: 11px; padding: 10px; }
      .bubble .katex-display > .katex { font-size: 1em; }
      .top { align-items: flex-start; flex-direction: column; }
      .top-actions { flex-wrap: wrap; }
    }

#root { height: 100%; }
