:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a20;
  --panel-2: #1f242c;
  --line: #303743;
  --text: #eef2f6;
  --muted: #9aa6b2;
  --low: #d95d4e;
  --mid: #d2ad35;
  --high: #2fa36b;
  --strict: #3da4d8;
  --unavailable: #c67635;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.camera-pane,
.inspector {
  min-width: 0;
}

.video-wrap {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 88px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090b0e;
}

video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.78);
  color: var(--text);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

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

.file-button input {
  display: none;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-panel,
.metrics-grid > div,
.calibration,
.sample-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.score-panel {
  padding: 16px;
}

.state-label {
  font-size: 28px;
  font-weight: 750;
  line-height: 1.1;
}

.score-row,
.policy-row,
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
}

.score-row strong {
  color: var(--text);
  font-size: 26px;
}

.score-meter {
  overflow: hidden;
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: #2a3039;
}

.score-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--mid);
  transition: width 140ms linear, background-color 140ms linear;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metrics-grid > div {
  min-height: 72px;
  padding: 12px;
}

.metrics-grid span,
.field label,
.list-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
}

.calibration {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.manual-label-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.manual-label-heading strong {
  color: var(--text);
  font-size: 14px;
}

.label-shortcuts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.label-button {
  min-width: 0;
  min-height: 48px;
  padding: 7px 6px;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
}

.label-button kbd {
  min-width: 22px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #101319;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

.label-button[aria-pressed="true"] {
  border-color: currentColor;
  background: #252d38;
}

.label-button-low[aria-pressed="true"] { color: var(--low); }
.label-button-mid[aria-pressed="true"] { color: var(--mid); }
.label-button-high[aria-pressed="true"] { color: var(--high); }

.shortcut-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101319;
  color: var(--text);
}

.sample-list {
  min-height: 0;
  padding: 12px;
}

.sample-list ol {
  overflow: auto;
  max-height: 230px;
  margin: 10px 0 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
}

.sample-list li {
  margin-bottom: 8px;
}

.state-low .state-label {
  color: var(--low);
}

.state-mid .state-label {
  color: var(--mid);
}

.state-high .state-label {
  color: var(--high);
}

.state-strict .state-label {
  color: var(--strict);
}

.state-unavailable .state-label {
  color: var(--unavailable);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 10px;
  }

  .video-wrap {
    min-height: auto;
    aspect-ratio: 3 / 4;
  }

  .inspector {
    padding-bottom: 18px;
  }
}
