/* Hand-written stylesheet for the PlayGuard SPA. Self-hosted only: no
 * external fonts, no CDN imports (CSP style-src 'self'). Sized for phones
 * (~380px) first; a single media query switches the card list to a grid on
 * desktop. */

* {
  box-sizing: border-box;
}

:root {
  --hud-bg: #0a0f0e;
  --hud-panel: #0f1715;
  --hud-panel-2: #121c19;
  --hud-line: #1e2c28;
  --hud-ink: #e9f5ee;
  --hud-dim: #8fa89b;
  --hud-faint: #5c7268;
  --hud-accent: #3dff9e;
  --hud-accent-soft: rgba(61, 255, 158, 0.14);
  --hud-accent-glow: rgba(61, 255, 158, 0.3);
  --hud-warn: #ffc24b;
  --hud-warn-soft: rgba(255, 194, 75, 0.14);
  --hud-warn-glow: rgba(255, 194, 75, 0.3);
  --hud-hot: #ff4d61;
  --hud-hot-soft: rgba(255, 77, 97, 0.14);
  --hud-hot-glow: rgba(255, 77, 97, 0.32);
  --hud-cool: #4bd8ff;
  --hud-cool-soft: rgba(75, 216, 255, 0.13);
  --hud-cool-glow: rgba(75, 216, 255, 0.3);
  --hud-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hud-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The page itself is dark (body.hud-theme); the stage only spaces the
 * cards. */
.hud-stage {
  padding: 16px 0 40px;
  color: var(--hud-ink);
}

.hud-message {
  margin: 0;
  color: var(--hud-dim);
  text-align: center;
}

.hud-device-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hud-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0;
  overflow: hidden;
  padding: 18px 18px 20px;
  border: 1px solid var(--hud-line);
  border-radius: 6px;
  background-color: var(--hud-panel);
  box-shadow: none;
}

.hud-card::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(0deg, rgba(233, 245, 238, 0.018) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.hud-swarm {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud-card > :not(.hud-swarm) {
  position: relative;
  z-index: 1;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 2px;
}

.hud-mark {
  color: var(--hud-dim);
  font-weight: 700;
}

.hud-player {
  overflow: hidden;
  padding: 3px 7px;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  color: var(--hud-dim);
  letter-spacing: 1.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-live {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--hud-dim);
  letter-spacing: 1.5px;
}

.hud-live-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hud-accent);
}

.hud-live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--hud-accent);
  border-radius: 50%;
  opacity: 0;
  animation: hud-ping 2.4s ease-out infinite;
}

@keyframes hud-ping {
  0% { transform: scale(0.5); opacity: 0.9; }
  70% { transform: scale(1.4); opacity: 0; }
  100% { opacity: 0; }
}

.hud-banner {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.hud-banner-chip {
  padding: 7px 16px 7px 20px;
  border: 1px solid;
  border-radius: 4px;
  font-family: var(--hud-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
}

.hud-banner.hud-tone-ok .hud-banner-chip {
  border-color: var(--hud-accent);
  background: var(--hud-accent-soft);
  box-shadow: 0 0 22px var(--hud-accent-glow);
  color: var(--hud-accent);
}

.hud-banner.hud-tone-warn .hud-banner-chip {
  border-color: var(--hud-warn);
  background: var(--hud-warn-soft);
  box-shadow: 0 0 22px var(--hud-warn-glow);
  color: var(--hud-warn);
}

.hud-banner.hud-tone-hot .hud-banner-chip {
  border-color: var(--hud-hot);
  background: var(--hud-hot-soft);
  box-shadow: 0 0 22px var(--hud-hot-glow);
  color: var(--hud-hot);
}

.hud-banner.hud-tone-cool .hud-banner-chip {
  border-color: var(--hud-cool);
  background: var(--hud-cool-soft);
  box-shadow: 0 0 22px var(--hud-cool-glow);
  color: var(--hud-cool);
}

.hud-hero {
  margin-top: 20px;
  text-align: center;
}

.hud-hero-label {
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 3px;
}

.hud-hero-clock {
  margin-top: 6px;
  color: var(--hud-ink);
  font-family: var(--hud-mono);
  font-size: clamp(56px, 19vw, 84px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 0 26px var(--hud-accent-glow);
}

.hud-hero-warn .hud-hero-clock {
  color: var(--hud-warn);
  text-shadow: 0 0 26px var(--hud-warn-glow);
}

.hud-hero-hot .hud-hero-clock {
  color: var(--hud-hot);
  text-shadow: 0 0 30px var(--hud-hot-glow);
  animation: hud-pulse 1s ease-in-out infinite;
}

.hud-hero-cool .hud-hero-clock {
  color: var(--hud-cool);
  text-shadow: 0 0 26px var(--hud-cool-glow);
}

.hud-hero-dead .hud-hero-clock {
  color: var(--hud-hot);
  opacity: 0.75;
  text-shadow: none;
}

@keyframes hud-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.hud-hero-sub {
  min-height: 18px;
  margin-top: 10px;
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 12px;
  letter-spacing: 2px;
}

.hud-meters {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.hud-meter-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
}

.hud-meter-value {
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hud-bar {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  background: var(--hud-panel-2);
}

.hud-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--hud-accent);
  box-shadow: 0 0 14px var(--hud-accent-glow);
  transition: width 0.4s ease;
}

.hud-bar.hud-tone-warn .hud-bar-fill {
  background: var(--hud-warn);
  box-shadow: 0 0 14px var(--hud-warn-glow);
}

.hud-bar.hud-tone-hot .hud-bar-fill {
  background: var(--hud-hot);
  box-shadow: 0 0 14px var(--hud-hot-glow);
}

.hud-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 14px, var(--hud-bg) 14px 16px);
  pointer-events: none;
}

