/* OpenToad — GISP structural spine + chat-first control field.
   Monochrome by default. Color by exception. Information before atmosphere. */

:root {
  color-scheme: dark;

  --void: #111315;
  --void-1: #16191b;
  --void-2: #1c2023;
  --structure: #667078;
  --paper: #f2f0e9;

  --ink-hi: #e9eae7;
  --ink-mid: #9aa1a5;
  --ink-lo: #6b7175;
  --rule: #2b2f31;

  --amber: #f5c84b;
  --cyan: #35d0c5;
  --green: #68d391;
  --red: #f05b5b;
  --blue: #5aa9e6;

  --display: "Barlow Condensed", "Oswald", "Arial Narrow", system-ui, sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --cap: 999px;
  --r: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--ink-hi);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: 0.86em; color: var(--ink-mid); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; left: 8px; top: 8px; z-index: 50; background: var(--amber); color: var(--void); padding: 8px 14px; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- spine (LCARS ribbon) */
.shell {
  display: grid;
  grid-template-columns: 202px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  gap: 0;
  padding: 35px 48px 58px;
  height: 100dvh;
}

/* The rail and register are one continuous LCARS spine. The inner cut-out
   creates the characteristic elbow instead of leaving two floating pills. */
.rail {
  grid-column: 1; grid-row: 1 / 3;
  position: relative;
  display: flex;
  flex-direction: column;
  color: #14161a;
  min-height: 0;
}

.rail::before,
.rail::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.rail::before {
  inset: 0;
  background: var(--structure);
  border-radius: 136px 0 0 62px;
}

.rail::after {
  top: 56px;
  right: 0;
  bottom: 0;
  left: 120px;
  background: var(--void);
  border-radius: 78px 0 0 0;
}

.rail > * {
  position: relative;
  z-index: 1;
}

.rail-brand { display: none; }
.rail-brand img { width: 20px; height: 20px; filter: grayscale(1) brightness(0.22); }
.rail-brand span { font-family: var(--display); font-weight: 700; letter-spacing: 0.11em; font-size: 15px; text-transform: uppercase; }

