.photo-trigger {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 1px solid #efb6a4;
  border-radius: 50%;
  background: #fff2db;
  color: #854c44;
  box-shadow: inset 0 0 0 2px #fff9ef, 0 2px 5px #75473245;
  font-size: 19px;
  line-height: 1;
  touch-action: manipulation;
}

.photo-trigger.is-corner-camera {
  right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
  bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  width: 44px;
  height: 44px;
  transform: none;
  transition: opacity .2s ease;
}

.photo-trigger.is-corner-camera:not(.is-camera-ready) {
  opacity: 0;
}

@media (orientation: portrait) and (max-width: 650px) {
  .photo-trigger.is-corner-camera {
    right: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    bottom: max(12px, calc(env(safe-area-inset-left, 0px) + 8px));
  }
}

.photo-camera-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.photo-camera-icon::before {
  position: absolute;
  top: -5px;
  left: 1px;
  width: 8px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
  content: "";
}

.photo-camera-icon::after {
  width: 7px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "";
}

.photo-shelf {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
}

.photo-shelf .photo-trigger {
  position: relative;
  transform: none;
  border-radius: 12px;
  background: #ffe7da;
}

.photo-trigger.is-bookshelf img {
  display: block;
  width: 30px;
  transform: rotate(-8deg);
  box-shadow: 0 1px 3px #75473255;
}

.photo-trigger[hidden],
.photo-shelf[hidden],
.photo-navigation[hidden],
.photo-countdown[hidden],
.photo-flash[hidden],
.photo-overlay[hidden] {
  display: none;
}

.photo-countdown {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff8eb;
  text-shadow: 0 2px 10px #542e26, 0 0 2px #542e26;
  font-size: clamp(38px, 10vmin, 70px);
  font-weight: 750;
}

.photo-flash {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background: #fffaf2;
  animation: cottage-photo-flash .42s ease-out both;
}

.photo-overlay {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: grid;
  justify-items: center;
  align-items: center;
  padding: 8px;
  background: #432a2b99;
}

.photo-dialog {
  position: relative;
  width: min(100%, 420px);
  max-height: 100%;
  padding: 12px clamp(10px, 3%, 22px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 2px solid #e8aa98;
  border-radius: 16px;
  background: #fff0d9;
  color: #643d31;
  box-shadow: inset 0 0 0 1px #fff9ee, 0 8px 30px #432a2b55;
}

.photo-dialog h2 {
  margin: 0 0 8px;
  padding-inline: 28px;
  text-align: center;
  font-size: 17px;
}

.photo-print {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 10px;
  overflow: hidden;
  border-radius: 2px;
  box-shadow: 0 3px 10px #5e342c36;
}

.photo-print img,
img.photo-print {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: clamp(94px, calc(100vmin - 160px), 360px);
  object-fit: contain;
}

.photo-print.is-developing {
  animation: cottage-photo-develop .75s ease-out both;
}

.photo-caption {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  font-size: 13px;
}

.photo-caption input,
.photo-caption textarea,
input.photo-caption {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #e8aa98;
  border-radius: 8px;
  background: #fffaf1;
  color: inherit;
  font-size: 16px;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.photo-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 9px;
}

.photo-index {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.photo-navigation button,
.photo-actions button,
.photo-actions a {
  display: inline-grid;
  min-height: 36px;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid #d39688;
  border-radius: 999px;
  background: #f9cfc0;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  touch-action: manipulation;
}

.photo-navigation button {
  min-height: 34px;
  background: #fff7e9;
}

.photo-navigation button:disabled {
  opacity: .46;
  cursor: default;
}

.photo-dialog:has(.photo-navigation:not([hidden])) .photo-print img {
  max-height: clamp(94px, calc(100vmin - 195px), 360px);
}

@keyframes cottage-photo-flash {
  from { opacity: .65; }
  to { opacity: 0; }
}

@keyframes cottage-photo-develop {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-flash,
  .photo-print.is-developing {
    animation: none;
  }

  .photo-flash {
    opacity: 0;
  }
}
