/* =========================================================
   Gallery / stuffs page – search, grid, modal, upload form
   ========================================================= */

/* Gallery fills the .app-page container — no own max-width needed. */
.gallery {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
  padding: 0;
}

/* ── Filter bar ───────────────────────────────────────────── */
.gallery__header {
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* ── Controls / chip bar — responsive across 5 tiers ────────
   xl / lg   centered row, wrap allowed
   md        centered row, horizontal scroll if overflow
   sm / xs   stacked: category row on top, price row below */
.gallery__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm) var(--space-md);
  padding: 0;
}

.gallery__chip-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs) var(--space-sm);
}

.gallery__chip-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
}

.gallery__chip-sep {
  display: none;
}

/* md — single row that scrolls horizontally when crowded */
@media (min-width: 768px) and (max-width: 1024px) {
  .gallery__controls,
  .gallery__chip-strip,
  .gallery__chip-group {
    flex-wrap: nowrap;
  }
  .gallery__controls {
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .gallery__controls::-webkit-scrollbar { display: none; }
}

/* sm/xs — stack chip groups vertically so the row is never cramped */
@media (max-width: 768px) {
  .gallery__chip-strip {
    flex-direction: column;
    gap: var(--space-xs);
  }
  .gallery__chip-sep {
    display: none;
  }
}

/* ── Filter (text-based open / close toggle) ───────────────── */
.filter-button {
  display: inline-block;
  padding: var(--space-xs) var(--space-xs);
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--ease);
}

.filter-button[hidden] {
  display: none;
}

.filter-button + .filter-button {
  margin-left: var(--space-sm);
}

.filter-button:hover,
.filter-button:focus-visible {
  color: var(--fg);
  outline: none;
}

/* Active (current selection): always visible, underlined. */
.filter-button--active {
  color: var(--fg);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 1.5px;
}

/* Collapsed group: only the active label shows, with a small ▾ chevron. */
.gallery__chip-group[data-filter-open="false"] .filter-button--active::after {
  content: " ▾";
  font-weight: 400;
  color: var(--muted);
}

/* Open group: highlight the active option inside the expanded list. */
.gallery__chip-group[data-filter-open="true"] .filter-button--active::after {
  content: "";
}

/* Gallery grid — 5 canonical tiers via column-count */
/* Gallery grid — column-count drops as viewport shrinks
   xl  ≥1440  : 5 cols
   lg  ≥1024  : 4 cols
   md  ≥768   : 3 cols
   sm  ≥480   : 2 cols
   xs  <480   : 2 cols (tighter gap) */
.gallery__grid {
  column-count: 5;
  column-gap: var(--space-sm);
  margin: 0;
  box-sizing: border-box;
}

@media (max-width: 1440px) { .gallery__grid { column-count: 4; } }
@media (max-width: 1024px) { .gallery__grid { column-count: 3; } }
@media (max-width: 768px)  { .gallery__grid { column-count: 2; } }
@media (max-width: 480px)  { .gallery__grid { column-gap: var(--space-xs); } }

.gallery__item,
.gallery__item--ad {
  display: inline-block;
  width: 100%;
  margin: 0 0 var(--space-sm);
  position: relative;
  aspect-ratio: auto;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  vertical-align: top;
}

.gallery__item { cursor: pointer; }
.gallery__item--ad { cursor: default; }

@media (max-width: 768px) {
  .gallery__item--ad {
    cursor: pointer;
  }
}

.gallery__item-image,
.gallery__item-image--ad {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  pointer-events: none;
  display: block;
}

.gallery__item-image img,
.gallery__item-image--ad img {
  width: 100%;
  height: auto;
  object-fit: initial;
  display: block;
}

.gallery__item--sold .gallery__item-image img {
  filter: grayscale(1) saturate(0.2) brightness(0.9);
}

.gallery__item--sold .gallery__item-content {
  background: #ddd9e1;
}