.hud-meter-secondary .hud-meter-row {
  color: var(--hud-faint);
}

.hud-meter-secondary .hud-meter-value {
  color: var(--hud-dim);
}

.hud-meter-secondary .hud-bar {
  height: 12px;
}

.hud-meter-secondary .hud-bar-fill {
  opacity: 0.32;
  box-shadow: none;
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.hud-stat {
  padding: 6px 10px;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  background: var(--hud-panel-2);
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
}

.hud-stat b {
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.hud-strip {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--hud-line);
}

.hud-strip-cap {
  margin-bottom: 10px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-align: center;
}

.hud-strip-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 46px;
}

.hud-strip-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.hud-strip-value {
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: #2a4a3c;
}

.hud-strip-col.hud-today .hud-strip-value {
  background: var(--hud-accent);
  box-shadow: 0 0 10px var(--hud-accent-glow);
}

.hud-strip-col.hud-future .hud-strip-value {
  opacity: 0.35;
}

.hud-strip-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 6px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
}

.hud-strip-days .hud-today {
  color: var(--hud-accent);
  font-weight: 700;
}

.hud-strip-error {
  margin: 8px 0 0;
  color: var(--hud-warn);
  font-family: var(--hud-mono);
  font-size: 10px;
  text-align: center;
}

.hud-hint {
  margin: 18px 0 0;
  color: var(--hud-dim);
  font-family: var(--hud-sans);
  font-size: 13px;
  text-align: center;
}

@media (min-width: 720px) {
  .hud-card {
    max-width: 640px;
    padding: 28px 36px 30px;
  }

  .hud-hero-clock {
    font-size: 96px;
  }

  .hud-bar {
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud-hero-hot .hud-hero-clock,
  .hud-live-dot::after {
    animation: none;
  }

  .hud-bar-fill {
    transition: none;
  }
}

/* -- Material 3 dark theme (admin + login) --------------------------------
 * Tokens follow the M3 baseline dark scheme; components approximate M3
 * shapes (filled cards, filled/outlined buttons, filter chips, primary
 * tabs, 16dp slider tracks with bar handles). Self-hosted: no fonts. */

:root {
  /* High-emphasis surfaces read as the kid HUD signature green (--hud-accent)
   * so admin and kid share one accent. --md-primary-dim carries the HUD's
   * quiet normal-bar green so week-chart/timeline "today"/"ongoing" (bright
   * green) still stand out against normal (dark green). */
  --md-primary: #3dff9e;
  --md-on-primary: #0a0f0e;
  --md-primary-dim: #2a4a3c;
  --md-primary-container: #23392f;
  --md-on-primary-container: #c8f0d2;
  /* M3 secondary-container repurposed to a quiet green: the only admin
   * surfaces it paints (the info .note banner) must not read lavender in
   * the green re-theme. */
  --md-secondary-container: #23392f;
  --md-on-secondary-container: #c8f0d2;
  --md-tertiary: #3dff9e;
  --md-on-tertiary: #0a0f0e;
  --md-surface: #141218;
  --md-surface-container-low: #1d1b20;
  --md-surface-container: #211f26;
  --md-surface-container-high: #2b2930;
  --md-surface-container-highest: #36343b;
  --md-on-surface: #e6e0e9;
  --md-on-surface-variant: #cac4d0;
  --md-outline: #938f99;
  --md-outline-variant: #49454f;
  --md-error: #f2b8b5;
  --md-error-container: #8c1d18;
  --md-on-error-container: #f9dedc;
  --md-ok: #6dd58c;
  --md-ok-container: #1f4c31;
  --md-on-ok-container: #c8f0d2;
  --md-warn: #ffcf86;
  --md-warn-container: #4a3800;
  --md-on-warn-container: #ffdf9e;
}

body {
  font: 16px/1.5 Roboto, -apple-system, system-ui, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 1100px;
  padding: 12px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  -webkit-font-smoothing: antialiased;
}

/* -- login ------------------------------------------------------------- */

main.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

form.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}

