:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101416;
  color: #edf4f3;
  --surface: #171d20;
  --surface-strong: #20282b;
  --surface-soft: #132126;
  --border: #334046;
  --text-muted: #9eb1b4;
  --text-dim: #6f8388;
  --green: #55d18d;
  --cyan: #58d7e8;
  --yellow: #f1c95a;
  --red: #ff6f65;
  --blue: #76a7ff;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(88, 215, 232, 0.16), transparent 32rem),
    linear-gradient(135deg, #101416, #172023 48%, #111719);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 12px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 4.7rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.status-pill {
  max-width: 45%;
  border: 1px solid var(--border);
  background: rgba(23, 29, 32, 0.82);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.86rem;
  text-align: right;
}

.status-pill.good {
  color: var(--green);
  border-color: rgba(85, 209, 141, 0.44);
}

.status-pill.warn {
  color: var(--yellow);
  border-color: rgba(241, 201, 90, 0.44);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 17px;
  color: #eff8f6;
  background: var(--surface-strong);
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-action {
  min-width: 136px;
  background: linear-gradient(135deg, #20b772, #1f8fd1);
  color: #06100d;
  font-weight: 720;
}

.secondary-action {
  border: 1px solid var(--border);
}

.quiet-action {
  background: transparent;
  border: 1px solid rgba(158, 177, 180, 0.28);
  color: var(--text-muted);
}

.quiet-action.compact {
  min-height: 34px;
  padding: 0 11px;
}

.readout-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.readout,
.field,
.event-log {
  border: 1px solid rgba(158, 177, 180, 0.2);
  background: rgba(23, 29, 32, 0.86);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.readout {
  min-height: 124px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.readout-large {
  grid-column: span 1;
}

.label,
.detail,
.field span,
.legend-row,
.event-log li {
  color: var(--text-muted);
}

.label,
.field span {
  font-size: 0.82rem;
}

.readout strong {
  display: block;
  margin: 10px 0;
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  line-height: 1;
}

.readout-large strong {
  color: var(--green);
}

.detail {
  font-size: 0.84rem;
  line-height: 1.35;
}

meter {
  width: 100%;
  height: 12px;
}

meter::-webkit-meter-bar {
  background: #0d1112;
  border: 0;
  border-radius: 999px;
}

meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--yellow));
  border-radius: 999px;
}

.scope-panel {
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(158, 177, 180, 0.2);
  background: rgba(10, 14, 15, 0.72);
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2.8 / 1;
  border-radius: 6px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    #0c1112;
  background-size: 100% 25%, 8.333% 100%, auto;
}

.legend-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.82rem;
}

.swatch {
  display: inline-block;
  width: 22px;
  height: 3px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 999px;
}

.swatch.motion {
  background: var(--cyan);
}

.swatch.confidence {
  background: var(--green);
}

.swatch.threshold {
  background: var(--yellow);
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  min-height: 92px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: #edf4f3;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #101719;
  color: #edf4f3;
}

.event-log {
  margin-top: 12px;
  padding: 14px;
}

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

.event-log ol {
  margin: 0;
  padding-left: 20px;
  max-height: 180px;
  overflow: auto;
}

.event-log li {
  padding: 5px 0;
  font-size: 0.9rem;
}

.event-log li.alert {
  color: var(--red);
}

@media (max-width: 880px) {
  .readout-grid,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
  }

  .topbar {
    flex-direction: column;
  }

  .status-pill {
    max-width: 100%;
    text-align: left;
  }

  .control-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .control-strip button {
    width: 100%;
  }

  .readout-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  canvas {
    aspect-ratio: 1.5 / 1;
  }
}
