/*
  Ember — components, v3. Depends on tokens.css + reset.css.

  House rules for this file:
  - Tokens only: no literal colours, sizes or durations.
  - Mode-safe: nothing assumes a dark ground. Accent roles: text and links
    use --color-accent / --color-ember(-bright); labelled fills use
    --color-accent-fill + --color-on-accent, unlabelled marks (checked
    controls, active bars) --color-accent-mark; washes --color-ember-muted.
    In light mode the primary button and checked toggle are solid fills (a
    wash there reads as disabled or as the danger wash).
  - Use the `border: <w> solid <colour>` shorthand, never a bare border-color.
  - Every animated component has a prefers-reduced-motion fallback (bottom).
  - Status modifiers come in canonical names (ok/info/warn/danger/quarantine/
    idle) plus the v2 aliases (ready/preview/standby/live/hygiene).

  Sections: layout · sidebar · header · heads · surfaces · status ·
  buttons · forms · tabs · table · overlays · empty/skeleton ·
  touch · reduced motion.
*/

/* ==================================================================== */
/* Layout                                                                */
/* ==================================================================== */

.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;            /* iOS address bar collapse */
  display: flex;
  flex-direction: column;
  transition: margin-left var(--duration-base) var(--ease-standard);
}
.app-shell.sidebar-pinned { margin-left: var(--sidebar-w-open); }

.page {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-6);
}

/* Vertical rhythm by gap, not margins: no collapse surprises. */
.stack { display: flex; flex-direction: column; gap: var(--space-10); }
.stack--tight { gap: var(--space-3); }

/* Neutral grid: fills the width, rows start at the top. */
.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-4);
  align-content: start;
  align-items: start;           /* panels keep their own height: no stretched voids */
}
/* v2 name for the neutral grid; kept so existing markup keeps working. */
.cardgrid--dense { max-width: none; padding: 0; margin: 0; }
/* Router-homepage showcase: capped, centred, fills the shell's height. */
.cardgrid--showcase {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-5);
  padding: var(--space-6);
  max-width: 1120px;
  margin: 0 auto;
  justify-content: center;
  align-content: center;
  flex: 1 1 auto;
  width: 100%;
}

.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
.formgrid__full { grid-column: 1 / -1; }

/* ==================================================================== */
/* Sidebar — one <nav>, three regimes                                    */
/* Desktop >=1024: 56px rail, hover-expands, pinnable (pushes content).  */
/* Tablet 768-1023: rail, .is-open overlays, never pushes.               */
/* Phone <768: the same element re-laid-out as a bottom tab bar.         */
/* ==================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-bg-raised);
  border-right: 1px solid var(--color-border-default);
  z-index: var(--z-sidebar);
  overflow: hidden;
  transition: width var(--duration-base) var(--ease-standard);
  display: flex;
  flex-direction: column;
  padding: var(--space-3) 0;
}
.sidebar:hover,
.sidebar:focus-within,
.sidebar.is-pinned { width: var(--sidebar-w-open); }
.sidebar:hover:not(.is-pinned) { box-shadow: var(--shadow-lg); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: calc(var(--header-h) - var(--space-3));
  padding: 0 var(--space-4) var(--space-3) 18px;  /* 18px centres a 20px mark in the 56px rail */
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
  white-space: nowrap;
  color: var(--color-accent-fill);
}
.sidebar__brand-label {
  font-family: var(--font-display);
  font-size: var(--font-size-display-md);
  letter-spacing: var(--letter-spacing-display);
  color: var(--color-text-primary);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.sidebar__pin {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard), color var(--duration-fast);
}
.sidebar__pin:hover { color: var(--color-accent); background: var(--color-bg-surface); }
.sidebar.is-pinned .sidebar__pin { color: var(--color-accent); transform: scaleX(-1); }

.sidebar__nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-1) var(--space-2);  /* room for the focus ring: overflow clips it otherwise */
  overflow-x: hidden;            /* hidden labels are ~220px wide; avoid a stray scrollbar */
  overflow-y: auto;
}
.sidebar__foot {
  margin-top: auto;
  padding: var(--space-2) var(--space-2) 0;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-h);
  padding: var(--space-2) 11px;  /* 11px + 18px icon + 11px = centred in the 40px inner rail */
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.sidebar__item:hover { background: var(--color-bg-surface); color: var(--color-text-primary); }
.sidebar__item.is-active {
  background: var(--color-ember-muted);
  color: var(--color-ember-bright);
  box-shadow: inset 2px 0 0 var(--color-accent-mark);
}
.sidebar__item-label {
  font-size: var(--font-size-sm);
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard);
}
/* Labels hide with opacity (screen readers still read them); stop clicks
   landing on an invisible label in the collapsed rail. */