/* -- app shell ----------------------------------------------------------- */

main.app {
  display: block;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

header.top h1 {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

/* M3 primary tabs: divider under the row, rounded 3dp indicator. */
nav.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--md-outline-variant);
}

nav.tabs button {
  position: relative;
  flex: 1;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--md-on-surface-variant);
  padding: 12px 8px 14px;
  font-weight: 500;
  cursor: pointer;
}

nav.tabs button:hover {
  background: rgba(61, 255, 158, 0.08);
  border-radius: 8px 8px 0 0;
}

nav.tabs button.active {
  color: var(--md-primary);
}

nav.tabs button.active::after {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--md-primary);
}

/* -- cards (M3 filled card) --------------------------------------------------- */

.card {
  background: var(--md-surface-container);
  border-radius: 16px;
  padding: 20px;
  margin: 0 0 12px;
  width: 100%;
}

.card h1 {
  font-size: 1.4rem;
  font-weight: 500;
  margin: 0 0 16px;
}

.card h2 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

section.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.grid .card {
  margin: 0;
}

/* Desktop: cards side by side, wider gutters. */
@media (min-width: 900px) {
  body {
    padding: 24px;
  }

  section.grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
}

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

input,
button,
select,
textarea {
  font: inherit;
  color: var(--md-on-surface);
}

input[type="text"],
input[type="password"],
select,
textarea {
  padding: 10px 12px;
  border: 1px solid var(--md-outline);
  border-radius: 8px;
  background: transparent;
}

select {
  background: var(--md-surface-container-high);
}

select option {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: -1px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-primary);
}

/* M3 filled button. */
button {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: 0;
  border-radius: 999px;
  padding: 10px 24px;
  font-weight: 500;
  cursor: pointer;
}

button:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

button:disabled {
  background: rgba(230, 224, 233, 0.12);
  color: rgba(230, 224, 233, 0.38);
  cursor: default;
  box-shadow: none;
}

/* M3 outlined button. */
button.ghost {
  background: none;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
  padding: 8px 18px;
}

button.ghost:hover {
  background: rgba(61, 255, 158, 0.08);
  box-shadow: none;
}

button.ghost:disabled {
  background: none;
  color: rgba(230, 224, 233, 0.38);
  border-color: rgba(230, 224, 233, 0.12);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
}

label.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-on-surface-variant);
  font-size: 0.9rem;
}

/* Wide enough to keep the week label readable; wraps onto its own row on
 * phones instead of getting crushed next to the device picker. */
.week-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 0;
}

.week-picker select {
  flex: 1;
  min-width: 0;
}

button.arrow {
  padding: 8px 16px;
  font-weight: 700;
}

/* -- text states ------------------------------------------------------------------ */

.error {
  color: var(--md-error);
  margin: 0 0 8px;
}

.muted {
  color: var(--md-on-surface-variant);
}

