/* ==========================================================================
   Ray - aurora
   Frosted glass over a slow-moving aurora. Colour is semantic, not
   decorative: cyan is primary and live, magenta wants attention, amber warns.
   ========================================================================== */

/* --- tokens --------------------------------------------------------------- */
:root {
  /* ground: two stops the aurora blobs float over */
  --ground-1: #120C2B;
  --ground-2: #1D1150;
  --rack: #120C2B;

  /* aurora light sources */
  --aur-violet:  #7C3AED;
  --aur-cyan:    #22D3EE;
  --aur-magenta: #D946C6;

  /* glass. The base is DARK, not white: a white film would let a bright
     aurora blob push the surface up under the text and wreck contrast. This
     clamps every panel into a narrow band whatever floats behind it. */
  --panel:      rgba(17, 11, 40, 0.62);
  --panel-hi:   rgba(32, 23, 66, 0.72);
  --panel-sink: rgba(9, 6, 24, 0.55);
  --sheen: linear-gradient(155deg, rgba(255,255,255,0.10), rgba(255,255,255,0.015) 58%);
  --rule:       rgba(255, 255, 255, 0.13);
  --rule-soft:  rgba(255, 255, 255, 0.07);
  --spec:       rgba(255, 255, 255, 0.30);   /* specular top edge */
  --blur: blur(22px) saturate(150%);

  /* Floating surfaces: menus, tooltips, toasts. Near-opaque on purpose -
     panel glass is translucent, which vanishes when it lands on another
     card instead of on the page ground. */
  --overlay:        rgba(30, 21, 60, 0.975);
  --overlay-line:   rgba(255, 255, 255, 0.22);
  --overlay-shadow: 0 18px 50px -16px rgba(0, 0, 0, 0.78);

  /* text */
  --ink:       #F4F1FF;
  --label:     #C3BCEA;
  --label-dim: #A79EDA;

  /* accents */
  --signal:  #3DE3F5;   /* primary, live, active */
  --magenta: #FB8AE0;   /* attention, overdue */
  --phos:    #5EEAD4;   /* healthy */
  --warn:    #FCC756;
  --fault:   #FF8FA3;
  --on-signal: #0B0720;  /* text that sits on a filled accent */

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "DM Mono", ui-monospace, "Cascadia Mono", monospace;

  --t-label: 0.6875rem;
  --t-micro: 0.8125rem;
  --t-body:  0.9375rem;
  --t-title: 1.0625rem;

  --rail-w: 70px;
  --r-sm: 8px;
  --r-md: 16px;
  --r-lg: 22px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --glow: 0 8px 32px -12px rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] {
  /* Day: the same aurora, washed out to a pale lilac sky with white glass. */
  --ground-1: #EFEAFB;
  --ground-2: #E4EDFB;
  --rack: #EFEAFB;

  --aur-violet:  #B79CFF;
  --aur-cyan:    #7FD8EC;
  --aur-magenta: #F0A6E0;

  --panel:      rgba(255, 255, 255, 0.74);
  --panel-hi:   rgba(255, 255, 255, 0.88);
  --panel-sink: rgba(255, 255, 255, 0.58);
  --sheen: linear-gradient(155deg, rgba(255,255,255,0.55), rgba(255,255,255,0.12) 58%);
  --rule:       rgba(74, 46, 140, 0.16);
  --rule-soft:  rgba(74, 46, 140, 0.09);
  --spec:       rgba(255, 255, 255, 0.95);
  --blur: blur(18px) saturate(135%);

  --overlay:        rgba(255, 255, 255, 0.985);
  --overlay-line:   rgba(74, 46, 140, 0.30);
  --overlay-shadow: 0 18px 44px -14px rgba(40, 20, 80, 0.40);

  --ink:       #1E1440;
  --label:     #55467F;
  --label-dim: #64548C;

  --signal:  #076576;
  --magenta: #9C2882;
  --phos:    #0B7A63;
  --warn:    #8A5A00;
  --fault:   #C03453;
  --on-signal: #FFFFFF;

  --glow: 0 8px 30px -14px rgba(58, 32, 110, 0.35);
}

/* --- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--ground-1);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }

/* The hidden attribute is only display:none in the user-agent stylesheet, so
   ANY author rule that sets display beats it. Several components here do
   (.btn is inline-flex, .pair-panel is grid, .live-idle is flex), which left
   them visible while marked hidden. This has to win outright. */
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* --- aurora --------------------------------------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    linear-gradient(165deg, var(--ground-1) 0%, var(--ground-2) 55%, var(--ground-1) 100%);
}
.aurora-blob {
  position: absolute;
  display: block;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.42;
  will-change: transform;
}
:root[data-theme="light"] .aurora-blob { opacity: 0.5; filter: blur(80px); }

