@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --ink: #f2f0e9;
  --muted: #969a98;
  --acid: #d9ff43;
  --orange: #ff6433;
  --panel: #151719;
  --line: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 12%, rgba(217,255,67,.08), transparent 28rem),
    #090a0c;
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 440px);
  gap: clamp(40px, 8vw, 112px);
  align-items: center;
  padding: 48px 0;
}

.intro { max-width: 520px; }
.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--acid);
  font: 500 12px/1 DM Mono, monospace;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.step-chip span {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--acid);
  border-radius: 50%;
}
h1 {
  margin: 22px 0 18px;
  font-size: clamp(44px, 6.2vw, 78px);
  line-height: .96;
  letter-spacing: -.06em;
}
h1 em { color: var(--acid); font-style: normal; }
.intro > p { color: var(--muted); font-size: 16px; line-height: 1.7; max-width: 450px; }

.status-card {
  margin: 32px 0 22px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.status-heading { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #737775; box-shadow: 0 0 0 4px rgba(115,119,117,.12); }
.status-dot.live { background: var(--acid); box-shadow: 0 0 0 4px rgba(217,255,67,.12); }
.status-dot.error { background: var(--orange); }
.progress-track { height: 2px; background: #292c2e; margin: 15px 0 12px; }
.progress-track span { display: block; width: 8%; height: 100%; background: var(--acid); transition: width .4s ease; }
.status-card p { margin: 0; color: var(--muted); font: 12px/1.5 DM Mono, monospace; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; }
button {
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  padding: 0 17px;
  font: 700 13px Manrope, sans-serif;
  cursor: pointer;
  transition: transform .15s, opacity .15s, background .15s;
}
button:hover:not(:disabled) { transform: translateY(-2px); }
button:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }
button:disabled { opacity: .35; cursor: not-allowed; }
.primary { background: var(--acid); color: #10120b; }
.secondary { background: var(--ink); color: #111; }
.secondary.recording { background: var(--orange); color: white; }
.ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.button-icon { margin-right: 8px; }
.record-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-right: 8px; }
.recording .record-dot { background: white; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.instructions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 24px; color: #797e7b; font: 11px DM Mono, monospace; }
.instructions p { margin: 0; }
.instructions span { color: var(--ink); }
.camera-source { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: #797e7b; font: 10px DM Mono, monospace; text-transform: uppercase; letter-spacing: .08em; }
.camera-source select { min-width: 210px; max-width: 100%; height: 38px; padding: 0 30px 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #111315; color: var(--ink); font: 11px DM Mono, monospace; }
.camera-source select:disabled { opacity: .4; }
.camera-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.camera-actions button { min-height: 38px; padding: 0 13px; font-size: 11px; }
.camera-help { margin: 8px 0 0; color: #686d6a; font: 10px/1.55 DM Mono, monospace; }

.stage-wrap { width: 100%; }
.stage-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 420px);
  margin: auto;
  aspect-ratio: 9 / 16;
  background: #101214;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 24px;
  box-shadow: 0 40px 100px rgba(0,0,0,.55);
}
#stage { display: block; width: 100%; height: 100%; }
#camera { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.permission-card {
  position: absolute;
  left: 50%; bottom: 23%;
  transform: translate(-50%, 50%);
  display: flex; flex-direction: column; align-items: center;
  width: 75%;
  color: var(--muted); text-align: center; font-size: 12px;
  transition: opacity .25s;
}
.permission-card.hidden { opacity: 0; pointer-events: none; }
.permission-card strong { color: var(--ink); margin: 8px 0 3px; }
.permission-icon { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; font-size: 26px; color: var(--acid); }

.live-readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 12px auto 0;
  width: min(100%, 420px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}
.live-readout div { display: flex; flex-direction: column; gap: 4px; padding: 11px 10px; background: #101214; }
.live-readout div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
.live-readout span { color: #686d6a; font: 9px DM Mono, monospace; text-transform: uppercase; }
.live-readout strong { overflow: hidden; text-overflow: ellipsis; color: var(--ink); font: 500 11px DM Mono, monospace; white-space: nowrap; }
.live-readout div:nth-child(2) strong { white-space: normal; line-height: 1.45; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: #111; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.recording-result { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(4,5,6,.78); backdrop-filter: blur(12px); }
.recording-result[hidden] { display: none; }
.result-card { width: min(92vw, 440px); padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: #151719; box-shadow: 0 30px 100px rgba(0,0,0,.7); }
.result-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.result-heading div { display: flex; flex-direction: column; gap: 5px; }
.result-heading span { color: var(--acid); font: 500 9px DM Mono, monospace; letter-spacing: .14em; }
.result-heading strong { font-size: 17px; }
.result-close { min-height: 32px; width: 32px; padding: 0; border-radius: 50%; background: #25282a; color: var(--ink); font-size: 20px; }
#recordingPreview { display: block; width: 100%; max-height: 58vh; border-radius: 10px; background: #090a0c; }
.result-meta { display: flex; justify-content: space-between; padding: 10px 2px; color: var(--muted); font: 10px DM Mono, monospace; }
.download-button { display: grid; place-items: center; min-height: 48px; border-radius: 10px; background: var(--acid); color: #10120b; font-size: 13px; font-weight: 800; text-decoration: none; }
.result-card > p { margin: 12px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; width: min(100% - 28px, 520px); gap: 34px; padding: 28px 0 44px; }
  .intro { max-width: none; }
  h1 { font-size: clamp(42px, 14vw, 68px); }
  .stage-wrap { grid-row: 2; }
}

@media (max-width: 430px) {
  .controls button { flex: 1 1 auto; }
  .live-readout div { padding: 9px 6px; }
  .live-readout strong { font-size: 9px; }
}

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

.instructions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.instructions > p { flex-basis: 100%; }
.instructions select { color: #f2f0e9; background: #191d20; border: 1px solid #424a4d; border-radius: 10px; padding: 12px; font: inherit; }
#sceneCue { color: #d9ff43; font-size: 14px; }
