.gallery-detail-screen {
  display: grid;
  min-width: 0;
  min-height: 100svh;
  grid-template-columns: minmax(0, 1.55fr) minmax(350px, .72fr);
  background: var(--paper);
}

.gallery-detail-loading {
  display: grid;
  min-height: 70svh;
  place-items: center;
  color: var(--muted);
}

.gallery-detail-warm-preview {
  display: grid;
  min-height: 100svh;
  grid-column: 1 / -1;
  padding: clamp(20px, 4vw, 64px);
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 20%, rgba(240, 255, 102, .12), transparent 34%),
    color-mix(in srgb, var(--surface-dark) 96%, #242424);
}

.gallery-detail-warm-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(100svh - 48px);
  object-fit: contain;
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, .24));
}

.gallery-detail-not-found {
  display: grid;
  width: min(560px, calc(100% - 40px));
  min-height: 70svh;
  grid-column: 1 / -1;
  align-content: center;
  justify-items: start;
  gap: 14px;
  margin: 0 auto;
}

.gallery-detail-not-found h1,
.gallery-detail-not-found p {
  margin: 0;
}

.gallery-detail-not-found h1 {
  font-family: var(--font-display);
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 520;
  letter-spacing: -.05em;
  line-height: .95;
}

.gallery-detail-not-found p {
  max-width: 46ch;
  color: var(--muted);
  line-height: 1.6;
}

.gallery-detail-not-found .btn {
  margin-top: 8px;
}

.gallery-detail-visual {
  position: sticky;
  top: 0;
  display: grid;
  height: 100svh;
  min-height: 560px;
  padding: clamp(20px, 4vw, 64px);
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 20%, rgba(240, 255, 102, .12), transparent 34%),
    color-mix(in srgb, var(--surface-dark) 96%, #242424);
  cursor: default;
}

.gallery-detail-open {
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-items: center;
  overflow: hidden;
  background: transparent;
  cursor: zoom-in;
}

.gallery-detail-visual img,
.gallery-detail-visual video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(100svh - 48px);
  object-fit: contain;
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, .24));
}

.gallery-detail-visual img {
  transition: opacity 120ms ease;
}

.gallery-detail-visual img.is-full-resolution {
  animation: gallery-detail-resolve 140ms ease-out;
}

@keyframes gallery-detail-resolve {
  from { opacity: .86; }
  to { opacity: 1; }
}

.gallery-detail-neighbor {
  position: absolute;
  z-index: 4;
  top: 50%;
  display: grid;
  width: 42px;
  height: 64px;
  place-items: center;
  color: rgba(255, 255, 255, .9);
  background: rgba(24, 24, 24, .42);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-12);
  backdrop-filter: blur(12px);
  transform: translateY(-50%);
  transition: background 100ms ease, opacity 100ms ease, transform 100ms ease;
}

.gallery-detail-neighbor.previous {
  left: clamp(10px, 2vw, 28px);
}

.gallery-detail-neighbor.next {
  right: clamp(10px, 2vw, 28px);
}

.gallery-detail-neighbor:hover,
.gallery-detail-neighbor:focus-visible {
  background: rgba(24, 24, 24, .68);
  outline: 0;
  transform: translateY(-50%) scale(1.03);
}

.gallery-detail-neighbor:disabled {
  opacity: 0;
  pointer-events: none;
}

.gallery-detail-quality {
  position: absolute;
  z-index: 3;
  top: 20px;
  right: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  pointer-events: none;
}

.gallery-detail-quality span {
  padding: 5px 8px;
  color: rgba(255, 255, 255, .94);
  background: rgba(24, 24, 24, .62);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 680;
}

.gallery-detail-inspector {
  position: relative;
  min-width: 0;
  padding: clamp(28px, 4vw, 58px) clamp(22px, 3.4vw, 52px) 96px;
  background: var(--paper);
  border-left: 1px solid var(--line);
}