.aurora-1 {
  top: -26vmax; left: -14vmax;
  background: radial-gradient(circle at 50% 50%, var(--aur-violet) 0%, transparent 68%);
  animation: drift-1 34s ease-in-out infinite alternate;
}
.aurora-2 {
  top: 8vmax; right: -22vmax;
  background: radial-gradient(circle at 50% 50%, var(--aur-cyan) 0%, transparent 68%);
  animation: drift-2 41s ease-in-out infinite alternate;
}
.aurora-3 {
  bottom: -30vmax; left: 22vmax;
  background: radial-gradient(circle at 50% 50%, var(--aur-magenta) 0%, transparent 68%);
  animation: drift-3 47s ease-in-out infinite alternate;
}
@keyframes drift-1 { to { transform: translate3d(14vmax, 10vmax, 0) scale(1.18); } }
@keyframes drift-2 { to { transform: translate3d(-16vmax, 14vmax, 0) scale(0.86); } }
@keyframes drift-3 { to { transform: translate3d(10vmax, -12vmax, 0) scale(1.12); } }

/* Micro label. Now sentence-height and only lightly tracked - the old
   all-caps mono treatment was doing too much shouting. */
.lbl {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--label);
}
.lbl-dim { color: var(--label-dim); }
.lbl-signal { color: var(--signal); }
.lbl-alert { color: var(--magenta); }

/* --- shell ---------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}

/* --- rail ----------------------------------------------------------------- */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 0 18px;
  z-index: 30;
}

.rail-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--signal), var(--aur-violet));
  color: var(--on-signal);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  flex: none;
  box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--signal) 60%, transparent);
  transition: transform 200ms var(--ease);
}
.rail-mark:hover { transform: translateY(-1px) scale(1.04); }

.rail-jacks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail-jacks::-webkit-scrollbar { display: none; }

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
}

/* Each module gets a glass pill on the rail. Active one glows. */
.jack {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--rule);
  color: var(--label);
  cursor: pointer;
  transition: color 180ms var(--ease), background 180ms var(--ease),
              border-color 180ms var(--ease), box-shadow 240ms var(--ease),
              transform 180ms var(--ease);
}
.jack:hover {
  color: var(--ink);
  background: var(--panel-hi);
  transform: translateY(-1px);
}
.jack svg { width: 18px; height: 18px; }

.jack-on {
  color: var(--signal);
  border-color: color-mix(in srgb, var(--signal) 45%, transparent);
  background: color-mix(in srgb, var(--signal) 12%, var(--panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--signal) 22%, transparent),
              0 6px 24px -8px color-mix(in srgb, var(--signal) 70%, transparent);
}

.jack-flag {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-5px);
  padding: 6px 11px;
  background: var(--overlay);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--overlay-line);
  border-radius: 10px;
  box-shadow: var(--overlay-shadow);
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  z-index: 40;
}
.jack:hover .jack-flag,
.jack:focus-visible .jack-flag { opacity: 1; transform: translateY(-50%) translateX(0); }

/* --- main ----------------------------------------------------------------- */
.main { position: relative; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 62px;
  padding: 0 26px;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--ground-1) 72%, transparent),
    transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.topbar-title { display: flex; align-items: baseline; gap: 11px; min-width: 0; }
.topbar-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer { margin-left: auto; }
.topbar-meta { display: flex; align-items: center; gap: 16px; }

/* status pip */
.pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--phos);
  box-shadow: 0 0 10px 0 var(--phos);
  flex: none;
}
.pip-idle { background: var(--label-dim); box-shadow: none; }
.pip-warn { background: var(--warn); box-shadow: 0 0 10px 0 var(--warn); }
.pip-alert { background: var(--magenta); box-shadow: 0 0 10px 0 var(--magenta); }
.pip-live { animation: breathe 3.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.content { padding: 26px 26px 72px; flex: 1; }
.wrap { max-width: 1220px; margin: 0 auto; }

/* --- page head ------------------------------------------------------------ */
.head { margin-bottom: 30px; }
.head-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.head-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4.6vw, 3rem);
  letter-spacing: -0.04em;
  line-height: 1.04;
  margin: 0;
  background: linear-gradient(120deg, var(--ink) 30%, color-mix(in srgb, var(--signal) 75%, var(--ink)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.head-sub { color: var(--label); margin: 12px 0 0; max-width: 56ch; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; flex-wrap: wrap; }

/* --- glass panels --------------------------------------------------------- */
.rack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(282px, 1fr));
  gap: 18px;
}

