/* Dickhead admin console. Dark, high-contrast, no frameworks, nothing from a CDN --
   this thing runs on a LAN box that a Tab5 also depends on, and a blocked font request
   should never be able to make it look broken. */

:root {
  --bg: #0b0b0d;
  --bg-1: #131317;
  --bg-2: #1b1b21;
  --line: #2a2a33;
  --text: #e8e6e3;
  --muted: #8f8b86;
  --amber: #f5a524;
  --amber-dim: #7a5411;
  --green: #4ec9a1;
  --red: #ef5f5f;
  --blue: #6cb6ff;
  --purple: #c792ea;
  --radius: 10px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--amber); }
code, pre, .mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0.75rem; }

/* ------------------------------------------------------------- sign-in / errors */

body.auth {
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(60rem 30rem at 50% -10rem, #1d1a12 0%, transparent 70%),
    var(--bg);
}

.auth-card {
  width: min(30rem, 100%);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
}

.brand-mark {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.42em;
  color: var(--amber);
  margin-bottom: 1rem;
}

.auth-card h1 { font-size: 1.6rem; margin: 0 0 0.35rem; }
.lede { color: var(--muted); margin: 0 0 1.5rem; }
.auth-footer { margin-top: 2rem; color: var(--muted); font-size: 0.78rem; }

.stack { display: grid; gap: 0.5rem; }
.stack.tight { gap: 0.4rem; }
label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.notice {
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  margin: 0 0 1rem;
  border: 1px solid var(--line);
}
.notice.warn { background: #2a2110; border-color: var(--amber-dim); color: #ffd79a; }
.notice.bad { background: #2a1414; border-color: #5c2323; color: #ffb3b3; }

/* -------------------------------------------------------------------- controls */

input[type="text"], input[type="search"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
textarea { resize: vertical; min-height: 2.6rem; }

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  background: var(--bg-2);
  color: var(--text);
}
button:hover { border-color: var(--amber-dim); }
button.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #17130a;
  font-weight: 650;
}
button.primary:hover { background: #ffb733; }
button.ghost { background: transparent; }
button.small { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
button.icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  padding: 0;
  font-size: 1rem;
  color: var(--muted);
  flex: 0 0 auto;
}
button.icon-btn.recording { background: var(--red); border-color: var(--red); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ----------------------------------------------------------------------- chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 0.5rem; }
.brand-word {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--amber);
}
.ver { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
/* What is left of the old six-pill status bar: who you are, and whether the page is still being
   pushed to. Everything else it carried is on the Status tab or on the device's own screen. */
.topbar-right { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; flex-wrap: wrap; }
.pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--green); border-color: #1f4436; }
.pill.bad { color: var(--red); border-color: #5c2323; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  overflow-x: auto;
}
.tab-link {
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  font-size: 0.87rem;
  white-space: nowrap;
}
.tab-link.is-active {
  background: var(--bg-1);
  border-color: var(--line);
  color: var(--text);
}
.badge {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 0.3rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--amber);
}

main { padding: 1rem; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---- the console is a page that fits its window ----------------------------

   `main` is the only thing that scrolls, and the bar and the tabs stay where they were. That is not
   decoration: on the Chat tab the composer has to be reachable without scrolling, and a page that
   grows every time anybody speaks is what put the microphone off the bottom of the window. The
   sign-in page is a centred card on a page that *should* scroll on a phone, so this is scoped to
   `body.console` rather than to every page the app renders. */
body.console {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
body.console main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ---- the Chat tab: one screen, and no scrolling at all ---------------------

   The panel is exactly the height `main` has to give it: the head takes what is left and the
   keyboard is the last thing on the page and sticky on top of that, so nothing can push the composer
   out of reach — not a long answer, not the dial drawer, not a short window.

   The head's width is derived from the *viewport* height because its aspect ratio is 16:9 and its
   height must not exceed the stage: `(100dvh - chrome) × 16/9`, where `chrome` is the bar, the tabs,
   `main`'s padding, the gap and the keyboard (measured: 275px closed, 385px with the listening dials
   open). Getting this exactly right is impossible in CSS without measuring the keyboard, and it does
   not need to be: the two numbers below are within ~20px, the stage is `overflow: auto` with a safe
   centring so a few pixels of overshoot scrolls instead of clipping the face, and the sticky keyboard
   means an overshoot can never cost you the send button.

   Container query units were tried first (`width: min(52rem, 100cqw, calc(100cqh * 16/9))` with
   `container-type: size` on the stage) and Chrome answered a 940px formula with 780px — inside a
   size-contained flex container its inline-size resolution for a child goes circular and it falls
   back to something arbitrary. Viewport units cannot be circular. */
#tab-chat.is-active {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
}
.chat-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: safe center;
  justify-content: center;
  overflow: auto;
}
/* Id-specific on purpose: the base `.device` rule further down sets its own width, and a
   same-specificity rule earlier in the file loses to it whatever the comment next to it says. */
