/*
 * K.E.R. shell stylesheet — the structure and the components of the app surface.
 *
 * The values are not here. Every token this file used to declare lives in
 * tokens.css, which is linked first and which both surfaces share; they were
 * moved after being checked identical one by one (`--bg`, `--ink`, `--accent`,
 * the six type sizes, the four corner steps), so the deletion could not change
 * a value. What stays here is the shell: layout, structure, components. Density
 * is still overridden below, because a user setting is not a token.
 *
 * Components below use var(--…) exclusively; a literal hex in a component is a
 * bug, and there is a test that greps for one.
 *
 * Direction: obsidian, flat, restrained. No glass and no glow — both were here
 * and both are gone. The accent is lime and it is reserved for *action and
 * state*: a button you can press, a status that is live, the screen you are on.
 * Everything highlighted means nothing highlighted, which is how a premium tool
 * turns into a Christmas tree.
 */

/* Density is a user setting, so it moves the tokens rather than each rule. */
:root[data-density="compact"] { --pad: 11px; --gap: 11px; }
:root[data-density="roomy"]   { --pad: 22px; --gap: 22px; }

/* -- reset ---------------------------------------------------------------- */

* { box-sizing: border-box; }
/* Controls do not inherit type by default. Without this an unstyled <button>
 * renders at the browser's 13.3px and an <h3> at 16.4px — which is how a
 * "design system" quietly carries eleven font sizes. Measured, not guessed:
 * see qa_redesign_shot.py, which counts them per screen. */
button, input, select, textarea { font: inherit; color: inherit; }
/* A view may render a bare <button> — Executions renders nine. With nothing
 * styling them they fall back to the browser's light-grey `buttonface`: an
 * off-theme island in an obsidian shell, and invisible to the class-rule guard
 * because there is no class to check. `:not([class])` reaches exactly those
 * and leaves every component (which always carries a class) untouched. */
button:not([class]) {
  font: inherit;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-control);
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
button:not([class]):hover:not(:disabled) { border-color: var(--line-strong); }
button:not([class]):disabled { opacity: .5; cursor: default; }
html, body { height: 100%; margin: 0; }

body {
  /* Flat obsidian. This used to paint two large radial washes — lime from the
   * top-right, teal from the bottom-left — which is the "glowing orb" look the
   * brief rules out, and the reason every surface above it needed a blur to
   * stay legible. One colour, one surface, nothing to composite. */
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-body)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

code, .mono, kbd { font-family: var(--mono); }

/* Focus is never removed, only restyled — the interface has to be usable
 * from the keyboard, and an invisible focus ring is the fastest way to make
 * it unusable. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background-clip: content-box; background-color: var(--dim); }

/* -- surfaces -------------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  /* Two lights and one weight: the hairline along the top edge is the glass
     catching the room, the wide soft shadow below is the card standing on
     the page. Neither is visible as a "effect" — together they read as
     depth. */
  box-shadow: inset 0 1px 0 rgba(233, 240, 236, 0.04),
              0 20px 44px -32px rgba(0, 0, 0, 0.85);
  padding: var(--pad);
}
.card:hover { border-color: var(--line-strong); }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 {
  margin: 0;
  font: 700 var(--fs-micro)/1 var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
}
.card-head .spacer { flex: 1; }

/* -- controls -------------------------------------------------------------- */

/* `hidden` means hidden, whatever else an element is (Фаза 25).
 *
 * The attribute's only styling comes from the browser's own stylesheet, and
 * any author rule that sets `display` outranks it. `.btn` sets
 * `display: inline-flex`, so every control written as
 * `<button class="btn" hidden>` was on screen the whole time: Stop while
 * nothing was streaming, Save with no file open, Load more with nothing left
 * to load — five of them, across chat, files, memory and notes. They read as
 * dead buttons because that is exactly what they were.
 *
 * Found by rendering the deck in a browser and looking at it. Reading the
 * markup does not show it: the markup is correct, and so is the JavaScript
 * that sets `.hidden`.
 *
 * `!important` deliberately: this must outrank every present and future
 * display-setting class, or the next component quietly brings the bug back. */
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-control);
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  font: 600 var(--fs-body) var(--sans);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--raised); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 4px var(--accent-wash);
}
.btn.danger { color: var(--crit); border-color: rgba(242, 85, 90, 0.3); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); }