/* The shared glass surface. ::before carries the specular top edge that makes
   it read as glass rather than a translucent rectangle. */
.panel, .card, .rows, .addbar, .empty, .slot, .gate-panel {
  position: relative;
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: var(--glow);
}
.panel::before, .card::before, .rows::before,
.addbar::before, .gate-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--spec), transparent);
  border-radius: inherit;
  pointer-events: none;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 220ms var(--ease), transform 220ms var(--ease),
              background 220ms var(--ease), box-shadow 220ms var(--ease);
}
.panel-link:hover {
  transform: translateY(-3px);
  background-color: var(--panel-hi);
  border-color: color-mix(in srgb, var(--signal) 42%, var(--rule));
  box-shadow: var(--glow), 0 0 34px -14px color-mix(in srgb, var(--signal) 80%, transparent);
}
.panel-link:hover .panel-go { color: var(--signal); transform: translateX(3px); }
.panel-link:hover .panel-pip { background: var(--signal); box-shadow: 0 0 10px 0 var(--signal); }

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  border-bottom: 1px solid var(--rule-soft);
}
.panel-pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--label-dim);
  transition: background 220ms var(--ease), box-shadow 220ms var(--ease);
  flex: none;
}
.panel-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.panel-port { color: var(--label-dim); }

.panel-body { padding: 20px 18px 18px; flex: 1; }
.panel-tagline { color: var(--label); font-size: var(--t-micro); margin: 0 0 20px; }

.readouts { display: flex; gap: 24px; flex-wrap: wrap; }
.readout { min-width: 0; }
.readout-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.125rem;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  display: block;
  margin-bottom: 7px;
}
.readout-signal { color: var(--signal); text-shadow: 0 0 26px color-mix(in srgb, var(--signal) 55%, transparent); }
.readout-phos { color: var(--phos); }
.readout-muted { color: var(--label-dim); }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 18px;
  border-top: 1px solid var(--rule-soft);
}
.panel-go { color: var(--label); transition: color 220ms var(--ease), transform 220ms var(--ease); }

/* free slot */
.slot {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  min-height: 188px;
  padding: 22px;
  border-style: dashed;
  background-color: transparent;
  background-image: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  color: var(--label);
}
.slot-code {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--signal);
}

/* --- controls ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--rule);
  border-radius: 11px;
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease),
              color 180ms var(--ease), transform 180ms var(--ease),
              box-shadow 180ms var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-hi); border-color: color-mix(in srgb, var(--ink) 24%, var(--rule)); }
.btn:active { transform: translateY(1px); }

.btn-signal {
  background: var(--signal);
  border-color: transparent;
  color: var(--on-signal);
  box-shadow: 0 6px 22px -8px color-mix(in srgb, var(--signal) 85%, transparent);
}
.btn-signal:hover {
  background: color-mix(in srgb, var(--signal) 88%, #fff);
  box-shadow: 0 8px 28px -8px color-mix(in srgb, var(--signal) 95%, transparent);
}

.btn-quiet { background: transparent; border-color: transparent; color: var(--label); backdrop-filter: none; }
.btn-quiet:hover { color: var(--ink); background: var(--panel); border-color: var(--rule); }

.btn-icon { width: 40px; padding: 0; justify-content: center; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 0.8125rem; border-radius: 9px; }
.btn-sm.btn-icon { width: 32px; padding: 0; }
.btn svg { width: 15px; height: 15px; flex: none; }

/* --- fields --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-input,
.field-area,
.field-select {
  width: 100%;
  padding: 11px 15px;
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  border-radius: 11px;
  color: var(--ink);
  transition: border-color 180ms var(--ease), background 180ms var(--ease),
              box-shadow 180ms var(--ease);
}
.field-input::placeholder, .field-area::placeholder { color: var(--label-dim); }
.field-input:focus, .field-area:focus, .field-select:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent);
}
.field-area { min-height: 240px; resize: vertical; font-family: var(--font-body); line-height: 1.7; }
.field-mono { font-family: var(--font-mono); font-size: 0.8125rem; }
.field-row { display: flex; gap: 11px; flex-wrap: wrap; }
.field-grow { flex: 1; min-width: 190px; }

.addbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.addbar .field-input { flex: 1; min-width: 200px; }
.addbar .field-select { width: auto; min-width: 130px; }

/* --- rows ----------------------------------------------------------------- */
/* No overflow clip here. It used to be `overflow: hidden` to stop a row's
   hover background bleeding past the rounded corners, but that also clipped
   any pop-out a row contains - and no z-index escapes an overflow clip.
   Rounding the first and last rows achieves the same thing without trapping
   their children. */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > .row:first-child {
  border-top-left-radius: var(--r-md);
  border-top-right-radius: var(--r-md);
}
.rows > .row:last-child {
  border-bottom-left-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
}
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 160ms var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background-color: var(--panel-hi); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; align-items: center; gap: 11px; margin-top: 5px; flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.row-done .row-title { color: var(--label-dim); text-decoration: line-through; text-decoration-thickness: 1px; }

