/* ==========================================================================
   The 1870 Project — Ancestral Gallery & Add-to-Gallery Modal Styles
   GALLERY-01b (D0-D12) + GALLERY-01c (T1-T7) + GALLERY-01d (E2-E4) + GALLERY-01e (F2)
   Palette tokens match DESIGN-RULES.md & live support.html — no new colors.
   ========================================================================== */

:root {
  --brown-950: #1C1008;
  --brown-900: #2C1A0E;
  --saddle: #8B4513;
  --sienna: #A0522D;
  --tan: #D4A574;
  --cream: #FAF3E8;
  --cream-2: #FFF8F0;
  --line: #E8DDD0;
  --ink: #3d2b1f;
  --muted: #6b5a4a;
  --error: #9B2C2C;
}

/* Accessible focus rings — 2px --sienna on cream, 2px --tan on dark band */
.gallery-card:focus-visible,
.gallery-btn-primary:focus-visible,
.gallery-btn-outline:focus-visible,
.gallery-btn-text:focus-visible,
.gallery-btn-secondary:focus-visible,
.gallery-helper-btn:focus-visible,
.gallery-how-toggle:focus-visible,
.gallery-modal-close:focus-visible,
.gallery-lightbox-close:focus-visible,
.gallery-input:focus-visible,
.gallery-textarea:focus-visible,
.gallery-consent-input:focus-visible {
  outline: 2px solid var(--sienna);
  outline-offset: 2px;
}

.gallery-section .gallery-card:focus-visible,
.gallery-section .gallery-btn-primary:focus-visible {
  outline: 2px solid var(--tan);
  outline-offset: 3px;
}

/* ── D2: Responsive Gallery Grid (2 @ 390, 3 @ 768, 4 @ 1100+) ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ── D1 / F2 / T2: "Framed Print" Square Card Button ── */
.gallery-card {
  container-type: inline-size;
  container-name: gallery-card;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  margin: 0;
  text-align: left;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  color: var(--ink);
  font-family: 'Crimson Text', Georgia, serif;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

@media (hover: hover) {
  .gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  }
}

.gallery-card__mat {
  padding: 8px;
  background: var(--cream);
}

/* F2: Square 1:1 frame everywhere — whole portrait visible, no cropping */
.gallery-card__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--tan);
  border-radius: 6px;
  overflow: hidden;
  background: var(--brown-950);
}

.gallery-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* T2: Pill sits cleanly INSIDE the thin --tan inner frame line (14px from top/left) */
.gallery-pill {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(250, 243, 232, 0.94);
  border: 1px solid var(--line);
  color: var(--sienna);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.25;
  white-space: nowrap;
  pointer-events: none;
}

.gallery-pill__short {
  display: none;
}

/* T2 + H2: On cards narrower than 200px (phones), show 1-line "Imagined" in bottom-left so it never covers a face */
@container gallery-card (max-width: 199px) {
  .gallery-pill {
    top: auto;
    bottom: 10px;
    left: 10px;
    padding: 2px 8px;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
  }
  .gallery-pill__full {
    display: none;
  }
  .gallery-pill__short {
    display: inline;
  }
}

.gallery-card__caption {
  padding: 0.5rem 0.95rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.gallery-card__msg {
  margin: 0;
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  word-break: break-word;
}

.gallery-card__by {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sienna);
  margin-top: auto;
}

/* ── D4 / E2 / E4: Designed Empty State Card + Real Example Portraits ── */
.gallery-empty-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  color: var(--ink);
}

.gallery-examples-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0 auto 1.5rem;
  max-width: 620px;
}

/* E2: Small framed example card (non-clickable figure, NOT a gallery entry) */
.gallery-example-card {
  position: relative;
  margin: 0;
  padding: 6px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.gallery-example-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--tan);
  border-radius: 6px;
  overflow: hidden;
  background: var(--brown-950);
}

.gallery-example-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery-example-pill {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(250, 243, 232, 0.94);
  border: 1px solid var(--line);
  color: var(--sienna);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
}

.gallery-example-caption {
  margin: 0.45rem 0.25rem 0.15rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 520px) {
  .gallery-examples-grid {
    gap: 0.5rem;
  }
  .gallery-example-card {
    padding: 4px;
    text-align: center;
  }
  .gallery-example-pill {
    position: static;
    display: inline-block;
    margin: 5px auto 0;
    padding: 2px 7px;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
  }
  .gallery-example-caption {
    font-size: 0.72rem;
    margin: 0.25rem 0.1rem 0.1rem;
  }
}

/* E4: Example row below gallery when 1-2 real entries exist (hidden once >= 3) */
.gallery-examples-supplement {
  max-width: 720px;
  margin: 2rem auto 0;
  padding: 1.5rem;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  text-align: center;
}

.gallery-examples-supplement__eyebrow {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-empty-title {
  margin: 0 0 0.6rem;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--brown-900);
  line-height: 1.25;
}

.gallery-empty-sub {
  margin: 0 auto 1.4rem;
  max-width: 480px;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--muted);
}