.gallery__item--sold .gallery__item-title,
.gallery__item--sold .gallery__item-description,
.gallery__item--sold .gallery__item-location,
.gallery__item--sold .gallery__item-date,
.gallery__item--sold .gallery__item-expiry-meta {
  color: var(--muted);
}

.gallery__item-body,
.gallery__item-body--ad {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  line-height: 1.45;
  pointer-events: none;
}

@media (max-width: 768px) {
  .gallery__item .gallery__item-image {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
  }

  .gallery__item-image img,
  .gallery__item-image--ad img {
    border: none;
    border-bottom: 0;
  }

  .gallery__item .gallery__item-body,
  .gallery__item--ad .gallery__item-body--ad {
    position: static;
    inset: auto;
  }
}

.gallery__item-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-xs);
  box-sizing: border-box;
  overflow-y: hidden;
  background: #d5d0db;
  color: var(--fg);
  padding-inline: var(--space-sm);
  padding-block: var(--space-sm);
  font-size: var(--text-sm);
}

@media (max-width: 768px) {
  .gallery__item-content {
    height: auto;
    background: var(--surface);
  }

  .gallery__item-body .gallery__item-content,
  .gallery__item-body--ad .gallery__item-content--ad {
    border: none;
    border-top: 0;
  }
}

/* Desktop overlay: semi-transparent panel on hover (matches JS overlay >768px) */
@media (min-width: 768px) {
  .gallery__item:hover .gallery__item-content {
    background: rgba(213, 208, 219, 0.5);
  }

  .gallery__item--sold:hover .gallery__item-content {
    background: rgba(221, 217, 225, 0.5);
  }

  .gallery__item--ad:hover .gallery__item-content--ad {
    background: rgba(113, 68, 159, 0.5);
  }
}

.gallery__item-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  width: 100%;
  text-align: left;
  word-break: normal;
  line-height: 1.25;
}

.gallery__item-title {
  display: block;
  min-width: 0;
  width: 100%;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: left;
}

.gallery__item-price {
  display: inline-block;
  align-self: flex-start;
  flex-shrink: 0;
  white-space: nowrap;
  word-break: keep-all;
}

.gallery__item-meta {
  display: flex;
  gap: var(--space-xs);
  flex-direction: column;
  flex-wrap: wrap;
  align-items: flex-start;
}

.gallery__item-meta div {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  align-items: flex-start;
}

.gallery__item-meta div:nth-child(2) {
  flex-direction: row;
  flex-wrap: wrap;
}

.gallery__item-meta .gallery__item-tag {
  padding: 0.25rem var(--space-sm);
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
}

.gallery__item-date-wrap {
  display: grid;
  gap: 0;
  font-size: var(--text-xs);
}

.gallery__item-date,
.gallery__item-expiry-meta {
  font-size: var(--text-xs);
  line-height: 1.35;
  color: var(--muted);
}

.gallery__item-description,
.gallery__item-location {
  margin: 0;
}

.gallery__item-meta .gallery__item-price {
  white-space: nowrap;
}

.gallery__grid .gallery__item-meta,
.gallery__grid .gallery__item-description,
.gallery__grid .gallery__item-location,
.gallery__grid .gallery__item-date-wrap {
  display: none;
}

/* Desktop hover overlay: title + price only */
@media (min-width: 768px) {
  .gallery__grid .gallery__item:not(.gallery__item--ad) .gallery__item-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
}

.gallery__upload-fab {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.gallery__upload-fab-label {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-sm);
  min-width: 0;
  height: 3rem;
  padding: 0 var(--space-md);
  background: #000;
  color: var(--fg-inverse);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease);
  border: none;
  font-weight: 600;
  font-size: var(--text-base);
  line-height: 1;
  box-shadow: 0 0.75rem 2rem #d6d6d6;
}

.gallery__upload-fab-label:hover {
  transform: scale(1.05);
}

