body.camera-open { overflow: hidden; width: 100%; }

.camera-modal {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
  box-sizing: border-box;
}
.camera-modal::backdrop { background: #000; }

.camera-shell {
  direction: rtl;
  position: relative;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  background: #000;
  overflow: hidden;
}

.camera-view {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

.camera-stage {
  position: relative;
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #050505;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.camera-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #050505;
  transform-origin: 50% 50%;
}

.camera-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background:
    linear-gradient(to right, transparent 33.15%, rgba(255,255,255,.55) 33.25%, transparent 33.35%, transparent 66.55%, rgba(255,255,255,.55) 66.65%, transparent 66.75%),
    linear-gradient(to bottom, transparent 33.15%, rgba(255,255,255,.55) 33.25%, transparent 33.35%, transparent 66.55%, rgba(255,255,255,.55) 66.65%, transparent 66.75%);
}

.camera-topbar {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 16px 14px;
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
  align-items: center;
  gap: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,.84), rgba(0,0,0,.38), transparent);
  box-sizing: border-box;
  pointer-events: none;
}
.camera-topbar > * { pointer-events: auto; }
.camera-topbar strong { text-align: center; font-size: 17px; text-shadow: 0 1px 7px rgba(0,0,0,.65); }
.camera-text-button {
  justify-self: start;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 750;
  padding: 9px 0;
  text-shadow: 0 1px 7px rgba(0,0,0,.65);
}
.camera-count {
  justify-self: end;
  min-width: 68px;
  color: rgba(255,255,255,.76);
  font-size: 13px;
  text-align: end;
  text-shadow: 0 1px 7px rgba(0,0,0,.65);
}

.camera-ratio-bar {
  position: absolute;
  z-index: 12;
  top: calc(max(10px, env(safe-area-inset-top)) + 67px);
  left: 50%;
  transform: translateX(-50%);
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(0,0,0,.48);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.camera-ratio-bar button {
  min-width: 46px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255,255,255,.72);
  font-size: 12px;
  font-weight: 750;
}
.camera-ratio-bar button.active {
  background: rgba(255,255,255,.95);
  color: #111;
}

.camera-quick-actions {
  position: absolute;
  z-index: 12;
  top: calc(max(10px, env(safe-area-inset-top)) + 116px);
  left: 12px;
  display: grid;
  gap: 8px;
}
.camera-circle-action {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 50%;
  background: rgba(0,0,0,.50);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.camera-circle-action.active { color: #ffd857; border-color: rgba(255,216,87,.6); }

.camera-lens-row {
  position: absolute;
  z-index: 18;
  left: 50%;
  bottom: calc(132px + env(safe-area-inset-bottom));
  transform: translate(-50%, 9px) scale(.98);
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.48);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.camera-lens-row::before {
  content: '';
  position: absolute;
  left: 22px;
  right: 22px;
  top: 50%;
  height: 1px;
  background: rgba(255,255,255,.18);
  transform: translateY(-50%);
  pointer-events: none;
}
.camera-lens-row.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}
.camera-lens-button {
  position: relative;
  z-index: 1;
  min-width: 42px;
  height: 42px;
  padding: 0 7px;
  border: 0;
  border-radius: 50%;
  background: rgba(30,30,30,.94);
  color: rgba(255,255,255,.92);
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.camera-lens-button.near { color: #ffd857; }
.camera-lens-button.active {
  background: #fff;
  color: #111;
  transform: scale(1.08);
}

.camera-zoom-readout {
  position: absolute;
  z-index: 19;
  left: 50%;
  bottom: calc(190px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px) scale(.94);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease, visibility .12s ease;
}
.camera-zoom-readout.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.camera-focus-ring {
  position: absolute;
  z-index: 6;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border: 2px solid #ffd857;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.55);
  opacity: 0;
  transform: scale(1.18);
  pointer-events: none;
}
.camera-focus-ring.show { opacity: 1; }
.camera-focus-ring.pulse { animation: camera-focus .55s ease-out; }
@keyframes camera-focus {
  0% { transform: scale(1.32); opacity: .2; }
  45% { transform: scale(.92); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.camera-shot-tray {
  position: absolute;
  z-index: 24;
  left: 12px;
  right: 12px;
  bottom: calc(124px + env(safe-area-inset-bottom));
  padding: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(8,8,8,.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .14s ease, transform .14s ease;
}
.camera-shot-tray.show { opacity: 1; transform: translateY(0); }
.camera-shot-tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #fff;
  font-size: 12px;
}
.camera-shot-tray-head button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.13);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}
.camera-shot-strip {
  width: 100%;
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  padding: 1px 0;
}
.camera-shot-strip::-webkit-scrollbar { display: none; }
.camera-shot {
  position: relative;
  flex: 0 0 64px;
  width: 64px;
  height: 76px;
  border-radius: 11px;
  overflow: hidden;
  background: #222;
  border: 1px solid rgba(255,255,255,.16);
}
.camera-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-shot > span {
  position: absolute;
  bottom: 4px;
  right: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0,0,0,.68);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}
.camera-shot > button {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.camera-status {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  text-align: center;
  background: #080808;
  color: rgba(255,255,255,.78);
}
.camera-status strong { color: #fff; font-size: 18px; }
.camera-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.22);
  border-top-color: #fff;
  animation: camera-spin .8s linear infinite;
}
@keyframes camera-spin { to { transform: rotate(360deg); } }
.camera-fallback-button {
  min-height: 44px;
  margin-top: 6px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #111;
  font-weight: 800;
}

.camera-flash {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}
.camera-flash.active { animation: camera-flash .14s ease-out; }
@keyframes camera-flash { 0% { opacity: .72; } 100% { opacity: 0; } }

.camera-bottom {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.94) 0%, rgba(0,0,0,.72) 52%, transparent 100%);
  pointer-events: none;
}
.camera-controls {
  width: 100%;
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto minmax(92px, 1fr);
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.camera-controls > * { pointer-events: auto; }
.camera-use-button {
  justify-self: start;
  min-height: 46px;
  max-width: 170px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 26px rgba(0,0,0,.22);
}
.camera-use-button:disabled { opacity: .35; }
.camera-shutter {
  justify-self: center;
  width: 78px;
  height: 78px;
  padding: 0;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(0,0,0,.14);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.28);
}
.camera-shutter span {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  transition: transform .08s ease, opacity .08s ease;
}
.camera-shutter:active span { transform: scale(.9); }
.camera-shutter:disabled { opacity: .45; }

