/* ===================================================================
   AI Chat — design tokens
   =================================================================== */
:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --bg: #ffffff;
  --bg-soft: #f7f7f9;
  --sidebar: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --hover: #ececf1;
  --active: #e4e4ec;
  --border: #e5e5ea;
  --border-strong: #d4d4dc;
  --text: #17171c;
  --text-2: #55555f;
  --text-3: #8b8b96;
  --accent: #5b5bd6;
  --accent-hover: #4d4dc4;
  --accent-soft: #eeeefd;
  --accent-text: #4747b8;
  --on-accent: #ffffff;
  --danger: #d4383e;
  --danger-soft: #fdeeee;
  --success: #1c9b58;
  --success-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --user-bubble: #f0f0f4;
  --code-bg: #f6f6f9;
  --code-block: #1b1b22;
  --code-block-text: #e6e6ef;
  --code-block-head: #25252e;
  --shadow-sm: 0 1px 2px rgba(16, 16, 30, .06);
  --shadow: 0 4px 16px rgba(16, 16, 30, .08), 0 1px 3px rgba(16, 16, 30, .06);
  --shadow-lg: 0 24px 64px rgba(16, 16, 30, .18), 0 4px 16px rgba(16, 16, 30, .08);
  --backdrop: rgba(18, 18, 28, .38);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sb-width: 272px;
  --panel-width: 360px;
  --content-width: 780px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181c; --bg-soft: #1d1d22; --sidebar: #131316; --surface: #212127; --surface-2: #26262d;
    --hover: #2a2a31; --active: #32323a; --border: #2d2d35; --border-strong: #3a3a44;
    --text: #ececf1; --text-2: #aeaeba; --text-3: #7c7c88;
    --accent: #7676ee; --accent-hover: #8686f3; --accent-soft: #2a2a4a; --accent-text: #a9a9ff; --on-accent: #fff;
    --danger: #f06368; --danger-soft: #3a2125; --success: #3fcf85; --success-soft: #1b3326; --warn: #e5a83b; --warn-soft: #3a2f1b;
    --user-bubble: #2a2a31; --code-bg: #2a2a31; --code-block: #111115; --code-block-head: #1c1c22;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 16px rgba(0,0,0,.4); --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
    --backdrop: rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18181c; --bg-soft: #1d1d22; --sidebar: #131316; --surface: #212127; --surface-2: #26262d;
  --hover: #2a2a31; --active: #32323a; --border: #2d2d35; --border-strong: #3a3a44;
  --text: #ececf1; --text-2: #aeaeba; --text-3: #7c7c88;
  --accent: #7676ee; --accent-hover: #8686f3; --accent-soft: #2a2a4a; --accent-text: #a9a9ff; --on-accent: #fff;
  --danger: #f06368; --danger-soft: #3a2125; --success: #3fcf85; --success-soft: #1b3326; --warn: #e5a83b; --warn-soft: #3a2f1b;
  --user-bubble: #2a2a31; --code-bg: #2a2a31; --code-block: #111115; --code-block-head: #1c1c22;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 16px rgba(0,0,0,.4); --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
  --backdrop: rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ===================================================================
   base
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
kbd {
  font-family: var(--font); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; line-height: 18px; background: var(--surface);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scroll-thin { scrollbar-width: thin; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ===================================================================
   buttons & inputs
   =================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn.soft:hover { filter: brightness(.97); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn.sm svg { width: 16px; height: 16px; }
.btn.lg { height: 44px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) var(--on-accent) transparent transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; border: none; background: transparent; color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.active { background: var(--active); color: var(--text); }

.input, .fld input, .fld select, .fld textarea, .textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .fld input:focus, .fld select:focus, .fld textarea:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fld > span, .fld-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.fld .help { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.fld textarea, .textarea { resize: vertical; min-height: 96px; line-height: 1.5; font-family: inherit; }
.fld select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b96' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }
.input-with-btn { position: relative; }
.input-with-btn input { padding-right: 42px; }
.input-with-btn .reveal { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }

/* ===================================================================
   logo
   =================================================================== */
.logo-mark {
  display: inline-block; width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(145deg, #7171ea, #4d4dc7);
  position: relative; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.logo-mark::before {
  content: ""; position: absolute; left: 27%; right: 27%; top: 35%; height: 38%;
  border: 3px solid #fff; border-bottom: none; border-radius: 50px 50px 0 0;
}
.logo-mark::after { content: ""; position: absolute; left: 50%; top: 58%; width: 6px; height: 6px; margin-left: -3px; background: #fff; border-radius: 50%; }
.logo-mark.sm { width: 26px; height: 26px; border-radius: 8px; box-shadow: none; }
.logo-mark.sm::before { border-width: 2px; }
.logo-mark.sm::after { width: 4px; height: 4px; margin-left: -2px; }

/* ===================================================================
   login
   =================================================================== */
.login {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #c05bd6 10%, transparent), transparent 60%),
    var(--bg-soft);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 36px 32px 26px; box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.login-card h1 { margin: 0; font-size: 24px; font-weight: 700; text-align: center; letter-spacing: -.01em; }
.login-sub { margin: 6px 0 22px; color: var(--text-2); text-align: center; font-size: 14px; }
.login-form { display: flex; flex-direction: column; }
.login-form .btn { margin-top: 6px; }
.login-error { color: var(--danger); font-size: 13.5px; min-height: 20px; margin: 12px 0 0; text-align: center; }
.login-foot { margin: 6px 0 0; color: var(--text-3); font-size: 12.5px; text-align: center; }
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 20px; }
.seg { flex: 1; height: 34px; border: none; background: transparent; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ===================================================================
   layout
   =================================================================== */
.app { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  width: var(--sb-width); flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 10px 10px 8px; gap: 6px; transition: margin-left .22s ease, transform .22s ease;
  z-index: 30;
}
.app.sb-collapsed .sidebar { margin-left: calc(-1 * var(--sb-width)); }
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 4px 6px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; text-decoration: none; letter-spacing: -.01em; }
.new-chat { justify-content: flex-start; width: 100%; height: 38px; background: var(--surface); box-shadow: var(--shadow-sm); }
.new-chat span { flex: 1; text-align: left; }
.new-chat kbd { opacity: 0; transition: opacity .12s; }
.new-chat:hover kbd { opacity: 1; }
.sb-search { position: relative; display: flex; align-items: center; }
.sb-search > svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.sb-search input {
  width: 100%; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  padding: 0 60px 0 34px; font-size: 14px; outline: none;
}
.sb-search input:hover { background: var(--hover); }
.sb-search input:focus { background: var(--surface); border-color: var(--border); }
.sb-search input::-webkit-search-cancel-button { display: none; }
.sb-search kbd { position: absolute; right: 8px; pointer-events: none; }
.sb-search input:focus ~ kbd, .sb-search input:not(:placeholder-shown) ~ kbd { display: none; }
.sb-nav { display: flex; flex-direction: column; }
.sb-link { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 10px; text-decoration: none; font-size: 14px; color: var(--text-2); }
.sb-link:hover { background: var(--hover); color: var(--text); }
.sb-link.active { background: var(--active); color: var(--text); font-weight: 600; }
.sb-link .count { margin-left: auto; font-size: 12px; color: var(--text-3); }

.conv-list { flex: 1; overflow-y: auto; margin: 4px -4px 0; padding: 0 4px 12px; }
.conv-group { margin-top: 14px; }
.conv-group-title { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 10px 6px; }
.conv-item {
  position: relative; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 10px;
  border-radius: 10px; font-size: 14px; color: var(--text); text-decoration: none; cursor: pointer;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--active); }
.conv-item .ci-icon { width: 15px; height: 15px; color: var(--text-3); }
.conv-item .ci-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item .ci-more { opacity: 0; }
.conv-item:hover .ci-more, .conv-item.active .ci-more, .conv-item .ci-more.open { opacity: 1; }
.conv-item input { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--accent); border-radius: 7px; padding: 0 8px; background: var(--surface); outline: none; font-size: 14px; }
.conv-empty { padding: 28px 12px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.conv-empty svg { width: 28px; height: 28px; margin-bottom: 6px; opacity: .6; }

.sb-foot { border-top: 1px solid var(--border); padding-top: 8px; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: none; background: transparent; border-radius: 12px; text-align: left; }
.user-btn:hover { background: var(--hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(145deg, #8b7cf6, #5b5bd6);
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .chev { color: var(--text-3); width: 16px; height: 16px; }

.sb-backdrop { display: none; }

.main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 12px; flex-shrink: 0; }
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.only-collapsed, .only-mobile { display: none; }
.app.sb-collapsed .only-collapsed { display: inline-flex; }

.title-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0;
  height: 34px; padding: 0 10px; border: none; background: transparent; border-radius: 9px; font-size: 15px; font-weight: 600;
}
.title-btn:hover { background: var(--hover); }
.title-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-input { height: 34px; border: 1px solid var(--accent); border-radius: 9px; padding: 0 10px; font-size: 15px; font-weight: 600; background: var(--surface); outline: none; min-width: 200px; max-width: 480px; width: 100%; }
.crumb { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--accent-text); background: var(--accent-soft); white-space: nowrap; max-width: 220px; }
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.crumb svg { width: 14px; height: 14px; }
.crumb:hover { filter: brightness(.97); }

.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
.view { min-height: 100%; }

/* ===================================================================
   dock + composer
   =================================================================== */
.dock { flex-shrink: 0; padding: 0 20px 14px; }
.dock-note { margin: 8px auto 0; max-width: var(--content-width); text-align: center; font-size: 12px; color: var(--text-3); }
.composer {
  max-width: var(--content-width); margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 22px; padding: 10px 10px 8px 14px;
  box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); }
.composer textarea {
  display: block; width: 100%; border: none; outline: none; resize: none; background: transparent;
  font-size: 15.5px; line-height: 1.55; padding: 6px 4px 8px; max-height: 280px; min-height: 30px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-bar { display: flex; align-items: center; gap: 4px; }
.composer-bar .spacer { flex: 1; }
.composer-hint { font-size: 12px; color: var(--text-3); margin-right: 8px; white-space: nowrap; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; transition: background .12s, opacity .12s, transform .06s;
}
.send-btn svg { stroke-width: 2.2; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border-strong); color: var(--surface); cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.send-btn:active:not(:disabled) { transform: scale(.95); }

.model-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; font-size: 13px; font-weight: 500; color: var(--text-2); max-width: 320px;
}
.model-pill:hover { background: var(--hover); color: var(--text); }
.model-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pill .spark { width: 15px; height: 15px; color: var(--accent); }
.model-pill .chev { width: 14px; height: 14px; flex-shrink: 0; }
.model-pill-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.model-pill-icon svg { width: 14px; height: 14px; }
.model-pill-icon.ssh svg { color: #0284c7; }
.model-pill-icon.cli svg { color: #d97706; }
.model-pill-icon.api svg { color: var(--text-3); }

.mode-badge {
  display: inline-flex; align-items: center; gap: 3.5px; font-size: 10.5px; font-weight: 600;
  padding: 1.5px 6px; border-radius: 999px; letter-spacing: 0.02em; line-height: 1.3;
  white-space: nowrap; flex-shrink: 0; margin-left: 2px;
}
.mode-badge svg, .mode-tag svg { width: 11.5px; height: 11.5px; stroke-width: 2.2; flex-shrink: 0; }
.mode-badge.ssh, .mode-tag.ssh {
  background: rgba(14, 165, 233, 0.12); color: #0284c7; border: 1px solid rgba(14, 165, 233, 0.3);
}
.mode-badge.cli, .mode-tag.cli {
  background: rgba(245, 158, 11, 0.14); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3);
}
.mode-badge.api, .mode-tag.api {
  background: rgba(100, 116, 139, 0.1); color: var(--text-2); border: 1px solid rgba(100, 116, 139, 0.2);
}
.mode-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px; line-height: 1.3; flex-shrink: 0;
}
.mi-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.project-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 500; max-width: 240px;
}
.project-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-chip svg { width: 15px; height: 15px; }
.project-chip button { border: none; background: transparent; color: inherit; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.project-chip button:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.project-chip button svg { width: 13px; height: 13px; }

.composer-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 8px; }
.file-card {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); max-width: 260px;
}
.file-card .fc-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-card .fc-icon svg { width: 18px; height: 18px; }
.file-card .fc-meta { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.file-card .fc-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fc-sub { font-size: 11.5px; color: var(--text-3); }
.file-card .fc-sub.warn { color: var(--warn); }
.file-card.clickable { cursor: pointer; }
.file-card.clickable:hover { border-color: var(--border-strong); }

/* home view: composer sits in the middle of the page */
.main.is-home .dock { display: none; }
.home {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px 48px;
}
.home-inner { width: 100%; max-width: var(--content-width); }
.home h1 { font-size: 30px; font-weight: 650; letter-spacing: -.02em; text-align: center; margin: 0 0 6px; }
.home .home-sub { text-align: center; color: var(--text-2); margin: 0 0 26px; }
.home-slot .composer { box-shadow: var(--shadow-lg); }
.home-slot .composer, .project-slot .composer { max-width: none; }
.home-slot .composer textarea { min-height: 56px; }
.home-section { margin-top: 30px; }
.home-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.home-section-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.home-section-head a { font-size: 13px; color: var(--accent-text); text-decoration: none; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.quick-card {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); transition: border-color .12s, background .12s, transform .12s;
}
.quick-card:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.quick-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.quick-card .qc-body { min-width: 0; }
.quick-card .qc-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-card .qc-sub { font-size: 12.5px; color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.proj-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
}
.proj-icon.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }

/* ===================================================================
   messages
   =================================================================== */
.thread { max-width: var(--content-width); margin: 0 auto; padding: 8px 20px 32px; }
.msg { position: relative; margin: 0 0 26px; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  max-width: 85%; background: var(--user-bubble); border-radius: 20px 20px 6px 20px; padding: 10px 16px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg-user .msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 8px; max-width: 85%; }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .12s; min-height: 28px; align-items: center; }
.msg:hover .msg-actions, .msg-actions:focus-within, .msg.last .msg-actions { opacity: 1; }
.msg-actions .time { font-size: 12px; color: var(--text-3); margin: 0 6px; }
.msg-assistant .msg-actions { margin-left: -6px; }

.msg-assistant .content { word-wrap: break-word; overflow-wrap: anywhere; }
.msg-error .content {
  display: flex; gap: 10px; align-items: flex-start; background: var(--danger-soft); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); border-radius: 12px; padding: 10px 14px; font-size: 14px;
}
.msg-error .content svg { margin-top: 2px; }
.msg-stopped { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

.edit-box { width: 85%; max-width: 100%; background: var(--surface); border: 1px solid var(--accent); border-radius: 16px; padding: 10px 12px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); }
.edit-box textarea { width: 100%; border: none; outline: none; resize: none; background: transparent; font-size: 15px; line-height: 1.55; min-height: 60px; max-height: 360px; }
.edit-box .edit-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 6px; }
.edit-box .edit-actions .note { flex: 1; font-size: 12px; color: var(--text-3); }

