/* ============================================================================
   Gemisfera UI — shared design system
   ----------------------------------------------------------------------------
   Quiet, Apple-minimal: one typeface (Vela Sans, the same face the device
   draws), near-neutral surfaces, hairline separators instead of boxes, soft
   depth only where something is raised, and generous space doing the grouping.

   Token names still mirror shadcn/ui (OKLCH) so React components could drop in
   without remapping. Vanilla CSS: the portal has no build step and is rsync'd
   and served raw, including to the Pi.

   Palette rules (see PRODUCT.md):
     · Neutrals are near-neutral (≤0.006 chroma). The installation's colour is
       the device, not the chrome around it.
     · Green is reserved for LIVE STATE. A green pixel that doesn't encode state
       is a bug.
     · Focus is cyan, never green — focus can never be misread as "live".
     · Text tokens are ≥7:1 on --background/--card except --muted-2 (AA,
       peripheral metadata only).
   ========================================================================= */

@font-face { font-family: "Vela Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/VelaSans-regular.woff2") format("woff2"); }
@font-face { font-family: "Vela Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/VelaSans-medium.woff2") format("woff2"); }
@font-face { font-family: "Vela Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/VelaSans-semibold.woff2") format("woff2"); }

:root {
  /* ── Surfaces ─────────────────────────────────────────────────────────── */
  --background:            oklch(0.145 0.004 160);   /* near-black */
  --foreground:            oklch(0.955 0.004 160);   /* 17:1 */

  --card:                  oklch(0.190 0.005 160);
  --card-foreground:       var(--foreground);
  --popover:               oklch(0.215 0.005 160);
  --popover-foreground:    var(--foreground);

  --secondary:             oklch(0.245 0.006 160);   /* control fill */
  --secondary-foreground:  var(--foreground);
  --accent:                oklch(0.285 0.006 160);   /* hover fill */
  --accent-foreground:     oklch(0.985 0.003 160);

  --muted:                 oklch(0.215 0.005 160);
  --muted-foreground:      oklch(0.760 0.008 160);   /* 8:1 on card */

  --fg:        var(--foreground);
  --muted-fg:  var(--muted-foreground);
  --bg:        var(--background);
  --muted-2:               oklch(0.640 0.008 160);   /* AA — peripheral only */

  /* ── Lines ────────────────────────────────────────────────────────────── */
  --border:                oklch(1 0 0 / 0.085);     /* hairline separator */
  --input:                 oklch(1 0 0 / 0.17);      /* control edge */
  --ring:                  oklch(0.860 0.120 210);   /* focus */

  /* ── Brand / state ────────────────────────────────────────────────────── */
  --primary:               oklch(0.790 0.140 152);
  --primary-foreground:    oklch(0.160 0.010 155);
  --destructive:           oklch(0.710 0.170  25);
  --destructive-foreground:oklch(0.160 0.010 155);

  --state-live:            oklch(0.790 0.140 152);
  --state-growing:         oklch(0.860 0.170 150);
  --state-warn:            oklch(0.840 0.140  75);
  --state-info:            oklch(0.800 0.100 240);
  --state-idle:            oklch(0.560 0.006 160);

  /* ── Radius (continuous-feeling, larger than before) ──────────────────── */
  --radius:      12px;
  --radius-sm:   6px;
  --radius-md:   9px;
  --radius-lg:   var(--radius);
  --radius-xl:   18px;

  /* ── Type ─────────────────────────────────────────────────────────────── */
  --text-xs:    0.75rem;    /* 12 — floor */
  --text-sm:    0.8125rem;  /* 13 */
  --text-base:  0.875rem;   /* 14 */
  --text-md:    1rem;       /* 16 */
  --text-lg:    1.1875rem;  /* 19 */
  --text-xl:    1.5rem;     /* 24 */
  --text-2xl:   2rem;       /* 32 */

  --font-sans: "Vela Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Fira Mono", Consolas, monospace;

  /* ── Space (4px base) ─────────────────────────────────────────────────── */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* ── Elevation — soft, and only for things that are actually raised ─── */
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35);
  --shadow-md: 0 12px 32px oklch(0 0 0 / 0.42), 0 2px 6px oklch(0 0 0 / 0.25);
  --highlight: inset 0 1px 0 oklch(1 0 0 / 0.035);

  /* ── Z-index ──────────────────────────────────────────────────────────── */
  --z-base: 0; --z-dropdown: 10; --z-sticky: 20; --z-backdrop: 30;
  --z-modal: 40; --z-toast: 50; --z-tooltip: 60;

  /* ── Motion ───────────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms;
  --dur:      200ms;
}

/* ============================================================================
   Base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.mono, code, kbd, samp { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.btn:focus-visible, .field:focus-visible { outline-offset: 2px; }

::selection { background: color-mix(in oklch, var(--ring) 28%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: oklch(1 0 0 / 0.12); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: oklch(1 0 0 / 0.22); background-clip: padding-box; }

a { color: inherit; }

/* ============================================================================
   Typography — hierarchy by size and weight, never by shouting
   ========================================================================= */