.sidebar:not(:hover):not(.is-pinned) .sidebar__item-label { pointer-events: none; }

.sidebar:hover .sidebar__brand-label,
.sidebar:hover .sidebar__pin,
.sidebar:hover .sidebar__item-label,
.sidebar.is-pinned .sidebar__brand-label,
.sidebar.is-pinned .sidebar__pin,
.sidebar.is-pinned .sidebar__item-label,
.sidebar:focus-within .sidebar__brand-label,
.sidebar:focus-within .sidebar__pin,
.sidebar:focus-within .sidebar__item-label { opacity: 1; }   /* keyboard walk expands the rail */

.sidebar__scrim { display: none; }
.sidebar__item--more { display: none; }

/* Touch has no hover: a tap would leave the rail stuck open. */
@media (hover: none) {
  .sidebar:hover:not(.is-pinned):not(:focus-within) { width: var(--sidebar-w); box-shadow: none; }
  .sidebar:hover:not(.is-pinned):not(:focus-within) .sidebar__item-label,
  .sidebar:hover:not(.is-pinned):not(:focus-within) .sidebar__brand-label,
  .sidebar:hover:not(.is-pinned):not(:focus-within) .sidebar__pin { opacity: 0; }
}

@media (max-width: 1023px) and (min-width: 768px) {
  .sidebar.is-pinned { width: var(--sidebar-w); }
  .app-shell,
  .app-shell.sidebar-pinned { margin-left: var(--sidebar-w); }
  .sidebar.is-open { width: var(--sidebar-w-open); }
  .sidebar.is-open .sidebar__item-label,
  .sidebar.is-open .sidebar__brand-label { opacity: 1; }
  .sidebar.is-open ~ .sidebar__scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1); background: var(--color-bg-overlay); }
}

@media (max-width: 767px) {
  .sidebar,
  .sidebar:hover,
  .sidebar.is-pinned {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 0 env(safe-area-inset-bottom);
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--color-border-default);
    box-shadow: none;
    overflow: visible;
  }
  .sidebar__foot { display: none; }
  /* The app mark moves to the left of the header (the rail is now the tab bar): a phone's first
     screen still says which app this is. Fixed, so no template change; .appheader leaves room. */
  .sidebar__brand {
    position: fixed;
    top: 0;
    left: 0;
    height: var(--header-h);
    margin: 0;
    padding: 0 0 0 var(--space-3);
    border: none;
  }
  .sidebar__brand-label,
  .sidebar__pin { display: none; }
  .sidebar__nav { flex-direction: row; align-items: stretch; gap: 0; padding: 0; width: 100%; overflow: visible; }
  .sidebar__item {
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--tabbar-h);
    padding: var(--space-1);
    border-radius: 0;
  }
  .sidebar__item.is-active { box-shadow: inset 0 2px 0 var(--color-accent-mark); }
  .sidebar__item-label,
  .sidebar:not(:hover):not(.is-pinned) .sidebar__item-label {
    opacity: 1;
    font-size: var(--font-size-2xs);
    line-height: 1;
    pointer-events: auto;
  }
  .sidebar__item--secondary { display: none; }
  .sidebar__item--more { display: flex; }

  /* "More": the bar grows upward into a sheet listing everything. */
  .sidebar.is-expanded {
    height: auto;
    max-height: 80dvh;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-expanded .sidebar__nav { flex-direction: column; }
  .sidebar.is-expanded .sidebar__item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: 48px;
    padding: var(--space-2) var(--space-4);
  }
  .sidebar.is-expanded .sidebar__item-label { font-size: var(--font-size-sm); }
  .sidebar.is-expanded .sidebar__item--secondary { display: flex; }
  .sidebar.is-expanded .sidebar__foot { display: flex; padding: var(--space-2) 0; }

  .app-shell,
  .app-shell.sidebar-pinned { margin-left: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .page { padding: var(--space-4) var(--space-3); }
}

/* ==================================================================== */
/* Header — status · clocks · bell                                       */
/* ==================================================================== */