.new-session {
  margin: 0 14px 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 12px;
  background: var(--void); color: var(--amber);
  border: 0; border-radius: var(--cap);
  font-family: var(--display); font-size: 14px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
  transition: background 120ms;
}
.new-session:hover { background: #1f2224; }
.new-session .plus { font-size: 16px; }

/* nav — plain text, amber block when active (matches the reference) */
.rail-nav { display: flex; flex-direction: column; }
.rail-nav a {
  display: flex;
  align-items: center;
  width: 120px;
  padding: 10px 14px;
  font-family: var(--display); font-size: 15px; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(20, 22, 26, 0.7);
  transition: background 100ms, color 100ms;
}
.rail-nav a:hover { background: rgba(20, 22, 26, 0.1); color: #14161a; }
.rail-nav a.active { background: var(--amber); color: var(--void); font-weight: 700; }
.rail-nav a:focus-visible { outline-offset: -2px; }
.badge {
  margin-left: auto; background: var(--void); color: var(--amber);
  font-family: var(--mono); font-size: 10px; padding: 0 6px; border-radius: var(--cap); line-height: 16px;
}

.rail-sessions { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: 16px; }
.rail-label {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 11px; color: rgba(20, 22, 26, 0.5); padding: 4px 22px;
}
.session-nav { overflow-y: auto; display: flex; flex-direction: column; }
.session-nav .sn-group {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em;
  color: rgba(20, 22, 26, 0.5); padding: 8px 22px 3px; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 22px; color: rgba(20, 22, 26, 0.78); font-size: 13px; overflow: hidden;
}
.session-nav a:hover { background: rgba(20, 22, 26, 0.1); color: #14161a; }
.session-nav a.active { background: rgba(20, 22, 26, 0.16); color: #14161a; font-weight: 500; }
.session-nav a .sn-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sn-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(20,22,26,0.45); flex: none; }
.sn-dot.running { background: var(--amber); }
.sn-dot.idle { background: #2f7d4f; }
.sn-dot.failed { background: var(--red); }
.session-nav .empty-note { padding: 6px 22px; color: rgba(20,22,26,0.55); }

@media (min-width: 821px) {
  /* The command train owns session creation on desktop; keeping a second button
     here interrupts the elbow and competes with the structural rail. */
  .new-session { display: none; }
  .rail-nav { margin-top: 188px; }
}

/* ---------------------------------------------------------------- register */
/* Continue the sidebar's top bridge, then finish it with the quiet end cap. */
.register {
  grid-column: 2; grid-row: 1;
  display: flex; align-items: stretch; gap: 3px;
  margin-left: 0;
}
.reg-identity {
  display: flex;
  flex: 1 1 580px;
  align-items: center;
  gap: clamp(24px, 4vw, 76px);
  max-width: 630px;
  min-width: 270px;
  background: var(--structure);
  color: #14161a;
  padding: 0 40px;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.reg-identity b {
  color: var(--cyan);
  font-size: 14px;
  font-weight: 600;
}
.reg-ctx {
  flex: 1; min-width: 0;
  background: var(--structure);
  border-radius: 0;
  display: flex; flex-direction: row-reverse; align-items: center; gap: 8px;
  padding: 0 24px 0 28px; overflow: hidden;
}
.reg-mark {
  display: flex;
  flex: 0 0 156px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 0 var(--cap) var(--cap) 0;
  background: var(--structure);
  color: #14161a;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.reg-mark img {
  width: 31px;
  height: 31px;
  object-fit: contain;
  filter: grayscale(1) brightness(0.18);
}
.ctx-label {
  margin-right: auto;   /* row-reverse: pushes the label to the far left */
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 14px; font-weight: 700; color: #14161a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.ctx-sub {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(20, 22, 26, 0.62); white-space: nowrap;
}
.ctx-btn {
  flex: none; background: var(--void); color: var(--ink-hi);
  border: 0; border-radius: var(--cap); cursor: pointer;
  padding: 7px 16px; font-family: var(--display); font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  transition: background 120ms;
}
.ctx-btn:hover { background: #1f2224; }
.ctx-btn.is-primary { color: var(--amber); }
.ctx-tab {
  flex: none; background: none; border: 0; cursor: pointer;
  padding: 7px 4px; font-family: var(--display); text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 12px; color: rgba(20, 22, 26, 0.55);
}
.ctx-tab:hover { color: #14161a; }
.ctx-tab.active { color: #14161a; border-bottom: 2px solid var(--void); }

/* ---------------------------------------------------------------- main field */
.main { grid-column: 2; grid-row: 2; position: relative; min-height: 0; }
.view { position: absolute; inset: 22px 6px 24px 30px; }
.panel { overflow-y: auto; padding: 16px 0 24px; }
.panel > * { max-width: 1080px; }

.kicker { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; color: var(--blue); }
.panel > h1 { font-size: clamp(28px, 3.4vw, 40px); text-transform: uppercase; margin: 6px 0 8px; }
.lede { color: var(--ink-mid); max-width: 62ch; margin-bottom: 26px; }
.meta { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); text-transform: none; letter-spacing: 0; font-weight: 400; }

.region-head {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 14px; color: var(--ink-mid);
  padding-bottom: 10px; border-bottom: 1px solid var(--rule); margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}

/* ---------------------------------------------------------------- overview */
.ov-top {
  display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 30px;
  padding-bottom: 34px; border-bottom: 1px solid var(--rule); margin-bottom: 32px;
}
.ov-situation .kicker { color: var(--blue); }
#situationHeadline {
  font-size: clamp(40px, 6vw, 76px); line-height: 0.95; text-transform: uppercase;
  margin: 10px 0 12px; font-weight: 700; overflow-wrap: anywhere;
}
.ov-sub { color: var(--ink-mid); font-size: 16px; margin-bottom: 24px; }

.command-train { display: inline-flex; align-items: stretch; }
.seg {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; font-size: 15px;
  background: var(--structure); color: var(--void);
  padding: 12px 26px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 3px; transition: background 120ms, color 120ms;
}
.seg:hover { background: #7b858c; }
.seg-a { border-radius: var(--cap) 0 0 var(--cap); padding-left: 30px; }
.seg-z { border-radius: 0 var(--cap) var(--cap) 0; margin-right: 0; padding-right: 30px; }
.seg.is-primary { background: var(--amber); }
.seg.is-primary:hover { background: #ffd766; }
.seg:disabled { opacity: 0.45; cursor: not-allowed; }

.ov-tally { display: flex; flex-direction: column; border-left: 1px solid var(--rule); padding-left: 22px; }
.tally-row { padding: 11px 0; border-bottom: 1px solid var(--rule); display: block; }
.tally-row:first-child { padding-top: 0; }
.tally-row:last-child { border-bottom: 0; }
.tally-row b { font-family: var(--display); font-weight: 700; font-size: 42px; line-height: 1; display: block; color: var(--ink-mid); }
.tally-row span { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--ink-lo); }
.tally-row.is-hot b { color: var(--amber); }
.tally-row.is-fault b { color: var(--red); }

.ov-regions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px; }

/* instrument field — thin-line technical widgets bound to real values */
.inst-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(234px, 1fr));
  gap: 32px 32px; margin-top: 4px;
}
.inst { display: flex; flex-direction: column; gap: 9px; color: var(--ink-mid); }
a.inst { cursor: pointer; }
a.inst:hover .inst-label { color: var(--ink-hi); }
.inst--wide { grid-column: span 2; }
@media (max-width: 900px) { .inst--wide { grid-column: span 1; } }

.inst-label {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.13em;
  font-size: 11px; color: var(--ink-mid);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.inst-label span { color: var(--ink-lo); font-family: var(--mono); letter-spacing: 0.03em; font-size: 10px; }

.inst-fig { height: 44px; display: flex; align-items: center; }
.inst-fig .fig { max-width: 100%; max-height: 44px; overflow: visible; }
.inst-fig .fig * { stroke: var(--structure); stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
.inst-fig .fig .fill { fill: var(--structure); stroke: none; }
.inst-fig .fig .track { stroke: none; fill: var(--rule); }
.inst-fig .fig .ok { fill: var(--green); stroke: none; }
.inst-fig .fig .fault { fill: var(--red); stroke: none; }
.inst-fig .fig .nfault { stroke: var(--red); fill: rgba(240, 91, 91, 0.16); }
.inst-fig .fig .figtext { fill: var(--ink-lo); font-family: var(--mono); font-size: 9px; stroke: none; letter-spacing: 0.1em; }
/* figures stay monochrome — color lives in the readout text (GISP: color by exception).
   is-fault only reddens line figures (signal/geometry), never node grids or bars. */
.inst-fig.is-fault .fig polyline,
.inst-fig.is-fault .fig path { stroke: var(--red); }
.inst-fig.barcode { height: 32px; }
.inst-fig.barcode .fig { width: 100%; height: 30px; }

.inst-readout {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.55;
  color: var(--ink-lo); display: flex; flex-direction: column; gap: 1px;
  letter-spacing: 0.02em;
}
.inst-readout .hot { color: var(--amber); }
.inst-readout .live { color: var(--cyan); }
.inst-readout .fault { color: var(--red); }

.inst-list { display: flex; flex-direction: column; }
.il-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 11px;
}
.il-row:last-child { border-bottom: 0; }
.il-t { color: var(--ink-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.il-s { color: var(--ink-lo); text-transform: uppercase; letter-spacing: 0.04em; }
.il-s.live { color: var(--cyan); } .il-s.run { color: var(--cyan); }
.il-s.fault { color: var(--red); } .il-s.warn { color: var(--amber); } .il-s.ok { color: var(--green); }
.il-empty { color: var(--ink-lo); font-family: var(--mono); font-size: 11px; padding: 8px 0; }
@media (max-width: 1040px) { .ov-regions { grid-template-columns: 1fr; gap: 26px; } .ov-top { grid-template-columns: 1fr; } .ov-tally { flex-direction: row; gap: 22px; border-left: 0; border-top: 1px solid var(--rule); padding: 12px 0 0; } .tally-row { border-bottom: 0; padding: 0; } }

/* system path — real topology, no decorative nodes */
.sys-path { display: flex; flex-direction: column; }
.sp-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 0; }
.sp-rail { position: relative; }
.sp-rail::before { content: ""; position: absolute; left: 6px; top: -9px; bottom: -9px; width: 1px; background: var(--rule); }
.sp-row:first-child .sp-rail::before { top: 9px; }
.sp-row:last-child .sp-rail::before { bottom: auto; height: 18px; }
.sp-node { width: 7px; height: 7px; border: 1px solid var(--structure); border-radius: 2px; background: var(--void); position: relative; z-index: 1; margin-top: 5px; }
.sp-node.is-live { border-color: var(--cyan); background: rgba(53,208,197,0.16); }
.sp-node.is-fault { border-color: var(--red); background: rgba(240,91,91,0.16); }
.sp-label { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; color: var(--ink-hi); }
.sp-val { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.sp-val.is-fault { color: var(--red); }

/* ledger — alignment, not boxes */
.ledger { display: flex; flex-direction: column; }
.ledger-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--rule);
}
.ledger-row:last-child { border-bottom: 0; }
.l-title { color: var(--ink-hi); }
.l-sub { grid-column: 1; font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.l-state { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-mid); }
.l-state.is-run { color: var(--cyan); }
.l-state.is-ok { color: var(--green); }
.l-state.is-warn { color: var(--amber); }
.l-state.is-fault { color: var(--red); }
.l-state.is-idle { color: var(--ink-lo); }

.attn-row { display: grid; grid-template-columns: 3px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.attn-row:last-child { border-bottom: 0; }
.attn-bar { background: var(--amber); border-radius: 2px; }
.attn-row.is-fault .attn-bar { background: var(--red); }
.attn-title { color: var(--ink-hi); }
.attn-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.attn-action { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--amber); align-self: center; }
.attn-row.is-fault .attn-action { color: var(--red); }

.empty-note { color: var(--ink-lo); font-family: var(--mono); font-size: 12px; padding: 12px 0; }

.resource-empty {
  grid-column: 1 / -1;
  width: min(640px, 100%);
  max-width: 640px;
  margin-top: 8vh;
  border-left: 3px solid var(--cyan);
  background: var(--void-1);
  padding: 24px 26px 26px;
}
.resource-empty .kicker { color: var(--cyan); }
.resource-empty h2 {
  margin: 5px 0 10px;
  font-size: 30px;
  text-transform: uppercase;
}
.resource-empty > p:not(.kicker) { color: var(--ink-mid); max-width: 62ch; }
.resource-empty-install {
  margin-top: 22px;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}
.resource-empty-install strong {
  display: block;
  color: var(--ink-hi);
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.resource-empty-install pre {
  margin: 11px 0 10px;
  overflow-x: auto;
  background: var(--void);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--amber);
  padding: 12px 14px;
}
.resource-empty-install pre code { border: 0; background: none; padding: 0; color: var(--ink-hi); }
.resource-empty-install small { color: var(--ink-lo); font-family: var(--mono); font-size: 11px; line-height: 1.55; }
.pool-os-tabs { display: flex; gap: 4px; margin-top: 12px; }
.pool-os-tab {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-mid); background: var(--void); border: 1px solid var(--rule);
  padding: 5px 12px; cursor: pointer;
}
.pool-os-tab.active { color: var(--void); background: var(--cyan); border-color: var(--cyan); }
.pool-os-panel small { display: block; margin-top: 10px; }

.agent-section {
  max-width: 640px;
  margin-top: 8vh;
  border-left: 3px solid var(--amber);
  background: var(--void-1);
  padding: 24px 26px 26px;
}
.agent-section .kicker { color: var(--amber); }
.agent-section h2 { margin: 5px 0 10px; font-size: 30px; text-transform: uppercase; }
.agent-section > p:not(.kicker) { color: var(--ink-mid); max-width: 60ch; }
.agent-empty-setup { margin-top: 22px; border-top: 1px solid var(--rule); padding-top: 16px; }
.agent-empty-setup pre {
  margin: 0 0 10px;
  background: var(--void);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--amber);
  padding: 12px 14px;
}
.agent-empty-setup pre code { border: 0; background: none; padding: 0; color: var(--ink-hi); }
.agent-empty-setup small { display: block; color: var(--ink-lo); font-family: var(--mono); font-size: 11px; line-height: 1.55; }
.agent-empty-setup button {
  margin-top: 16px;
  background: var(--amber);
  border: 0;
  border-radius: var(--cap);
  color: var(--void);
  cursor: pointer;
  padding: 8px 15px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.agent-empty-setup button:hover { background: #ffd766; }
.cloud-agent-section { margin-top: 28px; max-width: 860px; }
.cloud-agent-section .kicker { color: var(--cyan); }
.agent-config-list { margin-top: 18px; border-top: 1px solid var(--rule); }
.agent-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }
.agent-form label { display: grid; gap: 6px; color: var(--ink-lo); font: 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.agent-form input, .agent-form select { min-width: 0; padding: 9px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--void); color: var(--ink-hi); font: 12px var(--mono); }
.agent-form button { justify-self: start; align-self: end; background: var(--cyan); color: var(--void); border: 0; border-radius: var(--cap); padding: 9px 15px; cursor: pointer; font: 700 12px var(--display); letter-spacing: .07em; text-transform: uppercase; }
.agent-feedback { align-self: end; color: var(--ink-lo); font: 11px var(--mono); }
@media (max-width: 620px) { .agent-form { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- setup flow */
.setup-flow { padding: 2px 0 28px; margin-bottom: 26px; border-bottom: 1px solid var(--rule); }
.setup-flow-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.setup-flow h1 { margin: 0; font-size: clamp(28px, 3.4vw, 40px); text-transform: uppercase; }
.setup-refresh, .setup-command, .setup-link {
  border: 0; background: transparent; color: var(--cyan); cursor: pointer; padding: 0;
  font-family: var(--display); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.setup-command::before { content: "$ "; color: var(--ink-lo); }
.setup-link { color: var(--amber); }
.setup-refresh:hover, .setup-command:hover, .setup-link:hover { color: var(--ink-hi); }
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-step { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; padding: 20px 0; border-top: 1px solid var(--rule); }
.setup-number { color: var(--ink-lo); font-family: var(--mono); font-size: 11px; padding-top: 4px; }
.setup-step h2 { margin: 0 0 5px; font-size: 20px; text-transform: uppercase; }
.setup-step p { margin: 0; color: var(--ink-mid); font-size: 13px; line-height: 1.5; max-width: 68ch; }
.setup-state { display: inline-flex; align-items: center; gap: 6px; align-self: start; padding-top: 5px; color: var(--ink-lo); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.setup-state i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-lo); }
.setup-state.is-ready { color: var(--cyan); }.setup-state.is-ready i { background: var(--cyan); }
.setup-state.is-warn { color: var(--amber); }.setup-state.is-warn i { background: var(--amber); }
.setup-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.setup-providers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; margin-top: 18px; }
.setup-provider { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--rule); }
.setup-provider strong { font-family: var(--display); font-size: 16px; letter-spacing: .03em; text-transform: uppercase; }
.setup-provider .setup-command { grid-column: 1 / -1; font-size: 11px; }

/* ---------------------------------------------------------------- scheduled tasks */
.btn-pair { display: inline-flex; gap: 8px; }

.sched-row {
  display: grid; grid-template-columns: 18px 1fr auto auto; gap: 14px; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--rule);
}
.sched-row:last-child { border-bottom: 0; }
.sched-icon {
  width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 9px; border: 1px solid var(--ink-lo); border-radius: 50%; color: var(--ink-lo);
}
.sched-icon.is-active { border-color: var(--cyan); color: var(--cyan); }
.sched-icon.is-paused { border-color: var(--amber); color: var(--amber); font-size: 7px; letter-spacing: -1px; }
.sched-icon.is-done { border-color: var(--green); color: var(--green); }
.sched-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched-title { font-family: var(--display); font-size: 16px; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-cad { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.sched-row button { background: none; border: 1px solid var(--rule); color: var(--ink-mid); padding: 5px 12px; border-radius: var(--r); font-family: var(--display); text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; cursor: pointer; }
.sched-row button:hover { color: var(--ink-hi); border-color: var(--ink-lo); }

.sched-suggest { margin-top: 40px; }
.suggest-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; text-align: left;
  width: 100%; background: none; border: 0; border-bottom: 1px solid var(--rule);
  padding: 13px 0; cursor: pointer;
}
.suggest-row:last-child { border-bottom: 0; }
.suggest-row:hover .suggest-title { color: var(--amber); }
.suggest-title { font-family: var(--display); font-size: 15px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-hi); }
.suggest-cad { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); align-self: center; }
.suggest-desc { grid-column: 1 / -1; color: var(--ink-mid); font-size: 13px; }

/* ---------------------------------------------------------------- session / chat */
#view-session { display: flex; flex-direction: column; overflow: hidden; }
.session-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 8px 8px 2px; }
.session-empty { max-width: 620px; margin: 8vh auto 0; text-align: center; }
.session-empty .kicker { color: var(--blue); }
.session-empty h1 { font-size: 34px; text-transform: uppercase; margin: 8px 0 12px; }
.session-empty p { color: var(--ink-mid); }
body[data-mode="session"] .session-empty { display: none; }

.transcript { max-width: 740px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-top: 12px; }
.msg { font-size: 14px; line-height: 1.6; }
.msg.user {
  align-self: flex-end; max-width: 85%;
  background: var(--void-2); border: 1px solid var(--rule);
  border-radius: 12px; padding: 10px 14px; white-space: pre-wrap;
}
.msg.agent { align-self: stretch; white-space: pre-wrap; }
.msg.agent.error { color: var(--red); }
.msg.tool { align-self: stretch; font-family: var(--mono); font-size: 12px; color: var(--ink-lo); border-left: 2px solid var(--rule); padding-left: 10px; }

.composer { flex: none; width: 100%; max-width: 760px; margin: 12px auto 4px; }
.composer > textarea {
  width: 100%; resize: none; max-height: 220px;
  background: var(--void-1); border: 1px solid var(--rule);
  border-radius: 12px 12px 0 0; border-bottom: 0; padding: 13px 16px; line-height: 1.5;
}
.composer > textarea:focus { outline: none; border-color: var(--structure); }
.composer-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--void-1); border: 1px solid var(--rule); border-top: 0;
  border-radius: 0 0 12px 12px; padding: 8px 8px 8px 12px;
}
.composer-opts { display: flex; gap: 8px; flex: 1; min-width: 0; }
body[data-mode="session"] .composer-opts { display: none; }
body[data-mode="session"] .composer-bar { justify-content: flex-end; }
.composer-opts select, .composer-opts input {
  background: var(--void-2); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 6px 10px; font-size: 12px; font-family: var(--mono); width: auto;
}
.composer-opts select { flex: none; }
.composer-opts input { flex: 1; min-width: 0; }
#composerSend {
  flex: none; background: var(--amber); color: var(--void); border: 0;
  padding: 9px 22px; border-radius: var(--cap); cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
