:root {
  color-scheme: light;
  --ink: #101828;
  --muted: #667085;
  --panel: #ffffff;
  --panel-2: #f7f7f7;
  --line: #e4e7ec;
  --line-strong: #1c1c1c;
  --field: #fcfcfd;
  --accent: #fc7753;
  --accent-2: #156ec8;
  --danger: #d92d20;
  --ok: #2e7d32;
  --shadow: 0 8px 28px rgba(16, 24, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0%, #f6f8fb 54%, #ffffff 100%);
  color: var(--ink);
  font-family: "Barlow", "Aptos", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.primary,
button.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(252, 119, 83, 0.18);
}

.danger-action {
  border-color: rgba(255, 107, 107, 0.58);
  color: var(--danger);
}

.danger-action:hover {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
  padding: 20px;
  overflow: hidden;
}

.mode-select-screen {
  display: none;
}

html[data-initial-app-mode="validation"] .app-shell,
html[data-initial-app-mode="validation"] .app-shell.is-validation-test {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

html[data-initial-app-mode="validation"] .viewer-toolbar,
html[data-initial-app-mode="validation"] .timeline-strip,
html[data-initial-app-mode="validation"] #controlPanel,
html[data-initial-app-mode="validation"] #participantPanel,
html[data-initial-app-mode="validation"] #modeSelectScreen {
  display: none;
}

html[data-initial-app-mode="validation"] .viewer-section {
  grid-template-rows: minmax(0, 1fr);
  border: 0;
  box-shadow: none;
}

.mode-select-header {
  max-width: 680px;
}

.mode-select-header h1 {
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0;
}

.mode-choice-grid {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mode-choice {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  display: grid;
  align-content: end;
  gap: 12px;
  padding: 26px;
  text-decoration: none;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.mode-choice::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 72px;
  height: 6px;
  background: var(--accent);
}

.mode-choice:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: #ffffff;
}

.mode-choice strong {
  display: block;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1;
}

.mode-choice span:last-child {
  color: var(--muted);
  line-height: 1.45;
}

.app-shell.is-mode-select {
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: 28px;
}

.app-shell.is-mode-select .mode-select-screen {
  width: min(960px, calc(100vw - 36px));
  display: grid;
  gap: 28px;
}

.app-shell.is-mode-select #viewerSection,
.app-shell.is-mode-select #controlPanel,
.app-shell.is-mode-select #participantPanel {
  display: none;
}

.app-shell.is-analytics-mode #adminWorkflowRail,
.app-shell.is-analytics-mode #controlPanel > .panel-section:not(#adminRecordingPanel),
.app-shell.is-analytics-mode #adminRecordingPanel > :not(#aoiStatsPanel) {
  display: none;
}

.app-shell.is-analytics-mode #adminRecordingPanel {
  display: grid;
  gap: 12px;
}

.viewer-section,
.control-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.viewer-section {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2.1rem);
  line-height: 1.04;
  letter-spacing: 0;
  font-weight: 700;
}

.toolbar-actions,
.recording-actions,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recording-actions button {
  flex: 1 1 128px;
  min-width: 0;
  white-space: normal;
  line-height: 1.15;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mode-link {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  background: #ffffff;
}

.mode-link.is-active,
.mode-link:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.viewer {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 28px),
    #111111;
  cursor: grab;
}

.viewer.is-dragging {
  cursor: grabbing;
}

.viewer.is-flat-video {
  cursor: default;
}

.viewer.is-flat-video.is-dragging {
  cursor: default;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer > canvas {
  position: absolute;
  inset: 0;
}

.viewer > canvas:not(.gaze-heatmap-overlay) {
  z-index: 1;
}

.gaze-heatmap-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 160ms ease;
}

.app-shell.is-analytics-mode .gaze-heatmap-overlay {
  opacity: 0.78;
}

.aoi-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.aoi-overlay.is-authoring {
  pointer-events: auto;
  cursor: crosshair;
}

.aoi-overlay-shape {
  vector-effect: non-scaling-stroke;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.aoi-overlay.is-authoring .aoi-overlay-shape {
  pointer-events: none;
}

.aoi-vertex-handle {
  fill: var(--ink);
  stroke: #0a0b09;
  stroke-width: 2;
  cursor: grab;
  pointer-events: all;
}

.aoi-vertex-handle:active {
  cursor: grabbing;
}

.aoi-overlay-label {
  font-size: 13px;
  font-weight: 800;
  fill: #ffffff;
  paint-order: stroke;
  stroke: rgba(16, 24, 40, 0.78);
  stroke-width: 4px;
}

.viewer-notice {
  position: absolute;
  z-index: 6;
  left: 18px;
  bottom: 18px;
  max-width: min(440px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  padding: 10px 12px;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.1);
}

.viewer-notice.is-hidden {
  display: none;
}

.gaze-dot {
  position: absolute;
  z-index: 5;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(252, 119, 83, 0.26);
  pointer-events: none;
  transform: translate(-100px, -100px);
}

.viewer.is-raw-diagnostic .gaze-dot {
  z-index: 35;
}

.source-video {
  display: none;
}

.timeline-strip {
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
  background: #ffffff;
}

.timeline-strip canvas {
  width: 100%;
  height: 142px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(90deg, rgba(16, 24, 40, 0.08) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(16, 24, 40, 0.06) 0 1px, transparent 1px 32px);
}

.control-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
}