.small {
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.big {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 4px 0;
}

.big.yes {
  color: var(--md-ok);
}

.big.no {
  color: var(--md-on-surface-variant);
}

.status-body p {
  margin: 4px 0;
}

/* -- badges, alerts, overrides ---------------------------------------------------- */

.badge {
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge.playing {
  background: var(--md-ok-container);
  color: var(--md-on-ok-container);
}

.badge.idle {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
}

.badge.offline {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}

/* Build skew (spec WP3): amber like the override notices -- worth a look,
   not an emergency. */
.badge.skew {
  background: var(--md-warn-container);
  color: var(--md-on-warn-container);
}

.alert {
  background: var(--md-error-container);
  border-left: 4px solid var(--md-error);
  color: var(--md-on-error-container);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
}

.override {
  background: var(--md-warn-container);
  border-left: 4px solid var(--md-warn);
  color: var(--md-on-warn-container);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 600;
}

/* -- progress bars -------------------------------------------------------------------- */

.meter {
  margin: 10px 0;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.progress {
  background: var(--md-surface-container-highest);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  background: var(--md-primary);
  height: 100%;
  border-radius: 999px;
}

.progress-fill.full {
  background: var(--md-error);
}

/* -- week chart ---------------------------------------------------------------------------- */

svg.chart {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 4px auto;
}

svg.chart .axis {
  stroke: var(--md-outline-variant);
  stroke-width: 1;
}

svg.chart .bar {
  fill: var(--md-primary-dim);
}

svg.chart g.today .bar {
  fill: var(--md-tertiary);
}

svg.chart text {
  font-family: inherit;
  font-size: 12px;
  fill: var(--md-on-surface-variant);
}

svg.chart .value {
  font-size: 11px;
}

svg.chart g.today .day {
  font-weight: 700;
  fill: var(--md-on-surface);
}

svg.chart g.future .day {
  fill: var(--md-outline);
}

.week-total {
  margin: 4px 0 0;
  font-weight: 600;
}

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

section.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.stack .card {
  margin: 0;
}

.note {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  border-radius: 8px;
  padding: 8px 14px;
  margin: 8px 0 12px;
  font-size: 0.9rem;
}

form.control-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 8px 0 4px;
}

form.control-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-on-surface-variant);
  font-size: 0.9rem;
}

.success {
  color: var(--md-ok);
  margin: 4px 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* -- sliders (M3: 16dp rounded track, bar handle) ------------------------------------------ */

.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 260px;
  min-width: 220px;
}

.slider-row input[type="range"] {
  flex: 1;
  height: 44px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 16px;
  border-radius: 8px;
  /* --pct is set inline from the value; the active part is primary. */
  background: linear-gradient(
    to right,
    var(--md-primary) 0 var(--pct, 0%),
    var(--md-surface-container-highest) var(--pct, 0%) 100%
  );
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 36px;
  margin-top: -10px;
  border: none;
  border-radius: 9px;
  background: var(--md-primary);
  /* The M3 gap between handle and track, drawn in the card color. */
  box-shadow: 0 0 0 4px var(--md-surface-container);
  cursor: grab;
}

.slider-row input[type="range"]::-moz-range-track {
  height: 16px;
  border-radius: 8px;
  background: var(--md-surface-container-highest);
}

.slider-row input[type="range"]::-moz-range-progress {
  height: 16px;
  border-radius: 8px;
  background: var(--md-primary);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: var(--md-primary);
  box-shadow: 0 0 0 4px var(--md-surface-container);
  cursor: grab;
}

.slider-value {
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--md-primary);
  white-space: nowrap;
}

hr.rule {
  border: none;
  border-top: 1px solid var(--md-outline-variant);
  margin: 16px 0;
}

/* -- config editor ------------------------------------------------------------------------- */

.config-form h3 {
  margin: 20px 0 6px;
  font-size: 1rem;
  font-weight: 500;
}

.config-form h4 {
  margin: 12px 0 4px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
}

.field-label {
  display: block;
  margin: 12px 0 4px;
  color: var(--md-on-surface-variant);
  font-size: 0.9rem;
}

.field-label input[type="text"],
.field-label select,
.field-label textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 0.9rem;
}

.field-label textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.opt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 4px 0;
}

.opt-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  color: var(--md-on-surface);
  font-size: 0.9rem;
}

.per-day {
  border-left: 3px solid var(--md-outline-variant);
  padding-left: 14px;
  margin: 4px 0 8px;
}

details.advanced,
details.raw-config {
  margin: 16px 0 4px;
}

details.advanced summary,
details.raw-config summary {
  cursor: pointer;
  color: var(--md-on-surface-variant);
  font-size: 0.9rem;
}

details.raw-config pre {
  background: var(--md-surface-container-low);
  border: 1px solid var(--md-outline-variant);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  overflow-x: auto;
  color: var(--md-on-surface-variant);
}

