:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.62);
  --yellow: #ffd60a;
  --green: #30d158;
  --panel: #121212;
  --line: rgba(255, 255, 255, 0.14);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Times New Roman", Georgia, serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #050505;
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% 12%, rgba(255, 214, 10, 0.06), transparent 60%),
    radial-gradient(1200px 800px at 50% 100%, #171717, #050505 65%);
}

.phone {
  position: relative;
  width: 390px;
  height: 844px;
  max-height: calc(100dvh - 48px);
  border-radius: 48px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #111;
  z-index: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.demo-canvas {
  display: none;
}

.scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0) 66%, rgba(0, 0, 0, 0.62)),
    radial-gradient(120% 80% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.28));
}

.ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding:
    max(16px, env(safe-area-inset-top))
    18px
    max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.ui button,
.ui .scene-chip,
.ui .filter-chip {
  pointer-events: auto;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #fff;
  color: #000;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.brand-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.brand-beta {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  padding: 1px 3px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 10px rgba(255, 214, 10, 0.7);
}

.status.is-ready .dot {
  background: var(--green);
  box-shadow: 0 0 12px rgba(48, 209, 88, 0.8);
}

.topchips {
  align-self: flex-start;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  max-width: 100%;
}

.scene-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.camera-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--yellow);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #111;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.camera-cta:active {
  transform: scale(0.98);
}

.camera-cta:disabled {
  opacity: 0.55;
}

.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.85;
}

.grid .gv,
.grid .gh {
  position: absolute;
  background: rgba(255, 255, 255, 0.26);
}

.grid .gv {
  top: 0;
  bottom: 0;
  width: 1px;
}

.grid .gh {
  left: 0;
  right: 0;
  height: 1px;
}

.centerline {
  position: absolute;
  top: 18%;
  bottom: 20%;
  left: 50%;
  width: 1px;
  border-left: 1px dashed rgba(255, 255, 255, 0.34);
  pointer-events: none;
  opacity: 0.7;
}

.subject {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.subject-label {
  position: absolute;
  top: -24px;
  left: -1px;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

.target {
  position: absolute;
  border: 2px dashed var(--yellow);
  border-radius: 12px;
  pointer-events: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.target::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  background: rgba(255, 214, 10, 0.045);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.target.is-ready {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.16), 0 0 34px rgba(48, 209, 88, 0.18);
}

.target.is-ready::after {
  background: rgba(48, 209, 88, 0.06);
  opacity: 1;
}

.target-label {
  position: absolute;
  top: -28px;
  left: -2px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--yellow);
  color: #111;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

.target.is-ready .target-label {
  background: var(--green);
  color: #06120a;
}

.target.is-line {
  border: 0;
  border-top: 2px dashed var(--yellow);
  border-radius: 0;
  box-shadow: none;
}

.target.is-line::after { display: none; }

.target.is-line .target-label { top: -28px; }

.target.is-line.is-ready {
  border-top-color: var(--green);
  box-shadow: none;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}

.flash.is-on { opacity: 0.55; }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(168px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: #fff;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.hint.is-ready {
  background: rgba(48, 209, 88, 0.16);
  border-color: rgba(48, 209, 88, 0.36);
  color: #b9ffca;
}

.filter-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(112px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 0 18px;
}

.filter-chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-chip.is-active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #111;
}

.bottombar {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.42);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shutter {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.shutter span {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.12s ease, background 0.18s ease;
}

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

.shutter.is-ready {
  box-shadow: 0 0 0 5px rgba(48, 209, 88, 0.14), 0 0 30px rgba(48, 209, 88, 0.28);
  border-color: var(--green);
}

.shutter.is-ready span {
  background: var(--green);
}

.filter-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.42);
  display: grid;
  place-items: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.filter-wheel {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(#ff6b6b, #ffd93d, #6bcB77, #4d96ff, #b983ff, #ff6b6b);
  box-shadow: inset 0 0 0 5px #111;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.debug-toggle {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top));
  right: 18px;
  width: 28px;
  height: 22px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.32);
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  letter-spacing: 0.06em;
  display: grid;
  place-items: center;
  z-index: 12;
}

.debug {
  position: absolute;
  top: calc(84px + env(safe-area-inset-top));
  left: 18px;
  max-width: 330px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #c9ffd2;
  font: 10px/1.55 "SFMono-Regular", Menlo, monospace;
  white-space: pre-wrap;
  z-index: 11;
  pointer-events: none;
}

/* Start screen */
.start {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(700px 500px at 50% 30%, rgba(255, 214, 10, 0.08), transparent 65%),
    #050505;
}

.start.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.start-inner {
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.start-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
  border-radius: 19px;
  background: #fff;
  color: #000;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.start h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.start p {
  margin: 0 0 26px;
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.58);
}

.primary,
.secondary {
  width: 100%;
  height: 48px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.primary {
  background: var(--yellow);
  color: #111;
}

.secondary {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.86);
}

.primary:active,
.secondary:active {
  transform: scale(0.985);
}

.start-note {
  display: block;
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.34);
}

/* Sheets */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-panel {
  width: 100%;
  max-height: 86%;
  overflow: auto;
  border-radius: 26px 26px 0 0;
  background: #111;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from { transform: translateY(24px); }
  to { transform: translateY(0); }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sheet-sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: none;
}

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

.template-card {
  text-align: left;
  padding: 10px;
  border-radius: 16px;
  background: #181818;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.template-card.is-active {
  border-color: var(--yellow);
  background: #1d1b12;
}

.template-card svg {
  width: 100%;
  height: 96px;
  display: block;
  margin-bottom: 9px;
  border-radius: 10px;
  background: #0b0b0b;
}

.template-card strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}

.template-card span {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 1px 14px;
  scrollbar-width: none;
}

.filmstrip::-webkit-scrollbar { display: none; }

.film-item {
  position: relative;
  flex: none;
  width: 78px;
  height: 104px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #222;
}

.film-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.film-item.is-selected {
  border-color: rgba(255, 255, 255, 0.9);
}

.film-item.is-best {
  border-color: var(--yellow);
}

.film-item .flag {
  position: absolute;
  left: 5px;
  top: 5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--yellow);
  color: #111;
  font-size: 8px;
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.sheet-actions .secondary,
.sheet-actions .primary {
  margin-top: 0;
  flex: 1;
}

.poster-wrap {
  display: grid;
  place-items: center;
  padding: 2px 0 14px;
}

.poster-wrap img {
  max-width: 100%;
  max-height: 56vh;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(240px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #111;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (max-width: 520px) {
  .stage {
    padding: 0;
    background: #000;
  }

  .phone {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
}

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