:root {
  color-scheme: dark;
  --bg: #07090c;
  --line: rgba(255, 255, 255, .12);
  --muted: #a6abb0;
  --accent: #d8ff70;
  --danger: #ff5b61;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: #fff;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 38%, #20252c 0, #0b0e12 54%, #07090c 100%);
}

#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #080a0d; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.5), transparent 27%, transparent 55%, rgba(0,0,0,.8)); }
.camera-off #camera { opacity: 0; }

.topbar {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
}
.identity { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 800; letter-spacing: .2em; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; padding-right: 3px; border-radius: 11px; background: var(--accent); color: #11150b; font-size: 21px; letter-spacing: -.12em; box-shadow: 0 8px 24px rgba(216,255,112,.14); }
.mark-dot { color: #11150b; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button, .round-button, .close-button, .script-chip { border: 1px solid var(--line); background: rgba(22,25,29,.72); color: #fff; backdrop-filter: blur(18px); }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; }
.icon-button svg, .round-button svg, .script-chip svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.script-chip { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 11px 0 13px; border-radius: 13px; font-size: 12px; font-weight: 700; }
.script-chip svg { width: 16px; height: 16px; color: var(--accent); }

.setup-card {
  position: absolute;
  z-index: 3;
  top: 48%;
  left: 50%;
  width: min(380px, calc(100% - 38px));
  transform: translate(-50%, -50%);
  padding: 28px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(26,30,36,.96), rgba(12,15,19,.96));
  box-shadow: 0 28px 80px rgba(0,0,0,.45);
  text-align: center;
}
.setup-kicker, .sheet-kicker { display: block; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.setup-card h1 { margin: 10px 0 12px; font-size: clamp(34px, 9vw, 46px); line-height: .98; letter-spacing: -.055em; }
.setup-card p { margin: 0 0 22px; color: #b4b8bd; font-size: 13px; line-height: 1.45; }
.setup-card small { display: block; margin-top: 15px; color: #777d83; font-size: 10px; }
.setup-primary { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 54px; font-size: 15px; }
.camera-symbol { position: relative; display: inline-block; width: 17px; height: 13px; border: 1.8px solid currentColor; border-radius: 4px; }
.camera-symbol:after { content: ""; position: absolute; top: 3px; right: -5px; width: 5px; height: 7px; border: 1.8px solid currentColor; border-left: 0; border-radius: 0 3px 3px 0; }
.setup-secondary { width: 100%; margin-top: 9px; padding: 13px; border: 0; background: transparent; color: #e6e8e9; font-size: 13px; font-weight: 700; }

.prompt {
  position: absolute;
  z-index: 2;
  top: calc(env(safe-area-inset-top) + 72px);
  left: 50%;
  width: 58%;
  height: 22vh;
  max-height: 34%;
  transform: translateX(-50%);
  overflow: hidden;
  border-radius: 18px;
  transition: opacity .2s;
}
.camera-off .prompt { opacity: 0; pointer-events: none; }
.prompt-glass { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.1); border-radius: inherit; background: rgba(4,6,8,.55); backdrop-filter: blur(6px); }
.prompt-track { position: absolute; inset: 0; overflow: hidden; padding: 0 12px; }
.prompt-text { position: absolute; top: 0; left: 12px; right: 12px; color: #fff; font-size: 30px; font-weight: 700; line-height: 1.32; letter-spacing: -.03em; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; transform: translateY(0); will-change: transform; }
.reading-line { position: absolute; z-index: 2; top: 48%; left: 12px; right: 12px; height: 1px; background: linear-gradient(90deg, transparent, rgba(216,255,112,.22), transparent); pointer-events: none; }
.prompt-fade { position: absolute; z-index: 3; left: 1px; right: 1px; height: 34px; pointer-events: none; }
.prompt-fade-top { top: 1px; background: linear-gradient(rgba(8,10,12,.98), transparent); }
.prompt-fade-bottom { bottom: 1px; background: linear-gradient(transparent, rgba(8,10,12,.98)); }

.dock {
  position: absolute;
  z-index: 4;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px 21px calc(env(safe-area-inset-bottom) + 14px);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 27px 27px 0 0;
  background: linear-gradient(180deg, rgba(18,21,25,.84), rgba(8,10,13,.97));
  box-shadow: 0 -18px 60px rgba(0,0,0,.3);
  backdrop-filter: blur(24px);
  transition: transform .28s ease;
}
.camera-off .dock { transform: translateY(105%); pointer-events: none; }
.dock-heading, .dock-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.session-state { display: flex; align-items: center; gap: 8px; color: #e0e2e3; font-size: 12px; font-weight: 650; }
.state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.recording .state-dot { background: #ff6868; box-shadow: 0 0 0 5px rgba(255,104,104,.14); }
.timer { color: #c5c8ca; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.primary-controls { display: flex; align-items: flex-start; justify-content: center; gap: clamp(23px, 8vw, 38px); margin: 12px 0 9px; }
.control-item { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 62px; color: #92979c; font-size: 10px; font-weight: 650; }
.record-control { margin-top: -4px; color: #d9dcde; }
.round-button { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; }
.round-button.active { border-color: rgba(216,255,112,.55); color: var(--accent); }
#playIcon { width: 21px; height: 21px; fill: currentColor; stroke: none; }
.record-button { display: grid; place-items: center; width: 70px; height: 70px; padding: 0; border: 3px solid #fff; border-radius: 50%; background: rgba(255,255,255,.08); box-shadow: 0 0 0 5px rgba(255,255,255,.07); }
.record-inner { width: 50px; height: 50px; border-radius: 50%; background: var(--danger); transition: .2s; }
.recording .record-inner { width: 25px; height: 25px; border-radius: 7px; }
.dock-footer { min-height: 24px; }
.text-button { padding: 6px 0; border: 0; background: none; color: var(--accent); font-size: 11px; font-weight: 750; }
.dock-footer #hint { color: #8f9499; font-size: 9px; text-align: center; }
.resolution { max-width: 112px; overflow: hidden; color: #9da2a7; font-size: 9px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.countdown { position: absolute; z-index: 8; top: 48%; left: 50%; transform: translate(-50%,-50%); font-size: clamp(94px,24vw,180px); font-weight: 800; text-shadow: 0 10px 50px #000; }
.toast { position: absolute; z-index: 10; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 220px); min-width: 190px; max-width: calc(100% - 40px); padding: 11px 16px; transform: translateX(-50%) translateY(12px); border-radius: 13px; background: #edf0f2; color: #111; opacity: 0; pointer-events: none; font-size: 13px; font-weight: 700; text-align: center; transition: .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.shade { position: absolute; z-index: 5; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(3px); }
.sheet { position: absolute; z-index: 6; bottom: 0; left: 0; right: 0; max-height: min(90dvh, 880px); overflow-y: auto; padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px); border: 1px solid #31363c; border-bottom: 0; border-radius: 28px 28px 0 0; background: #15181c; box-shadow: 0 -25px 90px rgba(0,0,0,.5); }
.sheet-handle { width: 38px; height: 5px; margin: 0 auto 19px; border-radius: 8px; background: #464b51; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-kicker { margin-bottom: 6px; font-size: 9px; }
.sheet h1 { margin: 0; font-size: 26px; font-weight: 780; letter-spacing: -.04em; }
.close-button { width: 38px; height: 38px; border-radius: 13px; font-size: 25px; line-height: 1; }
.sheet-copy { margin: 12px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.sheet textarea { display: block; width: 100%; height: min(46dvh, 460px); padding: 17px; resize: vertical; border: 1px solid #41474e; border-radius: 18px; outline: none; background: #0c0f12; color: #fff; font-size: 17px; line-height: 1.52; caret-color: var(--accent); }
.sheet textarea:focus { border-color: rgba(216,255,112,.7); box-shadow: 0 0 0 3px rgba(216,255,112,.06); }
.script-stats { display: flex; justify-content: space-between; padding: 13px 3px 15px; color: #a6abb0; font-size: 12px; font-weight: 650; }
.solid-button { padding: 13px 21px; border: 0; border-radius: 14px; background: var(--accent); color: #15190d; font-size: 14px; font-weight: 780; }
.wide { width: 100%; min-height: 50px; }
.setting { padding: 18px 0; border-bottom: 1px solid #30353b; }
.setting-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; font-size: 14px; font-weight: 680; }
.setting output { color: var(--accent); font-size: 12px; }
.setting input[type=range] { width: 100%; accent-color: var(--accent); }
.scale { display: flex; justify-content: space-between; margin-top: 6px; color: #858b92; font-size: 10px; }
.setting select { width: 100%; padding: 13px; border: 1px solid #41474e; border-radius: 13px; background: #22262b; color: #fff; font-size: 14px; }
.setting small, .toggle-row small { display: block; margin-top: 7px; color: #999fa6; font-size: 11px; line-height: 1.45; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 21px 0; }
.toggle-row strong { font-size: 14px; }
.toggle-row input { position: absolute; opacity: 0; }
.switch { position: relative; flex: none; width: 47px; height: 28px; border-radius: 25px; background: #444a50; transition: .2s; }
.switch:after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle-row input:checked + .switch { background: var(--accent); }
.toggle-row input:checked + .switch:after { transform: translateX(19px); background: #111; }
.install-note { padding: 15px; border: 1px solid #373d44; border-radius: 15px; background: #24282d; font-size: 13px; }
.install-note p { margin: 7px 0 0; color: #abb0b6; line-height: 1.5; }
.result-sheet video { width: 100%; max-height: 48dvh; margin: 18px 0 14px; border-radius: 14px; background: #000; }
.result-sheet .sheet-copy { margin-bottom: 0; text-align: center; }

@media (min-width: 720px) {
  body { background: #05070a; }
  .app { max-width: 470px; margin: 0 auto; border-left: 1px solid #262a30; border-right: 1px solid #262a30; box-shadow: 0 0 110px rgba(0,0,0,.9); }
}

@media (display-mode: standalone) {
  .install-note { display: none; }
  .topbar { padding-top: calc(env(safe-area-inset-top) + 10px); }
  .prompt { top: calc(env(safe-area-inset-top) + 68px); }
}

@media (max-width: 380px) {
  .identity > span:last-child { display: none; }
  .script-chip { padding-left: 10px; }
  .prompt { width: 64%; }
  .prompt-text { font-size: 28px; }
  .primary-controls { gap: 18px; }
}

@media (max-height: 700px) {
  .setup-card { top: 47%; padding-top: 22px; padding-bottom: 18px; }
  .setup-card h1 { font-size: 34px; }
  .prompt { max-height: 31%; }
  .dock { padding-top: 11px; }
  .primary-controls { margin: 7px 0 5px; }
  .record-button { width: 60px; height: 60px; }
  .record-inner { width: 42px; height: 42px; }
  .control-item { gap: 4px; }
}