.appheader {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
  height: var(--header-h);
  padding: 0 var(--space-6);
  background: var(--color-bg-raised);
  border-bottom: 1px solid var(--color-border-default);
}
.appheader__side { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.appheader__side--right { justify-content: flex-end; }

.clocklist { display: flex; align-items: center; justify-content: center; gap: var(--space-5); }
.clock { display: flex; flex-direction: column; line-height: 1.2; }
/* Fixed-width time box (start-aligned, wider than "00:00:00" in every look's face and its
   fallback): the web-font swap and the first tick never move the clocks (CLS 0). */
.clock__label {
  font-size: var(--font-size-2xs);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}
.clock__time { min-inline-size: 5em; font-size: var(--font-size-sm); color: var(--color-text-primary); font-variant-numeric: tabular-nums; }

.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}
.bell:hover { background: var(--color-bg-surface); color: var(--color-text-primary); }
.bell__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--color-danger);
  box-shadow: 0 0 0 2px var(--color-bg-raised);
  display: none;
}
/* Hard on/off flash — a physical warning light, not a fade. */
.bell.has-warning .bell__badge { display: block; animation: bell-flash 0.9s steps(1) infinite; }
@keyframes bell-flash { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.2; } }

@media (max-width: 767px) {
  .appheader { grid-template-columns: auto 1fr auto; padding: 0 var(--space-3); gap: var(--space-2); }
  .sidebar ~ .app-shell .appheader { padding-left: calc(var(--space-3) * 2 + 20px); }   /* room for the fixed app mark */
  .clocklist { gap: var(--space-3); justify-content: flex-end; }
  .clock:nth-child(n+2) { display: none; }   /* one clock next to the app mark at 390px */
  .appheader__side:first-child .tally { font-size: 0; gap: 0; }  /* dot shape only; the word stays in the DOM for AT */
}

/* ==================================================================== */
/* Page + section heads                                                  */
/* ==================================================================== */

.pagehead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}
.pagehead__title {
  font-family: var(--font-display);
  font-size: var(--font-size-display-xl);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  margin: 0;
}
.pagehead__meta { font-size: var(--font-size-sm); color: var(--color-text-secondary); }
/* Every action here is .btn--sm, or the row outgrows the title's line box
   and the title drops a few px against other pages. */
.pagehead__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.sectionhead {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.sectionhead__title {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.sectionhead__count { font-size: var(--font-size-xs); color: var(--color-text-tertiary); font-variant-numeric: tabular-nums; }
.sectionhead__rule { flex: 1 1 auto; height: 1px; background: var(--color-border-subtle); }

@media (max-width: 767px) {
  .pagehead { margin-bottom: var(--space-6); }
  .pagehead__actions { margin-left: 0; width: 100%; }
}

/* ==================================================================== */
/* Surfaces — panel, card, kv, code, stat                                */
/* ==================================================================== */

.panel {
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  background: var(--color-bg-surface);
  min-width: 0;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border-subtle);
}
.panel__title {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0;
  color: var(--color-text-primary);
}
/* Optional. Rows that manage their own padding (tables, track lists) sit
   directly in .panel instead. */
.panel__body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); }
.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-raised);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.panel--error { border: 1px solid var(--color-danger); }
.panel > .dtable { margin: 0; }

.panelhead { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* Card: a padded surface. Neutral by default — no fixed height, no hover. */
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
.card--auto { height: auto; overflow: visible; }   /* v2 name; now the default */
/* Router-homepage tile: uniform height, body clamps. */
.card--tile { height: 300px; overflow: hidden; }
/* Only things you can click lift and glow. */
a.card:hover,
button.card:hover,
.card--link:hover {
  border: 1px solid var(--color-accent);
  box-shadow: var(--shadow-glow-ember);
  transform: translateY(-2px);
}
a.card:hover .card__cta,
.card--link:hover .card__cta { color: var(--color-ember-bright); }

.card__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--color-bg-raised);
  border-radius: var(--radius-md);
  color: var(--color-ember);
  margin-bottom: var(--space-4);
}
.card__eyebrow {
  font-size: var(--font-size-2xs);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}
