[hidden] { display: none !important; }
/* Grok-style: near-black, monochrome, no brand colour */
:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --raised: #1a1a1a;
  --hover: #1f1f1f;
  --line: #262626;
  --line-2: #333333;
  --text: #f1f1f1;
  --muted: #a1a1a1;
  --faint: #6b6b6b;
  --accent: #e6e6e6;
  --accent-2: #ffffff;
  --accent-soft: rgba(255, 255, 255, .07);
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--text); text-decoration-color: #555; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
::selection { background: rgba(255,255,255,.18); }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- sidebar ---------- */
#sidebar { width: 260px; flex: none; background: var(--panel); border-right: 1px solid #1a1a1a; display: flex; flex-direction: column; padding: 12px 8px 0; overflow-y: auto; transition: margin-left .2s ease; }
body.side-collapsed #sidebar { margin-left: -260px; }
.side-top { justify-content: flex-end; padding: 0 2px 6px; }
.side-search { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px 0 12px; margin: 2px 2px 8px; border-radius: 12px; background: var(--raised); border: 1px solid transparent; color: var(--muted); cursor: text; flex: none; }
.side-search:focus-within { border-color: var(--line-2); }
.side-search svg { width: 17px; height: 17px; }
.side-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 14px; color: var(--text); }
.side-search input::placeholder { color: var(--muted); }
.side-search kbd { font: 11px var(--sans); color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 1px; flex: none; }
.side-btn { display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 12px; border-radius: 12px; color: #d4d4d4; text-align: left; font-size: 14px; flex: none; }
.side-btn svg { width: 18px; height: 18px; color: var(--muted); }
.side-btn span:first-of-type { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-btn:hover { background: var(--hover); color: var(--text); }
.side-btn:hover svg { color: var(--text); }
.more-btn .chev { width: 14px; height: 14px; transition: transform .15s; color: var(--faint); }
.more-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.more-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); margin-right: 2px; }
.more-list { display: flex; flex-direction: column; gap: 1px; padding-left: 10px; }
.badge { margin-left: auto; background: var(--text); color: #000; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 18px; font-style: normal; }
.side-label { font-size: 13px; color: var(--faint); padding: 18px 12px 6px; flex: none; }
.side-label:empty { display: none; }
#chat-list { display: flex; flex-direction: column; gap: 1px; flex: none; padding-bottom: 8px; }
.chat-group { font-size: 12px; color: var(--faint); padding: 12px 12px 4px; }
.chat-group:first-child { padding-top: 0; }
.chat-item { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border-radius: 12px; color: #c8c8c8; font-size: 14px; cursor: pointer; flex: none; }
.chat-item > span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item:hover { background: var(--hover); color: var(--text); }
.chat-item.active { background: #222; color: #fff; }
.chat-item .dots { opacity: 0; color: var(--muted); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; flex: none; }
.chat-item:hover .dots, .chat-item.menu-open .dots { opacity: 1; }
.chat-item .dots:hover, .chat-item.menu-open .dots { color: var(--text); background: #2c2c2c; }
.chat-item .dots svg { width: 16px; height: 16px; }
.chat-item.menu-open { background: var(--hover); }
.chat-item.editing { background: var(--hover); padding-right: 6px; }
.chat-item.editing .dots { display: none; }
input.rename { flex: 1; min-width: 0; height: 28px; background: #0f0f0f; border: 1px solid #3a3a3a; border-radius: 8px; padding: 0 8px; color: var(--text); font-size: 14px; outline: 0; margin-left: -8px; }
input.rename:focus { border-color: #5a5a5a; }
#chat-title input.rename { width: min(420px, 60vw); margin-left: 0; }
.ctx-menu { position: fixed; z-index: 80; background: #1c1c1c; border: 1px solid #2c2c2c; border-radius: 14px; padding: 5px; box-shadow: 0 18px 50px rgba(0,0,0,.6); min-width: 170px; }
.ctx-menu .pm-item { height: 36px; font-size: 13.5px; }
.ctx-menu .pm-item.danger, .ctx-menu .pm-item.danger svg { color: #f87171; }
.ctx-menu .pm-item.danger:hover { background: rgba(248,113,113,.1); }
.chat-item .cp { color: var(--faint); font-size: 12px; }
.no-hits { color: var(--faint); font-size: 13px; padding: 8px 12px; }
.side-foot { margin-top: auto; position: sticky; bottom: 0; background: var(--panel); display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 12px; flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #262626; color: #cfcfcf; display: grid; place-items: center; border: 1px solid #2f2f2f; }
.avatar:hover { background: #2e2e2e; color: #fff; }
.avatar svg { width: 17px; height: 17px; }
.user-menu { left: 0; bottom: calc(100% + 8px); min-width: 240px; }
.model-tag { font-size: 11.5px; color: var(--faint); padding: 8px 12px 4px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
#topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
#chat-title { font-size: 14px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 4px 8px; border-radius: 8px; cursor: text; }
body.has-chat #chat-title:hover { background: var(--hover); color: var(--text); }
#chat-title:empty { display: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
#open-sidebar, #top-new { display: none; }
body.side-collapsed #open-sidebar, body.side-collapsed #top-new { display: grid; }
.only-mobile { display: none; }

#messages { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
#thread { max-width: 768px; margin: 0 auto; padding: 12px 24px 48px; display: flex; flex-direction: column; gap: 30px; }

/* empty state: composer sits in the middle, chips under it (no logo) */
body:not(.has-chat) #messages { display: none; }
body:not(.has-chat) #main { justify-content: center; }
body:not(.has-chat) #topbar { position: absolute; top: 0; left: 0; right: 0; }
body:not(.has-chat) #composer-wrap { padding-bottom: 12vh; }
body.has-chat #cap-row, body.has-chat #hero-title { display: none; }
#hero-title { max-width: 768px; margin: 0 auto 22px; text-align: center; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.cap-row { max-width: 768px; margin: 14px auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cap { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: #d4d4d4; font-size: 14px; transition: background .15s, border-color .15s; }
.cap svg { width: 17px; height: 17px; color: var(--muted); }
.cap:hover { background: var(--hover); border-color: var(--line-2); color: #fff; }

/* ---------- messages ---------- */
.msg { display: flex; flex-direction: column; gap: 10px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: #212121; padding: 10px 18px; border-radius: 24px 24px 8px 24px; max-width: 80%; white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; line-height: 1.55; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 80%; margin-left: auto; }
.att-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; max-width: 260px; }
.att-card .fi { width: 34px; height: 34px; border-radius: 9px; background: #262626; color: #ddd; display: grid; place-items: center; flex: none; }
.att-card .fi svg { width: 18px; height: 18px; }
.att-card .ft { min-width: 0; }
.att-card .fn { font-size: 13px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-card .fs { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.att-card.img { padding: 0; width: 130px; height: 130px; max-width: 130px; overflow: hidden; }
.att-card.img img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.att-card.img .ov { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; background: linear-gradient(transparent, rgba(0,0,0,.75)); font-size: 11px; color: #fff; }
.att-card.img .ov span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: #000; font-size: 11px; display: grid; place-items: center; border: 2px solid var(--raised); opacity: 0; transition: opacity .12s; }
.att-card:hover .att-x { opacity: 1; }
#attach-row.has-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 6px 10px; }
#attach-row .att-card { background: #222; }
#lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 40px; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 70px rgba(0,0,0,.6); }
.lb-x { position: fixed; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 17px; display: grid; place-items: center; }
.lb-x:hover { background: rgba(255,255,255,.22); }

.msg.assistant .body { color: #ededed; word-wrap: break-word; font-size: 15.5px; line-height: 1.7; }
.body p { margin: 0 0 14px; } .body p:last-child { margin-bottom: 0; }
.body h1, .body h2, .body h3 { line-height: 1.3; margin: 26px 0 10px; letter-spacing: -.01em; color: #fff; }
.body h1 { font-size: 22px; } .body h2 { font-size: 19px; } .body h3 { font-size: 16.5px; }
.body ul, .body ol { padding-left: 24px; margin: 0 0 14px; }
.body li { margin: 5px 0; }
.body li::marker { color: var(--muted); }
.body strong { color: #fff; font-weight: 600; }
.body code { font: 13px var(--mono); background: #1e1e1e; padding: 2px 6px; border-radius: 6px; }
.body pre { background: #141414; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; overflow-x: auto; margin: 0 0 16px; }
.body pre code { background: none; padding: 0; font-size: 13px; }
.body table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; display: block; overflow-x: auto; }
.body th, .body td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
.body th { font-weight: 600; color: #fff; border-bottom-color: var(--line-2); }
.body blockquote { margin: 0 0 14px; padding: 2px 16px; border-left: 2px solid var(--line-2); color: var(--muted); }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* Grok-style "Working for Ns" trace */
.thinking { border: 0; background: none; }
.thinking summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); user-select: none; padding: 2px 0; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { color: var(--text); }
.thinking summary .chev { width: 15px; height: 15px; transition: transform .15s; }
.thinking[open] summary .chev { transform: rotate(90deg); }
.thinking .now { color: var(--faint); font-size: 13px; max-width: 420px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thinking .now:empty { display: none; }
.thinking .now::before { content: "· "; }
.trace { margin: 8px 0 2px 7px; padding: 2px 0 2px 16px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.trace:empty { display: none; }
.trace-steps { display: flex; flex-direction: column; gap: 5px; }
.trace-steps:empty { display: none; }
.trace-step { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; color: var(--muted); }
.trace-step svg { width: 14px; height: 14px; margin-top: 3px; color: var(--faint); }
.think-text { font-size: 13.5px; color: #8f8f8f; white-space: pre-wrap; line-height: 1.6; max-height: 340px; overflow-y: auto; }
.think-text:empty { display: none; }
.thinking.live .think-text { max-height: 132px; -webkit-mask-image: linear-gradient(transparent, #000 40%); mask-image: linear-gradient(transparent, #000 40%); }
.shimmer { background: linear-gradient(90deg, #6b6b6b 0%, #6b6b6b 35%, #f5f5f5 50%, #6b6b6b 65%, #6b6b6b 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent !important; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--text); animation: pulse 1.2s ease-in-out infinite; flex: none; }
@keyframes pulse { 0%,100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.05); } }

.status { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12px; color: var(--faint); margin-left: -6px; }
.meta .act { color: var(--faint); width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 9px; }
.meta .act:hover { color: var(--text); background: var(--hover); }
.meta .act svg { width: 16px; height: 16px; }
.meta .act .lbl { display: none; }
.meta .stat { padding-left: 8px; }
.msg.assistant .meta { opacity: .0; transition: opacity .15s; }
.msg.assistant:hover .meta, .msg.assistant:last-child .meta { opacity: 1; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; }
.sources a { font-size: 12.5px; text-decoration: none; color: var(--muted); background: var(--raised); border: 1px solid var(--line); padding: 4px 11px; border-radius: 999px; max-width: 240px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sources a:hover { color: var(--text); border-color: var(--line-2); }
.error { color: #fca5a5; background: rgba(248,113,113,.07); border: 1px solid rgba(248,113,113,.25); padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--text); margin-left: 4px; vertical-align: 1px; border-radius: 50%; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }

.art-card { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 440px; padding: 12px 14px; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); text-align: left; transition: .15s; }
.art-card:hover { border-color: var(--line-2); background: #202020; }
.art-card .ico { width: 38px; height: 38px; border-radius: 10px; background: #2a2a2a; color: #eee; display: grid; place-items: center; flex: none; }
.art-card .t { font-weight: 600; font-size: 14px; }
.art-card .s { font-size: 12.5px; color: var(--muted); }
.art-card .building { display: flex; align-items: center; gap: 7px; }

/* ---------- swarm board ---------- */
.swarm { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 14px; }
.swarm-head { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 12px; }
.swarm-head .stage { color: var(--muted); flex: 1; }
.swarm-head .spent { color: var(--faint); font-size: 12.5px; }
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.agent { border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; background: var(--bg); font-size: 13px; cursor: default; display: flex; align-items: center; gap: 8px; }
.agent.done { cursor: pointer; }
.agent.done:hover { border-color: var(--line-2); }
.agent .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.agent.running .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.agent.done .dot { background: var(--good); }
.agent-output { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 14px; }

/* ---------- composer (Grok pill) ---------- */
#composer-wrap { padding: 0 24px 18px; flex: none; }
#composer { max-width: 768px; margin: 0 auto; background: #171717; border: 1px solid #2a2a2a; border-radius: 28px; padding: 8px 8px 8px 8px; transition: border-color .15s; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
#composer:focus-within { border-color: #3a3a3a; }
.comp-row { display: flex; align-items: center; gap: 4px; }
#input { flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent; padding: 9px 6px; max-height: 240px; line-height: 1.5; font-size: 16px; }
#input::placeholder { color: #7a7a7a; }
.tool-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); cursor: pointer; flex: none; }
.tool-btn:hover { background: #262626; color: var(--text); }
.menu-wrap { position: relative; flex: none; }
.plus-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #cfcfcf; transition: .15s; }
.plus-btn svg { width: 19px; height: 19px; }
.plus-btn:hover, .plus-btn[aria-expanded="true"] { background: #262626; color: #fff; }
.mode-chips { display: flex; gap: 4px; flex: none; }
.mode-chips:empty { display: none; }
.mchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 11px; border-radius: 999px; background: #262626; color: #f0f0f0; font-size: 13px; font-weight: 500; white-space: nowrap; }
.mchip svg { width: 15px; height: 15px; }
.mchip b { font-weight: 400; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 2px; }
.mchip:hover b { color: #fff; }
.pop { position: absolute; bottom: calc(100% + 10px); background: #1c1c1c; border: 1px solid #2c2c2c; border-radius: 16px; padding: 6px; box-shadow: 0 18px 50px rgba(0,0,0,.6); z-index: 30; min-width: 220px; }
.pop[hidden] { display: none; }
.plus-menu { left: 0; }
.pm-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px; border-radius: 11px; color: var(--text); font-size: 14px; cursor: pointer; text-align: left; }
.pm-item svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.pm-item span:first-of-type { flex: 1; }
.pm-item:hover { background: #262626; }
.pm-item .pm-chk { color: var(--text); opacity: 0; font-size: 13px; }
.pm-item[aria-pressed="true"] .pm-chk { opacity: 1; }
.pm-item[aria-pressed="true"] svg { color: var(--text); }
.pm-item:disabled { opacity: .4; cursor: not-allowed; }
.mode-btn { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 10px 0 13px; border-radius: 999px; color: #e5e5e5; font-size: 14px; font-weight: 500; }
.mode-btn svg { width: 15px; height: 15px; stroke-width: 2; opacity: .6; }
.mode-btn:hover, .mode-btn[aria-expanded="true"] { background: #262626; }
.mode-menu { right: 0; min-width: 250px; }
.mode-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 11px; text-align: left; }
.mode-menu button span { flex: 1; display: flex; flex-direction: column; }
.mode-menu button b { font-size: 14px; font-weight: 500; color: var(--text); }
.mode-menu button small { font-size: 12.5px; color: var(--faint); }
.mode-menu button i { font-style: normal; color: var(--text); opacity: 0; font-size: 13px; }
.mode-menu button.on i { opacity: 1; }
.mode-menu button:hover { background: #262626; }
#send { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #000; display: grid; place-items: center; transition: .15s; flex: none; }
#send svg { stroke-width: 2.3; width: 19px; height: 19px; }
#send:hover { background: #dcdcdc; }
#send.idle { background: #2e2e2e; color: #8a8a8a; }
#send.stop { background: #fff; color: #000; }
#attach-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pending-att { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; color: var(--muted); max-width: 240px; }
.pending-att span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pending-att button { color: var(--faint); padding: 0 4px; font-size: 14px; }

/* ---------- artifact panel ---------- */
#artifact-panel { width: 48%; min-width: 380px; flex: none; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
#artifact-panel[hidden] { display: none; }
.art-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.art-title-wrap { flex: 1; min-width: 0; }
.art-type { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.art-title { font-weight: 600; font-size: 14.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.art-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.art-tabs button { padding: 4px 11px; border-radius: 7px; font-size: 12.5px; color: var(--muted); }
.art-tabs button.on { background: var(--hover); color: var(--text); }
.art-actions { display: flex; gap: 2px; }
.art-body { flex: 1; position: relative; background: #fff; }
#art-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
#art-code { position: absolute; inset: 0; margin: 0; overflow: auto; background: #0e0e0e; padding: 18px; font: 13px/1.55 var(--mono); }
#art-code[hidden] { display: none; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 40px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 5px; min-width: 200px; z-index: 20; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.menu[hidden] { display: none; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; }
.menu button:hover { background: var(--hover); }

/* ---------- dialogs ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(600px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 6px; font-size: 19px; }
.dialog-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
dialog label.inline { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
dialog textarea, dialog select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); resize: vertical; outline: 0; }
dialog select { width: auto; padding: 6px 10px; }
dialog textarea:focus { border-color: #44444f; }
.opt { color: var(--faint); font-size: 12px; }
.dialog-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn { padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.btn.primary { background: var(--text); color: var(--bg); }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
#instructions { min-height: 260px; font-size: 14px; margin-bottom: 16px; }
input[type=range] { accent-color: var(--accent); }

#scrim { display: none; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  #artifact-panel { position: fixed; inset: 0; width: 100%; min-width: 0; z-index: 40; }
}
@media (max-width: 760px) {
  .only-mobile { display: flex; }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; width: 284px; margin-left: 0 !important; }
  body.sidebar-open #sidebar { transform: none; }
  body.sidebar-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 45; }
  #open-sidebar, #top-new { display: grid !important; }
  #collapse-sidebar { display: none; }
  #thread { padding: 8px 16px 32px; }
  #composer-wrap { padding: 0 10px 10px; }
  body:not(.has-chat) #composer-wrap { padding-bottom: 6vh; }
  #hero-title { font-size: 23px; }
  .msg.user .bubble { max-width: 90%; }
  .mode-btn { padding: 0 8px; }
  .cap-row { gap: 6px; } .cap { height: 34px; padding: 0 12px; font-size: 13px; }
  .thinking .now { max-width: 200px; }
  #mic, .side-search kbd { display: none !important; }
  .chat-item .dots { opacity: .7; }
  #input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .comp-row { gap: 2px; }
}

/* ---------- assistant: badges, drawer, actions, mic ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions span { font-size: 12px; color: var(--good); background: rgba(62,207,142,.08); border: 1px solid rgba(62,207,142,.25); padding: 3px 9px; border-radius: 999px; }
#mic.on { color: var(--bad); background: rgba(255,107,107,.1); }
#drawer { width: min(680px, calc(100vw - 32px)); max-height: 86vh; padding: 20px 22px; }
#drawer[open] { display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; }
.drawer-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.drawer-add:empty { display: none; }
.drawer-add input, .drawer-add select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; outline: 0; color: var(--text); min-width: 0; }
.drawer-add input.grow { flex: 1 1 220px; }
.drawer-add button { padding: 8px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; }
.drawer-body { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 0 -4px; padding: 0 4px; }
.row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 14px; }
.row .main { flex: 1; min-width: 0; }
.row .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row .tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-right: 6px; }
.row .tag.hypothesis { color: var(--warn); }
.row.done .main { color: var(--faint); text-decoration: line-through; }
.row.overdue .sub { color: var(--bad); }
.row input[type=checkbox] { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.row .mini { color: var(--faint); font-size: 12.5px; padding: 3px 7px; border-radius: 7px; }
.row .mini:hover { color: var(--text); background: var(--hover); }
.row .mini.yes:hover { color: var(--good); } .row .mini.no:hover { color: var(--bad); }
.row .mini.del:hover { color: var(--bad); }
.empty { color: var(--faint); font-size: 14px; padding: 20px 4px; text-align: center; }
.score { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ---------- accounts ---------- */
.acc-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.acc-head .grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.acc-head input, .acc-head select, .acc-head textarea, .evform input, .evform select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; outline: 0; color: var(--text); width: 100%; font-size: 14px; }
.acc-head textarea { resize: vertical; min-height: 54px; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.acc-actions button { padding: 8px 13px; border-radius: 10px; border: 1px solid var(--line); font-size: 13.5px; color: var(--text); }
.acc-actions button.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.acc-actions button:hover { border-color: #44444f; }
.warn { background: rgba(245,183,79,.1); border: 1px solid rgba(245,183,79,.35); color: var(--warn); padding: 8px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 10px; }
.sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 16px 0 6px; }
.evform { display: grid; grid-template-columns: 110px 130px 1fr; gap: 6px; margin-bottom: 8px; }
.evform .wide { grid-column: 1 / -1; }
.evform button { grid-column: 1 / -1; padding: 8px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); }
.hyp { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; font-size: 13.5px; }
.hyp b { color: var(--muted); font-weight: 500; }
.stage-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.back { color: var(--muted); font-size: 13px; margin-bottom: 8px; padding: 0; }
.back:hover { color: var(--text); }
@media (max-width: 760px) { .acc-head .grid, .evform { grid-template-columns: 1fr; } }

/* skills */
.skill-new { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.skill-new summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.skill-new form { display: grid; gap: 8px; margin-top: 10px; }
.skill-new input, .skill-new textarea { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); outline: 0; font: inherit; font-size: 13.5px; }
.skill-new textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.skill-new button { justify-self: start; padding: 8px 14px; border-radius: 9px; background: var(--text); color: var(--bg); font-weight: 600; }
.row.off .main { opacity: .5; }

/* dark, thin scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: #3a3a44 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #34343c; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #4a4a55; background-clip: padding-box; border: 3px solid transparent; }

/* code runs */
.run { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin: 6px 0 14px; overflow: hidden; }
.run-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13.5px; }
.run-ico { width: 26px; height: 26px; border-radius: 7px; background: #262626; color: #ddd; display: grid; place-items: center; flex: none; }
.run-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.run-title { flex: 1; font-weight: 500; min-width: 0; }
.run-st { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.run.failed .run-st { color: var(--bad); } .run.skipped { opacity: .7; }
.run-code { border-top: 1px solid var(--line); }
.run-code summary { cursor: pointer; padding: 7px 14px; font-size: 12.5px; color: var(--muted); }
.run-code pre, .run-out { margin: 0; padding: 12px 14px; background: #121212; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; overflow: auto; max-height: 360px; }
.run-code pre code { background: none; padding: 0; }
.run-out { border-top: 1px solid var(--line); white-space: pre-wrap; color: #d6d6dc; }
.run-out.err { color: #f2a19a; }
.run-img { display: block; padding: 12px 14px; border-top: 1px solid var(--line); background: #fff; }
.run-img img { max-width: 100%; display: block; margin: 0 auto; border-radius: 6px; }
.run-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.run-files a { font-size: 12.5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; }
.run-files a:hover { border-color: var(--accent); }
.run-actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); align-items: center; }
.run-actions button { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; color: var(--text); }
.run-actions button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.run-actions button.ghost { border-color: transparent; color: var(--muted); margin-left: auto; }
.run.approve { border-color: #4a4a4a; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 14px 0 4px; font-size: 14px; }
.setting-row small { color: var(--muted); }
.setting-row select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }

/* projects, schedules, telegram */
#chat-crumb { font-size: 13px; color: var(--muted); padding: 3px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; white-space: nowrap; }
#chat-crumb:hover { color: var(--text); border-color: var(--accent); }
#topbar { gap: 10px; }
.proj-banner { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.proj-banner b { color: var(--text); }
.pform { display: grid; gap: 10px; margin-bottom: 16px; }
.pform input, .pform textarea, .sform input, .sform textarea, .sform select { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); outline: 0; font: inherit; font-size: 13.5px; }
.pform textarea { min-height: 120px; resize: vertical; }
.pbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.pbtns button, .sform button.go { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.pbtns button.primary, .sform button.go { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.upl { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px dashed var(--line); font-size: 13px; color: var(--muted); cursor: pointer; }
.upl:hover { color: var(--text); border-color: var(--accent); }
.sform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.sform .wide { grid-column: 1 / -1; }
.sform textarea { min-height: 90px; resize: vertical; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.quick button { font-size: 12.5px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.quick button:hover { color: var(--text); border-color: var(--accent); }
.note-line { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.tg-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 14px 0 4px; display: grid; gap: 8px; font-size: 14px; }
.tg-box small { color: var(--muted); line-height: 1.5; }
.tg-box code { background: var(--hover); padding: 1px 5px; border-radius: 5px; }
.tg-head { display: flex; justify-content: space-between; align-items: center; }
.tg-status { font-size: 12.5px; color: var(--muted); }
.tg-status.ok { color: var(--good); } .tg-status.bad { color: var(--bad); }
.tg-row { display: flex; gap: 8px; }
.tg-row input { flex: 1; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); outline: 0; }
.tg-pair { background: var(--accent-soft); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; }
.tg-pair .code { font: 600 18px ui-monospace, Consolas, monospace; letter-spacing: .12em; color: var(--text); }
.agent .note { display: block; font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

.agent { flex-wrap: wrap; align-items: flex-start; }
.agent .dot { margin-top: 5px; }
.agent > span:nth-child(2) { flex: 1; min-width: 0; }
.agent .note { flex-basis: 100%; max-width: none; padding-left: 16px; margin-top: 2px; }

/* knowledge */
.kb-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.kb-stats span { font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.kb-stats b { color: var(--text); font-weight: 600; }
.drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 12px; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop .btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.drop .btns label { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 13px; }
.drop .btns label:hover { border-color: var(--accent); }
.kb-log { font: 12px/1.6 ui-monospace, Consolas, monospace; color: var(--muted); background: #121212; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-height: 180px; overflow: auto; white-space: pre-wrap; margin-bottom: 12px; }
.kb-row { display: flex; gap: 8px; margin-bottom: 10px; }
.kb-row input { flex: 1; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); outline: 0; }
.kb-row button { padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); color: var(--text); font-size: 13px; white-space: nowrap; }
.kb-hit { font-size: 13px; border-left: 2px solid var(--accent); padding: 4px 10px; margin: 6px 0; color: var(--muted); }
.kb-hit b { color: var(--text); }
.toggle-line { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; margin-bottom: 14px; }
.toggle-line small { color: var(--muted); display: block; }

/* compact code runs: one line, click to see code and output */
.run { margin: 4px 0 8px; }
.run-head { width: 100%; text-align: left; cursor: pointer; padding: 8px 12px; background: none; color: inherit; font: inherit; font-size: 13px; }
.run-head:hover { background: var(--hover); }
.run-head .run-title { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-ico { width: 22px; height: 22px; border-radius: 6px; }
.run-chev { width: 14px; height: 14px; fill: none; stroke: var(--faint); stroke-width: 2; transition: transform .15s; flex: none; }
.run.open .run-chev { transform: rotate(90deg); }
.run-body .run-code { border-top: 1px solid var(--line); }
.run.approve .run-head { cursor: default; }