#composerSend:hover { background: #ffd766; }
#composerSend:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms / panels */
.block { padding: 0 0 26px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.block:last-of-type { border-bottom: 0; }
textarea, input[type="text"], select {
  background: var(--void-1); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 9px 12px; color: var(--ink-hi); font-family: var(--sans); width: 100%;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--structure); }
.block textarea { resize: vertical; min-height: 70px; }
select { font-family: var(--mono); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.row > input[type="text"] { flex: 1; min-width: 180px; width: auto; }
.row > select { width: auto; min-width: 130px; }
.row.spread { justify-content: space-between; }
.check { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--ink-mid); }
.check input { width: auto; }
.search-bar { display: flex; gap: 8px; margin-bottom: 18px; }
.search-bar input { flex: 1; }
.meter { text-align: right; font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.meter strong { display: block; color: var(--cyan); font-size: 14px; }
.account-row { display: flex; align-items: center; gap: 14px; }
.account-row > div { flex: 1; }
.auth-avatar { width: 34px; height: 34px; border-radius: var(--r); }

/* cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.card { background: var(--void); padding: 15px; }
.card .topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.card h3 { font-size: 15px; text-transform: uppercase; }
.card p { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 10px 0 0; font-family: var(--mono); font-size: 11px; }
.card dt { color: var(--ink-lo); text-transform: uppercase; }
.card dd { margin: 0; color: var(--ink-mid); }
.mesh-search { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.mesh-search input { flex: 1 1 120px; font-family: var(--mono); font-size: 11px; padding: 4px 6px; }
.mesh-status { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.mesh-output { margin: 6px 0 0; padding: 8px; max-height: 260px; overflow: auto; background: var(--rule); font-family: var(--mono); font-size: 11px; white-space: pre-wrap; }
#termLog { min-height: 220px; max-height: 55vh; }
#view-terminal .row label, #view-projects #projKindRow label { font-size: 12px; color: var(--ink-mid); display: inline-flex; align-items: center; gap: 4px; }
#projDetail .region-head { margin-top: 4px; }
.gh-browse { margin-top: 10px; font-family: var(--mono); font-size: 11px; padding: 4px 8px; }
.gh-repo, .gh-text { width: 100%; font-family: var(--mono); font-size: 11px; margin: 6px 0; }
.gh-repo { padding: 4px 6px; }
.gh-crumb { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); word-break: break-all; }
.gh-list { display: flex; flex-direction: column; max-height: 240px; overflow: auto; }
.gh-entry { text-align: left; font-family: var(--mono); font-size: 11px; padding: 4px 6px; background: none; border: 0; color: var(--ink-mid); cursor: pointer; }
.gh-entry:hover { background: var(--rule); }
.gh-text { min-height: 200px; }
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-size: 21px;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 20;
}

.row-card { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.row-card:last-child { border-bottom: 0; }
.row-card .title { font-family: var(--display); font-size: 16px; }
.row-card .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }
.row-card pre { grid-column: 1 / -1; margin: 8px 0 0; padding: 10px; background: var(--void-1); border-left: 2px solid var(--rule); font-family: var(--mono); font-size: 11px; color: var(--ink-mid); overflow-x: auto; white-space: pre-wrap; }
.row-card button { background: var(--amber); color: var(--void); border: 0; padding: 6px 14px; border-radius: var(--r); font-family: var(--display); text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; cursor: pointer; }
.row-card button.quiet { background: none; border: 1px solid var(--rule); color: var(--ink-mid); }

.tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border: 1px solid var(--rule); border-radius: var(--cap); color: var(--ink-mid); white-space: nowrap; }
.tag.green { color: var(--green); border-color: rgba(104,211,145,0.35); }
.tag.yellow { color: var(--amber); border-color: rgba(245,200,75,0.35); }
.tag.red { color: var(--red); border-color: rgba(240,91,91,0.35); }
.tag.gray { color: var(--ink-lo); }

/* ---------------------------------------------------------------- documents */
#view-docs { overflow: hidden; }
.docs { height: 100%; }

.docs-browser { display: flex; flex-direction: column; gap: 10px; padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--rule); }
#docSearch { align-self: flex-start; width: min(360px, 100%); font-size: 12px; padding: 7px 10px; }