.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 14px; padding: 4px 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .35; animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
.streaming-caret::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; background: var(--accent); border-radius: 2px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* delegation / tool cards */
.tool-card { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); overflow: hidden; }
.tool-card summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary:hover { color: var(--text); }
.tool-card summary .tc-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.tool-card summary .tc-icon svg { width: 15px; height: 15px; }
.tool-card summary b { color: var(--text); font-weight: 600; }
.tool-card summary .chev { margin-left: auto; width: 16px; height: 16px; transition: transform .15s; }
.tool-card[open] summary .chev { transform: rotate(180deg); }
.tool-card .tc-body { padding: 4px 14px 12px 48px; font-size: 14px; }
.tool-card.error summary .tc-icon { background: var(--danger-soft); color: var(--danger); }

/* markdown */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 22px 0 10px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 26px; }
.md li { margin: 5px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md li.task { list-style: none; margin-left: -22px; }
.md li.task input { margin-right: 8px; accent-color: var(--accent); }
.md strong { font-weight: 650; }
.md a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent); }
.md a:hover { text-decoration-color: currentColor; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.md blockquote { margin: 0 0 14px; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.md del { color: var(--text-3); }
.md .table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: none; }
.code-block { margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: var(--code-block); color: var(--code-block-text); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 6px 0 14px; background: var(--code-block-head); font-size: 12px; color: #a3a3b5; font-family: var(--mono); }
.code-head button { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: #a3a3b5; font-size: 12px; height: 28px; padding: 0 8px; border-radius: 6px; font-family: var(--font); }
.code-head button:hover { background: rgba(255,255,255,.08); color: #fff; }
.code-head button svg { width: 14px; height: 14px; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.code-block code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }
.tok-k { color: #c792ea; } .tok-s { color: #c3e88d; } .tok-c { color: #6f7390; font-style: italic; } .tok-n { color: #f78c6c; }

/* scroll to bottom */
.to-bottom {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 5;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.to-bottom:hover { color: var(--text); }

/* drop overlay */
.drop-overlay { position: absolute; inset: 8px; z-index: 40; border: 2px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay div { text-align: center; color: var(--accent-text); font-weight: 600; }
.drop-overlay svg { width: 40px; height: 40px; }

/* ===================================================================
   pages (projects)
   =================================================================== */
.page { max-width: 1040px; margin: 0 auto; padding: 12px 28px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.search-input { position: relative; flex: 1; max-width: 360px; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search-input input { padding-left: 36px; height: 38px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); transition: border-color .12s, box-shadow .15s, transform .15s; cursor: pointer; min-height: 170px;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-title { font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc { font-size: 13.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; white-space: pre-line; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .card-menu { position: absolute; top: 10px; right: 10px; opacity: 0; }
.card:hover .card-menu, .card .card-menu.open { opacity: 1; }
.card.new-card { align-items: center; justify-content: center; border-style: dashed; color: var(--text-2); background: transparent; }
.card.new-card:hover { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.card.new-card svg { width: 26px; height: 26px; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge svg { width: 13px; height: 13px; }

.empty {
  text-align: center; padding: 56px 20px; color: var(--text-2); border: 1px dashed var(--border-strong); border-radius: 18px;
}
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
.empty p { margin: 0 auto 18px; max-width: 420px; font-size: 14px; }

.project-hero { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 20px; }
.project-hero h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.project-hero .hero-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.project-hero .hero-actions { margin-left: auto; display: flex; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--text-2); text-decoration: none; margin: 4px 0 12px; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }
.instr-card { border: 1px solid var(--border); border-radius: 14px; background: var(--bg-soft); padding: 14px 16px; margin-bottom: 22px; }
.instr-card .ic-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.instr-card .ic-text { font-size: 14px; white-space: pre-wrap; color: var(--text); max-height: 7.5em; overflow: hidden; position: relative; }
.instr-card .ic-text.clamped::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.5em; background: linear-gradient(transparent, var(--bg-soft)); }
.instr-card .ic-text.expanded { max-height: none; }
.instr-card .ic-text.expanded::after { display: none; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent-text); font-size: 13px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.project-slot { margin-bottom: 28px; }
.project-slot .composer textarea { min-height: 48px; }
.list { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-soft); }
.list-row .lr-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .lr-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.list-row svg { color: var(--text-3); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }

/* ===================================================================
   side panel (chat parameters)
   =================================================================== */
.panel {
  width: 0; flex-shrink: 0; overflow: hidden; background: var(--bg-soft); border-left: 1px solid transparent;
  display: flex; flex-direction: column; transition: width .22s ease, border-color .22s;
}
.app.panel-open .panel { width: var(--panel-width); border-left-color: var(--border); }
.panel-head { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 10px 0 20px; flex-shrink: 0; min-width: var(--panel-width); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 20px 28px; min-width: var(--panel-width); }
.p-sec { padding: 16px 0; border-bottom: 1px solid var(--border); }
.p-sec:last-child { border-bottom: none; }
.p-sec h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.p-sec h3 svg { width: 16px; height: 16px; color: var(--text-3); }
.p-sec .p-hint { font-size: 12.5px; color: var(--text-3); margin: 0 0 10px; }
.p-sec .textarea { min-height: 160px; font-size: 13.5px; background: var(--surface); }
.p-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.p-row .spacer { flex: 1; }
.p-model { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; text-align: left; }
.p-model:hover { border-color: var(--border-strong); }
.p-model .pm-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.p-model .pm-meta { flex: 1; min-width: 0; }
.p-model .pm-name { font-weight: 600; font-size: 14px; }
.p-model .pm-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.agent-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.agent-row .ar-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.agent-row .ar-icon svg { width: 16px; height: 16px; }
.agent-row .ar-meta { flex: 1; min-width: 0; }
.agent-row .ar-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-row .ar-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-3); font-size: 13px; }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); display: inline-block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }

/* ===================================================================
   popovers / menus
   =================================================================== */
.popover {
  position: fixed; z-index: 100; min-width: 200px; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border: none; background: none;
  border-radius: 9px; font-size: 14px; text-align: left; color: var(--text);
}
.menu-item:hover, .menu-item.focus { background: var(--hover); }
.menu-item svg { width: 17px; height: 17px; color: var(--text-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }
.menu-item .mi-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.menu-item .mi-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-check { color: var(--accent); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 10px 4px; }
.menu-search { padding: 2px 2px 6px; }
.menu-search input { height: 34px; font-size: 13.5px; }
.menu-scroll { max-height: 320px; overflow-y: auto; }
.menu-empty { padding: 12px; text-align: center; color: var(--text-3); font-size: 13px; }
.theme-switch { display: flex; gap: 4px; padding: 4px; margin: 2px 4px 4px; background: var(--surface-2); border-radius: 10px; }
.theme-switch button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border: none; background: transparent; border-radius: 7px; font-size: 12.5px; color: var(--text-2); }
.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.usage { padding: 6px 10px 8px; }
.usage-row { margin: 6px 0 10px; }
.usage-row .ur-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.usage-row .ur-head b { color: var(--text); font-weight: 600; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar.warn i { background: var(--warn); }
.bar.danger i { background: var(--danger); }

/* ===================================================================
   modals
   =================================================================== */
.modal-wrap { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--backdrop); animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 460px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { max-width: 640px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 6px 24px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 650; flex: 1; }
.modal-head p { margin: 4px 0 0; font-size: 13.5px; color: var(--text-2); }
.modal-body { padding: 12px 24px 8px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 20px; }
.modal-foot .left { margin-right: auto; }
.modal pre.preview { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-height: 60vh; overflow: auto; margin: 0; }
.counter { font-size: 12px; color: var(--text-3); text-align: right; margin-top: -8px; margin-bottom: 10px; }

/* ===================================================================
   toasts
   =================================================================== */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; max-width: min(520px, calc(100vw - 32px));
}
.toast svg { width: 17px; height: 17px; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

/* skeleton */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--hover), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===================================================================
   responsive
   =================================================================== */
@media (max-width: 1180px) {
  .app.panel-open .panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 60; box-shadow: var(--shadow-lg); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); margin-left: 0 !important; box-shadow: var(--shadow-lg); }
  .app.sb-mobile-open .sidebar { transform: none; }
  .app.sb-mobile-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: var(--backdrop); }
  .only-mobile { display: inline-flex; }
  .app.sb-collapsed .only-collapsed { display: none; }
  #sb-collapse { display: none; }
  .composer-hint { display: none; }
  .dock { padding: 0 10px 10px; }
  .dock-note { display: none; }
  .thread { padding: 4px 14px 24px; }
  .msg-user .bubble, .edit-box { max-width: 92%; width: auto; }
  .page { padding: 8px 16px 40px; }
  .page-head h1 { font-size: 24px; }
  .home h1 { font-size: 24px; }
  .project-hero { flex-wrap: wrap; }
  .project-hero h1 { font-size: 22px; }
  .project-hero .hero-actions { margin-left: 0; order: 3; width: 100%; }
  .project-hero .hero-meta .badge { max-width: 100%; }
  .app.panel-open .panel { width: 100%; }
  .panel-head, .panel-body { min-width: 0; }
  .msg-actions { opacity: 1; }
  .conv-item .ci-more { opacity: 1; }
  .card .card-menu { opacity: 1; }
  .model-pill { max-width: 170px; }
  .kbd-hide { display: none; }
  .new-chat kbd, .sb-search kbd { display: none; }
  .to-bottom { bottom: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* switch (toggle) */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; margin: 8px 0 4px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); flex-shrink: 0; transition: background .15s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .sw-text b { display: block; font-weight: 600; font-size: 14px; }
.switch .sw-text span { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.45; margin-top: 2px; }
.stateless-chip { border: none; cursor: pointer; font-family: inherit; }

/* separator between independent tasks in "each message is separate" chats */
.task-sep { display: flex; align-items: center; gap: 12px; margin: 6px 0 26px; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.task-sep::before, .task-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.menu-version { font-size: 11.5px; color: var(--text-3); padding: 4px 10px 2px; font-variant-numeric: tabular-nums; }

/* ===================================================================
   documents projects
   =================================================================== */
.docs-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; font-size: 13px; font-weight: 500; color: var(--text-2);
}
.docs-btn:hover { background: var(--hover); color: var(--text); }
.docs-btn svg { width: 15px; height: 15px; color: var(--accent); }

.doc-ref {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; margin: 0 1px; vertical-align: 1px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 6px;
  background: var(--accent-soft); color: var(--accent-text); font: 600 12.5px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.doc-ref svg { width: 12px; height: 12px; }
.doc-ref:hover { background: color-mix(in srgb, var(--accent) 18%, var(--accent-soft)); }
.doc-ref.missing { opacity: .6; border-style: dashed; }
.msg-user .bubble .doc-ref { background: var(--surface); }

.docs-section { margin: 4px 0 30px; }
.docs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.docs-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 16px; margin-bottom: 12px;
  border: 2px dashed var(--border-strong); border-radius: 16px; color: var(--text-2); font-size: 14px; transition: border-color .12s, background .12s;
}
.docs-drop > svg { width: 28px; height: 28px; color: var(--accent); }
.docs-drop.slim { flex-direction: row; justify-content: center; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
.docs-drop.slim > svg { width: 18px; height: 18px; }
.docs-drop.slim .muted { flex-basis: 100%; font-size: 12px; }
.docs-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.doc-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.doc-list.compact { border: none; background: none; gap: 6px; margin-bottom: 4px; }
.doc-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--bg-soft); }
.doc-row.compact { padding: 8px 6px 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); align-items: center; }
.doc-num { flex-shrink: 0; min-width: 34px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font: 700 12px/22px var(--font); text-align: center; font-variant-numeric: tabular-nums; }
.doc-row:not(.compact) .doc-num { margin-top: 7px; }
.doc-ico { flex-shrink: 0; width: 34px; height: 38px; border-radius: 7px; color: #fff; font: 800 9.5px/38px var(--font); text-align: center; letter-spacing: .02em; }
.doc-row.compact .doc-ico { width: 28px; height: 32px; line-height: 32px; font-size: 8.5px; }
.doc-body { flex: 1; min-width: 0; }
.doc-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.doc-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.doc-row.compact .doc-name { font-size: 13.5px; }
.doc-note { font-size: 13px; color: var(--accent-text); }
.doc-meta { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.doc-summary { font-size: 13.5px; color: var(--text-2); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-summary.muted { display: flex; align-items: center; gap: 8px; }
.doc-warn { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--warn); margin-top: 6px; }
.doc-warn svg { width: 15px; height: 15px; margin-top: 2px; }
.doc-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.doc-row:not(.compact) .doc-actions { margin-top: 4px; }
.doc-row .doc-actions .btn { opacity: 0; transition: opacity .12s; }
.doc-row:hover .doc-actions .btn, .doc-row:focus-within .doc-actions .btn { opacity: 1; }
.docs-budget { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 12.5px; color: var(--text-3); }
.docs-budget svg { width: 15px; height: 15px; margin-top: 1px; color: var(--success); }
.docs-budget.over svg { color: var(--warn); }
.doc-preview-summary { font-size: 14px; background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.doc-picker .doc-num { margin-top: 1px; }
.doc-pick { align-items: flex-start; }
.picker-hint { font-size: 11.5px; color: var(--text-3); padding: 6px 10px 2px; border-top: 1px solid var(--border); margin-top: 4px; }

.upload-toast { pointer-events: auto; min-width: 300px; max-width: min(460px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.upload-toast .ut-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 8px; }
.upload-toast .ut-head span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-toast .ut-head svg { width: 16px; height: 16px; color: var(--accent); }
.upload-toast .ut-head b { font-size: 12.5px; color: var(--text-2); font-weight: 600; }

.kind-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kind-card { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); }
.kind-card:hover { border-color: var(--border-strong); }
.kind-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.kind-card .kc-icon { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); }
.kind-card.selected .kc-icon { background: var(--accent); color: #fff; }
.kind-card b { display: block; font-size: 14px; margin-bottom: 2px; }
.kind-card span span, .kind-card > span:last-child > span { display: block; font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
@media (max-width: 860px) {
  .kind-grid { grid-template-columns: 1fr; }
  .docs-btn span { display: none; }
  .doc-row .doc-actions .btn { display: none; }
}

.ocr-progress { margin-top: 6px; font-size: 13px; color: var(--text-2); max-width: 360px; }
.ocr-progress .op-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ocr-progress .bar { height: 5px; }
.doc-warn .link-btn { font-size: 13px; }

/* search in project documents */
.doc-search { margin-bottom: 12px; }
.ds-field { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px; height: 42px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: text; }
.ds-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ds-field > svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.ds-input { flex: 1; min-width: 0; border: none; outline: none; background: none; font: inherit; font-size: 14.5px; color: var(--text); }
.ds-input::-webkit-search-cancel-button { display: none; }
.ds-results { display: flex; flex-direction: column; gap: 6px; }
.ds-results:not(:empty) { margin-top: 8px; }
.ds-status { font-size: 13.5px; color: var(--text-3); padding: 6px 2px; display: flex; align-items: center; gap: 8px; }
.ds-status.error { color: var(--danger); }
.ds-hit { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.ds-hit:hover, .ds-hit:focus-visible { border-color: var(--border-strong); background: var(--bg-soft); }
.ds-hit-head { display: flex; align-items: center; gap: 8px; min-width: 0; margin-bottom: 4px; }
.ds-hit-head .doc-num { min-width: 30px; height: 20px; line-height: 20px; font-size: 11.5px; }
.ds-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ds-page { font-size: 12.5px; color: var(--text-3); flex-shrink: 0; }
.ds-tag { margin-left: auto; flex-shrink: 0; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); }
.ds-snip { font-size: 13.5px; color: var(--text-2); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.ds-snip mark, .doc-hit mark { background: color-mix(in srgb, var(--warn) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.ds-foot { font-size: 12px; color: var(--text-3); padding: 2px 2px 0; }
mark.doc-hit { background: color-mix(in srgb, var(--accent) 16%, transparent); color: inherit; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* formulas */
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; margin: .6em 0; }
.md .katex { font-size: 1.08em; }
.math-raw { font-family: var(--mono); font-size: .9em; color: var(--text-2); }
.math-raw.display { display: block; margin: .5em 0; white-space: pre-wrap; }

/* photos → one document */
.pm-seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.seg-btn { padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13.5px; cursor: pointer; }
.seg-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pm-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; padding-right: 2px; }
.pm-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.pm-num { min-width: 26px; text-align: center; font-weight: 700; font-size: 12.5px; color: var(--text-2); }
.pm-item img { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--surface-2); flex-shrink: 0; }
.pm-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.pm-btns { display: flex; gap: 2px; }
.pm-btns .icon-btn:first-child svg { transform: rotate(90deg); }
.pm-btns .icon-btn:nth-child(2) svg { transform: rotate(90deg); }
/* page photo viewer */
.pv-wrap { display: flex; justify-content: center; background: var(--surface-2); border-radius: 12px; padding: 8px; min-height: 240px; }
.page-photo { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 6px; transition: opacity .15s; }
.page-photo.loading { opacity: .35; }
.pv-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.pv-label { font-size: 13px; color: var(--text-2); min-width: 130px; text-align: center; }
@media (max-width: 860px) { .kind-grid { grid-template-columns: 1fr; } }

/* ---- list reconciliation (compare projects) ---- */
.cmp-section { margin: 4px 0 30px; }
.cmp-loading { display: flex; align-items: center; gap: 10px; padding: 20px 4px; }
.cmp-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: cmpspin .8s linear infinite; }
@keyframes cmpspin { to { transform: rotate(360deg); } }
.cmp-error { display: flex; gap: 10px; align-items: flex-start; background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.cmp-error svg { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp-card { min-width: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: border-color .12s, background .12s; }
.cmp-card.over { border-color: var(--accent); background: var(--accent-soft); }
.cmp-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cmp-card-head b { font-size: 15px; white-space: nowrap; }
.cmp-fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 13.5px; }
.cmp-card.empty .cmp-card-head b { flex: 1; }
.cmp-side { flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font: 800 13px/1 var(--font); color: #fff; background: #3b82f6; }
.cmp-side.b { background: #d97706; }
.cmp-drop { margin: 0; flex: 1; justify-content: center; }
.cmp-drop .btn { margin-top: 4px; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-preview { border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 220px; }
.cmp-more { padding: 6px 10px; font-size: 12px; border-top: 1px solid var(--border); }
.cmp-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.cmp-table th, .cmp-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.cmp-table th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 12.5px; z-index: 1; }
.cmp-table.small th, .cmp-table.small td { padding: 5px 8px; font-size: 12.5px; max-width: 200px; }
.cmp-table tbody tr:hover td { background: var(--bg-soft); }
.cmp-table tbody tr:last-child td { border-bottom: none; }
.cmp-table .key { background: color-mix(in srgb, var(--accent) 7%, transparent); font-weight: 600; }
.cmp-table th.key { color: var(--accent-text); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.cmp-table .sep { border-left: 2px solid var(--border-strong); }
.cmp-table .num { color: var(--text-3); font-variant-numeric: tabular-nums; }
.cmp-table td.hi { color: var(--success); font-weight: 600; }
.cmp-table td.mid { color: var(--warn); font-weight: 600; }
.cmp-table td.lo { color: var(--danger); font-weight: 600; }
.cmp-table td.v-same { color: var(--success); font-weight: 600; }
.cmp-table td.v-diff { color: var(--danger); font-weight: 600; }
.cmp-table td.v-unsure { color: var(--warn); font-weight: 600; }
.cmp-read { border-top: 1px solid var(--border); padding-top: 8px; }
.cmp-read summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); list-style: none; }
.cmp-read summary::-webkit-details-marker { display: none; }
.cmp-read summary svg { width: 15px; height: 15px; }
.cmp-read summary .chev { margin-left: auto; transition: transform .15s; }
.cmp-read[open] summary .chev { transform: rotate(180deg); }
.cmp-read-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.cmp-read-row .fld { margin: 0; flex: 1 1 150px; min-width: 0; }
.cmp-read-row .fld > span { font-size: 12px; }
.input.sm, .cmp-read-row .fld select, .cmp-read-row .fld input { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.cmp-read-row .fld select { padding-right: 30px; }
.cmp-read-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.cmp-hint { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 13.5px; line-height: 1.5; }
.cmp-hint svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.cmp-sample { font: 12.5px/1.5 var(--mono); white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; color: var(--text-2); max-height: 140px; overflow: auto; }
.cmp-settings { margin-top: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 16px; }
.cmp-keys { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.cmp-eq { align-self: center; font-size: 22px; font-weight: 700; color: var(--text-3); }
.cmp-keybox { min-width: 0; }
.cmp-keyhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cmp-keyhead .muted { font-size: 12px; }
.cmp-keychips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-keychip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 10px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text); }
.cmp-keychip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-keychip small { font-size: 11px; color: var(--text-3); }
.cmp-keychip:hover { border-color: var(--border-strong); }
.cmp-keychip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.cmp-keyorder { margin-top: 8px; font-size: 12.5px; }
.cmp-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.cmp-opts .switch { margin: 0; }
.cmp-thr { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; font-size: 13.5px; }
.cmp-thr input[type=range] { flex: 0 1 220px; accent-color: var(--accent); }
.cmp-thr .muted { font-size: 12px; }
.cmp-run { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.cmp-run .muted { flex: 1 1 260px; font-size: 12px; }
.cmp-result { margin-top: 22px; scroll-margin-top: 12px; }
.cmp-dl { display: flex; gap: 8px; }
.cmp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cmp-stat { text-align: left; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmp-stat:hover { border-color: var(--border-strong); }
.cmp-stat .cs-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.cmp-stat .cs-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.cmp-stat .cs-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-stat.success .cs-num { color: var(--success); }
.cmp-stat.warn .cs-num { color: var(--warn); }
.cmp-stat.danger .cs-num { color: var(--danger); }
.cmp-stat.active.success { border-color: var(--success); background: var(--success-soft); }
.cmp-stat.active.warn { border-color: var(--warn); background: var(--warn-soft); }
.cmp-stat.active.danger { border-color: var(--danger); background: var(--danger-soft); }
.cmp-notes { display: flex; flex-direction: column; gap: 2px; margin: 10px 2px 4px; font-size: 12.5px; color: var(--text-3); }
.cmp-tabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.cmp-tab { border: none; background: none; padding: 9px 12px; font-size: 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.cmp-tab:hover { color: var(--text); }
.cmp-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.cmp-tab-n { font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 1px 7px; }
.cmp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 10px; }
.cmp-tools .search-input { max-width: 320px; }
.cmp-tools .search-input input { height: 34px; padding-left: 36px; }
.cmp-rows { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.cmp-scroll { overflow: auto; max-height: 70vh; }
.cmp-empty { padding: 26px 16px; text-align: center; }
.cmp-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .cmp-grid, .cmp-opts { grid-template-columns: 1fr; }
  .cmp-keys { grid-template-columns: 1fr; }
  .cmp-eq { display: none; }
  .cmp-stats { grid-template-columns: 1fr 1fr; }
  .cmp-result .docs-head { flex-wrap: wrap; }
}

/* ---- Ready ZIP archive card & workspace topbar chip ---- */
.ws-chip {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  font-weight: 600;
}
.ws-chip:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}
.zip-ready-card {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zrc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.zrc-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.zrc-icon svg {
  width: 20px;
  height: 20px;
}
.zrc-meta {
  flex: 1 1 200px;
  min-width: 0;
}
.zrc-title {
  font-size: 14px;
  color: var(--text);
  line-height: 1.35;
}
.zrc-sub {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
}
.zrc-btn {
  flex-shrink: 0;
}
.zrc-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.zrc-chip {
  font: 12px/1.3 var(--mono);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.zrc-chip.more {
  font-weight: 600;
  color: var(--accent-text);
}


/* Collapsible code blocks & collapsible heading sections (anti-"борода кода") */
details.code-block.collapsible {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--code-bg, #f8fafc);
  margin: 10px 0;
  overflow: hidden;
}
details.code-block.collapsible > summary.code-head {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2, #f1f5f9);
  transition: background 0.15s ease;
}
details.code-block.collapsible > summary.code-head::-webkit-details-marker {
  display: none;
}
details.code-block.collapsible > summary.code-head:hover {
  background: var(--hover, #e2e8f0);
}
details.code-block.collapsible[open] > summary.code-head {
  border-bottom: 1px solid var(--border);
}
.cb-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.cb-chev {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--text-2);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.cb-chev svg {
  width: 16px;
  height: 16px;
}
details.code-block.collapsible[open] .cb-chev {
  transform: rotate(90deg);
}
.cb-title {
  font: 600 12.5px/1.3 var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-lang {
  font: 500 11px/1.2 var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.cb-stats {
  font-size: 12px;
  color: var(--text-3, #64748b);
  white-space: nowrap;
}
details.code-block.collapsible[open] .cb-stats {
  display: none;
}

/* Collapsible markdown paragraphs / sections */
details.md-sec {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
details.md-sec > summary.md-sec-sum {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: background 0.15s ease;
}
details.md-sec > summary.md-sec-sum::-webkit-details-marker {
  display: none;
}
details.md-sec > summary.md-sec-sum:hover {
  background: var(--surface-2, #f8fafc);
}
.md-sec-chev {
  display: inline-flex;
  width: 16px;
  height: 16px;
  color: var(--text-2);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.md-sec-chev svg {
  width: 16px;
  height: 16px;
}
details.md-sec[open] > summary.md-sec-sum .md-sec-chev {
  transform: rotate(90deg);
}
.md-sec-title {
  flex: 1;
  min-width: 0;
}
.md-sec-meta {
  font: 500 11.5px/1.2 var(--sans);
  color: var(--accent-text, #4f46e5);
  background: var(--accent-soft, rgba(99, 102, 241, 0.08));
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
details.md-sec[open] > summary.md-sec-sum {
  border-bottom: 1px solid var(--border);
}
.md-sec-body {
  padding: 10px 14px;
}

/* Embedded UI screenshot / live preview card */
.ui-shot-card {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
.usc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2, #f8fafc);
  border-bottom: 1px solid var(--border);
}
.usc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-text, #4f46e5);
  background: var(--accent-soft, rgba(99, 102, 241, 0.1));
  padding: 3px 8px;
  border-radius: 6px;
}
.usc-badge svg {
  width: 14px;
  height: 14px;
}
.usc-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.usc-btn:hover {
  background: var(--hover);
}
.usc-btn svg {
  width: 14px;
  height: 14px;
}
.usc-frame-wrap {
  background: #f8fafc;
  height: 300px;
  position: relative;
}
.usc-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Version badge & screenshot buttons in zip-ready-card */
.zrc-ver {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  font: 600 11.5px/1.2 var(--mono);
  border-radius: 6px;
  background: var(--accent-text, #4f46e5);
  color: #fff;
  vertical-align: middle;
}
.zrc-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.zrc-chip.clickable {
  cursor: pointer;
  border-color: var(--accent-border, rgba(99, 102, 241, 0.4));
  color: var(--accent-text, #4f46e5);
}
.zrc-chip.clickable:hover {
  background: var(--accent-soft, rgba(99, 102, 241, 0.12));
}
.modal.shot-modal {
  width: min(980px, 94vw);
  max-width: 980px;
}
.shot-modal-body {
  height: min(72vh, 680px);
  background: #f8fafc;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.shot-modal-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---- Live Task Widget (UI for Background Agent) ---- */
.live-task-card {
  margin: 12px 0 16px;
  border-radius: 14px;
  border: 1.5px solid color-mix(in srgb, var(--accent, #7c3aed) 40%, var(--border));
  background: color-mix(in srgb, var(--accent, #7c3aed) 8%, var(--surface));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}
.live-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent, #7c3aed) 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #7c3aed) 20%, transparent);
}
.live-task-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-1);
  min-width: 0;
  flex: 1;
}
.live-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-dot 1.4s infinite ease-in-out;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.live-task-prompt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-2);
}
.live-task-timer {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-text, #4f46e5);
  font-weight: 600;
  flex-shrink: 0;
}
.live-task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.live-task-terminal {
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  border-top: 1px solid #1e293b;
}

/* ---- Git Diff Modal & Viewer ---- */
.diff-view {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-soft, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 60vh;
  overflow: auto;
  white-space: pre;
  padding: 8px 0;
}
.diff-line {
  padding: 1px 12px;
  display: block;
}
.diff-line-add {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}
.diff-line-del {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}
.diff-line-hunk {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-text, #4f46e5);
  font-weight: 600;
}
