/* Both faces are preloaded by every page: they are on the first paint.
   Colour is state only: green live/ok, cyan in progress, amber waiting or
   offline, red failed. Everything else is greys on near-black. Type scale
   11/13/16 px, 96 px for codes. Motion only where something is happening. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #0a0c0e;
  --panel: #0f1215;
  --line: #1c2126;
  --line-hi: #2a3138;
  --ok: #7ee787;
  --prog: #79c0ff;
  --amber: #e3b341;
  --red: #f85149;
  --fg: #c9d1d9;
  --hi: #e6edf3;
  --dim: #7d8590;
  --faint: #484f58;
  --s: 11px;
  --m: 13px;
  --l: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--m)/1.55 "JetBrains Mono", ui-monospace, monospace;
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; overflow: hidden; }

::selection { background: #79c0ff40; }

button, input, textarea { font: inherit; color: inherit; }
a { color: var(--prog); text-decoration: none; }
code, kbd, pre { font-family: inherit; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 4px;
  border: 1px solid var(--line-hi);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--fg);
  font-size: var(--s);
  line-height: 1.5;
  text-align: center;
}

.dim { color: var(--dim); }
.small { font-size: var(--s); }

/* --- strips ------------------------------------------------------------ */

.strip {
  flex: none;
  height: 22px;
  padding: 0 16px;
  font-size: var(--s);
  line-height: 22px;
  letter-spacing: 0.04em;
}
.strip[hidden] { display: none; }
.strip-amber { background: #e3b3411a; color: var(--amber); border-bottom: 1px solid #e3b34155; }
.strip-inline { border-top: 1px solid #e3b34155; }
.ellipsis::after { content: "…"; animation: blink 1.2s steps(2) infinite; }

/* --- top bar ----------------------------------------------------------- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.crumb { font-size: var(--m); font-weight: 500; color: var(--hi); white-space: nowrap; }
.crumb .sep { margin: 0 8px; color: var(--faint); }
.tabs { display: flex; height: 100%; }
.tab {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--hi); border-bottom-color: var(--hi); }
.tab.soon { color: var(--faint); cursor: default; }
.tab sup { margin-left: 5px; font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }
.me { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--dim); }
.me[hidden] { display: none; }
.me form { margin: 0; }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.link:hover, .link:focus-visible { color: var(--hi); outline: none; }

/* --- shell ------------------------------------------------------------- */

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
}
.shell.signed-out { grid-template-columns: 1fr; }

.canvas {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.view { flex: 1; padding: 28px 32px; }
.keys {
  flex: none;
  display: flex;
  gap: 22px;
  padding: 10px 32px 14px;
  color: var(--dim);
  font-size: var(--s);
}
.keys[hidden] { display: none; }
.keys kbd { margin-right: 3px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.label {
  color: var(--hi);
  font-weight: 500;
  font-size: var(--s);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.count { color: var(--dim); font-size: var(--s); }
.iso-link { margin-left: auto; font-size: var(--s); }

/* --- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  background: var(--panel);
  color: var(--hi);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover, .btn:focus-visible { border-color: var(--dim); outline: none; }
.btn-primary { border-color: var(--ok); color: var(--ok); background: #7ee78712; }
.btn-primary:hover, .btn-primary:focus-visible { background: #7ee78724; border-color: var(--ok); }
.btn[disabled] { border-color: var(--line); color: var(--faint); background: transparent; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn-ghost:hover, .btn-ghost:focus-visible { color: var(--hi); border-color: var(--line-hi); }
.btn-small { height: 26px; padding: 0 10px; font-size: var(--s); }
.btn-danger { border-color: #f8514980; color: var(--red); background: #f8514912; }
.btn-danger:hover, .btn-danger:focus-visible { border-color: var(--red); background: #f8514922; }

/* --- fleet ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.adopt-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 188px;
  border: 1px dashed var(--line-hi);
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}
.adopt-tile .plus { font-size: 28px; line-height: 1; font-weight: 400; }
.adopt-tile:hover, .adopt-tile:focus-visible { color: var(--hi); border-color: var(--dim); outline: none; }
.adopt-tile-big { width: 420px; min-height: 220px; font-size: var(--l); }
.adopt-tile-big .plus { font-size: 40px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding-top: 9vh;
}
.empty-actions { display: flex; gap: 12px; }
.steps { display: flex; gap: 28px; margin: 6px 0 0; color: var(--dim); font-size: var(--s); }
.steps b { color: var(--hi); font-weight: 500; }

.card {
  position: relative;
  min-height: 188px;
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--line-hi); }
.card:focus-visible { border-color: var(--dim); }
.card.selected { outline: 1px solid var(--dim); outline-offset: 3px; }
.card.selected::after {
  content: "agent scope";
  position: absolute;
  top: -11px;
  right: 12px;
  padding: 0 6px;
  background: var(--bg);
  color: var(--hi);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-installing { border: 1px dashed #79c0ff80; background: #79c0ff06; }
.card-installing:hover { border-color: var(--prog); }
.card-failed { border-color: #f8514980; }
.card-offline { border-color: #e3b34160; }

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head .name { color: var(--hi); font-size: var(--l); font-weight: 500; }
.card-head .state { margin-left: auto; font-size: var(--s); color: var(--dim); }
.card-installing .state { color: var(--prog); }
.card-failed .state { color: var(--red); }
.card-offline .state { color: var(--amber); }
.card-solid:not(.card-offline) .state { color: var(--ok); }

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.dot-ok { background: var(--ok); box-shadow: 0 0 0 0 #7ee78780; animation: pulse 2.4s ease-out infinite; }
.dot-progress { background: var(--prog); box-shadow: 0 0 0 0 #79c0ff80; animation: pulse-prog 1.4s ease-out infinite; }
.dot-warn { background: var(--amber); }
.dot-fail { background: var(--red); }
.dot-idle { background: var(--faint); }

.phase-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.phase { color: var(--prog); }
.pct { color: var(--hi); font-size: var(--l); font-weight: 500; font-variant-numeric: tabular-nums; }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--prog); transition: width 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); }

.phases {
  display: flex;
  gap: 0;
  margin: 10px 0 12px;
  padding: 0;
  list-style: none;
  font-size: 10px;
  color: var(--faint);
}
.phases li { flex: 1; padding-top: 5px; border-top: 2px solid var(--line); text-align: center; }
.phases li + li { margin-left: 3px; }
.phases li.done { color: var(--dim); border-top-color: #79c0ff60; }
.phases li.current { color: var(--prog); border-top-color: var(--prog); }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: var(--s);
  color: var(--dim);
}
.log-toggle { font-size: var(--s); }

.card-log {
  margin: 10px 0 0;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: var(--s);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: 64px 1fr;
  row-gap: 3px;
  margin: 0;
  font-size: var(--m);
}
.facts dt { color: var(--dim); }
.facts dd { margin: 0; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.error { margin: 0 0 6px; color: var(--red); }
.last-line {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: var(--s);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-note { margin: 8px 0 0; color: var(--amber); font-size: var(--s); }

/* --- adopt ------------------------------------------------------------- */

.adopt { max-width: 760px; }
.back { margin-right: 4px; }
.lead { margin: 0 0 22px; color: var(--fg); font-size: var(--l); }

.code { display: flex; gap: 12px; }
.code-box {
  width: 84px;
  height: 124px;
  padding: 0;
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  background: var(--panel);
  color: var(--hi);
  caret-color: var(--ok);
  font-size: 96px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  outline: none;
  transition: border-color 0.12s;
}
.code-box:nth-child(3) { margin-right: 18px; }
.code-box:focus { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.code-box.filled { border-color: var(--dim); }
.code-meta { height: 22px; margin: 8px 0 26px; font-size: var(--s); color: var(--dim); }

.adopt-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.row { display: flex; align-items: center; gap: 16px; }
.key { width: 84px; flex: none; color: var(--dim); }
.field {
  width: 260px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  background: var(--panel);
  color: var(--hi);
  outline: none;
}
.field:focus { border-color: var(--dim); }
.field.invalid { border-color: var(--red); }
.field-err { color: var(--red); font-size: var(--s); }
.hw { display: flex; align-items: center; gap: 10px; min-height: 34px; flex-wrap: wrap; }
.hw .dot-ok { animation: none; }
.hw-line { color: var(--hi); }
.hw-cpu { color: var(--dim); font-size: var(--s); }
.status { min-height: 20px; margin: 0 0 0 100px; font-size: var(--s); }
.status-wait { color: var(--prog); }
.status-warn { color: var(--amber); }
.status-bad { color: var(--red); }
.actions { margin-left: 100px; gap: 8px; }

/* --- agent panel ------------------------------------------------------- */

.agent {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.agent[hidden] { display: none; }
.agent-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.agent-title { color: var(--hi); font-weight: 500; }
.scope { color: var(--dim); }
.scope.scoped { color: var(--hi); }
.scope-clear { font-size: var(--l); line-height: 1; }
.agent-state { margin-left: auto; color: var(--dim); font-size: var(--s); }

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-hi) transparent;
}
.log > * + * { margin-top: 12px; }
.intro { color: var(--dim); }
.intro p { margin: 0 0 8px; }

.msg { white-space: pre-wrap; word-wrap: break-word; }
.msg.user { display: flex; gap: 10px; color: var(--hi); }
.msg.user .who { flex: none; color: var(--ok); }
.msg.user .who::before { content: "› "; }
.msg.assistant { color: var(--fg); }
.msg code, .thinking code { color: var(--hi); background: var(--line); padding: 0 3px; border-radius: 2px; }
.md > * { margin: 0; }
.md > * + * { margin-top: 8px; }
.md strong, .md-h { color: var(--hi); font-weight: 600; }
.md ul, .md ol { padding-left: 20px; }
.md ul { list-style-type: "– "; }
.md li::marker { color: var(--dim); }
.md li + li { margin-top: 2px; }
.md pre {
  padding: 6px 10px;
  overflow-x: auto;
  white-space: pre;
  color: var(--hi);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-hi) transparent;
}
.md-url { color: var(--dim); }

/* The cursor trails the last block's text, not a line of its own below it. */
.streaming:empty::after,
.streaming > :last-child:not(ul, ol)::after,
.streaming > :is(ul, ol):last-child > li:last-child::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--fg);
  animation: blink 1s steps(2) infinite;
}

.thinking { color: var(--faint); font-size: var(--s); }
.thinking summary { cursor: pointer; list-style: none; color: var(--dim); }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "▸ "; }
.thinking[open] summary::before { content: "▾ "; }
.thinking-body { margin-top: 4px; padding-left: 12px; border-left: 1px solid var(--line); white-space: pre-wrap; color: var(--dim); }
.thinking-body.streaming::after, .thinking-body.streaming *::after { background: var(--dim); }