.h1 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.022em; line-height: 1.15; text-wrap: balance; }
.h2 { font-size: var(--text-xl);  font-weight: 600; letter-spacing: -0.016em; line-height: 1.2; text-wrap: balance; }
.h3 { font-size: var(--text-md);  font-weight: 600; letter-spacing: -0.006em; }

.section-title { font-size: var(--text-sm); font-weight: 600; color: var(--foreground); }

.label     { font-size: var(--text-xs); color: var(--muted-foreground); font-weight: 500; }
.value     { font-size: var(--text-sm); color: var(--foreground); }
.value-lg  { font-size: var(--text-lg); color: var(--foreground); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.meta      { font-size: var(--text-xs); color: var(--muted-2); }

/* ============================================================================
   Card — the one bounded container. Never nest; group inside with space.
   ========================================================================= */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--highlight);
}

.stack   { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-2 { display: flex; flex-direction: column; gap: var(--space-2); }
.row     { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.sep     { flex: 1; }

/* ============================================================================
   Button — filled, borderless, quiet until hovered
   ========================================================================= */
.btn {
  --btn-bg: var(--secondary);
  --btn-fg: var(--secondary-foreground);
  --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 32px; padding: 0 var(--space-3);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--text-sm); font-weight: 500; letter-spacing: -0.003em;
  cursor: pointer; white-space: nowrap; user-select: none; text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled)  { background: var(--accent); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { --btn-bg: var(--primary); --btn-fg: var(--primary-foreground); font-weight: 600; }
.btn-primary:hover:not(:disabled)  { background: color-mix(in oklch, var(--primary) 90%, white); }
.btn-ghost    { --btn-bg: transparent; --btn-fg: var(--muted-foreground); }
.btn-ghost:hover:not(:disabled) { --btn-fg: var(--foreground); background: var(--secondary); }
.btn-danger   { --btn-bg: transparent; --btn-fg: var(--destructive); --btn-bd: color-mix(in oklch, var(--destructive) 35%, transparent); }
.btn-danger:hover:not(:disabled) { background: color-mix(in oklch, var(--destructive) 14%, transparent); border-color: var(--destructive); }

.btn-sm  { min-height: 28px; padding: 0 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }

.btn[aria-pressed="true"] {
  --btn-bg: color-mix(in oklch, var(--foreground) 14%, var(--card));
  --btn-fg: var(--accent-foreground);
  --btn-bd: oklch(1 0 0 / 0.14);
}

.btn-group { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* ============================================================================
   Badge / status
   ========================================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 99px;
  font-size: var(--text-xs); font-weight: 500; line-height: 1.6;
  background: var(--secondary); color: var(--muted-foreground);
  border: 1px solid transparent;
}
.badge-live  { background: color-mix(in oklch, var(--state-live) 15%, transparent); color: var(--state-live); }
.badge-info  { background: color-mix(in oklch, var(--state-info) 15%, transparent); color: var(--state-info); }

/* Colour is never the only channel — always pair a dot with a word. */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--state-idle); flex: none; }
.dot-live  { background: var(--state-live);  box-shadow: 0 0 0 3px color-mix(in oklch, var(--state-live) 18%, transparent); }
.dot-warn  { background: var(--state-warn); }
.dot-error { background: var(--destructive); }

/* ============================================================================
   Form controls
   ========================================================================= */
.field {
  min-height: 32px; width: 100%;
  padding: 0 var(--space-3);
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-out);
}
.field:hover { border-color: var(--input); }
select.field { cursor: pointer; padding-right: var(--space-5); }
.field::placeholder { color: var(--muted-2); }

