/* Viewport-bounded photo viewer. Keep images out of intrinsic grid sizing. */
dialog#app-dialog.gallery-dialog {
  position: fixed;
  inset: 0;
  width: calc(100vw - 32px);
  max-width: 1160px;
  height: min(900px, calc(100vh - 32px));
  height: min(900px, calc(100dvh - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid #cbb9bb;
  border-radius: 12px;
  background: #fffdfa;
  color: #302a2b;
  color-scheme: light;
}

dialog#app-dialog.gallery-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog#app-dialog.gallery-dialog > .dialog-head {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid #ded2c8;
}

dialog#app-dialog.gallery-dialog > .dialog-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

dialog#app-dialog.gallery-dialog .dialog-head h2 {
  margin: 0;
  overflow: hidden;
  color: #302a2b;
  font-size: 20px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog#app-dialog.gallery-dialog .dialog-head p {
  margin: 4px 0 0;
  color: #71676a;
  font-size: 11px;
  line-height: 1.4;
}

dialog#app-dialog.gallery-dialog .close-button {
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #ded2c8;
  border-radius: 7px;
  background: #f4efe8;
  color: #682b3d;
}

dialog#app-dialog.gallery-dialog > .dialog-body {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  overflow: hidden;
}

dialog#app-dialog.gallery-dialog .gallery-main {
  position: relative;
  flex: 1 1 0;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #ded2c8;
  border-radius: 6px;
  background: #eee7df;
}

dialog#app-dialog.gallery-dialog .gallery-main > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 10px;
  box-sizing: border-box;
  object-fit: contain;
  object-position: center;
  transform: none;
}

dialog#app-dialog.gallery-dialog .gallery-controls {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

dialog#app-dialog.gallery-dialog .gallery-nav {
  position: static;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #cbb9bb;
  border-radius: 7px;
  background: #fffdfa;
  color: #682b3d;
  transform: none;
  box-shadow: none;
}

dialog#app-dialog.gallery-dialog .gallery-nav:hover:not(:disabled) {
  border-color: #682b3d;
  background: #f4efe8;
}

dialog#app-dialog.gallery-dialog .gallery-nav:disabled {
  cursor: default;
  opacity: .35;
}

dialog#app-dialog.gallery-dialog .gallery-count {
  min-width: 92px;
  color: #51454a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

dialog#app-dialog.gallery-dialog .gallery-thumbs {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 3px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #b79da6 #eee7df;
}

dialog#app-dialog.gallery-dialog .gallery-thumbs > button {
  position: relative;
  flex: 0 0 86px;
  display: block;
  width: 86px;
  height: 58px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid #ded2c8;
  border-radius: 5px;
  background: #eee7df;
}

dialog#app-dialog.gallery-dialog .gallery-thumbs > button.active {
  border-color: #682b3d;
}

dialog#app-dialog.gallery-dialog .gallery-thumbs img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  padding: 2px;
  box-sizing: border-box;
  object-fit: contain;
  object-position: center;
  transform: none;
}

dialog#app-dialog.gallery-dialog .dialog-body > .fleet-photo-credit {
  flex: 0 0 auto;
  margin: 0;
  font-size: 10px;
  line-height: 1.4;
}

dialog#app-dialog.gallery-dialog .gallery-meta {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid #ded2c8;
}

dialog#app-dialog.gallery-dialog .gallery-details {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #51454a;
  font-size: 12px;
  line-height: 1.5;
}

dialog#app-dialog.gallery-dialog .gallery-details > summary {
  min-width: 0;
  padding: 11px 0;
  color: #682b3d;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  list-style-position: inside;
}

dialog#app-dialog.gallery-dialog .gallery-description {
  max-height: min(140px, 16vh);
  max-height: min(140px, 16dvh);
  margin-top: 4px;
  padding: 0 12px 2px 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

dialog#app-dialog.gallery-dialog .gallery-description p {
  margin: 0 0 8px;
  font-size: inherit;
  line-height: inherit;
}

dialog#app-dialog.gallery-dialog .gallery-description > :last-child {
  margin-bottom: 0;
}

dialog#app-dialog.gallery-dialog .gallery-meta > .button {
  flex: 0 0 auto;
  min-height: 42px;
  margin: 0;
  padding: 10px 17px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
}

dialog#app-dialog.gallery-dialog .gallery-empty {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  overflow: auto;
  border: 1px solid #ded2c8;
  border-radius: 6px;
  background: #eee7df;
  color: #71676a;
  text-align: center;
}

dialog#app-dialog.gallery-dialog .gallery-empty h3,
dialog#app-dialog.gallery-dialog .gallery-empty p {
  margin: 0;
}

dialog#app-dialog.gallery-dialog button:focus-visible,
dialog#app-dialog.gallery-dialog summary:focus-visible {
  outline: 2px solid #682b3d;
  outline-offset: 2px;
}