.gallery__upload-fab-label--primary {
  background: #000;
}

.gallery__upload-fab-label--login {
  text-decoration: none;
}


.gallery__upload-fab-copy {
  display: grid;
  gap: var(--space-xs);
  min-width: 0;
}

.gallery__upload-fab-text {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.gallery__upload-fab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery__upload-fab-btn svg {
  width: 18px;
  height: 18px;
}

/* Sell FAB (+): 90° step, 1s hold, repeat (lively “tick” rhythm) */
label[for="js-uploaded-file"] .gallery__upload-fab-btn svg {
  transform-origin: 50% 50%;
  animation: gallery-upload-plus-step 5s linear infinite;
}

@keyframes gallery-upload-plus-step {
  0% {
    transform: rotate(0deg);
  }

  5% {
    transform: rotate(90deg);
  }

  25% {
    transform: rotate(90deg);
  }

  30% {
    transform: rotate(180deg);
  }

  50% {
    transform: rotate(180deg);
  }

  55% {
    transform: rotate(270deg);
  }

  75% {
    transform: rotate(270deg);
  }

  80% {
    transform: rotate(360deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  label[for="js-uploaded-file"] .gallery__upload-fab-btn svg {
    animation: none;
  }
}

.gallery__item-body--ad .gallery__item-content--ad {
  overflow-y: hidden;
  background: #71449fbf;
  color: var(--fg-inverse);
  justify-content: flex-end;
}

.gallery__item-title--ad {
  color: inherit;
}

@media (max-width: 768px) {
  .gallery__upload-fab {
    bottom: var(--space-md);
    right: var(--space-md);
  }

  .gallery__item-content {
    overflow: hidden;
    touch-action: auto;
  }
}

/* Modal */
.modal {
  display: none;
}

.modal[aria-hidden="false"],
.modal--open {
  display: flex;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  text-align: left;
  padding: 0;
  box-sizing: border-box;
  background: var(--bg-overlay-mix);
  cursor: pointer;
}

.modal__content {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding-inline: var(--modal-content-padding-inline);
  padding-block: var(--modal-content-padding-block);
  box-sizing: border-box;
  gap: var(--space-rhythm-section);
  align-items: stretch;
  overflow: hidden;
}

.modal__content--two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr;
  min-height: 0;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  .modal__content {
    margin-inline: var(--space-lg);
    width: calc(100% - 2 * var(--space-lg));
  }
}

@media (min-width: 1440px) {
  .modal__content {
    margin-inline: var(--space-xl);
    width: calc(100% - 2 * var(--space-xl));
  }
}

.modal__left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.modal__seller-info {
  flex-shrink: 0;
}

.modal__seller-info-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.modal__seller-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.modal__seller-name {
  font-weight: 600;
}

.modal__seller-row {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: baseline;
}

.modal__seller-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.modal__seller-info-inner a {
  color: var(--fg);
  word-break: break-all;
}

.modal__seller-info-inner a:hover,
.modal__seller-info-inner a:focus-visible {
  text-decoration: underline;
}

.modal__seller-chip {
  display: inline-block;
  padding: 0.25rem var(--space-sm);
  border: none;
  border-radius: var(--radius);
}

.modal__seller-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.modal__seller-stat {
  display: grid;
  gap: var(--space-xs);
  padding: 0.6rem 0.7rem;
  border: none;
}

.modal__seller-stat-value {
  font-weight: 600;
}

.modal__seller-info-sep {
  color: var(--muted);
  font-size: var(--text-sm);
}

.modal__right {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
  min-height: 12rem;
  gap: var(--space-rhythm-block);
}

.modal__comments-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-rhythm-block);
}

.modal__image-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  position: relative;
}

.modal__image-main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__image-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal__image-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 2.85rem;
  height: 2.85rem;
  margin-top: -1.425rem;
  border: none;
  background: #5c5c5c;
  color: var(--fg-inverse);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal__image-nav:hover,
