:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070809;
  color: #f7f7f7;
  font-synthesis: none;
  --panel: rgba(15, 17, 20, 0.84);
  --border: rgba(255, 255, 255, 0.15);
  --muted: #a8adb7;
  --danger: #ff4d5e;
  --record: #ff3048;
  --focus: #ffd84a;
  --fallback: #70b7ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #070809; }
body { min-height: 100dvh; overscroll-behavior: none; }
button, select, input { font: inherit; }
button { border: 0; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; opacity: .55; }
a { color: #cfe5ff; }
[hidden] { display: none !important; }
.sr-only { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }

.app { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 12px; }
.app-header, .header-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(1.35rem, 5vw, 1.8rem); line-height: 1.1; }
.text-button, .setting-button, .icon-button, .round-text-button, .close-button { background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(16px); }
.text-button { min-height:44px; padding: 9px 13px; border-radius: 999px; font-weight: 700; }
.update-button { border-color: rgba(112, 183, 255, .7); color: #d9edff; }
.mode-control-row { width:min(100%,468px); margin:0 auto; display:grid; grid-template-columns:106px minmax(0,240px) 106px; align-items:center; justify-content:center; gap:8px; }
.mode-switcher { grid-column:2; position:relative; isolation:isolate; width:100%; min-width:0; padding:4px; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); border:1px solid var(--border); border-radius:999px; background:#121419; }
.mode-switcher::before { content:""; position:absolute; z-index:0; top:4px; bottom:4px; left:4px; width:calc((100% - 8px)/2); border-radius:999px; background:#fff; transform:translateX(0); transition:transform 180ms ease; pointer-events:none; }
.mode-switcher[data-mode="video"]::before { transform:translateX(100%); }
.mode-button { position:relative; z-index:1; min-width:0; min-height:44px; padding:4px 6px; border-radius:999px; background:transparent; color:var(--muted); font-weight:800; line-height:1.1; overflow-wrap:anywhere; }
.mode-button.active { color:#050607; }
.microphone-status { grid-column:3; min-width:106px; min-height:44px; max-height:54px; padding:0 6px; display:flex; flex-wrap:wrap; align-items:center; align-content:center; justify-content:center; gap:0 4px; border:1px solid currentColor; border-radius:999px; font-size:.65rem; line-height:1.1; font-weight:800; }
.microphone-status span, .microphone-status strong { white-space:nowrap; }
.microphone-status strong { font-size:.7rem; line-height:1.1; letter-spacing:.04em; }
.microphone-status.microphone-off { background:rgba(255,167,38,.15); color:#ffd08a; }
.microphone-status.microphone-on { background:rgba(62,207,126,.14); color:#9cf0bd; }

.camera-stage { position: relative; width: 100%; max-height: 67dvh; overflow: hidden; touch-action: pan-y; background: radial-gradient(circle at 50% 30%, #262a31 0, #0d0f12 45%, #050607 100%); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 18px 50px rgba(0,0,0,.45); isolation: isolate; }
.camera-stage.ratio-4-3 { aspect-ratio: 3 / 4; }
.camera-stage.ratio-1-1 { aspect-ratio: 1; }
.camera-stage.ratio-16-9 { aspect-ratio: 9 / 16; }
.camera-stage video { width: 100%; height: 100%; display: block; object-fit: cover; background: #000; }
.camera-stage video.mirrored { transform: scaleX(-1); }
.camera-top-controls { position: absolute; z-index: 4; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.icon-button, .setting-button { min-width:44px; height:44px; border-radius:999px; display:grid; place-items:center; font-size:.76rem; font-weight:800; }
.icon-button[aria-pressed="true"] { background: #fff; color: #050607; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.status-bar { position: absolute; z-index: 4; left: 14px; right: 14px; bottom: 12px; display: flex; justify-content: space-between; color: rgba(255,255,255,.86); font-size: .73rem; font-weight: 700; text-shadow: 0 1px 8px #000; }
.permission-panel { position: absolute; z-index: 8; inset: 0; padding: 28px; display: grid; align-content: center; justify-items: center; text-align: center; background: rgba(4,5,6,.82); backdrop-filter: blur(12px); }
.permission-title { margin: 0 0 8px; font-size: 1.3rem; font-weight: 800; }
.permission-copy { max-width: 360px; margin: 0 0 20px; color: #d0d4db; line-height: 1.65; }
.primary-button, .secondary-button, .danger-button { min-height: 48px; padding: 0 16px; border-radius: 14px; font-weight: 800; }
.primary-button { background: #fff; color: #050607; }
.secondary-button { background: #24272d; border: 1px solid var(--border); }
.danger-button { background: rgba(255,77,94,.13); border: 1px solid rgba(255,77,94,.48); color: #ff9aa5; }
.compact-button { min-height:44px; padding:0 12px; font-size:.78rem; }

.grid-overlay { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.grid-overlay span { position: absolute; background: rgba(255,255,255,.48); box-shadow: 0 0 1px rgba(0,0,0,.6); }
.grid-overlay span:nth-child(1), .grid-overlay span:nth-child(2) { top: 0; bottom: 0; width: 1px; }
.grid-overlay span:nth-child(1) { left: 33.333%; }
.grid-overlay span:nth-child(2) { left: 66.666%; }
.grid-overlay span:nth-child(3), .grid-overlay span:nth-child(4) { left: 0; right: 0; height: 1px; }
.grid-overlay span:nth-child(3) { top: 33.333%; }
.grid-overlay span:nth-child(4) { top: 66.666%; }
.focus-ring { position: absolute; z-index: 5; width: 68px; height: 68px; transform: translate(-50%,-50%) scale(1.18); border: 2px solid var(--focus); border-radius: 10px; box-shadow: 0 0 0 1px rgba(0,0,0,.45), inset 0 0 0 1px rgba(0,0,0,.25); opacity: 0; pointer-events: none; }
.focus-ring.visible { animation: focus-pop 900ms ease forwards; }
.focus-ring.failed { border-color: #ff7a86; }
.focus-ring.fallback { border-color: var(--fallback); border-style: dashed; }
@keyframes focus-pop { 0% { opacity:0; transform:translate(-50%,-50%) scale(1.3); } 18%,70% { opacity:1; transform:translate(-50%,-50%) scale(1); } 100% { opacity:0; transform:translate(-50%,-50%) scale(.96); } }
.flash-overlay { position:absolute; z-index:6; inset:0; pointer-events:none; background:#fff; opacity:0; }
.flash-overlay.active { animation: flash 180ms ease-out; }
@keyframes flash { 0% {opacity:0} 35% {opacity:.85} 100% {opacity:0} }
.countdown { position:absolute; z-index:7; inset:0; display:grid; place-items:center; pointer-events:none; font-size:clamp(5rem,28vw,10rem); font-weight:900; text-shadow:0 4px 30px #000; }
.recording-badge { position:absolute; z-index:6; top:64px; left:50%; min-height:34px; padding:7px 12px; transform:translateX(-50%); display:flex; align-items:center; gap:7px; border:1px solid rgba(255,255,255,.2); border-radius:999px; background:rgba(0,0,0,.66); font-size:.72rem; font-weight:800; backdrop-filter:blur(12px); white-space:nowrap; }
.recording-metric { display:inline-flex; align-items:center; }
.recording-dot { width:9px; height:9px; border-radius:50%; background:var(--record); box-shadow:0 0 0 4px rgba(255,48,72,.15); animation:pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% {opacity:.35} }
.zoom-control, .exposure-control { position:absolute; z-index:5; left:50%; width:min(78%,350px); padding:7px 10px; transform:translateX(-50%); display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:8px; border:1px solid var(--border); border-radius:999px; background:rgba(0,0,0,.58); backdrop-filter:blur(12px); font-size:.7rem; font-weight:800; }
.zoom-control { bottom:36px; }
.exposure-control { bottom:78px; }
.zoom-control input, .exposure-control input { width:100%; }

.settings-panel { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.setting-field { min-width:0; padding:9px 11px; display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:8px; border:1px solid var(--border); border-radius:14px; background:#111318; }
.setting-field > span, .setting-field > .setting-label { color:var(--muted); font-size:.72rem; font-weight:700; white-space:nowrap; }
.setting-field select { min-width:0; width:100%; min-height:44px; padding:7px 24px 7px 9px; border:0; border-radius:9px; background:#252830; color:#fff; font-size:.78rem; font-weight:800; }
.bottom-controls { min-height:82px; display:grid; grid-template-columns:64px 1fr 64px; align-items:center; }
.preview-button { position:relative; width:56px; height:56px; overflow:visible; padding:0; justify-self:center; border:1px solid var(--border); border-radius:14px; background:#17191d; color:var(--muted); font-size:.7rem; font-weight:800; }
.preview-button img { width:100%; height:100%; display:block; object-fit:cover; border-radius:13px; }
.video-thumbnail-mark { position:absolute; inset:0; display:grid; place-items:center; color:#fff; font-size:1.1rem; text-shadow:0 2px 8px #000; }
.gallery-count { position:absolute; top:-7px; right:-7px; min-width:22px; height:22px; padding:0 5px; display:grid; place-items:center; border:2px solid #070809; border-radius:999px; background:#fff; color:#070809; font-size:.68rem; font-weight:900; }
.shutter-button { width:76px; height:76px; padding:6px; justify-self:center; border:3px solid #fff; border-radius:50%; background:transparent; }
.shutter-button span { display:block; width:100%; height:100%; border-radius:50%; background:#fff; transition:transform 120ms ease,border-radius 160ms ease,background 160ms ease; }
.shutter-button.video span { background:var(--record); }
.shutter-button.recording span { width:62%; height:62%; margin:19%; border-radius:8px; background:var(--record); }
.shutter-button:active span { transform:scale(.88); }
.round-text-button { width:44px; height:44px; justify-self:center; border-radius:50%; font-family:Georgia,serif; font-size:1.1rem; font-weight:700; }
.camera-note { margin:-6px auto 0; max-width:560px; color:var(--muted); font-size:.73rem; line-height:1.55; text-align:center; }
.about-app { max-width:620px; margin:10px auto 0; padding:18px; border:1px solid var(--border); border-radius:18px; background:#111318; color:#d8dbe1; line-height:1.7; }
.about-app h2 { margin:0 0 8px; color:#fff; font-size:1.05rem; }
.about-app p { margin:8px 0; font-size:.82rem; }
.about-meta { display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:10px; color:var(--muted); font-size:.76rem; }
.about-meta strong { color:#fff; }
.about-links { display:flex; flex-wrap:wrap; gap:8px; }

.sheet-dialog { width:min(calc(100% - 24px),760px); max-height:calc(100dvh - 24px); margin:auto; padding:18px; overflow:auto; border:1px solid var(--border); border-radius:22px; background:#111318; color:#fff; box-shadow:0 24px 80px rgba(0,0,0,.65); }
.sheet-dialog::backdrop { background:rgba(0,0,0,.72); backdrop-filter:blur(5px); }
.dialog-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:14px; }
.dialog-header h2 { margin:0; font-size:1.15rem; }
.review-meta { margin:4px 0 0; color:var(--muted); font-size:.75rem; line-height:1.45; overflow-wrap:anywhere; }
.close-button { flex:0 0 auto; width:44px; height:44px; border-radius:50%; font-size:1.6rem; line-height:1; }
.review-dialog { width:min(calc(100% - 24px),1040px); overflow:hidden; overscroll-behavior:contain; }
.review-layout { min-width:0; min-height:0; display:grid; grid-template-columns:minmax(0,1.65fr) minmax(280px,.7fr); gap:18px; }
.review-media-column { min-width:0; min-height:0; display:flex; flex-direction:column; gap:8px; }
.review-photo-nav { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.review-photo-nav[hidden] { display:none; }
.review-photo-nav button { min-height:44px; padding:8px; }
.review-photo-status { grid-column:1/-1; margin:0; color:var(--muted); font-size:.72rem; line-height:1.5; }
.review-viewer { position:relative; touch-action:pan-y pinch-zoom; }
.review-viewer.is-page-zoomed { touch-action:auto; }
.video-preview-status { position:absolute; left:12px; right:12px; bottom:12px; z-index:1; margin:0; padding:8px; border-radius:8px; background:rgba(0,0,0,.8); color:#fff; font-size:.75rem; text-align:center; pointer-events:none; }
.video-thumbnail { position:relative; }
.video-thumbnail img { position:absolute; inset:0; }
.video-thumbnail-placeholder { padding:12px; color:var(--muted); font-size:.72rem; text-align:center; }
.video-thumbnail-badge { position:absolute; bottom:6px; right:6px; padding:4px 6px; border-radius:5px; background:rgba(0,0,0,.7); color:#fff; font-size:.65rem; font-weight:800; }
.review-viewer { min-width:0; min-height:360px; max-height:78dvh; display:grid; place-items:center; overflow:hidden; border-radius:16px; background:#000; }
.review-media { display:block; max-width:100%; max-height:78dvh; object-fit:contain; background:#000; }
#reviewVideo { width:100%; height:auto; }
.review-sidebar { min-width:0; display:flex; flex-direction:column; }
.dialog-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:14px; }
.review-actions { margin-top:auto; grid-template-columns:1fr; }
.dialog-help { margin:12px 0 0; color:var(--muted); font-size:.75rem; line-height:1.5; text-align:center; }

.camera-permission-dialog { width:min(calc(100% - 24px),560px); }
.camera-permission-message { margin:0; color:#d8dbe1; line-height:1.65; }
.camera-permission-instructions { margin-top:16px; padding:14px; border:1px solid var(--border); border-radius:14px; background:#191c21; }
.camera-permission-instructions h3 { margin:0 0 8px; font-size:.95rem; }
.camera-permission-instructions ul { margin:0; padding-left:1.25rem; color:#d8dbe1; line-height:1.65; }
.camera-permission-instructions li + li { margin-top:8px; }
.camera-permission-actions { grid-template-columns:1fr 1fr; }
.camera-permission-actions #closeCameraPermissionButton { grid-column:1/-1; }

.gallery-dialog { width:min(calc(100% - 24px),960px); overscroll-behavior:contain; }
.gallery-header { position:sticky; top:-18px; z-index:3; padding:18px 0 10px; background:#111318; }
.gallery-toolbar { position:sticky; top:55px; z-index:2; display:flex; flex-wrap:wrap; gap:8px; padding:8px 0 14px; background:#111318; }
.recovery-notice { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:10px; margin:0 0 14px; padding:12px; border:1px solid rgba(255,190,90,.45); border-radius:14px; background:rgba(90,55,8,.28); }
.recovery-notice[hidden] { display:none; }
.recovery-notice p { margin:0; color:#ffe0a6; line-height:1.45; }
.recovery-actions { display:flex; flex-wrap:wrap; gap:8px; }
.gallery-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.gallery-card { position:relative; isolation:isolate; min-width:0; border:1px solid var(--border); border-radius:16px; overflow:hidden; background:#17191e; }
.gallery-select { position:absolute; z-index:2; top:6px; left:6px; width:44px; height:44px; display:grid; place-items:center; border-radius:11px; background:rgba(0,0,0,.68); }
.gallery-select input { width:20px; height:20px; }
.gallery-open { width:100%; padding:0; display:block; text-align:left; background:transparent; }
.gallery-open:focus-visible { outline-offset:-4px; }
.gallery-visual { aspect-ratio:4/3; display:grid; place-items:center; overflow:hidden; background:#050607; }
.gallery-visual img { width:100%; height:100%; object-fit:cover; }
.video-placeholder { color:#fff; background:radial-gradient(circle at center,#343945,#08090b); }
.video-placeholder span { font-size:2rem; }
.video-placeholder small { margin-top:-30px; color:var(--muted); font-weight:800; letter-spacing:.12em; }
.gallery-info { padding:10px; display:grid; grid-template-columns:1fr auto; gap:3px 8px; }
.gallery-info strong { font-size:.82rem; }
.gallery-info span, .gallery-info small { color:var(--muted); font-size:.68rem; }
.gallery-info small { grid-column:1/-1; }
.gallery-empty { padding:48px 16px; color:var(--muted); text-align:center; }
.info-dialog ul { padding-left:1.25rem; color:#d8dbe1; line-height:1.75; }
.warning { margin:16px 0 0; padding:14px; border:1px solid rgba(255,255,255,.18); border-radius:14px; background:#1d2026; line-height:1.65; font-weight:700; }
.privacy-link { text-align:center; }
.toast { position:fixed; z-index:20; left:50%; bottom:max(24px,env(safe-area-inset-bottom)); max-width:calc(100% - 32px); padding:11px 16px; transform:translate(-50%,20px); border:1px solid var(--border); border-radius:999px; background:rgba(20,22,26,.96); color:#fff; box-shadow:0 10px 35px rgba(0,0,0,.45); opacity:0; pointer-events:none; transition:opacity 180ms ease,transform 180ms ease; font-size:.82rem; font-weight:700; text-align:center; }
.toast.visible { opacity:1; transform:translate(-50%,0); }

@media (min-width:700px) and (min-height:800px) {
  .camera-stage.ratio-4-3 { aspect-ratio:4/3; }
  .camera-stage.ratio-16-9 { aspect-ratio:16/9; }
  .settings-panel { grid-template-columns:repeat(3,minmax(0,1fr)); }
}

@media (max-width:699px) {
  .sheet-dialog { width:100%; max-width:none; max-height:94dvh; margin:auto 0 0; padding:14px max(14px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left)); border-radius:22px 22px 0 0; }
  .review-dialog { overflow:auto; }
  .review-layout { display:flex; flex-direction:column; gap:12px; }
  .review-viewer { min-height:0; height:auto; max-height:48dvh; border-radius:14px; }
  .review-media { width:100%; height:auto; max-height:48dvh; object-fit:contain; }
  #reviewVideo { width:100%; max-width:100%; max-height:48dvh; }
  .review-sidebar { min-height:0; }
  .review-sidebar .dialog-header { margin-bottom:6px; }
  .review-actions { grid-template-columns:1fr 1fr; margin-top:8px; position:sticky; bottom:0; padding-top:8px; background:#111318; }
  .review-actions .danger-button { grid-column:1/-1; }
  .gallery-dialog { overflow:auto; }
  .gallery-header { top:-14px; padding-top:14px; }
  .gallery-toolbar { top:51px; }
  .gallery-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
}

@media (max-width:420px) {
  .camera-top-controls { gap:0; }
  .icon-button, .setting-button { min-width:44px; height:44px; }
  .setting-field { grid-template-columns:1fr; gap:4px; }
  .recording-badge { top:58px; max-width:calc(100% - 24px); overflow:hidden; }
  .gallery-toolbar { display:grid; grid-template-columns:1fr 1fr; }
  .gallery-toolbar .danger-button { grid-column:1/-1; }
}

@media (max-height:700px) {
  .app { gap:7px; }
  .app-header { display:none; }
  .camera-stage { max-height:67dvh; }
  .bottom-controls { min-height:66px; }
  .shutter-button { width:64px; height:64px; }
  .camera-note { display:none; }
  .settings-panel { display:none; }
  .mode-switcher { width:100%; }
}

@media (max-width:499px) {
  /* Reserve a separate MIC row even in photo mode; the selector stays centered. */
  .mode-control-row { width:min(100%,380px); grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(54px,auto) 44px; gap:4px; }
  .mode-switcher { grid-column:1; grid-row:1; justify-self:center; width:min(100%,240px); }
  .microphone-status { grid-column:1; grid-row:2; justify-self:end; height:44px; max-width:100%; padding:0 12px; flex-wrap:nowrap; }
}

@media (orientation:portrait) and (max-height:700px), (orientation:portrait) and (max-width:699px) {
  /* Use the same available width. Portrait video grows taller instead of
     shrinking sideways; the page can scroll while capture controls stay handy. */
  html:not(.immersive-mode) .camera-stage { max-height:none; flex:0 0 auto; }
  .camera-stage.ratio-4-3 { width:100%; }
  .camera-stage.ratio-1-1 { width:100%; }
  .camera-stage.ratio-16-9 { width:100%; }
  html:not(.immersive-mode) .bottom-controls { position:sticky; z-index:10; bottom:max(8px,env(safe-area-inset-bottom)); border-radius:18px; padding:8px; background:rgba(7,8,9,.94); }
}

html:not(.immersive-mode) .camera-stage[data-capture-mode="video"] video { object-fit:contain; }

@media (orientation:landscape) and (max-height:700px) {
  .camera-stage {
    align-self:center;
    max-height:56dvh;
  }
  .camera-stage.ratio-4-3 { width:min(100%,74.6667dvh); aspect-ratio:4/3; }
  .camera-stage.ratio-1-1 { width:min(100%,56dvh); aspect-ratio:1; }
  .camera-stage.ratio-16-9 { width:min(100%,99.5556dvh); aspect-ratio:16/9; }
  .camera-top-controls { flex-wrap:wrap; justify-content:center; }
}

@keyframes focus-fade { 0%,100% { opacity:0; transform:translate(-50%,-50%); } 18%,70% { opacity:1; transform:translate(-50%,-50%); } }
@keyframes flash-reduced { 0%,100% { opacity:0; } 35% { opacity:.35; } }
@media (prefers-reduced-motion:reduce) {
  .mode-switcher::before { transition:none !important; }
  *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
  .focus-ring.visible { animation:focus-fade 900ms linear forwards !important; }
  .flash-overlay.active { animation:flash-reduced 180ms linear !important; }
  .recording-dot { animation:none !important; }
}

.privacy-page { max-width:820px; }
.policy-card { padding:clamp(18px,4vw,32px); border:1px solid var(--border); border-radius:22px; background:#111318; line-height:1.8; }
.policy-card h2 { margin:1.6em 0 .35em; font-size:1.08rem; }
.policy-card h2:first-child { margin-top:0; }
.policy-card p { color:#d8dbe1; }