@media (max-width: 650px) {
  dialog#app-dialog.gallery-dialog {
    width: calc(100vw - 16px);
    height: min(900px, calc(100vh - 16px));
    height: min(900px, calc(100dvh - 16px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 9px;
  }
  dialog#app-dialog.gallery-dialog > .dialog-head { gap: 12px; padding: 10px 12px; }
  dialog#app-dialog.gallery-dialog .dialog-head h2 { font-size: 18px; }
  dialog#app-dialog.gallery-dialog .dialog-head p { font-size: 10px; }
  dialog#app-dialog.gallery-dialog > .dialog-body { gap: 9px; padding: 10px 12px; }
  dialog#app-dialog.gallery-dialog .gallery-main > img { padding: 5px; }
  dialog#app-dialog.gallery-dialog .gallery-thumbs { gap: 7px; padding-bottom: 4px; }
  dialog#app-dialog.gallery-dialog .gallery-thumbs > button { flex-basis: 72px; width: 72px; height: 50px; }
  dialog#app-dialog.gallery-dialog .gallery-meta { flex-direction: column; align-items: stretch; gap: 5px; padding-top: 6px; }
  dialog#app-dialog.gallery-dialog .gallery-details > summary { padding: 5px 0; font-size: 12px; }
  dialog#app-dialog.gallery-dialog .gallery-description { max-height: min(110px, 14vh); max-height: min(110px, 14dvh); }
  dialog#app-dialog.gallery-dialog .gallery-meta > .button { width: 100%; min-height: 42px; }
}

/* Keep the car visible on landscape phones and short desktop windows. */
@media (max-height: 560px) {
  dialog#app-dialog.gallery-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  dialog#app-dialog.gallery-dialog > .dialog-head { gap: 10px; padding: 7px 12px; }
  dialog#app-dialog.gallery-dialog .dialog-head h2 { font-size: 17px; }
  dialog#app-dialog.gallery-dialog .dialog-head p { display: none; }
  dialog#app-dialog.gallery-dialog .close-button { flex-basis: 32px; width: 32px; height: 32px; }
  dialog#app-dialog.gallery-dialog > .dialog-body { gap: 6px; padding: 8px 12px; }
  dialog#app-dialog.gallery-dialog .gallery-main > img { padding: 4px; }
  dialog#app-dialog.gallery-dialog .gallery-controls { gap: 12px; }
  dialog#app-dialog.gallery-dialog .gallery-nav { flex-basis: 34px; width: 34px; height: 34px; }
  dialog#app-dialog.gallery-dialog .gallery-count { font-size: 11px; }
  dialog#app-dialog.gallery-dialog .gallery-thumbs { display: none; }
  dialog#app-dialog.gallery-dialog .dialog-body > .fleet-photo-credit { max-height: 38px; overflow-y: auto; font-size: 9px; }
  dialog#app-dialog.gallery-dialog .gallery-meta { flex-direction: row; align-items: flex-start; gap: 12px; padding-top: 6px; }
  dialog#app-dialog.gallery-dialog .gallery-details > summary { padding: 7px 0; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
  dialog#app-dialog.gallery-dialog .gallery-description { max-height: min(64px, 14vh); max-height: min(64px, 14dvh); font-size: 11px; }
  dialog#app-dialog.gallery-dialog .gallery-meta > .button { width: auto; min-height: 34px; padding: 7px 10px; gap: 7px; font-size: 11px; }
  dialog#app-dialog.gallery-dialog .gallery-meta > .button .icon { width: 15px; height: 15px; }
}

@media (max-height: 260px) {
  dialog#app-dialog.gallery-dialog {
    width: calc(100vw - 8px);
    height: calc(100vh - 8px);
    height: calc(100dvh - 8px);
    max-height: calc(100vh - 8px);
    max-height: calc(100dvh - 8px);
  }
  dialog#app-dialog.gallery-dialog > .dialog-head { padding: 4px 8px; }
  dialog#app-dialog.gallery-dialog .dialog-head h2 { font-size: 15px; }
  dialog#app-dialog.gallery-dialog .close-button { flex-basis: 28px; width: 28px; height: 28px; }
  dialog#app-dialog.gallery-dialog > .dialog-body { gap: 4px; padding: 4px 8px; }
  dialog#app-dialog.gallery-dialog .gallery-nav { flex-basis: 28px; width: 28px; height: 28px; }
  dialog#app-dialog.gallery-dialog .gallery-meta { gap: 8px; padding-top: 4px; }
  dialog#app-dialog.gallery-dialog .gallery-details > summary { padding: 4px 0; font-size: 10px; }
  dialog#app-dialog.gallery-dialog .gallery-description { max-height: min(32px, 14vh); max-height: min(32px, 14dvh); margin-top: 2px; font-size: 10px; line-height: 1.4; }
  dialog#app-dialog.gallery-dialog .gallery-meta > .button { min-height: 28px; padding: 4px 8px; font-size: 10px; }
}
