/* Vishvarupa Nexus — interface for the V6 agent.
   Dark, luminous, information-dense. All fonts are served same-origin. */

@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/vendor/fonts/SpaceGrotesk-Variable-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/vendor/fonts/JetBrainsMono-Variable-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg-0: #04060c;
  --bg-1: #080c17;
  --glass: rgba(14, 20, 36, 0.72);
  --glass-strong: rgba(18, 26, 46, 0.9);
  --glass-soft: rgba(255, 255, 255, 0.035);
  --line: rgba(130, 170, 255, 0.13);
  --line-strong: rgba(130, 170, 255, 0.26);
  --text: #e8edf8;
  --text-dim: #9aa5bf;
  --text-faint: #66718c;
  --cyan: #4de2ff;
  --violet: #9d7dff;
  --magenta: #ff5fa8;
  --amber: #ffba4a;
  --green: #3ee8a4;
  --red: #ff6070;
  --accent: var(--cyan);
  --accent-2: var(--violet);
  --glow-cyan: 0 0 0 1px rgba(77, 226, 255, 0.35), 0 0 24px rgba(77, 226, 255, 0.18);
  --glow-violet: 0 0 0 1px rgba(157, 125, 255, 0.4), 0 0 24px rgba(157, 125, 255, 0.2);
  --radius: 14px;
  --radius-sm: 9px;
  --rail: 68px;
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(88, 60, 200, 0.22), transparent 60%),
    radial-gradient(900px 600px at 105% 10%, rgba(0, 170, 220, 0.16), transparent 55%),
    radial-gradient(800px 700px at 50% 120%, rgba(255, 70, 160, 0.08), transparent 60%),
    var(--bg-0);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#cosmos { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0.55; }
body::after {
  /* faint grid */
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 85%);
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(77, 226, 255, 0.28); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(130, 170, 255, 0.18); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
[hidden] { display: none !important; }

/* ───────── shell ───────── */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--rail) 1fr; height: 100vh; height: 100dvh; }
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0;
  background: linear-gradient(180deg, rgba(10, 14, 28, 0.9), rgba(6, 9, 18, 0.85));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.rail-logo { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; }
.rail-item {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--text-dim); transition: color .2s, background .2s;
}
.rail-item:hover { color: var(--text); background: var(--glass-soft); text-decoration: none; }
.rail-item[aria-current="page"] { color: var(--cyan); background: rgba(77, 226, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(77, 226, 255, 0.25); }
.rail-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px;
  background: linear-gradient(var(--cyan), var(--violet)); box-shadow: 0 0 12px var(--cyan);
}
.rail-item svg { width: 21px; height: 21px; }
.rail-badge {
  position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--amber); color: #1a1200; font: 700 10px/16px var(--font); text-align: center;
  box-shadow: 0 0 12px rgba(255, 186, 74, 0.6);
}
.rail-spacer { flex: 1; }
.rail-tip {
  position: absolute; left: 54px; white-space: nowrap; padding: 4px 9px; border-radius: 7px; font-size: 12px;
  background: var(--glass-strong); border: 1px solid var(--line-strong); color: var(--text);
  opacity: 0; pointer-events: none; transform: translateX(-4px); transition: all .15s var(--ease);
}
.rail-item:hover .rail-tip, .rail-item:focus-visible .rail-tip { opacity: 1; transform: none; }
.stage { position: relative; min-width: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.view { height: 100%; animation: view-in .35s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────── generic parts ───────── */
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(18px); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--glass-soft); color: var(--text); cursor: pointer;
  transition: all .18s var(--ease); white-space: nowrap;
}
.btn:hover { border-color: rgba(77, 226, 255, 0.5); background: rgba(77, 226, 255, 0.07); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  border: 0; color: #041018; font-weight: 600;
  background: linear-gradient(135deg, var(--cyan), #7ab8ff 55%, var(--violet));
  box-shadow: 0 6px 24px rgba(77, 226, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--cyan), #7ab8ff 55%, var(--violet)); }
.btn-danger { border-color: rgba(255, 96, 112, 0.45); color: #ffc2c8; }
.btn-danger:hover { background: rgba(255, 96, 112, 0.1); border-color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-dim); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--glass-soft); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--glass-soft); color: var(--text-dim); font-size: 12.5px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font: 600 11px/18px var(--mono); letter-spacing: .02em; background: rgba(130, 170, 255, 0.1); color: var(--text-dim); }
.tag.ok { background: rgba(62, 232, 164, 0.12); color: var(--green); }
.tag.warn { background: rgba(255, 186, 74, 0.13); color: var(--amber); }
.tag.err { background: rgba(255, 96, 112, 0.13); color: var(--red); }
.tag.info { background: rgba(77, 226, 255, 0.12); color: var(--cyan); }
.tag.violet { background: rgba(157, 125, 255, 0.14); color: var(--violet); }
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: rgba(5, 8, 16, 0.6); color: var(--text); outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: rgba(77, 226, 255, 0.6); box-shadow: 0 0 0 3px rgba(77, 226, 255, 0.12); }
.textarea { resize: vertical; min-height: 80px; font-family: var(--mono); font-size: 13px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; border: 1px solid var(--line); background: rgba(5, 8, 16, 0.5); gap: 3px; }
.seg button { border: 0; background: transparent; color: var(--text-dim); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg button[aria-pressed="true"] { background: rgba(77, 226, 255, 0.12); color: var(--cyan); box-shadow: inset 0 0 0 1px rgba(77, 226, 255, 0.3); }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: rgba(130, 170, 255, 0.18); transition: .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #cfd8ee; transition: .2s var(--ease); }
.switch input:checked + span { background: linear-gradient(135deg, var(--cyan), var(--violet)); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(77, 226, 255, 0.25); border-top-color: var(--cyan); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: grid; place-items: center; gap: 10px; padding: 40px 20px; text-align: center; color: var(--text-faint); }
.section-title { font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); }
.kbd { font: 600 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); color: var(--text-dim); background: rgba(255, 255, 255, 0.03); }