.modal__image-nav:focus-visible {
  background: #2e2e2e;
}

.modal__image-nav--prev {
  left: 1rem;
}

.modal__image-nav--next {
  right: 1rem;
}

.modal__image-thumbs {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.modal__image-thumb {
  flex: 0 0 4.5rem;
  height: 4.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: #262626;
}

.modal__image-thumb.is-active {
  box-shadow: inset 0 0 0 2px var(--surface);
}

.modal__image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal__text-wrap {
  flex-shrink: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-rhythm-block);
  overflow-y: auto;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: left;
}

.modal__chat-form-wrap {
  flex-shrink: 0;
  margin-top: var(--space-rhythm-block);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-rhythm-group);
}

.modal__chat-link {
  color: var(--muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.modal__chat-link:hover {
  color: var(--fg);
  text-decoration: underline;
}

.modal__chat-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-rhythm-group);
  width: 100%;
}

.modal__bookmark-form {
  display: grid;
  gap: var(--space-xs);
}

/* Heart favorite button on image */
.modal__heart-form {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 5;
}

.modal__heart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: #999;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.modal__heart-btn:hover {
  background: #666;
  transform: scale(1.1);
}

.modal__heart-icon {
  width: 1.3rem;
  height: 1.3rem;
  fill: var(--fg-inverse);
  stroke: none;
  transition: fill 0.15s;
}

.modal__heart-btn:hover .modal__heart-icon {
  fill: var(--fg-inverse);
}

.modal__heart-btn--active .modal__heart-icon {
  fill: #e94560;
}

.modal__heart-btn--active:hover .modal__heart-icon {
  fill: #d63050;
}

.modal__guest-cta {
  display: grid;
  gap: var(--space-sm);
  justify-items: start;
  text-align: left;
}

.modal__guest-title {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
}

.modal__guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: flex-start;
}

.modal__bookmark-button {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-weight: 600;
}

.modal__bookmark-button:hover,
.modal__bookmark-button:focus-visible {
  background: var(--input-bg);
}

.modal__bookmark-button--link,
.modal__chat-submit--link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
}

.modal__help-links {
  display: grid;
  gap: var(--space-xs);
  padding-top: var(--space-md, 1rem);
}

.modal__chat-label {
  font-weight: 600;
  color: var(--fg);
  display: block;
}

.modal__chat-input {
  width: 100%;
  padding: var(--space-md) var(--space-sm);
  border: none;
  border-radius: var(--radius);
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  box-sizing: border-box;
}

.modal__chat-input::placeholder {
  color: var(--muted);
}

.modal__chat-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--fg);
}

.modal__chat-submit {
  align-self: flex-start;
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: var(--fg);
  color: var(--fg-inverse);
  cursor: pointer;
  font-weight: 600;
}


.modal__chat-submit:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.modal__close {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  left: auto;
}

.tutorial-tour {
  position: fixed;
  inset: 0;
  z-index: 128;
  display: none;
  pointer-events: auto;
}

.tutorial-tour[aria-hidden="false"] {
  display: block;
}

.tutorial-tour__backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.tutorial-tour__spotlight {
  position: fixed;
  z-index: 129;
  outline: 2px solid var(--surface);
  outline-offset: 0;
  background: transparent;
  box-shadow: 0 0 0 9999px rgb(138 138 138 / 10%);
  transition: top 160ms ease, left 160ms ease, width 160ms ease, height 160ms ease;
  pointer-events: none;
}

.tutorial-tour__badge {
  position: fixed;
  z-index: 131;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #71449f;
  color: var(--fg-inverse);
  font-weight: 700;
  border-radius: var(--radius);
  box-shadow: 0 0.75rem 1.75rem #b8b8b8;
  pointer-events: none;
}

