/* Nexus: the approved holographic design (nexus-reference.html), ported onto the live dashboard.
   Tokens first, then surfaces, then state-driven motion. Every number shown comes from the bridge. */
@property --nexus-border-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

:root {
  color-scheme: dark;
  --bg:#050B0F; --panel:#0A151C; --panel-2:#0C1A21; --text:#E1F5F6; --muted:#91AFB8; --border:#23414B;
  --accent:#62E8E8; --ok:#94F7A7; --warn:#FFCA82; --err:#FA9696;
  --halo:#10353f88; --grid:#79e8ef07; --header-bg:#050b0fd9;
  --hud-1:#10222be8; --hud-2:#09141be8; --cmd-1:#10252b; --cmd-2:#091417; --cmd-line:#44838b;
  --appr-1:#241e15; --appr-2:#101b20; --appr-line:#645137; --appr-hot:#fff1c8;
  --idle-line:#34434b; --idle-bg:#0a1319; --idle-corner:#52646d; --idle-ink:#a3b5bd;
  --fail-bg:#201519; --done-line:#85ddb0; --done-sweep:#285b43; --done-bg:#0b191b;
  --track:#233941; --on-accent:#052025; --on-warn:#241a0b; --placeholder:#b1c9ce;
  --claude:#FFCA82; --codex:#94F7A7; --antigravity:#A8BBFF; --gemini:#A8BBFF;
}
:root[data-theme=light] {
  color-scheme: light;
  --bg:#EEF5F6; --panel:#FFFFFF; --panel-2:#E4EFF1; --text:#0B2530; --muted:#3F5E69; --border:#9FBCC5;
  --accent:#00707A; --ok:#1E6B35; --warn:#8A5200; --err:#B0303C;
  --halo:#bfe6ea88; --grid:rgba(0,80,95,.05); --header-bg:#eef5f6e6;
  --hud-1:#ffffff; --hud-2:#f4f9fa; --cmd-1:#e3f2f3; --cmd-2:#f7fbfb; --cmd-line:#5f9aa2;
  --appr-1:#fff4e3; --appr-2:#fbf8f2; --appr-line:#c99a55; --appr-hot:#8a5200;
  --idle-line:#b5c6cc; --idle-bg:#f7fafb; --idle-corner:#8fa3aa; --idle-ink:#3f5e69;
  --fail-bg:#fdeff0; --done-line:#2f8a55; --done-sweep:#cdeedb; --done-bg:#ffffff;
  --track:#d3e2e6; --on-accent:#ffffff; --on-warn:#ffffff; --placeholder:#5d7a84;
  --claude:#8A5200; --codex:#1E6B35; --antigravity:#4b3fa0; --gemini:#4b3fa0;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: 90px; }
html, body { margin: 0; color: var(--text); background: var(--bg); }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh;
  background: radial-gradient(ellipse at 52% 18%, var(--halo), transparent 48%) fixed,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 36px 36px, var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#announcer, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: 0; left: 16px; transform: translateY(-120%); z-index: 100; background: var(--panel); color: var(--text); padding: 12px; }
.skip-link:focus { transform: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-weight: 400; font-size: 44px; letter-spacing: -1.6px; line-height: 1.1; margin: 8px 0 0; }
h2 { font-size: 17px; font-weight: 500; }
h3 { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
small { font-size: 12px; color: var(--muted); }
.label { font: 11px/1.5 ui-monospace, SFMono-Regular, monospace; letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted); }
.amber { color: var(--warn) !important; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; font: 10px/1.4 ui-monospace, monospace; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); border: 1px solid var(--border); white-space: nowrap; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-width: 0; }
.section-head { margin-bottom: 12px; }
.info { font-size: 13px; color: var(--muted); margin: 0; }
.info.err { color: var(--err); }

/* ---------- Controls ---------- */
.btn { cursor: pointer; min-height: 44px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); padding: 10px 14px;
  border-radius: 3px; font-size: 13px; font-weight: 500; transition: background-color .18s, border-color .18s, box-shadow .18s; }