/* ───────── orb ───────── */
.orb {
  --size: 120px; --c1: var(--cyan); --c2: var(--violet);
  position: relative; display: inline-block; width: var(--size); height: var(--size); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), transparent 12%),
              radial-gradient(circle at 50% 55%, var(--c1), transparent 58%),
              radial-gradient(circle at 60% 70%, var(--c2), transparent 62%),
              #0a1024;
  box-shadow: 0 0 calc(var(--size) * .35) rgba(77, 226, 255, 0.35), inset 0 0 calc(var(--size) * .25) rgba(255, 255, 255, 0.15);
  animation: breathe 4.5s ease-in-out infinite;
}
.orb::before, .orb::after {
  content: ""; position: absolute; inset: -12%; border-radius: 50%;
  border: 1.5px solid rgba(77, 226, 255, 0.25); border-top-color: rgba(77, 226, 255, 0.85);
  animation: spin 9s linear infinite; opacity: .55;
}
.orb::after { inset: -24%; border-color: rgba(157, 125, 255, 0.18); border-bottom-color: rgba(157, 125, 255, 0.7); animation-duration: 14s; animation-direction: reverse; }
.orb-mini { --size: 28px; }
.orb-mini::after { display: none; }
.orb[data-state="thinking"] { animation: breathe 1.6s ease-in-out infinite; --c1: #6fe9ff; }
.orb[data-state="thinking"]::before { animation-duration: 1.4s; opacity: 1; }
.orb[data-state="thinking"]::after { animation-duration: 2.4s; opacity: .9; }
.orb[data-state="acting"] { --c1: var(--green); --c2: var(--cyan); animation: breathe 1s ease-in-out infinite; }
.orb[data-state="acting"]::before { border-top-color: var(--green); animation-duration: .9s; opacity: 1; }
.orb[data-state="waiting"] { --c1: var(--amber); --c2: var(--magenta); box-shadow: 0 0 calc(var(--size) * .4) rgba(255, 186, 74, 0.45); }
.orb[data-state="waiting"]::before { border-top-color: var(--amber); animation-duration: 3s; }
.orb[data-state="error"] { --c1: var(--red); --c2: var(--magenta); }
@keyframes breathe { 0%, 100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.045); filter: brightness(1.18); } }

/* ───────── chat view ───────── */
.view-chat { display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; }
.view-chat.no-live { grid-template-columns: 290px minmax(0, 1fr) 0; }
.convos {
  display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.75), rgba(6, 9, 18, 0.55)); backdrop-filter: blur(14px);
}
.convos-head { display: grid; gap: 10px; padding: 16px 14px 10px; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-size: 17px; letter-spacing: .02em; }
.brand span { font: 600 10.5px var(--mono); letter-spacing: .18em; color: var(--cyan); text-transform: uppercase; }
.convo-list { flex: 1; overflow: auto; padding: 4px 8px 16px; }
.convo-group { margin: 12px 8px 4px; }
.convo-row { display: flex; align-items: center; gap: 2px; }
.convo-row .convo { flex: 1; min-width: 0; }
.convo-actions { display: flex; flex-shrink: 0; gap: 0; }
.convo-actions .icon-btn { width: 28px; height: 28px; }

.convo {
  display: grid; gap: 1px; width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; text-align: left; cursor: pointer; color: var(--text);
}
.convo:hover { background: var(--glass-soft); }
.convo[aria-current="true"] { background: rgba(77, 226, 255, 0.07); border-color: rgba(77, 226, 255, 0.22); }
.convo-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head {
  display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 18px; border-bottom: 1px solid var(--line);
  background: rgba(6, 9, 18, 0.45); backdrop-filter: blur(12px);
}
h1.thread-title { margin: 0; font-size: inherit; }
.thread-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brain-badge { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line); font: 500 12px var(--mono); color: var(--text-dim); background: rgba(5, 8, 16, 0.4); }
.brain-badge .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: breathe 2.4s infinite; }
.brain-badge.down .pulse { background: var(--red); box-shadow: 0 0 10px var(--red); }
.thread { flex: 1; overflow: auto; padding: 26px 0 30px; scroll-behavior: smooth; }
.thread-inner { width: min(860px, 100% - 48px); margin: 0 auto; display: grid; gap: 22px; }
.msg { display: grid; gap: 8px; animation: view-in .3s var(--ease); }
.msg-user { justify-items: end; }
.msg-user .bubble {
  max-width: 78%; padding: 11px 16px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; word-wrap: break-word;
  background: linear-gradient(135deg, rgba(77, 226, 255, 0.16), rgba(157, 125, 255, 0.16));
  border: 1px solid rgba(130, 170, 255, 0.28);
}
.msg-assistant { grid-template-columns: 30px minmax(0, 1fr); column-gap: 14px; }
.msg-avatar { grid-row: 1 / span 20; align-self: start; }
.msg-assistant > :not(.msg-avatar) { grid-column: 2; }
.msg-assistant .content { min-width: 0; }
.msg-who { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-dim, #93a0b8); }
.msg-user .msg-who { text-align: right; }
.msg-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-faint); }
.msg-foot .icon-btn { width: 28px; height: 28px; }
.msg-foot .icon-btn svg { width: 15px; height: 15px; }
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--glass-soft); font-size: 12.5px; }
.file-chip svg { width: 14px; height: 14px; color: var(--cyan); }
.file-chip button { border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: 0 0 0 4px; }