.tick {
  width: 22px; height: 22px; flex: none;
  border: 1.5px solid var(--rule);
  border-radius: 7px;
  background: var(--panel-sink);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: transparent;
  transition: border-color 180ms var(--ease), background 180ms var(--ease),
              color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.tick:hover { border-color: var(--signal); }
.tick svg { width: 13px; height: 13px; }
.tick-on {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
  box-shadow: 0 0 16px -3px color-mix(in srgb, var(--signal) 80%, transparent);
}

/* --- tags ----------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel-sink);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--label);
  transition: color 160ms var(--ease), border-color 160ms var(--ease),
              background 160ms var(--ease);
}
.tag:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 26%, var(--rule)); }
.tag-on {
  color: var(--signal);
  border-color: color-mix(in srgb, var(--signal) 48%, transparent);
  background: color-mix(in srgb, var(--signal) 13%, transparent);
}
.tags { display: flex; gap: 7px; flex-wrap: wrap; }

/* --- cards ---------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 16px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 18px;
  min-height: 162px;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease),
              background 200ms var(--ease), box-shadow 200ms var(--ease);
}
.card:hover {
  transform: translateY(-3px);
  background-color: var(--panel-hi);
  border-color: color-mix(in srgb, var(--signal) 38%, var(--rule));
  box-shadow: var(--glow), 0 0 30px -14px color-mix(in srgb, var(--signal) 75%, transparent);
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--t-title);
  letter-spacing: -0.02em;
}
.card-excerpt {
  color: var(--label);
  font-size: var(--t-micro);
  line-height: 1.65;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 11px; }

/* --- prose ---------------------------------------------------------------- */
.prose { max-width: 70ch; line-height: 1.75; }
.prose h1, .prose h2, .prose h3 {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
  margin: 1.7em 0 0.5em;
  line-height: 1.22;
  color: var(--ink);
}
.prose h1 { font-size: 1.75rem; font-weight: 700; }
.prose h2 { font-size: 1.375rem; font-weight: 600; }
.prose h3 { font-size: 1.125rem; font-weight: 600; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose a { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  padding: 2px 7px;
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.prose pre {
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 16px;
  overflow-x: auto;
}
.prose pre code { border: 0; padding: 0; background: none; font-size: 0.8125rem; }
.prose blockquote {
  margin: 0 0 1.1em;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--signal);
  color: var(--label);
}
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.prose img { border-radius: var(--r-sm); border: 1px solid var(--rule); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.1em; font-size: var(--t-micro); }
.prose th, .prose td { text-align: left; padding: 9px 13px; border: 1px solid var(--rule); }
.prose th { background: var(--panel-hi); font-weight: 600; color: var(--ink); }

/* --- empty ---------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 13px;
  padding: 52px 30px;
  border-style: dashed;
  background-color: transparent;
  background-image: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  color: var(--label);
}
.empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3125rem;
  color: var(--ink);
  letter-spacing: -0.025em;
}

/* --- flashes -------------------------------------------------------------- */
.flashes {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(370px, calc(100vw - 44px));
}
.flash {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 16px;
  background: var(--overlay);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--overlay-line);
  border-left: 3px solid var(--label-dim);
  border-radius: 13px;
  box-shadow: var(--overlay-shadow);
  font-size: var(--t-micro);
  animation: slide-in 280ms var(--ease);
}
.flash-error { border-left-color: var(--fault); }
.flash-success { border-left-color: var(--phos); }
.flash-info { border-left-color: var(--signal); }
@keyframes slide-in { from { opacity: 0; transform: translateY(10px); } }

/* --- sign in -------------------------------------------------------------- */
.gate { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 26px; }
.gate-panel { width: 100%; max-width: 380px; overflow: hidden; border-radius: var(--r-lg); }
.gate-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  border-bottom: 1px solid var(--rule-soft);
}
.gate-body { padding: 30px 26px 26px; display: flex; flex-direction: column; gap: 17px; }
.gate-mark {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 17px;
  background: linear-gradient(140deg, var(--signal), var(--aur-violet));
  color: var(--on-signal);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.625rem;
  letter-spacing: -0.04em;
  box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--signal) 65%, transparent);
}
.gate-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.035em;
  margin: 14px 0 0;
}
.gate-note { color: var(--label); font-size: var(--t-micro); margin: 0; }

