.cake-gallery-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: auto hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.cake-gallery-track::-webkit-scrollbar { display: none; }
.cake-gallery-track:focus-visible { outline-offset: -4px; }
.cake-gallery-track img {
  display: block;
  min-width: 0;
  min-height: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.cake-gallery-controls:not([hidden]) {
  position: absolute;
  inset: auto 8px 8px auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 100px;
  background: var(--cream, #fffaf3);
  color: var(--berry-dark, #6e263e);
  box-shadow: 0 2px 9px #39202b2e;
}
.cake-gallery-controls button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: 25px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cake-gallery-controls button:focus-visible { outline-offset: -3px; }
.cake-gallery-controls button:disabled { opacity: .4; cursor: default; }
@media (hover: hover) {
  .cake-gallery-controls button:not(:disabled):hover { background: var(--rose); }
}
.cake-gallery-count { font: 600 12px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cake-gallery-open:not([hidden]) {
  position: absolute;
  inset: 8px 8px auto auto;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 100px;
  background: var(--cream, #fffaf3);
  color: var(--berry-dark, #6e263e);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.cake-gallery-open:focus-visible { outline-offset: -3px; }
[data-gallery-photos]:has(.cake-gallery-open:not([hidden])) img { cursor: zoom-in; }

html:has(.cake-gallery-viewer[open]) { overflow: hidden; }
.cake-gallery-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  border: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  background: #1d171a;
  color: #fffaf3;
}
.cake-gallery-viewer[open] { display: grid; grid-template-columns:minmax(0,1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.cake-gallery-viewer::backdrop { background: #1d171a; }
.cake-gallery-viewer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px));
}
.cake-gallery-viewer-heading h2 { flex:1; margin: 0; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.cake-gallery-zoom {
  flex:none; min-height:44px; padding:0 14px; border:1px solid #fffaf35c; border-radius:30px;
  background:transparent; color:inherit; font:600 14px/1.3 var(--sans, sans-serif); cursor:pointer;
}
.cake-gallery-zoom:focus-visible,.cake-photo-detail:focus-visible { outline:2px solid #fffaf3; outline-offset:-3px; }
.cake-gallery-close {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #fffaf34f;
  border-radius: 50%;
  background: #fffaf318;
  color: inherit;
  font: 28px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cake-gallery-close:focus-visible { outline: 2px solid #fffaf3; outline-offset: 3px; }
.cake-gallery-viewer-track,.cake-photo-detail { grid-area:2 / 1; min-height:0; min-width:0; }
.cake-photo-detail { overflow:auto; overscroll-behavior:contain; }
.cake-photo-detail > div { display:flex; min-height:100%; min-width:100%; width:max-content; }
.cake-photo-detail img { display:block; flex:none; margin:auto; max-width:none; max-height:none; }
@media (pointer:fine) {
  .cake-photo-detail { cursor:grab; user-select:none; }
  .cake-photo-detail:active { cursor:grabbing; }
}
.cake-gallery-viewer[data-zoomed] .cake-gallery-viewer-track,
.cake-gallery-viewer[data-zoomed] .cake-gallery-viewer-controls { visibility:hidden; }
.cake-gallery-viewer-track img {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  object-fit: contain;
}
.cake-gallery-viewer-controls:not([hidden]) {
  position: static;
  justify-self: center;
  margin: 10px 0 14px;
  box-shadow: none;
  grid-row:3;
  background:#fffaf318; color:#fffaf3;
}
@media (hover:hover) {
  .cake-gallery-viewer-controls button:not(:disabled):hover,.cake-gallery-zoom:hover { background:#fffaf32a; }
}
@media (max-height:480px) and (orientation:landscape) {
  .cake-gallery-viewer-heading { padding-block:2px; }
  .cake-gallery-viewer-controls:not([hidden]) { margin-block:2px; }
}