.doc-tree { min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1px 12px; }
.doc-tree .empty-note { grid-column: 1 / -1; }
.doc-folder {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 11px; color: var(--ink-lo); padding: 12px 4px 4px;
}
.doc-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: none; border: 0; border-radius: var(--r); padding: 8px 10px; cursor: pointer; width: 100%;
}
.doc-item:hover { background: var(--void-1); }
.doc-item.active { background: var(--void-2); }
.doc-item-title { font-family: var(--display); font-size: 14px; letter-spacing: 0.01em; color: var(--ink-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-lo); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.docs-main { min-width: 0; overflow-y: auto; }
.doc-empty { max-width: 52ch; margin-top: 6vh; }
.doc-empty .kicker { color: var(--blue); }
.doc-empty h1 { font-size: 30px; text-transform: uppercase; margin: 6px 0 10px; }
.doc-empty p { color: var(--ink-mid); }

.doc-view { display: flex; flex-direction: column; gap: 14px; }
.doc-view-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.doc-title-input {
  flex: 1; min-width: 0; background: none; border: 0; padding: 0;
  font-family: var(--display); font-weight: 600; font-size: 26px; text-transform: uppercase; letter-spacing: 0.01em;
}
.doc-title-input:focus { outline: none; color: var(--amber); }
.doc-view-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.doc-view-tools select { width: auto; min-width: 120px; font-size: 12px; padding: 5px 8px; }
.doc-view-tools button {
  background: none; border: 1px solid var(--rule); color: var(--ink-mid);
  padding: 6px 12px; border-radius: var(--r); cursor: pointer;
  font-family: var(--display); text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em;
}
.doc-view-tools button:hover { color: var(--ink-hi); border-color: var(--ink-lo); }
.doc-view-tools button.is-primary { background: var(--amber); color: var(--void); border-color: var(--amber); }
.doc-view-tools button.quiet { color: var(--ink-lo); }

.doc-editor {
  min-height: 52vh; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.65;
  background: var(--void-1); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px;
}
.doc-editor:focus { outline: none; border-color: var(--structure); }
.doc-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-lo); }