.gallery-how-wrap {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.gallery-how-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--sienna);
  cursor: pointer;
}

.gallery-how-toggle svg {
  transition: transform 0.2s ease;
}

.gallery-how-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* E3: How it works panel with 3 steps + 1 square example portrait */
.gallery-how-body {
  margin: 0.75rem auto 0;
  max-width: 560px;
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 1rem;
  align-items: center;
  text-align: left;
}

.gallery-how-body[hidden] {
  display: none;
}

@media (max-width: 520px) {
  .gallery-how-body {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .gallery-how-example {
    max-width: 170px;
    width: 100%;
  }
}

.gallery-how-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
}

.gallery-how-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--ink);
}

.gallery-how-num {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--saddle);
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Shared Buttons (all >= 44px touch targets) ── */
.gallery-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.7rem 1.4rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--saddle) 0%, var(--sienna) 100%);
  color: #FFFFFF;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.gallery-btn-primary:hover:not(:disabled) {
  opacity: 0.93;
}

.gallery-btn-primary:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.gallery-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.7rem 1.25rem;
  border: 2px solid var(--sienna);
  border-radius: 10px;
  background: var(--cream-2);
  color: var(--saddle);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.gallery-btn-outline:hover:not(:disabled) {
  background: var(--cream);
}

.gallery-btn-outline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gallery-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.75rem 1.4rem;
  border: 2px solid var(--sienna);
  border-radius: 10px;
  background: var(--cream);
  color: var(--saddle);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.gallery-btn-secondary:hover {
  background: var(--cream-2);
}

.gallery-btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--cream-2);
  color: var(--ink);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.gallery-btn-text:hover {
  background: var(--cream);
}

/* ── D5 / F2: Loading Skeleton Cards (Square 1:1) & Error Card ── */
.gallery-skeleton-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  overflow: hidden;
}

.gallery-skeleton-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, #EFE5D5 25%, #FAF3E8 50%, #EFE5D5 75%);
  background-size: 200% 100%;
  animation: galleryShimmer 1.6s ease-in-out infinite;
}

.gallery-skeleton-line {
  height: 13px;
  border-radius: 6px;
  margin: 0.65rem 0.35rem 0;
  background: linear-gradient(90deg, #EFE5D5 25%, #FAF3E8 50%, #EFE5D5 75%);
  background-size: 200% 100%;
  animation: galleryShimmer 1.6s ease-in-out infinite;
}

.gallery-skeleton-line--short {
  width: 55%;
  height: 10px;
  margin-bottom: 0.35rem;
}

@keyframes galleryShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gallery-error-card {
  max-width: 440px;
  margin: 0 auto;
  padding: 28px 24px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  color: var(--ink);
}

.gallery-error-card__msg {
  margin: 0 0 1rem;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--error);
}

/* ── D3 / T1 / F2: Square Lightbox Modal (whole image visible, object-fit: contain) ── */
.gallery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10005;
  background: rgba(28, 16, 8, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  overflow-y: auto;
  box-sizing: border-box;
}

.gallery-lightbox-panel {
  position: relative;
  width: min(94vw, 560px);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-family: 'Crimson Text', Georgia, serif;
  box-sizing: border-box;
}

.gallery-lightbox-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.gallery-lightbox-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-lightbox-mat {
  padding: 10px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* T1 + F2: Square 1:1 lightbox frame, max-height ~70vh, object-fit: contain (never crops!) */
.gallery-lightbox-frame {
  position: relative;
  width: min(100%, 62vh);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 70vh;
  margin: 0 auto;
  border: 1px solid var(--tan);
  border-radius: 6px;
  overflow: hidden;
  background: var(--brown-950);
}

.gallery-lightbox-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery-lightbox-caption {
  margin-top: 1rem;
  text-align: center;
}

.gallery-lightbox-msg {
  margin: 0 0 0.4rem;
  font-family: 'Crimson Text', Georgia, serif;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--ink);
}