/* message content (sanitized markdown) */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.08em; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 .8em; }
.md li { margin: .2em 0; }
.md li::marker { color: var(--cyan); }
.md a { color: var(--cyan); border-bottom: 1px dashed rgba(77, 226, 255, .4); }
.md a:hover { text-decoration: none; border-bottom-style: solid; }
.md strong { color: #fff; }
.md code { font: .88em var(--mono); padding: .12em .4em; border-radius: 6px; background: rgba(130, 170, 255, 0.12); color: #cfe6ff; }
.md pre { position: relative; margin: .6em 0 1em; padding: 14px 16px; border-radius: 12px; overflow: auto; background: rgba(3, 5, 12, 0.85); border: 1px solid var(--line); }
.md pre code { padding: 0; background: none; font-size: 13px; line-height: 1.6; color: #d7e3ff; }
.md blockquote { margin: .6em 0; padding: .3em 1em; border-left: 3px solid var(--violet); color: var(--text-dim); background: rgba(157, 125, 255, 0.05); border-radius: 0 8px 8px 0; }
.md table { border-collapse: collapse; margin: .6em 0 1em; font-size: .93em; display: block; overflow: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 6px 10px; text-align: left; }
.md th { background: rgba(77, 226, 255, 0.07); }
.md hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); margin: 1.3em 0; }
.md img { max-width: 100%; border-radius: 10px; }
.md .v6-remote-image { border: 1px dashed var(--line-strong); background: var(--glass-soft); color: var(--text-dim); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.copy-code { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; }
.md pre:hover .copy-code { opacity: 1; }
.streaming-caret::after { content: "▍"; color: var(--cyan); animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* media */
.media { margin: 6px 0 4px; display: grid; gap: 6px; justify-items: start; }
.media img, .media video { max-width: min(640px, 100%); max-height: 520px; border-radius: 14px; border: 1px solid var(--line-strong); background: #000; box-shadow: 0 16px 50px rgba(0, 0, 0, .45); }
.media audio { width: min(480px, 100%); }
.media-open { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; }
.media figcaption { display: flex; gap: 12px; font-size: 12px; color: var(--text-faint); }
.lightbox { place-items: center; padding: 4vh 4vw; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 12px; box-shadow: 0 30px 90px rgba(0, 0, 0, .7); }
.lightbox-bar { display: flex; gap: 14px; align-items: center; margin-top: 12px; color: var(--text-dim); font-size: 13px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; aspect-ratio: 1; background: #000; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--cyan); }

/* inline activity */
.activity { display: grid; gap: 6px; margin: 2px 0 10px; }
.tool-card {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 11px; border: 1px solid var(--line); background: rgba(8, 12, 24, 0.6);
  font-size: 13px;
}
.tool-card .ti { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: rgba(77, 226, 255, 0.1); color: var(--cyan); }
.tool-card .ti svg { width: 15px; height: 15px; }
.tool-card .tname { font-family: var(--mono); font-size: 12.5px; }
.tool-card .tdetail { color: var(--text-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card.running { border-color: rgba(77, 226, 255, 0.35); box-shadow: var(--glow-cyan); }
.tool-card.error .ti { background: rgba(255, 96, 112, 0.12); color: var(--red); }
.tool-card.done .ti { background: rgba(62, 232, 164, 0.1); color: var(--green); }
.tool-card[data-power="MCP"] .ti { background: rgba(157, 125, 255, 0.14); color: var(--violet); }
.tool-card details { grid-column: 1 / -1; }
.tool-card summary { cursor: pointer; color: var(--text-faint); font-size: 12px; }
.tool-card pre { margin: 6px 0 0; white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--text-dim); max-height: 220px; overflow: auto; }

/* approval */
.approval {
  position: relative; display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; margin-top: 8px;
  border: 1px solid rgba(255, 186, 74, 0.45);
  background: linear-gradient(135deg, rgba(255, 186, 74, 0.08), rgba(255, 95, 168, 0.05));
  box-shadow: 0 0 28px rgba(255, 186, 74, 0.12);
}
.approval-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.approval-head svg { width: 18px; height: 18px; color: var(--amber); }
.approval-item { display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; background: rgba(4, 6, 12, 0.55); border: 1px solid var(--line); }
.approval-item pre { margin: 0; white-space: pre-wrap; font: 12.5px/1.5 var(--mono); color: #ffe3b0; max-height: 240px; overflow: auto; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approval.decided { border-color: var(--line); background: var(--glass-soft); box-shadow: none; }

/* composer */
.composer-wrap { padding: 0 24px 18px; }
.composer {
  width: min(860px, 100%); margin: 0 auto; border-radius: 18px; padding: 10px 10px 8px 16px;
  background: var(--glass-strong); border: 1px solid var(--line-strong);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(77, 226, 255, 0.04);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: rgba(77, 226, 255, 0.5); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), var(--glow-cyan); }
.composer.dragging { border-style: dashed; border-color: var(--cyan); }
.composer textarea {
  display: block; width: 100%; max-height: 260px; min-height: 26px; padding: 6px 0; border: 0; outline: none; resize: none;
  background: transparent; color: var(--text); font: 15px/1.55 var(--font);
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.composer-bar .grow { flex: 1; }
.send-btn { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 12px; }
.send-btn svg { width: 18px; height: 18px; }
.stop-btn { border-color: rgba(255, 96, 112, 0.5); color: #ffc2c8; }
.composer-hint { width: min(860px, 100%); margin: 8px auto 0; font-size: 11.5px; color: var(--text-faint); text-align: center; }
.profile-menu { position: absolute; bottom: 100%; margin-bottom: 8px; min-width: 260px; padding: 6px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); z-index: 20; }
.profile-menu button { display: grid; width: 100%; text-align: left; gap: 1px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.profile-menu button:hover { background: rgba(77, 226, 255, 0.08); }
.profile-menu b { font-size: 13px; }
.profile-menu span { font-size: 12px; color: var(--text-faint); }

/* hero (empty conversation) */
.hero { display: grid; justify-items: center; gap: 18px; padding: 8vh 24px 20px; text-align: center; }
.hero h1 { margin: 10px 0 0; font-size: clamp(26px, 3.2vw, 38px); font-weight: 600; letter-spacing: -.02em;
  background: linear-gradient(120deg, #fff 20%, var(--cyan) 60%, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0; color: var(--text-dim); max-width: 560px; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: min(760px, 100%); margin-top: 10px; }
.suggestion {
  display: grid; gap: 4px; padding: 14px 16px; text-align: left; border-radius: 14px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); transition: all .2s var(--ease);
}
.suggestion:hover { border-color: rgba(77, 226, 255, 0.45); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0, 0, 0, .35), var(--glow-cyan); }
.suggestion b { font-size: 14px; }
.suggestion span { font-size: 12.5px; color: var(--text-dim); }

/* live panel */
.live { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: rgba(6, 9, 18, 0.55); backdrop-filter: blur(14px); overflow: hidden; }
.live-top { display: grid; justify-items: center; gap: 12px; padding: 46px 18px 18px; border-bottom: 1px solid var(--line); }
.live-state { font: 600 12px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--cyan); }
.live-state[data-state="waiting"] { color: var(--amber); }
.live-state[data-state="error"] { color: var(--red); }
.live-sub { font-size: 12.5px; color: var(--text-faint); text-align: center; min-height: 18px; }
.live-body { flex: 1; overflow: auto; padding: 14px 16px 20px; display: grid; align-content: start; gap: 18px; }
.timeline { display: grid; gap: 0; }
.tl-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding: 0 0 12px; }
.tl-item::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line-strong); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--bg-1); margin-top: 2px; }
.tl-item.running .tl-dot { border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: breathe 1s infinite; }
.tl-item.done .tl-dot { border-color: var(--green); background: rgba(62, 232, 164, 0.25); }
.tl-item.error .tl-dot { border-color: var(--red); background: rgba(255, 96, 112, 0.25); }
.tl-item.waiting .tl-dot { border-color: var(--amber); background: rgba(255, 186, 74, 0.3); }
.tl-name { font: 500 12.5px var(--mono); }
.tl-detail { font-size: 12px; color: var(--text-faint); overflow-wrap: anywhere; }
.side-card { display: grid; gap: 8px; }
.side-list { display: grid; gap: 6px; }
.side-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; background: var(--glass-soft); border: 1px solid var(--line); font-size: 12.5px; min-width: 0; }
.side-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row svg { width: 14px; height: 14px; flex: none; color: var(--cyan); }

/* ───────── pages (tools, memory, brain, system) ───────── */
.page { height: 100%; overflow: auto; padding: 28px clamp(18px, 3vw, 44px) 60px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-dim); max-width: 720px; }
.page-head .grow { flex: 1; }
.grid { display: grid; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { min-width: 0; padding: 18px; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(18px); display: grid; gap: 12px; align-content: start; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, rgba(77, 226, 255, 0.18), rgba(157, 125, 255, 0.18)); color: var(--cyan); flex: none; }
.card-icon svg { width: 19px; height: 19px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row .grow { flex: 1; }
.tool-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 12px; border-radius: 10px; background: rgba(4, 6, 12, 0.45); border: 1px solid var(--line); }
.tool-row .tn { font: 500 13px var(--mono); }
.tool-row .td { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-dim); }
.stat { display: grid; gap: 2px; padding: 14px 16px; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--line); }
.stat b { font: 600 22px var(--mono); }
.stat span { font-size: 12px; color: var(--text-faint); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.meter { height: 6px; border-radius: 6px; background: rgba(130, 170, 255, 0.12); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.mem-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; padding: 12px 14px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); }
.mem-history summary { cursor: pointer; margin-top: 22px; }
.mem-row .mt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.mem-row .mm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--text-faint); }

