:root {
  --bg: #08060f;
  --bg-2: #0d0a18;
  --surface: #120e22;
  --surface-2: #19142d;
  --surface-3: #221b3b;
  --border: #2a2346;
  --border-2: #3a3160;
  --text: #ece8fb;
  --muted: #9b93bd;
  --dim: #6c6590;
  --pink: #ff5fd2;
  --pink-soft: rgba(255, 95, 210, 0.13);
  --cyan: #5ff0ff;
  --cyan-soft: rgba(95, 240, 255, 0.12);
  --violet: #9b85ff;
  --violet-soft: rgba(155, 133, 255, 0.14);
  --ok: #4be3a0;
  --warn: #ffbd5c;
  --danger: #ff6b7f;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --neon: "Audiowide", "Inter", sans-serif;
  --side-w: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 11.5px; font-weight: 700; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.ok-msg { color: var(--ok); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- brand / orb ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand-word { font-family: var(--neon); font-size: 15px; letter-spacing: .08em; color: #ffd6f5; text-shadow: 0 0 10px rgba(255, 95, 210, .55); }
.orb-mini { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, #fff, #ffb3f0 35%, #7a3cff 100%);
  box-shadow: 0 0 14px 2px rgba(255, 95, 210, .55); animation: orbPulse 3.6s ease-in-out infinite; }
@keyframes orbPulse { 0%, 100% { box-shadow: 0 0 10px 1px rgba(255, 95, 210, .45); } 50% { box-shadow: 0 0 20px 5px rgba(255, 95, 210, .7); } }

/* ---------- forms / buttons ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pink); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 15px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: linear-gradient(135deg, #ff4fc8, #8b5cff); border-color: transparent; color: #fff; box-shadow: 0 0 18px -4px rgba(255, 79, 200, .7); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ok { background: rgba(75, 227, 160, .13); border-color: var(--ok); color: var(--ok); }
.btn.danger { background: rgba(255, 107, 127, .12); border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 120%, rgba(255, 95, 210, .25), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 0 60px -20px rgba(255, 95, 210, .45); }
.login-card .muted { margin: 0 0 4px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100%; }
.side { width: var(--side-w); flex: 0 0 var(--side-w); background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; position: sticky; top: 0; height: 100vh; z-index: 20; }
.side .brand { padding: 2px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 13.5px; text-decoration: none !important; }
.nav-item .ic { width: 18px; text-align: center; color: var(--dim); font-size: 14px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--pink-soft); color: #fff; box-shadow: inset 2px 0 0 var(--pink); }
.nav-item.active .ic { color: var(--pink); }
.nav-item.disabled { opacity: .55; cursor: default; }
.nav-item.disabled:hover { background: none; color: var(--muted); }
.nav-badge { margin-left: auto; background: var(--warn); color: #1b1200; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.soon { margin-left: auto; font-size: 10px; border: 1px solid var(--border-2); border-radius: 99px; padding: 0 7px; color: var(--dim); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.pulse { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); padding: 0 6px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; }
.pulse.ok .pulse-dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: blink 2s ease-in-out infinite; }
.pulse.late .pulse-dot { background: var(--warn); }
.pulse.down .pulse-dot { background: var(--danger); }
@keyframes blink { 50% { opacity: .35; } }
.who { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 12.5px; padding: 0 6px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 15; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 15, .85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.top-title { flex: 1; min-width: 0; }
.top h1 { font-size: 18px; margin: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs { font-size: 11.5px; color: var(--dim); display: flex; gap: 6px; align-items: center; min-height: 16px; }
.crumbs a { color: var(--muted); }
.project-pick select { width: auto; max-width: 220px; padding: 7px 10px; }
.menu-btn { display: none; }
.view { flex: 1; padding: 22px 24px 40px; outline: none; animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- generic blocks ---------- */
.grid { display: grid; gap: 16px; align-content: start; }
.grid.two { align-items: start; }
.grid.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 14px; }
.panel-head .more { margin-left: auto; font-size: 12px; }
.empty { color: var(--dim); font-size: 13px; padding: 10px 0; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; min-width: 0; color: var(--text); text-decoration: none !important; }
.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .side-meta { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--dim); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.chip.active { background: var(--pink-soft); border-color: var(--pink); color: #fff; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; white-space: nowrap;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }
.badge.run { color: var(--cyan); }
.badge.plain::before { display: none; }
.pole-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.pole-tag i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--cyan)); }