/* -- play windows: M3 two-handle range slider ---------------------------------------------- */

.window-row {
  background: var(--md-surface-container-high);
  border-radius: 12px;
  padding: 14px 16px 6px;
  margin: 10px 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* M3 filter chip. */
button.chip {
  border: 1px solid var(--md-outline);
  background: none;
  color: var(--md-on-surface-variant);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

button.chip:hover {
  box-shadow: none;
  background: rgba(61, 255, 158, 0.08);
}

button.chip.on {
  /* Selected day chip reads as the signature green (soft-tint fill + green
   * border/text, mirroring the kid HUD active pill) so no admin control
   * turns lavender when toggled on. */
  background: rgba(61, 255, 158, 0.16);
  border-color: var(--md-primary);
  color: var(--md-primary);
}

.window-label {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--md-primary);
  font-size: 0.92rem;
}

button.remove {
  font-size: 0.8rem;
  padding: 5px 14px;
}

.dual-range {
  position: relative;
  height: 56px;
  /* Native range thumbs are CENTRED: at a value fraction f the thumb
   * centre sits at (thumb/2 + f*(track - thumb)), not at f*track. The
   * fill and midnight mark inset by --thumb the same way so their edges
   * line up exactly under the thumb centres (fixes the fill spilling past
   * the handle). Must match the ::thumb width below. */
  --thumb: 18px;
}

/* The track's usable span is inset by half a thumb at each end, matching
 * where the thumb centres can actually travel. */
.dual-range .range-track {
  position: absolute;
  top: 20px;
  left: calc(var(--thumb) / 2);
  right: calc(var(--thumb) / 2);
  height: 16px;
  border-radius: 8px;
  background: var(--md-surface-container-highest);
}

.dual-range .range-fill {
  position: absolute;
  top: 20px;
  height: 16px;
  /* --start-frac / --end-frac are 0..1, set inline from the view. */
  left: calc(var(--thumb) / 2 + var(--start-frac) * (100% - var(--thumb)));
  width: calc((var(--end-frac) - var(--start-frac)) * (100% - var(--thumb)));
  background: var(--md-primary);
}

.dual-range .range-fill.crossing {
  background: repeating-linear-gradient(
    90deg,
    var(--md-primary) 0 10px,
    var(--md-primary-container) 10px 20px
  );
}

.dual-range .midnight-mark {
  position: absolute;
  top: 12px;
  width: 2px;
  height: 32px;
  border-radius: 1px;
  /* Centre the 2px mark on the 24:00 point, inset like the thumbs. */
  left: calc(var(--thumb) / 2 + var(--midnight-frac) * (100% - var(--thumb)) - 1px);
  background: var(--md-outline);
}

.dual-range input[type="range"] {
  position: absolute;
  top: 6px;
  left: 0;
  width: 100%;
  margin: 0;
  height: 44px;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 18px;
  height: 40px;
  margin-top: 2px;
  border: none;
  border-radius: 9px;
  background: var(--md-primary);
  box-shadow: 0 0 0 4px var(--md-surface-container-high);
  cursor: grab;
}

.dual-range input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
  background: var(--md-on-primary-container);
}

.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 40px;
  border: none;
  border-radius: 9px;
  background: var(--md-primary);
  box-shadow: 0 0 0 4px var(--md-surface-container-high);
  cursor: grab;
}

.dual-range input[type="range"]::-moz-range-track {
  background: none;
}

/* -- play log timelines -------------------------------------------------------------------- */

.timeline {
  margin-top: 20px;
}

.timeline h3 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 500;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}

.timeline-day {
  width: 56px;
  flex: none;
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
  font-variant-numeric: tabular-nums;
}

.timeline-track {
  position: relative;
  flex: 1;
  height: 20px;
  background: var(--md-surface-container-high);
  border-radius: 6px;
  overflow: hidden;
}

.timeline-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--md-outline-variant);
}

.timeline-span {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 4px;
  background: var(--md-primary-dim);
  min-width: 2px;
}

.timeline-span.ongoing {
  background: var(--md-tertiary);
  animation: timeline-pulse 1.6s ease-in-out infinite;
}

@keyframes timeline-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.timeline-total {
  width: 64px;
  flex: none;
  text-align: right;
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
  font-variant-numeric: tabular-nums;
}