.card__title {
  font-family: var(--font-display);
  font-size: var(--font-size-display-lg);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-2);
}
.card__body {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-loose);
  margin: 0;
}
.card--tile .card__body {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: auto;
  padding-top: var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 22px;
  font-size: var(--font-size-sm);
}
.kvlist { display: flex; flex-direction: column; gap: var(--space-1); }
.kv__key { color: var(--color-text-secondary); flex-shrink: 0; }
.kv__value {
  color: var(--color-text-primary);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Inline code chip — paths, device nodes, ids. */
.code {
  display: inline-block;
  max-width: 100%;
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--color-bg-sunken);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat__value {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.stat__value small { font-size: 0.55em; font-weight: var(--font-weight-regular); color: var(--color-text-secondary); }
.stat__label {
  font-size: var(--font-size-2xs);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.stat--hero .stat__value { font-size: var(--font-size-2xl); }
.statrow { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-8); }

.pxicon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  image-rendering: pixelated;
}
canvas[data-pixel-icon] { image-rendering: pixelated; display: block; }

/* ==================================================================== */
/* Status — six states, each = colour + shape/icon + word                */
/* .tally   LIVE state that changes while you watch (dot shape + word)   */
/* .pill    STATIC attribute (icon + word, boxed)                        */
/* .statustext  colour-coded inline value; always pair with words        */
/* .banner  persistent inline message · .toast transient message         */
/* .meter   progress / capacity                                          */
/* ==================================================================== */

/* Per-state custom properties, set once; every component reads --st / --st-muted. */
.tally, .pill, .statustext, .banner, .toast, .meter { --st: var(--color-idle); --st-muted: var(--color-idle-muted); }

:is(.tally, .pill, .statustext, .banner, .toast, .meter):is([class*="--ok"], [class*="--ready"]) { --st: var(--color-ok); --st-muted: var(--color-ok-muted); }
:is(.tally, .pill, .statustext, .banner, .toast, .meter):is([class*="--info"], [class*="--preview"]) { --st: var(--color-info); --st-muted: var(--color-info-muted); }
:is(.tally, .pill, .statustext, .banner, .toast, .meter):is([class*="--warn"], [class*="--standby"]) { --st: var(--color-warn); --st-muted: var(--color-warn-muted); }
:is(.tally, .pill, .statustext, .banner, .toast, .meter):is([class*="--danger"], [class*="--live"], .statustext--bad) { --st: var(--color-danger); --st-muted: var(--color-danger-muted); }
:is(.tally, .pill, .statustext, .banner, .toast, .meter):is([class*="--quarantine"], [class*="--hygiene"]) { --st: var(--color-quarantine); --st-muted: var(--color-quarantine-muted); }

/* ---- tally: shaped dot + uppercase word ----
   ok ● circle · info ■ square · warn ▲ triangle · danger ◆ diamond ·
   quarantine ◆ hazard-striped diamond · idle ○ ring.
   Shapes survive greyscale and every colour-vision type. */
.tally {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-text-secondary);
}
.tally__dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: var(--st);
  border-radius: var(--radius-full);
}
.tally:not(.tally--idle) { color: var(--st); }
.tally:is([class*="--info"], [class*="--preview"]) .tally__dot { border-radius: 1px; width: 9px; height: 9px; }
.tally:is([class*="--warn"], [class*="--standby"]) .tally__dot { border-radius: 0; width: 11px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tally:is([class*="--danger"], [class*="--live"]) .tally__dot { border-radius: 0; width: 11px; height: 11px; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.tally:is([class*="--quarantine"], [class*="--hygiene"]) .tally__dot {
  border-radius: 0; width: 12px; height: 12px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: var(--pattern-quarantine);
}
.tally--idle .tally__dot,
.tally:not([class*="tally--"]) .tally__dot { background: transparent; border: 2px solid var(--color-idle); }

/* Something is happening right now. Opt-in; stepped like a physical lamp. */
.tally--pulse .tally__dot { animation: tally-blink 1.2s var(--ease-blink) infinite; }
@keyframes tally-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---- pill: boxed static attribute ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 20px;
  padding: 1px var(--space-2);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  background: var(--color-bg-raised);
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.pill[class*="pill--"] { border: 1px solid var(--st); background: var(--st-muted); color: var(--st); }
.pill:is(.pill--quarantine, .pill--hygiene) { border-style: dashed; }   /* held, provisional */
.pill--ember { --st: var(--color-ember-bright); --st-muted: var(--color-ember-muted); }

/* ---- statustext ---- */
.statustext[class*="statustext--"], [class*="statustext--"] { color: var(--st); }
.statustext--danger, .statustext--bad { font-weight: var(--font-weight-medium); }
/* statustext-- classes may sit on non-.statustext elements (a stat value, a td). */
[class*="statustext--ok"] { --st: var(--color-ok); }
[class*="statustext--info"] { --st: var(--color-info); }
[class*="statustext--warn"] { --st: var(--color-warn); }
[class*="statustext--danger"], .statustext--bad { --st: var(--color-danger); }
[class*="statustext--quarantine"] { --st: var(--color-quarantine); }
[class*="statustext--idle"] { --st: var(--color-idle); }

/* ---- banner: persistent inline message ---- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-bg-raised);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}
.banner[class*="banner--"] {
  border: 1px solid color-mix(in srgb, var(--st) 55%, transparent);
  background: var(--st-muted);
}
.banner:is(.banner--quarantine, .banner--hygiene) { border-style: dashed; }
.banner__icon { flex-shrink: 0; margin-top: 2px; color: var(--st); }
.banner__body { min-width: 0; color: var(--color-text-primary); }
.banner__title { display: block; color: var(--st); font-weight: var(--font-weight-medium); }
.banner:not([class*="banner--"]) .banner__title { color: var(--color-text-primary); }

/* ---- toast: transient, top-right (above the tab bar on phones) ---- */
.toaststack {
  position: fixed;
  top: calc(var(--header-h) + var(--space-3));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: min(380px, calc(100vw - var(--space-8)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-raised);
  box-shadow: var(--shadow-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  pointer-events: auto;
  animation: toast-in var(--duration-slow) var(--ease-standard);
}
.toast[class*="toast--"] { border: 1px solid color-mix(in srgb, var(--st) 55%, var(--color-border-strong)); }
.toast__icon { flex-shrink: 0; margin-top: 2px; color: var(--st); }
.toast__body { flex: 1 1 auto; min-width: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---- meter: progress / capacity ----
   The width transition is load-bearing: with SSE patching the same element,
   it is what makes the bar glide instead of teleport. */
.meter {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-sunken);
  border: 1px solid var(--color-border-default);
  overflow: hidden;
  --st: var(--color-info);
}
.meter__fill {
  height: 100%;
  width: 0;
  background: var(--st);
  /* width glides (SSE updates); a state change flips, it doesn't fade */
  transition: width var(--duration-slow) var(--ease-standard), background var(--duration-base) var(--ease-step);
}
.meter:is(.meter--quarantine, .meter--hygiene) .meter__fill { background: var(--pattern-quarantine); }
/* Shape cue so a full red bar never reads like a full green one:
   danger is segmented, quarantine striped, the rest solid. */
.meter:is(.meter--danger, .meter--live) .meter__fill {
  background-image: repeating-linear-gradient(90deg, transparent 0 6px, var(--color-danger-muted) 6px 8px);
}
.meter--idle .meter__fill { background: var(--color-idle); }
/* Unknown total: a slow sweep, never a fake value. */
.meter--indeterminate .meter__fill {
  width: 35%;
  background: var(--color-idle);
  animation: meter-sweep 1.6s var(--ease-sweep) infinite;
}
@keyframes meter-sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.meter__label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}
.meter__label b { font-weight: var(--font-weight-medium); color: var(--color-text-primary); }

/* ==================================================================== */
/* Buttons                                                               */
/* plain .btn = the workhorse (row actions) · --primary = ONE per view · */
/* --danger = destructive · --ghost = low emphasis · --sm in pageheads   */
/* ==================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-raised);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition:
    background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}
.btn:hover { border: 1px solid var(--color-border-control); background: var(--color-bg-surface); color: var(--color-text-primary); }
.btn:active { transform: translateY(1px); }

.btn--primary { border: 1px solid var(--color-ember); background: var(--color-ember-muted); color: var(--color-ember-bright); }
.btn--primary:hover { border: 1px solid var(--color-accent-fill-hover); background: var(--color-accent-fill); color: var(--color-on-accent); }
[data-theme="light"] .btn--primary { border: 1px solid var(--color-accent-fill); background: var(--color-accent-fill); color: var(--color-on-accent); }
[data-theme="light"] .btn--primary:hover { border: 1px solid var(--color-accent-fill-hover); background: var(--color-accent-fill-hover); }

.btn--danger { border: 1px solid var(--color-danger); background: var(--color-danger-muted); color: var(--color-danger); }
.btn--danger:hover { border: 1px solid var(--color-danger); background: var(--color-danger); color: var(--color-text-inverse); }

.btn--ghost { border: 1px solid transparent; background: transparent; color: var(--color-text-secondary); }
.btn--ghost:hover { border: 1px solid var(--color-border-default); background: var(--color-bg-raised); color: var(--color-text-primary); }

.btn--sm { min-height: var(--control-h-sm); padding: var(--space-1) var(--space-3); font-size: var(--font-size-xs); gap: var(--space-1); }
.btn--icon { padding: 0; width: var(--control-h); }
.btn--sm.btn--icon { width: var(--control-h-sm); }
.btn--block { width: 100%; }

.btn[disabled],
.btn.is-disabled {
  border: 1px solid var(--color-border-subtle);
  background: transparent;
  color: var(--color-text-tertiary);   /* readable label, clearly inert: no fill, faint edge */
  cursor: not-allowed;
  pointer-events: none;
}

/* In flight: full strength (dimming reads as disabled) plus a blinking
   pixel after the label. Stepped in Ember (--ease-blink): an indicator switching. */
.btn.is-busy { pointer-events: none; cursor: progress; }
.btn.is-busy::after {
  content: "";
  width: 6px;
  height: 6px;
  background: currentColor;
  animation: btn-busy 0.8s var(--ease-blink) infinite;
}
@keyframes btn-busy { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Two-click confirm, armed state (see js/ember-shell.js data-confirm).
   Also read by the poll guard: while .is-confirming exists inside an HTMX
   target, the swap is skipped so a refresh cannot cancel the prompt. */
.btn.is-confirming,
.btn.is-confirming:hover { border: 1px solid var(--color-danger); background: var(--color-danger); color: var(--color-text-inverse); }

/* ==================================================================== */
/* Forms                                                                 */
/* ==================================================================== */

.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field__label {
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.field__hint { font-size: var(--font-size-xs); color: var(--color-text-tertiary); }
.field__error { font-size: var(--font-size-xs); color: var(--color-danger); }
.field__error::before { content: "◆ "; font-size: 0.8em; }   /* danger's diamond: shape cue, not colour alone */

.input,
.select {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-md);
  background: var(--color-bg-canvas);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-tight);
  transition: border-color var(--duration-fast) var(--ease-standard);
}
textarea.input { line-height: var(--line-height-normal); resize: vertical; }
.input::placeholder { color: var(--color-text-tertiary); }
.input:hover,
.select:hover { border: 1px solid var(--color-text-tertiary); }
.input:focus-visible,
.select:focus-visible,
.input:focus,
.select:focus { border: 1px solid var(--color-ember); outline: none; box-shadow: var(--shadow-focus-ring); }
.input[aria-invalid="true"],
.select[aria-invalid="true"] { border: 1px solid var(--color-danger); }
.input[disabled],
.select[disabled] { border: 1px solid var(--color-border-subtle); color: var(--color-text-tertiary); background: transparent; cursor: not-allowed; }
.input--mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: var(--letter-spacing-wide); }

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-text-secondary) 50%),
    linear-gradient(135deg, var(--color-text-secondary) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* .input/.select are width:100% for stacked .field use. In an inline filter
   bar give the bar's controls `width: auto` or they stretch the row. */

/* Label wrapping a checkbox / radio / toggle. */
.choice {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  cursor: pointer;
}
.choice.is-disabled { color: var(--color-text-disabled); cursor: not-allowed; }

.checkbox,
.radio {
  appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  border: 1px solid var(--color-border-control);
  background: var(--color-bg-canvas);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.checkbox { border-radius: var(--radius-sm); }
.radio { border-radius: var(--radius-full); }
.checkbox:hover,
.radio:hover { border: 1px solid var(--color-ember); }
.checkbox:checked,
.radio:checked { border: 1px solid var(--color-accent-mark); background: var(--color-accent-mark); }
.checkbox:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--color-on-accent);
  border-bottom: 2px solid var(--color-on-accent);
  transform: translateY(-1px) rotate(-45deg);
}
.radio:checked::after { content: ""; width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--color-on-accent); }