.tutorial-tour__card {
  position: fixed;
  z-index: 132;
  width: min(22rem, calc(100vw - 2rem));
  display: grid;
  gap: var(--space-sm);
  padding: 1rem;
  text-align: left;
  border: none;
  background: #eeebf2;
  box-shadow: 0 1.25rem 3rem #c7c7c7;
  pointer-events: auto;
}

.tutorial-tour__eyebrow {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-accent);
}

.tutorial-tour__title {
  margin: 0;
  line-height: 1.3;
}

.tutorial-tour__text {
  margin: 0;
  line-height: 1.65;
  color: var(--muted);
  font-size: var(--text-sm);
}

.tutorial-tour__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.tutorial-tour__button {
  min-width: 5rem;
  padding: 0.72rem 0.95rem;
  border: none;
  background: var(--fg);
  color: var(--fg-inverse);
  font-weight: 600;
  cursor: pointer;
}


.tutorial-tour__button--ghost {
  background: var(--surface);
  color: var(--fg);
}

.tutorial-tour__target {
  outline: 2px solid var(--surface);
  outline-offset: 0.22rem;
}

/* ── Upload form ─────────────────────────────────────────── */
.upload-form {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.55);
  min-height: 100svh;
  min-height: 100dvh;
}

.upload-form[aria-hidden="false"] {
  display: flex;
}

/* Panel — full viewport like gallery modal shell; inset via same padding tokens as .modal__content */
.upload-form__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  padding: calc(var(--space-lg) * 2) var(--space-lg);
}

.upload-form__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 2;
}

/* Form fills the panel */
.upload-form__form {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.upload-form__eyebrow {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: var(--text-sm);
}


/* ── Two-column body ────────────────────────────────────── */
.upload-form__field {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.upload-form__field--two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
}

/* ── Left — dark image panel ────────────────────────────── */
.upload-form__left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #000;
}

.upload-form__media-copy {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.upload-form__file-name {
  margin: 0;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.upload-form__image-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-form__preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-lg);
  box-sizing: border-box;
}

.upload-form__preview-empty {
  margin: 0;
  padding: var(--space-lg);
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  line-height: 1.6;
  font-size: var(--text-sm);
}

.upload-form__thumbs {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  background: #242424;
}

.upload-form__thumb {
  position: relative;
  flex: 0 0 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  background: #2a2a2a;
  cursor: grab;
  user-select: none;
}

.upload-form__thumb.is-active {
  outline: 2px solid rgba(255, 255, 255, 0.8);
}

.upload-form__thumb.is-dragging {
  cursor: grabbing;
  opacity: 0.7;
}

.upload-form__thumb.is-drop-target {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}

.upload-form__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-form__thumb-index,
.upload-form__thumb-meta {
  position: absolute;
  left: 0.2rem;
  background: rgba(0, 0, 0, 0.65);
  color: var(--fg-inverse);
  line-height: 1;
  padding: 0.12rem 0.2rem;
  font-size: var(--text-xs);
}

.upload-form__thumb-index {
  top: 0.2rem;
}

.upload-form__thumb-meta {
  bottom: 0.2rem;
}

.upload-form__media-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: transparent;
  flex-shrink: 0;
}

/* ── Right — form panel ─────────────────────────────────── */
.upload-form__right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.upload-form__input-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.upload-form__file-area {
  display: none;
}

.upload-form__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  width: 100%;
  padding-left: var(--space-lg);
  box-sizing: border-box;
}

.upload-form__field-grid {
  display: grid;
  gap: var(--space-sm);
}

.upload-form__field-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upload-form__textarea {
  color: var(--fg);
  width: 100%;
  min-height: 2.5rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: 0;
  background: var(--input-bg);
  white-space: pre-wrap;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
}

.upload-form__textarea:focus {
  outline: none;
  border-color: var(--fg);
}

.upload-form__input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--input-bg);
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
}

.upload-form__input:focus {
  outline: none;
  border-color: var(--fg);
}