/* Slider: a thin track and a raised white thumb. 24px hit area, 4px visual. */
input[type=range].slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent; cursor: pointer;   /* taller = bigger drag area */
}
input[type=range].slider::-webkit-slider-runnable-track {
  height: 7px; border-radius: 99px; background: oklch(1 0 0 / 0.16);
}
input[type=range].slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -8px;
  border-radius: 50%; background: var(--foreground);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.5), 0 0 0 0.5px oklch(0 0 0 / 0.2);
  transition: transform var(--dur-fast) var(--ease-out);
}
input[type=range].slider:hover::-webkit-slider-thumb { transform: scale(1.1); }
input[type=range].slider:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type=range].slider::-moz-range-track { height: 7px; border-radius: 99px; background: oklch(1 0 0 / 0.16); }
input[type=range].slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--foreground); box-shadow: 0 1px 3px oklch(0 0 0 / 0.5);
}

/* Slider on its own full-width line, with label + value stacked above it. */
.slider-field { display: flex; flex-direction: column; gap: 5px; }
.slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.slider-head .cp-val { text-align: right; flex: none; }
.slider-head .label { white-space: nowrap; }

/* ============================================================================
   Log / console output
   ========================================================================= */
.log {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--muted-foreground);
  overflow-y: auto;
}
.log-line { display: flex; gap: var(--space-2); }
.log-time { color: var(--muted-2); flex: none; }
.log-error { color: var(--destructive); }
.log-warn  { color: var(--state-warn); }

/* ============================================================================
   Layout
   ========================================================================= */
.app { min-height: 100vh; display: flex; flex-direction: column; }
/* Translucent bar: content scrolls under it rather than behind a slab. */
.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--background) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  position: sticky; top: 0; z-index: var(--z-sticky); flex-wrap: wrap; row-gap: var(--space-2);
}
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--space-8) var(--space-6); }

/* Simulator work layout — device(s) beside their controls. The rail sticks while
   the devices scroll; below 1100px it drops under them. */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 29rem; gap: var(--space-8); align-items: start; }
.rail { position: sticky; top: calc(var(--space-12) + var(--space-4)); max-height: calc(100vh - 6.5rem); overflow-y: auto; padding-right: var(--space-2); }
@media (max-width: 1100px) {
  .work { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; overflow: visible; padding-right: 0; }
}
@media (max-width: 640px) { .container { padding: var(--space-5) var(--space-4); } .topbar { padding: var(--space-3) var(--space-4); } }

/* ============================================================================
   Fold — a collapsible section. Summary is the heading; the chevron is the only
   chrome. Used to dose detail: essentials open, the rest one click away.
   ========================================================================= */
.fold { border-top: 1px solid var(--border); }
.fold:first-child { border-top: 0; }
.fold > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) 0; font-size: var(--text-sm); font-weight: 600;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: ''; margin-left: auto; width: 7px; height: 7px; flex: none;
  border-right: 1.5px solid var(--muted-2); border-bottom: 1.5px solid var(--muted-2);
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease-out);
}
.fold[open] > summary::after { transform: rotate(45deg); }
.fold > summary .meta { font-weight: 400; }
.fold > summary:hover::after { border-color: var(--foreground); }
.fold-body { display: flex; flex-direction: column; gap: var(--space-3); padding: 0 0 var(--space-4); }

/* ============================================================================
   Side tabs — vertical navigation for a panel with several groups. Collapses
   to a horizontal, scrollable segmented row when there is no room for a column.
   ========================================================================= */
