:root {
  --bg: #050507;
  --panel: #12121a;
  --panel-2: #191924;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #c5cedf;
  --red: #e11d48;
  --red-deep: #be123c;
  --focus: #fecdd3;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --radius: 20px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 20% -10%, rgba(30, 27, 75, 0.55), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body { min-height: 100vh; }

button, select, input { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  min-width: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
  min-width: 0;
}

.top > div {
  min-width: 0;
  flex: 1;
}

.eyebrow {
  margin: 0 0 4px;
  font-family: Poppins, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fda4af;
}

h1, h2 {
  font-family: Poppins, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
  overflow-wrap: break-word;
}

h2 {
  margin: 0;
  font-size: 16px;
}

.status {
  margin: 0;
  max-width: 320px;
  text-align: right;
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.stage-column,
.panel {
  min-width: 0;
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.stage.is-cutout {
  background-color: #d4d4d8;
  background-image:
    linear-gradient(45deg, #a1a1aa 25%, transparent 25%),
    linear-gradient(-45deg, #a1a1aa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #a1a1aa 75%),
    linear-gradient(-45deg, transparent 75%, #a1a1aa 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.stage.is-recording { box-shadow: 0 0 0 2px var(--red), var(--shadow); }

.stage canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
}

.rec-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
}

.stage.is-recording .rec-dot { animation: blink 1.1s steps(2, end) infinite; }

.gate {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 12px;
  padding: 32px;
  background: rgba(5, 5, 7, 0.82);
}

.gate p {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
}

.stage-note {
  margin: 10px 4px 0;
  color: var(--muted);
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.block { display: grid; gap: 8px; }

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

select, input[type="range"] { width: 100%; }

input[type="range"] {
  appearance: none;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #2a2a36;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

select {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

select:disabled { opacity: 0.55; }

.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch-track {
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: #2a2a36;
  position: relative;
  flex: 0 0 auto;
  transition: background-color 200ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 200ms ease;
}

.switch input:checked + .switch-track { background: var(--red); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 3px; }

.mic-state, .hint, .export-status {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: #2a2a36;
  overflow: hidden;
}

#meterFill {
  display: block;
  height: 100%;
  width: 0%;
  background: #fb7185;
  border-radius: inherit;
}

.record {
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-family: Poppins, sans-serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background-color 200ms ease;
}

.record:hover:not(:disabled) { background: var(--red-deep); }
.record:disabled { opacity: 0.45; cursor: not-allowed; }

.record-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
}

.record.is-live .record-mark { width: 12px; height: 12px; border-radius: 3px; }

.btn {
  min-height: 44px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  transition: background-color 200ms ease, border-color 200ms ease;
}

.btn:hover:not(:disabled) { background: #232333; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  border-color: transparent;
  background: var(--red);
  color: white;
  font-weight: 700;
}

.btn.primary:hover:not(:disabled) { background: var(--red-deep); }

.text-btn {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fecdd3;
  text-align: left;
  width: fit-content;
}

.text-btn:hover { color: white; }
.text-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.center { text-align: center; }

.result {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.checker-preview {
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background-color: #d4d4d8;
  background-image:
    linear-gradient(45deg, #a1a1aa 25%, transparent 25%),
    linear-gradient(-45deg, #a1a1aa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #a1a1aa 75%),
    linear-gradient(-45deg, transparent 75%, #a1a1aa 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.checker-preview video { width: 100%; height: 100%; display: block; }

#camera {
  position: fixed;
  width: 320px;
  height: 180px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

@media (max-width: 900px) {
  .app { width: min(100% - 24px, 1180px); padding-top: 18px; }
  h1 { font-size: 26px; }
  .top { flex-direction: column; align-items: stretch; }
  .status { text-align: left; max-width: none; }
  main { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes blink {
  50% { opacity: 0.25; }
}