.upload-form__input--price:disabled {
  color: var(--muted);
  font-size: var(--text-sm);
  background: var(--surface-alt);
  cursor: not-allowed;
  border-color: transparent;
}

.upload-form__hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.upload-form__hint a {
  color: inherit;
  text-decoration: underline;
}

.upload-form__field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.upload-form__label {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  color: var(--muted);
}

.upload-form__category-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.category-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--fg);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.2;
  transition: background var(--ease), color var(--ease);
}

.category-btn:hover {
  background: var(--surface-alt);
}

.category-btn.active {
  background: var(--fg);
  color: var(--fg-inverse);
  border-color: var(--fg);
}

/* Category badge hidden everywhere in the gallery grid */
.gallery__item-category {
  display: none;
}

.upload-form__choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}

.upload-form__choice-btn {
  min-height: 2.5rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--fg);
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--ease), color var(--ease);
}

.upload-form__choice-btn.active {
  background: var(--fg);
  color: var(--fg-inverse);
  border-color: var(--fg);
}

/* Add / Replace / Remove — same pill radius as other form controls */
.upload-form__media-actions .upload-form__choice-btn {
  flex: 1;
  min-width: 0;
  min-height: 2.25rem;
  padding: var(--space-sm) var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: #1e1e1e;
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--text-sm);
  transition: background var(--ease), color var(--ease);
}

.upload-form__media-actions .upload-form__choice-btn:hover {
  background: #333;
  color: var(--fg-inverse);
}

.upload-form__price-row {
  align-items: stretch;
}

/* Helper / review note */
.upload-form__helper-wrap {
  display: none;
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.upload-form__helper-card {
  padding: var(--space-md);
  background: var(--bg-overlay);
  border-radius: var(--radius);
}

.upload-form__helper-text {
  margin: 0;
  line-height: 1.5;
  color: var(--fg);
  font-size: var(--text-sm);
}

/* ── Submit buttons ─────────────────────────────────────── */
.upload-form__step-wrap {
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-md);
}

.upload-form__step-btn {
  min-width: 9rem;
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--fg);
  transition: background var(--ease), color var(--ease);
}

.upload-form__step-btn:hover {
  background: var(--fg);
  color: var(--fg-inverse);
}

.upload-form__step-btn--next {
  background: var(--fg);
  color: var(--fg-inverse);
}

.upload-form__step-btn--next:hover {
  background: var(--fg-strong);
}

.upload-form__step-btn--prev,
.upload-form__step-btn--submit {
  display: none;
}

#js-mypage-product-modal.upload-form {
  cursor: pointer;
}

#js-mypage-product-modal .upload-form__step-btn--submit {
  display: inline-block;
  background: var(--fg);
  color: var(--fg-inverse);
}

#js-mypage-product-modal .upload-form__step-btn--submit:hover {
  background: var(--fg-strong);
  color: var(--fg-inverse);
}

/* Relist button — purple accent */
#js-mypage-product-modal .upload-form__step-btn[name="relist_product"] {
  background: var(--admin-accent);
  color: var(--fg-inverse);
}

#js-mypage-product-modal .upload-form__step-btn[name="relist_product"]:hover {
  background: #5a3580;
  color: var(--fg-inverse);
}