/* rendered markdown */
.md { color: var(--ink-hi); line-height: 1.65; max-width: 76ch; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.02em; margin: 1.4em 0 0.5em; }
.md h1 { font-size: 26px; } .md h2 { font-size: 21px; } .md h3 { font-size: 17px; } .md h4 { font-size: 15px; color: var(--ink-mid); }
.md p { margin: 0 0 1em; }
.md a { color: var(--cyan); text-decoration: underline; text-underline-offset: 2px; }
.md ul, .md ol { margin: 0 0 1em; padding-left: 1.4em; }
.md li { margin: 0.2em 0; }
.md code { background: var(--void-1); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; font-size: 0.88em; color: var(--ink-mid); }
.md pre { background: var(--void-1); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px; overflow-x: auto; margin: 0 0 1em; }
.md pre code { background: none; border: 0; padding: 0; color: var(--ink-mid); }
.md blockquote { border-left: 2px solid var(--structure); padding-left: 14px; margin: 0 0 1em; color: var(--ink-mid); }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 1.6em 0; }
.md img { max-width: 100%; border-radius: var(--r); }

@media (max-width: 720px) {
  .doc-tree { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 52px auto 1fr; padding: 12px; gap: 10px; }
  .rail {
    grid-row: 2; grid-column: 1; flex-direction: row; flex-wrap: wrap;
    background: var(--structure);
    border-radius: 20px;
    padding: 8px;
    gap: 4px;
    align-items: center;
    overflow: hidden;
  }
  .rail::before, .rail::after { display: none; }
  .rail-brand, .rail-label, .rail-sessions { display: none; }
  .new-session { margin: 0; }
  .rail-nav { flex-direction: row; flex-wrap: wrap; }
  .rail-nav a { padding: 6px 10px; }
  .register { grid-row: 1; grid-column: 1; gap: 14px; margin-left: 0; }
  .reg-identity, .reg-mark { display: none; }
  .reg-ctx { border-radius: var(--cap); }
  .view { inset: 16px 4px 20px 4px; }
  .main { grid-row: 3; grid-column: 1; }
  .setup-step { grid-template-columns: 32px minmax(0, 1fr); }
  .setup-step > .setup-state { grid-column: 2; }
}

@media (max-width: 460px) {
  .setup-providers { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* --- Agent skills --- */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 20px; }
.skill-card { display: block; }
.skill-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.skill-toggle { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; white-space: nowrap; }
.skill-note { margin: 4px 0 6px; font-size: 12px; color: var(--ink-mid); }
.skill-subhead { font-family: var(--display); font-size: 13px; letter-spacing: .05em; text-transform: uppercase; margin: 20px 0 8px; }
.skill-remove { background: none; border: 0; color: var(--ink-mid); font-size: 11px; cursor: pointer; padding: 2px 0; text-decoration: underline; }
.skill-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; border-top: 1px solid var(--rule); padding-top: 12px; }
.skill-add input { flex: 1 1 180px; background: var(--void); color: var(--ink-hi); border: 1px solid var(--rule); padding: 8px 10px; font: inherit; }
.skill-add button { background: var(--amber); color: var(--void); border: 0; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.skill-add span { color: #f08a7a; font-size: 12px; }
