:root {
  --bg: #0d0f18;
  --bg-soft: #111522;
  --panel: #171b2b;
  --panel-2: #1e2338;
  --panel-3: #252b45;
  --border: #363f63;
  --border-soft: #262d49;
  --text: #f0f2fa;
  --muted: #a6acc4;
  --muted-2: #777f9a;
  --accent: #546cfd;
  --accent-strong: #7788ff;
  --accent-soft: rgba(84, 108, 253, .16);
  --green: #64d39a;
  --red: #f07178;
  --yellow: #d7bb6a;
  --radius: 13px;
  --shadow: 0 18px 60px rgba(0,0,0,.35);
  --sans: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
code, pre { font-family: var(--mono); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: #ffffff;
  border: 1px solid #546cfd;
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(84,108,253,.18);
}
.brand-mark svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.brand-mark-img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px; }
.brand-text { font-size: 16px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; }
.brand-text b { color: var(--accent); font-weight: 650; }
.brand-large .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 12px; }
.brand-large .brand-mark svg { width: 30px; height: 30px; }
.brand-large .brand-text { font-size: 20px; }

/* ---------- login ---------- */
.login-view {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 18%, #1a2245 0, #101322 42%, #090b14 100%);
  overflow: auto; padding: 28px;
}
.login-glow {
  position: fixed; width: 720px; height: 440px; left: 50%; top: 4%; transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(84,108,253,.18), transparent 68%);
  filter: blur(20px); pointer-events: none;
}
.login-card {
  position: relative; width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(31,29,25,.96), rgba(22,21,19,.98));
  border: 1px solid #2d2f39; border-radius: 20px;
  padding: 34px 34px 24px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05);
}
.login-card h1 { margin: 26px 0 8px; font-size: 25px; letter-spacing: -.3px; font-weight: 650; }
.login-sub { color: var(--muted); margin: 0 0 24px; font-size: 13.5px; line-height: 1.65; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 7px; font-weight: 600; }
.password-wrap { position: relative; }
.password-wrap input {
  width: 100%; height: 46px; padding: 0 64px 0 14px;
  border: 1px solid #30333b; border-radius: 10px;
  background: #0f1220; outline: none; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.password-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(84,108,253,.16); }
.ghost-mini {
  position: absolute; right: 8px; top: 8px; height: 30px; padding: 0 9px;
  background: transparent; border: 0; color: var(--muted); font-size: 12px; border-radius: 7px;
}
.ghost-mini:hover { background: var(--panel-2); color: var(--text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; transition: .15s background, .15s border, .15s transform;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #0a0d1a; border-color: #7183dc; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--panel-3); }
.btn-block { width: 100%; margin-top: 16px; height: 44px; }
.btn.small { height: 34px; padding: 0 12px; font-size: 12.5px; }
.login-error {
  margin-top: 13px; padding: 9px 11px; border-radius: 8px;
  background: rgba(224,108,98,.12); border: 1px solid rgba(224,108,98,.3); color: #f0a19a; font-size: 12.5px;
}
.login-meta {
  margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted-2); font-size: 11.5px;
}
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: #494d59; }
.login-warning {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft);
  color: #6a7081; font-size: 11px; line-height: 1.55; text-align: center;
}

/* ---------- app shell ---------- */
.app { display: flex; height: 100%; width: 100%; }
.sidebar {
  position: relative;
  width: var(--sidebar-width, 266px); flex: 0 0 var(--sidebar-width, 266px); height: 100%;
  background: #141412; border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; padding: 16px 10px 12px;
  z-index: 30;
}
.sidebar-resizer {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 40; touch-action: none;
}
.sidebar-resizer::after {
  content: ""; position: absolute; top: 0; left: 3px; width: 1px; height: 100%;
  background: var(--accent); opacity: 0; transition: opacity .15s ease;
}
.sidebar-resizer:hover::after, .sidebar-resizer.dragging::after { opacity: .75; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
.context-menu {
  position: fixed; z-index: 300; min-width: 150px; padding: 4px;
  background: #17191d; border: 1px solid #31343c; border-radius: 9px;
  box-shadow: 0 12px 34px rgba(0,0,0,.45);
}
.context-menu button {
  display: flex; align-items: center; width: 100%; height: 32px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font-size: 12px; text-align: left;
}
.context-menu button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.sidebar > .brand { padding: 2px 8px 12px; }
.usage-badge {
  margin: -6px 8px 12px; padding: 5px 8px; border: 1px solid #292c3a;
  border-radius: 7px; background: #121319; color: #8c91a8;
  font: 10.5px var(--mono); cursor: pointer; user-select: none;
}
.usage-badge:hover { border-color: #3a3f58; color: #adb4d6; }
.usage-sep { margin: 0 5px; color: #4c515e; }
.usage-detail { margin: 10px 0 12px; }
.usage-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; margin: 10px 0 6px;
}
.usage-row b { color: #c9ccdc; font-weight: 500; text-align: right; }
.usage-meter { height: 6px; background: #1e2338; border-radius: 999px; overflow: hidden; }
.usage-meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.usage-empty { color: #616676; font-size: 11px; padding: 2px 0 8px; }
.usage-note { color: #777d8f; font-size: 11px; line-height: 1.6; margin: 6px 0 14px; }
.conn-badge {
  margin: 0 8px 14px; display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted-2); font-size: 11.5px; width: fit-content;
}
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(112,196,138,.09); }
.conn-badge.offline .conn-dot { background: var(--red); box-shadow: 0 0 0 3px rgba(224,108,98,.09); }
.conn-badge.offline { color: #b67a73; }
.sidebar-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 7px; color: var(--muted-2); font-size: 11px; font-weight: 650; letter-spacing: .9px; text-transform: uppercase;
}
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--border-soft); }
.icon-btn.small { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.project-list { flex: 1; overflow-y: auto; padding: 2px 0 10px; scrollbar-width: thin; }
.project-block { margin-bottom: 2px; }
.project-row {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 9px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: #ccced7; text-align: left;
}
.project-row:hover { background: #181d2f; }
.project-block.active .project-row { background: #22211d; border-color: #2b2e35; color: var(--text); }
.proj-icon { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 2px; background: #4c505c; }
.project-block.active .proj-icon { background: var(--accent); }
.proj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.proj-count { color: var(--muted-2); font-size: 10.5px; min-width: 15px; text-align: right; }
.proj-live { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
.chat-list { padding: 2px 0 4px 19px; }
.chat-item {
  width: 100%; display: flex; align-items: center; gap: 7px;
  border: 0; background: transparent; border-radius: 7px; padding: 6px 5px 6px 8px;
  color: var(--muted); text-align: left; font-size: 12.2px; cursor: pointer;
}
.chat-item:hover { background: #181d2f; color: #d8def0; }
.chat-item.active { background: #202128; color: var(--text); }
.chat-item .ctitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-queue {
  flex: 0 0 auto; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #242839; color: #7d8bd0; font: 9.5px var(--mono); display: grid; place-items: center;
}
.chat-hover-actions {
  flex: 0 0 auto; display: none; align-items: center; gap: 1px; margin-left: -2px;
}
.chat-item:hover .chat-hover-actions,
.chat-item:focus-within .chat-hover-actions,
.chat-item.pinned .chat-hover-actions { display: inline-flex; }
.chat-item.pinned [data-chat-pin] { color: var(--accent-strong); }
.chat-hover-btn {
  width: 19px; height: 19px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; color: #777d8f; display: grid; place-items: center;
  font: 12px/1 var(--sans); cursor: pointer;
}
.chat-hover-btn:hover { background: #242632; color: var(--accent-strong); }
.chat-hover-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.chat-more-btn { font-size: 13px; letter-spacing: -.5px; }
.chat-dot { width: 5px; height: 5px; border-radius: 50%; background: #4f5360; flex: 0 0 5px; }
.chat-dot.running, .chat-dot.queued { background: var(--accent); animation: pulse 1.4s infinite; }
.chat-dot.paused { background: var(--yellow); }
.chat-dot.error { background: var(--red); }
.new-chat-item {
  width: 100%; display: flex; align-items: center; gap: 6px; border: 0; background: transparent;
  color: #6c7285; font-size: 12px; padding: 6px 8px; border-radius: 7px; text-align: left;
}
.new-chat-item:hover { color: var(--accent-strong); background: var(--accent-soft); }
.new-chat-item svg { width: 13px; height: 13px; }
.sidebar-empty { padding: 18px 10px; color: var(--muted-2); font-size: 12px; line-height: 1.6; }
.sidebar-foot { border-top: 1px solid var(--border-soft); padding: 9px 2px 0; display: flex; gap: 2px; }
.side-action {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: transparent; color: var(--muted-2); font-size: 12px; padding: 8px 6px; border-radius: 7px;
}
.side-action:hover { color: var(--text); background: var(--panel-2); }
.side-action svg { width: 15px; height: 15px; }

/* ---------- main / topbar ---------- */
.main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  height: 68px; flex: 0 0 68px; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--border-soft); background: rgba(15,15,14,.95);
}
.menu-btn { display: none; }
.project-heading { min-width: 0; flex: 1; }
.project-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-heading h1 {
  margin: 0; font-size: 16.5px; font-weight: 650; letter-spacing: -.15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-path { margin-top: 2px; color: var(--muted-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 640px; }
.project-status { font-size: 10.5px; color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(84,108,253,.28); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.view-tabs {
  display: flex; gap: 2px; padding: 3px; background: #151a2c; border: 1px solid var(--border-soft); border-radius: 9px;
}
.view-tab {
  height: 28px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.view-tab:hover { color: var(--text); }
.view-tab.active { background: #262d49; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }

/* ---------- chat ---------- */
.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat-header {
  height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid #1f1e1a; background: #101322;
}
.chat-header-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chat-kicker { color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; }
.chat-title { font-size: 12.8px; color: #d8def0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 48vw; }
.chat-header-right { display: flex; align-items: center; gap: 12px; }
.status-pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.status-pill.running { color: var(--accent-strong); border-color: rgba(84,108,253,.4); background: var(--accent-soft); }
.status-pill.queued { color: var(--yellow); border-color: rgba(215,179,95,.25); background: rgba(215,179,95,.07); }
.status-pill.paused { color: var(--yellow); border-color: rgba(215,179,95,.3); background: rgba(215,179,95,.1); }
.status-pill.error { color: #f29a9a; border-color: rgba(224,108,98,.3); background: rgba(224,108,98,.08); }
.status-pill.idle { color: var(--green); border-color: rgba(112,196,138,.2); background: rgba(112,196,138,.06); }
.text-btn { border: 0; background: transparent; color: var(--muted); font-size: 12.3px; padding: 4px 6px; border-radius: 6px; }
.text-btn:hover { color: var(--text); background: var(--panel-2); }
.text-btn.danger { color: #e09189; }
.text-btn.danger:hover { background: rgba(224,108,98,.1); color: #f1aaa3; }
.messages {
  flex: 1; overflow-y: auto; overflow-anchor: none; padding: 28px clamp(20px, 5vw, 70px) 22px;
  scrollbar-width: thin; scrollbar-color: #31333b transparent;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #2b2d34; border-radius: 8px; }
.msg { max-width: 880px; margin: 0 auto 22px; }
.msg-user { position: relative; display: flex; flex-direction: column; align-items: flex-end; }
.user-bubble {
  max-width: min(680px, 88%); background: #1e2338; border: 1px solid #2a2f46;
  color: #e4e7f4; padding: 11px 15px; border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap; word-break: break-word; font-size: 13.5px;
}
.assistant-hover-actions {
  position: absolute; left: 0; top: 100%; z-index: 5;
  display: flex; align-items: center; gap: 3px; padding-top: 2px;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.assistant-row:hover .assistant-hover-actions,
.assistant-row.show-actions .assistant-hover-actions,
.assistant-row:focus-within .assistant-hover-actions { opacity: 1; pointer-events: auto; }
.assistant-hover-btn {
  width: 23px; height: 22px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 5px; background: transparent;
  color: #7f8aa8; cursor: pointer; position: relative;
}
.assistant-hover-btn:hover, .assistant-hover-btn.active { background: #20283c; color: #b9c8ff; }
.assistant-hover-btn.active { color: #9fb3ff; }
.assistant-hover-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.assistant-age { color: #70778b; font-size: 10.5px; padding: 2px 4px; cursor: default; position: relative; white-space: nowrap; }
.user-hover-actions {
  position: absolute; top: 100%; right: 3px; z-index: 5;
  display: flex; align-items: center; gap: 3px; padding-top: 3px;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.msg-user:hover .user-hover-actions,
.msg-user:focus-within .user-hover-actions { opacity: 1; pointer-events: auto; }
.user-age {
  color: #70778b; font-size: 10.5px; padding: 2px 4px; cursor: default;
  position: relative; white-space: nowrap;
}
.user-hover-btn {
  width: 23px; height: 22px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 5px; background: transparent;
  color: #7f8aa8; cursor: pointer; position: relative;
}
.user-hover-btn:hover { background: #20283c; color: #dce5ff; }
.user-hover-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 8px);
  width: max-content; max-width: 280px; padding: 6px 9px;
  border-radius: 6px; background: #08090d; color: #f1f3fa;
  border: 1px solid #2c334a; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  font-size: 10.5px; line-height: 1.45; text-align: left; white-space: normal;
  opacity: 0; pointer-events: none; transform: translateY(3px);
  transition: opacity .1s ease, transform .1s ease; z-index: 20;
}
[data-tip]::before {
  content: ""; position: absolute; right: 9px; bottom: calc(100% + 3px);
  border: 5px solid transparent; border-top-color: #08090d;
  opacity: 0; pointer-events: none; transition: opacity .1s ease; z-index: 21;
}
[data-tip]:hover::after, [data-tip]:hover::before { opacity: 1; transform: translateY(0); }
.pending-msg .user-bubble { border-color: #ef5555; box-shadow: 0 0 0 1px rgba(239,85,85,.35); }
.pending-msg { align-items: flex-end; display: flex; flex-direction: column; }
.pending-msg-actions { display: none; gap: 5px; margin: 4px 4px 0; }
.pending-msg.show-actions .pending-msg-actions,
.pending-msg:hover .pending-msg-actions { display: flex; }
.pending-msg-actions { align-items: center; }
.pending-now { border: 0; background: transparent; color: #ef6666; font-size: 10.5px; padding: 3px 5px; cursor: pointer; }
.pending-now:hover { color: #ff9a9a; }
.pending-act { width: 24px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: #7f8aa8; cursor: pointer; padding: 0; }
.pending-act:hover { background: #20283c; color: #dce5ff; }
.pending-act svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.user-image-grid { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.chat-image {
  display: block; width: auto; height: auto;
  max-width: min(560px, 100%); max-height: 520px; object-fit: contain;
  border-radius: 9px; border: 1px solid #343a58; background: #111522;
  cursor: zoom-in;
}
.user-image-grid .chat-image { max-width: 320px; max-height: 280px; }
.assistant-text .inline-chat-image {
  max-width: min(560px, 100%); max-height: 420px; object-fit: contain;
  margin: 8px 0 4px; background: #0d0f18;
}
.user-message-text { white-space: pre-wrap; }
.user-file-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.user-file-tag {
  display: inline-block; max-width: 300px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding: 3px 8px; border-radius: 5px;
  border: 1px solid #353a53; background: #181a23; color: #a7afd6; font-size: 11px;
}
.assistant-row { position: relative; display: flex; gap: 0; align-items: flex-start; }
.assistant-avatar {
  width: 27px; height: 27px; flex: 0 0 27px; margin-top: 2px; border-radius: 8px;
  display: grid; place-items: center; color: var(--accent);
  background: #ffffff; border: 1px solid #546cfd; overflow: hidden;
}
.assistant-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }
.assistant-body { min-width: 0; flex: 1; }
.assistant-text { font-size: 13.8px; line-height: 1.72; color: #dcdee7; overflow-wrap: anywhere; }
.assistant-text > :first-child { margin-top: 0; }
.assistant-text > :last-child { margin-bottom: 0; }
.assistant-text p { margin: 0 0 10px; }
.assistant-text h1, .assistant-text h2, .assistant-text h3 { margin: 18px 0 8px; font-size: 15px; line-height: 1.4; color: #e8eaf3; }
.assistant-text h1 { font-size: 17px; }
.assistant-text ul, .assistant-text ol { margin: 7px 0 11px; padding-left: 22px; }
.assistant-text li { margin: 3px 0; }
.assistant-text blockquote { margin: 9px 0; padding: 2px 12px; border-left: 2px solid var(--accent); color: var(--muted); }
.assistant-text code { background: #24231f; border: 1px solid #2b2d34; padding: 1px 5px; border-radius: 5px; font-size: 12px; color: #b2b9e0; }
.assistant-text pre {
  position: relative; margin: 11px 0; padding: 13px 14px; background: #0f1220;
  border: 1px solid #2a3150; border-radius: 9px; overflow: auto; font-size: 12px; line-height: 1.55;
}
.assistant-text pre code { background: transparent; border: 0; padding: 0; color: #c9cbd8; font-size: 12px; }
.code-wrap { position: relative; }
.code-lang { position: absolute; left: 10px; top: 7px; color: #6b7390; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; pointer-events: none; }
.code-copy {
  position: absolute; right: 7px; top: 7px; height: 24px; padding: 0 7px;
  border: 1px solid #2f3139; border-radius: 6px; background: #1d1c18; color: #7c8294; font-size: 10.5px;
}
.code-copy:hover { color: var(--text); background: #20263c; }
.typing-dots { display: inline-flex; gap: 4px; padding: 9px 2px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
.assistant-text table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.assistant-text th, .assistant-text td { border: 1px solid #2a2d34; padding: 6px 8px; text-align: left; }
.assistant-text th { background: #181d2f; }
.md-table-wrap {
  width: 100%; margin: 12px 0; overflow-x: auto;
  border: 1px solid #2a3150; border-radius: 9px; background: #0f1522;
}
.md-table { width: 100%; border-collapse: collapse; table-layout: auto; margin: 0; font-size: 12.5px; }
.md-table th, .md-table td {
  border: 0; border-right: 1px solid #27314d; border-bottom: 1px solid #27314d;
  padding: 8px 11px; vertical-align: top; line-height: 1.55; white-space: normal;
}
.md-table th:last-child, .md-table td:last-child { border-right: 0; }
.md-table tbody tr:last-child td { border-bottom: 0; }
.md-table thead th {
  background: #1b2238; color: #dce4ff; font-weight: 600; white-space: nowrap;
}
.md-table tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
.md-table tbody tr:hover { background: rgba(84,108,253,.06); }
.md-table code { white-space: nowrap; }
.assistant-text hr { border: 0; border-top: 1px solid #272930; margin: 16px 0; }
.message-time { color: #525664; font-size: 10px; margin-top: 5px; }

/* tool cards */
.action-group {
  max-width: 880px; margin: 0 auto 4px; border: 0;
  border-radius: 0; background: transparent; overflow: visible;
}
.action-group summary {
  list-style: none; display: flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 6px 2px; cursor: pointer;
  color: #8f99b5; font-size: 11.5px; user-select: none;
  border: 0; border-radius: 0; background: transparent;
}
.action-group summary::-webkit-details-marker { display: none; }
.action-group summary:hover { color: #c8d2ed; }
.action-chevron { order: 2; color: #66728f; font-size: 16px; line-height: 1; transform: rotate(0deg); transition: transform .12s; }
.action-group[open] .action-chevron { transform: rotate(90deg); }
.action-summary { order: 1; flex: 0 1 auto; min-width: 0; color: #aab4d0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-thumbs { order: 3; margin-left: auto; display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.action-thumb { width: auto; height: 36px; max-width: 120px; object-fit: contain; border-radius: 6px; border: 1px solid #3a4363; background: #0d1220; cursor: zoom-in; }
.action-video-thumb { background: #0b0f1a; object-fit: contain; }
.action-thumb-more { color: #7d89a6; font-size: 10px; }
.action-group[open] > summary { border-radius: 0; }
.action-group-body {
  padding: 7px 0 5px 18px; margin: 0 0 6px 8px;
  border: 0; border-left: 1px solid #28314a;
  border-radius: 0; background: transparent; overflow: visible;
}
.action-openspec { padding: 2px 0 4px; border: 0; background: transparent; }
.action-openspec .msg { max-width: none; margin: 0 0 8px; }
.action-openspec .assistant-avatar { display: none; }
.action-openspec .assistant-body { padding: 0; }
.action-item {
  margin: 6px 0; border: 1px solid #28314a; border-radius: 8px;
  background: #111725; overflow: hidden;
}
.action-item:first-child { border-top: 1px solid #28314a; }
.action-item summary {
  list-style: none; display: flex; align-items: center; gap: 9px;
  min-height: 36px; padding: 7px 10px; cursor: pointer; color: #aeb8d2;
  font-size: 12px; line-height: 1.45; background: #111725;
}
.action-item summary::-webkit-details-marker { display: none; }
.action-item summary:hover { background: #161d30; color: #dce3ff; }
.action-item-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-item-chevron { flex: 0 0 auto; color: #697795; font-size: 16px; line-height: 1; transition: transform .12s; }
.action-item[open] .action-item-chevron { transform: rotate(90deg); }
.action-item-thumb { width: 44px; height: 28px; object-fit: contain; border-radius: 4px; border: 1px solid #3a4363; background: #0d1220; flex: 0 0 auto; cursor: zoom-in; }
.action-item .tool-state { margin-left: 1px; }
.action-item-body { padding: 8px 12px 10px 23px; border-top: 1px solid #232b43; background: #0d1320; }
.action-item-body .tool-label { margin-top: 7px; }
.action-item-body .tool-label:first-child { margin-top: 0; }
.action-item-body pre { max-height: 260px; overflow: auto; margin: 4px 0 0; padding: 8px; border-radius: 6px; background: #0a0f1a; border: 1px solid #202941; font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.action-group-body .tool-entry:last-child { margin-bottom: 0; }
.action-group-body .tool-card { max-width: none; margin: 0; border-color: #252d47; background: #0f1522; }
.action-group-body .tool-card summary { padding: 6px 8px; font-size: 11px; }
.action-group-body .tool-file-grid { margin-top: 4px; }
.plan-card {
  max-width: 880px; margin: 0 auto 10px; padding: 0;
  border: 1px solid #2d3658; border-radius: 9px; background: #121827; overflow: hidden;
}
.plan-card summary {
  list-style: none; display: flex; align-items: center; gap: 7px;
  padding: 9px 12px; cursor: pointer; user-select: none;
}
.plan-card summary::-webkit-details-marker { display: none; }
.plan-card summary:hover { background: #161d31; }
.plan-title { color: #aeb8d2; font-size: 11px; margin: 0; }
.plan-count { color: #73809f; font: 10px var(--mono); }
.plan-chevron { color: #66728f; font-size: 15px; line-height: 1; margin-left: 2px; transform: rotate(0deg); transition: transform .12s; }
.plan-card[open] .plan-chevron { transform: rotate(90deg); }
.plan-body { padding: 2px 13px 11px; border-top: 1px solid #232b43; }
.plan-row { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; color: #b8c1dc; font-size: 12px; line-height: 1.5; }
.plan-mark { width: 14px; flex: 0 0 14px; color: #65708e; text-align: center; }
.plan-row.done { color: #76819d; }
.plan-row.done .plan-mark { color: #6fd39b; }
.plan-row.active { color: #dce3ff; }
.plan-row.active .plan-mark { color: var(--accent-strong); }
.chat-product-gallery {
  width: min(880px, 100%); max-width: 880px; margin: 0 auto 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.chat-product {
  display: block; width: auto; max-width: 450px; max-height: 255px;
  border: 1px solid #2a334d; border-radius: 8px; background: #0d1220;
  object-fit: contain; cursor: zoom-in;
}
.chat-product-gallery video.chat-product { cursor: default; }
.thinking-card {
  max-width: 880px; margin: 0 auto 2px; border: 0;
  border-radius: 0; background: transparent; overflow: visible;
}
.thinking-card summary {
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 5px 2px; cursor: pointer; color: #8f99b5; font-size: 11.5px; user-select: none;
}
.thinking-card summary::-webkit-details-marker { display: none; }
.thinking-card summary:hover { color: #c8d2ed; }
.thinking-dots { display: inline-flex; align-items: center; gap: 3px; }
.thinking-dots i { width: 3px; height: 3px; border-radius: 50%; background: #c87958; display: block; opacity: .8; }
.thinking-title { color: #8f99b5; font-weight: 400; }
.thinking-meta { margin-left: 1px; color: #65718e; font: 10px var(--mono); }
.thinking-chevron { margin-left: 1px; color: #66728f; font-size: 15px; line-height: 1; transform: rotate(0deg); transition: transform .12s; }
.thinking-card[open] .thinking-chevron { transform: rotate(90deg); }
.thinking-body {
  margin: 3px 0 7px 17px; border: 1px solid #28314a; border-radius: 8px;
  padding: 9px 12px 10px; color: #aeb9d8; font-size: 11.5px; line-height: 1.65; background: #111725;
}
.thinking-body p { margin: 0 0 6px; }
.thinking-body p:last-child { margin-bottom: 0; }
.thinking-unavailable { color: #6f7b9d; font-size: 10.5px; }
.tool-card {
  max-width: 880px; margin: 0 auto 10px; border: 1px solid #2a3150; border-radius: 10px;
  background: #161613; overflow: hidden;
}
.tool-card[open] { background: #171713; border-color: #2f3139; }
.tool-card summary {
  list-style: none; display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; cursor: pointer; color: #a8acb7; font-size: 12px; user-select: none;
}
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary:hover { background: #181d2f; }
.tool-glyph { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; background: #1d1f25; color: #838dc3; font-size: 10px; flex: 0 0 20px; }
.tool-name { font-weight: 600; color: #c1c4d1; white-space: nowrap; }
.tool-desc { flex: 1; color: #707688; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.tool-state { width: 6px; height: 6px; border-radius: 50%; background: #4c505d; flex: 0 0 6px; }
.tool-state.ok { background: var(--green); }
.tool-state.err { background: var(--red); }
.tool-state.live { background: var(--accent); animation: pulse 1.4s infinite; }
.tool-body { border-top: 1px solid #20263c; padding: 10px 12px 12px; }
.tool-label { color: #737b96; font-size: 10px; letter-spacing: .7px; text-transform: uppercase; margin: 0 0 5px; }
.tool-body pre {
  margin: 0 0 10px; padding: 9px 10px; background: #111522; border: 1px solid #20263c;
  border-radius: 7px; color: #c4cbe2; font-size: 11.3px; line-height: 1.5; overflow: auto; max-height: 300px; white-space: pre-wrap; word-break: break-word;
}
.tool-body pre:last-child { margin-bottom: 0; }
.tool-error { color: #e29a9a !important; }
.tool-entry { max-width: 880px; margin: 0 auto 10px; }
.tool-entry .tool-card { max-width: none; margin: 0; }
.tool-image-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding: 8px;
  border: 1px solid #2a3150; border-radius: 10px; background: #111522;
}
.tool-image {
  width: 142px; height: 106px; object-fit: contain; display: block;
  border: 1px solid #303a5e; border-radius: 8px; background: #0d0f18;
  cursor: zoom-in;
}
.tool-image:hover { border-color: var(--accent); }
.tool-file-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding: 8px;
  border: 1px solid #2a3150; border-radius: 10px; background: #111522;
}
.tool-file-grid > * { margin: 0; }
.chat-video {
  width: min(620px, 100%); max-height: 360px; display: block;
  border: 1px solid #303a5e; border-radius: 9px; background: #000;
}
.chat-audio { width: min(560px, 100%); display: block; margin: 8px 0; }
.chat-pdf {
  width: 100%; height: 520px; display: block;
  border: 1px solid #303a5e; border-radius: 9px; background: #fff;
}
.file-text-card {
  width: min(620px, 100%); border: 1px solid #303a5e; border-radius: 9px;
  background: #0d0f18; overflow: hidden;
}
.file-text-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 10px; color: #c4cbe2; font-size: 11px; background: #171d2f;
  border-bottom: 1px solid #262f4b;
}
.file-text-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-text-head a { color: var(--accent-strong); font-size: 10.5px; flex: 0 0 auto; }
.file-text-body {
  margin: 0; padding: 9px 10px; max-height: 220px; overflow: auto;
  color: #b8c1dc; font: 10.5px/1.5 var(--mono); white-space: pre-wrap;
  word-break: break-word;
}
.file-card {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 7px 10px; border: 1px solid #303a5e; border-radius: 8px;
  background: #171d2f; color: #c4cbe2; text-decoration: none; font-size: 11px;
}
.file-card:hover { border-color: var(--accent); color: #fff; }
.file-card-icon {
  width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center;
  border-radius: 6px; background: #242d4c; color: #aab7ff; font: 8px var(--mono);
}
.file-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .tool-image { width: calc(50% - 4px); height: 100px; }
}

/* OpenSpec process folds */
.openspec-fold {
  max-width: 880px; margin: 0 auto 10px; border: 1px solid #29324d;
  border-radius: 8px; background: #151b2b; overflow: hidden;
}
.openspec-fold > summary {
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; color: #8d99b8; font-size: 11px; cursor: pointer;
  user-select: none;
}
.openspec-fold > summary::-webkit-details-marker { display: none; }
.openspec-chevron { color: #66728f; font-size: 15px; line-height: 1; transition: transform .12s; }
.openspec-fold[open] .openspec-chevron { transform: rotate(90deg); }
.openspec-fold-body { padding: 0 10px 4px; }
.openspec-fold-body .msg { margin-bottom: 10px; }
.openspec-fold-body .notice { text-align: left; margin: 4px 0 8px; }

/* completion / notices */
.completion-card {
  max-width: 880px; margin: 2px auto 18px; border: 1px solid #2e3658; border-radius: 10px;
  background: linear-gradient(180deg, #15161b, #13172a); padding: 11px 13px;
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
}
.completion-icon { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: rgba(112,196,138,.1); color: var(--green); font-size: 13px; }
.completion-main { flex: 1; min-width: 160px; }
.completion-title { font-size: 12.5px; color: #d8def0; font-weight: 600; }
.completion-meta { font-size: 10.5px; color: #737b96; margin-top: 1px; }
.completion-actions { display: flex; gap: 7px; }
.notice {
  max-width: 880px; margin: 6px auto 15px; text-align: center; color: #737b96; font-size: 11px;
}
.error-card {
  max-width: 880px; margin: 2px auto 18px; padding: 11px 13px; border-radius: 9px;
  background: rgba(224,108,98,.08); border: 1px solid rgba(224,108,98,.26); color: #e7a29a; font-size: 12.5px; white-space: pre-wrap;
}
.empty-state {
  position: absolute; inset: 48px 0 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 28px; pointer-events: none;
}
.empty-state > * { pointer-events: auto; }
.empty-mark {
  width: 58px; height: 58px; border-radius: 17px; display: grid; place-items: center;
  color: var(--accent); background: #ffffff;
  border: 1px solid #546cfd; box-shadow: 0 14px 40px rgba(84,108,253,.18); overflow: hidden;
}
.empty-mark-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.empty-state h2 { margin: 18px 0 7px; font-size: 22px; font-weight: 650; letter-spacing: -.3px; }
.empty-state p { margin: 0; max-width: 560px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.empty-state p code { background: #1e2338; padding: 1px 5px; border-radius: 5px; color: #b9c2e8; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 24px; max-width: 650px; }
.suggestions button {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border: 1px solid #2a3150; border-radius: 9px; background: #13172a; color: #b9c0d8; font-size: 11.5px;
}
.suggestions button span { color: var(--accent); font-weight: 650; font-size: 10px; letter-spacing: .5px; }
.suggestions button:hover { border-color: #343c5e; background: #1a2033; color: var(--text); }

/* slash command menu */
.slash-menu {
  position: fixed; z-index: 120; max-height: min(380px, 52vh); overflow-y: auto;
  padding: 6px; border: 1px solid #303a5e; border-radius: 10px;
  background: #151b2b; box-shadow: 0 16px 46px rgba(0,0,0,.45);
  scrollbar-width: thin;
}
.slash-menu.hidden { display: none; }
.slash-head { padding: 5px 8px 6px; color: #7b86a6; font-size: 10px; letter-spacing: .5px; }
.slash-item {
  width: 100%; display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px;
  border: 0; border-radius: 7px; background: transparent; color: #c4cce2; text-align: left;
}
.slash-item:hover, .slash-item.active { background: #222b45; color: #eef2ff; }
.slash-icon { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border-radius: 6px; background: #202943; color: #9fb0e6; font-size: 11px; }
.slash-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.slash-main b { font-size: 12px; font-weight: 600; }
.slash-main small { color: #7f8aa8; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* composer */
.composer-wrap {
  flex: 0 0 auto; padding: 8px clamp(20px, 5vw, 70px) 12px; background: linear-gradient(180deg, transparent, var(--bg) 22%);
}
.run-bar {
  max-width: 880px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px;
  color: #b9c0d8; font-size: 11.5px; padding: 0 4px;
}
.run-spinner { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #323649; border-top-color: var(--accent); animation: spin .8s linear infinite; }
.run-elapsed { color: #5e6372; font-family: var(--mono); font-size: 10.5px; }
.run-bar .text-btn { margin-left: auto; }
.queue-panel {
  max-width: 880px; margin: 0 auto 8px; padding: 8px 10px 7px;
  border: 1px solid #303a5e; border-radius: 10px; background: #13172a;
}
.queue-head { display: flex; align-items: center; gap: 8px; color: #9fa3b8; font-size: 11px; }
.queue-summary { color: #676d7e; font-size: 10.5px; }
.queue-list { display: flex; flex-direction: column; gap: 4px; max-height: 152px; overflow-y: auto; margin-top: 6px; }
.queue-item {
  display: flex; align-items: center; gap: 7px; min-height: 27px;
  padding: 2px 4px 2px 5px; border-radius: 6px; background: #1a2033;
  user-select: none;
}
.queue-item[draggable="true"] { cursor: grab; }
.queue-item.dragging { opacity: .4; }
.queue-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.queue-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.queue-grip {
  width: 11px; flex: 0 0 11px; color: #5b606f; font-size: 10px;
  line-height: 1; text-align: center; cursor: grab;
}
.queue-engine {
  flex: 0 0 auto; width: 13px; height: 13px; border-radius: 4px;
  display: grid; place-items: center; font: 8px var(--mono);
  color: #b9c2e8; background: #2a3150; border: 1px solid #3a4368;
}
.queue-index {
  width: 18px; flex: 0 0 18px; text-align: center; color: #6e738b;
  font: 10px var(--mono);
}
.queue-text {
  flex: 1; min-width: 0; color: #b9bdce; font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.queue-move {
  width: 22px; height: 22px; border: 1px solid #303a5e; border-radius: 5px;
  background: transparent; color: #9aa2ba; font-size: 12px; line-height: 1;
}
.queue-move:hover:not(:disabled) { border-color: #3d4675; color: var(--accent-strong); background: var(--accent-soft); }
.queue-move:disabled { opacity: .25; }
.queue-move.queue-remove:hover { border-color: #6b3b45; color: #f29a9a; background: rgba(224,108,98,.1); }
.queue-move.queue-send { border-color: #3d4675; color: var(--accent-strong); background: var(--accent-soft); }
.queue-move.queue-send:hover:not(:disabled) { border-color: #7284ff; color: #dbe1ff; background: rgba(84,108,253,.22); }
.queue-edit-textarea {
  width: 100%; min-height: 120px; resize: vertical; margin: 4px 0 10px;
  padding: 9px 10px; border: 1px solid #303a5e; border-radius: 8px;
  background: #111522; color: var(--text); font: 12.5px/1.55 var(--sans);
  outline: none;
}
.queue-edit-textarea:focus { border-color: #3d4675; }
.queue-hint { margin-top: 5px; color: #5f6780; font-size: 10px; }
.queue-force {
  margin-left: auto; height: 24px; padding: 0 9px; border-radius: 6px;
  border: 1px solid #3c4675; background: var(--accent-soft); color: var(--accent-strong);
  font-size: 10.5px;
}
.queue-force:hover { background: #2b3354; border-color: var(--accent); }
.queue-panel.paused { border-color: #8a7440; }
.composer {
  max-width: 880px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: #191e30; border: 1px solid #3a4368; border-radius: 14px;
  padding: 8px 8px 8px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: #343c5e; box-shadow: 0 0 0 3px rgba(84,108,253,.12), 0 8px 30px rgba(0,0,0,.2); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  min-height: 36px; max-height: 190px; padding: 7px 0 5px; line-height: 1.55; font-size: 13.5px;
}
.composer textarea::placeholder { color: #5e6474; }
.composer-actions { display: flex; align-items: center; gap: 5px; }
.model-picker-btn {
  height: 30px; display: inline-flex; align-items: center; gap: 5px;
  padding: 0 8px; border: 1px solid #3a4368; border-radius: 8px;
  background: #111522; color: #9aa3bd; font: 10.5px var(--mono);
  cursor: pointer; white-space: nowrap;
}
.model-picker-btn:hover { border-color: var(--accent); color: #e8ebf5; }
.model-picker-btn:disabled { opacity: .45; cursor: not-allowed; }
.model-picker-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.model-picker-effort { color: var(--accent-strong); font-weight: 650; }
.model-picker-engine { color: #aeb6cc; }
.model-picker-sep { color: #5d6684; }
.model-picker-panel {
  position: fixed; z-index: 90; width: 340px; padding: 14px 14px 12px;
  border: 1px solid #3d4675; border-radius: 16px;
  background: #171c2f; color: #e5e9f6;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(84,108,253,.08) inset;
  --mp-pct: 75%;
}
.model-picker-panel.hidden { display: none; }
.mp-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 26px; margin-bottom: 10px; }
.mp-bolt { position: absolute; left: 2px; width: 17px; height: 17px; fill: none; stroke: #8f9ab9; stroke-width: 1.4; }
.mp-title { font: 600 15px var(--sans); color: #dbe2ff; letter-spacing: .2px; }
.mp-reset {
  position: absolute; right: 0; width: 26px; height: 26px; border: 0; border-radius: 7px;
  background: transparent; color: #8f9ab9; font-size: 16px; line-height: 1; cursor: pointer;
}
.mp-reset:hover { color: #fff; background: #252c47; }
.mp-models { display: flex; gap: 6px; padding: 4px; margin-bottom: 13px; background: #101526; border: 1px solid #2a3150; border-radius: 10px; }
.mp-models button {
  flex: 1; height: 30px; border: 0; border-radius: 7px; background: transparent;
  color: #8e97b2; font: 11px var(--mono); cursor: pointer;
}
.mp-models button:hover { color: #dce3ff; }
.mp-models button.active { background: #2b3560; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.22); }
.mp-slider-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 2px; font-size: 10.5px; color: #7f89a8; }
.mp-slider-head #mpEffortLabel { color: var(--accent-strong); font-weight: 600; }
.mp-range-wrap { position: relative; height: 30px; display: flex; align-items: center; }
.mp-ticks { position: absolute; left: 9px; right: 9px; top: 50%; transform: translateY(-50%); display: flex; justify-content: space-between; pointer-events: none; z-index: 3; }
.mp-ticks i { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.82); box-shadow: 0 0 0 1px rgba(20,26,45,.12); }
.mp-range { position: relative; z-index: 2; width: 100%; height: 30px; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.mp-range::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--mp-pct), #d5dbea var(--mp-pct), #d5dbea 100%);
}
.mp-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -7px;
  border-radius: 50%; background: #fff; border: 1px solid #cfd6e8;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.mp-footer { display: flex; justify-content: flex-end; gap: 7px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #262d49; }
.mp-btn { height: 30px; padding: 0 13px; border: 1px solid #343c5e; border-radius: 8px; background: transparent; color: #aab2c8; font: 11px var(--sans); cursor: pointer; }
.mp-btn:hover { border-color: #4b5682; color: #fff; }
.mp-apply { background: var(--accent); border-color: var(--accent); color: #fff; }
.mp-apply:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.engine-select {
  height: 30px; max-width: 108px; padding: 0 6px; border: 1px solid #3a4368;
  border-radius: 7px; background: #111522; color: #c4cbe2;
  font: 10.5px var(--mono); outline: none; cursor: pointer;
}
.engine-select:hover { border-color: var(--accent); color: #fff; }
.effort-control {
  width: 118px; flex: 0 0 118px; height: 34px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; --effort-pct: 75%;
}
.effort-label {
  height: 12px; line-height: 12px; font: 10px var(--sans);
  color: var(--accent-strong); white-space: nowrap;
}
.effort-track-wrap { position: relative; width: 100%; height: 16px; display: flex; align-items: center; }
.effort-ticks {
  position: absolute; left: 8px; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; justify-content: space-between; pointer-events: none; z-index: 1;
}
.effort-ticks i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.55); }
.effort-range {
  position: relative; z-index: 2; width: 100%; height: 16px; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.effort-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--effort-pct), #d5dbea var(--effort-pct), #d5dbea 100%);
}
.effort-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -5px;
  border-radius: 50%; background: #ffffff; border: 1px solid #cfd6e8;
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.effort-range:disabled { opacity: .4; cursor: not-allowed; }
.engine-select:disabled { opacity: .45; cursor: not-allowed; }
.btn-attach {
  width: 32px; height: 36px; border: 0; background: transparent; color: #777d8f;
  border-radius: 8px; display: grid; place-items: center;
}
.btn-attach:hover { color: var(--accent-strong); background: var(--accent-soft); }
.btn-attach:disabled { opacity: .35; }
.btn-attach svg { width: 17px; height: 17px; }
.attachment-bar {
  max-width: 880px; margin: 0 auto 8px; padding: 8px 10px;
  border: 1px solid #2e3658; border-radius: 10px; background: #13172a;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.attachment-bar .upload-status { width: 100%; color: #b9c0d8; font-size: 11px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 6px 4px 8px; border: 1px solid #303a5e; border-radius: 7px;
  background: #191b21; color: #bcbfce; font-size: 11px;
}
.attachment-chip.image-chip {
  padding: 4px 6px 4px 4px; cursor: zoom-in; min-height: 50px;
}
.attachment-thumb {
  width: 42px; height: 42px; flex: 0 0 42px; object-fit: cover;
  border-radius: 6px; border: 1px solid #303a5e; background: #111522; display: block;
}
.attachment-chip .name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip .size { color: #737b96; font-size: 10px; }
.modal.wide.image-modal {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 20px;
}
.image-preview {
  width: 100%; max-width: 100%; overflow: auto; display: block;
  margin: 10px auto 16px; padding: 8px; border: 1px solid #2e3658; border-radius: 10px; background: #111522;
  scrollbar-width: thin; scrollbar-color: #46527a #111522;
}
.image-preview.dragging, .image-preview.dragging img { cursor: grabbing; user-select: none; }
.image-preview::-webkit-scrollbar { width: 10px; height: 10px; }
.image-preview::-webkit-scrollbar-track { background: #111522; }
.image-preview::-webkit-scrollbar-thumb { background: #3b476b; border: 2px solid #111522; border-radius: 6px; }
.image-preview-inner {
  width: max-content; min-width: 100%; min-height: 100%;
  display: flex; align-items: flex-start; justify-content: center;
}
.image-preview img {
  display: block; width: auto; height: auto; flex: 0 0 auto;
  cursor: grab; object-fit: contain;
}
.attachment-chip .remove {
  width: 18px; height: 18px; border: 0; border-radius: 4px; background: transparent;
  color: #777d90; font-size: 13px; line-height: 1;
}
.attachment-chip .remove:hover { background: rgba(224,108,98,.12); color: #e09a92; }
.attachment-clear { border: 0; background: transparent; color: #6e7487; font-size: 10.5px; margin-left: auto; }
.attachment-clear:hover { color: var(--text); }
.btn-send, .btn-stop {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid #313858;
  display: grid; place-items: center; background: var(--accent); color: #ffffff;
}
.btn-send svg { width: 19px; height: 19px; stroke-width: 2; }
.btn-send:hover { background: var(--accent-strong); }
.btn-send:disabled { background: #242631; border-color: #2c2f3c; color: #5a5f6f; }
.btn-stop { background: #1b1d2a; border-color: #4c2f2a; color: #e08a80; font-size: 11px; }
.btn-stop:hover { background: #3a221e; }
.composer-hint { max-width: 880px; margin: 6px auto 0; color: #4f5360; font-size: 10.5px; text-align: center; }
kbd { font-family: var(--sans); font-size: 9.5px; border: 1px solid #2b2e35; background: #1a1916; border-radius: 4px; padding: 0 4px; color: #767c8e; }

/* ---------- files ---------- */
.files-view { flex: 1; min-height: 0; overflow-y: auto; padding: 20px clamp(20px, 4vw, 48px) 40px; }
.files-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.files-tabs { display: flex; gap: 4px; padding: 3px; background: #151a2c; border: 1px solid var(--border-soft); border-radius: 9px; }
.files-tab { height: 28px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12.3px; font-weight: 600; }
.files-tab.active { background: #262d49; color: var(--text); }
.files-actions { display: flex; gap: 8px; }
.artifacts-summary { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.artifacts-summary b { color: var(--text); font-weight: 600; }
.artifacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.artifact-card {
  background: #13172a; border: 1px solid #2a3150; border-radius: 11px; overflow: hidden;
  display: flex; flex-direction: column; min-height: 100px;
}
.artifact-card:hover { border-color: #313445; background: #15161b; }
.artifact-thumb { height: 132px; background: #111522; display: grid; place-items: center; overflow: hidden; }
.artifact-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.artifact-video video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.artifact-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: #1e2338; color: #7480bc; font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.artifact-info { padding: 10px 11px 11px; display: flex; gap: 9px; align-items: center; }
.artifact-name { flex: 1; min-width: 0; font-size: 12.2px; color: #d8def0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-meta { color: #6b7390; font-size: 10px; margin-top: 2px; }
.artifact-download { width: 28px; height: 28px; flex: 0 0 28px; border: 1px solid #2c2d36; border-radius: 7px; background: #1b1c20; color: #979caa; display: grid; place-items: center; }
.artifact-download:hover { color: var(--accent); border-color: #343c5e; }
.artifact-download svg { width: 14px; height: 14px; }
.artifact-view {
  height: 28px; flex: 0 0 auto; padding: 0 9px;
  border: 1px solid #2b3354; border-radius: 7px;
  background: #1e2338; color: var(--accent-strong);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.artifact-view:hover { background: #20263c; border-color: #3c4675; color: #a3aee9; }
.file-row .artifact-view { height: 26px; padding: 0 8px; font-size: 10.5px; }
.btn-secondary.view-ready { color: var(--accent-strong); border-color: #2b3354; background: #1e2338; }
.btn-secondary.view-ready:hover { background: #20263c; border-color: #3c4675; }
.empty-files { text-align: center; padding: 64px 20px; color: var(--muted-2); border: 1px dashed #282b32; border-radius: 12px; }
.empty-files h3 { color: #b7bac8; margin: 0 0 7px; font-size: 15px; }
.empty-files p { margin: 0; font-size: 12px; }
.browse-pane { max-width: 1000px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.breadcrumb button { border: 0; background: transparent; color: var(--muted); padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.breadcrumb button:hover { color: var(--text); background: var(--panel-2); }
.breadcrumb .sep { color: #444854; }
.file-list { border: 1px solid #25272d; border-radius: 10px; overflow: hidden; background: #151412; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #1d1e23; }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: #191e30; }
.file-glyph { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: #1c1e23; color: #8f93a7; flex: 0 0 24px; font-size: 9px; font-weight: 700; }
.file-glyph.dir { color: var(--accent); }
.file-name { flex: 1; min-width: 0; font-size: 12.5px; color: #c5c8d5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file-name:hover { color: var(--accent-strong); }
.file-size, .file-date { color: #6b7390; font-size: 10.5px; white-space: nowrap; }
.file-date { width: 100px; text-align: right; }
.file-row .artifact-download { width: 26px; height: 26px; flex-basis: 26px; }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto; background: #191e30;
  border: 1px solid #3a4368; border-radius: 15px; box-shadow: var(--shadow); padding: 22px;
}
.modal.wide { width: min(680px, 100%); }
.modal h2 { margin: 0 0 5px; font-size: 18px; font-weight: 650; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.modal label { display: block; color: var(--muted); font-size: 11.5px; margin: 13px 0 6px; font-weight: 600; }
.modal input[type=text], .modal input[type=password] {
  width: 100%; height: 40px; background: #0f1220; border: 1px solid #303a5e; border-radius: 8px;
  padding: 0 11px; outline: 0; color: var(--text);
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(84,108,253,.14); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-error { color: #e29a9a; font-size: 12px; margin-top: 10px; }
.settings-grid { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; font-size: 12.5px; margin: 4px 0 18px; }
.settings-grid .k { color: var(--muted-2); }
.settings-grid .v { color: #c7cad7; overflow-wrap: anywhere; }
.settings-section { border-top: 1px solid var(--border-soft); margin-top: 18px; padding-top: 4px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; border: 1px solid #303a5e; color: var(--muted); }
.badge.good { color: var(--green); border-color: rgba(112,196,138,.25); background: rgba(112,196,138,.06); }
.badge.warn { color: var(--yellow); border-color: rgba(215,179,95,.25); background: rgba(215,179,95,.06); }
.drop-overlay {
  position: fixed; inset: 0; z-index: 180; background: rgba(10,10,9,.72);
  backdrop-filter: blur(3px); display: grid; place-items: center; pointer-events: none;
}
.drop-card {
  width: min(440px, 86vw); padding: 34px 28px; text-align: center;
  border: 2px dashed #5262b2; border-radius: 18px;
  background: rgba(27,26,22,.96); box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.drop-card svg { width: 42px; height: 42px; color: var(--accent); stroke-width: 1.6; }
.drop-card h2 { margin: 14px 0 6px; font-size: 20px; font-weight: 650; }
.drop-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px); z-index: 200;
  background: #1d1f26; border: 1px solid #323545; color: #d6d9e8; padding: 9px 15px;
  border-radius: 9px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: .2s opacity, .2s transform; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(224,108,98,.4); color: #f29a9a; }

.sidebar-backdrop { display: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .sidebar-resizer { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; max-width: 86vw; transform: translateX(-104%); transition: transform .2s ease; box-shadow: 14px 0 40px rgba(0,0,0,.35); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; height: 62px; flex-basis: 62px; }
  .project-path { max-width: 58vw; }
  .chat-header { padding: 0 16px; }
  .messages { padding: 20px 14px; }
  .composer-wrap { padding: 8px 12px 10px; }
  .files-view { padding: 16px 14px 30px; }
  .view-tab { padding: 0 10px; }
  .file-date { display: none; }
}
@media (max-width: 560px) {
  .project-heading h1 { font-size: 15px; }
  .project-path { display: none; }
  .view-tabs { display: none; }
  .chat-title { max-width: 40vw; }
  .suggestions { display: none; }
  .empty-state h2 { font-size: 19px; }
  .composer-hint { display: none; }
  .files-actions .btn { padding: 0 9px; font-size: 11px; }
}


/* ---------- light theme ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f6f2;
  --bg-soft: #fffefb;
  --panel: #ffffff;
  --panel-2: #f0eee8;
  --panel-3: #e8e5dc;
  --border: #d8d4ca;
  --border-soft: #e7e3da;
  --text: #292722;
  --muted: #6f6a60;
  --muted-2: #928d82;
  --accent: #4f66e8;
  --accent-strong: #3b51c9;
  --accent-soft: rgba(79, 102, 232, .10);
  --green: #2e8b57;
  --red: #c74a44;
  --yellow: #a77a20;
  --shadow: 0 18px 60px rgba(65, 58, 46, .14);
}
html[data-theme="light"] body,
html[data-theme="light"] .app,
html[data-theme="light"] .main,
html[data-theme="light"] .chat-view,
html[data-theme="light"] .files-view { background: var(--bg); color: var(--text); }
html[data-theme="light"] .sidebar { background: #efede6; border-right-color: #ddd9cf; }
html[data-theme="light"] .sidebar-resizer::after { background: var(--accent); }
html[data-theme="light"] .project-row { color: #4b473f; }
html[data-theme="light"] .project-row:hover { background: #e7e4dc; }
html[data-theme="light"] .project-block.active .project-row { background: #e1ddd3; border-color: #d7d2c7; color: #24221d; }
html[data-theme="light"] .proj-icon { background: #b5b0a4; }
html[data-theme="light"] .chat-item { color: #6d685e; }
html[data-theme="light"] .chat-item:hover { background: #e7e4dc; color: #302d27; }
html[data-theme="light"] .chat-item.active { background: #e1ddd3; color: #24221d; }
html[data-theme="light"] .chat-hover-btn { color: #8a857a; }
html[data-theme="light"] .chat-hover-btn:hover { background: #dad6cc; color: var(--accent-strong); }
html[data-theme="light"] .usage-badge { background: #f7f5ef; border-color: #dedad1; color: #6b665c; }
html[data-theme="light"] .usage-badge:hover { border-color: #c8c3b8; color: #38352f; }
html[data-theme="light"] .usage-sep { color: #b3ada1; }
html[data-theme="light"] .sidebar-section-head { color: #8a857a; }
html[data-theme="light"] .sidebar-foot { border-top-color: #ddd9cf; }
html[data-theme="light"] .side-action { color: #827d71; }
html[data-theme="light"] .side-action:hover { background: #e7e4dc; color: #2d2a24; }
html[data-theme="light"] .topbar { background: rgba(247,246,242,.97); border-bottom-color: #e4e0d7; }
html[data-theme="light"] .project-path { color: #8d887d; }
html[data-theme="light"] .view-tabs { background: #efede6; border-color: #dedad1; }
html[data-theme="light"] .view-tab { color: #777268; }
html[data-theme="light"] .view-tab.active { background: #ffffff; color: #292722; box-shadow: 0 1px 3px rgba(40,35,28,.08); }
html[data-theme="light"] .chat-header { background: #f2f0ea; border-bottom-color: #e4e0d7; }
html[data-theme="light"] .chat-kicker { color: #969185; }
html[data-theme="light"] .chat-title { color: #302d27; }
html[data-theme="light"] .chat-header .icon-btn,
html[data-theme="light"] .topbar .icon-btn { color: #777268; }
html[data-theme="light"] .chat-header .icon-btn:hover,
html[data-theme="light"] .topbar .icon-btn:hover { background: #e7e4dc; color: #292722; }
html[data-theme="light"] .user-bubble { background: #ecebe5; border-color: #dfdcd4; color: #292722; }
html[data-theme="light"] .assistant-text { color: #302e28; }
html[data-theme="light"] .assistant-text h1,
html[data-theme="light"] .assistant-text h2,
html[data-theme="light"] .assistant-text h3 { color: #1f1d18; }
html[data-theme="light"] .assistant-text a { color: #3757d2; }
html[data-theme="light"] .assistant-text code { background: #efede6; border-color: #ddd9cf; color: #8a4b2f; }
html[data-theme="light"] .assistant-text pre,
html[data-theme="light"] .md-table-wrap { background: #f2f0ea; border-color: #dedad1; }
html[data-theme="light"] .assistant-text pre code { background: transparent; color: #4b473f; }
html[data-theme="light"] .code-lang { color: #918b7f; }
html[data-theme="light"] .code-copy { background: #fbfaf6; border-color: #d8d4ca; color: #7a756a; }
html[data-theme="light"] .code-copy:hover { background: #f0eee8; color: #292722; }
html[data-theme="light"] .assistant-text th { background: #eeebe3; }
html[data-theme="light"] .assistant-text th,
html[data-theme="light"] .assistant-text td { border-color: #ddd9cf; }
html[data-theme="light"] .assistant-text blockquote { color: #6f6a60; border-left-color: #d8d4ca; }
html[data-theme="light"] .action-group summary { color: #837e72; border: 0; }
html[data-theme="light"] .action-group summary:hover { color: #403c34; }
html[data-theme="light"] .action-summary { color: #837e72; }
html[data-theme="light"] .action-chevron,
html[data-theme="light"] .action-item-chevron,
html[data-theme="light"] .thinking-chevron,
html[data-theme="light"] .plan-chevron { color: #aaa497; }
html[data-theme="light"] .action-group-body { border-left-color: #ddd9cf; }
html[data-theme="light"] .action-item { background: #f5f3ed; border-color: #dedad1; }
html[data-theme="light"] .action-item summary { background: #f5f3ed; color: #5f5b52; }
html[data-theme="light"] .action-item summary:hover { background: #efede6; color: #292722; }
html[data-theme="light"] .action-item-body { background: #fbfaf6; border-top-color: #e4e0d7; }
html[data-theme="light"] .action-item-body pre { background: #f0eee8; border-color: #ddd9cf; color: #4b473f; }
html[data-theme="light"] .action-openspec { background: transparent; }
html[data-theme="light"] .action-item-thumb { background: #f0eee8; border-color: #d8d4ca; }
html[data-theme="light"] .plan-card { background: #f7f5ef; border-color: #dedad1; }
html[data-theme="light"] .plan-card summary:hover { background: #efede6; }
html[data-theme="light"] .plan-title { color: #5f5b52; }
html[data-theme="light"] .plan-count { color: #8a857a; }
html[data-theme="light"] .plan-body { border-top-color: #e4e0d7; }
html[data-theme="light"] .plan-row { color: #4b473f; }
html[data-theme="light"] .plan-row.done { color: #8d887d; }
html[data-theme="light"] .plan-row.active { color: #292722; }
html[data-theme="light"] .thinking-title { color: #837e72; }
html[data-theme="light"] .thinking-meta { color: #999386; }
html[data-theme="light"] .thinking-body { background: #f7f5ef; border-color: #dedad1; color: #4b473f; }
html[data-theme="light"] .tool-card { background: #f7f5ef; border-color: #dedad1; }
html[data-theme="light"] .tool-card[open] { background: #f7f5ef; border-color: #d8d4ca; }
html[data-theme="light"] .tool-card summary { color: #5f5b52; }
html[data-theme="light"] .tool-card summary:hover { background: #efede6; }
html[data-theme="light"] .tool-glyph { background: #e8e5dc; color: #6f6a60; }
html[data-theme="light"] .tool-name { color: #38352e; }
html[data-theme="light"] .tool-desc { color: #8a857a; }
html[data-theme="light"] .tool-body { border-top-color: #e4e0d7; }
html[data-theme="light"] .tool-body pre { background: #f0eee8; border-color: #ddd9cf; color: #4b473f; }
html[data-theme="light"] .tool-label { color: #999386; }
html[data-theme="light"] .tool-image-grid { background: #f0eee8; border-color: #dedad1; }
html[data-theme="light"] .composer-wrap { background: linear-gradient(180deg, transparent, var(--bg) 22%); }
html[data-theme="light"] .run-bar { color: #777268; }
html[data-theme="light"] .composer { background: #ffffff; border-color: #d8d4ca; box-shadow: 0 6px 22px rgba(60,52,40,.07); }
html[data-theme="light"] .composer:focus-within { border-color: #b9b4a8; box-shadow: 0 0 0 3px rgba(79,102,232,.09), 0 6px 22px rgba(60,52,40,.08); }
html[data-theme="light"] .composer textarea::placeholder { color: #9b9589; }
html[data-theme="light"] .model-picker-btn { background: #f2f0ea; border-color: #ddd9cf; color: #6f6a60; }
html[data-theme="light"] .model-picker-btn:hover { border-color: var(--accent); color: #292722; }
html[data-theme="light"] .btn-attach { color: #8a857a; }
html[data-theme="light"] .attachment-bar { background: #f5f3ed; border-color: #dedad1; }
html[data-theme="light"] .attachment-chip { background: #ffffff; border-color: #ddd9cf; color: #5f5b52; }
html[data-theme="light"] .attachment-chip .size { color: #9b9589; }
html[data-theme="light"] .composer-hint { color: #a29c90; }
html[data-theme="light"] kbd { background: #f0eee8; border-color: #d8d4ca; color: #777268; }
html[data-theme="light"] .context-menu { background: #fbfaf6; border-color: #d8d4ca; box-shadow: 0 12px 34px rgba(60,52,40,.18); }
html[data-theme="light"] .context-menu button { color: #4b473f; }
html[data-theme="light"] .context-menu button:hover { background: #f0eee8; color: #292722; }
html[data-theme="light"] .modal-backdrop { background: rgba(47,41,33,.38); }
html[data-theme="light"] .modal { background: #fbfaf6; border-color: #d8d4ca; }
html[data-theme="light"] .modal-sub { color: #777268; }
html[data-theme="light"] .modal label { color: #777268; }
html[data-theme="light"] .modal input[type=text],
html[data-theme="light"] .modal input[type=password] { background: #ffffff; border-color: #d8d4ca; color: #292722; }
html[data-theme="light"] .settings-grid .v { color: #3b3831; }
html[data-theme="light"] .settings-grid .k { color: #8a857a; }
html[data-theme="light"] .settings-section { border-top-color: #e4e0d7; }
html[data-theme="light"] .badge { border-color: #d8d4ca; color: #777268; }
html[data-theme="light"] .files-tabs { background: #efede6; border-color: #dedad1; }
html[data-theme="light"] .files-tab { color: #777268; }
html[data-theme="light"] .files-tab.active { background: #ffffff; color: #292722; }
html[data-theme="light"] .artifact-card { background: #f7f5ef; border-color: #dedad1; }
html[data-theme="light"] .artifact-card:hover { background: #ffffff; border-color: #d8d4ca; }
html[data-theme="light"] .artifact-thumb { background: #f0eee8; }
html[data-theme="light"] .artifact-icon { background: #e8e5dc; color: #6f6a60; }
html[data-theme="light"] .artifact-name { color: #38352e; }
html[data-theme="light"] .artifact-meta { color: #999386; }
html[data-theme="light"] .artifact-download { background: #f0eee8; border-color: #d8d4ca; color: #777268; }
html[data-theme="light"] .empty-files { border-color: #d8d4ca; color: #928d82; }
html[data-theme="light"] .empty-files h3 { color: #4b473f; }
html[data-theme="light"] .file-row { border-bottom-color: #e7e3da; }
html[data-theme="light"] .file-row:hover { background: #f1efe9; }
html[data-theme="light"] .file-glyph { background: #e8e5dc; color: #777268; }
html[data-theme="light"] .file-name { color: #3b3831; }
html[data-theme="light"] .file-size,
html[data-theme="light"] .file-date { color: #999386; }
html[data-theme="light"] .notice { color: #8a857a; }
html[data-theme="light"] .error-card { background: #fdf0ed; border-color: #efc9c2; color: #a13e36; }
html[data-theme="light"] .toast { background: #ffffff; border-color: #d8d4ca; color: #38352e; box-shadow: 0 10px 30px rgba(60,52,40,.16); }
html[data-theme="light"] .toast.error { border-color: #e5b6ae; color: #a13e36; }
html[data-theme="light"] .image-preview { background: #f0eee8; border-color: #dedad1; scrollbar-color: #c8c3b8 #f0eee8; }
html[data-theme="light"] .image-preview::-webkit-scrollbar-track { background: #f0eee8; }
html[data-theme="light"] .image-preview::-webkit-scrollbar-thumb { background: #c8c3b8; border-color: #f0eee8; }
html[data-theme="light"] .theme-choice { display: flex; gap: 7px; }
.theme-choice-btn {
  height: 32px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--panel-2); color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.theme-choice-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-choice-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }



html[data-theme="light"] .model-picker-panel {
  background: #fbfaf6; color: #302d27; border-color: #d8d4ca;
  box-shadow: 0 20px 60px rgba(60,52,40,.18), 0 0 0 1px rgba(79,102,232,.05) inset;
}
html[data-theme="light"] .mp-bolt { stroke: #8a857a; }
html[data-theme="light"] .mp-title { color: #292722; }
html[data-theme="light"] .mp-reset { color: #8a857a; }
html[data-theme="light"] .mp-reset:hover { color: #292722; background: #f0eee8; }
html[data-theme="light"] .mp-models { background: #f0eee8; border-color: #ddd9cf; }
html[data-theme="light"] .mp-models button { color: #777268; }
html[data-theme="light"] .mp-models button:hover { color: #292722; }
html[data-theme="light"] .mp-models button.active { background: #ffffff; color: #292722; box-shadow: 0 1px 4px rgba(60,52,40,.10); }
html[data-theme="light"] .mp-slider-head { color: #8a857a; }
html[data-theme="light"] .mp-slider-head #mpEffortLabel { color: var(--accent-strong); }
html[data-theme="light"] .mp-ticks i { background: #ffffff; box-shadow: 0 0 0 1px rgba(60,52,40,.10); }
html[data-theme="light"] .mp-footer { border-top-color: #e4e0d7; }
html[data-theme="light"] .mp-btn { border-color: #ddd9cf; color: #6f6a60; background: #f5f3ed; }
html[data-theme="light"] .mp-btn:hover { border-color: #bdb7aa; color: #292722; }
html[data-theme="light"] .mp-apply { background: var(--accent); border-color: var(--accent); color: #ffffff; }
html[data-theme="light"] .mp-apply:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
html[data-theme="light"] .model-picker-panel .mp-range::-webkit-slider-thumb { border-color: #d8d4ca; box-shadow: 0 2px 8px rgba(60,52,40,.18); }
html[data-theme="light"] .engine-select { background: #ffffff; border-color: #ddd9cf; color: #4b473f; }


.product-name {
  color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px;
  text-decoration-thickness: 1px; cursor: pointer; font-weight: 600;
}
.product-name:hover { color: var(--accent); }

.media-hover-preview {
  position: fixed; z-index: 260; pointer-events: none; padding: 6px;
  border: 1px solid #3a4363; border-radius: 9px; background: #0d1220;
  box-shadow: 0 16px 40px rgba(0,0,0,.42);
}
.media-hover-preview img {
  display: block; width: auto; height: auto; max-width: 380px; max-height: 320px;
  border-radius: 5px; object-fit: contain;
}
html[data-theme="light"] .media-hover-preview { background: #fffefb; border-color: #d8d4ca; box-shadow: 0 16px 40px rgba(60,52,40,.2); }

html[data-theme="light"] .assistant-text .md-table thead th {
  background: #eeebe3; color: #3b3831; border-color: #ddd9cf;
}
html[data-theme="light"] .assistant-text .md-table tbody tr:nth-child(even) { background: rgba(60,52,40,.025); }
html[data-theme="light"] .assistant-text .md-table tbody tr:hover { background: rgba(79,102,232,.055); }
html[data-theme="light"] .assistant-text .md-table th,
html[data-theme="light"] .assistant-text .md-table td { border-color: #ddd9cf; }

/* ---------- inline live activity ---------- */
.run-bar { display: none !important; }
.live-activity {
  max-width: 880px; margin: 4px auto 10px; color: #9aa3bd;
  font-size: 11.5px; line-height: 1.5;
}
.live-activity:not(details) {
  display: flex; align-items: center; gap: 6px; padding: 4px 2px;
}
.live-activity summary {
  list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 4px 2px; cursor: pointer; color: #9aa3bd; user-select: none;
}
.live-activity summary::-webkit-details-marker { display: none; }
.live-activity summary:hover { color: #c8d2ed; }
.live-dots { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.live-dots i {
  display: block; width: 3px; height: 3px; border-radius: 50%;
  background: #c87958; animation: live-dot 1.2s ease-in-out infinite;
}
.live-dots i:nth-child(2) { animation-delay: .15s; }
.live-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes live-dot { 0%, 80%, 100% { opacity: .28; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-1px); } }
.live-elapsed { color: #6c7899; font: 10.5px var(--mono); flex: 0 0 auto; }
.live-sep { color: #4e566b; }
.live-label { color: #9aa3bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-chevron { color: #66728f; font-size: 15px; line-height: 1; margin-left: 1px; transform: rotate(0deg); transition: transform .12s; }
.live-activity[open] .live-chevron { transform: rotate(90deg); }
.live-activity-body {
  margin: 2px 0 8px 18px; padding: 8px 11px; border: 1px solid #28314a;
  border-radius: 8px; background: #111725; color: #aeb9d8; max-height: 260px; overflow: auto;
}
.live-activity-body pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 10.8px/1.55 var(--mono); }

html[data-theme="light"] .live-activity,
html[data-theme="light"] .live-activity summary { color: #777268; }
html[data-theme="light"] .live-dots i { background: #c87958; }
html[data-theme="light"] .live-elapsed { color: #999386; }
html[data-theme="light"] .live-sep { color: #b5afa3; }
html[data-theme="light"] .live-label { color: #6f6a60; }
html[data-theme="light"] .live-chevron { color: #aaa497; }
html[data-theme="light"] .live-activity-body { background: #f7f5ef; border-color: #dedad1; color: #4b473f; }

.context-menu button.context-danger,
.context-danger { color: #e06c62; }
.archived-chats {
  width: 100%; display: flex; align-items: center; gap: 6px;
  margin-top: 4px; padding: 6px 8px; border: 0; border-radius: 7px;
  background: transparent; color: #777f9a; font-size: 11.5px; text-align: left;
}
.archived-chats:hover { background: #181d2f; color: #c8d2ed; }
.archived-list { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 14px; }
.archived-row {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border: 1px solid #2a3150; border-radius: 8px; background: #111725;
}
.archived-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.archived-info b { color: #d8def0; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archived-info span { color: #6b7390; font-size: 10px; }
.archived-row .btn { height: 28px; padding: 0 9px; font-size: 11px; }
html[data-theme="light"] .archived-chats { color: #827d71; }
html[data-theme="light"] .archived-chats:hover { background: #e7e4dc; color: #292722; }
html[data-theme="light"] .archived-row { background: #f7f5ef; border-color: #dedad1; }
html[data-theme="light"] .archived-info b { color: #302d27; }
html[data-theme="light"] .archived-info span { color: #8a857a; }

/* 登录：默认勾选记住密码 */
.remember-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}
.remember-row input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}