.btn:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 10%, transparent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 15%, transparent); }
.btn.ok { background: var(--ok); color: var(--on-accent); border-color: var(--ok); font-weight: 600; }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--err) 60%, var(--border)); color: var(--err); }
.btn.ghost { background: transparent; color: var(--muted); font-size: 12px; }
.btn.small { font-size: 12px; padding: 8px 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-button { border: 0; background: transparent; padding: 10px 0; min-height: 44px; color: var(--accent); font-size: 12px; text-align: left; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
select, input[type=text], input[type=password], input[type=url], input[type=number], textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 3px; padding: 10px 12px; min-height: 44px; color: var(--text);
}
select { color: var(--muted); font-size: 13px; padding: 8px 10px; }
textarea { resize: vertical; min-height: 96px; }
label.field { display: block; font-size: 12px; color: var(--muted); }
label.field select, label.field input { margin-top: 4px; }
label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--muted); cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 10px; max-height: 360px; overflow: auto; font-size: 12px; }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border); background: var(--header-bg); backdrop-filter: blur(8px); }
.brand { font-weight: 600; font-size: 16px; letter-spacing: 3px; white-space: nowrap; }
.brand span, .brand em { color: var(--accent); font-style: normal; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 10px 14px; color: var(--muted); text-decoration: none; font-size: 13px;
  border: 1px solid transparent; border-radius: 3px; }
.nav a:hover { color: var(--accent); }
.nav a.selected { color: var(--accent); border-bottom-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.top-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.connection { display: inline-flex; align-items: center; gap: 7px; font: 11px/1.5 ui-monospace, monospace; letter-spacing: .5px; text-transform: uppercase; color: var(--err); }
.connection.on { color: var(--ok); animation: nexus-connection 5s ease-in-out infinite; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
#macLabel { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#syncFresh { font-size: 10px; color: var(--muted); }

/* ---------- Page ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 26px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left)); display: grid; gap: 24px; min-width: 0; }
main > * { min-width: 0; }
.hero { align-items: flex-end; }
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* Instrument panel with corner brackets */
.hud { background: linear-gradient(130deg, var(--hud-1), var(--hud-2)); border: 1px solid var(--border); padding: 18px; position: relative; min-width: 0; }
.hud::before, .hud::after { content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none; }
.hud::before { top: -1px; left: -1px; border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); }
.hud::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); }

/* ---------- Authorization requests ---------- */
#approvals { display: grid; gap: 14px; }
.approval { border: 1px solid var(--appr-line); background: linear-gradient(110deg, var(--appr-1), var(--appr-2)); padding: 20px 22px;
  box-shadow: 0 0 18px color-mix(in srgb, var(--warn) 6%, transparent); }
