.modal-mobile-nav {
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  min-width: 38px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: rgba(6, 8, 12, 0.88);
  color: var(--accent-bright);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-mobile-download {
  padding: 0;
  color: var(--text-dim);
}
.modal-mobile-download:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent-glow);
}
.modal-mobile-download .modal-download-icon {
  width: 15px;
  height: 15px;
  display: block;
}
.modal-mobile-download[hidden] {
  display: none !important;
}
.modal-mobile-close-btn {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 8px;
  letter-spacing: 0.12em;
}
.modal-inner {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  max-width: min(960px, 100%);
  max-height: 100%;
  cursor: url("../../refs/New-Cursor.png") 1 1, auto;
}
.modal-inner__media {
  position: relative;
  flex: 1;
  min-width: 0;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

/* Desktop: download / edit / delete — column to the right of the art box */
.modal.open:not(.modal--mobile-shell) .modal-art-actions {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: 12px;
  z-index: 212;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.modal.open:not(.modal--mobile-shell) .modal-art-actions > * {
  pointer-events: auto;
}
.modal.open:not(.modal--mobile-shell) .modal-art-actions .modal-download-btn,
.modal.open:not(.modal--mobile-shell) .modal-art-actions .modal-metadata-edit-btn,
.modal.open:not(.modal--mobile-shell) .modal-art-actions .modal-delete-btn {
  position: static;
  top: auto;
  left: auto;
  right: auto;
}
.modal.open.modal--mobile-shell .modal-art-actions {
  display: none !important;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner {
  overflow: visible;
}
.modal-description-terminal {
  flex: 0 1 auto;
  width: clamp(240px, 32vw, 400px);
  min-width: min(240px, 100%);
  max-width: min(400px, 42vw);
  max-height: min(72vh, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 8px 10px;
  background: rgba(6, 8, 12, 0.92);
  border: 1px solid var(--line);
  font-family: var(--mono);
  color: var(--text-dim);
  overflow: hidden;
}
.modal-description-terminal[hidden] {
  display: none !important;
}
.modal-description-terminal__title {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin-bottom: 6px;
  opacity: 0.9;
}
.modal-description-terminal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: #3d3d3d #050505;
}
.modal-description-terminal__body::-webkit-scrollbar {
  width: 10px;
}
.modal-description-terminal__body::-webkit-scrollbar-track {
  background: #050505;
}
.modal-description-terminal__body::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border: 1px solid var(--line);
}
.modal-description-terminal__body::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}
@media (max-width: 720px) {
  .modal-inner {
    flex-direction: column;
    align-items: stretch;
    max-width: 100%;
  }
  .modal-inner__media {
    order: -1;
  }
  .modal-mobile-controls {
    order: 0;
  }
  .modal-description-terminal {
    flex: 0 1 auto;
    max-width: none;
    width: 100%;
    max-height: min(32vh, 240px);
    order: 1;
  }
}

/* Landscape art on desktop — stacked layout.
 * When the loaded image / video is wider than tall (ratio >= 1.05) JS
 * adds `.modal--landscape` to #modal. The side terminal then drops
 * underneath the media instead of competing with it for horizontal
 * space, so wide art occupies the full modal width and reads at a
 * comfortable size. Tall art is unchanged. */
@media (min-width: 721px) {
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner {
    flex-direction: column;
    align-items: stretch;
    width: min(1100px, 92vw);
    max-width: min(1100px, 92vw);
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media {
    order: -1;
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    max-height: 60vh;
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media img,
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media video {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    margin: 0 auto;
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-description-terminal {
    order: 1;
    flex: 0 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: min(32vh, 280px);
  }
}
@media (min-width: 1025px) {
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) {
    padding: 14px;
  }
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner {
    max-width: min(1800px, 96vw);
    max-height: calc(100vh - 28px);
    gap: 10px;
  }
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-description-terminal {
    width: clamp(220px, 22vw, 320px);
    max-width: min(320px, 30vw);
    max-height: calc(100vh - 28px);
  }
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media {
    max-height: calc(100vh - 28px);
  }
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media img,
  .modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media video {
    max-height: calc(100vh - 28px);
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner {
    width: min(1800px, 96vw);
    max-width: min(1800px, 96vw);
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media {
    max-height: 84vh;
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media img,
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-inner__media video {
    max-width: 96vw;
    max-height: 84vh;
  }
  .modal.open.modal--landscape:not(.modal--mobile-shell):not(.modal--mobile-zoom) .modal-description-terminal {
    max-height: min(14vh, 160px);
  }
}
.modal img {
  max-width: 100%;
  max-height: calc(100vh - 60px);
  display: block;
  border: 1px solid var(--line);
}
/* During mobile pinch: isolate gestures + promote layer (only while body.modal-pinch-zooming). */
body.modal-pinch-zooming .modal-inner__media,
body.modal-pinch-zooming .modal-mobile-stage {
  touch-action: none;
  overscroll-behavior: contain;
}
body.modal-pinch-zooming .modal img,
body.modal-pinch-zooming .modal-video {
  touch-action: none;
  will-change: transform;
  backface-visibility: hidden;
  transform-origin: center center;
}
.modal-video {
  max-width: 100%;
  max-height: calc(100vh - 60px);
  display: none;
  border: 1px solid var(--line);
  object-fit: contain;
}
.modal .info {
  position: absolute;
  top: -28px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  font-family: var(--pixel-en);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
  z-index: 8;
  pointer-events: none;
}
.modal .info strong { color: var(--accent-bright); font-weight: 400; }
.modal-desktop-media-loading {
  display: none;
  pointer-events: none;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media .info {
  visibility: hidden;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-description-terminal {
  display: none !important;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: min(56vw, 720px);
  min-height: min(58vh, 480px);
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media #modalImg,
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media #modalVideo {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-desktop-media-loading {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: absolute;
  inset: 0;
  z-index: 6;
  width: auto;
  min-height: 0;
  margin: 0;
  pointer-events: none;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media .modal-art-loader__img {
  width: auto;
  height: auto;
  max-width: min(28vw, 200px);
  max-height: min(28vw, 200px);
  object-fit: contain;
  display: block;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
.modal.open:not(.modal--mobile-shell):not(.modal--mobile-zoom).modal--media-loading .modal-inner__media .modal-art-loader__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: rgba(255, 255, 255, 0.88);
}
.modal-close {
  position: fixed;
  top: 14px; right: 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 32px; height: 32px;
  font-family: var(--mono);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
  font-size: 14px;
  z-index: 201;
}
.modal-close:hover { border-color: var(--warn); color: var(--warn); }

.modal-download-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  right: auto;
  z-index: 201;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}

.modal-metadata-edit-btn {
  position: fixed;
  top: 52px;
  left: 14px;
  right: auto;
  z-index: 201;
}

.modal-delete-btn {
  position: fixed;
  top: 90px;
  left: 14px;
  right: auto;
  z-index: 201;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #9a2222;
  color: #e14b4b;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-delete-btn:hover {
  border-color: #ff5555;
  color: #ff8888;
  box-shadow: 0 0 8px rgba(225, 75, 75, 0.35);
}
.modal-delete-btn[hidden] {
  display: none !important;
}

.modal-metadata-edit-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent-glow);
}
.modal-metadata-edit-btn[hidden] {
  display: none !important;
}

.modal-metadata-editor {
  position: fixed;
  inset: 0;
  z-index: 214;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.78);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-editor[hidden] {
  display: none !important;
}
.modal-metadata-editor-panel {
  width: min(420px, 100%);
  max-height: min(88vh, 560px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg-window);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 18px var(--accent-glow);
  cursor: url("../../refs/New-Cursor.png") 1 1, auto;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a #050505;
}
.modal-metadata-editor-panel::-webkit-scrollbar { width: 10px; }
.modal-metadata-editor-panel::-webkit-scrollbar-track { background: #050505; }
.modal-metadata-editor-panel::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border: 1px solid var(--line);
}
.modal-metadata-hidden-store[hidden] {
  display: none !important;
}
.modal-metadata-description-btn {
  align-self: flex-start;
  letter-spacing: 0.1em;
}
.modal-metadata-description-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
  word-break: break-word;
  min-height: 14px;
}
.asterrvn-upload-progress {
  width: 100%;
  height: 8px;
  border: 1px solid var(--line);
  background: #050505;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
.asterrvn-upload-progress[hidden] {
  display: none !important;
}
.asterrvn-upload-progress__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 120ms linear;
}
.modal-metadata-editor-head {
  font-family: var(--pixel-en);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--accent-bright);
  margin-bottom: 4px;
}
.modal-metadata-editor-error {
  font-family: var(--mono);
  font-size: 10px;
  color: #e14b4b;
  line-height: 1.35;
  white-space: pre-wrap;
}
.modal-metadata-editor-error[hidden] {
  display: none !important;
}
.modal-metadata-label {
  font-family: var(--pixel-en);
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.modal-metadata-folder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.modal-metadata-folder-btn.modal-metadata-folder-btn--active {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 8px var(--accent-glow);
}
.modal-metadata-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: rgba(6, 8, 12, 0.88);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
}
.modal-metadata-textarea {
  width: 100%;
  min-height: 220px;
  max-height: 36vh;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(6, 8, 12, 0.88);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  resize: vertical;
  scrollbar-width: thin;
  scrollbar-color: #3d3d3d #050505;
}
.modal-metadata-textarea--i18n {
  min-height: 200px;
  max-height: 32vh;
}
.modal-metadata-textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.modal-metadata-textarea::-webkit-scrollbar-track {
  background: #050505;
}
.modal-metadata-textarea::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border: 1px solid var(--line);
}
.modal-metadata-textarea::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}
.modal-metadata-textarea::-webkit-scrollbar-corner {
  background: #050505;
}
.modal-metadata-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #3d3d3d #050505;
}
.modal-metadata-categories::-webkit-scrollbar {
  width: 10px;
}
.modal-metadata-categories::-webkit-scrollbar-track {
  background: #050505;
}
.modal-metadata-categories::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border: 1px solid var(--line);
}
.modal-metadata-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--pixel-en);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-checkbox-row input[type="checkbox"] {
  margin: 0;
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-cat input {
  margin: 0;
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-metadata-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}
.modal-metadata-save-btn {
  border-color: var(--accent);
  color: var(--accent-bright);
}
.modal-metadata-save-btn:disabled {
  opacity: 0.45;
  filter: saturate(0.65);
  border-color: var(--line);
  color: var(--text-dim);
  cursor: url("../../refs/New-Cursor.png") 1 1, default;
}

.modal-download-icon {
  width: 17px;
  height: 17px;
  display: block;
}
.modal-download-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 0 10px var(--accent-glow);
}
.modal-download-btn[hidden] {
  display: none !important;
}
.modal-download-dialog {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-download-dialog[hidden] {
  display: none !important;
}
.modal-download-dialog-panel {
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg-window);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 20px var(--accent-glow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: url("../../refs/New-Cursor.png") 1 1, auto;
}
.modal-download-dialog-head {
  font-family: var(--pixel-en);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent-bright);
  margin-bottom: 4px;
}
.modal-download-dialog-btn {
  width: 100%;
  justify-content: center;
  font-family: var(--pixel-en);
  font-size: 9px;
  letter-spacing: 0.06em;
}
.modal-download-dialog-btn:disabled {
  opacity: 0.45;
  cursor: url("../../refs/New-Cursor.png") 1 1, not-allowed;
}