.toggle {
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-sm);
  background: var(--color-bg-canvas);
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--color-text-tertiary);
  transition: transform var(--duration-fast) var(--ease-standard), background var(--duration-fast);
}
.toggle:checked { border: 1px solid var(--color-accent-mark); background: var(--color-ember-muted); }
.toggle:checked::after { transform: translateX(16px); background: var(--color-accent-mark); }
[data-theme="light"] .toggle:checked:not([disabled]) { background: var(--color-accent-mark); }
[data-theme="light"] .toggle:checked:not([disabled])::after { background: var(--color-on-accent); }

.checkbox[disabled],
.radio[disabled] { border: 1px solid var(--color-border-default); background: var(--color-bg-sunken); cursor: not-allowed; }
.toggle[disabled] { border: 1px solid var(--color-border-subtle); background: transparent; cursor: not-allowed; }  /* dashed = quarantine only */
.toggle[disabled]::after { background: var(--color-text-disabled); }

/* Range (seek, volume): sunken track, mark fill up to the thumb (Blink: --range-pct from ember-shell.js), square thumb */
.range {
  appearance: none;
  width: 100%;
  height: var(--control-h-sm);
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range::-moz-range-track { height: 4px; border-radius: var(--radius-sm); background: var(--color-bg-sunken); border: 1px solid var(--color-border-default); }
.range::-moz-range-progress { height: 4px; border-radius: var(--radius-sm); background: var(--color-accent-mark); }
.range::-moz-range-thumb { width: 12px; height: 12px; border: 1px solid var(--color-accent-fill-hover); border-radius: var(--radius-sm); background: var(--color-accent-mark); }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: var(--radius-sm); background: linear-gradient(to right, var(--color-accent-mark) var(--range-pct, 0%), var(--color-bg-sunken) 0); border: 1px solid var(--color-border-default); }
.range::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; margin-top: -5px; border: 1px solid var(--color-accent-fill-hover); border-radius: var(--radius-sm); background: var(--color-accent-mark); }
.range:focus-visible { outline: none; }
.range:focus-visible::-moz-range-thumb { box-shadow: var(--shadow-focus-ring); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--shadow-focus-ring); }
.range[disabled] { cursor: not-allowed; }
.range[disabled]::-moz-range-progress { background: var(--color-text-disabled); }
.range[disabled]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--color-text-disabled) var(--range-pct, 0%), var(--color-bg-sunken) 0); }
.range[disabled]::-moz-range-thumb { border-color: var(--color-border-default); background: var(--color-text-disabled); }
.range[disabled]::-webkit-slider-thumb { border-color: var(--color-border-default); background: var(--color-text-disabled); }

