/* ===== Theme tokens ===== */
:root, [data-theme="light"] {
  --bg: #ffffff;
  --bg-sidebar: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-soft: #f2f4f7;
  --bg-hover: #eceef2;
  --bg-active: #e3e9ff;
  --border: #e3e6ec;
  --border-strong: #d4d8e0;
  --text: #1d2129;
  --text-2: #4e5969;
  --text-muted: #86909c;
  --accent: #4d6bfe;
  --accent-hover: #3d5bf0;
  --accent-soft: rgba(77, 107, 254, 0.1);
  --accent-text: #3451e6;
  --claude: #d97706;
  --gemini: #0284c7;
  --success: #16a34a;
  --warn: #ca8a04;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --user-bubble: #eef1ff;
  --user-bubble-text: #1d2129;
  --code-bg: #f6f8fa;
  --code-header: #eef1f5;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 24px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-sidebar: #151821;
  --bg-elev: #151821;
  --bg-card: #1b1f2b;
  --bg-soft: #1f2431;
  --bg-hover: #252b3a;
  --bg-active: #26335c;
  --border: #2a3142;
  --border-strong: #353d52;
  --text: #e8ecf5;
  --text-2: #b9c1d4;
  --text-muted: #8a94ab;
  --accent: #5b7cff;
  --accent-hover: #6d8bff;
  --accent-soft: rgba(91, 124, 255, 0.16);
  --accent-text: #a9bcff;
  --claude: #f59e0b;
  --gemini: #38bdf8;
  --success: #34d399;
  --warn: #facc15;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --user-bubble: #243259;
  --user-bubble-text: #eef2ff;
  --code-bg: #10131b;
  --code-header: #181c28;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.6;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }
svg.ico { width: 16px; height: 16px; flex-shrink: 0; display: block; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 25% 20%, rgba(245, 158, 11, 0.10), transparent 45%),
              radial-gradient(circle at 75% 80%, rgba(56, 189, 248, 0.10), transparent 45%), var(--bg-sidebar);
}
.login-card {
  width: min(400px, 92vw); padding: 28px 26px; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 8px; }
