.gallery-admin-page {
  --gallery-ink: #1d1a16;
  --gallery-muted: rgba(29, 26, 22, 0.6);
  --gallery-panel: #fffdf9;
  --gallery-success: #506e58;
  --gallery-action-strong: #9e482e;
  --gallery-action-soft: #fff0e7;
  background: #f7f2ec;
}

.gallery-workspace {
  min-width: 0;
}

.gallery-directory {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(29, 26, 22, 0.07);
  border-radius: 8px;
  background: var(--gallery-panel);
  box-shadow: 0 18px 60px rgba(82, 58, 42, 0.06);
  animation: gallery-directory-enter 0.32s ease both;
}

@keyframes gallery-directory-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-directory-head,
.gallery-directory-actions,
.gallery-command-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.gallery-directory-head {
  position: static;
  width: auto;
  min-height: 0;
  overflow: visible;
  background: transparent;
}

.gallery-directory-head h2 {
  margin: 0;
  color: var(--gallery-ink);
  font-size: clamp(2.35rem, 2.5vw, 3.4rem);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.05;
}

.gallery-directory-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(23, 23, 19, 0.08);
  border-radius: 8px;
  background: #fff;
  color: rgba(23, 23, 19, 0.58);
  font-size: 1.02rem;
}

.admin-stats strong {
  color: var(--gallery-ink);
  font-size: 1.42rem;
  font-weight: 750;
  line-height: 1;
}

.gallery-command-bar {
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(189, 101, 68, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 247, 241, 0.82), rgba(251, 248, 244, 0.96));
}