#tab-chat .device {
  width: min(52rem, 100%, calc((100dvh - 17.5rem) * 16 / 9));
}
#tab-chat:has(.tuning[open]) .device {
  width: min(52rem, 100%, calc((100dvh - 24.5rem) * 16 / 9));
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.filter { width: auto; min-width: 12rem; margin-left: auto; }
.seg { display: flex; gap: 0.2rem; margin-left: auto; }
.seg-btn { padding: 0.25rem 0.55rem; font-size: 0.78rem; color: var(--muted); }
.seg-btn.is-active { color: var(--amber); border-color: var(--amber-dim); }

.row-form {
  display: grid;
  grid-template-columns: minmax(10rem, 2fr) minmax(8rem, 1fr) minmax(10rem, 2fr) auto;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.row-form .wide { grid-column: span 1; }
@media (max-width: 900px) {
  .row-form { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------- lists */

.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.item-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.item-list.small li { padding: 0.35rem 0.5rem; font-size: 0.82rem; }
.item-main { display: grid; gap: 0.1rem; min-width: 0; }
.item-title { overflow-wrap: anywhere; }
.item-sub { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.item-actions { margin-left: auto; display: flex; gap: 0.3rem; flex: 0 0 auto; }
.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.35rem;
  color: var(--blue);
}
.state { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.state.running, .state.scheduled { color: var(--green); }
.state.fired { color: var(--amber); }
.state.cancelled { color: var(--muted); }
.state.pending { color: var(--red); }
.state.ack { color: var(--muted); }
.empty { color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0; list-style: none; }

/* -------------------------------------------------------------------- the device

   The Tab5's screen, in the browser. Every colour below is a `#define C_*` from
   firmware/main/src/dh_ui.c and tests/test_device_face.py fails if the two copies drift, so
   treat them as an interface rather than decoration: the console has to look like the box on the
   desk because it *is* the same assistant, and a chat page in a different palette is a second
   product people will rightly distrust. */

/* The LIGHT dial. A page cannot reach a backlight, so it dims what it draws instead — which is
   why the toasts are left out: a notification you cannot read because you turned the screen down
   is worse than a bright one. */
html { --dh-light: 1; }
.topbar,
.tabs,
main {
  filter: brightness(var(--dh-light));
}

.device {
  --screen-bg: #05080c;
  --chassis: #141922;
  --chassis-hi: #1e2530;
  --device-strip: #10141b;
  --device-text: #e8eff7;
  --device-dim: #7c8ca0;
  --btn: #171d27;
  --btn-edge: #2a3341;
  --btn-text: #c9d5e4;
  --btn-off: #4a5464;
  --okay: #4ade80;
  --alarm: #ff4d5e;
  --meter-track: #2b3646;
  --meter-edge: #39485a;
  --meter-fill: #2ed3b7;
  --notice: #f5a524;

  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 2px solid var(--chassis-hi);
  border-radius: 22px;
  background: var(--chassis);
  overflow: hidden;
  /* An explicit width, not `max-width` + auto margins: auto margins switch a grid item from
     stretch to fit-content, which sizes the screen to whatever the buttons happen to spell and
     then wraps them onto a second row. */
  width: min(52rem, 100%);
  margin-inline: auto;
  box-shadow: 0 18px 40px rgb(0 0 0 / 55%);
  /* The panel is a 1280x720 landscape screen, so the thing on the page is too. Without it the
     box grows to whatever the caption happens to say and reads as a web layout wearing a face;
     with it, a longer answer wraps inside the screen instead of pushing the controls off the
     bottom of the page — which is exactly how it behaves on the hardware. */
  aspect-ratio: 16 / 9;
}
@media (max-width: 700px) {
  /* A phone is taller than it is wide and a 16:9 box on it is a stripe. */
  .device {
    aspect-ratio: auto;
  }
}

/* ---- the sign-in screen: the same hardware, smaller ------------------------

One face above one field, drawn by the same face.js the console mounts. A login page with a stock
emoji in it is a login page for a different product; a hand-copied second drawing of this face is a
second thing to fall out of date the week the mood table moves. */
.device--login {
  width: min(24rem, 100%);
  margin-bottom: 1.4rem;
}
.device--login .device-content {
  padding: 0.75rem;
}

/* ---- status strip ---------------------------------------------------------- */
.device-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.1rem;
  background: var(--device-strip);
  border-bottom: 1px solid var(--btn-edge);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--device-dim);
}
.device-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--okay);
  flex: none;
}
.device-net { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-clock {
  margin-inline: auto;
  font-size: 1.05rem;
  color: var(--device-text);
  letter-spacing: 0.04em;
}
.device-counts { text-align: right; }
.device.urgent .device-dot { background: var(--alarm); }

/* ---- content: face, meter, captions --------------------------------------- */
.device-content {
  display: grid;
  /* `max-content`, not `auto`: inside a screen of fixed height the browser otherwise sizes each
     caption row to the item's own `min-height` and lets the words overflow on top of the next one,
     which is what "the reply is written over my question" looked like on a 16:9 panel. The rows get
     their real height and the screen scrolls (see `overflow-y` below). */
  grid-auto-rows: max-content;
  justify-items: center;
  /* `safe center`, not `center`: centring an overflow in a grid puts the first line above the
     scrollable region, where no amount of scrolling reaches it. The captions are the transcript now
     -- there is no chat log below to fall back to -- so a long question that cannot be scrolled to
     is a question the page has thrown away. */
  align-content: safe center;
  gap: 0.6rem;
  min-height: 0;
  /* Not `hidden`. On the hardware the line budget is LVGL's and a long reply is cut off there; on
     the page this is the only copy of what was said, so it scrolls inside the screen instead of
     losing the ending -- and the controls stay put because the screen's rows do not move. */
  overflow-y: auto;
  padding: 1rem 1.2rem;
  background: var(--screen-bg);
}
/* A thumb you can actually see. The screen scrolls now that it holds a whole exchange, and an
   overlay scrollbar that only appears while you are dragging reads as a reply with no ending. The
   colours are the firmware's meter colours, so the scrollbar belongs to the screen rather than to
   the page around it. */
.device-content {
  scrollbar-width: thin;
  scrollbar-color: var(--meter-edge) transparent;
}
.device-content::-webkit-scrollbar {
  width: 8px;
}
.device-content::-webkit-scrollbar-track {
  background: transparent;
}
.device-content::-webkit-scrollbar-thumb {
  background: var(--meter-edge);
  border-radius: 4px;
}
/* The head itself is drawn 2:1 — the firmware's own viewBox — inside a screen that is 16:9, which
   is what leaves room above and below it for the strip and the buttons.

   46% is `lv_obj_set_size(U.face, W * 0.46f, …)` in `dh_ui_build`, not a number anyone liked the
   look of. It matters more here than on the hardware because the browser screen is also the
   transcript: at 70% the head ate four fifths of the content box and every reply of any length
   started below the fold of its own screen. */
.device-face {
  width: min(27rem, 46%);
  aspect-ratio: 2 / 1;
  align-self: center;
}
.dh-chassis {
  width: 100%;
  height: 100%;
  border: 2px solid var(--chassis-hi);
  border-radius: 44px;
  background: var(--chassis);
  display: grid;
  padding: 4%;
}
.dh-screen {
  border: 3px solid var(--btn-edge);
  border-radius: 32px;
  background: var(--screen-bg);
  display: grid;
}
.dh-face-svg { width: 100%; height: 100%; display: block; }

/* The meter is 12px, rounded, and its track is lighter than the screen: on a near-black panel a
   24-level-grey track is not a bar nobody remembered to fill, it is a bar that is not there. */
.device-meter,
.wake-meter {
  position: relative;
  width: min(22rem, 60%);
  height: 12px;
  border: 1px solid var(--meter-edge);
  border-radius: 6px;
  background: var(--meter-track);
  overflow: hidden;
  opacity: 0.35;
  transition: opacity 120ms ease-out;
}
.device-meter.live { opacity: 1; }

/* The fill is the level; the two marks are the learned noise floor and the bar a voice has to
   clear. All three on one track is the whole point: the argument about a room is settled by where
   the marks sit relative to each other, and not by anybody's opinion of a sensitivity dial. */
.wake-meter-fill,
.device-meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: var(--meter-fill);
  transition: width 60ms linear;
}
/* While the speaker is moving the level is the speaker, not a voice: grey, so an echo is never
   read as an interruption. */