.admin-workflow-rail {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.admin-flow-step {
  min-height: 42px;
  display: grid;
  place-items: center;
  background: #f7f7f7;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
}

.admin-flow-step.is-active,
.admin-flow-step[aria-current="step"] {
  color: #ffffff;
  background: var(--line-strong);
}

.admin-flow-step:hover,
.admin-flow-step:focus-visible {
  color: var(--ink);
  background: #ffffff;
}

.admin-panel-section {
  position: relative;
  padding-left: 54px;
}

.admin-panel-section::before {
  content: attr(data-step);
  position: absolute;
  left: 16px;
  top: 18px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  display: grid;
  place-items: center;
  color: var(--line-strong);
  font-size: 0.68rem;
  font-weight: 900;
  background: #ffffff;
}

.panel-heading {
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 700;
}

.button-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.button-pair .wide-action {
  margin-top: 0;
}

.primary-loader {
  min-height: 56px;
  border-style: solid;
  border-color: rgba(252, 119, 83, 0.42);
  background: rgba(252, 119, 83, 0.06);
}

.admin-inline-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.compact-admin-section {
  background: #fafafa;
}

.participant-panel {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.validation-test-panel {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.participant-flow-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.flow-step {
  min-height: 46px;
  display: grid;
  place-items: center;
  background: #f7f7f7;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.flow-step.is-active {
  background: var(--line-strong);
  color: #ffffff;
}

.flow-step.is-complete {
  color: var(--ok);
}

.participant-card h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  letter-spacing: 0;
  font-weight: 700;
}

.participant-card .wide-action {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -10px 18px rgba(255, 255, 255, 0.88);
}

.participant-gaze-setup {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f7f7f7;
}

.participant-gaze-status {
  margin-top: 0;
}

.tracker-status-row {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f7f7f7;
}

.tracker-status-row span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tracker-status-row strong {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.25;
}

.field-stack {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field-label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.field-stack span,
.field-label span,
.checkbox-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-stack input,
.field-stack select,
.field-label input,
.field-label select,
.field-label textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--field);
  color: var(--ink);
  padding: 0 12px;
}

.field-stack select,
.field-label select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--line-strong) 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--line-strong) 50%, transparent 50%) calc(100% - 13px) 50% / 6px 6px no-repeat,
    var(--field);
}

.field-label textarea {
  min-height: 86px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.35;
}

.field-label input[type="color"] {
  width: 100%;
  padding: 4px;
}

.compact-field {
  margin-top: 0;
}

.compact-loader {
  flex: 1 1 150px;
}

.field-stack input:focus,
.field-label input:focus,
.field-label select:focus,
.field-label textarea:focus {
  outline: 2px solid rgba(21, 110, 200, 0.28);
  outline-offset: 1px;
}

.checkbox-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.checkbox-row input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.participant-session-panel {
  background: #fafafa;
}

.participant-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.participant-actions button {
  min-height: 44px;
}

.validation-test-card {
  height: 100%;
  display: grid;
  align-content: start;
  gap: 18px;
}

.validation-test-card h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.validation-step-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.validation-test-actions {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.is-participant-mode {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}

.app-shell.is-participant-mode #playVideoButton {
  display: none;
}

.app-shell.is-validation-test {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.app-shell.is-participant-mode .timeline-strip,
.app-shell.is-participant-mode #controlPanel,
.app-shell.is-participant-mode #aoiOverlay {
  display: none;
}

.app-shell.is-validation-test .viewer-toolbar,
.app-shell.is-validation-test .timeline-strip,
.app-shell.is-validation-test #controlPanel,
.app-shell.is-validation-test #participantPanel {
  display: none;
}

.app-shell.is-validation-test .viewer-section {
  grid-template-rows: minmax(0, 1fr);
  border: 0;
  box-shadow: none;
}

.app-shell.is-validation-test .viewer {
  width: 100%;
  height: 100vh;
  aspect-ratio: auto;
  background: #ffffff;
}

