.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;
}
.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);
  }
}
.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;
}
.modal .info strong { color: var(--accent-bright); font-weight: 400; }
.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-delete-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  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 {
  position: fixed;
  top: 14px;
  left: 52px;
  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);
  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, 640px);
  overflow: hidden;
  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;
}
.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-download-btn {
  position: fixed;
  top: 14px;
  right: 52px;
  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-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;
}