.wake-meter-fill.hot {
  background: var(--device-dim);
}
.wake-meter-floor,
.wake-meter-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--device-dim);
}
.wake-meter-threshold {
  background: var(--alarm);
}

.device-caption { margin: 0; text-align: center; max-width: 34rem; overflow-wrap: anywhere; }
.device-caption.heard {
  font-size: 0.86rem;
  color: var(--device-dim);
  min-height: 1.2em;
}
.device-caption.said {
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--device-text);
  min-height: 1.35em;
}
/* The notice is the amber line, and it is the one piece of text that is allowed to expire back to
   nothing. Clicking it is the demo-day escape hatch: every other part of barge-in is a guess about
   a room, a click never is. */
.device-notice {
  margin: 0;
  min-height: 1.6em;
  font-size: 0.85rem;
  color: var(--notice);
  text-align: center;
  cursor: pointer;
  max-width: 34rem;
}

/* ---- controls ------------------------------------------------------------- */
.device-controls {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.8rem 0.9rem;
  background: var(--device-strip);
  border-top: 1px solid var(--btn-edge);
}
.device-btn {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  background: var(--btn);
  color: var(--btn-text);
  border: 1px solid var(--btn-edge);
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  min-width: 2.2rem;
  cursor: pointer;
}
.device-btn:hover { border-color: var(--device-dim); }
.device-btn.listen {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: center;
  min-width: 8rem;
}
/* The two buttons the box paints green — "I am listening" and "this is the speaker, and it is on"
   — are filled, not merely outlined, because at arm's length across a kitchen the fill is what is
   readable and the outline is not. */
