:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080c1b;
  color: #f6f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(circle at 15% 0%, rgba(95, 105, 255, .24), transparent 34%),
    radial-gradient(circle at 90% 86%, rgba(37, 206, 190, .14), transparent 36%),
    #080c1b;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

.app-card {
  width: 100%;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 28px;
  background: rgba(13, 18, 39, .76);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28), inset 0 1px rgba(255, 255, 255, .05);
  backdrop-filter: blur(18px);
}

.topbar,
.control-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.control-kicker {
  margin: 0 0 5px;
  color: #8d9aff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(25px, 6vw, 34px);
  line-height: 1;
  letter-spacing: -.04em;
}

h2 {
  font-size: 17px;
  letter-spacing: -.02em;
}

.privacy-badge {
  padding: 8px 10px;
  border: 1px solid rgba(102, 232, 214, .24);
  border-radius: 999px;
  color: #91eee0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.stage {
  position: relative;
  height: min(66svh, 650px);
  min-height: 330px;
  margin: 22px 0 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(118, 126, 255, .12), transparent 45%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 14px),
    #111831;
}

#glCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 15px;
  pointer-events: none;
}

.source-video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 5px;
  border: 1px solid rgba(141, 154, 255, .34);
  border-radius: 18px;
  color: #aeb7ff;
  font-size: 35px;
  line-height: 1;
  transform: rotate(-8deg);
}

.empty-state p {
  font-size: 16px;
  font-weight: 700;
}

.empty-state span,
.status-message,
.error-panel span {
  color: #a5adc9;
  font-size: 12px;
  line-height: 1.55;
}

.stage-hint {
  position: absolute;
  top: 24px;
  left: 24px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  color: rgba(240, 243, 255, .78);
  background: rgba(9, 13, 30, .42);
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.error-panel {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 143, 160, .32);
  border-radius: 13px;
  background: rgba(55, 17, 37, .82);
  backdrop-filter: blur(10px);
}

.error-panel strong {
  color: #ffb3c0;
  font-size: 13px;
}

.controls {
  display: grid;
  gap: 12px;
}

.control-heading output {
  min-width: 48px;
  color: #91eee0;
  font-size: 15px;
  font-weight: 800;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: #82e5d5;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  color: #7e87a6;
  font-size: 11px;
}

.primary-button {
  min-height: 50px;
  margin-top: 6px;
  border: 0;
  border-radius: 15px;
  color: #07151b;
  background: linear-gradient(100deg, #82e5d5, #aeb7ff);
  box-shadow: 0 8px 24px rgba(108, 222, 207, .16);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.primary-button:active {
  transform: translateY(1px) scale(.99);
}

.primary-button:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid rgba(141, 154, 255, .55);
  outline-offset: 3px;
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(.35);
  opacity: .7;
}

.status-message {
  min-height: 19px;
  text-align: center;
}

.status-message.error {
  color: #ffb3c0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 500px) {
  .app-card {
    padding: 16px;
    border-radius: 24px;
  }

  .stage {
    height: 62svh;
    min-height: 300px;
    margin-top: 18px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .app-shell {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .app-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, .48fr);
    align-items: center;
    column-gap: 22px;
  }

  .topbar {
    grid-column: 1 / -1;
  }

  .stage {
    grid-row: 2;
    height: 70svh;
    min-height: 270px;
    margin: 18px 0 0;
  }

  .controls {
    grid-row: 2;
  }
}