.gallery-command-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gallery-command-status > span {
  color: rgba(23, 23, 19, 0.5);
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gallery-command-status > p {
  margin: 0;
  color: var(--gallery-muted);
  font-size: 1.12rem;
  font-weight: 650;
}

.admin-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.gallery-add-button {
  position: relative;
  min-height: 46px;
  padding: 0 18px 0 42px;
  box-shadow: 0 14px 32px rgba(189, 101, 68, 0.2);
}

.gallery-add-button::before,
.gallery-add-button::after {
  position: absolute;
  left: 19px;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.gallery-add-button::after {
  transform: rotate(90deg);
}

.admin-button-danger {
  border: 1px solid rgba(132, 35, 26, 0.35);
  background: rgba(132, 35, 26, 0.04);
  color: #84231a;
}

.admin-button-danger:hover {
  border-color: #84231a;
  background: #84231a;
  color: #fff;
}

.upload-drawer,
.maintenance-drawer {
  position: relative;
}

.upload-drawer summary,
.maintenance-drawer summary {
  list-style: none;
}

.upload-drawer summary::-webkit-details-marker,
.maintenance-drawer summary::-webkit-details-marker {
  display: none;
}

.upload-panel,
.maintenance-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 35;
  display: grid;
  gap: 16px;
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 156px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid rgba(23, 23, 19, 0.12);
  border-radius: 8px;
  background: #fbfafa;
  box-shadow: 0 22px 70px rgba(23, 23, 19, 0.18);
}

.maintenance-panel {
  gap: 10px;
  width: min(280px, calc(100vw - 40px));
  padding: 12px;
}

.maintenance-panel .admin-button {
  width: 100%;
}

.upload-panel-head {
  display: grid;
  gap: 6px;
}

.upload-panel-head p {
  margin: 0;
  color: rgba(23, 23, 19, 0.58);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.upload-panel-head h2 {
  margin: 0;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 650;
  line-height: 1;
}

.upload-panel > label,
.photo-field label {
  display: grid;
  gap: 8px;
  color: rgba(23, 23, 19, 0.68);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.upload-panel input[type="text"],
.photo-field input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(23, 23, 19, 0.14);
  border-radius: 8px;
  background: #fff;
  color: #171713;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.upload-panel input:focus,
.photo-field input:focus {
  border-color: #656c5c;
  outline: 3px solid rgba(101, 108, 92, 0.16);
}

.upload-drop {
  position: relative;
}

.upload-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-drop label {
  display: grid;
  gap: 8px;
  min-height: 76px;
  padding: 16px;
  border: 1px dashed rgba(23, 23, 19, 0.28);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.upload-drop:focus-within label {
  border-color: #656c5c;
  outline: 3px solid rgba(101, 108, 92, 0.16);
}

.upload-drop strong {
  color: #171713;
  font-size: 1.36rem;
}

.upload-drop span {
  color: rgba(23, 23, 19, 0.58);
  font-size: 1.18rem;
  font-weight: 400;
  line-height: 1.45;
}

.upload-options {
  display: grid;
  gap: 10px;
}

.admin-check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 24px;
  color: #171713 !important;
  cursor: pointer;
  letter-spacing: 0.04em !important;
}

.admin-check input {
  appearance: auto;
  width: 18px !important;
  min-height: 18px !important;
  height: 18px !important;
  margin: 0;
  accent-color: #656c5c;
}

.gallery-management {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 330px);
  align-items: start;
  gap: 18px;
  min-width: 0;
}

.media-library {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(29, 26, 22, 0.08);
  border-radius: 8px;
  background: #faf7f2;
}

.media-library-head,
.media-inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.media-library-head {
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(29, 26, 22, 0.08);
}

.media-library-head h3,
.media-inspector-head h3 {
  margin: 3px 0 0;
  color: var(--gallery-ink);
  font-size: 1.55rem;
  font-weight: 780;
  line-height: 1.2;
}

.media-library-head > p {
  margin: 2px 0 0;
  color: var(--gallery-muted);
  font-size: 1.05rem;
  white-space: nowrap;
}

.media-library-head > p strong {
  color: var(--gallery-ink);
  font-size: 1.25rem;
}

.photos-manager {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.admin-photo {
  position: relative;
  display: grid;
  align-content: start;
  appearance: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(29, 26, 22, 0.08);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  overflow: hidden;
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
}

.admin-photo:hover {
  border-color: rgba(158, 72, 46, 0.52);
  background: #fffaf6;
}

.admin-photo:focus-visible {
  border-color: var(--gallery-action-strong);
  outline: 3px solid rgba(158, 72, 46, 0.18);
  outline-offset: 2px;
}

.admin-photo.is-selected {
  border-color: var(--gallery-action-strong);
  outline: 2px solid var(--gallery-action-strong);
  outline-offset: -2px;
  background: #fffaf6;
}

.admin-photo.is-selected::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 22%, var(--gallery-action-strong) 25% 100%);
  content: "";
}

.admin-empty {
  width: min(100%, 420px);
  margin: 0;
  padding: 28px;
  border: 1px solid rgba(23, 23, 19, 0.1);
  border-radius: 8px;
  background: #fff;
  color: rgba(23, 23, 19, 0.62);
  font-size: 1.35rem;
}

.photos-manager.is-reordering {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.photos-manager.is-reordering .admin-photo {
  display: block;
  margin: 0;
  cursor: grab;
}

.photos-manager.is-reordering .admin-photo.is-selected {
  border-color: #171713;
  outline-color: #171713;
}

.photos-manager.is-reordering .admin-photo:active {
  cursor: grabbing;
}

.photos-manager.is-reordering .admin-photo.is-dragging {
  opacity: 0.58;
  transform: scale(0.985);
}

.photos-manager.is-reordering .photo-preview {
  aspect-ratio: 1.18 / 1;
}

.photos-manager.is-reordering .photo-preview img {
  height: 100%;
  object-fit: cover;
}

.photo-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #efe9e0;
}

.photo-preview.is-video-preview {
  background: #171713;
}

.photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-badge,
.photo-type-badge {
  position: absolute;
  top: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(251, 250, 250, 0.9);
  color: #171713;
  font-size: 1rem;
  font-weight: 700;
}

.photo-badge {
  right: 8px;
}

.photo-type-badge {
  left: 8px;
}

.photo-play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(251, 250, 250, 0.48);
  border-radius: 50%;
  background: rgba(23, 23, 19, 0.52);
  transform: translate(-50%, -50%);
}

