#private button.gallery-launch {
  width: 100%;
  min-height: 0;
  justify-content: center;
  gap: 9px;
  padding: 16px 11px;
  color: #55236e;
  background: #fbf7fd;
}
#private button.gallery-launch:hover,
#private button.gallery-launch:focus-visible {
  background: #f1e5f7;
}
#private .gallery-launch .media-icon {
  padding: 0;
  background: transparent;
  color: #802d9f;
  font-size: 32px;
  line-height: 1.2;
}
#private .gallery-launch strong { font-size: 16px; }
#familyGallery { min-width: 0; }
.gallery-heading, .gallery-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}
.gallery-heading { justify-content: space-between; }
.gallery-heading h2 { margin: 0; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
  gap: 14px;
  margin-block: 12px;
}
.gallery-card {
  padding: 9px;
  min-width: 0;
  border: 1px solid #dfcce7;
  border-radius: 15px;
  background: #fbf7fd;
}
button.gallery-preview {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #eadcf2;
  color: #54246c;
  box-shadow: none;
}
.gallery-preview img { width: 100%; height: 100%; object-fit: cover; }
.gallery-preview img:not([src]) { display: none; }
.gallery-caption { margin: 9px 2px; overflow-wrap: anywhere; white-space: pre-wrap; }
.gallery-options summary { cursor: pointer; font-size: 24px; padding-inline: 8px; }
.gallery-options button { margin: 3px; }
dialog.gallery-dialog {
  width: min(680px, calc(100% - 24px));
  max-height: 90dvh;
  padding: clamp(15px, 4vw, 27px);
  border: 1px solid #dec9e8;
  border-radius: 18px;
  color: #402450;
  background: #fff;
}
.gallery-dialog::backdrop { background: #2c193c99; }
.gallery-dialog h2 { margin-block-start: 0; }
.gallery-dialog input, .gallery-dialog textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d8c6e2;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.gallery-dialog textarea { display: block; resize: vertical; }
.gallery-dialog .gallery-actions { margin-top: 12px; }
.gallery-upload-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding-block: 10px;
  border-bottom: 1px solid #e4d4ec;
}
.gallery-upload-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.gallery-item-status { grid-column: 1 / -1; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .gallery-upload-row { grid-template-columns: 52px minmax(0, 1fr); }
  .gallery-upload-row img { width: 52px; height: 52px; }
  .gallery-upload-row button { grid-column: 1 / -1; justify-self: start; }
}

dialog.photo-viewer {
  width: min(1050px, calc(100% - 32px));
  max-height: 94dvh;
  padding: 12px 16px;
  overflow: auto;
  background: #211629;
  border-color: #51395c;
  color: #fff;
}
.photo-viewer::backdrop { background: #170f1cbd; }
.photo-viewer-header,
.photo-viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.photo-viewer-header h2 { margin: 0; color: inherit; font-size: 17px; }
#galleryPhotoCount { color: #efe2f4; font-variant-numeric: tabular-nums; }
.photo-viewer-body { position: relative; }
#galleryPhotoStage {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: calc(100% - 112px);
  height: clamp(188px, 61dvh, 640px);
  margin: 8px auto 0;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  background: #2c2034;
  border-radius: 10px;
}
#galleryPhotoStage[data-zoomed="true"] { cursor: grab; }
#galleryPhotoStage[data-zoomed="true"]:active { cursor: grabbing; }
#galleryLargeImage {
  display: block;
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
#galleryLargeImage:not([src]) { display: none; }
.photo-viewer-navigation {
  position: absolute;
  inset: 0;
  height: clamp(188px, 61dvh, 640px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.photo-viewer button.photo-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  padding: 0;
  border: 1px solid #6e5777;
  border-radius: 50%;
  color: #fff;
  background: #493650;
  font-size: 25px;
  line-height: 1;
  box-shadow: none;
  pointer-events: auto;
}
.photo-viewer button.photo-icon:hover { background: #63476f; }
.photo-viewer :focus-visible { outline: 2px solid #f2b9fc; outline-offset: 2px; }
.photo-viewer button:disabled, .photo-viewer button[aria-disabled="true"] { opacity: .45; cursor: default; }
[dir="rtl"] .photo-viewer-navigation button span { transform: scaleX(-1); }
#galleryPhotoCaption {
  max-height: 5.8em;
  min-height: 1.5em;
  margin: 8px 0 4px;
  overflow: auto;
  text-align: center;
}
#galleryPhotoStatus { margin: 0; color: #ead9ef; font-size: .9rem; }
.photo-viewer-zoom { display: flex; gap: 6px; }
.photo-viewer-zoom button.photo-icon { font-size: 22px; }
.photo-viewer button.photo-retry { background: #493650; color: #fff; box-shadow: none; }
.photo-viewer button.photo-retry[hidden] { display: none; }
#galleryPhotoStage[data-motion="1"] { --slide-start: 18px; }
#galleryPhotoStage[data-motion="-1"] { --slide-start: -18px; }
@media(prefers-reduced-motion: no-preference) {
  #galleryPhotoStage .photo-viewer-enter {
    animation: photo-viewer-enter 180ms ease-out both;
  }
}
@keyframes photo-viewer-enter {
  from { translate: var(--slide-start, 0) 0; opacity: .7; }
  to { translate: 0 0; opacity: 1; }
}
@media(max-width: 640px) {
  dialog.photo-viewer { width: calc(100% - 16px); padding: 8px; max-height: 96dvh; }
  #galleryPhotoStage { width: 100%; height: clamp(155px, 58dvh, 540px); }
  .photo-viewer-navigation { position: static; height: auto; margin-block: 6px; }
  .photo-viewer-footer { justify-content: flex-start; }
}
@media(max-height: 500px) and (orientation: landscape) {
  #galleryPhotoStage, .photo-viewer-navigation { height: max(125px, 45dvh); }
  .photo-viewer-navigation { position: absolute; margin-block: 0; }
  #galleryPhotoStage { width: calc(100% - 112px); }
}

.gallery-empty {
  width:min(100%,760px);margin:28px auto;padding:30px 18px;
  border:1px solid #e7d3ee;border-radius:16px;background:#fbf7fd;text-align:center;color:#542a6e;
}
.gallery-empty-icon {
  display:inline-grid;place-items:center;width:52px;height:52px;
  border-radius:50%;background:#efe0f5;color:#692887;font-size:24px;
}
.gallery-empty h3 {display:grid;gap:2px;margin:12px 0;font:800 22px/1.3 'Tajawal',Tahoma,Arial,sans-serif}
.gallery-empty p {margin:5px 0;color:#765f83}

/* Abuharaz: description guidance is a placeholder, never prefilled content. */
.gallery-upload-row textarea::placeholder,
#galleryEditCaption::placeholder{color:#9f93aa!important;font-weight:400!important;font-style:normal!important;opacity:1!important;line-height:1.5}
.gallery-upload-row label{font-weight:600}
.gallery-upload-row textarea{font-weight:400!important}