.camera-stack-button {
  position: relative;
  justify-self: end;
  width: 66px;
  height: 76px;
  padding: 0;
  border: 0;
  background: transparent;
}
.camera-stack-button img,
.camera-stack-layer {
  position: absolute;
  width: 52px;
  height: 62px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.42);
  background: #242424;
  box-shadow: 0 5px 16px rgba(0,0,0,.28);
}
.camera-stack-button img {
  left: 7px;
  top: 7px;
  object-fit: cover;
  display: block;
  z-index: 3;
}
.camera-stack-layer.layer-mid { left: 10px; top: 4px; z-index: 2; transform: rotate(2deg); }
.camera-stack-layer.layer-back { left: 13px; top: 1px; z-index: 1; transform: rotate(4deg); opacity: .72; }
.camera-stack-count {
  position: absolute;
  z-index: 4;
  right: 0;
  top: 0;
  min-width: 25px;
  height: 25px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 3px 12px rgba(0,0,0,.32);
}

@media (max-width: 420px) {
  .camera-ratio-bar button { min-width: 43px; padding-inline: 8px; }
  .camera-controls { grid-template-columns: minmax(86px, 1fr) auto minmax(86px, 1fr); gap: 8px; }
  .camera-use-button { padding-inline: 10px; font-size: 12px; }
  .camera-shutter { width: 74px; height: 74px; }
  .camera-shutter span { width: 60px; height: 60px; }
  .camera-stack-button { width: 60px; height: 72px; }
  .camera-stack-button img, .camera-stack-layer { width: 48px; height: 58px; }
  .camera-lens-row { gap: 6px; padding-inline: 7px; }
  .camera-lens-button { min-width: 39px; width: 39px; height: 39px; padding: 0 4px; font-size: 12px; }
}

@media (orientation: landscape) and (min-width: 700px) {
  .camera-ratio-bar { top: calc(max(8px, env(safe-area-inset-top)) + 58px); }
  .camera-quick-actions { top: calc(max(8px, env(safe-area-inset-top)) + 102px); }
  .camera-lens-row { bottom: calc(112px + env(safe-area-inset-bottom)); }
  .camera-zoom-readout { bottom: calc(170px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .camera-spinner, .camera-flash.active, .camera-focus-ring.pulse { animation: none !important; }
  .camera-lens-row, .camera-zoom-readout, .camera-shot-tray { transition: none !important; }
}