/* studio */
.studio-view { display: flex; flex-direction: column; height: 100%; }
.studio-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(6, 9, 18, 0.7); backdrop-filter: blur(12px); min-width: 0; }
.studio-bar .faint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-frame { flex: 1; width: 100%; border: 0; background: #0b0f1a; }
@media (max-width: 820px) { .studio-bar .faint { display: none; } }

/* activity */
.rail-badge-info { background: var(--cyan); box-shadow: 0 0 12px rgba(77, 226, 255, 0.6); color: #041018; }
.activity-drawer { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(420px, 94vw); display: flex; flex-direction: column;
  background: var(--glass-strong); border-left: 1px solid var(--line-strong); box-shadow: -30px 0 80px rgba(0, 0, 0, .55); backdrop-filter: blur(20px);
  animation: slide-in .25s var(--ease); }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.activity-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.activity-list { flex: 1; overflow: auto; padding: 8px 10px 20px; display: grid; align-content: start; gap: 4px; }
.activity-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 8px; border-radius: 10px; }
.activity-row:hover { background: var(--glass-soft); }
.activity-icon { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 8px; }
.activity-icon svg { width: 15px; height: 15px; }
.activity-text { min-width: 0; font-size: 13px; display: grid; gap: 2px; }
.activity-detail { font-size: 12px; overflow-wrap: anywhere; }

/* ───────── modal, palette, toasts ───────── */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding-top: 10vh; background: rgba(2, 4, 10, 0.62); backdrop-filter: blur(6px); animation: view-in .2s var(--ease); }
.modal { width: min(640px, calc(100vw - 32px)); max-height: 80vh; overflow: auto; padding: 22px; border-radius: 18px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); display: grid; gap: 16px; }
.modal h2 { margin: 0; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.palette-box { width: min(620px, calc(100vw - 32px)); border-radius: 16px; overflow: hidden; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), var(--glow-violet); }
.palette-box input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font-size: 16px; outline: none; }
.palette-list { max-height: 52vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: 14px; }
.palette-item[aria-selected="true"] { background: rgba(77, 226, 255, 0.1); box-shadow: inset 0 0 0 1px rgba(77, 226, 255, 0.25); }
.palette-item svg { width: 17px; height: 17px; color: var(--text-dim); flex: none; }
.palette-item .ph { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.toasts { position: fixed; z-index: 60; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 11px 14px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); font-size: 13.5px; animation: view-in .25s var(--ease); }
.toast.err { border-color: rgba(255, 96, 112, 0.55); }
.toast.ok { border-color: rgba(62, 232, 164, 0.5); }