.approval::before, .approval::after { display: none; }
.approval .title { font-size: 20px; font-weight: 400; margin-top: 12px; overflow-wrap: anywhere; }
.approval .meta { color: var(--muted); font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.approval .approval-count { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.approval .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.approval .actions .btn { font-size: 13px; padding: 12px 18px; }
.approval .actions .btn.primary { background: var(--warn); border-color: var(--warn); color: var(--on-warn); box-shadow: 0 0 16px color-mix(in srgb, var(--warn) 12%, transparent); }
.approval .rule { font-size: 12px; color: var(--muted); margin-top: 8px; }
.approval .q { margin: 12px 0; }
.approval .q .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.approval .q .opts button.chosen { background: var(--warn); border-color: var(--warn); color: var(--on-warn); }
.approval pre { background: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ---------- Directive console ---------- */
.command { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 16px; align-items: end; border: 1px solid var(--cmd-line);
  background: linear-gradient(115deg, var(--cmd-1), var(--cmd-2)); padding: 20px 22px; position: relative;
  box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 4%, transparent); }
.command::before { content: ''; position: absolute; top: -1px; left: 0; width: 90px; height: 2px; background: var(--accent); box-shadow: 0 0 16px var(--accent); }
.command-label { display: block; color: var(--accent); font: 12px/1.5 ui-monospace, monospace; letter-spacing: 3px; margin-bottom: 8px; }
.command textarea, .command #cmd { width: 100%; display: block; resize: vertical; min-height: 70px; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 18px; line-height: 1.5; }
.command #cmd { min-height: 48px; font-size: 16px; }
.command textarea::placeholder, .command #cmd::placeholder { color: var(--placeholder); opacity: 1; }
.command textarea:focus-visible, .command #cmd:focus-visible { outline: none; }
.command:focus-within { border-color: var(--accent); }
.command-options { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.command-options select { width: auto; max-width: 100%; min-width: 150px; font-size: 12px; }
.command-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.command-actions .btn.primary { font-size: 15px; padding: 12px 18px; }
.command .advanced { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 4px; }
.advanced-body { display: grid; gap: 12px; padding: 8px 0 4px; }
.advanced-body .row { justify-content: flex-start; }
.gate-settings, .project-rules { border: 1px solid var(--border); border-radius: 3px; padding: 12px; display: grid; gap: 8px; font-size: 13px; }
.project-rules ul { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.project-rules li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.project-rules li .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.project-rules li .who { color: var(--muted); font-size: 12px; flex: none; }
#status pre { margin-top: 8px; }

/* ---------- Live operations ---------- */
.motion-key { display: flex; gap: 18px; flex-wrap: wrap; font: 11px ui-monospace, monospace; color: var(--muted); margin-bottom: 14px; }
.motion-key span { display: inline-flex; gap: 6px; align-items: center; }
.motion-key i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.motion-key .k-working { background: var(--accent); } .motion-key .k-idle { background: var(--idle-corner); }
.motion-key .k-attention { background: var(--warn); } .motion-key .k-failed { background: var(--err); }
.orbit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px minmax(0, 1fr); gap: 20px; align-items: center; }
.stack { display: grid; gap: 16px; align-content: center; min-width: 0; }
.stack:empty { display: none; }
.core-wrap { grid-column: 2; }
.core { position: relative; width: 250px; height: 250px; display: grid; place-items: center; margin: auto; text-align: center; }
.ring { position: absolute; border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent); border-radius: 50%; inset: 0;
  box-shadow: inset 0 0 34px color-mix(in srgb, var(--accent) 4%, transparent), 0 0 24px color-mix(in srgb, var(--accent) 4%, transparent); }
.ring.r2 { inset: 14px; border: 4px solid transparent; border-top-color: color-mix(in srgb, var(--accent) 63%, transparent); border-bottom-color: color-mix(in srgb, var(--accent) 38%, transparent); transform: rotate(28deg); }
.ring.r3 { inset: 31px; border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent); }
.ring.r4 { inset: 48px; border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent); background: radial-gradient(circle, color-mix(in srgb, var(--accent) 17%, transparent), transparent 70%); }
.core-text { z-index: 1; display: grid; justify-items: center; }
.core strong { display: block; font-size: 44px; letter-spacing: -2px; font-weight: 300; color: var(--accent); line-height: 1.2; }
.core .label { color: var(--accent); font-size: 11px; }
.core small { font-size: 13px; }
.orbit-caption { text-align: center; margin-top: 14px; }
.core[data-state=working] .r2 { animation: nexus-orbit 42s linear infinite; }
.core[data-state=working] .r3 { animation: nexus-orbit-reverse 65s linear infinite; }
.core[data-state=working] .r4 { animation: nexus-core 7s ease-in-out infinite; }
.core[data-state=offline] { opacity: .55; }