/* --- error ---------------------------------------------------------------- */
.fault-page { display: grid; place-items: center; min-height: 58vh; }
.fault-code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(4.5rem, 16vw, 8rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
  margin-bottom: 14px;
  background: linear-gradient(120deg, var(--magenta), var(--signal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.85;
}

/* --- utility -------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; }
.gap-xs { gap: 6px; }
.gap-sm { gap: 10px; }
.gap-md { gap: 18px; }
.gap-lg { gap: 28px; }
.inline { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.muted { color: var(--label); }
.dim { color: var(--label-dim); }
.mono { font-family: var(--font-mono); font-size: var(--t-label); }
.nowrap { white-space: nowrap; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.divider { height: 1px; background: var(--rule); border: 0; margin: 26px 0; }
.inline-form { display: inline-flex; }

/* --- motion --------------------------------------------------------------- */
.rise { animation: rise 520ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 720px) {
  :root { --rail-w: 0px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--ground-1) 82%, transparent);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border-top: 1px solid var(--rule);
    overflow-x: auto;
  }
  .rail-mark { margin-bottom: 0; }
  .rail-jacks { flex-direction: row; }
  .rail-foot { margin-top: 0; margin-left: auto; flex-direction: row; padding-top: 0; }
  .jack-flag { display: none; }
  .content { padding: 20px 16px 100px; }
  .topbar { padding: 0 16px; height: 56px; }
  .aurora-blob { filter: blur(70px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .panel-link:hover, .card:hover { transform: none; }
  .aurora-blob { animation: none; }
}

/* --- faces ---------------------------------------------------------------- */
.notice {
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, var(--signal) 40%, var(--rule));
  border-left: 3px solid var(--signal);
  border-radius: 13px;
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  font-size: var(--t-micro);
  color: var(--label);
}
.notice strong { color: var(--ink); font-weight: 600; }
.notice a { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.notice-warn { border-left-color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--rule)); }

/* enrolled-photo thumbnails on the people cards */
.face-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 11px;
  overflow: hidden;
  background: var(--panel-sink);
  display: grid;
  place-items: center;
}
.face-thumb img { width: 100%; height: 100%; object-fit: cover; }
.face-thumb-empty { color: var(--label-dim); }

.face-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 14px;
}
.face-card {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.face-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.face-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-top: 1px solid var(--rule-soft);
}

/* the live view: stage on the left, roster on the right */
.live-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}
.live-stage {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: #06040F;
  box-shadow: var(--glow);
  aspect-ratio: 4 / 3;
}
.live-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.live-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--label-dim);
  font-size: var(--t-micro);
  background: var(--panel-sink);
}
.live-side { min-width: 0; }

@media (max-width: 900px) {
  .live-wrap { grid-template-columns: minmax(0, 1fr); }
}

/* --- tabs ----------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 20px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background-color: var(--panel-sink);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--label);
  cursor: pointer;
  white-space: nowrap;
  transition: color 160ms var(--ease), background 160ms var(--ease),
              border-color 160ms var(--ease);
}
.tab:hover { color: var(--ink); }
.tab svg { width: 15px; height: 15px; flex: none; }
.tab-on {
  color: var(--ink);
  background-color: var(--panel-hi);
  border-color: var(--rule);
  box-shadow: 0 2px 10px -4px rgba(0, 0, 0, 0.4);
}

/* --- phone pairing -------------------------------------------------------- */
.pair-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 22px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}

/* The QR has to stay high-contrast to scan, so it keeps a white card in both
   themes rather than inheriting the glass. */