.input, input[type="text"], input[type="password"], input[type="search"],
textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-control);
  color: var(--ink);
  padding: 9px 13px;
  font: var(--fs-body) var(--sans);
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--line);
}
::placeholder { color: var(--dim); }

/* -- status vocabulary ------------------------------------------------------
 * Six words the whole interface uses for the same six meanings. A screen
 * inventing a seventh is a screen the user has to learn separately.
 */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--r-xs);
  font: 700 var(--fs-micro)/1 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill.ok      { background: rgba(63, 217, 176, 0.13); color: var(--ok); }
.pill.live    { background: var(--accent-wash);       color: var(--accent); }
.pill.warn    { background: rgba(232, 184, 74, 0.13); color: var(--warn); }
.pill.crit    { background: rgba(242, 85, 90, 0.13);  color: var(--crit); }
.pill.idle    { background: rgba(233, 240, 236, 0.06); color: var(--dim); }
/* "Unavailable" is a first-class state here, not an error: a gauge nobody
 * can measure and a feature that needs setup both land on it. */
.pill.na      { background: rgba(233, 240, 236, 0.05); color: var(--dim); }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim); flex: none;
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 217, 176, 0.14); }
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }

/* -- states every screen must be able to show ------------------------------ */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.state .glyph { font-size: 26px; opacity: 0.5; }
.state h4 { margin: 0; font: 600 var(--fs-section) var(--sans); color: var(--ink); }
.state p { margin: 0; max-width: 46ch; font-size: var(--fs-small); }
.state.bad h4 { color: var(--crit); }

.skeleton {
  background: linear-gradient(90deg, var(--raised) 25%,
              rgba(233, 240, 236, 0.05) 37%, var(--raised) 63%);
  background-size: 400% 100%;
  border-radius: var(--r-xs);
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--line-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Honour the OS setting rather than deciding for the user. Motion here is
 * decoration on top of state that is also conveyed in text, so removing it
 * costs nothing. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
:root[data-motion="off"] *, :root[data-motion="off"] *::before {
  animation: none !important;
  transition: none !important;
}

/* -- asking the user something ---------------------------------------------
 * The product's own dialog, replacing `window.confirm`/`window.prompt`. A
 * `<dialog>` element, so the top layer, the focus trap and Escape come from
 * the platform and only the appearance is ours.
 */

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  max-width: min(420px, calc(100vw - 32px));
}
.modal::backdrop {
  background: rgba(8, 11, 10, 0.62);
}

.modal-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modal-in var(--t-base) var(--ease);
}
.modal-box.danger { border-color: rgba(242, 85, 90, 0.34); }
.modal-box h4 { margin: 0; font: 600 var(--fs-section) var(--sans); }
.modal-box p { margin: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* -- permission questions ---------------------------------------------------
 * A card, not a modal: several can be pending at once, and a prompt that
 * steals focus is how people learn to press Allow without reading. It is
 * marked out by the warning colour rather than by moving, because it is
 * genuinely blocking something — K.E.R. is stopped until it is answered.
 */

.card.ask {
  border-color: rgba(232, 184, 74, 0.32);
  background: var(--panel-solid);
}
.ask-row + .ask-row { border-top: 1px solid var(--line-soft); }
.ask-row .ask-note:empty { display: none; }
.ask-row .ask-note { margin-top: 4px; }

/* -- the K.E.R. Core indicator ---------------------------------------------
 * Always on screen, so it is where a persistent status belongs. Each state
 * moves differently and every one of them is a fact the app already holds —
 * there is no "looks busy". The words are in the aria-label, so removing the
 * motion removes nothing but the motion.
 */

.core {
  display: grid; place-items: center;
  background: var(--accent-wash);
  border: 1px solid var(--line);
  color: var(--accent);
  font: 800 var(--fs-small)/1 var(--sans); letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(233, 240, 236, 0.05);
  transition: color var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease);
}

/* Idle: a slow pulse, so "alive" is distinguishable from "frozen". */
.core[data-state="idle"] { animation: core-idle 4s ease-in-out infinite; }
@keyframes core-idle {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-wash); }
  50%      { box-shadow: 0 0 0 10px transparent; }
}

/* Thinking: the same pulse, faster and tighter. */
.core[data-state="thinking"] {
  animation: core-idle 1.1s ease-in-out infinite;
}

/* Executing: a rotating ring — something is happening *outside* the model,
 * and it should not look like the same activity as thinking. */
