:root {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #eef7ef;
  background: #080b09;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% 10%, rgba(93, 255, 126, 0.09), transparent 30rem),
    #080b09;
}

button,
select,
a {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 960px);
  min-height: 100vh;
  margin: auto;
  padding: max(22px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #74ee8e;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: -0.04em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid #29322b;
  border-radius: 99px;
  color: #aeb7b0;
  background: rgba(15, 20, 16, 0.8);
  font-size: 0.75rem;
  white-space: nowrap;
}

.status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6e776f;
  content: "";
}

.status[data-state="live"]::before {
  background: #59f57c;
  box-shadow: 0 0 12px #59f57c;
}

.status[data-state="error"]::before {
  background: #ff6c5d;
}

.viewer {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid #2b362e;
  border-radius: 24px;
  background: #0d110e;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.35);
}

video {
  width: 100%;
  height: 100%;
  background: #050706;
  object-fit: cover;
}

.tracking-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  object-fit: cover;
}

.empty-state {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    #0d110e;
  background-size: 32px 32px;
}

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

.empty-state h2 {
  margin: 20px 0 8px;
}

.empty-state p {
  max-width: 340px;
  margin-bottom: 22px;
  color: #929d94;
}

.lens {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border: 1px solid #3e4e42;
  border-radius: 50%;
  box-shadow: inset 0 0 0 8px #151c17;
}

.lens span {
  width: 22px;
  height: 22px;
  border: 2px solid #76f391;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(118, 243, 145, 0.35);
}

.hud {
  pointer-events: none;
}

.hud .corner,
.hud .resolution {
  z-index: 2;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: rgba(116, 238, 142, 0.7);
}

.top-left {
  top: 18px;
  left: 18px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.top-right {
  top: 18px;
  right: 18px;
  border-top: 1px solid;
  border-right: 1px solid;
}

.bottom-left {
  bottom: 18px;
  left: 18px;
  border-bottom: 1px solid;
  border-left: 1px solid;
}

.bottom-right {
  right: 18px;
  bottom: 18px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.resolution {
  position: absolute;
  right: 24px;
  bottom: 18px;
  color: rgba(255, 255, 255, 0.7);
  font: 700 0.65rem/1 monospace;
}

.gesture-panel {
  position: absolute;
  z-index: 3;
  top: 20px;
  left: 50%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-width: 230px;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(117, 242, 143, 0.22);
  border-radius: 13px;
  background: rgba(6, 10, 7, 0.74);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  backdrop-filter: blur(12px);
}

.gesture-panel.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.gesture-panel small,
.gesture-panel strong {
  display: block;
}

.gesture-panel small {
  margin-bottom: 2px;
  color: #91a195;
  font-size: 0.62rem;
}

.gesture-panel strong {
  font-size: 0.86rem;
}

.gesture-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(117, 242, 143, 0.36);
  border-radius: 10px;
  color: #75f28f;
  background: rgba(117, 242, 143, 0.08);
  font-size: 1.1rem;
}

.gesture-score {
  color: #75f28f;
  font: 700 0.66rem/1 monospace;
}

.message {
  min-height: 22px;
  margin: 12px 4px 18px;
  color: #919c93;
  font-size: 0.78rem;
}

.message.error {
  color: #ff8c81;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 12px;
}

.tracking-toggle {
  min-width: 150px;
}

.toggle-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid #2b342d;
  border-radius: 12px;
  color: #edf4ee;
  background: #121713;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: none;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 99px;
  background: #364039;
  transition: background 160ms ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle {
  background: #75f28f;
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(14px);
}

.toggle-row:has(input:focus-visible) {
  outline: 2px solid #75f28f;
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: #8f9a91;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-width: 0;
  padding: 13px 40px 13px 14px;
  border: 1px solid #2b342d;
  border-radius: 12px;
  color: #edf4ee;
  background: #121713;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 22px;
  max-width: 440px;
  margin: 30px auto 0;
}

button,
.primary,
.secondary {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 800;
  text-decoration: none;
}

.primary {
  color: #061007;
  background: #75f28f;
}

.secondary {
  color: #dce6de;
  background: #202722;
}

.icon-button {
  display: grid;
  gap: 5px;
  place-items: center;
  border: 0;
  color: #dfe8e1;
  background: transparent;
}

.icon-button span {
  font-size: 1.7rem;
}

.icon-button small {
  color: #8d978f;
  font-size: 0.66rem;
}

.shutter {
  display: grid;
  width: 76px;
  height: 76px;
  padding: 5px;
  place-items: center;
  border: 2px solid #edf8ef;
  border-radius: 50%;
  background: transparent;
}

.shutter span {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #75f28f;
  transition: transform 120ms ease;
}

.shutter:active span {
  transform: scale(0.88);
}

.result {
  position: fixed;
  z-index: 10;
  inset: 0;
  overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: rgba(7, 10, 8, 0.97);
}

.result > div,
.result > img {
  width: min(100%, 900px);
  margin-right: auto;
  margin-left: auto;
}

.result img {
  display: block;
  max-height: 70vh;
  border-radius: 18px;
  object-fit: contain;
  background: #000;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 600px) {
  .app {
    padding-right: 14px;
    padding-left: 14px;
  }

  .viewer {
    aspect-ratio: 3 / 4;
    border-radius: 18px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .gesture-panel {
    top: 16px;
    min-width: 210px;
  }
}