.sidetabs { display: flex; flex-direction: column; gap: 2px; }
.sidetab {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 34px; padding: 0 var(--space-3); text-align: left;
  border: 0; border-radius: var(--radius-md); background: transparent;
  color: var(--muted-foreground); font: inherit; font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sidetab:hover { color: var(--foreground); background: oklch(1 0 0 / 0.04); }
.sidetab[aria-selected="true"] { color: var(--foreground); background: var(--secondary); }
.sidetab .count { margin-left: auto; font-size: var(--text-xs); color: var(--muted-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .dot-live { box-shadow: none; }
}

/* ============================================================================
   Control panel component — mounted by the simulator pages.
   ========================================================================= */
.cp { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.cp-head { display: flex; align-items: center; gap: var(--space-2); }

/* Always-visible status: health + clock, whichever tab is open. */
.cp-status { display: flex; align-items: center; gap: var(--space-2); min-height: 20px; }

/* Segmented control — the iOS pattern: a quiet track, the selected segment raised. */
.cp-tabs {
  display: flex; gap: 2px; padding: 2px;
  background: oklch(1 0 0 / 0.06);
  border-radius: var(--radius-md);
}
.cp-full .cp-tabs { max-width: 520px; }
.cp-tab {
  flex: 1 1 0; min-width: 0; min-height: 30px; padding: 0 var(--space-2);
  border: 0; background: transparent; color: var(--muted-fg);
  font-family: inherit; font-size: var(--text-sm); font-weight: 500;
  border-radius: 7px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.cp-tab:hover { color: var(--fg); }
.cp-tab[aria-selected="true"] { background: var(--accent); color: var(--fg); box-shadow: var(--shadow-sm); }
.cp-tab:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.cp-panels { min-width: 0; }
.cp-tabpanel { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.cp-full .cp-tabpanel { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-4); align-items: start; }
.cp-tabpanel[hidden] { display: none !important; }
.cp-tabpanel:focus-visible { outline: none; }

.cp-sec-head { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.cp-sec-head .meta { margin-left: auto; }

/* Label / control / readout. Fixed readout column so numbers don't jitter. */
.cp-row { display: grid; grid-template-columns: 5.5rem 1fr 5rem; align-items: center; gap: var(--space-3); }
.cp-lab { white-space: nowrap; }
.cp-val { text-align: right; font-size: var(--text-sm); color: var(--muted-fg); }
.cp-check { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.cp-check input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }

.cp-seeds { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-2); }
.cp-seed { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; height: auto; padding: var(--space-2) var(--space-3); }
.cp-seed .meta { font-weight: 400; }

.cp-offline .cp-panels { opacity: 0.5; pointer-events: none; }

@media (max-width: 520px) { .cp-row { grid-template-columns: 1fr; } .cp-val { text-align: left; } }

/* ── Visual control surfaces ────────────────────────────────────────────────
   State shown as pictures: a gauge read by its fill, a day arc read by the sun,
   scenario tiles read by their art. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: var(--space-2); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  align-items: flex-start; justify-content: flex-end;
  min-height: 80px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card); color: var(--fg); cursor: pointer; text-align: left;
  overflow: hidden; transition: border-color var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.tile:hover { border-color: oklch(1 0 0 / 0.22); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.tile:active { transform: translateY(0) scale(.985); }
.tile:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.tile-art { position: absolute; inset: 0; opacity: .38; pointer-events: none; }
.tile-art svg { width: 100%; height: 100%; display: block; }
.tile::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top,
    color-mix(in oklch, var(--card) 94%, transparent) 0%,
    color-mix(in oklch, var(--card) 76%, transparent) 48%,
    transparent 100%);
}
.tile-name, .tile-sub { z-index: 1; position: relative; }
.tile-name { font-size: var(--text-sm); font-weight: 600; letter-spacing: -0.005em; }
.tile-sub { font-size: var(--text-xs); color: var(--muted-fg); }
.tile.is-on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* Vitality gauge — the four bands painted into the track. */
.gauge { display: flex; flex-direction: column; gap: var(--space-2); }
.gauge-track {
  position: relative; height: 24px; border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer;
  background: linear-gradient(90deg,
    color-mix(in oklch, var(--destructive) 30%, transparent) 0 15%,
    color-mix(in oklch, var(--state-warn) 24%, transparent) 15% 35%,
    color-mix(in oklch, var(--state-live) 16%, transparent) 35% 65%,
    color-mix(in oklch, var(--state-live) 30%, transparent) 65% 100%);
}
.gauge-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  border-right: 2px solid var(--fg);
  box-shadow: 2px 0 8px color-mix(in oklch, var(--fg) 40%, transparent);
  transition: width .4s var(--ease-out);
  pointer-events: none; z-index: 2;
}
@property --fill { syntax: '<percentage>'; inherits: true; initial-value: 72%; }
.gauge-track { transition: --fill .4s var(--ease-out); }
.gauge-track::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: color-mix(in oklch, var(--bg) 70%, transparent);
  clip-path: inset(0 0 0 var(--fill, 72%));
}
.gauge-ticks { position: absolute; inset: 0; pointer-events: none; }
.gauge-ticks i { position: absolute; top: 0; bottom: 0; width: 1px; background: oklch(0 0 0 / 0.35); }
.gauge-head { display: flex; align-items: baseline; gap: var(--space-2); }
.gauge-band { font-weight: 600; font-size: var(--text-md); letter-spacing: -0.01em; text-transform: capitalize; }
.gauge-num { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted-fg); font-size: var(--text-sm); }

/* Day arc — the clock as a shape. */
.dayarc { position: relative; height: 62px; }
.dayarc svg { display: block; width: 100%; height: 100%; overflow: visible; }
.dayarc input[type=range] { position: absolute; inset: auto 0 -2px 0; width: 100%; margin: 0; }

/* Autopilot pill: who is driving the weather. */
.pilot { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.pilot-state {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600;
  background: var(--secondary);
}
.pilot-auto   { color: var(--state-live); background: color-mix(in oklch, var(--state-live) 14%, transparent); }
.pilot-manual { color: var(--state-warn); background: color-mix(in oklch, var(--state-warn) 14%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .tile, .gauge-fill, .gauge-track { transition: none; }
  .tile:hover { transform: none; }
}

/* Compact variant: the panel in the simulator's rail. */
.cp-compact .cp-row { grid-template-columns: 4.75rem 1fr 4rem; gap: var(--space-2); }
.cp-compact .cp-sec-head .meta { display: none; }

/* Studio navigation — the one switch between the four-device view and a single
   device, styled as a quiet segmented control made of links. */
.brand { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.01em; }
.studio-nav { display: flex; gap: 2px; padding: 2px; border-radius: var(--radius-md); background: oklch(1 0 0 / 0.06); }
.studio-nav a {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-3);
  border-radius: 7px; font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground);
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.studio-nav a:hover { color: var(--foreground); }
.studio-nav a[aria-current="page"] { background: var(--accent); color: var(--foreground); box-shadow: var(--shadow-sm); }
@media (max-width: 640px) { .studio-nav { order: 10; width: 100%; overflow-x: auto; } }

/* Panel layout: side tabs beside the active group. The tab column is narrow and
   sticky; below 520px it becomes a scrolling row above the content. */
.cp-split { display: grid; grid-template-columns: 5.75rem minmax(0, 1fr); gap: var(--space-4); align-items: start; }
/* Wide mode (compact:false): the active group's folds flow into as many columns
   as the width allows (via .cp-full .cp-tabpanel grid above), so a big display
   shows everything at once instead of one tall scrolling rail. */
.cp-full .cp-split { grid-template-columns: 10rem minmax(0, 1fr); }
.cp-split .sidetabs { position: sticky; top: 0; }
/* Global scope (main page) has a single group — drop the lone side tab. */
.cp-split-global { grid-template-columns: 1fr; }
.cp-split-global .sidetabs { display: none; }
.cp-lede { margin-bottom: var(--space-1); }
@media (max-width: 520px) {
  .cp-split { grid-template-columns: 1fr; }
  .cp-split .sidetabs { flex-direction: row; overflow-x: auto; position: static; }
}

/* Flat mode (opts.flat): no tabs — every fold becomes a delineated cell and the
   whole set packs into balanced columns, so an operator sees the entire control
   surface at once. Used by the session console. Columns are CSS multi-column with
   break-inside:avoid; each cell is a hairline card so the grid reads at a glance. */
.cp-masonry { columns: 248px auto; column-gap: var(--space-3); }
.cp-masonry > .fold {
  break-inside: avoid; -webkit-column-break-inside: avoid;
  margin: 0 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card); padding: 0 var(--space-3);
}
.cp-masonry > .fold > summary { padding-block: var(--space-3); }
.cp-masonry > .fold[open] > summary { padding-bottom: var(--space-2); }
.cp-masonry > .fold > .fold-body { padding: 0 0 var(--space-3); gap: var(--space-2); }
.cp-masonry .gauge-track { height: 22px; }
.cp-masonry .dayarc { margin: var(--space-1) 0; }

/* Sessions: compact rows instead of a wide table, so the rail stays readable. */
.cp-list { display: flex; flex-direction: column; }
.cp-item { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 4px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cp-item:last-child { border-bottom: 0; }
.cp-devices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1) var(--space-3); }
.cp-dev { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.cp-dev .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-val .btn { min-height: 22px; padding: 0 6px; }
