:root {
  color-scheme: dark;
  --sp-red: #e31b23;
  --sp-red-deep: #b9141b;
  --black: #080808;
  --charcoal-950: #111111;
  --charcoal-900: #181818;
  --charcoal-800: #242424;
  --charcoal-700: #343434;
  --white: #ffffff;
  --paper: #f7f7f7;
  --ink: #101010;
  --muted: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  --green: #35d07f;
  --red: var(--sp-red);
  --orange: var(--sp-red);
  --orange-deep: var(--sp-red-deep);
  --yellow: var(--white);
  --cyan: #ffffff;
  --blue: var(--sp-red);
  --cardboard-950: var(--black);
  --cardboard-900: var(--charcoal-950);
  --cardboard-800: var(--charcoal-800);
  --cardboard-700: var(--charcoal-700);
  --cardboard-600: #4a4a4a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px) 0 0 / 38px 38px,
    radial-gradient(circle at 18% 12%, rgba(227, 27, 35, 0.22), transparent 26rem),
    radial-gradient(circle at 88% 80%, rgba(227, 27, 35, 0.16), transparent 24rem),
    var(--charcoal-950);
  color: var(--white);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

.app-shell {
  width: min(1420px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(14px, 2.8vw, 36px);
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(360px, 0.86fr);
  gap: clamp(18px, 3vw, 36px);
  align-items: center;
}

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

.video-frame {
  position: relative;
  overflow: hidden;
  border: 10px solid var(--sp-red);
  border-radius: 8px;
  background: #030303;
  aspect-ratio: 4 / 3;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

video,
canvas,
.empty-state {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

video {
  object-fit: cover;
}

canvas {
  object-fit: fill;
}

.is-mirrored video,
.is-mirrored canvas {
  transform: scaleX(-1);
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 34%, rgba(227, 27, 35, 0.2), transparent 15rem),
    #050505;
  color: rgba(255, 255, 255, 0.88);
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  font-size: clamp(28px, 5vw, 58px);
  line-height: 1;
}

.empty-state span {
  font-size: 16px;
}

.floating-tools {
  position: absolute;
  top: 20px;
  right: 20px;
  display: grid;
  gap: 14px;
  z-index: 3;
}

.sp-brand {
  position: absolute;
  left: clamp(12px, 2.4vw, 22px);
  bottom: clamp(12px, 2.4vw, 22px);
  z-index: 3;
  width: clamp(62px, 10vw, 96px);
  pointer-events: none;
}

.sp-brand img {
  display: block;
  width: 100%;
  height: auto;
}
.round-button {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border: 2px solid rgba(16, 16, 16, 0.82);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.round-button.is-active {
  color: var(--ink);
}

#cameraButton {
  background: rgba(255, 255, 255, 0.98);
  color: var(--sp-red);
  border-color: var(--sp-red);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 0 3px rgba(227, 27, 35, 0.12);
}

#cameraButton:hover,
#cameraButton:focus-visible {
  background: var(--sp-red);
  color: var(--white);
}


.floating-tools .round-button {
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}

.floating-tools .icon-camera,
.floating-tools .icon-switch-camera,
.floating-tools .icon-fullscreen {
  width: 100%;
  height: 100%;
}


.floating-tools #cameraButton,
.floating-tools #cameraButton:hover,
.floating-tools #cameraButton:focus-visible {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: inherit;
}
.floating-tools #cameraButton:hover,
.floating-tools #cameraButton:focus-visible {
  background: transparent;
  color: inherit;
}

.round-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.panel {
  padding: clamp(14px, 2vw, 24px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sp-red);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 4.6vw, 66px);
  line-height: 0.95;
  letter-spacing: 0;
  max-width: 540px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 86px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.status-pill.is-good {
  background: rgba(53, 208, 127, 0.16);
  border-color: rgba(53, 208, 127, 0.54);
}

.status-pill.is-warn {
  background: rgba(227, 27, 35, 0.16);
  border-color: rgba(227, 27, 35, 0.56);
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 10px;
  margin-bottom: 14px;
}

.primary-action,
.secondary-action {
  min-height: 54px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-action {
  background: var(--sp-red);
  color: var(--white);
  box-shadow: 0 10px 28px rgba(227, 27, 35, 0.28);
}

.secondary-action {
  background: var(--white);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.primary-action:disabled,
.secondary-action:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(227, 27, 35, 0.48);
  border-radius: 8px;
  background: rgba(227, 27, 35, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.35;
}

.metrics-grid {
  display: grid;
  gap: 6px;
}

.metric {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  min-height: 21px;
}

.metric label {
  color: white;
  font-size: 9px;
  font-weight: 900;
  text-align: right;
}

.meter {
  height: 19px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--sp-red);
  transition: width 110ms linear;
}

.metric output {
  min-width: 34px;
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--paper);
  color: var(--sp-red);
  font-size: 13px;
  font-weight: 1000;
  line-height: 1.15;
}

