:root {
  color-scheme: light;
  --ink: #101613;
  --ink-soft: #25302b;
  --muted: #66716c;
  --muted-2: #98a39d;
  --line: #e3e8e3;
  --paper: #f7f9f6;
  --panel: #ffffff;
  --mint: #b8f36b;
  --mint-deep: #48751f;
  --lilac: #d6c7ff;
  --lilac-deep: #6b55a7;
  --amber: #f5c76d;
  --coral: #e78067;
  --shadow: 0 18px 50px rgba(16, 22, 19, .08);
  --panel-2: #fbfcfa;
  --panel-3: #eef2ee;
  --line-strong: #d5ddd7;
  --on-ink: #ffffff;
  --on-ink-accent: var(--mint);
  --ink-hover: #25332c;
  --brand-dark: #101613;
  --topbar-bg: rgba(247, 249, 246, .92);
  --code-bg: rgba(16, 22, 19, .07);
  --mint-tint: #eff8e8;
  --mint-line: #b8d79a;
  --lilac-tint: #f1ecff;
  --danger-tint: #fff0eb;
  --danger-line: #f2c9bc;
  --danger-ink: #a55038;
  --warn-tint: #fff8e8;
  --warn-line: #f3dfae;
  --rail: 76px;
  --rail-open: 290px;
  --topbar: 68px;
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
}

/* Dark theme: follows the system unless the viewer picked a theme (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e7eee9; --ink-soft: #cbd5cf; --muted: #9ba7a1; --muted-2: #77837d;
    --line: #26302b; --line-strong: #37423c; --paper: #0c110f; --panel: #131a16; --panel-2: #101613; --panel-3: #1b241f;
    --on-ink: #0c110f; --on-ink-accent: #48751f; --ink-hover: #ffffff; --topbar-bg: rgba(12, 17, 15, .92); --code-bg: rgba(255, 255, 255, .08);
    --mint-deep: #9fd66a; --lilac-deep: #b9a7f2;
    --mint-tint: #1a2816; --mint-line: #3e5c29; --lilac-tint: #211c33;
    --danger-tint: #2d1813; --danger-line: #5b2d22; --danger-ink: #f0a893; --warn-tint: #2a2312; --warn-line: #5b4b22;
    --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7eee9; --ink-soft: #cbd5cf; --muted: #9ba7a1; --muted-2: #77837d;
  --line: #26302b; --line-strong: #37423c; --paper: #0c110f; --panel: #131a16; --panel-2: #101613; --panel-3: #1b241f;
  --on-ink: #0c110f; --on-ink-accent: #48751f; --ink-hover: #ffffff; --topbar-bg: rgba(12, 17, 15, .92); --code-bg: rgba(255, 255, 255, .08);
  --mint-deep: #9fd66a; --lilac-deep: #b9a7f2;
  --mint-tint: #1a2816; --mint-line: #3e5c29; --lilac-tint: #211c33;
  --danger-tint: #2d1813; --danger-line: #5b2d22; --danger-ink: #f0a893; --warn-tint: #2a2312; --warn-line: #5b4b22;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.45; }
button, textarea, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(184, 243, 107, .75); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.25; letter-spacing: -.02em; }
h2 { font-size: 24px; line-height: 1.2; letter-spacing: -.025em; }
h3 { font-size: 17px; line-height: 1.25; letter-spacing: -.015em; }
.eyebrow, .card-kicker, .pane-label { font: 12px "DM Mono", monospace; letter-spacing: .1em; color: var(--muted-2); text-transform: uppercase; margin: 0 0 8px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint-deep); display: inline-block; flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(184, 243, 107, .25); }
.empty { color: var(--muted); font-size: 14px; }
.soft-badge, .status-badge { border-radius: 999px; padding: 4px 10px; font: 12px "DM Mono", monospace; letter-spacing: .04em; color: var(--muted); background: var(--panel-3); white-space: nowrap; }
.status-badge.granted { background: var(--mint-tint); color: var(--mint-deep); }
.status-badge.rejected { background: var(--danger-tint); color: var(--danger-ink); }

/* Buttons */
.text-button, .primary-button, .secondary-button { border-radius: 9px; min-height: 42px; padding: 0 16px; font-size: 14px; font-weight: 600; }
.text-button { color: var(--muted); border: 0; background: transparent; }
.text-button:hover { color: var(--ink); }
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: var(--on-ink); }
.primary-button:hover:not(:disabled) { background: var(--ink-hover); }
.primary-button span, .secondary-button span { color: var(--on-ink-accent); margin-left: 6px; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--panel); }
.secondary-button:hover { border-color: var(--ink); }
.secondary-button span { color: var(--mint-deep); }

/* Shell */
.app-shell { height: 100vh; }
.workspace { margin-left: var(--rail); height: 100vh; display: flex; flex-direction: column; min-width: 0; }