/* ───────── notebooks ───────── */
.view-notebooks { display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; }
.nb-left, .nb-right {
  display: flex; flex-direction: column; min-height: 0; background: linear-gradient(180deg, rgba(8, 12, 24, 0.75), rgba(6, 9, 18, 0.55)); backdrop-filter: blur(14px);
}
.nb-left { border-right: 1px solid var(--line); }
.nb-right { border-left: 1px solid var(--line); padding: 14px 14px 0; gap: 12px; }
.nb-list { max-height: 34%; overflow: auto; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.nb-sources-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 4px 16px; }
.nb-sources-head .section-title { margin: 0; }
.nb-sources { flex: 1; overflow: auto; padding: 4px 10px 16px; display: grid; align-content: start; gap: 6px; border-radius: 12px; transition: background .2s; }
.nb-sources.dragging { background: rgba(77, 226, 255, 0.06); box-shadow: inset 0 0 0 1px rgba(77, 226, 255, 0.35); }
.nb-drop { display: grid; justify-items: center; gap: 6px; padding: 26px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; text-align: center; font-size: 13px; color: var(--text-dim); }
.nb-drop .ic { width: 26px; height: 26px; color: var(--cyan); }
.nb-source { display: grid; gap: 6px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(5, 8, 16, 0.4); transition: opacity .2s, border-color .2s; }
.nb-source:hover { border-color: var(--line-strong); }
.nb-source.off { opacity: .55; }
.nb-source-main { display: flex; align-items: center; gap: 9px; cursor: pointer; min-width: 0; }
.nb-source-main input { accent-color: var(--cyan); width: 15px; height: 15px; flex: none; }
.nb-source-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.nb-actions { display: flex; align-items: center; gap: 6px; }
.nb-cites { margin-top: 2px; }
.nb-cites .chip b { color: var(--cyan); font-size: 11px; }
.nb-tabs { align-self: start; }
.nb-notes, .nb-viewer { flex: 1; overflow: auto; padding-bottom: 18px; display: grid; align-content: start; gap: 10px; }
.nb-note { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(5, 8, 16, 0.45); font-size: 13px; }
.nb-note .md { max-height: 260px; overflow: auto; }
.nb-artifact { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(169, 125, 255, 0.3); background: rgba(169, 125, 255, 0.06); }
.nb-source-text { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.6 var(--mono); color: var(--text-dim); padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 5, 12, 0.6); }
.nb-generate { width: 138px; height: 32px; padding-block: 0; font-size: 13px; }
.only-medium { display: none; }
@media (max-width: 1180px) {
  .view-notebooks { grid-template-columns: 270px minmax(0, 1fr); }
  .only-medium { display: inline-grid; }
  .nb-right { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 92vw); z-index: 30; transform: translateX(100%); transition: transform .3s var(--ease); box-shadow: -20px 0 60px rgba(0, 0, 0, .5); background: var(--glass-strong); }
  .view-notebooks.right-open .nb-right { transform: none; }
}
@media (max-width: 820px) {
  .view-notebooks { grid-template-columns: minmax(0, 1fr); }
  .nb-left { position: fixed; left: 0; top: 0; bottom: var(--bar); width: min(310px, 88vw); z-index: 30; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: 20px 0 60px rgba(0, 0, 0, .5); background: var(--glass-strong); }
  .view-notebooks.left-open .nb-left { transform: none; }
  .nb-right { bottom: var(--bar); }
  .nb-actions .btn-label { display: none; }
  .nb-actions { gap: 2px; }
  .nb-generate { width: 44px; padding: 0 4px; }
}

.tool-link { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 6px; justify-self: start; font-size: 12px; color: var(--cyan); text-decoration: none; }
.tool-link:hover { text-decoration: underline; }
.tool-link .ic svg { width: 13px; height: 13px; }

.mic-btn.recording { color: var(--red); box-shadow: 0 0 0 2px rgba(255, 96, 112, 0.5); animation: breathe 1.6s infinite; }
.mic-btn.busy { opacity: .6; pointer-events: none; }
.msg-foot .icon-btn.active { color: var(--cyan); }