.app-shell.is-validation-test #viewer canvas,
.app-shell.is-validation-test #aoiOverlay {
  opacity: 0;
}

.app-shell.is-validation-test #gazeDot {
  opacity: 1;
  z-index: 12;
  background: #156ec8;
  box-shadow:
    0 0 0 4px rgba(21, 110, 200, 0.18),
    0 0 18px rgba(21, 110, 200, 0.28);
}

.app-shell.is-validation-test #viewerNotice {
  display: none;
}

.app-shell.is-participant-mode #participantPanel {
  display: block;
}

.app-shell.is-participant-started #adminModeLink {
  display: none;
}

.app-shell.is-admin-mode #participantPanel {
  display: none;
}

.app-shell.is-validation-test #validationTestPanel {
  display: block;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(16, 24, 40, 0.16);
}

.app-shell.is-admin-mode #validationTestPanel,
.app-shell.is-participant-mode #validationTestPanel {
  display: none;
}

.app-shell.is-participant-mode:not(.is-participant-started) {
  grid-template-columns: minmax(0, 720px);
  place-content: center;
}

.app-shell.is-participant-mode:not(.is-participant-started) #viewerSection {
  display: none;
}

.app-shell.is-participant-mode:not(.is-participant-started) #participantPanel {
  display: block;
  width: min(720px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 36px));
}

.app-shell.is-participant-started {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 20px;
  padding: 20px;
}

.app-shell.is-participant-started .viewer-section {
  position: static;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.app-shell.is-participant-started .viewer-toolbar {
  position: static;
  width: auto;
  min-height: 82px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
  padding: 18px 20px;
  backdrop-filter: none;
}

.app-shell.is-participant-started .viewer {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.app-shell.is-participant-started #participantPanel {
  position: static;
  width: auto;
  min-width: 0;
  max-height: calc(100vh - 40px);
  overflow: auto;
  box-shadow: var(--shadow);
}

.app-shell.is-participant-started .participant-card {
  display: none;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

details.panel-section > summary {
  display: grid;
  gap: 2px;
  margin: -16px -16px 12px -56px;
  padding: 16px 16px 14px 56px;
  cursor: pointer;
  list-style: none;
}

details.panel-section > summary::-webkit-details-marker {
  display: none;
}

details.panel-section > summary::after {
  content: "Hide";
  position: absolute;
  right: 16px;
  top: 19px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

details.panel-section:not([open]) > summary {
  margin-bottom: -16px;
}

details.panel-section:not([open]) > summary::after {
  content: "Show";
}

details.panel-section > summary:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: -3px;
}

.panel-section[hidden] {
  display: none;
}

.panel-section.admin-panel-section {
  padding: 18px 16px 18px 56px;
}

.panel-section:last-child {
  border-bottom: 0;
}

.file-loader {
  position: relative;
  margin-top: 10px;
  min-height: 48px;
  border: 1px dashed var(--line);
  border-radius: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--field);
  cursor: pointer;
  font-weight: 600;
}

.file-loader:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.file-loader input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.wide-action {
  width: 100%;
  margin-top: 10px;
}

.wide-action + .recording-actions {
  margin-top: 8px;
}

.selected-aoi-actions {
  margin-top: 12px;
}

.status-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.status-grid div {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  background: var(--field);
}

.status-grid span,
.readout dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.aoi-stats-panel {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.aoi-stats-panel[hidden] {
  display: none;
}

.aoi-stats-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.aoi-stats-header h3 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.aoi-stats-header button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.aoi-stats-header-actions,
.aoi-stats-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.aoi-stats-actions {
  justify-content: flex-start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.aoi-stats-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.aoi-stats-summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 3px solid #287a76;
  border-radius: 6px;
  padding: 9px 10px;
  background: #f8fbfb;
}

.aoi-stats-summary-item span,
.aoi-stat-primary span,
.aoi-stat-card-metrics dt {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.aoi-stats-summary-item strong,
.aoi-stat-primary strong {
  display: block;
  margin-top: 4px;
  min-width: 0;
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.aoi-results-main {
  display: grid;
  gap: 10px;
}

.aoi-stats-cards {
  display: grid;
  gap: 8px;
}

.aoi-stats-empty {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 12px;
  color: var(--muted);
  background: var(--field);
}

.aoi-stats-result-note {
  margin: 0;
  border: 1px solid #d6dde6;
  border-left: 3px solid #9a4b1f;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--muted);
  background: #fff9f3;
  font-size: 0.82rem;
  line-height: 1.35;
}

.aoi-stat-card {
  display: grid;
  gap: 9px;
  border: 1px solid #d6dde6;
  border-radius: 8px;
  padding: 10px;
  background: #fcfcfd;
}

.aoi-stat-card-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.aoi-stat-rank {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  background: #253858;
  font-size: 0.72rem;
  font-weight: 800;
}

.aoi-stat-card h4 {
  margin: 0;
  min-width: 0;
  font-size: 0.95rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.aoi-stat-primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
}

.aoi-stat-primary strong {
  margin-top: 0;
  color: #9a4b1f;
  font-size: 1.25rem;
}

.aoi-stat-card-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

.aoi-stat-card-bar-fill {
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: #287a76;
}

.aoi-stat-card-metrics {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
}

.aoi-stat-card-metrics div {
  min-width: 0;
}

.aoi-stat-card-metrics dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.aoi-stats-details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.aoi-stats-details summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.aoi-stats-details[open] summary {
  margin-bottom: 8px;
}

.aoi-stats-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--field);
}

.aoi-stats-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
}

.aoi-stats-table th,
.aoi-stats-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aoi-stats-table th {
  color: var(--muted);
  font-weight: 700;
  background: #ffffff;
}

.aoi-stats-table th:first-child,
.aoi-stats-table td:first-child {
  width: 34%;
  text-align: left;
}

.aoi-stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.aoi-stats-table .aoi-name-cell {
  font-weight: 600;
}

.aoi-stats-table .empty-table-cell {
  color: var(--muted);
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.readout {
  margin: 0;
  display: grid;
  gap: 8px;
}

.readout div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.readout dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.aoi-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  max-height: min(42vh, 460px);
  overflow: auto;
  padding-right: 4px;
}

.aoi-list li {
  padding: 0;
  border-radius: 6px;
}

.aoi-list-button {
  width: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  text-align: left;
  cursor: pointer;
}

.aoi-list-button:hover {
  background: transparent;
}

.aoi-list-button:active {
  transform: none;
}

.aoi-list-button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.aoi-list li.is-selected {
  background: rgba(255, 209, 102, 0.08);
  box-shadow: inset 0 0 0 1px var(--accent-2);
}

.swatch {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 0;
  border: 1px solid rgba(16, 24, 40, 0.18);
}

.aoi-list strong {
  display: block;
  font-size: 0.92rem;
}

.aoi-list span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.25;
}