.device-btn.listen.on {
  color: var(--okay);
  background: #0f3524;
  border-color: #1e6b45;
}
.device-btn.listen:disabled { color: var(--btn-off); cursor: not-allowed; opacity: 0.6; }
/* LIGHT and EARS are numbers, not states: plain buttons with the number on them. */
.device-btn.value {
  color: var(--btn-text);
  background: var(--btn);
}
.device-btn.speaker {
  color: var(--okay);
  background: #14401f;
  border-color: #1e6b3a;
}
/* Mute is red and stays red, with the glyph in front of the number: the number is still true, and
   hiding it would make the dial look broken rather than deliberately silenced. */
.device-btn.speaker.muted {
  color: #ff9aa5;
  background: #4a1218;
  border-color: #802a33;
}
/* One row, always: four controls that wrap onto two lines turn a 16:9 screen into a square, and the
   screen is the thing that is supposed to look like the box. */
.device-dial { display: inline-flex; align-items: center; gap: 0.15rem; }
.device-dial .device-btn.step { padding: 0.45rem 0.45rem; min-width: 0; }
.device-btn.value {
  /* The dial keeps its number while the box is muted, because the number is still true; what
     changes is the colour, so a mute cannot be mistaken for "it is loud, it is just quiet". */
  background: transparent;
}

@media (max-width: 700px) {
  .device-controls { gap: 0.35rem; }
  .device-btn.listen { min-width: 0; }
}

/* ------------------------------------------------------------------------- chat */

/* The keyboard is the last thing on the Chat tab and stays there: bottom-anchored like every chat
   there is, and sticky so a short window or an opened dial drawer cannot bury the microphone. */
.keyboard {
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: sticky;
  bottom: 0;
  z-index: 15;
}
.tuning summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.tuning[open] { padding-top: 0.4rem; }
.wake-tuning { margin-top: 0.5rem; }
.stream-status {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--amber);
  padding: 0.25rem 0.5rem;
  border: 1px dashed var(--amber-dim);
  border-radius: 6px;
}

.composer { display: flex; gap: 0.4rem; align-items: flex-end; }
.composer textarea { flex: 1 1 auto; }
.composer-row { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; font-size: 0.8rem; }
.check { display: inline-flex; gap: 0.35rem; align-items: center; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 0.8rem; }
.check input { accent-color: var(--amber); }

/* -------------------------------------------------------- continuous listening */

/* Continuous listening used to live in its own bar of its own. It lives on the device now: the
   LISTENING button is one of the four controls, the meter is the one under the face, and the state
   line is the amber notice. What is left here is the shared behaviour those parts still use. */