.core[data-state="executing"] {
  border-color: var(--warn); color: var(--warn);
  animation: core-spin 1.6s linear infinite;
}
@keyframes core-spin {
  from { box-shadow: 0 2px 0 -1px var(--warn); }
  25%  { box-shadow: 2px 0 0 -1px var(--warn); }
  50%  { box-shadow: 0 -2px 0 -1px var(--warn); }
  75%  { box-shadow: -2px 0 0 -1px var(--warn); }
  to   { box-shadow: 0 2px 0 -1px var(--warn); }
}

/* Generating: the ring and the accent border say it. It used to add a 28px
   lime halo on top, which is the "glowing orb" the brief names — and on the
   one element that is always on screen it was the loudest thing in the shell. */
.core[data-state="generating"] {
  box-shadow: 0 0 0 4px var(--accent-wash);
  border-color: var(--accent);
}

.core[data-state="listening"] {
  border-color: var(--info); color: var(--info);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 14%, transparent);
  animation: core-idle 0.9s ease-in-out infinite;
}

/* Offline: no motion at all. A dead indicator reads as dead, which is
 * exactly right — the app cannot see K.E.R. and must not imply it can. */
.core[data-state="offline"] {
  background: transparent; border-color: var(--line-soft);
  color: var(--dim); box-shadow: none; animation: none;
}

/* -- the command palette ----------------------------------------------------
 * A dialog like every other modal, so the focus trap, Escape and the top
 * layer come from the platform. Anchored high rather than centred: it grows
 * downwards as results arrive, and a box that moves while you type is
 * unusable.
 */

.modal.palette { max-width: min(680px, calc(100vw - 32px)); width: 100%;
                margin-top: 12vh; }
.palette-box { background: var(--panel-solid);
              border: 1px solid var(--line-strong);
              border-radius: var(--r-card); overflow: hidden;
              box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.palette-input { width: 100%; border: 0; border-radius: 0;
                background: transparent; color: var(--ink);
                padding: 16px 18px; font: var(--fs-title) var(--sans); }
/* The input is borderless and transparent inside .palette-box (which already
 * carries the outer border), so a focus that simply removed the default ring
 * would leave the keyboard user with no cue at all. An inset accent ring is
 * the indicator: it sits inside the input, never doubles up against the box's
 * own border, and reads as "the palette is taking your keystrokes." */
.palette-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.palette-results { max-height: 56vh; overflow-y: auto;
                  border-top: 1px solid var(--line-soft); }
.palette-group { padding: 6px 0; }
.palette-title { padding: 8px 18px 4px; font: 700 var(--fs-micro) var(--sans);
                letter-spacing: 0.13em; text-transform: uppercase;
                color: var(--dim); }
.palette-row { display: flex; align-items: baseline; gap: 12px;
              padding: 9px 18px; cursor: pointer;
              border-radius: var(--r-control);
              transition: background var(--t-fast) var(--ease),
                          color var(--t-fast) var(--ease); }
.palette-row:hover, .palette-row:focus-visible,
.palette-row[aria-selected="true"] { background: var(--accent-wash); color: var(--ink); }

/* -- hints and toasts --------------------------------------------------------
 * `hint` is the quiet sentence a view renders when a slot has no data yet
 * (or none at all). Views already reached for this class; the design system
 * is saying it back. `#toasts` is where the desktop app speaks unprompted
 * (proactive messages, greetings, update news): the record lives in the
 * app's notification centre — a toast is the glance, so it fades, and a
 * click dismisses.
 */
.hint { color: var(--muted); font-size: var(--fs-small); line-height: 1.45; }

#toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  max-width: min(380px, calc(100vw - 48px));
  pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-control);
  padding: 10px 14px;
  color: var(--ink);
  font: 400 var(--fs-small)/1.45 var(--sans);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in var(--t-slow) var(--ease);
}
.toast.leaving {
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* -- utility --------------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }

/* An alert is not a card.
 *
 * The System screen renders each alert as `card alert-row`, and the class had
 * no rule at all — so an alert, a heading and a quiet note all arrived as the
 * same glass panel. That is the one thing an alert must not be. Severity
 * rides on the left edge, the vocabulary this stylesheet already uses for
 * state; nothing else about the card changes.
 */