.tool {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}
.tool.running { border-color: #79c0ff70; }
.tool-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: var(--s);
}
.tool.running .tool-head { cursor: default; }
.tool-head:focus-visible { outline: 1px solid var(--dim); outline-offset: -1px; }
.sigil { color: var(--ok); flex: none; }
.cmd { flex: 1; min-width: 0; color: var(--hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool:not(.collapsed) .cmd { white-space: pre-wrap; overflow-wrap: anywhere; }
.exit { flex: none; font-variant-numeric: tabular-nums; }
.exit-running { color: var(--prog); }
.exit-running::before { content: "● "; animation: blink 1s steps(2) infinite; }
.exit-ok { color: var(--ok); }
.exit-fail { color: var(--red); }
.tool-out {
  margin: 0;
  padding: 2px 10px 8px 26px;
  max-height: 260px;
  overflow: auto;
  color: var(--fg);
  font-size: var(--s);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tool-out:empty { display: none; }
.tool.collapsed .tool-out { display: none; }
.tool.collapsed:not(.empty) .tool-head::after { content: "▸"; color: var(--dim); flex: none; }
.tool:not(.collapsed):not(.running) .tool-head::after { content: "▾"; color: var(--dim); flex: none; }

.line { font-size: var(--s); }
.line-err { color: var(--red); }
.line-err::before { content: "! "; }
.line-sys { color: var(--hi); }
.line-sys::before, .line-sys summary::before { content: "[platform] "; color: var(--dim); }
details.line-sys::before { content: none; }
.line-sys summary { cursor: pointer; list-style: none; }
.line-sys summary::-webkit-details-marker { display: none; }
.line-sys pre {
  margin: 6px 0 0;
  padding: 6px 8px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chips { flex: none; display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 16px 0; }
.chip {
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line-hi);
  border-radius: 12px;
  background: transparent;
  color: var(--dim);
  font-size: var(--s);
  cursor: pointer;
}
.chip:hover, .chip:focus-visible { color: var(--hi); border-color: var(--dim); outline: none; }

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 10px 16px 14px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  background: var(--bg);
}
.composer:focus-within { border-color: var(--dim); }
.caret { color: var(--ok); line-height: 22px; }
.composer textarea {
  flex: 1;
  min-height: 22px;
  max-height: 160px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--hi);
  line-height: 22px;
  resize: none;
  outline: none;
}
.composer textarea::placeholder { color: var(--faint); }
.send {
  flex: none;
  height: 22px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--dim);
  font-size: var(--s);
  cursor: pointer;
}
.send:hover { color: var(--hi); }
.stop { color: var(--red); }
.send[hidden] { display: none; }

/* --- signed out and notices -------------------------------------------- */

.signin, .notice main {
  max-width: 520px;
  margin: 16vh auto 0;
  padding: 0 24px;
}
.signin h1, .notice h1 { margin: 10px 0 12px; color: var(--hi); font-size: var(--l); font-weight: 500; }
.signin .btn { margin: 18px 0 14px; }
.notice { overflow: auto; }
.notice-head { color: var(--dim); font-size: var(--s); letter-spacing: 0.12em; text-transform: uppercase; }
.notice p { color: var(--fg); }

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #7ee78770; }
  70%, 100% { box-shadow: 0 0 0 7px #7ee78700; }
}
@keyframes pulse-prog {
  0% { box-shadow: 0 0 0 0 #79c0ff80; }
  70%, 100% { box-shadow: 0 0 0 6px #79c0ff00; }
}

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