.pair-qr {
  width: 208px;
  height: 208px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 14px;
  background: #FFFFFF;
  box-shadow: 0 8px 26px -12px rgba(0, 0, 0, 0.6);
}
.pair-qr svg { width: 100%; height: 100%; display: block; }
.pair-qr svg path { fill: #0B0720; }
.pair-placeholder { text-align: center; }
.pair-placeholder .lbl { color: #6B6480; }

.pair-steps { min-width: 0; }
.pair-list {
  margin: 0;
  padding-left: 20px;
  color: var(--label);
  font-size: var(--t-micro);
  line-height: 1.75;
}
.pair-list li { margin-bottom: 7px; }
.pair-list strong { color: var(--ink); font-weight: 600; }
#pairUrl {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 620px) {
  .pair-panel { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .pair-steps { width: 100%; }
}

/* --- the phone page ------------------------------------------------------- */
.phone {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 40px;
  min-height: 100svh;
}
.phone-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 4px 14px;
}
.phone-bar-spacer { margin-left: auto; }

.phone-stage {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: #06040F;
  box-shadow: var(--glow);
  aspect-ratio: 3 / 4;
  margin-bottom: 14px;
}
.phone-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.phone-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
/* Big enough to hit with a thumb while holding the phone up. */
.phone-go { height: 52px; font-size: 1rem; justify-content: center; border-radius: 14px; }
.phone-controls .field-select { height: 46px; border-radius: 12px; }

.phone-card {
  margin-top: 12vh;
  padding: 28px 24px;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.phone-card .gate-mark { margin-bottom: 18px; }

/* --- recently seen: enrolled reference vs captured frame ------------------ */
.seen-ref {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  display: grid;
  place-items: center;
  color: var(--label-dim);
  transition: border-color 160ms var(--ease);
}
.seen-ref:hover { border-color: color-mix(in srgb, var(--signal) 55%, var(--rule)); }
.seen-ref img { width: 100%; height: 100%; object-fit: cover; }

/* The captured frame sits at the end of the row, where the eye lands last. */
.seen-shot {
  position: relative;
  width: 68px;
  height: 68px;
  flex: none;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--panel-sink);
  display: grid;
  place-items: center;
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}
.seen-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
a.seen-shot:hover {
  transform: scale(1.04);
  border-color: color-mix(in srgb, var(--signal) 60%, var(--rule));
}
.seen-shot-tag {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 2px 0 3px;
  text-align: center;
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  color: #F4F1FF;
  background: linear-gradient(to top, rgba(8, 5, 22, 0.85), transparent);
}
.seen-shot-none { border-style: dashed; }
.seen-shot-none .lbl { font-size: 0.5625rem; text-align: center; padding: 0 4px; }

@media (max-width: 560px) {
  .seen-shot { width: 54px; height: 54px; }
  .seen-ref { width: 36px; height: 36px; }
}

/* --- guided enrolment ----------------------------------------------------- */
.enrol-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
.enrol-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.enrol-side { min-width: 0; }

/* readiness meter: fills while the frame stays good, then fires */
.meter {
  height: 5px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--label-dim);
  transition: width 220ms var(--ease), background 220ms var(--ease);
}
.meter-good { background: var(--signal); box-shadow: 0 0 12px 0 var(--signal); }
.meter-bad { background: var(--warn); }

.pose-card {
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.pose-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.pose-hint { color: var(--label); font-size: var(--t-micro); margin: 0 0 14px; }

.pose-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule-soft);
  padding-top: 12px;
}
.pose-steps li {
  position: relative;
  padding: 5px 0 5px 24px;
  font-size: var(--t-micro);
  color: var(--label-dim);
  transition: color 160ms var(--ease);
}
/* A hollow ring that fills once the pose is captured. */
.pose-steps li::before {
  content: "";
  position: absolute;
  left: 4px; top: 11px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.pose-steps .pose-on { color: var(--ink); font-weight: 600; }
.pose-steps .pose-on::before {
  border-color: var(--signal);
  box-shadow: 0 0 10px -1px var(--signal);
}
.pose-steps .pose-done { color: var(--label); }
.pose-steps .pose-done::before { background: var(--signal); border-color: var(--signal); }

.shot-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 74px;
  align-items: flex-start;
}
.shot { margin: 0; width: 66px; }
.shot img {
  width: 66px; height: 66px;
  object-fit: cover;
  border-radius: 11px;
  border: 1px solid var(--rule);
  display: block;
}
.shot figcaption { margin-top: 4px; text-align: center; font-size: 0.5625rem; }
.shot-empty { align-self: center; }

