:root {
  color-scheme: dark;
  --bg: #07080c;
  --panel: #151820;
  --panel-2: #1d202a;
  --line: #303440;
  --text: #f7f7f5;
  --muted: #a4aab8;
  --red: #ef3340;
  --red-dark: #b81421;
  --gold: #ffc942;
  --green: #31d17c;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
fieldset { padding: 0; border: 0; margin: 0; }
fieldset legend { width: 100%; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; padding: 0; margin: -1px; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Full-screen camera */
.creator-page { width: 100%; height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
.creator-page.overlay-open { touch-action: none; }
.fullscreen-studio, .camera-stage { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #000; }
.camera-stage > #camera-preview { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; background: #000; transform: scaleX(1); }
.camera-stage.user-camera > #camera-preview { transform: scaleX(-1); }
.camera-placeholder { position: absolute; z-index: 3; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px; text-align: center; background: radial-gradient(circle at center, #272b36 0, #08090d 65%); }
.camera-placeholder > span:not(.camera-symbol) { max-width: 310px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.camera-symbol { display: grid; width: 68px; height: 68px; place-items: center; margin-bottom: 5px; border: 2px solid rgba(255,255,255,.17); border-radius: 50%; color: var(--red); font-size: 30px; }

.camera-topbar { position: absolute; z-index: 20; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); background: linear-gradient(to bottom, rgba(0,0,0,.8), rgba(0,0,0,.28) 72%, transparent); pointer-events: none; }
.camera-topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand b { font-size: 16px; }
.brand small { margin-top: 4px; color: #c9cdd7; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; width: 66px; height: 66px; place-items: center; border-radius: 19px; background: linear-gradient(145deg, #ff4654, #c41122); box-shadow: 0 12px 35px rgba(239,51,64,.24); font-weight: 950; letter-spacing: -.08em; }
.small-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 14px; }
.camera-actions { display: flex; align-items: center; gap: 8px; }
.camera-actions form { margin: 0; }
.hud-button, .round-hud { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid rgba(255,255,255,.23); background: rgba(9,10,14,.66); box-shadow: 0 7px 22px rgba(0,0,0,.2); backdrop-filter: blur(12px); cursor: pointer; }
.hud-button { gap: 7px; padding: 0 14px; border-radius: 999px; font-size: 12px; font-weight: 850; }
.hud-button > span { color: var(--green); }
.accent-hud { border-color: rgba(239,51,64,.55); background: rgba(179,19,32,.75); }
.accent-hud > span { color: white; }
.round-hud { width: 42px; padding: 0; border-radius: 50%; font-size: 20px; }
.lock-hud { font-size: 18px; color: #d8dae1; }

.notes-overlay { position: absolute; z-index: 12; top: max(82px, calc(env(safe-area-inset-top) + 72px)); right: max(20px, env(safe-area-inset-right)); width: min(270px, calc(100% - 40px)); max-height: min(42dvh, 370px); overflow-x: hidden; overflow-y: auto; padding: 13px; border: 1px solid rgba(255,255,255,.2); border-radius: 16px; background: rgba(8,10,14,.7); box-shadow: 0 10px 35px rgba(0,0,0,.3); backdrop-filter: blur(12px); overscroll-behavior: contain; }
.notes-overlay.collapsed { width: auto; }
.notes-overlay.collapsed .overlay-note-list, .notes-overlay.collapsed .overlay-empty { display: none; }
.overlay-heading { display: flex; justify-content: space-between; gap: 14px; align-items: center; font-size: 12px; }
.overlay-heading button { padding: 3px; border: 0; background: none; color: #d3d6de; font-size: 11px; cursor: pointer; }
.overlay-note-list { display: grid; gap: 8px; padding: 0; margin: 11px 0 0; list-style: none; }
.overlay-note-list label { display: flex; gap: 8px; align-items: flex-start; color: white; font-size: 12px; line-height: 1.35; cursor: pointer; }
.overlay-note-list input { margin: 1px 0 0; accent-color: var(--green); }
.overlay-note-list .done { opacity: .48; text-decoration: line-through; }
.overlay-empty { margin: 10px 0 0; color: var(--muted); font-size: 11px; }

.recording-indicator { position: absolute; z-index: 16; top: max(88px, calc(env(safe-area-inset-top) + 78px)); left: max(20px, env(safe-area-inset-left)); padding: 8px 11px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(0,0,0,.72); box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 11px; font-weight: 900; letter-spacing: .09em; backdrop-filter: blur(10px); }
.recording-indicator span { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; }

.capture-dock { position: absolute; z-index: 18; left: 50%; bottom: 0; width: min(860px, calc(100% - 24px)); padding: 14px 18px max(15px, env(safe-area-inset-bottom)); border: 1px solid rgba(255,255,255,.15); border-bottom: 0; border-radius: 24px 24px 0 0; background: linear-gradient(180deg, rgba(13,15,20,.78), rgba(8,9,13,.96)); box-shadow: 0 -18px 55px rgba(0,0,0,.34); backdrop-filter: blur(18px); transform: translateX(-50%); }
.capture-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(320px, 100%); margin: 0 auto 10px; }
.mode-choice, .aspect-choice { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; padding: 8px 10px; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; background: rgba(32,35,44,.84); cursor: pointer; transition: .15s ease; }
.mode-choice input, .aspect-choice input { position: absolute; opacity: 0; pointer-events: none; }
.mode-choice span { display: flex; gap: 7px; align-items: baseline; }
.mode-choice b { font-size: 12px; }
.mode-choice small, .aspect-choice small { color: var(--muted); font-size: 10px; }
.mode-choice.active-choice, .aspect-choice.active-choice { border-color: var(--red); background: rgba(188,28,40,.24); box-shadow: inset 0 0 0 1px var(--red); }

.record-dial-wrap { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 88px; }
.record-dial { position: relative; display: grid; width: 92px; height: 92px; flex: 0 0 auto; place-items: center; }
.record-progress { position: absolute; z-index: 1; inset: -6px; width: 104px; height: 104px; overflow: visible; pointer-events: none; transform: rotate(-90deg); }
.progress-track, .progress-value { fill: none; stroke-width: 5; }
.progress-track { stroke: rgba(255,255,255,.25); }
.progress-value { stroke: var(--red); stroke-linecap: round; stroke-dasharray: 295.31; stroke-dashoffset: 295.31; filter: drop-shadow(0 0 4px rgba(239,51,64,.55)); }
.record-button { position: relative; z-index: 2; display: grid; width: 76px; height: 76px; place-items: center; padding: 0; border: 3px solid white; border-radius: 50%; background: rgba(0,0,0,.4); box-shadow: 0 8px 30px rgba(0,0,0,.35); cursor: pointer; }
.record-core { width: 58px; height: 58px; border-radius: 50%; background: var(--red); transition: .18s ease; box-shadow: inset 0 -5px 12px rgba(118,0,10,.24); }
.record-button:hover:not(:disabled) .record-core { transform: scale(.93); }
.record-button:disabled { opacity: .4; cursor: not-allowed; }
.record-button.recording .record-core { width: 31px; height: 31px; border-radius: 7px; }
.record-readout { display: grid; min-width: 160px; }
.record-readout output { color: white; font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.record-readout strong { margin-top: 5px; font-size: 13px; }
.record-readout small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.filmstrip-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.filmstrip-heading > strong { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.count-badge { padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.1); color: #dfe2e9; font-size: 10px; font-weight: 850; }
.filmstrip-empty { display: grid; min-height: 66px; place-items: center; margin-top: 7px; border: 1px dashed rgba(255,255,255,.18); border-radius: 13px; color: var(--muted); font-size: 11px; text-align: center; }
.clip-list { display: flex; gap: 9px; overflow-x: auto; overflow-y: hidden; min-height: 82px; padding: 7px 2px 2px; margin: 0; list-style: none; counter-reset: clip; scrollbar-width: thin; scrollbar-color: #555b68 transparent; scroll-snap-type: x proximity; }
.clip-strip-item { position: relative; flex: 0 0 74px; width: 74px; scroll-snap-align: start; counter-increment: clip; }
.clip-open { position: relative; display: block; overflow: hidden; width: 74px; height: 74px; padding: 0; border: 1px solid rgba(255,255,255,.25); border-radius: 13px; background: #000; cursor: pointer; }
.clip-open:hover, .clip-open:focus-visible { border-color: var(--red); outline: none; box-shadow: 0 0 0 2px rgba(239,51,64,.35); }
.clip-open video { display: block; width: 100%; height: 100%; object-fit: contain; background: black; pointer-events: none; }
.clip-number { position: absolute; top: 5px; left: 5px; display: grid; width: 21px; height: 21px; place-items: center; border-radius: 7px; background: rgba(0,0,0,.82); font-size: 10px; font-weight: 900; }
.clip-number::after { content: counter(clip); }
.clip-timing { position: absolute; right: 4px; bottom: 4px; max-width: calc(100% - 8px); padding: 3px 5px; overflow: hidden; border-radius: 999px; background: rgba(0,0,0,.82); color: var(--gold); font-size: 8px; font-weight: 900; white-space: nowrap; text-overflow: ellipsis; }
.clip-timing.normal { color: white; }

.global-message { position: absolute; z-index: 80; top: max(78px, calc(env(safe-area-inset-top) + 68px)); left: 50%; width: max-content; max-width: calc(100% - 28px); padding: 11px 15px; border: 1px solid #424854; border-radius: 12px; background: rgba(30,34,43,.95); box-shadow: 0 12px 30px rgba(0,0,0,.32); font-size: 12px; text-align: center; transform: translateX(-50%); backdrop-filter: blur(10px); }
.global-message.error { border-color: #82343b; background: #39181d; color: #ffd9dc; }
.global-message.success { border-color: #23653f; background: #102c1d; color: #c9ffdf; }

/* Drawers */
.drawer-layer { position: fixed; z-index: 100; inset: 0; display: flex; align-items: stretch; justify-content: flex-end; padding: 0; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); cursor: default; }
.drawer-card { position: relative; z-index: 1; width: min(480px, 100%); height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; overflow-x: hidden; overflow-y: auto; padding: max(24px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom)); border-left: 1px solid var(--line); background: #12151c; box-shadow: -18px 0 55px rgba(0,0,0,.42); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.drawer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.drawer-heading h2 { margin: 5px 0 0; font-size: 28px; letter-spacing: -.035em; }
.drawer-close, .viewer-close { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 13px; background: #222630; color: white; font-size: 26px; cursor: pointer; }
.eyebrow { margin: 0; color: var(--red); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.panel-copy { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.device-storage-note { display: flex; align-items: flex-start; gap: 11px; padding: 12px 13px; margin: -4px 0 17px; border: 1px solid rgba(51,194,116,.32); border-radius: 13px; background: rgba(23,106,60,.14); }
.device-storage-note > span { font-size: 20px; line-height: 1; }
.device-storage-note > div { display: grid; gap: 3px; min-width: 0; }
.device-storage-note strong { color: #bfffd8; font-size: 12px; }
.device-storage-note small { color: #aeb8b3; font-size: 10px; line-height: 1.45; }
.note-form { display: flex; gap: 9px; }
.note-form input, .login-form input { min-width: 0; flex: 1; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: #090b10; color: var(--text); }
.note-form input:focus, .login-form input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,51,64,.15); }
.note-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 13px 0 0; color: var(--muted); font-size: 10px; }
.text-button { padding: 7px; border: 0; background: transparent; color: #c5c9d2; font-size: 11px; font-weight: 800; cursor: pointer; }
.note-list { display: grid; gap: 8px; padding: 0 0 1px; margin: 12px 0 0; list-style: none; }
.note-item { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #0c0e13; }
.note-item label { display: flex; flex: 1; gap: 9px; min-width: 0; align-items: flex-start; cursor: pointer; }
.note-item input { margin-top: 2px; accent-color: var(--green); }
.note-item span { overflow-wrap: anywhere; font-size: 13px; line-height: 1.35; }
.note-item.done span { color: var(--muted); text-decoration: line-through; }
.delete-note { flex: 0 0 auto; width: 30px; height: 30px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.delete-note:hover { background: rgba(255,255,255,.07); color: white; }

.aspect-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 5px 0 17px; }
.aspect-choices legend { grid-column: 1 / -1; }
.aspect-choice { flex-direction: column; gap: 4px; padding: 13px 8px; text-align: center; }
.aspect-choice b { font-size: 12px; }
.aspect-icon { display: block; border: 2px solid #8e95a5; border-radius: 3px; }
.vertical-icon { width: 16px; height: 25px; }
.square-icon { width: 23px; height: 23px; }
.landscape-icon { width: 29px; height: 19px; }
.active-choice .aspect-icon { border-color: #ff7a83; }

.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 17px; border: 0; border-radius: 12px; color: white; text-decoration: none; font-weight: 850; cursor: pointer; }
.primary-button { background: linear-gradient(135deg, #f03b48, #c71625); box-shadow: 0 8px 20px rgba(239,51,64,.18); }
.secondary-button { border: 1px solid #414755; background: #262a35; }
.danger-button { border: 1px solid rgba(239,51,64,.42); background: rgba(147,20,31,.34); color: #ffb4b9; }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: .4; cursor: not-allowed; }
.full-button { width: 100%; }
.render-progress { display: flex; min-height: 68px; align-items: center; justify-content: center; gap: 5px; color: #dfe1e6; font-size: 12px; }
.render-progress span { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: bounce .9s infinite ease-in-out; }
.render-progress span:nth-child(2) { animation-delay: .15s; }
.render-progress span:nth-child(3) { margin-right: 8px; animation-delay: .3s; }
.render-result { overflow: hidden; margin-top: 17px; border: 1px solid var(--line); border-radius: 16px; background: #080a0e; }
.render-result video { display: block; width: 100%; max-height: 60dvh; object-fit: contain; background: black; }
.result-copy { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; }
.result-copy > div { display: grid; }
.result-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.result-actions { display: flex !important; grid-template-columns: 1fr; gap: 8px; }
.result-actions .primary-button, .result-actions .secondary-button { min-height: 42px; white-space: nowrap; }

/* Full-screen clip viewer */
.clip-viewer { position: fixed; z-index: 140; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; background: #000; }
.viewer-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 72px; padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); background: #0b0d12; }
.viewer-heading > div { display: grid; }
.viewer-heading span { color: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.viewer-heading h2 { margin: 3px 0 0; font-size: 19px; }
.viewer-stage { display: grid; min-height: 0; place-items: center; overflow: hidden; background: black; }
.viewer-stage video { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; background: black; }
.viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: #0b0d12; }
.viewer-meta { display: grid; }
.viewer-meta strong { font-size: 13px; }
.viewer-meta small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.viewer-actions { display: flex; gap: 8px; }

/* Private login */
.login-page { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 20px; background: radial-gradient(circle at 50% -20%, #31252d 0, var(--bg) 44rem); }
.login-shell { width: min(420px, 100%); }
.login-card { padding: 36px; border: 1px solid var(--line); border-radius: 26px; background: rgba(21,24,32,.97); box-shadow: 0 25px 80px rgba(0,0,0,.4); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 5px 0 8px; font-size: 38px; letter-spacing: -.04em; }
.login-copy { margin: 0 0 25px; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 10px; }
.login-form label { font-size: 12px; font-weight: 800; }
.login-form input { width: 100%; margin-bottom: 4px; }
.form-error { margin: 0 0 4px; color: #ff959c; font-size: 12px; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: .35; } 50% { transform: translateY(-5px); opacity: 1; } }

@media (max-width: 680px) {
  .camera-topbar { min-height: 64px; padding-left: 12px; padding-right: 12px; }
  .brand > span:last-child { display: none; }
  .small-mark { width: 40px; height: 40px; }
  .camera-actions { gap: 6px; }
  .hud-button { width: 42px; padding: 0; border-radius: 50%; font-size: 0; }
  .hud-button > span { font-size: 16px; }
  .round-hud { width: 40px; min-height: 40px; }
  .lock-hud { display: none; }
  .notes-overlay { top: max(68px, calc(env(safe-area-inset-top) + 58px)); right: 10px; width: min(238px, calc(100% - 20px)); max-height: 30dvh; }
  .recording-indicator { top: max(70px, calc(env(safe-area-inset-top) + 60px)); left: 10px; }
  .capture-dock { width: 100%; padding: 9px 12px max(9px, env(safe-area-inset-bottom)); border-left: 0; border-right: 0; border-radius: 21px 21px 0 0; }
  .capture-modes { margin-bottom: 6px; }
  .mode-choice { padding: 6px 8px; }
  .record-dial-wrap { min-height: 78px; gap: 12px; }
  .record-dial { width: 80px; height: 80px; }
  .record-progress { inset: -6px; width: 92px; height: 92px; }
  .record-button { width: 66px; height: 66px; }
  .record-core { width: 50px; height: 50px; }
  .record-readout { min-width: 145px; }
  .record-readout output { font-size: 19px; }
  .record-readout small { max-width: 175px; }
  .filmstrip-heading { margin-top: 3px; }
  .clip-list { min-height: 72px; }
  .clip-strip-item, .clip-open { width: 65px; flex-basis: 65px; }
  .clip-open { height: 65px; }
  .filmstrip-empty { min-height: 55px; }
  .drawer-layer { align-items: flex-end; }
  .drawer-card { width: 100%; height: auto; max-height: 88vh; max-height: 88dvh; padding: 19px 16px max(22px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -18px 55px rgba(0,0,0,.5); }
  .drawer-heading h2 { font-size: 24px; }
  .viewer-footer { align-items: stretch; flex-direction: column; gap: 9px; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .viewer-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .viewer-actions > button { min-width: 0; padding: 0 9px; font-size: 11px; }
  .result-copy { align-items: stretch; flex-direction: column; }
  .result-actions { display: grid !important; grid-template-columns: 1fr; width: 100%; }
  .result-actions .primary-button, .result-actions .secondary-button { width: 100%; }
  .login-card { padding: 27px 22px; }
}

@media (max-height: 700px) and (max-width: 680px) {
  .capture-modes { width: 280px; }
  .record-dial-wrap { min-height: 70px; }
  .record-dial { width: 72px; height: 72px; }
  .record-progress { inset: -5px; width: 82px; height: 82px; }
  .record-button { width: 60px; height: 60px; }
  .record-core { width: 45px; height: 45px; }
  .record-readout output { font-size: 17px; }
  .clip-list { min-height: 62px; }
  .clip-strip-item, .clip-open { width: 56px; flex-basis: 56px; }
  .clip-open { height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