.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-left: 2px solid var(--warn);
}
.alert-row[data-severity="critical"],
.alert-row[data-severity="high"] { border-left-color: var(--crit); }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* -- rows, stacks and the execution list -----------------------------------
 *
 * Seven classes the Executions and System screens had been asking for since
 * they were written, none of which existed: `toolbar`, `stack`, `exec-row`,
 * `row-main`, `row-actions`, `exec-detail`, `kv`. Every one of them read as
 * deliberate markup, so nothing looked wrong in the source — the screen just
 * arrived as bare text stacked in the window's corner, with its controls
 * rendered as unstyled buttons.
 *
 * `test_every_class_a_module_renders_has_a_rule` only found them once it
 * started walking the shell's nav instead of a hand-typed list of modules:
 * the list still named sixteen views after plan, system and executions had
 * shipped, so the three newest screens were never checked.
 */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* A labelled control, stacked: the label belongs to the input under it, not
 * beside it, so a four-field form reads down the card instead of across it. */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field > .hint { font-size: var(--fs-micro); }

.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }

/* One execution: its subject on the left, its actions on the right. */
.exec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* What the row expands into. Labels are quiet, values are not. */
.exec-detail { margin-top: 4px; }
.kv {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 6px 14px;
  margin: 12px 0;
}
.kv dt {
  color: var(--dim);
  font: 700 var(--fs-micro)/1.5 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.kv dd { margin: 0; color: var(--ink); font-size: var(--fs-small); }
.kv dd.warn { color: var(--warn); }
.kv dd.err { color: var(--crit); }

/* ==========================================================================
 * COMPONENT LIBRARY — unified tokens, no hardcoded values.
 * Every component below uses var(--…) exclusively; a literal hex here is a bug.
 * ========================================================================= */

/* -- select --------------------------------------------------------------- */
/* Wrapper keeps the native <select> accessible while we style the affordance. */
.select-wrap { position: relative; display: inline-flex; }
.select-wrap::after {
  content: ""; position: absolute; right: 10px; top: 50%; translate: 0 -50%;
  width: 0; height: 0; border-left: 5px solid transparent;
  border-right: 5px solid transparent; border-top: 6px solid var(--muted);
  pointer-events: none;
}
.select-wrap:has(select:disabled)::after { border-top-color: var(--dim); }
.select {
  appearance: none; width: 100%; min-width: 160px;
  padding: 8px 32px 8px 12px; font: var(--fs-body) var(--sans);
  color: var(--ink); background: var(--raised);
  border: 1px solid var(--line-soft); border-radius: var(--r-control);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.select:hover:not(:disabled) { border-color: var(--line-strong); }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.select:disabled { opacity: 0.5; cursor: not-allowed; background: var(--panel); }

/* -- toggle --------------------------------------------------------------- */
/* Checkbox-based toggle, keyboard accessible, no JS required for basic use. */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 44px; height: 26px; background: var(--line-soft); border-radius: var(--r-pill);
  transition: background var(--t-fast) var(--ease);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  background: var(--ink); border-radius: var(--r-pill);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: var(--accent-ink); }
.toggle-input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-input:disabled + .toggle-track { opacity: 0.5; cursor: not-allowed; }
.toggle-label { font-size: var(--fs-body); color: var(--ink); user-select: none; }
.toggle-input:disabled ~ .toggle-label { color: var(--dim); }

/* -- badge ---------------------------------------------------------------- */
/* Small inline label — count, version, capability tag. */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  font: 600 var(--fs-micro) var(--sans); letter-spacing: 0.04em;
  border-radius: var(--r-pill); background: var(--accent-wash); color: var(--accent);
  white-space: nowrap;
}
.badge.neutral { background: var(--line-soft); color: var(--muted); }
.badge.ok { background: rgba(63,217,176,0.15); color: var(--ok); }
.badge.warn { background: rgba(242,166,90,0.15); color: var(--warn); }
.badge.crit { background: rgba(255,107,90,0.15); color: var(--crit); }
.badge.info { background: rgba(110,193,228,0.15); color: var(--info); }