.login-brand h1 { margin: 0; font-size: 20px; }
.login-sub { margin: 8px 0 20px; font-size: 13px; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.login-form input {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none;
}
.login-form input:focus { border-color: var(--accent); }
.login-error { color: var(--danger); font-size: 13px; }

.brand-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.brand-dot.lg { width: 14px; height: 14px; }
.brand-dot.claude { background: var(--claude); box-shadow: 0 0 8px rgba(245, 158, 11, 0.45); }
.brand-dot.gemini { background: var(--gemini); box-shadow: 0 0 8px rgba(56, 189, 248, 0.45); }

/* ===== Buttons ===== */
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.danger { background: var(--danger); }
.full-width { width: 100%; }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 5px 10px; font-size: 12.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.btn-mini {
  background: var(--bg-soft); color: var(--text-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 9px; font-size: 12px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn-mini:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn {
  background: transparent; border: none; color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; }
.icon-btn.xs svg.ico { width: 13px; height: 13px; }
.icon-btn.on { color: var(--accent); }

/* ===== Shell ===== */
.app-shell { display: flex; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar {
  --sb-w: 280px;
  width: var(--sb-w); min-width: 220px; max-width: 480px; flex-shrink: 0;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px 10px; gap: 8px;
  position: relative; transition: margin-left 0.18s ease;
}
.app-shell.sidebar-collapsed .sidebar { margin-left: calc(-1 * var(--sb-w) - 1px); }
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 2px 6px; }
.sb-brand { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sb-brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 10px 12px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(77, 107, 254, 0.28);
}
.btn-new-chat:hover { background: var(--accent-hover); }
.btn-new-chat svg.ico { width: 17px; height: 17px; }

.sb-section-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 0 8px; }
.sb-section-title { font-size: 13px; color: var(--text-muted); }
.sb-section-actions { display: flex; align-items: center; gap: 2px; }

.sb-search {
  display: flex; align-items: center; gap: 6px; padding: 0 6px 0 10px; height: 34px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
}
.sb-search:focus-within { border-color: var(--accent); }
.sb-search-icon { color: var(--text-muted); }
.sb-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: var(--text); font-size: 13px; }

.view-toggle { display: flex; background: var(--bg-hover); border-radius: 10px; padding: 3px; gap: 2px; }
.view-tab {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  font-size: 13px; padding: 5px 0; border-radius: 8px; cursor: pointer;
}
.view-tab.active { background: var(--bg-card); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }

.sb-tree { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 2px 4px 8px; }
.sb-tree::-webkit-scrollbar { width: 6px; }
.sb-tree::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.tree-empty { color: var(--text-muted); font-size: 13px; padding: 14px 12px; }
.tree-group-label { font-size: 11.5px; color: var(--text-muted); padding: 10px 10px 4px; }

.ws-node { margin-bottom: 2px; border-radius: 10px; }
.ws-node.drag-over-top { box-shadow: inset 0 2px 0 var(--accent); }
.ws-node.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--accent); }
.ws-node.dragging { opacity: 0.45; }
.ws-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 4px; border-radius: 9px;
  cursor: pointer; user-select: none; color: var(--text-2); min-height: 34px;
}
.ws-row:hover { background: var(--bg-hover); }
.ws-row.current { color: var(--text); }
.ws-row.current .ws-name { font-weight: 600; }
.ws-chevron { color: var(--text-muted); transition: transform 0.15s ease; width: 18px; }
.ws-chevron svg.ico { width: 14px; height: 14px; }
.ws-node.collapsed .ws-chevron { transform: rotate(-90deg); }
.ws-folder { color: var(--text-muted); }
.ws-name { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-count { font-size: 11.5px; color: var(--text-muted); padding: 0 4px; }
.ws-actions, .sess-actions { display: none; align-items: center; gap: 1px; }
.ws-row:hover .ws-actions { display: flex; }
.ws-row:hover .ws-count { display: none; }
.ws-children { padding-left: 14px; margin-left: 12px; border-left: 1px solid var(--border); }
.ws-node.collapsed .ws-children { display: none; }
.ws-empty-hint { font-size: 12px; color: var(--text-muted); padding: 4px 10px 6px; cursor: pointer; }
.ws-empty-hint:hover { color: var(--accent-text); }

.sess-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-radius: 9px;
  cursor: pointer; user-select: none; min-height: 34px; position: relative; color: var(--text-2);
}
.sess-row:hover { background: var(--bg-hover); color: var(--text); }
.sess-row.active { background: var(--bg-active); color: var(--text); }
.sess-row.active .sess-title { font-weight: 600; }
.sess-status { width: 8px; display: inline-flex; justify-content: center; flex-shrink: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.status-dot.running { background: var(--success); animation: pulse 1.2s infinite; }
.status-dot.unread { background: var(--accent); }
.status-dot.idle { background: var(--border-strong); width: 5px; height: 5px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.sess-title { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-title-input {
  flex: 1; min-width: 0; font-size: 13px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--bg-card); color: var(--text); outline: none;
}
.sess-pin { color: var(--text-muted); }
.sess-pin svg.ico { width: 12px; height: 12px; }
.sess-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.sess-queue { font-size: 10.5px; padding: 0 5px; border-radius: 999px; background: rgba(202, 138, 4, 0.14); color: var(--warn); flex-shrink: 0; }
.sess-ws-tag { font-size: 10.5px; color: var(--text-muted); background: var(--bg-hover); padding: 0 6px; border-radius: 5px; max-width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.sess-row:hover .sess-actions, .sess-row.menu-open .sess-actions { display: flex; }
.sess-row:hover .sess-time, .sess-row.menu-open .sess-time { display: none; }
.platform-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.platform-dot.claude { background: var(--claude); }
.platform-dot.gemini { background: var(--gemini); }
.search-snippet { font-size: 11.5px; color: var(--text-muted); padding: 0 8px 6px 22px; margin-top: -4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.search-snippet mark { background: rgba(250, 204, 21, 0.35); color: inherit; border-radius: 2px; }

.sb-footer { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.node-card {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-card);
  cursor: pointer; color: var(--text);
}
.node-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.node-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.node-dot.online { background: var(--success); box-shadow: 0 0 6px rgba(22, 163, 74, 0.5); }
.node-dot.offline { background: var(--danger); }
.node-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.node-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-meta { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-card-arrow { color: var(--text-muted); }
.user-row { display: flex; align-items: center; gap: 6px; padding: 2px 2px 0 4px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-status { font-size: 11px; color: var(--text-muted); }
.ws-status.online { color: var(--success); }
.ws-status.offline { color: var(--danger); }

.sidebar-resizer {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 5;
}
.sidebar-resizer:hover, .sidebar-resizer.active { background: var(--accent-soft); }
body.resizing { cursor: col-resize; user-select: none; }
.sidebar-backdrop { display: none; }

/* ===== Main ===== */
.main-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.topbar {
  height: 54px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.main-pane.draft .topbar { border-bottom-color: transparent; }
.topbar-left { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.expand-btn { display: none; }
.app-shell.sidebar-collapsed .expand-btn { display: inline-flex; }
.workspace-pill {
  font-size: 13px; color: var(--text-muted); max-width: 180px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 4px;
}
.workspace-pill:hover { color: var(--text); }
.crumb-sep { color: var(--border-strong); }
.session-title {
  margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 40px; max-width: 420px; padding: 3px 6px; border-radius: 7px; cursor: text;
}
.session-title:hover { background: var(--bg-hover); }
.main-pane.draft .session-title { cursor: default; color: var(--text-muted); font-weight: 500; }
.main-pane.draft .session-title:hover { background: transparent; }
.session-title-edit {
  font-size: 15px; font-weight: 600; padding: 3px 8px; border-radius: 7px; min-width: 220px;
  border: 1px solid var(--accent); background: var(--bg-card); color: var(--text); outline: none;
}
.inline-select {
  background: var(--bg-soft); color: var(--text-2); border: 1px solid transparent;
  border-radius: 8px; padding: 4px 8px; font-size: 12.5px; outline: none; cursor: pointer; max-width: 210px;
}
.inline-select:hover { border-color: var(--border); }
.meta-pill { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--text-muted); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.meta-pill.running { color: var(--success); background: rgba(22, 163, 74, 0.1); }
.meta-pill.queued { color: var(--warn); background: rgba(202, 138, 4, 0.12); }
.platform-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; flex-shrink: 0; }
.platform-badge.claude { background: rgba(217, 119, 6, 0.12); color: var(--claude); }
.platform-badge.antigravity { background: rgba(2, 132, 199, 0.12); color: var(--gemini); }

/* ===== New chat (draft) ===== */
.new-chat-view { flex: 1; overflow-y: auto; display: flex; justify-content: center; padding: 0 20px; }
.nc-inner { width: min(780px, 100%); padding: 9vh 0 40px; display: flex; flex-direction: column; gap: 14px; }
.nc-hero { text-align: center; margin-bottom: 8px; }
.nc-logo { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.nc-title { font-size: 28px; font-weight: 700; letter-spacing: 0.5px; }
.nc-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 6px; }
.nc-pickers { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 13.5px; cursor: pointer;
  max-width: 100%;
}
.picker-btn > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.picker-btn:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.picker-btn.open { border-color: var(--accent); }
.picker-btn.warn { border-color: var(--warn); color: var(--warn); }
.picker-caret { color: var(--text-muted); }
.picker-caret svg.ico { width: 13px; height: 13px; }
.nc-composer-slot .composer-wrap { padding: 0; background: transparent; }
.nc-composer-slot .composer-box { min-height: 140px; }
.nc-composer-slot #prompt-input { min-height: 72px; }
.nc-recent { margin-top: 18px; }
.nc-recent-title { font-size: 12.5px; color: var(--text-muted); margin: 0 4px 8px; }
.nc-recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.nc-recent-item {
  text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-card); cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.nc-recent-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.nc-recent-item .t { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-recent-item .s { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Messages ===== */
.messages-scroll { flex: 1; overflow-y: auto; padding: 22px 20px 30px; }
.messages-container { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.empty-state { text-align: center; padding: 72px 20px; color: var(--text-muted); }
.empty-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-desc { max-width: 560px; margin: 0 auto; line-height: 1.7; }

.msg-row { display: flex; flex-direction: column; gap: 4px; position: relative; }
.msg-row.user { align-items: flex-end; }
.msg-row.assistant, .msg-row.tool, .msg-row.system { align-items: flex-start; }
.msg-bubble { max-width: 85%; padding: 10px 15px; border-radius: 16px; word-break: break-word; overflow-wrap: anywhere; }
.msg-row.user .msg-bubble { background: var(--user-bubble); color: var(--user-bubble-text); border-bottom-right-radius: 6px; }
.msg-row.assistant .msg-bubble { background: transparent; width: 100%; max-width: 100%; padding: 2px 2px; }
.msg-row.system .msg-bubble { background: var(--danger-soft); border: 1px solid rgba(220, 38, 38, 0.25); color: var(--danger); font-size: 13px; }
.msg-actions {
  display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity 0.12s;
  font-size: 11.5px; color: var(--text-muted); min-height: 24px;
}
.msg-row:hover .msg-actions, .msg-actions.always { opacity: 1; }
.msg-actions .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.msg-actions .icon-btn svg.ico { width: 14px; height: 14px; }
.msg-time { margin: 0 6px; }
.msg-model { margin-left: 4px; padding: 0 6px; border-radius: 5px; background: var(--bg-soft); }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; justify-content: flex-end; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); text-decoration: none; }
.att-thumb { max-width: 200px; max-height: 140px; border-radius: 10px; border: 1px solid var(--border); display: block; cursor: pointer; }

.tool-card { width: 100%; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 12.5px; }
.tool-card summary { padding: 7px 12px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; gap: 8px; list-style: none; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-badge { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; flex-shrink: 0; }
.tool-badge.err { background: var(--danger-soft); color: var(--danger); }
.tool-badge.think { background: rgba(147, 51, 234, 0.12); color: #9333ea; }
[data-theme="dark"] .tool-badge.think { color: #d4b3ff; }
.tool-summary-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.tool-body { padding: 10px 12px; border-top: 1px solid var(--border); background: var(--code-bg); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-height: 360px; overflow: auto; }

.live-preview { width: 100%; background: var(--bg-soft); border: 1px dashed var(--border-strong); border-radius: 14px; padding: 11px 15px; }
.live-header { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--accent-text); margin-bottom: 6px; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; animation: pulse 1.2s infinite; }

.md { line-height: 1.75; }
.md p { margin: 0 0 10px; } .md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 8px; line-height: 1.4; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.22em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { margin: 6px 0 10px; padding-left: 24px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--text-2); background: var(--bg-soft); border-radius: 0 6px 6px 0; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md table { border-collapse: collapse; margin: 10px 0; font-size: 13px; overflow-x: auto; display: block; max-width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--bg-soft); font-weight: 600; }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; }
.md .code-block { margin: 10px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--code-bg); }
.md .code-header { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px; background: var(--code-header); border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); font-family: var(--mono); }
.md .code-copy { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 5px; padding: 1px 8px; font-size: 11px; cursor: pointer; }
.md .code-copy:hover { color: var(--text); }
.md pre { margin: 0; padding: 10px 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.md pre code { background: transparent; padding: 0; }
.md a { color: var(--accent-text); }

/* ===== Composer ===== */
.chat-composer-slot { flex-shrink: 0; }
.main-pane.draft .messages-scroll, .main-pane.draft .chat-composer-slot { display: none; }
.composer-wrap { padding: 8px 20px 16px; position: relative; background: var(--bg); }
.composer-box {
  max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px;
  padding: 10px 12px 8px; box-shadow: var(--shadow-md);
}
.composer-box:focus-within { border-color: var(--accent); }
#prompt-input {
  width: 100%; background: transparent; border: none; outline: none; resize: none; color: var(--text);
  font-size: 14.5px; line-height: 1.55; max-height: 240px; padding: 4px 4px; min-height: 28px;
}
#prompt-input::placeholder { color: var(--text-muted); }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.composer-hint { flex: 1; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-send, .btn-stop {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.btn-send { background: var(--accent); }
.btn-send:hover { background: var(--accent-hover); }
.btn-send.disabled { opacity: 0.4; }
.btn-send.queue-mode { background: var(--warn); }
.btn-stop { background: var(--text); color: var(--bg); }
.btn-send svg.ico { width: 18px; height: 18px; }
.btn-stop svg.ico { width: 13px; height: 13px; }
.attachment-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 4px; }
.pending-att { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 9px; border-radius: 8px; background: var(--bg-soft); border: 1px solid var(--border); font-size: 12px; }
.pending-att button { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.drop-overlay { position: absolute; inset: 0; background: var(--accent-soft); border: 2px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; color: var(--accent-text); z-index: 20; pointer-events: none; border-radius: 18px; }
.scroll-bottom-btn {
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 14px; font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow-md); z-index: 15;
}
.scroll-bottom-btn:hover { border-color: var(--accent); color: var(--accent-text); }

/* Queue */
.queue-bar { max-width: 860px; margin: 0 auto 8px; background: var(--bg-card); border: 1px solid rgba(202, 138, 4, 0.35); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.queue-bar-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--warn); }
.queue-bar-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.queue-bar-hint { color: var(--text-muted); font-weight: 400; }
.queue-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; background: var(--bg-soft); border-radius: 8px; font-size: 13px; }
.queue-idx { font-family: var(--mono); font-size: 11px; color: var(--warn); flex-shrink: 0; }
.queue-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-att-tag { font-size: 11px; color: var(--accent-text); flex-shrink: 0; }
.queue-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.q-btn { border: 1px solid var(--border); background: var(--bg-card); color: var(--text-2); border-radius: 7px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.q-btn:hover { color: var(--text); border-color: var(--border-strong); }
.q-btn.send-now { color: var(--accent-text); border-color: rgba(77, 107, 254, 0.4); }
.q-btn.send-now:hover { background: var(--accent); color: #fff; }
.q-btn.del:hover { color: var(--danger); border-color: rgba(220, 38, 38, 0.4); }

/* ===== Files drawer ===== */
.files-drawer { width: 310px; min-width: 260px; background: var(--bg-sidebar); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.files-drawer.collapsed { display: none; }
.drawer-header { height: 54px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.drawer-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.files-breadcrumb { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumb-btn { background: transparent; border: none; color: var(--accent-text); cursor: pointer; padding: 1px 3px; font-size: 12px; }
.files-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.files-empty { text-align: center; color: var(--text-muted); padding: 28px 12px; font-size: 13px; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.file-row:hover { background: var(--bg-hover); }
.file-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--text-muted); }
.file-dl { opacity: 0.75; text-decoration: none; color: var(--accent-text); padding: 2px 5px; }

/* ===== Popover menu ===== */
.popover {
  position: fixed; z-index: 300; min-width: 200px; max-width: 340px; max-height: 70vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 5px;
}
.pop-header { font-size: 11.5px; color: var(--text-muted); padding: 6px 10px 3px; }
.pop-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.pop-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 10px; border: none; background: transparent; color: var(--text); font-size: 13px;
  border-radius: 8px; cursor: pointer;
}
.pop-item:hover, .pop-item.kb { background: var(--bg-hover); }
.pop-item .pi-icon { color: var(--text-muted); width: 16px; display: inline-flex; }
.pop-item .pi-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-item .pi-desc { font-size: 11.5px; color: var(--text-muted); }
.pop-item .pi-check { color: var(--accent); width: 16px; display: inline-flex; }
.pop-item.checked .pi-label { color: var(--accent-text); font-weight: 600; }
.pop-item.danger, .pop-item.danger .pi-icon { color: var(--danger); }
.pop-item.accent, .pop-item.accent .pi-icon { color: var(--accent-text); }
.pop-item:disabled { opacity: 0.45; cursor: default; }

/* ===== Modals ===== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 17, 23, 0.45); backdrop-filter: blur(2px); }
.modal-card { position: relative; width: min(920px, 92vw); max-height: 88vh; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-header { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.modal-title { font-weight: 600; font-size: 14px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-body { padding: 14px; overflow: auto; flex: 1; background: var(--code-bg); }
.modal-body pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.modal-body img { max-width: 100%; max-height: 70vh; display: block; margin: 10px auto 0; border-radius: 8px; border: 1px solid var(--border); }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 12px; }
.diag-item { padding: 10px 12px; border-radius: 10px; background: var(--bg-card); border: 1px solid var(--border); font-size: 13px; }
.diag-item strong { display: block; font-size: 11.5px; color: var(--text-muted); margin-bottom: 4px; }
.dialog-card { position: relative; width: min(420px, 92vw); background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 20px 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; }
.dialog-title { font-size: 16px; font-weight: 700; }
.dialog-message { font-size: 13.5px; color: var(--text-2); line-height: 1.6; white-space: pre-wrap; }
.dialog-message:empty { display: none; }
.dialog-input { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); font-size: 14px; outline: none; }
.dialog-input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 10px; font-size: 13px; z-index: 400; box-shadow: var(--shadow-md); max-width: 86vw; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 120; box-shadow: var(--shadow-lg); }
  .app-shell:not(.sidebar-collapsed) .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(0, 0, 0, 0.35); }
  .sidebar-resizer { display: none; }
  .expand-btn { display: inline-flex; }
  .files-drawer { position: fixed; right: 0; top: 0; bottom: 0; z-index: 105; box-shadow: var(--shadow-lg); }
  .inline-select { max-width: 120px; }
  .session-title { max-width: 40vw; }
  .btn-label { display: none; }
  .workspace-pill, .crumb-sep, #session-state-pill { display: none !important; }
  .messages-scroll { padding: 16px 12px 24px; }
  .composer-wrap { padding: 6px 10px 12px; }
  .nc-inner { padding-top: 5vh; }
  .nc-title { font-size: 22px; }
  .msg-actions { opacity: 1; }
}

/* Session status dot: platform color when idle */
.status-dot.claude { background: var(--claude); width: 6px; height: 6px; opacity: 0.75; }
.status-dot.gemini { background: var(--gemini); width: 6px; height: 6px; opacity: 0.75; }
.workspace-pill svg.ico { width: 14px; height: 14px; }
.ws-row .pulse-dot { margin-right: 2px; }

/* ===== Process block: thinking + tool calls folded, newest step shown ===== */
.proc-card { width: 100%; }
.proc-card > summary {
  display: flex; align-items: center; gap: 7px; cursor: pointer; list-style: none; user-select: none;
  padding: 5px 8px 5px 4px; border-radius: 9px; color: var(--text-muted); font-size: 13px; min-width: 0;
}
.proc-card > summary::-webkit-details-marker { display: none; }
.proc-card > summary:hover { color: var(--text-2); background: var(--bg-soft); }
.proc-icon { flex-shrink: 0; }
.proc-icon svg.ico { width: 15px; height: 15px; }
.proc-card:not(.live) .proc-icon { color: var(--success); }
.proc-label { flex-shrink: 0; max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--text-2); }
.proc-latest { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.85; }
.proc-latest:not(:empty)::before { content: '·'; margin-right: 6px; opacity: 0.6; }
.proc-caret { flex-shrink: 0; transition: transform 0.15s ease; }
.proc-caret svg.ico { width: 14px; height: 14px; }
.proc-card[open] > summary .proc-caret { transform: rotate(180deg); }
.proc-card[open] > summary .proc-latest { visibility: hidden; }
.proc-card.live .proc-icon { color: var(--accent); animation: pulse 1.2s infinite; }
.proc-card.live .proc-label {
  background: linear-gradient(90deg, var(--text-muted) 20%, var(--text) 50%, var(--text-muted) 80%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: think-shimmer 1.6s linear infinite;
}
@keyframes think-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.proc-body {
  margin: 4px 0 6px 11px; padding: 2px 0 2px 12px; border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; max-height: 460px; overflow-y: auto;
}
.proc-step { font-size: 12.5px; color: var(--text-2); }
.proc-step.think { display: flex; gap: 7px; padding: 4px 2px; }
.proc-step.think .ps-text { white-space: pre-wrap; word-break: break-word; line-height: 1.65; color: var(--text-muted); }
.proc-step > summary {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 2px; border-radius: 7px;
  cursor: pointer; list-style: none; min-width: 0;
}
.proc-step > summary::-webkit-details-marker { display: none; }
.proc-step > summary:hover { background: var(--bg-soft); }
.ps-icon { flex-shrink: 0; color: var(--text-muted); display: inline-flex; padding-top: 1px; }
.ps-icon svg.ico { width: 14px; height: 14px; }
.ps-verb { flex-shrink: 0; font-weight: 500; color: var(--text-2); }
.ps-arg { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
.ps-name { flex-shrink: 0; font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); opacity: 0.7; }
.proc-step.result .ps-icon { color: var(--success); }
.proc-step.result.err .ps-icon, .proc-step.result.err .ps-verb { color: var(--danger); }
.ps-pre {
  margin: 2px 0 6px 21px; padding: 8px 10px; border-radius: 8px; background: var(--code-bg); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto; color: var(--text-2);
}
.live-preview .proc-card { margin-bottom: 6px; }
.live-preview { border: none; background: transparent; padding: 2px 2px; }