.icon-camera,
.icon-switch-camera,
.icon-fullscreen,
.icon-bluetooth,
.icon-target {
  width: 24px;
  height: 24px;
  display: inline-block;
  background: currentColor;
  flex: 0 0 auto;
}

.icon-camera {
  background: transparent url("assets/icons/camera.png") center / contain no-repeat;
}

#cameraButton.is-camera-off .icon-camera {
  background-image: url("assets/icons/camera-off.png");
}

.icon-switch-camera {
  background: transparent url("assets/icons/switch-camera.png") center / contain no-repeat;
}

.icon-fullscreen {
  background: transparent url("assets/icons/fullscreen.png") center / contain no-repeat;
}

.icon-bluetooth {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 2 6 6-4 4 4 4-6 6h-2v-7.2L6.8 18 5.4 16.6l4.6-4.6-4.6-4.6L6.8 6 10 9.2V2h2Zm0 11.8V18l3-3-3-1.2Zm0-7.8v4.2L15 8l-3-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.icon-target {
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 2h2v3.05A7 7 0 0 1 18.95 11H22v2h-3.05A7 7 0 0 1 13 18.95V22h-2v-3.05A7 7 0 0 1 5.05 13H2v-2h3.05A7 7 0 0 1 11 5.05V2Zm1 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10Zm0 3a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.is-fullscreen-mode {
  overflow: hidden;
  background: #000;
}

.is-fullscreen-mode .app-shell {
  width: 100vw;
  height: 100svh;
  min-height: 100svh;
  padding: 0;
  display: block;
}

.is-fullscreen-mode .stage {
  width: 100vw;
  height: 100svh;
  padding: 0;
  background: #000;
}

.is-fullscreen-mode .video-frame {
  width: 100vw;
  height: 100svh;
  min-height: 100svh;
  border-width: 0;
  border-radius: 0;
  aspect-ratio: auto;
  box-shadow: none;
}

.is-fullscreen-mode .panel,
.is-fullscreen-mode .empty-state {
  display: none !important;
}


@media (max-width: 980px) {
  body {
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 38px 38px,
      linear-gradient(0deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px) 0 0 / 38px 38px,
      var(--charcoal-950);
  }

  .app-shell {
    width: 100%;
    min-height: 100svh;
    display: block;
    padding: 0 0 max(16px, env(safe-area-inset-bottom));
  }

  .stage {
    background: var(--sp-red);
    padding: max(14px, env(safe-area-inset-top)) clamp(14px, 5vw, 46px) 28px;
  }

  .video-frame {
    width: 100%;
    height: min(58svh, 760px);
    min-height: 360px;
    border-width: 0;
    border-radius: 8px;
    aspect-ratio: auto;
    box-shadow: none;
  }

  .panel {
    padding: 20px clamp(16px, 5vw, 46px) 0;
  }

  .panel-header {
    align-items: center;
    margin-bottom: 14px;
  }

  h1 {
    font-size: clamp(30px, 8.5vw, 52px);
  }

  .status-pill {
    min-width: 78px;
    padding: 8px 10px;
  }

  .actions {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 10px 0;
    background: linear-gradient(180deg, var(--charcoal-950) 78%, rgba(17, 17, 17, 0));
  }

  .primary-action,
.secondary-action {
  min-height: 54px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  cursor: pointer;
}

  .metrics-grid {
    gap: 5px;
  }

  .metric {
    grid-template-columns: 80px minmax(0, 1fr) 40px;
    gap: 5px;
    min-height: 20px;
  }

  .metric label {
    font-size: 9px;
  }

  .meter {
    height: 18px;
  }

  .metric output {
    font-size: 12px;
  }
}

@media (max-width: 620px) {
  .floating-tools {
    top: 12px;
    right: 12px;
    gap: 12px;
  }

  .round-button {
    width: 58px;
    height: 58px;
  }

  .panel-header {
    gap: 5px;
  }

  .eyebrow {
    font-size: 12px;
  }

  .metric {
    grid-template-columns: 74px minmax(0, 1fr) 38px;
    gap: 5px;
  }

  .metric label {
    font-size: 9px;
  }

  .metric output {
    min-width: 34px;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  .video-frame {
    min-height: 320px;
  }

  .metric {
    grid-template-columns: 68px minmax(0, 1fr) 36px;
  }

  .metric label {
    font-size: 8px;
  }
}