/* -- status --------------------------------------------------------------- */
/* Standalone state indicator — larger than badge, used in cards/rows. */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); }
.status-dot {
  width: 8px; height: 8px; border-radius: var(--r-pill); flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
.status.ok .status-dot { background: var(--ok); box-shadow: 0 0 6px 1px var(--ok); }
.status.warn .status-dot { background: var(--warn); box-shadow: 0 0 6px 1px var(--warn); }
.status.crit .status-dot { background: var(--crit); box-shadow: 0 0 6px 1px var(--crit); }
.status.neutral .status-dot { background: var(--dim); }
.status-text { color: var(--ink); font-weight: 500; }

/* -- avatar --------------------------------------------------------------- */
/* Circular identity marker — image or fallback initials. */
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-solid); border: 1px solid var(--line-soft); border-radius: var(--r-pill);
  overflow: hidden; flex-shrink: 0; color: var(--ink); font-weight: 600; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.fallback { background: var(--accent-wash); color: var(--accent); }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 72px; height: 72px; font-size: 22px; }
.avatar.status-ring::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit;
  border: 2px solid transparent; pointer-events: none;
}
.avatar.ok.status-ring::after { border-color: var(--ok); }
.avatar.warn.status-ring::after { border-color: var(--warn); }
.avatar.crit.status-ring::after { border-color: var(--crit); }

/* -- tooltip -------------------------------------------------------------- */
/* CSS-only tooltip — show on hover/focus of a [data-tooltip] host. */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::before {
  content: attr(data-tooltip); position: absolute; bottom: 120%; left: 50%; translate: -50% 0;
  max-width: 240px; padding: 6px 10px; font: var(--fs-micro) var(--sans);
  color: var(--bg); background: var(--ink); border-radius: var(--r-control);
  white-space: normal; opacity: 0; pointer-events: none; z-index: var(--z-toast);
  transform: translateY(4px); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
[data-tooltip]::after {
  content: ""; position: absolute; bottom: 110%; left: 50%; translate: -50% 0;
  width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--ink); opacity: 0; pointer-events: none; z-index: var(--z-toast);
  transition: opacity var(--t-fast) var(--ease);
}
[data-tooltip]:hover::before, [data-tooltip]:focus::before,
[data-tooltip]:hover::after, [data-tooltip]:focus::after { opacity: 1; transform: translateY(0); }

/* -- dropdown ------------------------------------------------------------- */
/* Minimal dropdown — .dropdown > summary + .dropdown-menu; JS for outside-click close. */
.dropdown { position: relative; display: inline-block; }
.dropdown-trigger { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  font: var(--fs-body) var(--sans); color: var(--ink); background: var(--raised);
  border: 1px solid var(--line-soft); border-radius: var(--r-control); cursor: pointer; }
.dropdown-trigger:hover { border-color: var(--line-strong); }
.dropdown-trigger:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 180px;
  background: var(--panel-solid); border: 1px solid var(--line-soft);
  border-radius: var(--r-card); box-shadow: var(--shadow-2); padding: 6px 0;
  opacity: 0; visibility: hidden; transform: translateY(-4px); z-index: var(--z-dropdown);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.dropdown[open] .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: block; width: 100%; padding: 8px 12px; text-align: left;
  font: var(--fs-body) var(--sans); color: var(--ink); background: transparent; border: none; cursor: pointer; }
.dropdown-item:hover { background: var(--raised); }
.dropdown-item:focus { outline: none; background: var(--accent-wash); color: var(--accent); }
.dropdown-divider { height: 1px; background: var(--line-soft); margin: 6px 0; }

/* -- drawer --------------------------------------------------------------- */
/* Overlay panel from right — used for details, settings, filters. */
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; max-width: 420px; width: 100%;
  background: var(--panel-solid); border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-3); z-index: var(--z-drawer); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--t-slow) var(--ease-out);
}
.drawer[open] { transform: translateX(0); }
.drawer::backdrop { background: var(--overlay); backdrop-filter: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.drawer-title { font: 600 var(--fs-section) var(--sans); color: var(--ink); }
.drawer-close { padding: 6px; color: var(--muted); background: transparent; border: none; border-radius: var(--r-control); cursor: pointer; }
.drawer-close:hover { color: var(--ink); background: var(--raised); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px;
  border-top: 1px solid var(--line-soft); flex-shrink: 0; }

/* -- tabs ----------------------------------------------------------------- */
/* Accessible tabs — .tabs > .tab-list[role=tablist] > button[role=tab] + .tab-panel[role=tabpanel] */
.tabs { display: flex; flex-direction: column; }
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 0; }
.tab { padding: 10px 16px; font: 600 var(--fs-small) var(--sans); color: var(--muted);
  background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus { outline: none; color: var(--ink); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-xs)  var(--r-xs) 0 0; }