/* ───────── missions ───────── */
.mission.stuck { border-color: rgba(255, 186, 74, 0.35); }
.mission-objective { font-weight: 600; font-size: 15px; line-height: 1.4; }
.progress { height: 6px; border-radius: 99px; background: rgba(130, 170, 255, 0.1); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet)); box-shadow: 0 0 12px rgba(77, 226, 255, 0.5); transition: width .5s var(--ease); }
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; }
.pipe-step { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 4px 10px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-step .ic svg { width: 12px; height: 12px; }
.pipe-step.completed { color: var(--green); border-color: rgba(62, 232, 164, 0.35); }
.pipe-step.running { color: var(--cyan); border-color: rgba(77, 226, 255, 0.45); box-shadow: 0 0 12px rgba(77, 226, 255, 0.2); }
.pipe-step.waiting_approval { color: var(--amber); border-color: rgba(255, 186, 74, 0.45); }
.pipe-step.failed { color: var(--red); border-color: rgba(255, 96, 112, 0.45); }
.mission-note { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; background: var(--glass-soft); border: 1px solid var(--line); color: var(--text-dim); }
.mission-note .ic svg { width: 14px; height: 14px; }
.mission-note.warn { border-color: rgba(255, 186, 74, 0.35); color: var(--amber); }
.mission-note.err { border-color: rgba(255, 96, 112, 0.35); color: var(--red); }
.mission-preview { font-size: 12.5px; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--line-strong); }
.mission-preview ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.task-row {
  display: grid; grid-template-columns: 110px minmax(0, 1fr) auto auto 90px; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(4, 6, 12, 0.45); color: var(--text); text-align: left; cursor: pointer;
}
.task-row:hover { border-color: var(--line-strong); background: var(--glass-soft); }
.task-cap { justify-self: start; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.task-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-extras { display: inline-flex; gap: 10px; font-size: 11.5px; }
.task-extras span { display: inline-flex; align-items: center; gap: 3px; }
.task-extras .ic svg { width: 12px; height: 12px; }
.task-time { font-size: 11.5px; text-align: right; }
@media (max-width: 820px) {
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-cap, .task-extras, .task-time { display: none; }
}

/* ───────── settings ───────── */
.settings-grid { columns: 2 440px; column-gap: 18px; }
.settings-grid > .card { break-inside: avoid; margin-bottom: 18px; }
.setting-row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.setting-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.setting-text b { font-weight: 500; font-size: 13.5px; }
.setting-text span { font-size: 12px; color: var(--text-faint); }
.setting-sub { padding-left: 14px; border-left: 2px solid var(--line); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-faint); cursor: pointer; }
.chip-x:hover { color: var(--red); background: rgba(255, 96, 112, 0.12); }
.chip-x svg { width: 11px; height: 11px; }
.range { width: 100%; accent-color: var(--cyan); }
.code-snippet { position: relative; }
.code-snippet pre { margin: 0; padding: 10px 40px 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(3, 5, 12, 0.6); font: 12px/1.55 var(--mono); color: var(--text-dim); white-space: pre-wrap; word-break: break-all; }
.code-snippet .icon-btn { position: absolute; top: 6px; right: 6px; }
.check-chip input { accent-color: var(--cyan); margin: 0; }
.check-chip:has(input:checked) { color: var(--cyan); border-color: rgba(77, 226, 255, 0.35); }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* ───────── operations ───────── */
.policy-result { display: grid; gap: 6px; min-height: 8px; }
.cap-row { border-radius: 10px; border: 1px solid var(--line); background: rgba(4, 6, 12, 0.45); padding: 9px 12px; }
.cap-row[open] { border-color: var(--line-strong); background: var(--glass-soft); }
.cap-row summary { display: grid; grid-template-columns: 150px 92px 90px minmax(0, 1fr); align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.cap-row summary::-webkit-details-marker { display: none; }
.cap-name { font: 600 13px var(--mono); overflow: hidden; text-overflow: ellipsis; }
.cap-row summary .tag { justify-self: start; }
.cap-sub { font-size: 12px; }
.cap-detail { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ops-cols { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.audit-row { display: grid; grid-template-columns: 82px minmax(0, 1fr) 80px; gap: 4px 10px; align-items: center; padding: 7px 10px; border-radius: 9px; background: rgba(4, 6, 12, 0.45); border: 1px solid var(--line); font-size: 13px; }
.audit-action { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-time { font-size: 11.5px; text-align: right; }
.audit-reason { grid-column: 2 / -1; font-size: 12px; }
@media (max-width: 1000px) { .ops-cols { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .cap-row summary { grid-template-columns: minmax(0, 1fr) auto; }
  .cap-sub, .cap-detail { display: none; }
}

/* ───────── browser ───────── */
.browser-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.browser-shot { min-height: 260px; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 5, 12, 0.6); overflow: hidden; display: grid; }
.browser-shot img { width: 100%; height: auto; display: block; }
.computer-screen { aspect-ratio: 1280 / 800; border-radius: 12px; border: 1px solid var(--line); background: rgba(3, 5, 12, 0.6); overflow: hidden; display: grid; cursor: crosshair; }
.computer-screen img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; }
.computer-steps { max-height: 360px; overflow-y: auto; }
.computer-steps .side-row > span:nth-child(3) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.result-row { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(4, 6, 12, 0.45); }
.result-title { font-weight: 600; font-size: 13.5px; }
.result-url { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) { .browser-cols { grid-template-columns: 1fr; } }
.yantra-cols { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .yantra-cols { grid-template-columns: 1fr; } }

/* ───────── responsive ───────── */
.only-narrow { display: none; }
@media (max-width: 1180px) {
  .view-chat, .view-chat.no-live { grid-template-columns: 270px minmax(0, 1fr); }
  .live { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 90vw); z-index: 30; transform: translateX(100%); transition: transform .3s var(--ease); box-shadow: -20px 0 60px rgba(0, 0, 0, .5); }
  .view-chat.live-open .live { transform: none; }
}
@media (max-width: 820px) {
  :root { --rail: 0px; --bar: calc(58px + env(safe-area-inset-bottom, 0px)); }
  .app { grid-template-columns: 1fr; }
  /* Every section stays reachable on a phone: the bar scrolls sideways,
     with the edge faded to show there is more. */
  .rail { position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 40; flex-direction: row; justify-content: flex-start; gap: 2px; height: var(--bar); padding: 6px 8px env(safe-area-inset-bottom, 0px); border-right: 0; border-top: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .rail::-webkit-scrollbar { display: none; }
  .rail-item { flex: 0 0 auto; scroll-snap-align: start; }
  .rail-logo, .rail-spacer, .rail-tip { display: none; }
  .rail-item[aria-current="page"]::before { display: none; }
  .stage { height: calc(100vh - var(--bar)); height: calc(100dvh - var(--bar)); }
  .view-chat, .view-chat.no-live { grid-template-columns: minmax(0, 1fr); }
  .convos { position: fixed; left: 0; top: 0; bottom: var(--bar); width: min(300px, 88vw); z-index: 30; transform: translateX(-100%); transition: transform .3s var(--ease); }
  .view-chat.convos-open .convos { transform: none; }
  .only-narrow { display: inline-grid; }
  .thread-head { gap: 8px; padding: 0 10px; }
  .thread-head .brain-badge span:last-child, .thread-head .agent-label-text { display: none; }
  .composer-bar .faint { display: none; }
  .suggestions { grid-template-columns: 1fr; }
  .msg-user .bubble { max-width: 92%; }
  .thread-inner { width: calc(100% - 28px); }
  .composer-wrap { padding: 0 10px 10px; }
  .page { padding: 20px 14px 80px; }
  .toasts { bottom: calc(var(--bar) + 14px); right: 12px; left: 12px; }
  /* Under 16px, iPhones zoom into a text box when it is tapped, which pushes the page off the screen. */
  .input, .textarea, .select, .composer textarea, .member-compose-row textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  #cosmos { display: none; }
}

/* Rajya */
.meter i.warn { background: linear-gradient(90deg, var(--amber, #ffb547), #ff6b6b); }
.table-wrap { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-weight: 600; color: var(--text-dim, #9aa6c8); padding: 6px 8px; border-bottom: 1px solid rgba(130, 170, 255, 0.16); }
.data-table td { padding: 6px 8px; border-bottom: 1px solid rgba(130, 170, 255, 0.08); vertical-align: top; }

/* Gurukula */
.gk-steps { flex-wrap: wrap; }
.gk-steps button { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gk-points { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 13.5px; color: var(--text-dim); }
.gk-body { font-size: 15px; line-height: 1.65; }
.gk-question { border: 1px solid rgba(130, 170, 255, 0.14); border-radius: 12px; padding: 12px 14px; margin: 0; display: grid; gap: 8px; }
.gk-question legend { font-weight: 600; padding: 0 6px; font-size: 14px; }
.gk-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; border: 1px solid transparent; }
.gk-option:hover { background: rgba(130, 170, 255, 0.06); }
.gk-option:focus-within { border-color: rgba(77, 226, 255, 0.6); }
.gk-option.right { border-color: rgba(80, 220, 150, 0.5); background: rgba(80, 220, 150, 0.08); }
.gk-option.wrong { border-color: rgba(255, 120, 120, 0.5); background: rgba(255, 120, 120, 0.08); }
.gk-option .tag { margin-left: auto; }
.gk-line { display: grid; grid-template-columns: 80px 1fr; gap: 10px; font-size: 13.5px; line-height: 1.55; }
.gk-line b { color: var(--cyan); }
.gk-line.skeptic b { color: var(--amber); }
.gk-line.student b { color: var(--violet); }

/* Matsya */
.matsya-cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.matsya-move { border-left: 2px solid rgba(77, 226, 255, 0.35); padding: 4px 0 4px 12px; display: grid; gap: 4px; }
.matsya-move.missing { border-left-color: rgba(255, 186, 74, 0.6); opacity: 0.8; }

/* Supreme Soul */
.supreme-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.supreme-module { text-decoration: none; color: inherit; gap: 8px; }
.supreme-module:hover { border-color: rgba(77, 226, 255, 0.35); }
.supreme .stat { text-decoration: none; color: inherit; }

/* Task grants */
.grant-bar { display: flex; align-items: center; gap: 10px; margin: 0 20px 8px; padding: 8px 12px; border-radius: 10px; font-size: 13px;
  background: rgba(255, 186, 74, 0.1); border: 1px solid rgba(255, 186, 74, 0.35); }
.grant-bar[hidden] { display: none; }
.effort-select { background: transparent; color: var(--text-dim); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 12.5px; }
.effort-select:focus-visible { outline: 2px solid rgba(77, 226, 255, 0.6); outline-offset: 1px; }

/* Talk mode */
.talk-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 8px 12px; border-radius: 12px; font-size: 13px;
  background: rgba(77, 226, 255, 0.08); border: 1px solid rgba(77, 226, 255, 0.3); }
.talk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); animation: talk-pulse 1.2s ease-in-out infinite; }
@keyframes talk-pulse { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .talk-dot { animation: none; } }
.talk-btn.recording { color: var(--cyan); }

.md pre.v6-markdown-fallback { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }

/* Keyboard shortcut past the conversation list; visible only when focused. */
.skip-link { position: absolute; left: -9999px; top: auto; }
.skip-link:focus { left: 12px; top: 12px; z-index: 1000; padding: 8px 14px; border-radius: 8px; background: #0b1226; color: #e8eefc; border: 2px solid var(--cyan, #4cc9ff); text-decoration: none; }

/* Health check and first-run panel */
.health-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.health-check { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.health-check .tag { white-space: nowrap; }
.health-fix { margin-top: 4px; }
.getting-started { text-align: left; max-width: 640px; width: 100%; margin: 0 auto 18px; }

/* Plan step graph */
.step-graph { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.graph-column { display: grid; gap: 8px; align-content: start; min-width: 200px; max-width: 260px; }
.graph-step { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel, transparent); display: grid; gap: 4px; }
.graph-step[data-state="completed"] { border-color: color-mix(in srgb, var(--ok, #3c9) 45%, var(--line)); }
.graph-step[data-state="failed"] { border-color: color-mix(in srgb, var(--err, #e55) 55%, var(--line)); }
.graph-step[data-state="waiting_approval"] { border-color: color-mix(in srgb, var(--warn, #db3) 55%, var(--line)); }
.graph-result { font-size: 12px; max-height: 6.5em; overflow: hidden; }

/* Guided brain setup */
.setup-wizard { width: min(640px, 94vw); display: grid; gap: 12px; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.setup-choice { display: grid; gap: 4px; text-align: left; cursor: pointer; }
.setup-choice:hover, .setup-choice:focus-visible { border-color: var(--line-strong); }
.setup-message { min-height: 1.4em; font-size: 13px; }

/* Sign-in and members' page */
.signin-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.signin-card { width: min(420px, 100%); display: grid; gap: 12px; }
.signin-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.member-page { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; }
.member-preview { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 6px 16px; font-size: 13px; background: rgba(157, 125, 255, 0.16); border-bottom: 1px solid var(--line); }
.member-preview[hidden] { display: none; }
.member-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.member-brand { font-size: 16px; }
.member-menu-toggle { display: none; }
.member-layout { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; min-height: 0; }
.member-list { border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 0; }
.member-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.member-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 8px 0 4px; }
.member-conversation { width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; padding: 7px 9px; color: inherit; cursor: pointer; display: grid; gap: 2px; }
.member-conversation:hover { background: rgba(130, 170, 255, 0.06); }
.member-conversation[aria-current="true"] { border-color: var(--line-strong); background: rgba(130, 170, 255, 0.08); }
.member-conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-conv-time { font-size: 11.5px; }
.member-main { display: grid; grid-template-rows: 1fr auto auto; min-height: 0; min-width: 0; }
.member-thread { overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }
.member-message { display: grid; gap: 6px; max-width: 780px; width: 100%; margin: 0 auto; }
.member-message.from-user .member-text { white-space: pre-wrap; overflow-wrap: anywhere; background: rgba(77, 226, 255, 0.08); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; justify-self: start; }
.member-message.from-v6 .member-text { overflow-wrap: anywhere; line-height: 1.55; }
.member-message .member-text.err { color: var(--red); }
.member-msg-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.member-msg-foot .icon-btn.active { color: var(--accent); }
.member-working:empty { display: none; }
.member-welcome { max-width: 640px; margin: 12vh auto 0; text-align: center; }
.member-welcome h2 { margin: 0 0 8px; }
.member-readonly { padding: 10px 16px; border-top: 1px solid var(--line); text-align: center; font-size: 13px; }
.member-readonly[hidden] { display: none; }
.member-composer { padding: 10px 16px 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.member-composer[hidden] { display: none; }
.member-compose-row { display: flex; gap: 8px; align-items: flex-end; max-width: 820px; width: 100%; margin: 0 auto; }
.member-compose-row textarea { flex: 1; resize: none; min-height: 44px; max-height: 40vh; }
.member-attach { cursor: pointer; font-size: 18px; }
#member-mic.recording { color: var(--red); animation: breathe 1s ease-in-out infinite; }
.member-attachments { display: flex; flex-wrap: wrap; gap: 6px; max-width: 820px; width: 100%; margin: 0 auto; }
.member-attachments:empty { display: none; }
.member-status { font-size: 12px; max-width: 820px; width: 100%; margin: 0 auto; }
.member-status:empty { display: none; }
.member-memory-list { max-height: 50vh; overflow-y: auto; }
.member-memory-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 720px) {
  .member-menu-toggle { display: inline-flex; }
  .member-layout { grid-template-columns: 1fr; position: relative; }
  .member-list { position: absolute; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 5; background: var(--bg-1); transform: translateX(-105%); transition: transform .2s ease; border-right: 1px solid var(--line); }
  .member-sidebar-open .member-list { transform: none; }
  .member-head .btn { padding-inline: 8px; }
  .member-thread { padding: 14px 12px; }
}

/* Monitoring: small charts of the vital numbers. */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.metric-tile { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--line, rgba(127,127,127,.2)); border-radius: 10px; min-width: 0; }
.metric-tile b { font-size: 15px; }
.metric-tile .sparkline { width: 100%; height: 44px; color: var(--accent, currentColor); }
.health-check[data-alert] { grid-template-columns: auto 1fr auto; }
.plain-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
[data-card="monitoring"] .ok:not(.tag) { color: var(--green); }
[data-card="monitoring"] .err:not(.tag) { color: var(--red); }
[data-card="monitoring"] .warn:not(.tag) { color: var(--amber); }
.member-security { max-width: 440px; width: calc(100% - 32px); display: grid; gap: 14px; }
.member-security h3 { margin: 0; font-size: 15px; }
.member-security [data-secret] { word-break: break-all; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.member-preview { grid-row: 1; }
.member-head { grid-row: 2; }
.member-layout { grid-row: 3; }

/* ───────── first run ───────── */
.welcome-step.done { border-color: rgba(52, 211, 153, 0.25); }
.welcome-qr-row { display: flex; gap: 18px; flex-wrap: wrap; }
.welcome-qr { margin: 0; display: grid; gap: 6px; justify-items: center; font-size: 12.5px; color: var(--muted, #a8b0d0); }
.welcome-qr img { border-radius: 10px; background: #fff; padding: 6px; }
.welcome-question { text-align: left; white-space: normal; height: auto; padding: 9px 12px; line-height: 1.4; }

/* ───────── Voice mode: Vishvarupa's avatar takes over the screen ───────── */
body.voice-open { overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.voice-stage {
  position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto 1fr auto; color: #eef2ff;
  background: radial-gradient(ellipse at 50% 42%, #14193a 0%, #090c1e 55%, #04050f 100%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: voice-in .45s var(--ease, ease-out);
}
.voice-stage[data-state="listening"], .voice-stage[data-state="hearing"] { background: radial-gradient(ellipse at 50% 42%, #0c2442 0%, #070d22 55%, #03050f 100%); }
.voice-stage[data-state="thinking"], .voice-stage[data-state="transcribing"] { background: radial-gradient(ellipse at 50% 42%, #21134a 0%, #0b0a22 55%, #04040f 100%); }
.voice-stage[data-state="speaking"] { background: radial-gradient(ellipse at 50% 42%, #321342 0%, #120a24 55%, #05040f 100%); }
.voice-stage { transition: background .8s ease; }
@keyframes voice-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
.voice-top { grid-row: 1; position: relative; z-index: 1; display: flex; justify-content: center; padding: 18px 16px 0; }
.voice-name { font-size: 15px; letter-spacing: .32em; text-transform: uppercase; opacity: .75; }
.voice-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; touch-action: manipulation; }
.voice-foot { grid-row: 3; position: relative; z-index: 1; pointer-events: none; display: grid; gap: 8px; justify-items: center; text-align: center; padding: 0 20px 22px; max-width: 760px; width: 100%; margin: 0 auto; }
.voice-state { font-size: 15px; letter-spacing: .08em; opacity: .85; min-height: 1.4em; }
.voice-you { margin: 0; font-size: 14px; opacity: .55; min-height: 1.3em; max-height: 2.8em; overflow: hidden; }
.voice-it { margin: 0; font-size: clamp(17px, 2.4vw, 22px); line-height: 1.45; min-height: 3.2em; max-height: 6.5em; overflow: hidden; }
.voice-hint { font-size: 12.5px; opacity: .6; cursor: pointer; pointer-events: auto; }
.voice-controls { display: flex; gap: 12px; margin-top: 4px; pointer-events: auto; }
.voice-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 48px; min-height: 48px; padding: 0 18px; justify-content: center; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); color: inherit; font: inherit; font-size: 14px; cursor: pointer; }
.voice-btn:hover { background: rgba(255,255,255,.16); }
.voice-btn:focus-visible { outline: 2px solid #8fd8ff; outline-offset: 3px; }
.voice-btn.muted { background: rgba(255,90,110,.28); border-color: rgba(255,120,140,.6); }
.voice-btn svg { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) { .voice-stage { animation: none; transition: none; } }
@media (max-height: 560px) { .voice-it { min-height: 0; max-height: 4.4em; } .voice-top { padding-top: 8px; } }
