:root {
  --bg: #0e0e0e;
  --panel: #191919;
  --raised: #262625;
  --line: rgba(255,255,255,0.14);
  --text: #ffffff;
  --muted: rgba(255,255,255,0.62);
  --accent: #e8a13a;
  --accent-soft: rgba(232,161,58,0.16);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) 18px 12px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand h1 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.3px;
  margin: 0;
}

.brand span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: #333;
}

.stage {
  position: relative;
  flex: 1;
  margin: 4px 14px 0;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

#video,
#preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#preview { display: none; }
#canvas { display: none; }
.video-filter { will-change: filter; }

.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  max-width: 320px;
  z-index: 2;
}

.placeholder .big {
  font-size: 40px;
  margin-bottom: 12px;
}

.placeholder p {
  font-size: 13.5px;
  line-height: 1.6;
  margin: 6px 0;
}

.start-btn {
  margin-top: 18px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a1205;
  border: none;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.start-btn:active { transform: scale(0.96); }

.start-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.permission-note {
  min-height: 38px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.permission-note[data-tone="ok"] { color: #b9e7bf; }
.permission-note[data-tone="error"] { color: #ffb4a8; }
.permission-note[data-tone="warn"] { color: #ffd59a; }

.vignette-ovl,
.datestamp {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vignette-ovl {
  box-shadow: inset 0 0 120px 24px rgba(0,0,0,0.55);
  border-radius: 20px;
}

.datestamp {
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px 18px;
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 17px;
  color: #ff8c26;
  text-shadow: 0 0 6px rgba(255,120,20,0.85), 0 0 2px rgba(255,60,0,0.9);
  letter-spacing: 1px;
}

body.stamp-on .datestamp { display: flex; }
body.mode-preview .datestamp { display: none; }

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.flash.fire { animation: flash .45s ease-out; }

@keyframes flash {
  0% { opacity: .85; }
  100% { opacity: 0; }
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid var(--line);
}

.filters {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 14px 4px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
}

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

.chip {
  flex: 0 0 auto;
  scroll-snap-align: center;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 30px calc(var(--safe-b) + 20px);
  gap: 18px;
  touch-action: none;
}

.side-btn {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.side-btn:active { transform: scale(0.92); }
.side-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.thumb-btn {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--raised);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 20px;
}

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

.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.85);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
}

.shutter .core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  transition: transform .12s ease, background .12s ease;
}

.shutter:active .core {
  transform: scale(0.86);
  background: #eee;
}

.preview-actions { display: none; }
body.mode-preview .preview-actions { display: flex; }
body.mode-preview .capture-actions { display: none; }
body.mode-preview #video,
body.mode-preview .video-live-ovl { display: none; }
body.mode-preview #preview { display: block; }

.capture-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 18px;
}

.preview-actions {
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 14px;
}

.pill-btn {
  flex: 1;
  padding: 15px 10px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 650;
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: center;
}

.pill-btn.ghost { background: var(--raised); color: var(--text); }
.pill-btn.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); }
.pill-btn:active { transform: scale(0.97); }

.hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 20px 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 130px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,20,0.95);
  border: 1px solid var(--line);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  transition: all .28s ease;
  pointer-events: none;
  z-index: 20;
  max-width: 84%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