.tab-panel { padding: 16px 0; animation: viewIn var(--t-base) var(--ease-out) both; }

/* -- list / empty state --------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-control);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.list-item:hover { border-color: var(--line-strong); background: var(--raised); }
.list-item:focus-within { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }
.list-item .avatar { flex-shrink: 0; }
.list-item .item-main { flex: 1; min-width: 0; }
.list-item .item-title { font: 600 var(--fs-body) var(--sans); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-sub { font: var(--fs-small) var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s-6, 32px) var(--s-4, 16px); text-align: center; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line-soft); border-radius: var(--r-card);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .title { font: 600 var(--fs-section) var(--sans); color: var(--ink); margin-bottom: 6px; }
.empty-state .desc { font-size: var(--fs-body); max-width: 280px; }
.empty-state .action { margin-top: 16px; }

/* -- skeleton variants ---------------------------------------------------- */
/* Loading placeholders matching component shapes. */
.skeleton { background: linear-gradient(90deg, var(--line-soft) 25%, var(--line-strong) 50%, var(--line-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--r-control); }
.skeleton.text { height: 1em; border-radius: 4px; margin: 6px 0; }
.skeleton.title { height: 1.5em; width: 60%; border-radius: 4px; }
.skeleton.avatar { border-radius: var(--r-pill); }
.skeleton.btn { height: 38px; width: 120px; }
.skeleton.card { border-radius: var(--r-card); }
.skeleton.row { height: 56px; }

/* -- toast variants ------------------------------------------------------- */
.toast { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--panel-solid); border: 1px solid var(--line-soft); border-radius: var(--r-card);
  box-shadow: var(--shadow-2); min-width: 280px; max-width: 420px; animation: toast-in var(--t-slow) var(--ease-out) both; }
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.toast.ok .toast-icon { color: var(--ok); }
.toast.warn .toast-icon { color: var(--warn); }
.toast.crit .toast-icon { color: var(--crit); }
.toast.info .toast-icon { color: var(--info); }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font: 600 var(--fs-body) var(--sans); color: var(--ink); margin-bottom: 2px; }
.toast-message { font: var(--fs-small) var(--sans); color: var(--muted); }
.toast-close { flex-shrink: 0; padding: 2px; color: var(--dim); background: transparent; border: none; border-radius: var(--r-control); cursor: pointer; }
.toast-close:hover { color: var(--ink); background: var(--raised); }
.toast.leaving { animation: toast-out var(--t-base) var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* -- execution state ------------------------------------------------------ */
/* Semantic component for execution lifecycle display. */
.execution-state { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  font: 600 var(--fs-small) var(--sans); border-radius: var(--r-pill); }
.execution-state.pending { background: var(--line-soft); color: var(--muted); }
.execution-state.running { background: var(--accent-wash); color: var(--accent); }
.execution-state.waiting { background: rgba(232,184,74,0.15); color: var(--warn); }
.execution-state.success { background: rgba(63,217,176,0.15); color: var(--ok); }
.execution-state.failed { background: rgba(255,107,90,0.15); color: var(--crit); }
.execution-state.cancelled { background: var(--line-soft); color: var(--dim); }
.execution-state .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }

/* -- device status -------------------------------------------------------- */
/* Composite status for device cards — combines connectivity + capability state. */
.device-status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-card); }
.device-status .status-dot { width: 10px; height: 10px; }
.device-status.online .status-dot { background: var(--ok); box-shadow: 0 0 8px 2px var(--ok); }
.device-status.offline .status-dot { background: var(--dim); }
.device-status.busy .status-dot { background: var(--warn); animation: pulse 1.5s ease-in-out infinite; }
/* idle: the connection is alive but the heartbeat went stale (device asleep?)
 * — amber without the busy pulse, so "quiet" reads differently from "working". */
.device-status.idle .status-dot { background: var(--warn); opacity: 0.7; }
.device-status.error .status-dot { background: var(--crit); }
/* revoked is a dead credential, not a live failure — same red, dimmed so a
 * whole list of revoked rows does not shout. */