.upload-form__step-wrap .user-form__btn--danger {
  border-radius: var(--radius);
  font-family: inherit;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .upload-form {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .upload-form__panel {
    width: 100%;
    height: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    border: none;
    padding-inline: 0;
    padding-block: var(--modal-content-padding-mobile-block);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .upload-form__fields {
    padding: var(--space-lg);
  }

  .upload-form__field--two-column {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .upload-form__left {
    flex: 0 0 auto;
  }

  .upload-form__image-wrap {
    aspect-ratio: 16 / 9;
    min-height: 0;
  }

  .upload-form__right {
    border-top: 1px solid var(--border-subtle);
    overflow: visible;
  }

  .upload-form__input-wrap {
    overflow: visible;
  }

  .upload-form__thumb {
    flex-basis: 3rem;
    height: 3rem;
  }

  .upload-form__field-grid--two {
    grid-template-columns: 1fr;
  }

  .upload-form__category-toggle {
    grid-template-columns: repeat(2, 1fr);
  }

  .upload-form__step-wrap {
    padding-top: var(--space-sm);
  }

  .upload-form__step-btn {
    flex: 1;
    min-width: 0;
  }
}

.gallery__search-results {
  margin-bottom: var(--space-md);
}

.gallery__search-results-text {
  color: var(--fg);
}

/* .gallery__filter kept as alias for legacy JS targeting */
.gallery__filter {
  display: contents;
}

@media (max-width: 768px) {
  .modal__image-thumb {
    flex-basis: 3.75rem;
    height: 3.75rem;
  }

  .modal__image-nav {
    width: 2.45rem;
    height: 2.45rem;
    margin-top: -1.225rem;
  }

  .modal__image-nav--prev {
    left: 0.6rem;
  }

  .modal__image-nav--next {
    right: 0.6rem;
  }

  .tutorial-tour__badge {
    width: 1.8rem;
    height: 1.8rem;
  }

  .tutorial-tour__card {
    width: calc(100vw - 1.25rem);
    padding: 0.9rem;
    gap: var(--space-sm);
  }

  .tutorial-tour__actions {
    justify-content: stretch;
  }

  .tutorial-tour__button {
    flex: 1 1 calc(50% - 0.3rem);
    min-width: 0;
  }
}

@media (max-width: 768px) {
  /* Gallery: center all copy on small screens */
  .gallery,
  .gallery__header,
  .gallery__search-results,
  .gallery__search-results-text,
  .gallery__item-content,
  .gallery__item-content--ad,
  .gallery__item-title,
  .gallery__item-title--ad,
  .gallery__item-price,
  .gallery__item-meta,
  .gallery__item-meta div,
  .gallery__item-tag,
  .gallery__item-description,
  .gallery__item-location,
  .gallery__item-date-wrap,
  .gallery__item-date,
  .gallery__item-expiry-meta {
    text-align: center;
  }

  .gallery__chip-strip {
    justify-content: center;
  }

  .gallery__item-meta,
  .gallery__item-meta div {
    align-items: center;
  }

  /* Fullscreen listing modal: image fills space above; detail strip pinned to bottom, no whole-modal scroll */
  #js-modal-fullscreen .modal__backdrop {
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100svh;
    min-height: 100dvh;
    height: 100svh;
    height: 100dvh;
    box-sizing: border-box;
  }

  .gallery__controls {
    gap: var(--space-xs) var(--space-sm);
  }

  .gallery__search-form {
    flex: 0 0 auto;
    min-width: 6.5rem;
  }

  .gallery__chip-sep {
    margin: 0;
  }

  .gallery__title {
    line-height: 1.2;
  }

  .gallery__item-content {
    gap: var(--space-xs);
    padding-inline: var(--space-md);
    padding-block: var(--space-sm);
  }

  .gallery__item-header {
    gap: 0;
    text-align: center;
    align-items: center;
  }

  .gallery__item-price {
    align-self: center;
  }

  .gallery__item-title {
    align-self: stretch;
    min-width: 0;
    line-height: 1.3;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .gallery__item-meta {
    gap: var(--space-xs);
  }

  .gallery__item-meta div {
    gap: var(--space-xs);
  }

  .gallery__item-meta .gallery__item-tag {
    padding: 0.18rem 0.45rem;
  }

  .gallery__item-expiry-meta {
    color: var(--muted);
  }

  .gallery__comment-date {
    color: var(--muted);
  }

  .gallery__item-description {
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }

  .gallery__item-location {
    line-height: 1.4;
  }

  .modal__content {
    gap: var(--space-rhythm-section);
    padding-inline: var(--modal-content-padding-mobile-inline);
    padding-block: var(--modal-content-padding-mobile-block);
    overflow-y: auto;
    overflow-x: hidden;
    align-items: start;
  }

  .modal__content.modal__content--two-column {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-height: 100svh;
    max-height: 100dvh;
    overflow: hidden;
    gap: 0;
    padding-block: 0;
    padding-inline: 0;
    align-items: stretch;
    align-content: stretch;
  }

  .modal__content--two-column .modal__left {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
  }

  .modal__content--two-column .modal__image-wrap {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    padding: 0;
    gap: 0;
  }

  .modal__content--two-column .modal__image-main {
    min-height: 0;
  }

  .modal__content--two-column .modal__image-thumbs {
    flex-shrink: 0;
  }

  .modal__content--two-column .modal__right {
    flex: 0 0 auto;
    flex-shrink: 0;
    width: 100%;
    max-height: min(46dvh, 50svh);
    min-height: 0;
    overflow: hidden;
    overflow-y: hidden;
    margin: 0;
    margin-top: auto;
    padding: var(--space-sm) var(--modal-content-padding-mobile-inline)
      calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    background: var(--bg-overlay);
    border-top: 1px solid var(--border-subtle);
    gap: var(--space-rhythm-group);
    align-items: center;
    text-align: center;
  }

  .modal__content--two-column .modal__text-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0.1rem;
    -webkit-overflow-scrolling: touch;
    text-align: center;
    align-items: center;
    width: 100%;
  }

  .modal__content--two-column .modal__chat-form-wrap {
    flex-shrink: 0;
    align-items: center;
    text-align: center;
    width: 100%;
  }

  .modal__content--two-column .modal__right .gallery__item-content {
    align-items: center;
    text-align: center;
  }

  .modal__content--two-column .modal__right .gallery__item-meta,
  .modal__content--two-column .modal__right .gallery__item-meta div {
    align-items: center;
  }

  .modal__content--two-column .modal__right .gallery__item-meta div:nth-child(2) {
    justify-content: center;
  }

  .modal__content--two-column .modal__right .gallery__item-date-wrap {
    justify-items: center;
    text-align: center;
  }

  .modal__content--two-column .modal__right .gallery__item-description,
  .modal__content--two-column .modal__right .gallery__item-location {
    text-align: center;
  }

  .modal__content--two-column .modal__right .modal__chat-form {
    align-items: center;
  }

  .modal__content--two-column .modal__right .modal__chat-submit {
    align-self: center;
  }

  .modal__content--two-column .modal__right .modal__guest-cta {
    justify-items: center;
    text-align: center;
  }

  .modal__content--two-column .modal__right .modal__guest-actions {
    justify-content: center;
    align-items: stretch;
  }

  .modal__content--two-column .modal__right .modal__help-links {
    justify-items: center;
    text-align: center;
  }

  .modal__content--two-column .modal__right .modal__chat-submit--link,
  .modal__content--two-column .modal__right .modal__bookmark-button--link {
    justify-content: center;
  }

  .modal__seller-row,
  .modal__text-wrap {
    line-height: 1.5;
  }

  .modal__seller-info-inner a {
    line-height: 1.45;
  }

  .modal__chat-form {
    gap: var(--space-sm);
  }

  .modal__guest-actions {
    flex-direction: column;
  }

  .modal__guest-actions > * {
    width: 100%;
  }

  
  .upload-form__file-name {
    line-height: 1.45;
  }

  .upload-form__helper-card {
    padding: var(--space-md) var(--space-lg);
  }
}

.gallery__item-chat {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm);
  background: var(--fg-inverse);
}

.gallery__item-chat-form {
  margin: 0;
}

.gallery__item-chat-btn {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--fg);
  color: var(--fg-inverse);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