.gallery-detail-breadcrumbs {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.gallery-detail-breadcrumbs button {
  max-width: 190px;
  padding: 2px 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
  text-overflow: ellipsis;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.gallery-detail-breadcrumbs button:hover,
.gallery-detail-breadcrumbs button:focus-visible {
  color: var(--ink);
  outline: 0;
  text-decoration-color: currentColor;
}

.gallery-detail-breadcrumbs button[aria-current="page"] {
  color: var(--ink-2);
}

.gallery-detail-heading {
  display: grid;
  gap: 12px;
  margin-top: 34px;
}

.gallery-detail-heading h1 {
  max-width: 13ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 74px);
  font-weight: 520;
  letter-spacing: -.055em;
  line-height: .92;
  overflow-wrap: anywhere;
}

.gallery-detail-heading p {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.gallery-detail-inspector .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 22px;
}

.gallery-detail-facts {
  display: grid;
  gap: 0;
  margin: 30px 0;
  border-top: 1px solid var(--line);
}

.gallery-detail-facts > div {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(80px, .55fr) minmax(0, 1fr);
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.gallery-detail-facts dt,
.gallery-detail-facts dd {
  min-width: 0;
  margin: 0;
  font-size: 12px;
}

/* Каталожная карточка. Подпись сверху, значение под ней во всю ширину:
   у фото блюда «Детали объекта» бывают в 600 знаков, и в узкой колонке
   фактов такой текст превращается в лапшу по два слова в строке.
   Отрицательного отступа сверху здесь больше нет: он затягивал карточку под
   чипы, и вторая строка чипов оказывалась ПОД первой подписью карточки. */
.gallery-detail-card {
  display: block;
  margin: 24px 0 30px;
  border-top: 1px solid var(--line);
}

.gallery-detail-card > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .04em;
  list-style: none;
  text-transform: uppercase;
}

.gallery-detail-card > summary::-webkit-details-marker {
  display: none;
}

.gallery-detail-card > summary::after {
  width: 7px;
  height: 7px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  content: "";
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 120ms ease;
}

.gallery-detail-card[open] > summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.gallery-detail-card > summary:hover {
  color: var(--ink);
}

.gallery-detail-card > summary small {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.gallery-detail-card > dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.gallery-detail-card div {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.gallery-detail-card dt {
  margin: 0 0 3px;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.gallery-detail-card dd {
  min-width: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.gallery-detail-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: -13px 0 24px;
}

.gallery-detail-source-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 11px;
  text-decoration-color: color-mix(in srgb, currentColor 42%, transparent);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.gallery-detail-source-links a:hover,
.gallery-detail-source-links a:focus-visible {
  color: var(--ink);
  outline: 0;
  text-decoration-color: currentColor;
}

.gallery-detail-source-links .icon {
  width: 13px;
  height: 13px;
}

.gallery-detail-facts dt {
  color: var(--muted);
}

.gallery-detail-facts dd {
  overflow-wrap: anywhere;
  text-align: right;
}

.gallery-detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.gallery-detail-actions .btn {
  min-width: 0;
}

.gallery-detail-actions .span-two {
  grid-column: 1 / -1;
}

.gallery-detail-screen.is-work-submission .gallery-detail-visual {
  cursor: default;
}

.gallery-work-source {
  display: grid;
  gap: 5px;
  margin: 26px 0 22px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gallery-work-source strong {
  font-size: 13px;
}

.gallery-work-source small,
.gallery-work-form label > span {
  color: var(--muted);
  font-size: 11px;
}

.gallery-work-form {
  display: grid;
  gap: 14px;
}

.gallery-work-form label {
  display: grid;
  gap: 7px;
}

.gallery-work-form textarea {
  width: 100%;
  min-width: 0;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  outline: 0;
  resize: vertical;
}

.gallery-work-form textarea:focus {
  border-color: var(--ink);
}

.gallery-work-error {
  margin: 0;
  color: var(--danger-ink);
  font-size: 12px;
}

.gallery-detail-meta {
  margin-top: 24px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gallery-detail-meta summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.gallery-detail-meta summary span {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 500;
}

.gallery-detail-meta pre {
  max-height: 240px;
  margin: 14px 0 0;
  overflow: auto;
  color: var(--muted);
  font: 12px/1.6 var(--font-sans);
  white-space: pre-wrap;
}

.gallery-dialog-transcript {
  display: grid;
  max-height: 360px;
  gap: 7px;
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  user-select: text;
}

.gallery-dialog-message {
  padding: 9px 10px;
  background: color-mix(in srgb, var(--surface-2) 68%, transparent);
  border-radius: var(--radius-8);
}

.gallery-dialog-message.model {
  background: transparent;
  box-shadow: inset 2px 0 0 var(--line-strong);
}

.gallery-dialog-message > strong {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.gallery-dialog-message > p {
  margin: 5px 0 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.gallery-dialog-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.gallery-dialog-images img {
  width: 100%;
  height: 88px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: var(--radius-4);
}

.gallery-dialog-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.gallery-dialog-selection > span {
  color: var(--muted);
  font-size: 9px;
}

.gallery-dialog-selection .btn {
  flex: 0 0 auto;
}

.gallery-detail-media-actions {
  display: flex;
  gap: 7px;
  margin-top: 24px;
}

.gallery-detail-media-actions .icon-btn.active {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
}

.gallery-detail-panel {
  position: absolute;
  z-index: 8;
  top: clamp(68px, 8vw, 104px);
  right: clamp(18px, 2.5vw, 38px);
  left: clamp(18px, 2.5vw, 38px);
  display: grid;
  max-height: calc(100svh - 130px);
  gap: 12px;
  padding: 18px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-16);
}

.gallery-detail-panel > header,
.gallery-detail-comments article > header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-detail-panel > header {
  justify-content: space-between;
  margin-bottom: 4px;
}

.gallery-detail-panel h2 {
  margin: 3px 0 0;
  font-size: 20px;
}

.gallery-detail-panel label,
.gallery-detail-panel form {
  display: grid;
  gap: 7px;
}

.gallery-detail-panel label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.gallery-detail-panel select,
.gallery-detail-panel textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-8);
  outline: 0;
  resize: vertical;
}

.gallery-detail-panel select:focus,
.gallery-detail-panel textarea:focus {
  border-color: var(--ink);
}

.gallery-detail-panel-actions {
  display: grid;
  gap: 7px;
  margin-top: 4px;
}

.gallery-detail-panel .danger {
  color: var(--danger-ink);
}

.gallery-detail-comments {
  display: grid;
  gap: 8px;
}

.gallery-detail-comments article {
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-12);
}

.gallery-detail-comments article > header strong {
  min-width: 0;
  flex: 1;
  font-size: 12px;
}

.gallery-detail-comments article > header small {
  color: var(--muted);
  font-size: 10px;
}

.gallery-detail-comments article > header .icon-btn {
  width: 28px;
  height: 28px;
}

.gallery-detail-comments article p {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.gallery-detail-panel-state {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.gallery-detail-panel-state.error {
  color: var(--danger-ink);
}

.gallery-detail-comment-form {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.gallery-detail-comment-form .btn {
  justify-self: end;
}

@media (max-width: 980px) {
  .gallery-detail-screen {
    display: block;
  }

  .gallery-detail-visual {
    position: relative;
    top: 0;
    height: min(66svh, 720px);
    min-height: 420px;
    padding: 20px 14px;
  }

  .gallery-detail-visual img,
  .gallery-detail-visual video {
    max-height: 100%;
  }

  .gallery-detail-quality {
    right: 70px;
  }

  .gallery-detail-inspector {
    padding: 28px 17px 100px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .gallery-detail-heading h1 {
    max-width: 16ch;
    font-size: clamp(42px, 12vw, 68px);
  }

  .gallery-detail-panel {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: 12px;
    max-height: min(72svh, 640px);
  }
}

@media (max-width: 420px) {
  .gallery-detail-actions {
    grid-template-columns: 1fr;
  }

  .gallery-detail-actions .span-two {
    grid-column: auto;
  }
}