.device-status.revoked .status-dot { background: var(--crit); opacity: 0.55; }
.device-status.unknown .status-dot { background: var(--dim); opacity: 0.5; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.device-status .label { font: 600 var(--fs-small) var(--sans); color: var(--ink); }
.device-status .caps { font: var(--fs-micro) var(--mono); color: var(--dim); }

/* -- mobile and nav grouping ---------------------------------------------- */
.mobile-tabs { display: none; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-group-title { font: 600 var(--fs-micro) var(--sans); color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 12px 4px; }

/* -- model pool & product toolbar ----------------------------------------- */
.model-pool-dialog { display: flex; flex-direction: column; gap: 8px; }
.model-pool-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.product-toolbar { display: flex; align-items: center; gap: 8px; }
.product-details { display: flex; flex-direction: column; gap: 8px; }

/* -- overview metrics ----------------------------------------------------- */
.overview-hero { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.overview-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.overview-metric { padding: 12px; border-radius: var(--r-card); background: var(--panel); border: 1px solid var(--line-soft); }

/* -- profile view --------------------------------------------------------- */
.profile-section { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.profile-overview { display: flex; align-items: center; gap: 16px; }
.profile-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--panel); display: flex; align-items: center; justify-content: center; }
.profile-identity { display: flex; flex-direction: column; gap: 4px; }
.profile-plan { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: var(--r-pill); font-size: var(--fs-micro); }
.profile-devices { display: flex; flex-direction: column; gap: 8px; }
.profile-engine { display: flex; flex-direction: column; gap: 8px; }

/* -- system & device reference -------------------------------------------- */
.system-reference { display: flex; flex-direction: column; gap: 16px; }
.system-device-detail { display: flex; flex-direction: column; gap: 12px; }
.system-device-select { display: flex; gap: 8px; align-items: center; }
.reference-device-list { display: flex; flex-direction: column; gap: 8px; }
.reference-device-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; }
.reference-device-last { font-size: var(--fs-micro); color: var(--dim); }
.reference-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.reference-metric { padding: 8px; border-radius: var(--r-card); background: var(--panel); }
.device-information { display: flex; flex-direction: column; gap: 6px; }
.detail-list { display: flex; flex-direction: column; gap: 4px; }
.metric-spark { width: 100%; height: 24px; }
.network-reading { display: flex; justify-content: space-between; font-size: var(--fs-small); }

/* -- devices view --------------------------------------------------------- */
.device-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-card); background: var(--panel); border: 1px solid var(--line-soft); }
.device-glyph { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.device-details { display: flex; flex-direction: column; gap: 8px; }
.device-capabilities { display: flex; flex-wrap: wrap; gap: 6px; }

/* -- activity & executions view ------------------------------------------- */
.activity-reference { display: flex; flex-direction: column; gap: 12px; }
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.activity-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.activity-summary { font-size: var(--fs-small); color: var(--ink); }
.activity-time { font-size: var(--fs-micro); color: var(--dim); }

/* -- common filter & task view -------------------------------------------- */
.product-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tasks-product { display: flex; flex-direction: column; gap: 12px; }

/* -- mcp & integrations view ---------------------------------------------- */
.integrations-product { display: flex; flex-direction: column; gap: 16px; }
.integration-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.integration-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--r-card); background: var(--panel); border: 1px solid var(--line-soft); }

/* -- notes view ----------------------------------------------------------- */
.notes-workspace { display: flex; height: 100%; gap: 16px; }
.notes-side { width: 260px; display: flex; flex-direction: column; gap: 12px; }
.notes-main { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.notes-pane { display: flex; flex-direction: column; gap: 8px; }
.notes-reference { display: flex; flex-direction: column; gap: 8px; }
.note-format-toolbar { display: flex; gap: 4px; align-items: center; }
.note-preview { padding: 12px; border-radius: var(--r-card); background: var(--panel); border: 1px solid var(--line-soft); }
.note-check { display: flex; align-items: center; gap: 8px; }
.reference-search { display: flex; align-items: center; gap: 8px; }

/* -- voice view ----------------------------------------------------------- */
.voice-main { display: flex; flex-direction: column; gap: 16px; }
.voice-reference { display: flex; flex-direction: column; gap: 12px; }
.voice-categories { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-check { display: flex; align-items: center; gap: 8px; }
.voice-check-controls { display: flex; gap: 8px; align-items: center; }
.voice-language { display: flex; flex-direction: column; gap: 6px; }
.voice-speed { display: flex; align-items: center; gap: 12px; }
.voice-toggle { display: inline-flex; align-items: center; gap: 8px; }

/* -- settings view -------------------------------------------------------- */
.settings-category-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; }
.settings-panels { display: flex; flex-direction: column; gap: 16px; }

/* ========================================================================== */