.dirty {
  color: var(--md-warn);
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.pending {
  background: var(--md-warn-container);
  color: var(--md-on-warn-container);
}

.badge.applied {
  background: var(--md-ok-container);
  color: var(--md-on-ok-container);
}

.badge.rejected {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}

table.history-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

table.history-table th,
table.history-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--md-outline-variant);
  white-space: nowrap;
}

table.history-table th {
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

table.history-table td.detail {
  white-space: normal;
  min-width: 140px;
  color: var(--md-on-surface-variant);
}

/* -- statistics --------------------------------------------------------------------------------- */

dl.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

dl.stats div {
  background: var(--md-surface-container-high);
  border-radius: 12px;
  padding: 10px 12px;
}

dl.stats dt {
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
}

dl.stats dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

dl.stats div.bad {
  background: var(--md-error-container);
}

dl.stats div.bad dt {
  color: var(--md-on-error-container);
}

dl.stats div.bad dd {
  color: var(--md-on-error-container);
}

.table-wrap {
  overflow-x: auto;
}

table.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  white-space: nowrap;
}

table.stats-table th,
table.stats-table td {
  text-align: right;
  padding: 8px;
  border-bottom: 1px solid var(--md-outline-variant);
}

table.stats-table th:first-child,
table.stats-table td:first-child {
  text-align: left;
}

table.stats-table th {
  color: var(--md-on-surface-variant);
  font-weight: 500;
}

tr.bad td {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}

/* -- footer (admin shell only, spec WP3) ------------------------------------------ */

footer.foot {
  margin-top: 24px;
  padding: 8px 0;
  text-align: center;
  color: var(--md-outline);
  font-size: 0.8rem;
}

/* -- kid dark theme ---------------------------------------------------------------
 * Applied to <body> while a kid session is active (app.rs toggles the
 * class), so the WHOLE page - shell, tabs, History - shares the HUD look.
 * Login and admin keep the plain light style. */

body.hud-theme {
  background: var(--hud-bg);
  color: var(--hud-ink);
  -webkit-font-smoothing: antialiased;
}

body.hud-theme header.top h1 {
  color: var(--hud-ink);
}

/* Login as a HUD panel: the ambient cloud lives behind the form fields,
 * clipped by the card like on the status view. */
body.hud-theme form.login {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  padding: 26px 22px;
}

body.hud-theme form.login > :not(.hud-swarm) {
  position: relative;
  z-index: 1;
}

body.hud-theme form.login h1 {
  margin: 0 0 10px;
  color: var(--hud-ink);
  font-family: var(--hud-mono);
  font-size: 1.05rem;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}

body.hud-theme nav.tabs {
  border-bottom-color: var(--hud-line);
}

body.hud-theme nav.tabs button {
  background: none;
  color: var(--hud-dim);
}

body.hud-theme nav.tabs button.active {
  border-bottom-color: var(--hud-accent);
  color: var(--hud-accent);
}

body.hud-theme .card {
  border: 1px solid var(--hud-line);
  background: var(--hud-panel);
  box-shadow: none;
}

body.hud-theme .muted {
  color: var(--hud-dim);
}

body.hud-theme .error {
  color: var(--hud-hot);
}

body.hud-theme input,
body.hud-theme select {
  border: 1px solid var(--hud-line);
  background: var(--hud-panel-2);
  color: var(--hud-ink);
}

body.hud-theme button {
  background: var(--hud-accent);
  color: var(--hud-bg);
}

body.hud-theme button:disabled {
  background: #23392f;
  color: var(--hud-faint);
}

body.hud-theme button.ghost {
  border: 1px solid var(--hud-line);
  background: none;
  color: var(--hud-accent);
}

body.hud-theme button.ghost:disabled {
  color: var(--hud-faint);
}

body.hud-theme label.picker {
  color: var(--hud-dim);
}

body.hud-theme .week-total {
  color: var(--hud-ink);
}

/* History week chart in HUD colors: quiet green bars, accent on today --
 * the same visual language as the status strip. */
body.hud-theme svg.chart .axis {
  stroke: var(--hud-line);
}

body.hud-theme svg.chart .bar {
  fill: #2a4a3c;
}

body.hud-theme svg.chart g.today .bar {
  fill: var(--hud-accent);
}

body.hud-theme svg.chart text {
  fill: var(--hud-dim);
}

body.hud-theme svg.chart g.today .day {
  fill: var(--hud-ink);
}

body.hud-theme svg.chart g.future .day {
  fill: var(--hud-faint);
}