/* ==================================================================== */
/* Tabs                                                                  */
/* ==================================================================== */

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border-default);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.tabs__item:hover { color: var(--color-text-primary); background: var(--color-bg-raised); }
.tabs__item.is-active,
.tabs__item[aria-selected="true"] { color: var(--color-text-primary); box-shadow: inset 0 -2px 0 var(--color-accent-mark); }
.tabs__item[disabled] { color: var(--color-text-disabled); cursor: not-allowed; background: transparent; }
.tabs__count {
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-bg-raised);
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xs);
  font-variant-numeric: tabular-nums;
}

/* ==================================================================== */
/* Table — collapses to stacked cards under 768px.                       */
/* Every <td> needs data-label="Column" for the collapsed layout.        */
/* ==================================================================== */

.dtable { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); font-variant-numeric: tabular-nums; }
.dtable th {
  height: 36px;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border-default);
  background: var(--color-bg-surface);
  text-align: left;
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.dtable td {
  height: 44px;
  padding: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-primary);
  vertical-align: middle;
}
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr { transition: background var(--duration-fast); }
.dtable tbody tr:hover { background: var(--color-bg-raised); }
.dtable tbody tr.is-active { background: var(--color-bg-raised); box-shadow: inset 2px 0 0 var(--color-accent-mark); }
.dtable__num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable th.dtable__num { text-align: right; }
.dtable__actions { width: 1%; text-align: right; white-space: nowrap; }
.dtable--dense td { height: 32px; padding: 2px var(--space-3); }
.dtable--sticky th { position: sticky; top: var(--header-h); z-index: 1; }

