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

html, body {
  height: 100%;
  background: #0b0e13;
  color: #e8ecf1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Camera & overlay layers ===== */
#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 50%;
  transition: transform .18s ease-out;
  background: #000;
}

#overlay {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
}

#ghost {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  object-fit: fill;
  pointer-events: none;
  z-index: 2;
  opacity: .5;
}

/* ===== Top bar ===== */
#topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  background: linear-gradient(rgba(5,8,12,.65), transparent);
}

#brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #cfd6df;
}

#btnSettings {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: rgba(15,20,28,.55);
  color: #dfe6ee;
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
}

/* ===== Toast ===== */
#toast {
  position: absolute;
  left: 50%;
  top: calc(max(10px, env(safe-area-inset-top)) + 52px);
  transform: translateX(-50%);
  z-index: 9;
  background: rgba(10,14,20,.88);
  border: 1px solid rgba(255,255,255,.12);
  color: #eef2f7;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
#toast.show { opacity: 1; }

/* ===== Bottom panel ===== */
#bottom {
  position: relative;
  z-index: 5;
  margin-top: auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: linear-gradient(transparent, rgba(5,8,12,.82) 30%);
}

.chipRow {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  justify-content: flex-start;
  justify-content: safe center;
}
.chipRow::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(18,24,33,.6);
  color: #d5dce4;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transition: background .15s, border-color .15s, color .15s;
}
.chip.active {
  background: #e8ecf1;
  border-color: #e8ecf1;
  color: #0b0e13;
  font-weight: 700;
}

/* ghost thumbs */
.ghostBtn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,.22);
  overflow: hidden;
  background: rgba(18,24,33,.6);
  color: #cfd6df;
  display: grid; place-items: center;
}
.ghostBtn img { width: 100%; height: 100%; object-fit: cover; }
.ghostBtn.active { border-color: #ffffff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.ghostOff { width: 38px; height: 38px; margin-top: 3px; }

/* opacity */
#opacityRow { align-items: center; justify-content: center; gap: 10px; }
#opacityRow.hidden, .hidden { display: none !important; }
.opLabel { font-size: 11px; color: #9aa7b4; letter-spacing: .08em; text-transform: uppercase; }
#opVal { font-size: 12px; color: #cfd6df; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] {
  -webkit-appearance: none;
  width: min(46vw, 260px);
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.25);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #e8ecf1;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #e8ecf1; border: none;
}

/* control row */
#controlRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
}

.sideBtn {
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: rgba(18,24,33,.6);
  color: #dfe6ee;
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}

#zoomRow { gap: 5px; }
.zChip { padding: 6px 10px; font-size: 11.5px; }

.shutter {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid #e8ecf1;
  background: transparent;
  display: grid; place-items: center;
  flex: 0 0 auto;
  transition: transform .1s;
}
.shutter:active { transform: scale(.92); }
.shutter span {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: #e8ecf1;
  transition: background .1s;
}
.shutter:active span { background: #b9c2cc; }

#zoomInfo {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ===== Settings sheet ===== */
#settingsModal {
  position: fixed; inset: 0;
  z-index: 20;
  background: rgba(4,6,10,.6);
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(3px);
}
.sheet {
  width: 100%;
  background: #131820;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.1);
}
.sheet h2 { font-size: 16px; margin-bottom: 16px; font-weight: 700; }
.sheet .row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; padding: 6px 0;
}
.sheet .row input { width: 22px; height: 22px; accent-color: #e8ecf1; }
.sheet .hint { font-size: 12px; color: #8b98a7; margin: 8px 0 18px; line-height: 1.5; }
.sheet .chip { border: none; }

/* ===== Camera denied ===== */
#deny {
  position: fixed; inset: 0;
  z-index: 30;
  background: #0b0e13;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}
#deny p { font-size: 15px; font-weight: 600; }
#deny .hint { font-size: 13px; color: #8b98a7; font-weight: 400; line-height: 1.6; }

@media (min-width: 700px) {
  #bottom { max-width: 480px; margin-left: auto; margin-right: auto; width: 100%; align-self: center; }
}
