/* Astra · Chat 门户 原型样式（设计令牌取自 repo assets/bridge.css + review-refinements.css） */
:root {
  /* —— 底色 / 面板（仓库原值） —— */
  --bg-deep: #03060e;
  --bg-panel: rgba(8, 13, 25, 0.78);
  --bg-panel-solid: #0a1020;
  --bg-card: rgba(15, 23, 42, 0.62);
  --bg-card-hover: rgba(25, 37, 66, 0.78);
  --bg-topbar: rgba(7, 12, 23, 0.88);
  --bg-popover: #101929;
  --border-subtle: rgba(142, 176, 226, 0.16);
  --border-strong: rgba(168, 204, 250, 0.36);
  /* —— 文字（muted 用 refinements 覆盖值 #93a9c4，保证 ≥4.5:1） —— */
  --text-primary: #eef4ff;
  --text-secondary: #9bb1d1;
  --text-muted: #93a9c4;
  --text-on-gold: #ffe8ba;
  /* —— 强调 —— */
  --accent-gold: #f3be5e;
  --accent-gold-rgb: 243, 190, 94;
  --accent-cyan: #56d7eb;
  --accent-cyan-rgb: 86, 215, 235;
  --deco-purple: #8b7cf6; /* 新增：仅行星装饰，不用于信息 */
  /* —— 状态（仓库原值） —— */
  --status-running: #38d39f;
  --status-idle: #8da2c0;
  --status-blocked: #f26d6d;
  --status-done: #6ea8fe;
  --status-review: #38bdf8;
  --status-ready: #f5b942;
  /* —— 审批语义（新增，复用已有色相） —— */
  --approval-pending: #f7c877;   /* = --wait-rgb 247,200,119 */
  --approval-pending-rgb: 247, 200, 119;
  --approval-allowed: var(--status-running);
  --approval-denied: var(--status-blocked);
  --approval-expired: var(--status-idle);
  --countdown-urgent: #ff8a7a;
  --focus-ring: #9ec9ff;
  /* —— 字体 —— */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Noto Sans Mono CJK SC", monospace;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-20: 20px; --fs-24: 24px;
  /* —— 间距 4 基数 —— */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  /* —— 圆角（仓库原值 + 胶囊） —— */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-pill: 999px; --radius-bubble: 11px;
  /* —— 阴影 —— */
  --shadow-panel: 0 18px 48px rgba(0, 0, 0, 0.65);
  --shadow-popover: 0 10px 24px rgba(0, 0, 0, 0.53);
  /* —— 动效 —— */
  --dur-fast: 140ms; --dur-base: 200ms; --dur-slow: 280ms; --ease: ease;
  /* —— 尺寸 —— */
  --bar-height: 54px;
  --sidebar-w: 280px;
  --chat-max: 820px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ 星空背景 ============ */
#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.planet-deco {
  position: fixed; z-index: 0; pointer-events: none; border-radius: 50%;
  background:
    repeating-linear-gradient(-18deg, rgba(139,124,246,0.0) 0 14px, rgba(139,124,246,0.42) 14px 22px, rgba(98,84,200,0.25) 22px 34px),
    radial-gradient(circle at 35% 30%, #6d5fd6 0%, #3a2f86 55%, #160f3c 100%);
  box-shadow: inset -30px -24px 60px rgba(0,0,0,0.7), 0 0 80px rgba(139,124,246,0.18);
  opacity: 0.55;
}
.planet-deco.p1 { width: 340px; height: 340px; right: -110px; top: 120px; }
.planet-deco.p2 { width: 120px; height: 120px; left: 6%; bottom: 9%; opacity: 0.35; }
body[data-view="chat"] .planet-deco { opacity: 0.16; }

/* ============ 顶栏 ============ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--bar-height); z-index: 40;
  display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4);
  background: var(--bg-topbar);
  backdrop-filter: blur(18px) saturate(130%); -webkit-backdrop-filter: blur(18px) saturate(130%);
  border-bottom: 1px solid rgba(152, 186, 236, 0.2);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: .02em; white-space: nowrap; }
.view-switch {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 3px; border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border-subtle);
}
.view-tab {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--text-secondary);
  font-size: var(--fs-13); font-weight: 600; padding: 5px 14px; min-height: 32px; border-radius: var(--radius-pill);
  cursor: pointer; white-space: nowrap; transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
  display: inline-flex; align-items: center; gap: 6px;
}
.view-tab:hover { color: var(--text-primary); }
.view-tab[aria-selected="true"] { background: rgba(var(--accent-gold-rgb), .18); border-color: rgba(var(--accent-gold-rgb), .56); color: var(--text-on-gold); }
.view-tab .tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--approval-pending); }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: rgba(15, 23, 42, 0.62); color: var(--text-secondary);
  font-size: var(--fs-13); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-strong); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, rgba(243,190,94,.24), rgba(214,146,52,.32));
  border-color: rgba(243,190,94,.54); color: var(--text-on-gold); font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(135deg, rgba(243,190,94,.35), rgba(214,146,52,.44)); border-color: rgba(247,206,122,.8); color: #fff3d6; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: var(--fs-12); }

/* —— 全局待审批角标 —— */
.pending-badge {
  display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px 0 10px;
  border-radius: var(--radius-pill); cursor: pointer; font-size: var(--fs-13); font-weight: 600;
  color: #fff0cf; background: rgba(var(--approval-pending-rgb), .16); border: 1px solid rgba(var(--approval-pending-rgb), .62);
}
.pending-badge:hover { background: rgba(var(--approval-pending-rgb), .26); }
.pending-badge .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--approval-pending); box-shadow: 0 0 0 0 rgba(var(--approval-pending-rgb), .7); animation: pulse 1.8s ease-out infinite; }
.pending-badge .secs { font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 500; color: var(--approval-pending); }
.pending-badge.is-urgent .secs { color: var(--countdown-urgent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--approval-pending-rgb), .7);} 70% { box-shadow: 0 0 0 7px rgba(var(--approval-pending-rgb), 0);} 100% { box-shadow: 0 0 0 0 rgba(var(--approval-pending-rgb), 0);} }
.popover {
  position: fixed; top: calc(var(--bar-height) + 6px); z-index: 60; width: 420px; max-width: calc(100vw - 24px);
  background: var(--bg-popover); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover); padding: var(--sp-3);
}
.popover h2 { margin: 2px 4px 10px; font-size: var(--fs-13); color: var(--text-secondary); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.popover .pop-empty { padding: 16px 6px; color: var(--text-muted); font-size: var(--fs-13); }
.pop-item { border: 1px solid rgba(var(--approval-pending-rgb), .35); border-radius: var(--radius-md); padding: 10px 12px; background: rgba(var(--approval-pending-rgb), .05); }
.pop-item + .pop-item { margin-top: 8px; }
.pop-item .appr-line { flex-wrap: wrap; }
.pop-item .appr-text { flex-basis: calc(100% - 32px); white-space: normal; }
.pop-item .appr-actions { margin-left: auto; }
.pop-item.is-urgent .cd-fill { background: var(--countdown-urgent); }
.pop-item.is-urgent .cd-text { color: var(--countdown-urgent); }

/* ============ 主体 ============ */
.app { position: fixed; inset: var(--bar-height) 0 0 0; z-index: 1; }
.view { position: absolute; inset: 0; }
.view[hidden] { display: none; }

/* ============ Chat 门户 ============ */
.portal { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100%; }
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(8, 13, 25, 0.82); border-right: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.side-sec { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.side-sec + .side-sec { border-top: 1px solid var(--border-subtle); }
.side-sec.grow { flex: 1; min-height: 0; overflow: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 8px; }
.side-head h2 { margin: 0; font-size: var(--fs-12); font-weight: 600; color: var(--text-muted); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-list, .sess-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.bot-item {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px;
  min-height: 48px; padding: 6px 8px; border-radius: var(--radius-md); border: 1px solid transparent;
  background: transparent; color: var(--text-primary); text-align: left; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.bot-item:hover { background: var(--bg-card-hover); }
.bot-item[aria-current="true"] { background: rgba(var(--accent-gold-rgb), .10); border-color: rgba(var(--accent-gold-rgb), .42); }
.avatar { position: relative; width: 28px; height: 28px; border-radius: 50%; flex: none; box-shadow: inset -4px -4px 8px rgba(0,0,0,.45); }
.avatar .sdot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--bg-panel-solid); }
.sdot.running { background: var(--status-running); }
.sdot.idle { background: var(--status-idle); }
.sdot.blocked { background: var(--status-blocked); }
.sdot.review { background: var(--status-review); }
.sdot.running::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--status-running); opacity: .0; animation: ring 1.6s ease-out infinite; }
@keyframes ring { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.4); opacity: 0; } }
.bot-meta { min-width: 0; }
.bot-name { font-weight: 600; font-size: var(--fs-14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.bot-sub { display: block; font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-sub .st-running { color: var(--status-running); }
.bot-sub .st-blocked { color: var(--status-blocked); }
.bot-sub .st-review { color: var(--status-review); }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--accent-gold); color: #1a1205; font-size: var(--fs-11); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.mini-pending { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--radius-pill); font-size: var(--fs-11); font-weight: 600; color: #fff0cf; border: 1px solid rgba(var(--approval-pending-rgb), .6); background: rgba(var(--approval-pending-rgb), .14); }
.right-tags { display: flex; gap: 4px; align-items: center; }

.sess-item {
  width: 100%; display: flex; flex-direction: column; gap: 1px; min-height: 44px; padding: 7px 10px;
  border-radius: var(--radius-md); border: 1px solid transparent; background: transparent; color: var(--text-primary);
  text-align: left; cursor: pointer; transition: background var(--dur-fast);
}
.sess-item:hover { background: var(--bg-card-hover); }
.sess-item[aria-current="true"] { background: rgba(var(--accent-cyan-rgb), .09); border-color: rgba(var(--accent-cyan-rgb), .35); }
.sess-title { font-size: var(--fs-13); font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-snippet { display: block; font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: var(--fs-11); font-weight: 600; padding: 0 6px; border-radius: 4px; line-height: 18px; flex: none; }
.tag.cur { color: #c3f6ff; background: rgba(var(--accent-cyan-rgb), .16); }
.tag.arc { color: var(--text-secondary); background: rgba(142,176,226,.12); }
.arch-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin-top: 6px; padding: 0 6px; background: transparent; border: 0; color: var(--text-muted); font-size: var(--fs-12); font-weight: 600; cursor: pointer; border-radius: 6px; }
.arch-toggle:hover { color: var(--text-primary); }
.switch-confirm { margin: 4px 2px 6px; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: rgba(15,23,42,.9); font-size: var(--fs-12); color: var(--text-secondary); }
.switch-confirm .row { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }
.side-note { font-size: var(--fs-12); color: var(--text-muted); padding: 6px 8px; }

/* —— 中栏 —— */
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-header {
  display: flex; align-items: center; gap: var(--sp-3); height: 60px; padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border-subtle); background: rgba(7, 12, 24, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chat-header .avatar { width: 32px; height: 32px; }
.ch-title { min-width: 0; flex: 1; }
.ch-name { font-size: var(--fs-16); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ch-sub { font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capsule { font-size: var(--fs-12); font-weight: 600; padding: 1px 9px; border-radius: var(--radius-pill); border: 1px solid; line-height: 20px; display: inline-flex; gap: 5px; align-items: center; }
.capsule.idle { color: #c9d5e6; border-color: rgba(141,162,192,.5); }
.capsule.running { color: #b7f5dc; border-color: rgba(56,211,159,.55); background: rgba(56,211,159,.1); }
.capsule.review { color: #c6ecff; border-color: rgba(56,189,248,.55); }
.capsule.waiting { color: #fff0cf; border-color: rgba(var(--approval-pending-rgb), .6); background: rgba(var(--approval-pending-rgb), .12); }
.bot-sub .st-waiting { color: var(--approval-pending); }
.capsule.blocked { color: #ffd0d0; border-color: rgba(242,109,109,.6); }
.capsule .cd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chat-header .sess-btn { display: none; }
.chat-header .hdr-new { display: none; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.chat-stream { max-width: var(--chat-max); margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-4); }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 78%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; align-items: flex-start; }
.msg-meta { font-size: var(--fs-11); color: var(--text-muted); font-family: var(--font-mono); display: flex; gap: 6px; align-items: center; }
.bubble { padding: 10px 14px; border-radius: var(--radius-bubble); font-size: var(--fs-14); line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.msg.user .bubble { background: linear-gradient(135deg, rgba(243,190,94,.16), rgba(212,148,52,.18)); border: 1px solid rgba(243,190,94,.45); color: #fff3d6; border-bottom-right-radius: 3px; }
.msg.agent .bubble { background: rgba(18, 28, 50, .78); border: 1px solid rgba(154,186,232,.28); color: #f2f7ff; border-bottom-left-radius: 3px; }
.bubble code, .inline-code { font-family: var(--font-mono); font-size: .92em; padding: 1px 5px; border-radius: 4px; background: rgba(142,176,226,.14); }
.bubble .att { display: block; max-width: 240px; border-radius: 8px; margin-bottom: 6px; border: 1px solid var(--border-subtle); }
.task-chip { font-size: var(--fs-11); font-weight: 600; color: var(--text-on-gold); border: 1px solid rgba(var(--accent-gold-rgb), .5); border-radius: var(--radius-pill); padding: 0 8px; line-height: 18px; background: rgba(var(--accent-gold-rgb), .1); }
.msg.is-located .bubble { outline: 2px solid var(--accent-gold); outline-offset: 3px; animation: locate 2.4s ease-out 1; }
@keyframes locate { 0%, 30% { box-shadow: 0 0 0 6px rgba(var(--accent-gold-rgb), .35), 0 0 28px rgba(var(--accent-gold-rgb), .45);} 100% { box-shadow: 0 0 0 0 rgba(var(--accent-gold-rgb), 0);} }
.sys { align-self: center; max-width: 90%; text-align: center; font-size: var(--fs-12); color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.sys::before, .sys::after { content: ""; height: 1px; width: 40px; background: var(--border-subtle); flex: none; }
.sys.warn { color: #ffd0d0; }

/* —— 内联审批消息 —— */
.appr { align-self: stretch; max-width: 620px; border-radius: var(--radius-md); font-size: var(--fs-13); }
.appr.pending { border: 1px solid rgba(var(--approval-pending-rgb), .55); background: rgba(var(--approval-pending-rgb), .06); padding: 10px 12px 10px 14px; position: relative; overflow: hidden; }
.appr.pending::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--approval-pending); }
.appr-line { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.appr-ic { flex: none; width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: rgba(var(--approval-pending-rgb), .16); color: var(--approval-pending); }
.appr-text { flex: 1; min-width: 0; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appr-text b { font-weight: 700; }
.appr-text .once { color: var(--text-muted); font-size: var(--fs-12); margin-left: 4px; }
.appr-actions { display: flex; gap: 6px; flex: none; }
.btn-allow { background: rgba(56,211,159,.16); border-color: rgba(56,211,159,.6); color: #c9f8e6; font-weight: 600; }
.btn-allow:hover { background: rgba(56,211,159,.28); color: #fff; border-color: rgba(56,211,159,.9); }
.btn-deny:hover { border-color: rgba(242,109,109,.7); color: #ffd6d6; background: rgba(242,109,109,.12); }
.cd-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cd-track { flex: 1; height: 4px; border-radius: 4px; background: rgba(142,176,226,.16); overflow: hidden; }
.cd-fill { height: 100%; background: var(--approval-pending); border-radius: 4px; transition: width 250ms linear; }
.cd-text { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--approval-pending); min-width: 88px; text-align: right; white-space: nowrap; }
.appr.is-urgent .cd-fill { background: var(--countdown-urgent); }
.appr.is-urgent .cd-text { color: var(--countdown-urgent); }
.expand-link { appearance: none; border: 0; background: transparent; color: var(--accent-cyan); font-size: var(--fs-12); cursor: pointer; padding: 2px 4px; border-radius: 4px; white-space: nowrap; flex: none; }
.expand-link:hover { text-decoration: underline; }
.appr-detail { margin: 8px 0 2px 32px; display: grid; grid-template-columns: 64px 1fr; gap: 4px 10px; font-size: var(--fs-12); color: var(--text-secondary); }
.appr-detail dt { color: var(--text-muted); }
.appr-detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text-primary); }
.appr-detail .mono { font-family: var(--font-mono); }
.appr.folded { padding: 2px 4px; color: var(--text-muted); font-size: var(--fs-12); }
.appr.folded .appr-line { min-height: 26px; gap: 8px; }
.appr.folded .appr-text { flex: 0 1 auto; color: var(--text-secondary); font-size: var(--fs-12); }
.fold-ic { flex: none; width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #071018; }
.appr.allowed .fold-ic { background: var(--approval-allowed); }
.appr.denied .fold-ic { background: var(--approval-denied); }
.appr.expired .fold-ic { background: var(--approval-expired); }
.appr.folded .appr-detail { margin-left: 24px; }
.appr.sending .appr-text { color: var(--text-secondary); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(142,176,226,.3); border-top-color: var(--accent-cyan); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.web-ro { font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; }

/* —— 忙碌指示 —— */
.typing { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-bubble); border: 1px dashed rgba(56,211,159,.45); background: rgba(56,211,159,.06); font-size: var(--fs-13); color: #b7f5dc; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--status-running); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .3; transform: translateY(0);} 40% { opacity: 1; transform: translateY(-3px);} }
.typing .elapsed { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-muted); }

/* —— 输入区 —— */
.composer-wrap { padding: 0 var(--sp-6) var(--sp-4); background: linear-gradient(180deg, rgba(3,6,14,0) 0%, rgba(3,6,14,.85) 30%); }
.composer-inner { max-width: var(--chat-max); margin: 0 auto; }
.quick { display: flex; gap: 6px; padding: 8px 0; flex-wrap: wrap; }
.quick-chip { appearance: none; border: 1px solid rgba(148,179,224,.22); background: rgba(18,28,48,.65); color: var(--text-secondary); font-size: var(--fs-12); min-height: 28px; padding: 0 10px; border-radius: var(--radius-pill); cursor: pointer; }
.quick-chip:hover { color: var(--text-primary); border-color: rgba(var(--accent-cyan-rgb), .48); background: rgba(34,52,86,.88); }
.composer { border: 1px solid rgba(var(--accent-gold-rgb), .38); background: rgba(10, 16, 32, .92); border-radius: var(--radius-lg); padding: 8px 8px 8px 12px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.composer:focus-within { border-color: rgba(var(--accent-gold-rgb), .75); box-shadow: 0 0 0 3px rgba(var(--accent-gold-rgb), .14); }
.composer.is-disabled { border-color: var(--border-subtle); }
.thumbs { display: flex; gap: 8px; padding: 4px 0 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-strong); background: #0b1324; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(3,6,14,.85); color: #fff; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.thumb .nm { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; padding: 1px 4px; background: rgba(3,6,14,.75); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-row { display: flex; align-items: flex-end; gap: 8px; }
.comp-row textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: var(--fs-14); line-height: 22px; min-height: 22px; max-height: 176px; padding: 5px 0; }
.comp-row textarea::placeholder { color: #7f94b3; }
.comp-row textarea:focus-visible { outline: none; }
.icon-btn { appearance: none; width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); background: rgba(15,23,42,.62); color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.send-btn { min-height: 36px; padding: 0 16px; }
.comp-hint { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-11); color: var(--text-muted); padding: 6px 4px 0; }
.comp-hint .busy-hint { color: #b7f5dc; }
.comp-hint .err { color: #ffb4b4; }
.drop-overlay { position: absolute; inset: 8px; z-index: 20; border: 2px dashed rgba(var(--accent-cyan-rgb), .8); border-radius: var(--radius-lg); background: rgba(6, 18, 32, .86); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; color: #c3f6ff; font-size: var(--fs-20); font-weight: 700; pointer-events: none; }
.drop-overlay::before { content: "⤓"; font-size: 40px; line-height: 1; color: var(--accent-cyan); }
.drop-overlay small { font-size: var(--fs-12); color: var(--text-secondary); font-weight: 400; }

/* —— 空状态 —— */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 24px; color: var(--text-secondary); }
.empty .orb { width: 72px; height: 72px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe6a8, #f3be5e 40%, #a86a1c 100%); box-shadow: 0 0 40px rgba(var(--accent-gold-rgb), .35); margin-bottom: 6px; }
.empty .orb.cyan { background: radial-gradient(circle at 35% 30%, #d9fbff, #56d7eb 40%, #146a7a 100%); box-shadow: 0 0 40px rgba(var(--accent-cyan-rgb), .3); }
.empty h3 { margin: 0; font-size: var(--fs-20); color: var(--text-primary); }
.empty p { margin: 0; max-width: 420px; font-size: var(--fs-13); }
.empty .chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* ============ 全局总览（简化） ============ */
.ov { height: 100%; overflow: auto; padding: 32px 40px; }
.ov-head { max-width: 1100px; margin: 0 auto 20px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ov-head h1 { margin: 0; font-size: var(--fs-20); }
.ov-head p { margin: 0; color: var(--text-muted); font-size: var(--fs-13); }
.ov-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ov-card { appearance: none; text-align: left; color: var(--text-primary); background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(10px); transition: border-color var(--dur-fast), background var(--dur-fast); font-size: var(--fs-13); }
.ov-card:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }
.ov-card.running { border-color: rgba(56,211,159,.45); }
.ov-top { display: flex; align-items: center; gap: 12px; }
.ov-top .avatar { width: 40px; height: 40px; }
.ov-top .avatar .sdot { width: 13px; height: 13px; }
.ov-tasks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; color: var(--text-secondary); font-size: var(--fs-12); }
.ov-tasks li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-go { font-size: var(--fs-12); color: var(--accent-cyan); font-weight: 600; }
.ov-card.idle .ov-go { color: var(--text-muted); font-weight: 500; }

/* ============ 任务关系（简化） ============ */
.tg { height: 100%; overflow: auto; padding: 24px 32px; }
.tg-head { display: flex; justify-content: space-between; align-items: baseline; max-width: 1100px; margin: 0 auto 12px; }
.tg-head h1 { margin: 0; font-size: var(--fs-20); }
.tg-head p { margin: 0; color: var(--text-muted); font-size: var(--fs-13); }
.tg-canvas { position: relative; max-width: 1100px; height: 440px; margin: 0 auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: rgba(8,13,25,.6); }
.tg-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tnode { position: absolute; width: 210px; transform: translate(-50%, -50%); appearance: none; text-align: left; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: rgba(15,23,42,.92); color: var(--text-primary); cursor: pointer; font-size: var(--fs-12); display: flex; flex-direction: column; gap: 4px; }
.tnode:hover { border-color: var(--accent-gold); }
.tnode .tid { font-family: var(--font-mono); color: var(--text-muted); font-size: var(--fs-11); display: flex; justify-content: space-between; }
.tnode .tt { font-size: var(--fs-13); font-weight: 600; line-height: 1.35; }
.tnode .st { font-size: var(--fs-11); font-weight: 600; }
.tnode.s-running { border-color: rgba(56,211,159,.6); } .tnode.s-running .st { color: var(--status-running); }
.tnode.s-done .st { color: var(--status-done); }
.tnode.s-ready .st { color: var(--status-ready); }
.tnode.s-review .st { color: var(--status-review); }

/* ============ Toast ============ */
.toast { position: fixed; left: 50%; top: calc(var(--bar-height) + 72px); transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-md); background: var(--bg-popover); border: 1px solid var(--border-strong); box-shadow: var(--shadow-popover); font-size: var(--fs-13); max-width: calc(100vw - 32px); }
.toast button { appearance: none; border: 0; background: transparent; color: var(--accent-cyan); cursor: pointer; font-size: var(--fs-13); font-weight: 600; padding: 2px 4px; }

/* ============ 演示控制 ============ */
.demo { position: fixed; right: 16px; bottom: 132px; z-index: 80; width: 216px; background: rgba(16, 25, 41, .96); border: 1px dashed rgba(139,124,246,.7); border-radius: var(--radius-md); box-shadow: var(--shadow-popover); font-size: var(--fs-12); }
.demo:not([open]) { width: auto; }
.demo summary { list-style: none; cursor: pointer; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; color: #d6cffd; font-weight: 600; }
.demo summary::-webkit-details-marker { display: none; }
.demo .tagline { font-size: var(--fs-11); font-weight: 600; color: #1a1240; background: #b8adff; border-radius: 4px; padding: 0 5px; }
.demo .body { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.demo .body .btn { width: 100%; justify-content: flex-start; min-height: 28px; font-size: var(--fs-12); }
.demo label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); min-height: 24px; cursor: pointer; }

/* ============ 抽屉（窄屏会话列表） ============ */
.drawer-mask { position: fixed; inset: var(--bar-height) 0 0 0; z-index: 30; background: rgba(3,6,14,.6); }
.drawer { position: fixed; top: var(--bar-height); bottom: 0; left: 0; width: 300px; max-width: 86vw; z-index: 31; background: #0a1020; border-right: 1px solid var(--border-strong); box-shadow: var(--shadow-panel); display: flex; flex-direction: column; overflow: auto; }

/* ============ 断点 ============ */
/* L ≥1280：默认值。 M 1024–1279 */
@media (max-width: 1279px) {
  :root { --sidebar-w: 248px; }
  .chat-header { padding: 0 var(--sp-5); }
  .chat-stream { padding: var(--sp-5) var(--sp-5) var(--sp-6); }
  .composer-wrap { padding: 0 var(--sp-5) var(--sp-4); }
  .msg { max-width: 82%; }
}
/* S 720–1023（约 800）：左栏收为 72px 头像轨，会话列表进抽屉 */
@media (max-width: 1023px) {
  :root { --sidebar-w: 72px; }
  .brand-title { display: none; }
  .btn-create .lbl, .btn-more .lbl { display: none; }
  .sidebar .side-sec.sessions { display: none; }
  .sidebar .side-head h2, .sidebar .bot-meta, .sidebar .right-tags .mini-pending { display: none; }
  .sidebar .side-head { justify-content: center; }
  .sidebar .side-head .btn { display: none; }
  .sidebar .bot-item { grid-template-columns: 1fr; justify-items: center; padding: 8px 0; position: relative; min-height: 52px; }
  .sidebar .bot-item .avatar { width: 34px; height: 34px; }
  .sidebar .right-tags { position: absolute; top: 2px; right: 6px; }
  .sidebar .unread { min-width: 18px; height: 18px; font-size: 10px; padding: 0 5px; }
  .sidebar .rail-pending { display: block; }
  .chat-header .sess-btn { display: inline-flex; }
  .chat-header .hdr-new { display: inline-flex; }
  .msg { max-width: 88%; }
  .chat-header { padding: 0 var(--sp-4); }
  .chat-stream { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .composer-wrap { padding: 0 var(--sp-4) var(--sp-3); }
  .appr-text .once { display: none; }
  .ov { padding: 24px; }
}
.rail-pending { display: none; position: absolute; left: 8px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--approval-pending); border: 2px solid var(--bg-panel-solid); }
/* XS <720：左栏整体隐藏为抽屉 */
@media (max-width: 719px) {
  .portal { grid-template-columns: 1fr; }
  .portal > .sidebar { display: none; }
  .view-tab { padding: 5px 10px; }
  .pending-badge .secs { display: none; }
}
/* 审批行在窄宽度下换成两行：文字一行，按钮 + 倒计时一行 */
@media (max-width: 1023px) {
  .appr.pending .appr-line { flex-wrap: wrap; }
  .appr.pending .appr-text { flex-basis: calc(100% - 32px); }
  .appr.pending .appr-actions { margin-left: 32px; }
}

/* ============ 减少动态效果 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .pending-badge .pulse { box-shadow: 0 0 0 2px rgba(var(--approval-pending-rgb), .45); }
  .sdot.running::after { display: none; }
  .msg.is-located .bubble { box-shadow: 0 0 0 4px rgba(var(--accent-gold-rgb), .35); }
  .dots i { opacity: .8; }
}
body.force-reduced *, body.force-reduced *::before, body.force-reduced *::after { animation: none !important; transition: none !important; }

/* ============ 强制色（高对比） ============ */
@media (forced-colors: active) {
  .appr.pending, .bot-item[aria-current="true"], .pending-badge { border: 2px solid CanvasText; }
  .cd-fill { background: Highlight; }
  :focus-visible { outline: 2px solid Highlight; }
}