@media (max-width: 767px) {
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; width: 100%; }
  .dtable thead { display: none; }
  .dtable tr {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border-default);
  }
  .dtable tbody tr:last-child { border-bottom: none; }
  .dtable td,
  .dtable--dense td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    height: auto;
    min-height: 28px;
    border-bottom: none;
    padding: 2px 0;
    text-align: right;
  }
  .dtable td[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--color-text-secondary);
    font-size: var(--font-size-2xs);
    letter-spacing: var(--letter-spacing-wide);
    text-transform: uppercase;
    text-align: left;
  }
  /* The first cell is the card's title: no label, full width, stronger. */
  .dtable td:first-child { justify-content: flex-start; text-align: left; font-weight: var(--font-weight-medium); }
  .dtable td:first-child::before { content: none; }
  .dtable td.dtable__actions { width: 100%; justify-content: flex-end; padding-top: var(--space-2); }
  .dtable td.dtable__actions::before { content: none; }

  /* Opt-in .dtable--list: a compact row for list-like tables (recordings, jobs). Title left, the
     .dtable__status cell and the actions right on the same line, every other cell on one meta line
     below (values only, joined with a dot). About half the height of the label/value card. */
  .dtable--list tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-3); row-gap: var(--space-1); }
  .dtable--list tr::after { content: ""; order: 5; flex-basis: 100%; }
  .dtable--list td,
  .dtable--list.dtable--dense td { display: block; width: auto; min-height: 0; padding: 0; text-align: left; }
  .dtable--list td[data-label]::before { content: none; }
  .dtable--list td:first-child { flex: 1 1 auto; min-width: min(14ch, 100%); overflow-wrap: anywhere; }  /* a floor: status + actions wrap below first */
  .dtable--list td.dtable__status { order: 1; }
  .dtable--list td.dtable__actions { order: 2; width: auto; margin-left: auto; padding-top: 0; }
  .dtable--list td:not(:first-child):not(.dtable__status):not(.dtable__actions) {
    order: 9;
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
  }
  .dtable--list td:not(:first-child):not(.dtable__status):not(.dtable__actions) ~ td:not(.dtable__status):not(.dtable__actions)::before {
    content: "·";
    margin-right: var(--space-3);   /* matches the column gap on its left */
    color: var(--color-text-tertiary);
  }
}

