.camera-topbar {
  background: #000;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.camera-ratio-bar {
  display: none !important;
}

.camera-ratio-cycle {
  justify-self: center;
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.camera-ratio-cycle:active {
  transform: scale(.95);
  background: rgba(255,255,255,.16);
}

.camera-ratio-cycle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.camera-top-actions {
  justify-self: end;
  display: grid;
  grid-template-columns: 40px 40px;
  align-items: center;
  direction: ltr;
  gap: 8px;
  width: 88px;
  min-width: 88px;
}

.camera-top-action {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}

.camera-top-action:active {
  transform: scale(.92);
  background: rgba(255,255,255,.14);
}

/* Keep the camera switch permanently in the left slot and flash in the right slot. */
.camera-switch-control {
  grid-column: 1;
  grid-row: 1;
}

.camera-flash-control {
  grid-column: 2;
  grid-row: 1;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.camera-switch-icon {
  width: 25px;
  height: 25px;
  display: block;
}

.camera-switch-body,
.camera-switch-arrows {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.camera-switch-body { stroke-width: 1.8; }
.camera-switch-arrows { stroke-width: 1.65; }

.camera-flash-symbol,
.camera-flash-mode {
  grid-column: 1;
  grid-row: 1;
}

.camera-flash-symbol {
  display: grid;
  place-items: center;
  transform: translateY(-3px);
}

.camera-flash-symbol svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.camera-flash-mode {
  align-self: end;
  justify-self: center;
  margin-bottom: 3px;
  min-width: 17px;
  padding: 1px 3px;
  border-radius: 999px;
  background: rgba(0,0,0,.72);
  color: rgba(255,255,255,.9);
  font-size: 7px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -.1px;
}

.camera-flash-control.mode-auto,
.camera-flash-control.mode-on {
  color: #ffd857;
  border-color: rgba(255,216,87,.45);
}

.camera-flash-control.mode-on {
  background: rgba(80,65,0,.54);
}

.camera-shot-tray-head .camera-tray-count {
  justify-self: auto;
  min-width: 0;
  margin-inline-start: auto;
  margin-inline-end: 4px;
  color: rgba(255,255,255,.68);
  font-size: 11px;
  text-align: center;
}

.camera-photo-review {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(max(74px, env(safe-area-inset-top) + 64px)) 12px calc(124px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.camera-photo-review img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.camera-photo-review-label {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 67px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.58);
  color: rgba(255,255,255,.88);
  font-size: 11px;
  font-weight: 750;
}

#cameraPhotoReviewClose {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 61px);
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  background: rgba(0,0,0,.58);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.camera-shot img { cursor: pointer; }

/* Keep all capture controls fully inside a deliberate black control bar. */
.camera-bottom {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #000;
  border-top: 1px solid rgba(255,255,255,.08);
}

.camera-controls {
  min-height: 96px;
  grid-template-columns: minmax(74px, 1fr) 82px minmax(74px, 1fr);
  align-items: center;
  gap: 16px;
}

.camera-shutter {
  align-self: center;
  margin: 0;
  transform: none;
  touch-action: manipulation;
}

.camera-use-button {
  position: relative;
  justify-self: start;
  align-self: center;
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
  display: grid;
  place-items: center;
  font-size: 0;
  line-height: 1;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  touch-action: manipulation;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}

.camera-use-button:active:not(:disabled) {
  transform: scale(.94);
}

/* Enlarge the check for better visual balance while keeping the tap target unchanged. */
.camera-use-button::before {
  content: '';
  width: 36px;
  height: 36px;
  display: block;
  transform: translateY(5px);
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7.5' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.camera-use-button:disabled {
  opacity: .34;
}

.camera-stack-button {
  align-self: center;
  margin: 0;
  transform: none;
  touch-action: manipulation;
}

/* Safari can leave a blue rectangular focus ring on the cancel text button after opening the camera. */
#cameraCancelBtn {
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: none;
}

#cameraCancelBtn:focus,
#cameraCancelBtn:active {
  outline: none;
  box-shadow: none;
}

#cameraCancelBtn:focus-visible {
  outline: none;
  box-shadow: none;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

@media (max-width: 560px) {
  .camera-ratio-cycle {
    min-width: 66px;
    height: 34px;
    padding-inline: 12px;
    font-size: 12px;
  }

  .camera-top-actions {
    grid-template-columns: 38px 38px;
    gap: 6px;
    width: 82px;
    min-width: 82px;
  }

  .camera-top-action {
    width: 38px;
    height: 38px;
  }

  .camera-switch-icon {
    width: 24px;
    height: 24px;
  }

  .camera-flash-symbol svg {
    width: 19px;
    height: 19px;
  }

  .camera-bottom {
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  }

  .camera-controls {
    min-height: 92px;
    grid-template-columns: minmax(66px, 1fr) 78px minmax(66px, 1fr);
    gap: 10px;
  }

  .camera-use-button {
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    height: 52px;
    min-height: 52px;
  }

  .camera-use-button::before {
    width: 32px;
    height: 32px;
    transform: translateY(5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .camera-ratio-cycle,
  .camera-top-action,
  .camera-use-button {
    transition: none;
  }
}