.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.card + .card { margin-top: 8px; }
.card.attention { border-color: var(--warn); box-shadow: 0 0 0 1px rgba(255, 189, 92, .15); }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.actions input { flex: 1; min-width: 160px; }
.meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
pre.content { white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 var(--mono); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; margin: 10px 0 0; }
.err-text { color: var(--danger); font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.radios { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: flex; gap: 18px; flex-wrap: wrap; }
.radios legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.radios label { flex-direction: row; align-items: center; color: var(--text); }
.radios input { width: auto; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > input { flex: 1; min-width: 200px; }
.inline-form .compact { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.inline-form .compact input { width: 70px; }
.narrow { max-width: 760px; }
.notice { border: 1px dashed var(--border-2); border-radius: var(--radius); padding: 10px 12px; color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

/* ---------- QG ---------- */
.hero { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: center; margin-bottom: 18px;
  background: radial-gradient(ellipse at 15% 50%, rgba(255, 95, 210, .16), transparent 55%), var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 18px 22px; }
.hero canvas { width: 200px; height: 200px; display: block; }
.hero-name { font-family: var(--neon); font-size: 26px; letter-spacing: .08em; color: #ffd6f5; text-shadow: 0 0 16px rgba(255, 95, 210, .6); margin: 0; }
.hero-state { font-size: 15px; margin: 6px 0 12px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 14px; min-width: 112px; text-decoration: none !important; color: var(--text); }
.stat .n { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 11.5px; color: var(--muted); }
.stat.warn .n { color: var(--warn); }
.stat.run .n { color: var(--cyan); }
.stat.danger .n { color: var(--danger); }
.mini-poles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mini-pole { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 12.5px; text-decoration: none !important; min-width: 0; }
.mini-pole span.name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-pole:hover { border-color: var(--border-2); }

/* ---------- City SVG ---------- */
.vc-wrap { position: relative; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: #04020d; box-shadow: 0 0 80px -30px rgba(255, 95, 210, .5); }
.vc-svg { display: block; width: 100%; height: auto; }
.vc-label { font-family: var(--neon); letter-spacing: .06em; }
.vc-hq-label { font-size: 13px; }
.vc-sub { font-family: var(--mono); font-size: 7.5px; letter-spacing: .08em; opacity: .75; }
.vc-ask-n { font: 700 12px var(--font); fill: #1b1200; }
.vc-bldg { cursor: pointer; outline: none; }
.vc-bldg .vc-frame, .vc-bldg .vc-top { transition: stroke-width .15s, fill-opacity .15s; }
.vc-bldg:hover .vc-frame, .vc-bldg:focus-visible .vc-frame, .vc-bldg.selected .vc-frame { stroke-width: 3; filter: url(#vc-glow); }
.vc-bldg:hover .vc-front, .vc-bldg.selected .vc-front { fill-opacity: .14; }
.vc-bldg.not_implemented { opacity: .62; }
.vc-bldg.partial .vc-frame { animation: breathe 4s ease-in-out infinite; }
.vc-win.on { animation: winFlicker 2.6s ease-in-out infinite; }
.vc-win.on:nth-child(3n) { animation-delay: -1.1s; }
.vc-beacon, .vc-ask { animation: beacon 1.6s steps(1) infinite; }
.vc-agent.busy { animation: bob 1.4s ease-in-out infinite; }
.vc-hq { cursor: pointer; outline: none; }
.vc-hq .vc-orb, .vc-hq .vc-orb-halo { animation: orbSvg 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.vc-hq.state-busy .vc-orb, .vc-hq.state-busy .vc-orb-halo { animation-duration: 1.4s; }
.vc-hq.state-ask .vc-orb-halo { fill: #ffbd5c; }
.vc-hq:hover .vc-hq-frame { stroke-width: 3; filter: url(#vc-glow); }
.vc-sun { animation: breathe 6s ease-in-out infinite; }
.vc-stars circle { animation: twinkle 3s ease-in-out infinite; }
.vc-stars circle:nth-child(2n) { animation-delay: -1s; }
.vc-stars circle:nth-child(3n) { animation-delay: -2s; }
.vc-link { animation: dash 1.2s linear infinite; }
@keyframes breathe { 50% { opacity: .72; } }
@keyframes winFlicker { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes beacon { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .25; } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes orbSvg { 50% { transform: scale(1.12); } }
@keyframes twinkle { 50% { opacity: .25; } }
@keyframes dash { to { stroke-dashoffset: -16; } }
.vc-tip { position: absolute; pointer-events: none; z-index: 3; background: rgba(13, 10, 24, .96); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; width: 210px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.vc-tip span { color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 10px 2px 18px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 10px; border: 1.5px solid var(--cyan); border-radius: 2px; }
.legend i.dashed { border-style: dashed; border-color: var(--violet); }
.legend i.fig { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); border: none; }
.legend i.hollow { width: 8px; height: 8px; border-radius: 50%; border: 1.5px dashed var(--cyan); }
.legend i.ask { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); border: none; }
.pole-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-decoration: none !important; color: var(--text); border-top: 3px solid var(--c, var(--border)); }
.pole-card:hover { border-color: var(--border-2); border-top-color: var(--c); }
.pole-card .pc-name { font-weight: 700; font-size: 14px; }
.pole-card .pc-counts { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.pole-card .pc-counts b { color: var(--text); }

/* pole detail */
.pole-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.pole-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-family: var(--neon); font-size: 20px; color: #08060f; flex: 0 0 auto; }
.pole-head .grow { flex: 1; min-width: 220px; }
.pole-head h2 { font-size: 20px; margin: 0 0 4px; }
.prof { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface-2); }
.prof + .prof { margin-top: 10px; }
.prof-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.prof-head strong { flex: 1; min-width: 0; }
.agents { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.agent { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--border); font-size: 12px; }
.agent .av { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #08060f; }
.agent.busy { border-color: var(--cyan); box-shadow: 0 0 12px -3px var(--cyan); }

/* ---------- missions ---------- */
.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.m-item { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--border)); border-radius: var(--radius);
  padding: 11px 13px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; text-decoration: none !important; color: var(--text); }
.m-item:hover { border-color: var(--border-2); border-left-color: var(--c, var(--border-2)); }
.m-item.selected { background: var(--pink-soft); border-color: var(--pink); }
.m-item .obj { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; min-height: 320px; min-width: 0; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.objective { white-space: pre-wrap; font-size: 15px; margin: 10px 0 14px; overflow-wrap: anywhere; }
.pipeline { display: flex; flex-direction: column; gap: 10px; }
.lane { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
.lane-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.lane-head .who-agent { font-weight: 600; flex: 1; min-width: 0; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.step { font: 11.5px var(--mono); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border-2); color: var(--muted); background: var(--bg-2); display: inline-flex; gap: 6px; align-items: center; }
.step.done { color: var(--ok); border-color: rgba(75, 227, 160, .45); }
.step.current { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 10px -3px var(--cyan); }
.step.blocked { color: var(--warn); border-color: var(--warn); }
.step .model { color: var(--violet); }
.step-arrow { color: var(--dim); font-size: 11px; }

.card.verif { margin: 10px 0; }
.card.verif.ok { border-color: var(--ok); }
.card.verif.warn { border-color: var(--warn); }
.card.verif.danger { border-color: var(--danger); }
.verif-points { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.verif-points li { margin: 3px 0; }
.summary-text { font-size: 13.5px; color: var(--muted); margin: 8px 0; }

.inbox-card { display: flex; flex-direction: column; gap: 8px; }
.inbox-full { border-top: 1px solid var(--border); padding-top: 10px; max-height: 420px; overflow: auto; }
.inline-label { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.inline-label select { width: auto; max-width: 240px; }

/* ---------- timeline ---------- */
.tl-day { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin: 18px 0 8px; }
.tl-day:first-child { margin-top: 0; }
.tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--border-2); display: flex; flex-direction: column; gap: 2px; }
.tl li { position: relative; padding: 7px 10px; border-radius: 9px; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; }
.tl li:hover { background: var(--surface-2); }
.tl li::before { content: ""; position: absolute; left: -19px; top: 13px; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--dim)); box-shadow: 0 0 8px var(--c, transparent); }
.tl .time { font: 11.5px var(--mono); color: var(--dim); padding-top: 1px; }
.tl .what { font-size: 13px; overflow-wrap: anywhere; }
.tl .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.tl a.sub-link { color: var(--muted); }

/* ---------- projects ---------- */
.proj-card { cursor: pointer; text-decoration: none !important; color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.proj-card:hover { border-color: var(--border-2); }
.proj-card .pn { font-weight: 700; font-size: 14.5px; }
.proj-card .pc { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.proj-card .pc b { color: var(--text); }

/* ---------- Cortex ---------- */
.cortex { display: grid; grid-template-columns: 280px minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.cortex.no-right { grid-template-columns: 280px minmax(0, 1fr); }
.tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.tree input { margin-bottom: 10px; }
.tree details { margin-left: 4px; }
.tree summary { cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; list-style: none; display: flex; gap: 6px; align-items: center; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--dim); font-size: 10px; transition: transform .12s; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary .n { margin-left: auto; color: var(--dim); font-weight: 500; font-size: 11px; }
.tree summary:hover { background: var(--surface-2); }
.tree .children { margin-left: 10px; border-left: 1px solid var(--border); padding-left: 4px; }
.tree a.note { display: block; padding: 4px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none !important; }
.tree a.note:hover { background: var(--surface-2); }
.tree a.note.active { background: var(--violet-soft); color: #fff; }
.hit { display: block; padding: 7px 8px; border-radius: 7px; color: var(--text); text-decoration: none !important; }
.hit:hover { background: var(--surface-2); }
.hit .t { font-size: 12.5px; font-weight: 600; }
.hit .s { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.note-view { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 28px; min-width: 0; }
.note-path { font: 11.5px var(--mono); color: var(--dim); overflow-wrap: anywhere; }
.note-title { font-size: 22px; margin: 4px 0 12px; }
.props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 16px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.prop-v { background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.side-col { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 84px; }
.graph-wrap { position: relative; background: #05030c; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; height: calc(100vh - 210px); min-height: 420px; }
.graph-wrap canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.graph-legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11.5px; color: var(--muted); max-width: 70%; background: rgba(5, 3, 12, .7); padding: 6px 10px; border-radius: 8px; }
.graph-legend span { display: inline-flex; gap: 5px; align-items: center; }
.graph-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* markdown */
.md { font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.md .md-h { margin: 22px 0 8px; line-height: 1.3; }
.md h2.md-h { font-size: 19px; }
.md h3.md-h { font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
.md h4.md-h, .md h5.md-h, .md h6.md-h { font-size: 14px; }
.md p { margin: 8px 0; }
.md .md-list { margin: 6px 0; padding-left: 22px; }
.md .md-task { list-style: none; margin-left: -18px; }
.md .md-check { display: inline-grid; place-items: center; width: 14px; height: 14px; border: 1px solid var(--border-2); border-radius: 4px; margin-right: 6px; font-size: 10px; color: var(--ok); vertical-align: -2px; }
.md .md-task.done { color: var(--muted); }
.md .md-code { font: 12.5px var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.md .md-pre { font: 12.5px/1.55 var(--mono); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; white-space: pre; }
.md .md-quote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--border-2); color: var(--muted); }
.md .md-callout { margin: 12px 0; padding: 10px 14px; border-radius: 9px; border: 1px solid var(--violet); background: var(--violet-soft); }
.md .md-callout-warning, .md .md-callout-caution { border-color: var(--warn); background: rgba(255, 189, 92, .1); }
.md .md-callout-danger, .md .md-callout-error { border-color: var(--danger); background: rgba(255, 107, 127, .1); }
.md .md-callout-title { font-weight: 700; margin-bottom: 4px; }
.md .md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md .md-table { border-collapse: collapse; font-size: 13px; }
.md .md-table th, .md .md-table td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; vertical-align: top; }
.md .md-table th { background: var(--surface-2); }
.md .md-tag { color: var(--pink); font-size: .92em; }
.md .md-img { color: var(--dim); font-style: italic; }
.md mark { background: rgba(255, 189, 92, .3); color: inherit; padding: 0 2px; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.md a.wikilink { color: var(--violet); border-bottom: 1px dashed rgba(155, 133, 255, .5); }
.md a.wikilink.missing { color: var(--dim); border-bottom-style: dotted; cursor: help; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(4, 2, 10, .72); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; padding: 20px 22px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 0 60px -20px rgba(255, 95, 210, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }

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


/* ---------- one-screen layouts ---------- */
.grid.three { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .9fr); align-items: start; }
.scroll-box { max-height: 300px; overflow: auto; margin-right: -6px; padding-right: 6px; }
.scroll-box.tall { max-height: calc(100vh - 380px); min-height: 260px; }
.hero { grid-template-columns: 150px 1fr; padding: 14px 20px; }
.hero canvas { width: 150px; height: 150px; }
.hero-name { font-size: 22px; }
.hero-state { margin: 2px 0 10px; }
.ask-form { display: flex; gap: 8px; margin: 0 0 10px; max-width: 760px; }
.ask-input { flex: 1; font-size: 15px; padding: 11px 14px; border-radius: 12px; border-color: var(--border-2); background: var(--bg-2); }
.list-col { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; padding-right: 4px; }
.map-fold { margin-top: 16px; }
.map-fold > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px 0; }
.map-fold[open] > summary { margin-bottom: 8px; }

/* tabs */
.tabs-wrap { margin-top: 14px; }
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabbar .tab { font: inherit; font-size: 13px; font-weight: 600; background: none; border: none; color: var(--muted); padding: 8px 12px;
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabbar .tab:hover { color: var(--text); }
.tabbar .tab.active { color: #fff; border-bottom-color: var(--pink); }

/* ---------- Agents view (pixel office) ---------- */
.av-wrap { position: relative; height: calc(100vh - 210px); min-height: 460px; border-radius: 18px; overflow: hidden; border: 1px solid var(--border); }
.av-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; image-rendering: pixelated; }
.av-tools { position: absolute; top: 10px; left: 10px; right: 170px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.av-tools-head, .av-tool { font: 600 11.5px var(--font); padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .88); color: #2a2a44; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.av-tool { color: #6a6a88; }
.av-tool.on { background: #2a2346; color: #b6f8ff; box-shadow: 0 0 12px rgba(95, 240, 255, .6); }
.av-mini { position: absolute; right: 10px; bottom: 10px; width: 150px; height: 110px; cursor: pointer; filter: drop-shadow(0 2px 8px rgba(0,0,0,.2)); }
.av-card { position: absolute; top: 48px; right: 10px; width: 250px; background: rgba(255, 255, 255, .96); color: #2a2a44; border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); font-size: 13px; }
.av-card .muted { color: #6a6a88; }
.av-card a { color: #6b3fd0; }
.av-card .av-busy { color: #0a7a8a; font-weight: 600; }
.av-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; color: #6a6a88; border-color: #ddd; }
.av-hint { position: absolute; left: 10px; bottom: 10px; font-size: 11.5px; color: #2a2a44; background: rgba(255, 255, 255, .8); padding: 4px 10px; border-radius: 99px; }
.city-modes { margin-right: 6px; }

/* ---------- chat ---------- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 30; display: flex; align-items: center; gap: 10px;
  font: 600 14px var(--font); color: #fff; background: linear-gradient(135deg, #2a1546, #3a1a5c); border: 1px solid var(--pink);
  border-radius: 999px; padding: 10px 18px 10px 12px; cursor: pointer; box-shadow: 0 0 30px -6px rgba(255, 95, 210, .8); }
.chat-fab:hover { filter: brightness(1.15); }
body.chat-open .chat-fab, body[data-route="discussions"] .chat-fab { display: none; }
.view { padding-bottom: 90px; }
.chat-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 40; background: var(--bg-2);
  border-left: 1px solid var(--border-2); box-shadow: -20px 0 60px rgba(0, 0, 0, .55); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.chat-drawer-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-drawer-bar .grow { flex: 1; }
.chat-drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.chat-head-row { display: flex; gap: 8px; align-items: center; }
.chat-pick { flex: 1; width: auto; padding: 7px 10px; }
.chat-title { font-weight: 650; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chat-meta:empty { display: none; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { color: var(--muted); font-size: 13.5px; }
.chat-empty .chips { margin-top: 10px; }
.chat-empty .chip { text-align: left; white-space: normal; }
.msg { display: flex; flex-direction: column; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }
.bubble { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user .bubble { background: linear-gradient(135deg, #ff4fc8, #8b5cff); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot .bubble .md { font-size: 14px; }
.msg.bot .bubble .md > :first-child { margin-top: 0; }
.msg.bot .bubble .md > :last-child { margin-bottom: 0; }
.bubble.pending { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.bubble.error-bubble { border-color: var(--danger); color: var(--danger); background: rgba(255, 107, 127, .08); }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--pink); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.msg-meta { font-size: 11px; color: var(--dim); margin-top: 4px; padding: 0 4px; }
.sources { margin-top: 6px; font-size: 12px; }
.sources summary { cursor: pointer; color: var(--violet); }
.src-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.src { font-size: 11.5px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--muted); text-decoration: none !important; }
.src.note { border-color: rgba(155, 133, 255, .5); color: #cfc3ff; }
.src.mission { border-color: rgba(95, 240, 255, .4); color: #b6f8ff; }
.proposal { margin-top: 8px; border: 1px solid var(--pink); background: var(--pink-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.proposal p { margin: 6px 0; }
.proposal .actions { margin-top: 4px; }
.proposal.done { border-color: var(--ok); background: rgba(75, 227, 160, .08); }
.proposal-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.chat-composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.chat-input { resize: none; min-height: 42px; max-height: 180px; border-radius: 12px; line-height: 1.45; }
.chat-send { height: 42px; }
.chat-drawer-body > .error, .chat-panel > .error { padding: 0 14px; }

.discussions { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; height: calc(100vh - 120px); min-height: 480px; }
.conv-col { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; }
.conv-col .toolbar { flex-wrap: nowrap; }
.conv-col .toolbar input { max-width: none; }
.conv-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.conv { display: block; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none !important; border: 1px solid transparent; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--pink-soft); border-color: var(--pink); }
.conv-top { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.conv-who { font-size: 11.5px; font-weight: 700; color: var(--pink); text-transform: uppercase; letter-spacing: .05em; }
.conv-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

@media (max-width: 1280px) {
  .grid.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid.three > :nth-child(2) { grid-row: span 2; }
}
@media (max-width: 980px) {
  .grid.three { grid-template-columns: minmax(0, 1fr); }
  .scroll-box.tall { max-height: 420px; }
  .list-col { position: static; max-height: none; }
  .discussions { grid-template-columns: minmax(0, 1fr); height: auto; }
  .conv-col { max-height: 260px; }
  .chat-panel { height: 70vh; }
  .ask-form { flex-direction: column; }
}
@media (max-width: 860px) {
  .chat-fab span:last-child { display: none; }
  .chat-fab { padding: 12px; }
  .chat-drawer { width: 100vw; }
}

@media (max-width: 1180px) {
  .cortex { grid-template-columns: 250px minmax(0, 1fr); }
  .cortex .side-col { grid-column: 2; position: static; }
}
@media (max-width: 980px) {
  .grid.two, .split { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; max-height: none; }
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .hero .stats { justify-content: center; }
}
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .shell.menu-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .project-pick { order: 4; flex-basis: 100%; }
  .project-pick select { max-width: none; width: 100%; }
  .view { padding: 16px 16px 40px; }
  .cortex, .cortex.no-right { grid-template-columns: minmax(0, 1fr); }
  .cortex .side-col { grid-column: auto; }
  .tree { position: static; max-height: 320px; }
  .note-view { padding: 16px; }
  .hero canvas { width: 150px; height: 150px; }
  .graph-wrap { height: 70vh; }
  .vc-wrap { overflow-x: auto; }
  .vc-svg { min-width: 760px; }
  .av-wrap { height: 70vh; }
  .av-tools { right: 10px; }
  .av-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