/* ==================================================================== */
/* Overlays — modal (sheet on phones)                                    */
/* Policy: inline first. A modal only for a decision that must block     */
/* (destructive confirm with typed input, a dump to read). Two-click     */
/* .is-confirming for everyday destructive row actions. Never confirm(). */
/* ==================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal.is-open { display: flex; }
.modal__scrim { position: absolute; inset: 0; background: var(--color-bg-overlay); }
.modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 80dvh;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-surface);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--duration-slow) var(--ease-standard);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
.modal__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
}
.modal__title { font-family: var(--font-display); font-size: var(--font-size-display-lg); margin: 0; }
.modal__sub { font-size: var(--font-size-xs); color: var(--color-text-secondary); margin: var(--space-1) 0 0; }
.modal__close { margin-left: auto; }
.modal__body { flex: 1 1 auto; overflow-y: auto; padding: var(--space-5); }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-bg-raised);
}
.modal__pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-loose);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
@media (max-width: 767px) {
  .modal--sheet { align-items: flex-end; padding: 0; }
  .modal--sheet .modal__panel {
    max-width: none;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal--sheet .modal__foot > .btn { flex: 1 1 0; }
  .toaststack {
    top: auto;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-3));
    left: var(--space-3);
    right: var(--space-3);
    width: auto;
  }
}

/* ==================================================================== */
/* Empty + loading                                                       */
/* ==================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-6);
  border: 1px dashed var(--color-border-default);
  border-radius: var(--radius-lg);
  text-align: center;
}
.empty__icon { color: var(--color-text-tertiary); margin-bottom: var(--space-1); }
.empty__text { font-family: var(--font-display); font-size: var(--font-size-display-md); color: var(--color-text-primary); }
.empty__hint { font-size: var(--font-size-sm); color: var(--color-text-secondary); max-width: 46ch; }

.skel {
  background: var(--color-border-subtle);  /* a visible step on surface in every look and mode (raised is too close in Seedling) */
  border-radius: var(--radius-sm);
  animation: skel-pulse 1.2s var(--ease-standard) infinite;
}
.skel--line { height: 10px; }
.skel--card { height: 180px; }
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* ==================================================================== */
/* Theme toggle — three-way light / dark / system group (wired by       */
/* ember-shell.js; inert when <html> carries data-theme-lock)           */
/* ==================================================================== */

.themetoggle {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-md);
  background: var(--color-bg-sunken);
}
.themetoggle button {
  height: calc(var(--control-h-sm) - 6px);
  min-height: 24px;                /* WCAG 2.5.8 target size on fine pointers too */
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast);
}
.themetoggle button:hover { background: var(--color-bg-raised); color: var(--color-text-primary); }
.themetoggle button[aria-pressed="true"] { background: var(--color-accent-fill); color: var(--color-on-accent); }
.themetoggle button:disabled { cursor: not-allowed; }
.themetoggle button:disabled:not([aria-pressed="true"]) { color: var(--color-text-disabled); background: transparent; }

/* ==================================================================== */
/* Touch — coarse pointers get 44px targets everywhere                   */
/* ==================================================================== */

@media (pointer: coarse) {
  .btn, .btn--sm, .input, .select, .tabs__item, .bell { min-height: var(--control-h-touch); }
  .btn--icon, .btn--sm.btn--icon, .bell { width: var(--control-h-touch); }
  .choice { min-height: var(--control-h-touch); }
  .themetoggle button { min-height: calc(var(--control-h-touch) - 6px); }
  .checkbox, .radio { width: 22px; height: 22px; }
  .toggle { width: 44px; height: 26px; }
  .toggle::after { width: 20px; height: 20px; }
  .toggle:checked::after { transform: translateX(18px); }
  .input, .select { font-size: 16px; }   /* stops iOS zoom-on-focus */
}

/* ==================================================================== */
/* Reduced motion — keep the state, drop the movement                    */
/* ==================================================================== */

@media (prefers-reduced-motion: reduce) {
  .tally--pulse .tally__dot,
  .btn.is-busy::after,
  .skel,
  .toast,
  .modal__panel { animation: none; }
  .bell.has-warning .bell__badge { animation: none; opacity: 1; }
  .meter__fill { transition: none; }
  .meter--indeterminate .meter__fill { animation: none; width: 100%; opacity: 0.5; }
  .sidebar, .app-shell, .card { transition: none; }
  a.card:hover, .card--link:hover { transform: none; }
}