@media (max-width: 900px) {
  .enrol-wrap { grid-template-columns: minmax(0, 1fr); }
}
/* The phone shell is already narrow, so never split it. */
.phone .enrol-wrap { grid-template-columns: minmax(0, 1fr); }
.phone .enrol-controls { flex-direction: column; }
.phone .head-title { font-size: 1.75rem; }

/* --- camera picker -------------------------------------------------------- */
.cam-picker { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.cam-picker .field-select { flex: 1; min-width: 0; }
.cam-picker .btn-icon { flex: none; }
/* On the phone the picker sits inside the stacked control column, so it must
   not inherit that column's vertical stacking. */
.phone .phone-controls .cam-picker { margin-top: 0; }
.phone .cam-picker .field-select { height: 46px; border-radius: 12px; }
.phone .cam-picker .btn-icon { height: 46px; width: 46px; border-radius: 12px; }

/* --- on-video coaching ---------------------------------------------------- */
/* Sits over the picture because that is where the person is looking. Nothing
   here takes pointer events, so the canvas underneath is unaffected. */
.stage-prompt-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 26px;
  background: linear-gradient(to bottom, rgba(8, 5, 22, 0.82), transparent);
  pointer-events: none;
  z-index: 3;
}
.stage-step {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #F4F1FF;
}
.stage-prompt {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #FFFFFF;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.65);
}

.stage-hint {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(10, 6, 26, 0.74);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #EDEAFB;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  z-index: 3;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
/* Amber = something for you to change. Cyan = you are doing it right. */
.stage-hint-fix {
  border-color: color-mix(in srgb, var(--warn) 70%, transparent);
  color: #FFE2A6;
}
.stage-hint-good {
  border-color: color-mix(in srgb, var(--signal) 70%, transparent);
  color: #C8F6FF;
}

/* A single white pulse on capture, so it is obvious a shot was taken. */
.stage-flash {
  position: absolute;
  inset: 0;
  background: #FFFFFF;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.stage-flash.flash-on { animation: shutter 420ms var(--ease); }
@keyframes shutter { 0% { opacity: 0.75; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .stage-flash.flash-on { animation: none; }
}

/* --- live capture metrics ------------------------------------------------- */
.metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel-sink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--label);
}
.metric b { font-weight: 500; color: var(--label-dim); }
.metric span { color: var(--ink); font-variant-numeric: tabular-nums; }
/* Whichever number is holding the capture back turns amber. */
.metric-low { border-color: color-mix(in srgb, var(--warn) 60%, transparent); }
.metric-low span, .metric-low b { color: var(--warn); }

/* --- tuning --------------------------------------------------------------- */
.tune {
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.tune-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.tune-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.015em;
  cursor: pointer;
}
.tune-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--signal);
}
.tune-help {
  color: var(--label);
  font-size: var(--t-micro);
  line-height: 1.6;
  margin: 8px 0 16px;
  max-width: 62ch;
}

/* The track is drawn by hand because the default control ignores the palette
   and looks foreign against the glass. */
.tune-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--panel-sink);
  border: 1px solid var(--rule);
  outline: none;
  cursor: pointer;
}
.tune-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--signal);
  border: 2px solid var(--ground-1);
  box-shadow: 0 0 14px -2px var(--signal);
  cursor: grab;
}
.tune-range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--signal);
  border: 2px solid var(--ground-1);
  box-shadow: 0 0 14px -2px var(--signal);
  cursor: grab;
  border-color: var(--ground-1);
}
.tune-range:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }

.tune-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--label-dim);
}
.tune-scale span:first-child { text-align: left; }
.tune-scale span:last-child { text-align: right; }
.tune-default { color: var(--label); text-align: center; white-space: nowrap; }

@media (max-width: 620px) {
  .tune-scale { font-size: 0.5625rem; }
}

/* An unrecognised face has no enrolled photo to show beside it. */
.seen-ref-unknown {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--magenta) 45%, var(--rule));
  color: var(--magenta);
}