.lab-panel .project-name { font-size: 20px; letter-spacing: -.4px; margin-top: 12px; overflow-wrap: anywhere; }
.lab-panel .goal { font-size: 13px; color: var(--muted); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lab-panel .taskline { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 20px; overflow-wrap: anywhere; }
.lab-panel .prog { margin-top: 14px; }
.lab-actions { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 4px; }
.lab-job { margin-top: 12px; display: grid; gap: 8px; }
.lab-reason { font-size: 12px; line-height: 1.45; color: var(--err); overflow-wrap: anywhere; }
.lab-roles { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.lab-roles label.mini { flex: 1 1 140px; }
.lab-roles select { min-width: 0; }
.lab-controls { justify-content: flex-start; gap: 8px; }
.percent { font-size: 24px; color: var(--accent); font-family: ui-monospace, monospace; }
.bar { height: 5px; background: var(--track); margin: 10px 0 7px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width .8s ease; }
.bar.segmented { height: 8px; -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 10px); mask-image: repeating-linear-gradient(90deg, #000 0 7px, transparent 7px 10px); }
.bar.green span { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.bar.warn span { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.idle-labs { margin-top: 12px; }
.idle-labs > summary { color: var(--muted); }
#idleLabList { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; padding-top: 8px; }

/* State pill with dot */
.state-pill { display: inline-flex; align-items: center; gap: 7px; font: 11px/1.4 ui-monospace, monospace; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.pill.state-pill { padding: 4px 8px; font-size: 10px; }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
[data-tone=idle], [data-tone=queued], [data-tone=paused] { color: var(--idle-ink) !important; }
[data-tone=disconnected], [data-tone=stale] { color: var(--muted) !important; }
[data-tone=needs-input], [data-tone=waiting-limit] { color: var(--warn) !important; }
[data-tone=failed], [data-tone=blocked] { color: var(--err) !important; }
[data-tone=completed] { color: var(--done-line) !important; }
.agent-panel .state-pill[data-tone=working] { color: var(--ok) !important; }

/* ---------- Agent telemetry ---------- */
.agents { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 16px; }
.agent-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.agent-title h3 { font-size: 16px; letter-spacing: .5px; }
.agent-symbol { width: 36px; height: 36px; border: 1px solid var(--accent); display: grid; place-items: center; color: var(--accent); font: 12px ui-monospace, monospace;
  background: color-mix(in srgb, var(--accent) 5%, transparent); flex: none; }
.agent-panel .agent-work { font-size: 13px; color: var(--muted); margin-top: 8px; overflow-wrap: anywhere; }
.agent-panel .latest-activity { margin-top: 6px; }
.metrics { margin-top: 14px; display: grid; gap: 4px; }
.metrics .row { font-size: 12px; }
.metrics strong { font-weight: 600; }
.metrics .na { color: var(--muted); font-weight: 400; }
.latest-activity { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Execution feed ---------- */
.event { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; overflow-wrap: anywhere; }
.event:last-child { border: 0; }
.event time { color: var(--accent); font: 11px ui-monospace, monospace; margin-right: 10px; display: inline-block; min-width: 30px; }
.event.err { color: var(--err); }
#execFeed { margin-top: 6px; }

/* ---------- Jobs, tasks, queue, history ---------- */
#jobs, #feed { display: grid; gap: 16px; }
.job, .task { padding: 18px; }
.head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; min-width: 0; flex-wrap: wrap; }
.head .who { font-weight: 600; overflow-wrap: anywhere; }
.head .proj { font: 11px ui-monospace, monospace; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font: 10px/1.4 ui-monospace, monospace; letter-spacing: 1px; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.running { color: var(--accent); } .badge.ok, .badge.done { color: var(--ok); }
.badge.fail, .badge.failed, .badge.lost { color: var(--err); } .badge.paused, .badge.pausing, .badge.stopped, .badge.interrupted, .badge.waiting_limit { color: var(--warn); }
.fa-badge { font: 10px/1.4 ui-monospace, monospace; letter-spacing: 1px; color: var(--warn); border: 1px solid var(--warn); padding: 2px 6px; flex: none; }
.agent-name.claude { color: var(--claude); } .agent-name.codex { color: var(--codex); }
.agent-name.antigravity, .agent-name.gemini { color: var(--antigravity); }
.prompt { color: var(--muted); font-size: 14px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }
.job .task-text { font-size: 15px; margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; }
.job .stepline { font-size: 14px; margin-bottom: 10px; }
.job .error, .task .error { color: var(--err); font-size: 14px; margin-bottom: 8px; white-space: pre-wrap; }
.job .ship-ok { color: var(--ok); font-size: 14px; margin-bottom: 8px; white-space: pre-wrap; }
.job .controls { margin: 10px 0; justify-content: flex-start; }
.job details, .task details { margin-top: 6px; }
.job summary, .task summary { color: var(--muted); font-size: 13px; }
.job .grid3 { margin-top: 10px; }
.stage-strip { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 8px; padding: 0; }
.stage-strip li { font: 10px/1.5 ui-monospace, monospace; color: var(--muted); border-bottom: 2px solid var(--border); padding: 5px 6px; flex: 1 1 auto; text-align: center; }
.stage-strip li.current { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.setting-badges { color: var(--muted); font: 11px/1.6 ui-monospace, monospace; margin-bottom: 10px; }
.scope-bar { height: 5px; background: var(--track); margin: 8px 0; overflow: hidden; }
.scope-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .8s ease; }
.freshness { color: var(--muted); font-size: 10px; }
.log { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 3px; background: var(--bg); padding: 8px 10px; margin-top: 8px; }
.line { padding: 2px 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.line.tool { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.line.info { font-size: 12px; color: var(--accent); }
.line.error { color: var(--err); }
.line.result { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.line .tag { font-weight: 600; margin-right: 6px; }
ul.issues { margin: 6px 0 0; padding-left: 20px; font-size: 13px; }
ul.issues li { margin: 2px 0; }
.sev { font: 10px ui-monospace, monospace; text-transform: uppercase; margin-right: 6px; }
.sev.blocker { color: var(--err); } .sev.major { color: var(--warn); } .sev.minor { color: var(--muted); }
.report { margin-top: 10px; }
.report .report-head { font-size: 13px; font-weight: 600; }
.waiting { border: 1px solid var(--warn); color: var(--warn); border-radius: 3px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.follow { margin-top: 10px; flex-wrap: nowrap; }
.gate, .phases { margin: 8px 0; font-size: 13px; }
.gate .gate-head, .phases .gate-head { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.gate ul, .phases ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.gate .ok { color: var(--ok); } .gate .bad { color: var(--err); } .gate .skip { color: var(--muted); }
.store-error { color: var(--err); font-size: 13px; margin-bottom: 8px; white-space: pre-wrap; }
.rules { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.rules .chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); padding: 2px 4px 2px 10px; color: inherit; max-width: 100%; overflow-wrap: anywhere; }
.rules .chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 6px; min-height: 44px; min-width: 44px; }
.queue-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.queue-head h2 { flex: 1; margin: 0; }
#queueList { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#queueList li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border: 1px solid var(--border); padding: 10px 12px; min-width: 0; }
#queueList .n { font: 11px ui-monospace, monospace; color: var(--accent); flex: none; }
#queueList .t { flex: 1 1 40%; min-width: 0; overflow-wrap: anywhere; }
#queueList .p { color: var(--muted); font-size: 12px; flex: none; }
#queueList .fa { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); flex: none; cursor: pointer; min-height: 44px; }
#queueList button { min-height: 44px; min-width: 44px; padding: 0 8px; }
#queueCurrent { font-size: 13px; margin-bottom: 8px; }
#historyList { display: grid; gap: 10px; padding-top: 6px; }
.history-entry > summary { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
#history > summary { color: var(--text); font: 11px/1.5 ui-monospace, monospace; letter-spacing: 1.8px; text-transform: uppercase; }
.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.system-grid > div { display: grid; gap: 8px; align-content: start; }
.system-grid .row { justify-content: flex-start; }
.foot { font: 10px/1.5 ui-monospace, monospace; color: var(--muted); letter-spacing: .8px; text-transform: uppercase; }
.target { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Commit review panel */
.review { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; display: grid; gap: 8px; }
.review .file { display: grid; gap: 4px; }
.review .file-row { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.review .file-row input { width: 20px; height: 20px; flex: none; }
.review .file-name { flex: 1; min-width: 0; min-height: 44px; text-align: left; background: none; border: 0; color: var(--text); padding: 0; cursor: pointer;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; text-decoration: underline dotted; }
.review .tag { font: 10px ui-monospace, monospace; padding: 1px 6px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.review .tag.warn { color: var(--warn); }
.review textarea { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.diff { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 6px 8px; max-height: 60vh; overflow: auto; }
.diff div { white-space: pre-wrap; word-break: break-word; }
.diff .add { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.diff .del { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); }
.diff .hunk { color: var(--accent); } .diff .meta { color: var(--muted); } .diff .note { color: var(--warn); font-family: inherit; font-weight: 600; }

/* ---------- Login ---------- */
#login { max-width: 400px; margin: 14vh auto 0; padding: 0 16px; }
#login h1 { font-size: 34px; margin: 18px 0 6px; }
.login-form { display: grid; gap: 10px; margin-top: 22px; }
#loginError { color: var(--err); min-height: 1.5em; font-size: 13px; }

/* ---------- State-driven motion ----------
   working: faint cyan light travels the border (~9s). needs input: amber, faster (~5s), with a slow glow.
   failed / completed: one-time effect on the transition only (data-effect), then a static border. */
.hud[data-state=working] { border: 1px solid transparent;
  background: linear-gradient(130deg, var(--hud-1), var(--hud-2)) padding-box,
    conic-gradient(from var(--nexus-border-angle), var(--border) 0deg, var(--border) 295deg, color-mix(in srgb, var(--accent) 67%, transparent) 335deg, var(--border) 360deg) border-box;
  animation: nexus-border 9s linear infinite; }
.hud[data-state=working] .state-dot { animation: state-dot 3.5s ease-in-out infinite; }
.hud[data-state=needs-input], .approval { border: 1px solid transparent;
  background: linear-gradient(110deg, var(--appr-1), var(--appr-2)) padding-box,
    conic-gradient(from var(--nexus-border-angle), var(--appr-line) 0deg, var(--appr-line) 265deg, var(--warn) 325deg, var(--appr-hot) 345deg, var(--appr-line) 360deg) border-box;
  animation: nexus-border 5s linear infinite, nexus-breathe 4s ease-in-out infinite; }
.hud[data-state=needs-input]::before, .hud[data-state=needs-input]::after,
.hud[data-state=waiting-limit]::before, .hud[data-state=waiting-limit]::after { border-color: var(--warn); }
.hud[data-state=waiting-limit] { border-color: var(--appr-line); background: linear-gradient(110deg, var(--appr-1), var(--appr-2)); }
.hud[data-state=idle], .hud[data-state=queued], .hud[data-state=paused] { border-color: var(--idle-line); background: var(--idle-bg); }
.hud[data-state=idle]::before, .hud[data-state=idle]::after, .hud[data-state=queued]::before, .hud[data-state=queued]::after,
.hud[data-state=paused]::before, .hud[data-state=paused]::after { border-color: var(--idle-corner); }
.hud[data-state=disconnected], .hud[data-state=stale] { border-style: dashed; border-color: var(--idle-line); background: var(--idle-bg); }
.hud[data-state=disconnected]::before, .hud[data-state=disconnected]::after, .hud[data-state=stale]::before, .hud[data-state=stale]::after { border-color: var(--idle-corner); }
.hud[data-state=failed], .hud[data-state=blocked] { border-color: var(--err); background: var(--fail-bg); }
.hud[data-state=failed]::before, .hud[data-state=failed]::after, .hud[data-state=blocked]::before, .hud[data-state=blocked]::after { border-color: var(--err); }
.hud[data-state=completed] { border-color: var(--done-line); background: var(--done-bg); }
.hud[data-state=completed]::before, .hud[data-state=completed]::after { border-color: var(--done-line); }
.hud[data-effect=failed], .hud[data-effect=blocked] { animation: state-failed 1.6s ease-in-out 1; }
.hud[data-effect=completed] { background: linear-gradient(110deg, var(--done-bg) 30%, var(--done-sweep) 50%, var(--done-bg) 70%); background-size: 300% 100%;
  animation: state-complete 1.8s ease-out 1; background-position: 0% 50%; }
#history > summary[data-effect=completed] { animation: summary-complete 1.6s ease-out 1; }

@keyframes nexus-border { to { --nexus-border-angle: 360deg; } }
@keyframes nexus-breathe { 0%, 100% { box-shadow: 0 0 12px color-mix(in srgb, var(--warn) 4%, transparent); } 50% { box-shadow: 0 0 27px color-mix(in srgb, var(--warn) 13%, transparent); } }
@keyframes nexus-orbit { from { transform: rotate(28deg); } to { transform: rotate(388deg); } }
@keyframes nexus-orbit-reverse { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
@keyframes nexus-core { 0%, 100% { box-shadow: inset 0 0 22px color-mix(in srgb, var(--accent) 4%, transparent), 0 0 15px color-mix(in srgb, var(--accent) 3%, transparent); }
  50% { box-shadow: inset 0 0 32px color-mix(in srgb, var(--accent) 16%, transparent), 0 0 30px color-mix(in srgb, var(--accent) 9%, transparent); } }
@keyframes nexus-connection { 0%, 100% { text-shadow: 0 0 0 transparent; } 50% { text-shadow: 0 0 12px color-mix(in srgb, var(--ok) 40%, transparent); } }
@keyframes state-dot { 0%, 100% { box-shadow: 0 0 0 0 transparent; opacity: .7; } 50% { box-shadow: 0 0 10px 3px color-mix(in srgb, currentColor 31%, transparent); opacity: 1; } }
@keyframes state-failed { 0%, 100% { box-shadow: 0 0 0 transparent; } 30%, 70% { box-shadow: 0 0 22px color-mix(in srgb, var(--err) 25%, transparent); } }
@keyframes state-complete { from { background-position: 100% 50%; } to { background-position: 0% 50%; } }
@keyframes summary-complete { 35% { color: var(--ok); } }

:root[data-motion=paused] *, :root[data-motion=paused] *::before, :root[data-motion=paused] *::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .orbit-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .core-wrap { grid-column: 1 / -1; grid-row: 1; }
  .core { width: 200px; height: 200px; }
  .stack { display: contents; }
}
@media (max-width: 620px) {
  .topbar { padding: max(16px, env(safe-area-inset-top)) 16px 14px; flex-direction: column; align-items: flex-start; }
  .nav { gap: 0; }
  .nav a { padding: 8px 10px; }
  main { padding: 18px 16px 32px; gap: 20px; }
  h1 { font-size: 34px; letter-spacing: -1.2px; }
  .orbit-layout { grid-template-columns: minmax(0, 1fr); }
  .core-wrap { grid-column: auto; }
  .core { width: 180px; height: 180px; }
  .core strong { font-size: 36px; }
  .command { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .command textarea, .command-options select, .command #cmd { font-size: 16px; }
  .command-options select { flex: 1 1 100%; }
  .command-actions { justify-content: stretch; }
  .command-actions .btn { flex: 1 1 auto; }
  .command-actions .btn.primary { flex-basis: 100%; order: -1; }
  .approval { padding: 18px; }
  .approval .actions .btn { flex: 1 1 100%; }
  .hud, .job, .task { padding: 16px; }
  .grid3 { grid-template-columns: minmax(0, 1fr); }
  #queueList .p { flex-basis: 100%; }
  .foot { flex-direction: column; align-items: flex-start; }
}
#login .login-brand { font-size: 40px; letter-spacing: 2px; margin: 0 0 6px; font-weight: 600; }

/* ---------- Simplified console: visible job settings ---------- */
.command-options { margin: 0 0 12px; }
.command-options .mini select { min-width: 140px; }
label.mini { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 12px; color: var(--muted); }
label.mini select { width: auto; min-height: 40px; font-size: 13px; }
.command .hint { display: block; margin-top: 6px; color: var(--muted); }
.job-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.switches, .roles { display: flex; flex-wrap: wrap; gap: 4px 22px; align-items: center; }
.roles label.mini select { min-width: 120px; }
label.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 13px; color: var(--text); cursor: pointer; position: relative; }
label.switch input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
label.switch .track { width: 38px; height: 22px; border-radius: 11px; border: 1px solid var(--border); background: var(--track); position: relative; flex: none; transition: background .2s, border-color .2s; }
label.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
label.switch input:checked + .track { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
label.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent); }
label.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
label.switch:has(#fullAuto:checked) .track { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 22%, transparent); }
label.switch:has(#fullAuto:checked) .track::after { background: var(--warn); }
.fa-note { display: grid; gap: 6px; font-size: 13px; color: var(--warn); border-left: 2px solid var(--warn); padding: 4px 0 4px 10px; }
.fa-note .btn { margin-left: 6px; }
.approval .rule-help { margin-top: 8px; }
.approval .rule-help > summary { font-size: 12px; color: var(--muted); min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.lab-panel > .row:first-child { align-items: flex-start; gap: 10px; }
.lab-panel .project-name { margin-top: 0; }
.lab-panel { cursor: pointer; }
.lab-panel .taskline { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 620px) {
  /* Phone: the title and pill go; the New task button stays, full width. */
  .hero > div:first-child, .hero #heroPill { display: none; }
  .hero-actions { width: 100%; }
  #consoleToggle { width: 100%; }
  label.mini { flex: 1 1 100%; justify-content: space-between; }
  label.mini select, .command-options .mini select, .roles label.mini select { flex: 1; min-width: 0; max-width: 70%; }
  .switches { gap: 0 18px; }
  label.switch { flex: 1 1 100%; }
  label.mini.rounds { flex: 1 1 100%; }
}

/* ---------- Dense desktop layout ----------
   Below 1100px the column wrappers vanish (display: contents) and `order` gives the phone/tablet sequence:
   approvals, directive, labs, agents, active jobs, queue, then everything else. */
.overview-grid, .col-main, .col-side { display: contents; }
#telemetry { order: 1; } #activeJobs { order: 2; } #queueCard { order: 3; } #execFeedPanel { order: 4; }
#directActivity { order: 5; } #history { order: 6; } #system { order: 7; } .foot { order: 8; }

@media (min-width: 1100px) {
  main { max-width: 1480px; gap: 16px; padding-top: 16px; }
  .hero h1 { font-size: 26px; letter-spacing: -.6px; margin-top: 2px; }
  .overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; order: 0; }
  .col-main, .col-side { display: grid; gap: 16px; min-width: 0; align-content: start; }
  #telemetry, #activeJobs, #queueCard, #execFeedPanel { order: 0; }
  .section-head { margin-bottom: 8px; }
  .hud, .job, .task { padding: 14px 16px; }

  /* Approvals */
  .approval { padding: 14px 18px; }
  .approval .title { font-size: 17px; margin-top: 6px; }
  .approval .meta { font-size: 13px; }
  .approval .actions { margin-top: 10px; gap: 8px; }
  .approval .actions .btn { padding: 8px 14px; min-height: 38px; }
  .approval .rule-help > summary { min-height: 32px; }

  /* Directive console */
  .command { padding: 14px 18px; gap: 10px 16px; }
  .command-options { margin-bottom: 4px; gap: 4px 16px; }
  label.mini { min-height: 38px; }
  label.mini select { min-height: 34px; padding: 5px 8px; }
  .command textarea { min-height: 52px; font-size: 16px; }
  .job-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 0 22px; margin-top: 8px; padding-top: 6px; }
  .job-settings .fa-note { flex-basis: 100%; order: 3; margin: 2px 0 4px; }
  label.switch { min-height: 38px; }
  .command-actions .btn { min-height: 40px; padding: 8px 16px; }
  .command .advanced > summary { min-height: 32px; }

  /* Labs */
  .orbit-layout { grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1fr); gap: 14px; }
  .core { width: 180px; height: 180px; }
  .ring.r3 { inset: 24px; } .ring.r4 { inset: 38px; }
  .core strong { font-size: 34px; }
  .orbit-caption { margin-top: 8px; }
  .stack { gap: 12px; }
  .lab-panel .project-name { font-size: 17px; }
  .lab-panel .taskline { margin-top: 4px; }
  .lab-panel .prog { margin-top: 8px; }
  .bar { margin: 6px 0 4px; }
  .percent { font-size: 18px; }
  .lab-panel .link-button { min-height: 30px; padding: 4px 0; }
  .idle-labs { margin-top: 4px; }

  /* Side column: agents, queue, activity */
  .agents { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .agent-panel { padding: 12px 14px; }
  .agent-symbol { width: 28px; height: 28px; font-size: 11px; }
  .agent-title { gap: 10px; }
  .agent-title h3 { font-size: 14px; }
  .agent-panel .agent-work { margin-top: 6px; font-size: 12px; }
  .agent-panel .latest-activity { margin-top: 2px; -webkit-line-clamp: 1; }
  .metrics { margin-top: 6px; gap: 2px; }
  .metrics .bar { margin: 3px 0; height: 6px; }
  #queueList li { padding: 6px 10px; gap: 6px; }
  #queueList .t { flex-basis: 100%; }
  #queueList button, #queueList .fa { min-height: 34px; min-width: 34px; }
  .queue-head { margin-bottom: 8px; }
  .queue-head .btn { min-height: 34px; }
  .event { padding: 6px 0; font-size: 13px; }

  /* Active jobs side by side */
  #jobs { grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); gap: 14px; align-items: start; }
  .job .grid3 select { min-height: 36px; padding: 6px 8px; }
  .job .controls .btn { min-height: 36px; padding: 6px 12px; }
  .stage-strip { margin: 8px 0 6px; }
  .system-grid { margin-top: 6px !important; }
}
@media (min-width: 1100px) {
  /* An empty allowance bar says nothing; it shows only when a real usage limit fills it. */
  .agent-panel .bar.green { display: none; }
  .agent-panel .metrics { grid-template-columns: 1fr; }
  #queueList .t { flex-basis: auto; }
}

/* ---------- Sign-in, identity, machines ---------- */
.google-login { display: inline-flex; justify-content: center; align-items: center; width: 100%; max-width: 360px; text-decoration: none; margin: 18px 0 6px; }
.break-glass { margin-top: 14px; max-width: 360px; width: 100%; }
.break-glass > summary { color: var(--muted); }
.break-glass .login-form { margin-top: 6px; }
#loginError { color: var(--err); font-size: 13px; min-height: 18px; max-width: 360px; }
.whoami { font-size: 10px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .by { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.worker-alert { border: 1px solid var(--warn); padding: 8px 12px; display: grid; gap: 6px; font-size: 13px; }
label.locked { opacity: .55; }
[data-locked=true] { cursor: not-allowed; }
@media (max-width: 620px) { .whoami { max-width: 100%; } }
.demo-banner { background: var(--warn); color: var(--on-warn); text-align: center; font: 600 12px/1.4 ui-monospace, monospace; letter-spacing: 1px; text-transform: uppercase; padding: 8px 16px; }
.link-button:disabled { opacity: .45; cursor: not-allowed; text-decoration: none; }
.new-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 22px; }
.new-settings .hint { flex-basis: 100%; color: var(--muted); }
.new-settings input#newName { min-height: 40px; width: 200px; padding: 6px 10px; }
@media (max-width: 620px) { .new-settings input#newName { width: auto; flex: 1; } .new-settings label.switch { flex: 1 1 100%; } }