/* Rail: collapsed to icons, grows over the page on hover or focus */
.rail { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--rail); background: var(--brand-dark); color: #fff; border-right: 1px solid rgba(255, 255, 255, .06); padding: 22px 12px; display: flex; flex-direction: column; gap: 28px; overflow: hidden; transition: width 200ms ease, box-shadow 200ms ease; }
.rail:hover, .rail:focus-within { width: var(--rail-open); box-shadow: 18px 0 50px rgba(16, 22, 19, .25); }
.rail-label { opacity: 0; white-space: nowrap; transition: opacity 140ms ease; }
.rail:hover .rail-label, .rail:focus-within .rail-label { opacity: 1; transition-delay: 60ms; }
.brand-lockup { display: flex; align-items: center; gap: 14px; padding: 0 12px; min-height: 40px; }
.brand-lockup strong { display: block; font-size: 22px; letter-spacing: -.05em; }
.brand-lockup small { display: block; color: #85918b; font: 11px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .13em; }
.brand-icon { width: 36px; height: 36px; flex: 0 0 36px; object-fit: contain; }
.rail .brand-lockup { padding: 0 8px; }
.brand-mark { width: 26px; height: 26px; position: relative; flex: 0 0 26px; }
.brand-mark span { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--mint); top: 6px; left: 0; }
.brand-mark span + span { background: var(--lilac); left: 11px; opacity: .9; mix-blend-mode: screen; }
.rail-nav { display: grid; gap: 8px; }
.rail-item { border: 0; background: transparent; color: #a3afa9; border-radius: 12px; min-height: 52px; padding: 0 14px; display: flex; align-items: center; gap: 16px; font-size: 16px; font-weight: 500; text-align: left; transition: background 160ms ease, color 160ms ease; }
.rail-item:hover, .rail-item.active { color: #fff; background: #222d27; }
.rail-item.active { box-shadow: inset 3px 0 var(--mint); }
.rail-icon { width: 24px; flex: 0 0 24px; text-align: center; color: var(--mint); font-size: 20px; }
.rail-bottom { margin-top: auto; padding: 0 14px; }
.security-note { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.security-note .pulse-dot { margin-left: 8px; background: var(--mint); }
.security-note strong, .security-note small { display: block; }
.security-note small { color: #82908a; }

/* Top bar */
.topbar { height: var(--topbar); flex: 0 0 var(--topbar); border-bottom: 1px solid var(--line); background: var(--topbar-bg); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.breadcrumbs { color: var(--muted-2); font: 13px "DM Mono", monospace; display: flex; gap: 10px; align-items: center; }
.breadcrumbs b { color: var(--line-strong); font-weight: 400; }
.breadcrumbs strong { color: var(--ink); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.permissions-toggle { min-height: 38px; }
.permissions-toggle .chevron { display: inline-block; color: var(--muted); transition: transform 160ms ease; }
.permissions-toggle[aria-expanded="true"] { border-color: var(--ink); }
.permissions-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.auth-links { display: flex; align-items: center; gap: 14px; }
.auth-links a { color: var(--muted); text-decoration: none; font: 12px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .04em; }
.auth-links a:hover { color: var(--ink); }
.user-chip { display: flex; align-items: center; gap: 10px; border-left: 1px solid var(--line); padding-left: 20px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-dark); color: var(--mint); font: 13px "DM Mono", monospace; }
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { font-size: 14px; }
.user-chip small { color: var(--muted); font-size: 12px; }

/* Permissions drawer */
.permissions-drawer { position: relative; flex: 0 0 auto; max-height: 55vh; overflow: auto; border-bottom: 1px solid var(--line); background: var(--panel-2); padding: 44px 28px 26px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; }
.permissions-drawer[hidden] { display: none; }
.drawer-close { position: absolute; right: 18px; top: 6px; min-height: 34px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 18px; }
.section-heading p:not(.eyebrow) { color: var(--muted); font-size: 15px; margin-top: 6px; }
.section-note { color: var(--muted); font-size: 14px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-card { position: relative; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; min-height: 150px; padding: 20px; transition: transform 160ms ease, box-shadow 160ms ease; }
.profile-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.profile-card.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.profile-card.shared { background: linear-gradient(135deg, var(--panel), var(--lilac-tint)); }
.profile-card .profile-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px; background: var(--mint-tint); color: var(--mint-deep); font-size: 20px; }
.profile-card.shared .profile-icon { background: var(--lilac-tint); color: var(--lilac-deep); }
.profile-card h3 { font-size: 18px; }
.profile-card p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.profile-card .profile-state { position: absolute; right: 18px; top: 18px; font: 12px "DM Mono", monospace; text-transform: uppercase; color: var(--muted-2); }
.profile-card.active .profile-state { color: var(--mint-deep); }
.profile-card .profile-arrow { position: absolute; right: 18px; bottom: 16px; color: var(--muted-2); font-size: 18px; }
.consent-card { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 20px 22px; }
.card-topline, .panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.consent-title-row { display: flex; align-items: center; gap: 16px; margin: 16px 0 18px; }
.consent-title-row h2 { font-size: 22px; }
.consent-title-row p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.brain-orbit { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto; position: relative; background: var(--lilac-tint); }
.brain-orbit:before { content: ""; position: absolute; inset: 9px; border: 1px solid var(--lilac-deep); border-radius: 50%; }
.brain-orbit span { width: 8px; height: 8px; border-radius: 50%; position: absolute; background: var(--lilac-deep); top: 5px; left: 20px; }
.brain-orbit span + span { background: var(--mint-deep); top: 31px; left: 8px; }
.consent-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.consent-option { border: 1px solid var(--line); padding: 12px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-start; }
.consent-option:has(input:checked) { border-color: var(--mint-line); background: var(--mint-tint); }
.consent-option input { accent-color: var(--mint-deep); margin-top: 4px; }
.consent-option strong, .consent-option small { display: block; }
.consent-option strong { font-size: 14px; }
.consent-option small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.consent-footer { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.collection-state { display: flex; align-items: center; gap: 10px; }
.state-icon { color: var(--muted-2); font-size: 22px; }
.collection-state strong, .collection-state small { display: block; }
.collection-state strong { font-size: 14px; }
.collection-state small { color: var(--muted); font-size: 13px; }
.consent-actions { display: flex; align-items: center; gap: 10px; }

/* Views */
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: block; }
.page-view { overflow: auto; }
.page-wrap { width: min(1320px, 100% - 56px); margin: 0 auto; padding: 32px 0 48px; }
.page-section { margin-top: 48px; }
.page-section.first { margin-top: 0; }

/* Chat view: history | conversation | side */
.chat-view.active { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; }
.history-pane { border-right: 1px solid var(--line); background: var(--panel-2); padding: 20px 14px; display: flex; flex-direction: column; min-height: 0; }
.new-chat { width: 100%; margin-bottom: 20px; }
.pane-label { padding: 0 8px; }
.history-list { flex: 1; overflow: auto; display: grid; align-content: start; gap: 4px; }
.history-list { grid-template-columns: minmax(0, 1fr); }
.history-item { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 10px; }
.history-item:hover, .history-item.active { background: var(--panel-3); }
.history-open { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 10px 4px 10px 12px; color: var(--ink-soft); font-size: 15px; }
.history-actions { display: flex; gap: 2px; padding-right: 6px; opacity: .55; transition: opacity .15s; }
.history-item:hover .history-actions, .history-item.active .history-actions, .history-actions:focus-within { opacity: 1; }
.history-action { border: 0; background: transparent; color: var(--muted); font-size: 13px; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.history-action:hover { color: var(--ink); background: var(--panel-2); }
.history-action.danger:hover { color: var(--danger-ink); background: var(--danger-tint); }
.history-rename { width: 100%; margin: 4px; padding: 8px 10px; border: 1px solid var(--mint-deep); border-radius: 8px; background: var(--panel-2); color: var(--ink); font: 15px "DM Sans", sans-serif; outline: 2px solid rgba(184, 243, 107, .3); }
.history-open strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-open small { display: block; color: var(--muted-2); font-size: 12px; margin-top: 1px; }
.history-item.active .history-open strong { color: var(--ink); font-weight: 600; }
.pane-footer { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.pane-note { color: var(--muted-2); font-size: 12px; padding: 0 4px; }
.theme-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink-soft); font-size: 14px; font-weight: 500; }
.theme-toggle:hover { border-color: var(--ink); color: var(--ink); }
.theme-icon { width: 20px; text-align: center; font-size: 16px; }

.chat-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 32px; border-bottom: 1px solid var(--line); }
.chat-head h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; text-align: right; }
.chat-thread { flex: 1; overflow: auto; padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.chat-empty { margin: auto; text-align: center; max-width: 520px; color: var(--muted); }
.chat-empty h2 { color: var(--ink); font: 600 34px/1.1 "Newsreader", Georgia, serif; letter-spacing: -.03em; margin-bottom: 10px; }
.chat-empty p { font-size: 16px; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.suggestion { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 9px 16px; font-size: 14px; color: var(--ink-soft); }
.suggestion:hover { border-color: var(--ink); }
.message { max-width: min(780px, 88%); display: grid; gap: 6px; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }
.bubble { padding: 14px 18px; border-radius: 18px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .bubble { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 6px; }
.message.assistant .bubble { background: var(--panel-3); color: var(--ink); border-bottom-left-radius: 6px; }
.message.notice .bubble { background: var(--warn-tint); border: 1px solid var(--warn-line); }
.message.error .bubble { background: var(--danger-tint); border: 1px solid var(--danger-line); color: var(--danger-ink); }
.bubble pre { white-space: pre-wrap; margin: 8px 0; padding: 12px; border-radius: 10px; background: #101613; color: #e6efe8; font: 13px/1.55 "DM Mono", monospace; overflow: auto; }
.bubble code { font: 14px "DM Mono", monospace; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.bubble pre code { background: transparent; padding: 0; font-size: 13px; }
.message-meta { font: 12px "DM Mono", monospace; color: var(--muted-2); padding: 0 6px; }
.message.user .message-meta { text-align: right; }
.typing { display: inline-flex; gap: 5px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.composer { margin: 0 32px 24px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--panel); padding: 12px 14px 10px 18px; box-shadow: 0 8px 30px rgba(16, 22, 19, .06); }
.composer:focus-within { border-color: var(--ink); }
.composer textarea { display: block; width: 100%; border: 0; resize: none; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.5; max-height: 220px; padding: 4px 0; }
.composer textarea:focus-visible { outline: none; }
.composer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.composer-row > * { white-space: nowrap; }
.composer-row .text-button { padding-inline: 4px; }
.composer-row #sendButton { margin-left: auto; }
.composer-row .composer-hint { white-space: normal; max-width: 150px; text-align: right; line-height: 1.3; }
.composer-hint { color: var(--muted-2); font-size: 12px; margin-left: auto; }
.attachment-button { cursor: pointer; }
.attachment-tray { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 240px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px 4px 10px; color: var(--ink-soft); background: var(--paper); font-size: 12px; }
.attachment-chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.message-attachments { margin-top: 8px; color: var(--muted); font-size: 12px; }
.privacy-count { margin: 12px 0 0; color: var(--muted-2); font-size: 12px; }
.chat-head h1 { min-width: 0; }
#sendToBrainButton { margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.chat-import-list { max-height: 360px; overflow-y: auto; }
.chat-import-list .connection-item > div:first-child { min-width: 0; }
.chat-import-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-import-actions { display: flex; gap: 6px; flex-shrink: 0; }
.settings-form .local-system-controls { margin: 0; }
.settings-form .local-system-controls label { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font: 15px "DM Sans", sans-serif; text-transform: none; letter-spacing: 0; }
.settings-form .local-system-controls input[type="checkbox"] { width: auto; min-height: 0; margin: 0; }
.target-chip { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; background: var(--lilac-tint); color: var(--lilac-deep); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600; }
.target-chip[hidden] { display: none; }
/* Ask Jev: routing check shown above the composer */
.jev-button { font-size: 13px; }
.jev-threshold { font-size: 11px; white-space: nowrap; }
.jev-check { position: relative; margin-bottom: 8px; padding: 10px 36px 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 13px; color: var(--ink-soft); }
.jev-check[hidden] { display: none; }
.jev-check-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.jev-check-head .eyebrow { margin: 0; }
.jev-check-head b { color: var(--ink); }
.jev-rows { display: grid; gap: 2px; margin-top: 8px; }
.jev-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr 42px; align-items: center; gap: 10px; width: 100%; padding: 3px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); font: 12px "DM Mono", monospace; text-align: left; cursor: pointer; }
.jev-row:hover { background: var(--panel); }
.jev-row.picked { color: var(--ink); font-weight: 600; }
.jev-row .agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jev-row .track { display: block; height: 6px; }
.jev-row .bar { display: block; height: 100%; }
.jev-row .score { text-align: right; }
.jev-check-close { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px; cursor: pointer; }
.target-chip button { border: 0; background: transparent; color: inherit; font-size: 16px; line-height: 1; padding: 0 4px; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle-track { width: 32px; height: 18px; border-radius: 999px; background: var(--line-strong); position: relative; transition: 160ms ease; flex: 0 0 auto; }
.toggle-track:before { content: ""; width: 14px; height: 14px; border-radius: 50%; position: absolute; left: 2px; top: 2px; background: #fff; transition: 160ms ease; }
.toggle input:checked + .toggle-track { background: var(--mint-deep); }
.toggle input:checked + .toggle-track:before { transform: translateX(14px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(184, 243, 107, .75); outline-offset: 2px; }

.side-pane { border-left: 1px solid var(--line); background: var(--panel-2); padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.side-card { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 16px; }
.mcp-card { flex: 0 0 auto; }
.agents-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-note { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.side-list { display: grid; gap: 6px; align-content: start; }
.agents-card .side-list { overflow: auto; min-height: 0; }
.side-item { display: flex; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; font-size: 14px; background: var(--panel-3); text-align: left; width: 100%; color: var(--ink); }
.side-item small { display: block; color: var(--muted); font-size: 12px; }
button.side-item:hover { border-color: var(--line); background: var(--panel); }
.side-item.selected { border-color: var(--lilac-deep); background: var(--lilac-tint); }
.side-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint-deep); flex: 0 0 auto; }
.side-dot.off { background: var(--muted-2); }
.side-link { padding: 0; min-height: 32px; margin-top: 6px; font-size: 13px; }

/* Brain view */
.manager-status { color: var(--muted); font: 13px "DM Mono", monospace; display: flex; align-items: center; gap: 8px; }
.prompt-card, .data-panel { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; }
.prompt-card { padding: 16px 18px 14px; }
.prompt-card textarea { display: block; width: 100%; resize: vertical; border: 0; background: transparent; color: var(--ink); min-height: 54px; font-size: 16px; line-height: 1.5; }
.prompt-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.prompt-actions .soft-badge { margin-right: auto; }
.manager-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin: 14px 0; }
.data-panel { padding: 18px; }
.data-panel .panel-heading { margin-bottom: 14px; }
.panel-heading > span:last-child { color: var(--muted); font-size: 13px; }
.ratio-list, .agent-list, .files-list { display: grid; gap: 10px; }
.ratio-row { display: grid; grid-template-columns: 140px 1fr 52px; gap: 12px; align-items: center; }
.agent-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.track { height: 8px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.bar { height: 100%; background: var(--mint-deep); transition: width 220ms ease; }
.bar.mid { background: #7089bd; }
.bar.low { background: var(--coral); }
.score { color: var(--muted); font: 13px "DM Mono", monospace; text-align: right; }
.file-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); font-size: 14px; }
.file-path { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.graph-wrap { width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: radial-gradient(ellipse at center, color-mix(in srgb, var(--mint) 6%, var(--panel-2)) 0%, var(--panel-2) 70%); }
.graph-wrap svg { display: block; width: 100%; height: auto; }
/* Specialist map */
.map-dot { fill: var(--line-strong); opacity: .5; }
.map-glow-in { stop-color: var(--mint); stop-opacity: .22; }
.map-glow-out { stop-color: var(--mint); stop-opacity: 0; }
.map-orbit { fill: none; stroke: var(--line); stroke-dasharray: 2 8; }
.map-link { fill: none; stroke: var(--muted-2); stroke-linecap: round; transition: opacity .3s; }
.map-link.custom { stroke: var(--lilac-deep); }
.map-link.chosen { stroke: var(--mint-deep); }
.map-flow { fill: none; stroke: var(--mint); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 6 14; animation: map-flow 1s linear infinite; filter: drop-shadow(0 0 4px var(--mint)); }
@keyframes map-flow { to { stroke-dashoffset: -20; } }
.map-hub-spin { fill: none; stroke: var(--mint-deep); stroke-width: 1.5; stroke-dasharray: 4 10; transform-box: fill-box; transform-origin: center; animation: map-spin 18s linear infinite; }
@keyframes map-spin { to { transform: rotate(360deg); } }
.map-hub-ring { fill: none; stroke: var(--mint-deep); stroke-width: 2; opacity: .6; }
.map-hub-core { fill: var(--brand-dark); stroke: var(--mint-deep); stroke-width: 1.5; filter: drop-shadow(0 0 12px color-mix(in srgb, var(--mint) 45%, transparent)); }
.map-hub-title { fill: var(--mint); font: 700 18px "DM Mono", monospace; text-anchor: middle; letter-spacing: .12em; }
.map-hub-sub { fill: #cfe7c4; font: 10px "DM Mono", monospace; text-anchor: middle; }
.map-node { cursor: pointer; }
.map-node .map-core { fill: var(--panel); stroke: var(--line-strong); stroke-width: 1.5; transition: fill .2s, stroke .2s; }
.map-node:hover .map-core { fill: var(--panel-3); stroke: var(--mint-deep); }
.map-node.custom .map-core { stroke: var(--lilac-deep); }
.map-node.chosen .map-core { fill: var(--brand-dark); stroke: var(--mint); }
.map-ring-track { fill: none; stroke: var(--line); stroke-width: 3; }
.map-ring { fill: none; stroke: var(--mint-deep); stroke-width: 3; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.map-node.custom .map-ring { stroke: var(--lilac-deep); }
.map-halo { fill: none; stroke: var(--mint); stroke-width: 2; opacity: .5; transform-box: fill-box; transform-origin: center; animation: map-pulse 1.8s ease-out infinite; }
@keyframes map-pulse { from { transform: scale(.8); opacity: .7; } to { transform: scale(1.15); opacity: 0; } }
.map-initials { fill: var(--ink); font: 600 14px "DM Mono", monospace; text-anchor: middle; pointer-events: none; }
.map-node.chosen .map-initials { fill: var(--mint); }
.map-label { fill: var(--ink); font: 600 14px "DM Sans", sans-serif; text-anchor: middle; }
.map-sub { fill: var(--muted); font: 11px "DM Mono", monospace; text-anchor: middle; }
.map-new rect { fill: var(--lilac); }
.map-new text { fill: #101613; font: 700 9px "DM Mono", monospace; text-anchor: middle; letter-spacing: .06em; }
.map-node.fresh .map-core { animation: map-fresh 2.4s ease-in-out infinite; }
@keyframes map-fresh { 50% { stroke-width: 3; } }
@media (prefers-reduced-motion: reduce) { .map-flow, .map-hub-spin, .map-halo, .map-node.fresh .map-core { animation: none; } }
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 12px 4px 0; color: var(--muted); font: 12px "DM Sans", sans-serif; }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.graph-legend .lg-chosen { background: var(--mint); }
.graph-legend .lg-ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--mint-deep); background: transparent; }
.graph-legend .lg-custom { background: var(--lilac-deep); }
.graph-legend b, .new-tag { display: inline-block; padding: 1px 6px; border-radius: 99px; background: var(--lilac); color: #101613; font: 700 9px "DM Mono", monospace; letter-spacing: .06em; vertical-align: middle; }
svg { display: block; width: 100%; min-height: 300px; }

/* Cards and forms (settings, agency, crews, brain) */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-card { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 22px; min-width: 0; }
.settings-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.settings-card-head h3 { font-size: 19px; }
.settings-lock { color: var(--mint-deep); background: var(--mint-tint); border-radius: 999px; padding: 5px 10px; font: 12px "DM Mono", monospace; text-transform: uppercase; white-space: nowrap; }
.settings-notice { color: var(--muted); font-size: 14px; margin: 12px 0; }
.notice-banner { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; }
.connection-list { display: grid; gap: 8px; margin-bottom: 16px; }
.connection-item { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.connection-item strong, .connection-item small { display: block; }
.connection-item strong { font-size: 15px; }
.connection-item small { color: var(--muted); font: 12px "DM Mono", monospace; margin-top: 3px; overflow-wrap: anywhere; }
.connection-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.connection-status { color: var(--mint-deep); font: 12px "DM Mono", monospace; text-transform: uppercase; }
.connection-button { border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.connection-button:hover { border-color: var(--ink); }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
.settings-form label { display: grid; gap: 6px; color: var(--muted); font: 12px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .04em; }
.settings-form .wide { grid-column: 1 / -1; }
.settings-form input, .settings-form select, .settings-form textarea { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel-2); color: var(--ink); font: 15px "DM Sans", sans-serif; text-transform: none; letter-spacing: 0; }
.settings-form textarea { resize: vertical; }
.settings-form input:focus, .settings-form select:focus, .settings-form textarea:focus { border-color: var(--mint-deep); outline: 2px solid rgba(184, 243, 107, .35); }
.settings-form > .primary-button, .settings-form > .secondary-button { grid-column: 1 / -1; justify-self: start; }
.button-row { display: flex; gap: 10px; }
.local-system-controls { display: grid; gap: 10px; margin: 12px 0 16px; color: var(--ink-soft); font-size: 15px; }
.local-system-controls input { accent-color: var(--mint-deep); margin-right: 8px; }
.capability-list, .pipeline-list, .golden-grid { display: grid; gap: 12px; }
.capability-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 12px; }
.capability-item, .pipeline-step, .golden-card { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); padding: 14px; font-size: 14px; }
.integration-catalog { display: grid; gap: 8px; max-height: 520px; overflow: auto; }
.integration-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.integration-item > div { min-width: 0; flex: 1; }
.integration-item strong, .integration-item small, .agency-tool-copy strong, .agency-tool-copy small { display: block; }
.integration-item strong, .agency-tool-copy strong { font-size: 15px; }
.integration-item small, .agency-tool-copy small { color: var(--muted); font-size: 13px; }
.integration-mark { width: 34px; height: 34px; flex: 0 0 34px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--brand-dark); color: var(--mint); font: 600 12px "DM Mono", monospace; }
.mark-telegram { background: #229ed9; color: #fff; }
.mark-google, .mark-gemini { background: #fff; color: #4285f4; border: 1px solid #d9e3f5; }
.mark-slack { background: #4a154b; color: #fff; }
.mark-github { background: #24292f; color: #fff; }
.mark-notion { background: #fff; color: #111; border: 1px solid #d9ddd9; }
.mark-linear { background: #5e6ad2; color: #fff; }
.mark-discord { background: #5865f2; color: #fff; }
.mark-filesystem { background: #f5c76d; color: #101613; }
.mark-postgres { background: #336791; color: #fff; }
/* Agency builder tool picker: compact cards side by side, the whole card toggles the tool. */
#agencyTools { display: block; margin: 0; }
.agency-tools-label { display: block; margin-bottom: 6px; color: var(--muted); font: 12px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .04em; }
.agency-tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.settings-form label.agency-tool { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--ink); cursor: pointer; text-transform: none; letter-spacing: 0; font: 14px "DM Sans", sans-serif; transition: border-color .15s, background .15s; }
.settings-form label.agency-tool:hover { border-color: var(--mint-deep); }
.settings-form .agency-tool input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; border: 0; }
.agency-tool .integration-mark { margin-bottom: 4px; }
.agency-tool strong { font-size: 14px; overflow-wrap: anywhere; }
.agency-tool small { color: var(--muted); font: 11px "DM Mono", monospace; }
.agency-tool-check { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: transparent; font-size: 12px; line-height: 1; }
.settings-form label.agency-tool:has(input:checked) { border-color: var(--mint-deep); background: color-mix(in srgb, var(--mint) 10%, var(--panel-2)); }
.agency-tool:has(input:checked) .agency-tool-check { background: var(--mint-deep); border-color: var(--mint-deep); color: var(--brand-dark); }
.agency-tool:has(input:focus-visible) { outline: 2px solid rgba(184, 243, 107, .35); outline-offset: 2px; }
.tool-kind { color: var(--muted-2); font: 11px "DM Mono", monospace; text-transform: uppercase; white-space: nowrap; }

/* Golden images and pipeline */
.golden-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.golden-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
.golden-card.not-built { border-style: dashed; }
.golden-card strong { display: block; font-size: 17px; }
.golden-card p { margin: 0; color: var(--ink-soft); line-height: 1.45; }
.golden-top { display: flex; align-items: center; justify-content: space-between; }
.golden-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-dark); color: var(--mint); font: 700 14px "DM Mono", monospace; }
.golden-status { font: 600 12px "DM Mono", monospace; padding: 3px 10px; border-radius: 99px; }
.golden-status.ready { color: var(--mint-deep); background: color-mix(in srgb, var(--mint) 14%, transparent); }
.golden-status.missing { color: var(--muted); background: var(--panel-3); }
.golden-ref { align-self: flex-start; font: 12px "DM Mono", monospace; color: var(--muted); background: var(--panel-3); padding: 2px 8px; border-radius: 6px; }
.golden-use b { color: var(--ink); font-weight: 600; }
.golden-kit code { font: 12px "DM Mono", monospace; background: var(--lilac-tint); color: var(--lilac-deep); padding: 1px 6px; border-radius: 5px; }
.golden-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.golden-tags span { font: 11px "DM Mono", monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }
.golden-limits { color: var(--muted-2); font: 11px "DM Mono", monospace; margin-top: auto; }
.golden-build { border-top: 1px dashed var(--line); padding-top: 8px; }
.golden-build small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.golden-build code { display: block; font: 12px "DM Mono", monospace; color: var(--ink); background: var(--panel-3); padding: 6px 8px; border-radius: 6px; overflow-wrap: anywhere; }
.pipeline-shell { display: grid; gap: 16px; }
.pipeline-reference { position: relative; justify-self: center; width: 100%; aspect-ratio: 1983 / 793; margin: 0; border: 1px solid #b6c7bc; border-radius: 8px; background: #17231d; overflow: hidden; }
.pipeline-reference img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pipeline-overlay { position: absolute; inset: 0; pointer-events: none; }
.pipeline-glow { position: absolute; width: var(--glow-w, 10%); height: var(--glow-h, 24%); border: 2px solid #b8f36b; border-radius: 14px; background: radial-gradient(ellipse, rgba(184,243,107,.2) 0 34%, transparent 72%); box-shadow: inset 0 0 18px rgba(184,243,107,.24), 0 0 20px rgba(184,243,107,.8); transform: translate(-50%, -50%); animation: pipelineGlowPulse 1.5s ease-in-out infinite; }
@keyframes pipelineGlowPulse { 50% { opacity: .55; } }
.pipeline-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pipeline-summary article { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--panel); min-width: 0; }
.pipeline-summary span { color: var(--muted); font-size: 13px; }
.pipeline-summary strong { font-size: 17px; overflow-wrap: anywhere; }
.pipeline-legacy-status { display: none; }
.pipeline-step { display: flex; gap: 10px; align-items: flex-start; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 1280px) { .chat-view.active { grid-template-columns: 250px minmax(0, 1fr); } .side-pane { display: none; } }
@media (max-width: 1000px) { .permissions-drawer, .settings-grid, .manager-grid { grid-template-columns: 1fr; } .auth-links, .user-chip > div:not(.avatar) { display: none; } }
@media (max-width: 760px) {
  :root { --rail: 0px; }
  .rail { inset: auto 0 0 0; width: 100%; height: 62px; flex-direction: row; padding: 6px 8px; gap: 0; }
  .rail:hover, .rail:focus-within { width: 100%; box-shadow: none; }
  .brand-lockup, .rail-bottom, .rail-label { display: none; }
  .rail-nav { display: flex; width: 100%; justify-content: space-around; }
  .rail-item { padding: 0 12px; }
  .workspace { height: calc(100vh - 62px); }
  .topbar { padding: 0 16px; }
  .breadcrumbs > :nth-child(-n+2) { display: none; }
  .chat-view.active { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .history-pane { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; flex-direction: row; align-items: center; gap: 10px; }
  .new-chat { width: auto; margin: 0; flex: 0 0 auto; }
  .pane-label, .pane-note, #themeLabel { display: none; }
  .pane-footer { border: 0; padding: 0; order: 1; }
  .history-list { display: flex; overflow-x: auto; }
  .history-open { padding: 8px 4px 8px 10px; max-width: 180px; }
  .chat-head, .chat-thread { padding-left: 16px; padding-right: 16px; }
  .composer { margin: 0 16px 16px; }
  .composer-hint { display: none; }
  .page-wrap { width: calc(100% - 32px); }
  .profile-grid, .consent-options, .settings-form, .pipeline-summary { grid-template-columns: 1fr; }
  .permissions-drawer { padding: 44px 16px 18px; }
}

/* Stop, queue and send-now while a chat turn runs */
.composer [hidden] { display: none !important; }
.prompt-queue { display: grid; gap: 6px; margin: 0 0 8px; max-height: 132px; overflow: auto; }
.queue-title { color: var(--muted); font-size: 12px; }
.queued-prompt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--paper); color: var(--ink-soft); font-size: 13px; }
.queued-prompt span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-remove { flex: none; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.queue-remove:hover { color: var(--ink); }
.primary-button.stop-button { background: #c93c52; border-color: #c93c52; color: #fff; }

/* Run mode (Chat / Harness) next to the composer */
.run-mode { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.run-mode select, .golden-select { font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
/* MCP apps: one-click connect */
.apps-card { margin-bottom: 16px; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.app-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.app-card.connected { border-color: color-mix(in srgb, var(--mint-deep) 60%, var(--line)); }
.app-card p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.45; flex: 1; }
.app-head { display: flex; align-items: center; gap: 10px; }
.app-head strong { display: block; font-size: 15px; }
.app-head small { color: var(--muted-2); font: 11px "DM Mono", monospace; }
.app-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-dark); color: var(--mint); font: 700 12px "DM Mono", monospace; }
/* Real logos: a tile in the brand colour with the logo masked on top, or the brand's own image. */
.brand-mark { display: inline-grid; place-items: center; overflow: hidden; background: var(--tile, var(--brand-dark)); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .25); }
.brand-mark i { width: 58%; height: 58%; background: var(--ink, #fff); -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.app-status { font: 11px "DM Mono", monospace; color: var(--muted); }
.app-status.on { color: var(--mint-deep); }
.app-status.warn { color: var(--coral); overflow-wrap: anywhere; }
.app-actions { display: flex; gap: 8px; align-items: center; }
.app-actions .primary-button, .app-actions .secondary-button { padding: 7px 14px; font-size: 13px; }
.app-token { display: grid; gap: 6px; }
.app-token p { font-size: 12px; }
.app-token a { color: var(--mint-deep); }
.app-token input { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel); color: var(--ink); font: 13px "DM Sans", sans-serif; }
.app-token .primary-button { justify-self: start; padding: 6px 14px; font-size: 13px; }
/* Harness run progress inside a chat message */
.harness-run { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.harness-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.harness-head small { margin-left: auto; color: var(--muted-2); font: 11px "DM Mono", monospace; }
.harness-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.harness-run.live .harness-dot { background: var(--mint-deep); animation: harness-pulse 1s ease-in-out infinite; }
.harness-run.ok .harness-dot { background: var(--mint-deep); }
.harness-run.bad .harness-dot { background: var(--coral); }
@keyframes harness-pulse { 50% { opacity: .3; } }
.harness-log { margin: 0; padding: 10px 12px; max-height: 220px; overflow: auto; font: 12px/1.5 "DM Mono", monospace; color: var(--ink-soft); white-space: pre-wrap; background: transparent; }
.approval-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.approval-actions button { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--panel); cursor: pointer; }
.approval-actions button.secondary-button { background: transparent; color: var(--ink); border-color: var(--line); }

/* MCP tools (settings): per-server card with a tool checklist */
.mcp-server { flex-direction: column; align-items: stretch; }
.mcp-tools { display: grid; gap: 6px; margin: 6px 0; }
.mcp-tool { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.mcp-tool span { display: grid; min-width: 0; }
.mcp-server .connection-actions { flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mcp-server .connection-actions select { font: inherit; font-size: 12px; padding: 3px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

/* Chat cost panel: total of the chat, split into model tokens, JEV and VPS. */
.chat-cost { margin: 0 0 8px; padding: 6px 12px; font-size: 13px; opacity: 0.9; border-bottom: 1px solid rgba(127, 127, 127, 0.25); }
.chat-cost summary { cursor: pointer; font-weight: 600; }
.chat-cost-body { margin-top: 6px; display: grid; gap: 3px; font-family: ui-monospace, monospace; font-size: 12px; }
@media (max-width: 720px) { .chat-cost { font-size: 12px; } }

/* Regular users do not see admin controls (the server refuses them anyway). */
body:not(.is-admin) .admin-only { display: none !important; }
/* Enterprise screens exist only inside a company; each one also needs its permission ([data-perm] gets `hidden`). */
body:not(.in-company) .company-only { display: none !important; }
[data-perm][hidden] { display: none !important; }

/* Personal / company switcher in the top bar */
.context-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.context-switch span { opacity: .7; }
.context-switch select { max-width: 220px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line, rgba(127,127,127,.35)); background: transparent; color: inherit; font: inherit; }
.company-create { margin-top: 10px; }
.company-permissions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.member-row .policy-picks { margin-top: 6px; }
.brain-notice { color: #a55038; }
/* Error banner: company and permission errors are shown, never swallowed. Click to close. */
.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1000; max-width: min(640px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 10px; background: #a55038; color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); cursor: pointer; }
.toast[hidden] { display: none; }
.company-danger { display: grid; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, rgba(127,127,127,.25)); }
.company-danger[hidden] { display: none; }
.company-danger small { opacity: .7; font-size: 12px; }
.danger-button { justify-self: start; border: 1px solid #a55038; background: transparent; color: #a55038; border-radius: 9px; min-height: 36px; padding: 0 12px; font-weight: 600; cursor: pointer; }
.danger-button:hover { background: rgba(165, 80, 56, .1); }
/* Company brain overview (Enterprise tab) */
.brain-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.brain-counts span { padding: 6px 10px; border-radius: 8px; background: var(--panel-3, rgba(127,127,127,.12)); font-size: 13px; }
#brainOverview h4 { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.brain-reasons { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 3px; }
.brain-reasons small { opacity: .6; margin-left: 4px; }
.brain-reasons.why { margin-top: 6px; color: #a55038; }
@media (max-width: 720px) { .context-switch span { display: none; } .context-switch select { max-width: 140px; } }


/* Jev router card (Settings → API and local model connections) */
.jev-settings { display: grid; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: 10px; }
.jev-settings-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.jev-settings-head small { display: block; opacity: .8; margin-top: 2px; }
.jev-settings-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.jev-settings-form input { min-width: 0; }
.jev-how { display: block; margin-top: 6px; opacity: .75; font-size: 12px; }

/* Model access policy and company shares (admin) */
.jev-members { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; opacity: .9; }
.policy-settings { display: grid; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: 10px; }
.policy-settings .jev-settings-head small { display: block; opacity: .8; margin-top: 2px; }
.policy-row { display: grid; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line, rgba(127,127,127,.2)); }
.policy-picks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.policy-pick { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.company-shares { display: grid; gap: 12px; }

/* Sandbox approval card: the internet question */
.approval-note { display: block; flex-basis: 100%; margin-bottom: 6px; opacity: .9; }
.approval-actions { flex-wrap: wrap; }

/* ---- Composer v2: compact when idle, options bar on focus, Harness panel slides open below ---- */
.composer { position: relative; padding: 10px 10px 10px 18px; transition: border-color 160ms ease, box-shadow 200ms ease, padding 200ms ease; }
.composer.is-private { border-color: var(--lilac-deep); box-shadow: 0 0 0 3px var(--lilac-tint), 0 8px 30px rgba(16, 22, 19, .06); }
.composer-main { display: flex; align-items: flex-end; gap: 8px; }
.composer-main textarea { flex: 1 1 auto; min-width: 0; padding: 9px 0; }
.composer .send-button { min-height: 40px; padding: 0 16px; flex: 0 0 auto; }
.composer.is-compact { padding-block: 6px; }
.composer.is-compact .send-button { min-height: 36px; }

.composer-extra { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 240ms cubic-bezier(.2, .8, .2, 1), opacity 200ms ease; }
.composer-extra-inner { min-height: 0; overflow: hidden; }
.composer.is-compact .composer-extra { grid-template-rows: 0fr; opacity: 0; }
.composer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-top: 8px; margin-top: 6px; border-top: 1px solid var(--line); }
.composer-left, .composer-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.composer-right { margin-left: auto; justify-content: flex-end; }
.composer .composer-hint { display: block; margin: 6px 0 0; text-align: right; max-width: none; }

.chip-button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel-2); color: var(--ink-soft); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 140ms ease, border-color 140ms ease, color 140ms ease; }
.chip-button:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.chip-button:disabled { opacity: .55; cursor: progress; }
.chip-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip-button .jev-threshold { font: 11px "DM Mono", monospace; color: var(--lilac-deep); background: var(--lilac-tint); border-radius: 999px; padding: 1px 7px; }
.toggle-sm .toggle-track { width: 26px; height: 15px; }
.toggle-sm .toggle-track:before { width: 11px; height: 11px; }
.toggle-sm input:checked + .toggle-track:before { transform: translateX(11px); }
.private-toggle input:checked + .toggle-track { background: var(--lilac-deep); }
.private-toggle input:checked ~ span:last-child { color: var(--lilac-deep); font-weight: 600; }

.pill-select { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel-2); overflow: hidden; font-size: 12px; }
.pill-select > span { padding: 0 4px 0 11px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.pill-select select { font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: transparent; border: 0; padding: 6px 10px 6px 4px; max-width: 220px; cursor: pointer; }
.pill-select select:focus-visible { outline: 2px solid var(--mint-deep); outline-offset: -2px; border-radius: 999px; }

/* Chat | Harness switch; the thumb slides between the two */
.run-switch { position: relative; display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line); isolation: isolate; }
.run-switch button { position: relative; z-index: 1; border: 0; background: transparent; padding: 4px 13px; font-size: 13px; font-weight: 600; color: var(--muted); border-radius: 999px; cursor: pointer; transition: color 200ms ease; }
.run-switch button[aria-checked="true"] { color: var(--on-ink); }
.run-switch-thumb { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px; background: var(--ink); transition: transform 280ms cubic-bezier(.3, 1.4, .5, 1), background 200ms ease; }
.run-switch.is-harness .run-switch-thumb { transform: translateX(100%); background: var(--mint-deep); }
.run-switch-dock:empty, .run-switch-home:empty { display: none; }

/* Harness panel: the second row that opens under the bar */
.harness-panel { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 320ms cubic-bezier(.2, .8, .2, 1), opacity 240ms ease; }
.harness-panel.open { grid-template-rows: 1fr; opacity: 1; }
.harness-panel-inner { min-height: 0; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.harness-panel.open .harness-panel-inner { margin-top: 8px; padding: 9px 10px; border-radius: 14px; background: var(--mint-tint); border: 1px solid var(--mint-line); }
.device-list { display: flex; flex-wrap: wrap; gap: 6px; }
.device-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink-soft); font-size: 12px; font-weight: 600; cursor: pointer; }
.device-pill:hover { border-color: var(--ink); }
.device-pill[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.device-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.device-pill .dot.on { background: #3fbf5f; box-shadow: 0 0 0 3px rgba(63, 191, 95, .18); }
.device-pill .dot.vps { background: var(--amber); }
.harness-panel.open .device-pill, .harness-panel.open .pill-select { animation: pill-in 320ms cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 40ms + 80ms); }
@keyframes pill-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* "/" agent menu above the input */
.slash-menu { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); z-index: 20; max-height: 260px; overflow: auto; padding: 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.slash-item { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; font-size: 14px; }
.slash-item code { font: 13px "DM Mono", monospace; color: var(--lilac-deep); }
.slash-item small { color: var(--muted); margin-left: auto; font-size: 12px; }
.slash-item.active, .slash-item:hover { background: var(--lilac-tint); }

@media (max-width: 720px) {
  .composer-right { margin-left: 0; justify-content: flex-start; }
  .composer .composer-hint { display: none; }
  .pill-select select { max-width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .composer-extra, .harness-panel, .run-switch-thumb { transition: none; }
  .harness-panel.open .device-pill, .harness-panel.open .pill-select { animation: none; }
}

/* Attach: a light text button, no pill outline */
.composer .attachment-button { min-height: 26px; padding: 0 4px; gap: 5px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.composer .attachment-button:hover { color: var(--ink); background: transparent; }
.composer .attachment-button svg { width: 14px; height: 14px; }

/* Open dropdown lists follow the theme instead of the browser's white list */
.composer select { color-scheme: inherit; }
.composer select option, .composer select optgroup { background-color: var(--panel); color: var(--ink); }
.composer select optgroup { color: var(--muted); font-weight: 600; }
.composer select option:checked { background-color: var(--panel-3); }

/* Slimmer composer: options always visible, about a third less height */
.composer, .composer.is-compact { padding: 6px 8px 6px 14px; border-radius: 14px; }
.composer .composer-extra, .composer.is-compact .composer-extra { grid-template-rows: 1fr; opacity: 1; }
.composer-main textarea { padding: 4px 0; font-size: 15px; line-height: 1.4; }
.composer .send-button, .composer.is-compact .send-button { min-height: 32px; padding: 0 14px; font-size: 13px; }
.composer-bar { padding-top: 5px; margin-top: 4px; gap: 6px 10px; }
.chip-button { min-height: 26px; padding: 0 9px; font-size: 12px; }
.pill-select select { padding: 4px 9px 4px 3px; font-size: 12px; }
.run-switch button { padding: 3px 11px; font-size: 12px; }
.composer .composer-hint { margin-top: 3px; font-size: 11px; }
.harness-panel.open .harness-panel-inner { margin-top: 5px; padding: 6px 8px; border-radius: 11px; }
.device-pill { min-height: 24px; padding: 0 9px; }
.composer .attachment-button svg { flex: 0 0 14px; width: 14px !important; height: 14px !important; max-height: 14px; }
.composer svg { min-height: 0; }

/* Mic: same light style as Attach */
.composer .plain-chip { min-height: 26px; padding: 0 4px; gap: 5px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.composer .plain-chip:hover { color: var(--ink); }
.composer .plain-chip svg { flex: 0 0 14px; width: 14px !important; height: 14px !important; }
.voice-button[aria-pressed="true"] { color: var(--danger-ink) !important; }
/* Listen button and the "how this was answered" strip on answers */
.voice-play-button { display: block; min-height: 26px; padding: 3px 0; font-size: 12px; text-align: left; }
.voice-play-button:disabled { color: var(--danger-ink); }
.transparency-strip { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--muted); font: 11px "DM Mono", monospace; }
.transparency-strip span { white-space: nowrap; }
.transparency-strip b { color: var(--ink-soft); font-weight: 600; }
.transparency-strip .classification-private, .transparency-strip .classification-restricted { color: var(--danger-ink); }