.fine-print {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

#rawGazeDiagnosticStatus {
  min-height: 2.4em;
}

.calibration-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(16, 24, 40, 0.46);
  backdrop-filter: blur(4px);
}

.calibration-overlay[hidden] {
  display: none;
}

.calibration-card {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 1;
  width: min(320px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.calibration-overlay[data-card-position^="bottom"] .calibration-card {
  top: auto;
  bottom: 16px;
}

.calibration-overlay[data-card-position$="right"] .calibration-card {
  right: 16px;
  left: auto;
}

.calibration-card strong,
.calibration-card span {
  display: block;
}

.calibration-card strong {
  font-size: 1.2rem;
}

.calibration-card span {
  margin-top: 6px;
  color: var(--muted);
}

.calibration-card button {
  margin-top: 12px;
}

.calibration-target {
  position: absolute;
  left: var(--target-x, 50%);
  top: var(--target-y, 50%);
  z-index: 2;
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, #101828 0 7px, transparent 8px),
    var(--accent);
  box-shadow:
    0 0 0 8px rgba(252, 119, 83, 0.24),
    0 18px 44px rgba(16, 24, 40, 0.34);
  transform: translate(-50%, -50%);
}

.calibration-target::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(16, 24, 40, 0.48);
  border-radius: inherit;
}

.calibration-target.is-capturing {
  background:
    radial-gradient(circle at center, #101828 0 7px, transparent 8px),
    var(--accent-2);
  box-shadow:
    0 0 0 14px rgba(21, 110, 200, 0.22),
    0 18px 44px rgba(16, 24, 40, 0.34);
}

@media (max-width: 980px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .control-panel {
    max-height: none;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .viewer-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions,
  .recording-actions,
  .segmented,
  .mode-choice-grid {
    width: 100%;
  }

  .app-shell.is-validation-test {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .app-shell.is-validation-test .viewer-section {
    min-height: min(46vh, 360px);
  }

  .app-shell.is-validation-test .viewer {
    width: 100%;
    min-height: min(46vh, 360px);
    aspect-ratio: auto;
  }

.app-shell.is-validation-test #validationTestPanel {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    min-height: 0;
  }

  .metadata-grid,
  .button-pair,
  .participant-actions {
    grid-template-columns: 1fr;
  }

  .mode-choice-grid {
    grid-template-columns: 1fr;
  }

  button {
    flex: 1;
    min-width: 0;
    padding: 0 10px;
  }
}