.modal-delete-dialog {
  position: fixed;
  inset: 0;
  z-index: 212;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  cursor: url("../../refs/New-Cursor-Finger.png") 8 1, pointer;
}
.modal-delete-dialog[hidden] {
  display: none !important;
}
.modal-delete-dialog-panel {
  min-width: 240px;
  max-width: 90vw;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: var(--bg-window);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.85), 0 0 16px rgba(225, 75, 75, 0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: url("../../refs/New-Cursor.png") 1 1, auto;
}
.modal-delete-dialog-text {
  font-family: var(--pixel-ru);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}
.modal-delete-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.modal-delete-dialog-yes {
  border-color: #9a2222;
  color: #e14b4b;
}
.modal-delete-dialog-yes:hover {
  border-color: #ff5555;
  color: #ff8888;
}

.stub {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.stub h2 {
  font-family: var(--display);
  font-size: 48px;
  letter-spacing: 4px;
  margin-bottom: 16px;
  color: var(--text);
}
.stub p {
  font-family: var(--pixel-ru);
  font-size: 14px;
  max-width: 380px;
  margin: 0 auto 8px;
  line-height: 1.6;
  letter-spacing: 0;
}
.stub .err-box {
  display: inline-block;
  margin-top: 24px;
  border: 1px solid var(--warn);
  padding: 8px 16px;
  font-family: var(--pixel-en);
  font-size: 8px;
  color: var(--warn);
  letter-spacing: 2px;
}