/* --- naming an unknown face ----------------------------------------------- */
.name-wrap {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.name-shot {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.name-shot img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 11px;
  display: block;
}
.name-shot figcaption { margin-top: 10px; text-align: center; line-height: 1.5; }
.name-forms { min-width: 0; }

/* The unknown row's own avatar slot, so it does not look like a broken image. */
.seen-ref-unknown { color: var(--magenta); border-style: dashed; }

@media (max-width: 720px) {
  .name-wrap { grid-template-columns: minmax(0, 1fr); }
  .name-shot { max-width: 260px; }
}

/* --- accounts ------------------------------------------------------------- */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
/* Standard accounts get a quieter avatar than managers. */
.seen-ref-plain { border-style: solid; color: var(--label-dim); }

/* The per-user password field is tucked behind a disclosure so the row stays
   readable; opened, it floats over the row rather than reflowing the list. */
.pw-drop { position: relative; }
.pw-drop > summary { list-style: none; cursor: pointer; }
.pw-drop > summary::-webkit-details-marker { display: none; }
/* Hidden until the script re-parents it to <body>; without this an open
   <details> would flash the form in the corner of the page. */
.pw-drop > .pw-pop { display: none; }
/* Positioned with fixed coordinates set by script, not absolutely inside the
   row. An absolutely positioned pop-out is at the mercy of every ancestor:
   an overflow clip hides it, and any later sibling with its own stacking
   context paints over it. Fixed takes it out of that entirely - it cannot be
   clipped or covered by page content whatever the surrounding CSS does. */
.pw-pop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 900;
  display: flex;
  gap: 8px;
  padding: 10px;
  width: max(240px, 18vw);
  border: 1px solid var(--overlay-line);
  border-radius: 12px;
  background: var(--overlay);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--overlay-shadow);
}
.pw-pop .field-input { flex: 1; min-width: 0; }

@media (max-width: 620px) {
  .pw-pop { right: auto; left: 0; width: min(280px, calc(100vw - 60px)); }
}

/* --- module grants -------------------------------------------------------- */
.access-pop {
  flex-direction: column;
  align-items: stretch;
  width: max(210px, 15vw);
  max-height: min(60vh, 380px);
  overflow-y: auto;
}
.access-row { display: flex; gap: 8px; flex-wrap: wrap; }
.access-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel-sink);
  font-size: var(--t-micro);
  cursor: pointer;
  transition: border-color 140ms var(--ease), color 140ms var(--ease);
}
.access-item:hover { border-color: var(--label-dim); }
.access-item input { accent-color: var(--signal); cursor: pointer; }
/* A ticked box reads as granted without needing to inspect the control. */
.access-item input:checked + span { color: var(--ink); font-weight: 600; }
/* Progressive enhancement: browsers with :has() also tint the whole chip. */
.access-item:has(input:checked) {
  border-color: color-mix(in srgb, var(--signal) 55%, transparent);
  color: var(--ink);
}
.access-pop .access-item { border-radius: 10px; justify-content: flex-start; }

/* Flipped above its trigger when there is no room below. */

/* --- ptz pad -------------------------------------------------------------- */
.ptz {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background-color: var(--panel);
  background-image: var(--sheen);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glow);
}
.ptz-pad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 6px;
}
.ptz-key {
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel-sink);
  color: var(--ink);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  /* A held direction must not start a text selection or a long-press menu. */
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 120ms var(--ease), border-color 120ms var(--ease),
              transform 80ms var(--ease);
}
.ptz-key:hover { border-color: color-mix(in srgb, var(--signal) 50%, var(--rule)); }
.ptz-key:active {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
  transform: scale(0.95);
}
.ptz-stop { color: var(--magenta); font-size: 0.75rem; }
.ptz-side { min-width: 0; }

@media (max-width: 620px) {
  .ptz { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .ptz-side { width: 100%; }
}

/* --- push to talk --------------------------------------------------------- */
.talk-btn { width: 100%; justify-content: center; height: 44px; }
/* Live mic is worth making unmissable - it is an open microphone in a room. */
.talk-btn.talk-live {
  background: var(--magenta);
  border-color: var(--magenta);
  color: var(--on-signal);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--magenta) 70%, transparent);
  animation: talk-pulse 1.6s ease-out infinite;
}
@keyframes talk-pulse {
  70% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--magenta) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--magenta) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .talk-btn.talk-live { animation: none; }
}

/* --- event clip viewer --------------------------------------------------- */
/* A native <dialog> rather than a positioned div: the top layer sits above
   every stacking context on the page, which is exactly the problem that made
   the earlier popups so stubborn. */
.clip-box {
  width: min(880px, 92vw);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--overlay-bg, #141821);
  color: var(--ink);
  padding: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.clip-box::backdrop { background: rgba(6, 8, 12, .72); }
.clip-box video {
  width: 100%;
  max-height: 68vh;
  border-radius: var(--r-md);
  background: #000;
  display: block;
}