.photo-play::before {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid #fbfafa;
  content: "";
}

.photo-summary {
  display: grid;
  gap: 7px;
  min-height: 78px;
  padding: 11px;
}

.photo-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.photo-summary strong {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--gallery-ink);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.photo-media-kind,
.photo-reorder-hint {
  color: rgba(23, 23, 19, 0.52);
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.photo-visibility {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: fit-content;
  min-height: 23px;
  padding: 0 7px;
  border-radius: 8px;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.photo-visibility.is-visible {
  background: #e8f0e4;
  color: var(--gallery-success);
}

.photo-visibility.is-hidden {
  background: #f1ece6;
  color: rgba(29, 26, 22, 0.62);
}

.photo-reorder-hint {
  display: block;
  padding: 0 14px 13px;
}

.admin-photo.is-selected .photo-reorder-hint {
  color: #171713;
}

.media-inspector {
  position: sticky;
  top: 18px;
  min-width: 0;
  border: 1px solid rgba(29, 26, 22, 0.1);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.media-inspector::before {
  display: block;
  height: 4px;
  background: var(--gallery-action-strong);
  content: "";
}

.media-inspector-content {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.media-inspector-content[hidden],
.media-inspector-empty[hidden],
.media-inspector [hidden] {
  display: none !important;
}

.media-inspector-head {
  align-items: center;
}

.media-inspector-index {
  flex: 0 0 auto;
  color: var(--gallery-muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.media-inspector-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: #efe9e0;
}

.media-inspector-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-inspector-meta {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.media-inspector-meta p {
  margin: 0;
  color: var(--gallery-ink);
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1.35;
}

.media-inspector-settings {
  display: grid;
  gap: 10px;
  padding: 13px;
  border-radius: 7px;
  background: #faf7f2;
}

.media-inspector-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.media-inspector-actions .admin-button {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
}

.media-inspector-empty {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 280px;
  padding: 28px;
  color: var(--gallery-muted);
  text-align: center;
}

.media-inspector-empty > span {
  color: var(--gallery-action-strong);
  font-size: 2rem;
}

.media-inspector-empty p {
  max-width: 220px;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.45;
}

.photo-field {
  display: grid;
  gap: 12px;
}

@media only screen and (max-width: 1100px) {
  .gallery-management {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 300px);
  }

  .photos-manager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media only screen and (max-width: 900px) {
  .gallery-directory-head,
  .gallery-command-bar {
    display: grid;
  }

  .gallery-directory-actions,
  .admin-stats,
  .admin-toolbar-actions {
    justify-content: flex-start;
  }

  .gallery-management {
    grid-template-columns: 1fr;
  }

  .media-inspector {
    position: static;
    grid-row: 1;
  }

  .media-library {
    grid-row: 2;
  }

  .gallery-directory.is-reordering .media-library {
    grid-row: 1;
  }
}

@media only screen and (max-width: 760px) {
  .gallery-directory {
    padding: 16px;
  }

  .gallery-directory-actions,
  .gallery-command-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery-directory-actions,
  .gallery-directory-actions .upload-drawer,
  .gallery-directory-actions .gallery-add-button {
    width: 100%;
  }

  .upload-panel,
  .maintenance-panel {
    left: 0;
    right: auto;
  }

  .upload-panel {
    width: min(560px, calc(100vw - 28px));
    max-height: calc(100vh - 126px);
  }

  .maintenance-panel {
    width: min(280px, calc(100vw - 28px));
  }

  .photos-manager {
    grid-template-columns: 1fr;
  }

  .admin-toolbar-actions,
  .admin-toolbar-actions > .admin-button,
  .admin-toolbar-actions > details {
    width: 100%;
  }

  .admin-toolbar-actions > details > summary,
  .gallery-add-button {
    width: 100%;
  }

  .media-inspector-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-directory,
  .admin-photo {
    animation: none;
    transition: none;
  }
}
