/* SI Somewhere: an instrument panel. Two themes (theme.js sets
   html[data-theme]): Oscilloscope, phosphor green to cyan on near-black teal,
   and Ultraviolet, cyan to violet to crimson on plum black. Gradients carry
   meaning: a limit scale runs cool to hot, and the colour under its needle
   says how close you are. Red is kept for "needs you" and for the hot end. */

@property --amb-a { syntax: "<color>"; inherits: true; initial-value: #000; }
@property --amb-b { syntax: "<color>"; inherits: true; initial-value: #000; }

:root,
:root[data-theme="oscilloscope"] {
  color-scheme: dark;
  --bg: #03110f;
  --card: #061815;
  --card-hi: #0a221e;
  --track: #0d2a25;
  --text: #dcfff3;
  --dim: #7fb3a5;
  --faint: #4a7a6e;
  --line: #12352e;
  --ring: #1d5247;
  --good: #39ff9e;
  --needs: #ff2d55;
  --needs-soft: rgba(255, 45, 85, 0.22);
  --scale: linear-gradient(90deg, #39ff9e, #1fd3ff 55%, #4a5bff 85%, #ff2d55);
  --mark: linear-gradient(135deg, #39ff9e, #1fd3ff 55%, #4a5bff);
  --rim: linear-gradient(135deg, rgba(57, 255, 158, 0.55), rgba(31, 211, 255, 0.12) 45%, rgba(74, 91, 255, 0.4));
  --rim-hot: linear-gradient(135deg, #ff2d55, rgba(255, 45, 85, 0.25) 50%, #4a5bff);
  --button: linear-gradient(135deg, #39ff9e, #1fd3ff);
  --on-button: #022019;
}

:root[data-theme="ultraviolet"] {
  --bg: #12061c;
  --card: #1a0b27;
  --card-hi: #221033;
  --track: #2a1440;
  --text: #f6e9ff;
  --dim: #b39ac8;
  --faint: #7a5f92;
  --line: #2f1a45;
  --ring: #452868;
  --good: #3dff9a;
  --needs: #ff1f4b;
  --needs-soft: rgba(255, 31, 75, 0.24);
  --scale: linear-gradient(90deg, #2bd9ff, #a855ff 50%, #e23cff 75%, #ff1f4b);
  --mark: linear-gradient(135deg, #2bd9ff, #a855ff 55%, #e23cff);
  --rim: linear-gradient(135deg, rgba(168, 85, 255, 0.6), rgba(43, 217, 255, 0.12) 45%, rgba(226, 60, 255, 0.45));
  --rim-hot: linear-gradient(135deg, #ff1f4b, rgba(255, 31, 75, 0.25) 50%, #a855ff);
  --button: linear-gradient(135deg, #a855ff, #e23cff);
  --on-button: #1a0326;
}

/* The ambient light behind the panel drifts with the time of day (theme.js
   sets data-daypart). Barely there; it eases over two minutes. */
:root { --amb-a: #062a24; --amb-b: #04161f; transition: --amb-a 120s linear, --amb-b 120s linear; }
:root[data-daypart="morning"] { --amb-a: #0a3a2a; --amb-b: #062530; }
:root[data-daypart="day"] { --amb-a: #07363a; --amb-b: #0a2238; }
:root[data-daypart="evening"] { --amb-a: #0b2a3f; --amb-b: #14183f; }
:root[data-daypart="night"] { --amb-a: #062a24; --amb-b: #04161f; }
:root[data-theme="ultraviolet"] { --amb-a: #2a0d40; --amb-b: #160a33; }
:root[data-theme="ultraviolet"][data-daypart="morning"] { --amb-a: #1d1450; --amb-b: #0c1a3c; }
:root[data-theme="ultraviolet"][data-daypart="day"] { --amb-a: #241052; --amb-b: #0d1e44; }
:root[data-theme="ultraviolet"][data-daypart="evening"] { --amb-a: #3a0c46; --amb-b: #210a3a; }

/* Providers keep their identity as accents only; none of them orange. */
.p-claude { --pc: #ff5c8a; }
.p-codex { --pc: #10e0a0; }
.p-gemini { --pc: #6f9bff; }
.p-grok { --pc: #e9e6ff; }

:root {
  --radius: 12px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "DM Sans", ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 700px at 12% -10%, var(--amb-a), transparent 70%),
    radial-gradient(1000px 800px at 100% 110%, var(--amb-b), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.4 var(--sans);
  min-height: 100vh;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Gradient ink for the clock. */
.clock, .ink {
  background: var(--mark);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* The tachometer mark (brand/mark.svg). */
.mark { display: block; width: 34px; height: 34px; }
.home { display: block; line-height: 0; }

/* A card is an instrument: dark face, a 1px gradient rim like light on a bezel. */
.bezel {
  border: 1px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box, var(--rim) border-box;
  border-radius: var(--radius);
}
.bezel.hot { background: linear-gradient(var(--card-hi), var(--card-hi)) padding-box, var(--rim-hot) border-box; }
.engraved { font: 500 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }

/* Header */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  max-width: 1120px; margin: 0 auto; padding: 20px 0 12px;
}
.clock { font: 400 clamp(34px, 6vw, 52px)/1 var(--serif); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.who { justify-self: end; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--dim); }
.who form { margin: 0; }
.link { background: none; border: 0; padding: 4px 0; color: var(--dim); cursor: pointer; text-decoration: none; }
.link:hover { color: var(--text); }
/* The gear menu: theme, alerts, devices, sign out. */
.settings { position: relative; }
.gear {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: none; border: 1px solid transparent; color: var(--dim); cursor: pointer;
}
.gear:hover, .gear[aria-expanded="true"] { color: var(--text); border-color: var(--line); background: var(--card); }
.gear:focus-visible, .menu .item:focus-visible { outline: 2px solid var(--dim); outline-offset: 2px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 220px; padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.menu-label { margin: 6px 8px 4px; }
.menu-rule { height: 1px; background: var(--line); margin: 8px 4px; }
.menu form { margin: 0; }
.menu .item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border-radius: 8px;
  background: none; border: 0; color: var(--text); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu .item:hover { background: var(--card-hi); }
.menu [role="radio"]::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--faint); }
.menu [role="radio"][aria-checked="true"]::after { background: var(--good); border-color: var(--good); box-shadow: 0 0 6px var(--good); }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.swatch-osc { background: linear-gradient(135deg, #39ff9e, #1fd3ff 55%, #4a5bff); }
.swatch-uv { background: linear-gradient(135deg, #2bd9ff, #a855ff 55%, #e23cff); }
.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint); margin-right: 6px; vertical-align: 1px;
}
.live.on::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.live.off::before { background: var(--needs); }

/* Narrow screens: one screen at a time, like paging the board. */
.tabs { display: flex; gap: 6px; max-width: 1120px; margin: 0 auto 14px; }
.tabs button { flex: 1; border-radius: 999px; padding: 9px 0; color: var(--dim); font-weight: 500; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border: 1px solid transparent; background: linear-gradient(var(--card-hi), var(--card-hi)) padding-box, var(--rim) border-box; }
.tabs button[aria-selected="false"] { background: var(--card); border: 1px solid var(--line); }
.screens { max-width: 1120px; margin: 0 auto; }
.screen-title { display: none; }
@media (min-width: 900px) {
  .tabs { display: none; }
  .screens { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .screen[hidden] { display: block !important; }
  .screen-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 12px; }
  .screen-title span:first-child { font: 400 28px/1.1 var(--serif); color: var(--text); }
}

/* Machine chips: each machine a fixed hue between green and magenta (app.js). */
.chip { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--mc, var(--faint)); }

/* Agents: one row per session, most urgent first, each with an orbit dial. */
.agents { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.agent { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 12px; align-items: center; padding: 10px 14px 11px 10px; }
.dial { grid-row: span 3; width: 40px; height: 40px; position: relative; }
.dial svg { width: 40px; height: 40px; display: block; }
.dial .ring { fill: none; stroke: var(--ring); stroke-width: 3; }
.dial .arc { fill: none; stroke-width: 3; stroke-linecap: round; }
.dial .core { position: absolute; inset: 0; display: grid; place-items: center; font: 500 15px/1 var(--sans); color: var(--pc, var(--text)); }
.agent.working .arc { stroke: var(--pc, var(--good)); stroke-dasharray: 26 200; transform-box: fill-box; transform-origin: center; animation: orbit 2.4s linear infinite; }
.agent.needs .arc { stroke: var(--needs); stroke-dasharray: 200 0; filter: drop-shadow(0 0 4px var(--needs)); }
.agent.needs .core { color: var(--needs); font-weight: 600; }
.agent.needs .dial { border-radius: 50%; animation: pulse 2s ease-out infinite; }
.agent.done .arc { stroke: var(--good); stroke-dasharray: 200 0; opacity: 0.8; }
.agent.done .core { color: var(--good); }
.agent.idle .arc { stroke: var(--faint); stroke-dasharray: 3 6; }
/* Working, but silent for 15+ minutes: the orbit stops and the row fades. */
.agent.stale .arc { animation: none; stroke: var(--faint); }
.agent.stale .project, .agent.stale .detail, .agent.stale .dial { opacity: 0.55; }
.agent .meta .quiet { color: var(--text); }
.agent.idle .core { color: var(--faint); }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--needs-soft); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .agent .arc, .agent .dial { animation: none !important; } }
.agent .project { font-size: 19px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .elapsed { font: 500 14px var(--mono); color: var(--dim); justify-self: end; }
.agent .detail { grid-column: 2 / 4; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent.needs .detail { color: var(--needs); }
.agent.done .detail, .agent.idle .detail { color: var(--dim); }
.agent .meta { grid-column: 2 / 4; display: flex; gap: 12px; margin-top: 5px; font: 12px/1.3 var(--mono); color: var(--faint); }
.agent .meta .prov { color: var(--pc, var(--faint)); }
.summary { text-align: center; color: var(--dim); font: 13px var(--mono); margin: 16px 0 0; }
.empty { padding: 22px 16px; color: var(--dim); text-align: center; }

/* Usage: one panel per account, one gauge per limit window. */
.accounts { display: grid; gap: 24px; }
@media (min-width: 640px) and (max-width: 899px) { .accounts { grid-template-columns: 1fr 1fr; } }
.account { display: grid; gap: 10px; }
.account-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: 12px; row-gap: 2px; padding: 0 2px; }
.account-name { margin: 0; font: 500 17px/1.2 var(--mono); color: var(--pc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.account-name .glyph { margin-right: 8px; }
.account-name .label { opacity: 0.75; margin-left: 8px; font-weight: 400; }
.account-meta { font: 12px var(--mono); color: var(--faint); margin-left: auto; white-space: nowrap; display: flex; gap: 10px; }
.meters { display: grid; gap: 10px; }
@media (min-width: 1100px) { .meters { grid-template-columns: 1fr 1fr; } }
.meter { padding: 12px 16px 14px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pct { font: 500 34px/1.05 var(--mono); letter-spacing: -0.02em; }
.pct small { font-size: 16px; opacity: 0.7; margin-left: 2px; }
/* The gauge: the whole cool-to-hot scale, dim past the reading, ticks every
   10%, and a needle in the scale's colour at that point (glowing when hot). */
.gauge { position: relative; height: 22px; margin: 12px 0 8px; }
.gauge .scale, .gauge .lit { position: absolute; left: 0; right: 0; top: 6px; height: 10px; border-radius: 3px; background: var(--scale); }
.gauge .scale { opacity: 0.16; }
.gauge .ticks {
  position: absolute; left: 0; right: 0; top: 0; height: 22px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 10%);
  -webkit-mask: linear-gradient(#000 0 4px, transparent 4px 18px, #000 18px);
  mask: linear-gradient(#000 0 4px, transparent 4px 18px, #000 18px);
}
.gauge .needle { position: absolute; top: 0; width: 2px; height: 22px; margin-left: -1px; border-radius: 1px; background: var(--needle, var(--text)); }
.gauge .needle.hot { box-shadow: 0 0 8px 1px var(--needle); }
.resets { color: var(--dim); font: 14px var(--mono); }
.account-error { padding: 14px 16px; color: var(--dim); font-size: 15px; }

/* Sign in, pair, devices */
body.login { display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px 24px; }
.login-card .mark { width: 52px; height: 52px; }
.login-card h1 { font: 400 40px/1.05 var(--serif); margin: 14px 0 6px; }
.login-card .sub { color: var(--dim); margin: 0 0 24px; }
.clerk-mount { min-height: 220px; }
.login-card .fine { margin: 18px 0 0; font: 400 12px/1.4 var(--mono); color: var(--faint); }
.login-card .fine a { color: var(--dim); }
.stack { display: grid; gap: 8px; }
.stack label { font: 500 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-top: 8px; }
.stack input {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 12px; width: 100%;
}
.stack input:focus { outline: 2px solid transparent; border-color: transparent; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--dim); }
.primary {
  margin-top: 14px; background: var(--button); color: var(--on-button); border: 0; border-radius: 8px;
  padding: 12px; font-weight: 600; cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }
.login-error { border: 1px solid var(--needs); background: var(--needs-soft); color: var(--text); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.page-title { font-size: clamp(28px, 5vw, 40px); }
.narrow { max-width: 520px; margin: 8px auto 0; display: grid; gap: 16px; }
.panel { padding: 18px 18px 20px; }
.panel h2 { font: 400 24px/1.2 var(--serif); margin: 0 0 6px; }
.panel a { color: var(--text); text-decoration-color: var(--dim); }
.dim { color: var(--dim); margin: 0 0 14px; }
.small { font: 12px var(--mono); margin: 3px 0 0; }
.code-input { font: 500 26px/1.2 var(--mono) !important; letter-spacing: 0.14em; text-align: center; text-transform: uppercase; }
.danger { background: none; border: 1px solid var(--needs); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.danger:hover { background: var(--needs-soft); }
.device-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.device { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.device-name { font-weight: 500; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline input { flex: 1; min-width: 0; }
.inline .primary, .inline .danger { margin-top: 0; white-space: nowrap; padding: 0 14px; }
.row-form { margin-bottom: 14px; }
.new-key { padding: 12px 14px; margin: 0 0 14px; display: grid; gap: 8px; }
.new-key .engraved { margin: 0; }
.code { margin: 0; font: 12px/1.6 var(--mono); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.ghost { justify-self: start; background: none; border: 1px solid var(--ring); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.ghost:hover { border-color: var(--dim); }
.sub-head { margin: 18px 0 8px; }
.hint { max-width: 1120px; margin: 0 auto 14px; padding: 10px 14px; color: var(--dim); font-size: 14px; }

/* Phones: the clock keeps one line, the links get their own row under it. */
.clock { white-space: nowrap; }
@media (max-width: 599px) {
  .top { grid-template-columns: auto 1fr auto; padding-bottom: 8px; }
  .top .clock { justify-self: center; font-size: 40px; }
  .top .clock { font-size: 40px; }
}

/* ---- SI Everywhere: acting on sessions ---------------------------------- */
.sie-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.sie-btn { background: none; border: 1px solid var(--ring); color: var(--text); border-radius: 8px; padding: 6px 12px; font: 500 14px var(--sans, inherit); cursor: pointer; text-decoration: none; display: inline-block; }
.sie-btn:hover { border-color: var(--dim); }
.sie-review { border-color: var(--needs); background: var(--needs-soft); }
.sie-note { font: 12px var(--mono); color: var(--dim); }
.agent.sie-asking { box-shadow: 0 0 0 1px var(--needs), 0 0 24px var(--needs-soft); }
.sie-sheet { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px 20px 22px; color: var(--text); background: var(--card); border: 0; }
.sie-sheet::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.sie-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sie-sheet-head h2 { font: 400 24px/1.2 var(--serif); margin: 0 0 6px; }
.sie-x { background: none; border: 0; color: var(--dim); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.sie-sheet-body { display: grid; gap: 12px; }
.sie-preview { max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-word; user-select: text; }
.sie-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.sie-choices .primary, .sie-choices .danger { margin-top: 0; padding: 10px 16px; }
.sie-note-input, .sie-reply-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; resize: vertical; }
.sie-note-input:focus, .sie-reply-input:focus { outline: 2px solid transparent; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--dim); }
.sie-keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; align-items: baseline; }
.sie-keys dd { margin: 0; }
.code-key { font: 500 15px var(--mono); letter-spacing: .06em; color: var(--text); }
.sie-code { font: 500 34px/1.2 var(--mono); letter-spacing: .14em; text-align: center; margin: 10px 0; }
.sie-wide { display: block; text-align: center; text-decoration: none; margin-top: 14px; }
#sie-banner code, .panel code { font: 13px var(--mono); color: var(--text); }
#sie-banner { max-width: 1120px; margin: 0 auto 14px; }
