:root {
  color-scheme: dark;
  --black: #000;
  --paper: #f3ecee;
  --muted: #a99da0;
  --panel: rgba(24, 19, 21, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #86e7ef;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
}

body { user-select: none; }

.app {
  position: fixed;
  inset: 0;
  background: #000;
  color: var(--paper);
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  transform: translate(-50%, -50%);
  background: #000;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.8s ease;
}

.stage.visible { opacity: 1; }

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.app.format-portrait .stage {
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
}

.countdown {
  position: absolute;
  left: 50%;
  bottom: clamp(26px, 4vh, 70px);
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(13px, 1.35vw, 25px);
  font-weight: 400;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.boot-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: #000;
  color: rgba(255, 255, 255, 0.58);
  letter-spacing: 0.18em;
  font-size: 11px;
}

.boot-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(134, 231, 239, 0.5);
  animation: breathe 1.8s ease-in-out infinite;
}

.boot-media-progress {
  width: min(360px, calc(100vw - 48px));
  height: 5px;
  border: 0;
  accent-color: var(--accent);
}

.live-setup {
  display: grid;
  width: min(360px, calc(100vw - 48px));
  gap: 12px;
  margin-top: 6px;
  text-align: center;
}

.live-setup button {
  min-height: 52px;
  background: rgba(134, 231, 239, 0.08);
  font-size: 11px;
}

.live-setup p {
  min-height: 30px;
  margin: 0;
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
  line-height: 1.5;
}

.live-check-status {
  position: fixed;
  left: 50%;
  bottom: max(34px, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  letter-spacing: 0.18em;
  pointer-events: none;
}

.repeat-live-test {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  min-height: 34px;
  padding: 0 14px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.65);
  color: rgba(255, 255, 255, 0.62);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.repeat-live-test:hover,
.repeat-live-test:focus-visible {
  border-color: rgba(134, 231, 239, 0.7);
  color: rgba(255, 255, 255, 0.92);
}

.restore-fullscreen {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 50;
  min-height: 46px;
  transform: translateX(-50%);
  padding: 0 22px;
  border-color: rgba(134, 231, 239, 0.7);
  background: rgba(0, 0, 0, 0.86);
  color: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.restore-fullscreen:hover,
.restore-fullscreen:focus-visible { color: var(--accent); }

.audio-tab-notice {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  max-width: min(360px, calc(100vw - 36px));
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(134, 231, 239, 0.36);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
  line-height: 1.45;
  letter-spacing: 0.1em;
}

.audio-tab-notice strong {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.audio-tab-notice button {
  min-height: 32px;
  margin-top: 4px;
  padding: 0 10px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  font-size: 9px;
}

@keyframes breathe {
  50% { opacity: 0.25; transform: scale(0.75); }
}

.test-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(720px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.7);
}

.test-panel header { margin-bottom: 30px; }
.test-panel h1 { margin: 4px 0 10px; font-size: 30px; font-weight: 400; }
.test-panel h2 { margin: 0 0 15px; color: var(--muted); font-size: 11px; letter-spacing: 0.16em; }
.test-panel p { line-height: 1.5; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: 0.2em; }

.test-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

dl { margin: 0; }
dl div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}
dt { color: var(--muted); }
dd { margin: 0; font-variant-numeric: tabular-nums; }
.pass { color: #90e8b0; }
.warn { color: #f2c678; }
.fail { color: #ff8888; }

.test-actions { display: grid; gap: 9px; }
.media-progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 30px;
}
.media-progress-wrap progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  appearance: none;
}
.media-progress-wrap progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.media-progress-wrap progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
  transition: width 180ms ease;
}
.media-progress-wrap progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}
.media-progress-wrap output {
  min-width: 76px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
  letter-spacing: 0.12em;
  font-size: 10px;
  cursor: pointer;
}
.file-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--paper);
  letter-spacing: 0.12em;
  font-size: 10px;
  cursor: pointer;
}
.file-button:hover { border-color: var(--accent); }
.file-button.disabled { opacity: 0.35; pointer-events: none; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.35; cursor: wait; }

.test-message {
  min-height: 24px;
  margin: 24px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.live-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}
.primary { border-color: rgba(134, 231, 239, 0.65); color: var(--accent); }
.secondary { color: var(--muted); }

.emergency-arm {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(280px, calc(100vw - 40px));
  opacity: 0.58;
}

.settings-toggle {
  position: absolute;
  right: clamp(14px, 2vw, 30px);
  bottom: clamp(14px, 2vw, 30px);
  z-index: 20;
  min-width: 112px;
  background: rgba(116, 76, 87, 0.84);
  backdrop-filter: blur(12px);
}

.settings-panel {
  position: absolute;
  right: clamp(14px, 2vw, 30px);
  top: 50%;
  z-index: 21;
  width: min(290px, calc(100vw - 28px));
  transform: translateY(-50%);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(116, 76, 87, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
}

.settings-head,
.preset-buttons,
.settings-fields label {
  display: grid;
  align-items: center;
}

.settings-head {
  grid-template-columns: 1fr auto;
  margin-bottom: 13px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.settings-head button {
  min-width: 34px;
  min-height: 34px;
  border: 0;
  font-size: 20px;
}

.preset-buttons {
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.preset-buttons button.active { border-color: var(--accent); color: var(--accent); }
.settings-fields { display: grid; gap: 11px; }
.settings-fields label { grid-template-columns: 46px 1fr 52px; gap: 9px; }
.settings-fields span,
.settings-fields output {
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  letter-spacing: 0.11em;
}
.settings-fields output { text-align: right; font-variant-numeric: tabular-nums; }
.settings-fields input { width: 100%; accent-color: var(--accent); }
.settings-divider { height: 1px; margin: 3px 0; background: rgba(255, 255, 255, 0.12); }
.settings-reset { width: 100%; margin-top: 16px; }

.headless .settings-panel,
.headless .settings-toggle { display: none !important; }

.video-pattern {
  opacity: 1;
  outline: 2px solid #fff;
  outline-offset: -2px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), #fff 50%, transparent calc(50% + 1px)),
    linear-gradient(transparent calc(50% - 1px), #fff 50%, transparent calc(50% + 1px)),
    linear-gradient(135deg, #000 0 25%, #fff 25% 50%, #777 50% 75%, #ce8a9b 75%);
}
.video-pattern canvas { opacity: 0; }

.headless,
.headless * { cursor: none !important; }

.headless .repeat-live-test,
.headless .restore-fullscreen,
.headless .audio-tab-notice,
.headless .audio-tab-notice * { cursor: pointer !important; }

@media (max-width: 620px) {
  .test-grid { grid-template-columns: 1fr; gap: 24px; }
  .live-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .stage { transition: none; }
  .boot-mark { animation: none; }
}