.wake-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #4a4a55; flex: none; }
.wake-dot.on {
  background: var(--amber);
  animation: wake-pulse 1.9s ease-out infinite;
}
@keyframes wake-pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.45); }
  70% { box-shadow: 0 0 0 0.5rem rgba(245, 165, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0); }
}

/* The state line changes width constantly as it fills with text; reserving space stops the
   sliders from jumping out from under the pointer mid-drag. It is also the "shut up" button,
   because arguing with a microphone from across a room is not a strategy. */
.wake-state {
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
.wake-state:hover { color: var(--text); }

/* The line says what it is doing, so it is coloured by what it is doing: shut when there is
   nothing to hear, green while it is somebody's turn to talk, amber while it is busy or making a
   noise. Reading it across a room is the whole point of putting it on the bar. */
.wake-state[data-state="hearing"],
.wake-state[data-state="armed"] { color: var(--green); }
.wake-state[data-state="thinking"],
.wake-state[data-state="waiting"],
.wake-state[data-state="speaking"],
.wake-state[data-state="note"] { color: var(--amber); }
.wake-state[data-state="disabled"] { color: var(--red); }
/* Only the states that are *doing* something breathe, and only so "thinking… 6s" cannot be
   mistaken for a page that stopped responding. */
.wake-state[data-state="thinking"],
.wake-state[data-state="speaking"] { animation: wake-breathe 1.5s ease-in-out infinite; }
@keyframes wake-breathe {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* The bar itself is styled with the device (.device-meter above); these are the parts that move. */
/* The bar's moving parts live with the device (see `.device-meter` above): one fill, two markers,
   in the firmware's colours. They used to be a green-to-amber gradient of the console's own
   invention, which made the same number look different on the two mouths. */

.wake-tuning {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
}
.wake-slider { display: inline-flex; align-items: center; gap: 0.4rem; }
.wake-slider input[type="range"] { width: 6.5rem; accent-color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  .wake-dot.on,
  .wake-state[data-state="thinking"],
  .wake-state[data-state="speaking"] { animation: none; }
  .wake-meter-fill { transition: none; }
}

/* --------------------------------------------------------- searching and paging

   Four panels share this row -- notes, timers, reminders, and each half of the queue -- so it is
   one stylesheet block and one function in app.js rather than four near-copies that drift. The
   range says "1-15 of 63" out of the server's own `total`, never out of the rows on the page: a
   pager that counts its own array is a pager with no last page. */
.list-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0 0 0.7rem;
}
.list-tools .search { flex: 1 1 14rem; min-width: 10rem; }
.pager { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.pager[hidden] { display: none; }
.pager-range { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); white-space: nowrap; }

/* The finished half of the queue: there when you want to check it said the thing, out of the way
   when you do not, and never silent about how much it is hiding. */
.done-box {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  background: var(--bg-1);
}
.done-box summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.done-box summary:hover { color: var(--text); }
.done-box[open] summary { margin-bottom: 0.7rem; }

/* The settings the top bar used to carry. */
.install {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber-dim);
  border-radius: 8px;
  background: var(--bg-1);
  font-family: var(--mono);
  font-size: 0.76rem;
}
.install-row { display: flex; gap: 0.4rem; align-items: baseline; }
.install-k { color: var(--muted); text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.1em; }
.install-v { color: var(--text); }

.msg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.msg-list li { background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; }
.msg-list .role { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.msg-list .role.user { color: var(--blue); }
.msg-list .role.assistant { color: var(--amber); }
.msg-list .role.tool { color: var(--purple); }
.msg-list pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0.3rem 0 0; color: #cbd5e1; }

/* ----------------------------------------------------------------------- status */

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr)); gap: 1rem; }
.status-grid h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 1rem 0 0.4rem; }
.status-grid h2:first-child { margin-top: 0; }
.json {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  margin: 0;
  overflow-x: auto;
  max-height: 24rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.4rem;
  z-index: 100;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  max-width: 24rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 45%);
}
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }

/* ------------------------------------------------------------------- accounts */

/* The minted key, in the one place it will ever appear. Monospace, wrappable, selectable: it is a
   credential being transcribed to another device, and a value that truncates with an ellipsis is a
   key that does not work. */
.key-reveal {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  background: var(--bg-2);
}
.key-value {
  margin: 0.5rem 0 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}
