:root {
  color-scheme: dark;
  --bg: #050914;
  --panel: rgba(8, 22, 43, .86);
  --panel-strong: rgba(7, 17, 34, .96);
  --line: rgba(62, 190, 255, .27);
  --cyan: #55e7ff;
  --blue: #278cff;
  --magenta: #ff4fc8;
  --mint: #4dffd0;
  --text: #e7f6ff;
  --muted: #8eacc8;
  --warning: #ffbd6b;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  position: relative; isolation: isolate; min-height: 100vh; margin: 0; overflow-x: hidden;
  color: var(--text); font: 15px/1.55 Inter, "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 50% 7%, rgba(15, 80, 151, .28), transparent 42rem),
    radial-gradient(ellipse at 88% 42%, rgba(155, 29, 137, .13), transparent 35rem),
    radial-gradient(ellipse at 8% 75%, rgba(0, 189, 255, .10), transparent 32rem),
    linear-gradient(145deg, #030711, #071326 55%, #050815);
}
body::before {
  content: ""; position: fixed; z-index: -1; inset: 0; pointer-events: none; opacity: .42;
  background-image:
    radial-gradient(circle, rgba(95, 228, 255, .9) 0 1px, transparent 1.7px),
    radial-gradient(circle, rgba(255, 76, 199, .75) 0 1px, transparent 1.8px);
  background-size: 97px 113px, 151px 167px;
  background-position: 5px 12px, 41px 58px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}
body::after {
  content: ""; position: fixed; z-index: -1; inset: 0; pointer-events: none; opacity: .15;
  background-image: linear-gradient(rgba(57, 160, 255, .22) 1px, transparent 1px), linear-gradient(90deg, rgba(57, 160, 255, .22) 1px, transparent 1px);
  background-size: 46px 46px; mask-image: linear-gradient(to bottom, transparent, black 35%, transparent 95%);
}
header, main { width: min(1500px, 100%); margin: auto; padding: 22px clamp(14px, 3vw, 42px); }
header {
  position: relative; display: grid; grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center; gap: 8px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(3, 11, 24, .96), rgba(8, 28, 55, .72), rgba(3, 11, 24, .96));
  box-shadow: 0 8px 38px rgba(0, 0, 0, .26);
}
header::after { content: "LOCAL-FIRST  /  CONTROLLED AUTONOMY  /  SIX AGENTS"; grid-column: 1 / -1; color: #6e9dbb; font: 10px/1.5 ui-monospace, monospace; letter-spacing: .2em; }
h1 { margin: 0; color: #dffaff; font-size: clamp(24px, 3vw, 36px); line-height: 1.15; letter-spacing: .08em; text-shadow: 0 0 22px rgba(61, 217, 255, .5); }
h1::before { content: "⬡"; margin-right: 12px; color: var(--cyan); text-shadow: 0 0 16px var(--blue); }
header > p { margin: 0; color: var(--muted); }
#mode { color: var(--mint); font: 11px ui-monospace, monospace; letter-spacing: .08em; }
#system-state { grid-column: 1 / 2; color: #b5d3e8; }
#token { grid-column: 1 / 3; width: 100%; }
#connect { grid-column: 3; }
#error { grid-column: 1 / -1; color: #ff91bb; overflow-wrap: anywhere; }
main { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
section {
  position: relative; min-width: 0; padding: clamp(16px, 2vw, 25px); overflow: hidden;
  border: 1px solid rgba(58, 186, 255, .24); border-radius: 14px;
  background: linear-gradient(145deg, rgba(9, 27, 51, .91), rgba(5, 13, 29, .88));
  box-shadow: inset 0 1px 0 rgba(143, 235, 255, .07), 0 12px 34px rgba(0, 0, 0, .24);
  backdrop-filter: blur(14px);
}
section::before { content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 1px; background: linear-gradient(90deg, transparent, rgba(83, 231, 255, .65), transparent); pointer-events: none; }
section h2 { margin: 0 0 14px; color: #c9f6ff; font-size: 17px; font-weight: 650; letter-spacing: .035em; }
section h2::before { content: "//"; margin-right: 9px; color: var(--magenta); font: 12px ui-monospace, monospace; }
section p { color: #9bb8d0; }
#nexus-hero { grid-column: 1 / -1; min-height: 390px; display: grid; grid-template-columns: minmax(260px, .85fr) minmax(320px, 1.15fr); align-items: center; padding: clamp(20px, 3vw, 42px); background: radial-gradient(ellipse at 72% 48%, rgba(14, 108, 210, .22), transparent 28rem), linear-gradient(115deg, rgba(5, 16, 34, .98), rgba(8, 23, 48, .88)); }
#nexus-hero::after { content: ""; position: absolute; width: 36%; height: 1px; left: 0; bottom: 25px; background: linear-gradient(90deg, var(--magenta), transparent); }
.hero-copy { position: relative; z-index: 2; }
.eyebrow { color: var(--cyan) !important; font: 11px ui-monospace, monospace; letter-spacing: .15em; }
.eyebrow span { color: #7396b5; }
.hero-copy h2 { max-width: 540px; margin: 18px 0; font-size: clamp(27px, 4vw, 48px); line-height: 1.2; letter-spacing: .025em; text-shadow: 0 0 28px rgba(48, 169, 255, .2); }
.hero-copy h2::before { content: none; }
.hero-subtitle { color: #b9d6ee !important; font-size: 16px; }
.hero-note { max-width: 450px; font-size: 12px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 24px; }
.hero-tags span { padding: 5px 8px; border: 1px solid rgba(85, 231, 255, .3); border-radius: 3px; color: #a6dff4; font: 9px ui-monospace, monospace; letter-spacing: .1em; background: rgba(7, 50, 81, .28); }
.orbit-scene { position: relative; min-height: 330px; width: 100%; max-width: 660px; justify-self: center; overflow: hidden; perspective: 700px; }
.orbit-scene::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(45, 207, 255, .16), transparent 23%), radial-gradient(circle at 50% 50%, rgba(255, 52, 190, .07), transparent 48%); }
.orbit { position: absolute; left: 50%; top: 50%; border: 1px solid rgba(75, 216, 255, .43); border-radius: 50%; transform-style: preserve-3d; box-shadow: 0 0 16px rgba(30, 162, 255, .12), inset 0 0 16px rgba(30, 162, 255, .08); }
.orbit-a { width: 76%; height: 40%; transform: translate(-50%, -50%) rotate(-23deg); animation: orbit-turn 24s linear infinite; }
.orbit-b { width: 88%; height: 53%; transform: translate(-50%, -50%) rotate(29deg); border-color: rgba(255, 79, 200, .4); animation: orbit-turn 31s linear infinite reverse; }
.orbit-c { width: 54%; height: 83%; transform: translate(-50%, -50%) rotate(68deg); border-color: rgba(72, 255, 211, .28); }
.core-halo { position: absolute; left: 50%; top: 50%; width: 170px; height: 170px; border: 1px solid rgba(80, 229, 255, .62); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 18px rgba(50, 190, 255, .35), inset 0 0 22px rgba(50, 190, 255, .2); animation: core-pulse 3.2s ease-in-out infinite; }
.core { position: absolute; left: 50%; top: 50%; width: 116px; height: 116px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #7cefff; border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle at 50% 25%, #123e6d, #06152d 70%); box-shadow: 0 0 28px rgba(45, 183, 255, .48), inset 0 0 20px rgba(55, 205, 255, .22); }
.core span { color: #f0fdff; font-size: 19px; font-weight: 800; letter-spacing: .13em; text-shadow: 0 0 12px var(--cyan); }
.core small { margin-top: 4px; color: #82bfdc; font: 8px ui-monospace, monospace; letter-spacing: .12em; }
.agent-node { position: absolute; display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid rgba(76, 206, 255, .45); border-radius: 5px; color: #dffaff; background: rgba(4, 19, 39, .9); box-shadow: 0 0 18px rgba(23, 145, 255, .13); font-size: 11px; white-space: nowrap; }
.agent-node b { color: var(--cyan); font: 13px ui-monospace, monospace; }
.node-market { top: 8%; left: 34%; } .node-ops { top: 24%; left: 1%; border-color: rgba(255, 79, 200, .5); } .node-sales { top: 27%; right: 0; border-color: rgba(42, 226, 255, .5); } .node-delivery { bottom: 19%; left: 2%; border-color: rgba(194, 98, 255, .5); } .node-tech { bottom: 8%; left: 39%; border-color: rgba(77, 255, 208, .5); } .node-quality { bottom: 23%; right: 0; border-color: rgba(255, 161, 87, .55); }
.orbit-caption { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); color: #6388a9; font: 8px ui-monospace, monospace; letter-spacing: .15em; white-space: nowrap; }
.orbit-caption span { color: var(--mint); }
.particle { position: absolute; z-index: 1; width: 5px; height: 5px; border-radius: 50%; background: #b9f9ff; box-shadow: 0 0 12px 3px #248fff; animation: particle-glow 2.5s ease-in-out infinite; }
.p1 { left: 23%; top: 30%; } .p2 { left: 73%; top: 18%; animation-delay: -.7s; } .p3 { left: 81%; top: 62%; animation-delay: -1.2s; } .p4 { left: 27%; top: 72%; animation-delay: -.3s; } .p5 { left: 53%; top: 8%; animation-delay: -1.6s; } .p6 { left: 57%; top: 85%; animation-delay: -.9s; }
#plan-panel { grid-column: span 7; } #budget-panel { grid-column: span 5; }
#agents-panel { grid-column: 1 / -1; }
#agents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#agents article { min-height: 74px; display: flex; align-items: center; border: 1px solid rgba(56, 176, 255, .22); border-radius: 7px; background: linear-gradient(100deg, rgba(12, 47, 76, .48), rgba(7, 19, 37, .62)); }
#task-create-panel { grid-column: span 5; } #task-progress-panel { grid-column: span 7; }
#approval-panel, #memory-panel, #proposal-panel, #logs-panel { grid-column: span 6; }
input, select, textarea, button { max-width: 100%; margin: 5px 0; padding: 10px 12px; border: 1px solid rgba(81, 167, 220, .42); border-radius: 5px; color: var(--text); background: rgba(2, 10, 23, .82); font: inherit; }
input, select, textarea { width: 100%; }
input[type="checkbox"] { width: auto; accent-color: var(--cyan); }
textarea { display: block; min-height: 88px; resize: vertical; }
label { display: block; margin: 10px 0; color: #b9d4e8; font-size: 13px; }
button { position: relative; border-color: rgba(70, 221, 255, .48); color: #eaffff; background: linear-gradient(110deg, rgba(9, 111, 154, .9), rgba(26, 66, 143, .92)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 0 14px rgba(28, 151, 255, .1); cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
button:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 18px rgba(51, 201, 255, .22); transform: translateY(-1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }
#stop { border-color: rgba(255, 80, 135, .6); background: linear-gradient(110deg, #7f244f, #391a43); }
article { min-width: 0; padding: 12px 13px; border-bottom: 1px solid rgba(61, 151, 208, .2); color: #b9d4e8; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
article:last-child { border-bottom-color: transparent; }
#error { font-size: 12px; }
#mode, #submission-status, #plan-submission { color: var(--warning); }
#system-state { padding-left: 12px; border-left: 2px solid var(--mint); }
@keyframes orbit-turn { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes core-pulse { 0%, 100% { opacity: .72; scale: .96; } 50% { opacity: 1; scale: 1.04; } }
@keyframes particle-glow { 0%, 100% { opacity: .4; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.45); } }
@media (max-width: 900px) {
  header { grid-template-columns: 1fr auto; }
  header > p { grid-column: 1 / -1; }
  #system-state { grid-column: 1 / -1; }
  #token { grid-column: 1 / -1; }
  #connect { grid-column: auto; }
  #nexus-hero { grid-template-columns: 1fr; }
  .orbit-scene { min-height: 300px; margin-top: 18px; }
  #plan-panel, #budget-panel, #task-create-panel, #task-progress-panel, #approval-panel, #memory-panel, #proposal-panel, #logs-panel { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  header, main { padding: 14px; }
  header { grid-template-columns: 1fr; }
  header::after, #mode, #system-state, #token, #connect, #error { grid-column: 1; }
  #agents { grid-template-columns: 1fr; }
  #nexus-hero { padding: 18px 14px; }
  .hero-copy h2 { font-size: 28px; }
  .orbit-scene { min-height: 250px; margin-inline: -6px; width: calc(100% + 12px); }
  .core-halo { width: 130px; height: 130px; }
  .core { width: 90px; height: 90px; }
  .core span { font-size: 15px; }
  .agent-node { gap: 4px; padding: 5px 6px; font-size: 9px; }
  .agent-node b { font-size: 11px; }
  .node-market { left: 28%; } .node-ops { left: 0; } .node-sales { right: 0; } .node-delivery { left: 0; } .node-tech { left: 31%; } .node-quality { right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
/* Keep grid children shrinkable at narrow widths; do not mask overflow. */
header > *, .hero-copy { min-width: 0; overflow-wrap: anywhere; }
#agents[data-stale] { opacity: .6; }
#agent-freshness { font-size: 12px; }


/* Authenticated live HUD: visual ambient particles are decorative, statuses are API-bound */
#nexus-hero { padding-top:94px; padding-bottom:28px; position:relative; grid-template-columns:minmax(300px,.85fr) minmax(380px,1.15fr); min-height:600px; }
#nexus-hero .hero-copy { align-self:start; }
.hud-topline { position:absolute; top:0; left:0; right:0; display:flex; align-items:center; justify-content:space-between; gap:15px; padding:13px 22px; border-bottom:1px solid rgba(75,194,255,.25); background:rgba(0,11,27,.65); font:11px ui-monospace,monospace; letter-spacing:.1em; }
.hud-brand { color:#88e9ff; font-weight:700; }
.hud-diamond { color:#51e7ff; margin-right:8px; text-shadow:0 0 12px #3cc8fc; }
.hud-ver { color:#6989ae; margin-left:11px; font-size:9px; }
.hud-status { display:flex; align-items:center; gap:8px; color:#ffc87a; }
.hud-signal { width:7px; height:7px; border-radius:50%; background:#ffc87a; box-shadow:0 0 12px #ffc87a; }
#nexus-hero[data-hud-state="connected"] .hud-status { color:#74ffde; }
#nexus-hero[data-hud-state="connected"] .hud-signal { background:#74ffde; box-shadow:0 0 14px #31ffc4; }
#nexus-hero[data-hud-state="stopped"] .hud-status { color:#ff6a8c; }
#nexus-hero[data-hud-state="stopped"] .hud-signal { background:#ff6a8c; box-shadow:0 0 14px #ff6a8c; }
.hud-kpis { position:absolute; left:0; right:0; top:47px; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); border-bottom:1px solid rgba(70,164,241,.15); background:rgba(5,19,39,.47); z-index:2; }
.hud-kpis>div { display:flex; justify-content:center; align-items:baseline; gap:13px; padding:12px 6px; border-right:1px solid rgba(70,164,241,.15); }
.hud-kpis>div:last-child { border-right:0; }
.hud-kpis small { font:10px ui-monospace,monospace; color:#7eb2d5; }
.hud-kpis strong { font:700 21px ui-monospace,monospace; color:#82ecff; text-shadow:0 0 16px rgba(77,204,255,.25); }
.hud-kpis>div:last-child strong { color:#ffa4d6; }
.nexus-neural-canvas { position:absolute; inset:0; width:100%; height:100%; z-index:1; pointer-events:none; }
.orbit-scene .core-halo,.orbit-scene .core { z-index:2; }
.orbit-scene .agent-node { z-index:3; transition:box-shadow .3s ease,border-color .3s ease,opacity .3s ease; }
.orbit-scene .agent-node[data-real-status="busy"] { border-color:#b7f9ff; box-shadow:0 0 24px rgba(72,218,255,.55),inset 0 0 14px rgba(59,190,255,.14); }
.orbit-scene .agent-node[data-real-status="unknown"] { opacity:.58; }
.hud-model-state { display:inline-block; margin-top:8px; padding:5px 11px; border:1px solid rgba(255,84,189,.4); border-radius:4px; color:#ffa6db; font:11px ui-monospace,monospace; }
.hud-livefeed { margin-top:19px; max-width:500px; border:1px solid rgba(55,196,255,.28); background:rgba(0,12,29,.72); padding:12px 14px; border-radius:7px; box-shadow:0 8px 25px rgba(0,0,0,.18); }
.hud-livefeed-title { display:flex; justify-content:space-between; flex-wrap:wrap; gap:6px; color:#7deaff; font:600 11px ui-monospace,monospace; letter-spacing:.05em; padding-bottom:8px; border-bottom:1px solid rgba(67,175,229,.18); }
.hud-livefeed-title span { font:10px ui-monospace,monospace; color:#699abb; }
#hud-events { margin-top:8px; display:grid; gap:6px; color:#bad8f1; font:11px/1.6 ui-monospace,monospace; max-height:110px; overflow-y:auto; overflow-wrap:anywhere; }
#hud-events>div::before { content:"●"; color:#ff58c3; margin-right:8px; font-size:8px; }
.hud-timestamp { font:10px ui-monospace,monospace; color:#6ba0bc !important; }
@media (max-width:900px) {
 #nexus-hero { grid-template-columns:1fr; min-height:auto; padding-top:116px; }
 .hud-kpis { top:47px; grid-template-columns:repeat(2,minmax(0,1fr)); }
 .hud-kpis>div { padding:8px 5px; }
 .hud-kpis small { font-size:9px; }
 .hud-kpis strong { font-size:16px; }
 .orbit-scene { margin-top:10px; }
}
@media (max-width:580px) {
 .hud-topline { padding:10px 12px; font-size:9px; }
 .hud-ver { display:none; }
 #nexus-hero { padding-top:116px; }
 .hud-kpis>div { gap:6px; }
 .hud-kpis small { font-size:8px; }
 .hud-livefeed { margin-top:15px; }
 .orbit-scene { height:260px; }
}