.gallery-lightbox-by {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-lightbox-note {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ── D6-D11 / T4-T7 / F2: Add-to-Gallery Modal / Bottom Sheet ── */
.gallery-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10005;
  background: rgba(28, 16, 8, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  overflow-y: auto;
  box-sizing: border-box;
}

.gallery-modal-panel {
  width: min(95vw, 560px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
  color: var(--ink);
  font-family: 'Crimson Text', Georgia, serif;
  box-sizing: border-box;
}

.gallery-modal-header {
  padding: 1.15rem 1.35rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--cream-2);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.gallery-modal-title {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brown-900);
  line-height: 1.2;
}

/* T7: Current step stands out clearly (bold + dark brown + underline) */
.gallery-modal-steps {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.gallery-step-item {
  font-weight: 400;
  color: var(--muted);
  padding-bottom: 1px;
}

.gallery-step-active {
  font-weight: 700;
  color: var(--brown-900);
  border-bottom: 2px solid var(--sienna);
}

.gallery-modal-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.gallery-modal-scroll {
  padding: 1.15rem 1.35rem 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
  box-sizing: border-box;
}

.gallery-form-layout {
  display: flex;
  gap: 1.15rem;
  align-items: flex-start;
}

.gallery-preview-col {
  flex: 0 0 120px;
  width: 120px;
}

.gallery-preview-mat {
  padding: 6px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* F2 + T6: Square 1:1 120px thumbnail, NO pill overlay */
.gallery-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--tan);
  border-radius: 5px;
  overflow: hidden;
  background: var(--brown-950);
}

.gallery-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery-fields-col {
  flex: 1 1 0;
  min-width: 0;
}

.gallery-field {
  margin-bottom: 0.9rem;
}

.gallery-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.gallery-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-label-row .gallery-label {
  margin-bottom: 0;
}

.gallery-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.gallery-input,
.gallery-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: #FFFFFF;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.gallery-input {
  min-height: 44px;
}

.gallery-textarea {
  min-height: 76px;
  resize: vertical;
}

/* T4: 24px consent checkbox placed directly under Display Name, BEFORE mini preview */
.gallery-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.75rem 0.85rem;
  background: var(--cream-2);
  border: 1.5px solid var(--tan);
  border-radius: 12px;
  cursor: pointer;
  margin: 0.25rem 0 0.9rem;
}

.gallery-consent-input {
  width: 24px;
  height: 24px;
  min-width: 24px;
  margin: 1px 0 0;
  accent-color: var(--saddle);
  cursor: pointer;
}

.gallery-consent-text {
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
}

/* D8 / T5 / F2: Live mini preview card */
.gallery-mini-wrap {
  margin: 0 0 0.9rem;
  padding: 0.85rem;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.gallery-mini-label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-mini-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
}

.gallery-mini-thumb {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border: 1px solid var(--tan);
  border-radius: 5px;
  overflow: hidden;
  background: var(--brown-950);
}

.gallery-mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery-mini-text {
  min-width: 0;
  flex: 1;
}

.gallery-mini-pill {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sienna);
  margin-bottom: 0.15rem;
}

.gallery-mini-msg {
  margin: 0 0 0.2rem;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

/* T5: Empty preview message in muted text */
.gallery-mini-msg--placeholder {
  color: var(--muted);
}

.gallery-mini-by {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sienna);
}

.gallery-inline-error {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  background: #FDF2F2;
  border: 1px solid #E5B8B8;
  border-left: 4px solid var(--error);
  border-radius: 0 10px 10px 0;
  color: var(--error);
  font-size: 0.95rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gallery-inline-error[hidden] {
  display: none;
}

.gallery-action-bar {
  padding: 0.9rem 1.35rem 1.15rem;
  border-top: 1px solid var(--line);
  background: var(--cream-2);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.gallery-action-bar[hidden],
.gallery-modal-panel [hidden],
.gallery-lightbox-panel [hidden] {
  display: none !important;
}

/* T4: Helper text is a clickable link-style button that scrolls to & focuses checkbox */
.gallery-helper-btn {
  align-self: center;
  min-height: 44px;
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sienna);
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.gallery-helper-btn:hover {
  color: var(--saddle);
}

.gallery-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.gallery-action-row .gallery-btn-primary {
  flex: 1 1 200px;
}

/* D10: Success + Package-style Support Card */
.gallery-success-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.95rem 1rem;
  margin-bottom: 1.1rem;
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--saddle);
  border-radius: 0 12px 12px 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}

.gallery-success-icon {
  flex: 0 0 24px;
  color: var(--saddle);
  margin-top: 1px;
}

.gallery-support-card {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 24px;
  box-sizing: border-box;
}

.gallery-support-heading {
  margin: 0 0 0.5rem;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brown-900);
}

.gallery-support-body {
  margin: 0 0 1.1rem;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
}

.gallery-support-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.gallery-support-skip {
  margin-top: 0.7rem;
  width: 100%;
}

/* D7: <= 480px phone bottom sheet + stacked centered portrait + sticky action bar */
@media (max-width: 480px) {
  .gallery-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .gallery-modal-panel {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
  .gallery-modal-header {
    padding: 1rem 1rem 0.75rem;
  }
  .gallery-modal-scroll {
    padding: 0.95rem 1rem 1rem;
  }
  .gallery-form-layout {
    flex-direction: column;
    align-items: center;
  }
  .gallery-preview-col {
    flex: 0 0 auto;
    width: 120px;
  }
  .gallery-fields-col {
    width: 100%;
  }
  .gallery-action-bar {
    position: sticky;
    bottom: 0;
    padding: 0.8rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(28, 16, 8, 0.08);
  }
  .gallery-support-actions {
    grid-template-columns: 1fr;
  }
  .gallery-empty-card {
    padding: 24px 16px;
  }
  .gallery-lightbox-frame {
    width: 100%;
    max-height: 58vh;
  }
}

/* D2 / D5: Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-how-toggle svg,
  .gallery-btn-primary {
    transition: none;
  }
  .gallery-card:hover {
    transform: none;
  }
  .gallery-skeleton-img,
  .gallery-skeleton-line {
    animation: none;
    background: #EFE5D5;
  }
}
