.admin-access {
  margin-left: auto;
  margin-right: 2px;
  min-height: 42px;
  border: 0;
  border-radius: 22px;
  color: #536987;
  white-space: nowrap;
}

.mobile-brand { display: none; }
.library-view-switch { display: none; }

.library-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.traffic-modal { max-height: calc(100dvh - 28px); overflow: auto; }
.traffic-views { display: flex; gap: 7px; margin-bottom: 10px; }
.traffic-views .secondary-button { min-height: 37px; padding: 6px 12px; }
.traffic-views [aria-pressed="true"] { color: #fff; background: var(--navy); border-color: transparent; }
.traffic-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.traffic-table th, .traffic-table td {
  padding: 11px 0;
  border-bottom: 1px solid #e5eaf1;
  text-align: left;
}
.traffic-table thead { color: #63768f; font-size: 12px; }
.traffic-table tbody th { font-weight: 500; }
.traffic-table td, .traffic-table th:last-child { text-align: right; }
.traffic-table tbody tr:last-child > * { border-bottom: 0; }

.primary-button {
  background: var(--navy);
  color: #fff;
  border-color: transparent;
}

.library-facets {
  display: flex;
  gap: 9px;
  min-width: 0;
}

.library-facets .library-sort select {
  min-width: 98px;
  max-width: 154px;
  text-overflow: ellipsis;
}

.library-sort select { color: #516785; }
.library-sort > span { color: #7689a3; }
.library-search { flex: 1 1 210px; min-width: 140px; }
.library-search input::placeholder { color: #657891; }

.reset-filters {
  flex-shrink: 0;
  color: #59708d;
  font-size: 11px;
  padding: 8px 2px;
  white-space: nowrap;
}

.reset-filters:hover { text-decoration: underline; }
.gallery-open:focus-visible { outline-offset: -3px; }
.gallery-preview > .image-placeholder { color: #7285a1; }
.gallery-card-body { min-height: 64px; padding-right: 64px; }
.gallery-card-title { font-size: 13px; }
.gallery-card-meta { color: #5e7290; }
.gallery-card-style { max-width: 115px; overflow: hidden; text-overflow: ellipsis; color: #536987; }
.gallery-favorite {
  position: absolute;
  right: 11px;
  bottom: 11px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fffffff2;
  color: #657891;
  box-shadow: 0 2px 8px #10234420;
  padding: 0;
}
.gallery-favorite svg { width: 17px; height: 17px; }
.gallery-favorite[aria-pressed="true"],
#previewFavorite[aria-pressed="true"] { color: #a45469; background: #fff0f3; }
.gallery-favorite[aria-pressed="true"] svg,
#previewFavorite[aria-pressed="true"] svg { fill: currentColor; }
.library-empty h2 { color: #506888; }
.library-empty p { color: #657891; }
.library-empty .secondary-button { margin-top: 15px; }

.library-footer {
  flex: none;
  margin-top: auto;
  padding-top: 8px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}
.library-footer a {
  display: inline-block;
  padding: 4px 8px;
  color: #56687d;
  text-decoration: none;
}
.library-footer a:hover,
.library-footer a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.preview-navigation {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
  align-items: center;
}

.preview-position {
  color: #627693;
  white-space: nowrap;
  min-width: 36px;
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.preview-information { display: contents; }
.mobile-preview-info { display: none; }
.preview-exit-fullscreen { display: none; }
.preview-detail-title { font-weight: 600; font-size: 13px; }
.preview-details { display: grid; gap: 13px; margin: 0; font-size: 12px; }
.preview-details > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.preview-details dt { color: #617692; flex: none; }
.preview-details dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
.preview-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-tags .gallery-card-style { padding: 5px 9px; font-size: 11px; max-width: 100%; }
.preview-admin { display: flex; flex: 1 1 100%; gap: inherit; }
.gallery-dialog-actions .delete-image { color: #934b5c; }

.management-form { display: grid; gap: 13px; }
.management-form label { display: grid; gap: 8px; font-weight: 500; }
.management-form input:not([type=file]) {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #e0e6ef;
  border-radius: 13px;
  background: #fff;
  font-weight: 400;
}

.form-hint, .form-error { font-size: 12px; line-height: 1.6; margin: 0; }
.form-hint { color: #617692; }
.form-error { color: #9b4055; overflow-wrap: anywhere; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 13px; }
.form-actions .primary-button { min-height: 42px; padding-left: 18px; padding-right: 18px; }
.form-actions > span { font-size: 12px; color: #617692; }
.confirm-modal .form-error { color: #9b4055; }
.confirm-modal #deleteDescription { color: #657891; overflow-wrap: anywhere; }
.upload-modal { width: min(565px, calc(100% - 32px)); }

.upload-drop {
  display: grid;
  gap: 7px;
  justify-items: center;
  background: #edf0f5;
  border: 1px dashed #b9c7da;
  border-radius: 18px;
  padding: 17px 14px;
  text-align: center;
  transition: background .18s, border-color .18s;
}

.upload-drop.is-over { background: #e2eaf6; border-color: #728dab; }
.upload-drop p { margin: 0; color: #617692; font-size: 11px; line-height: 1.5; }
.upload-emblem { color: #6e83a0; }
.upload-emblem svg { width: 26px; height: 26px; }
.upload-list {
  list-style: none;
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  max-height: 145px;
  overflow: auto;
}

.upload-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
  background: #fff;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
}

.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-meta { color: #617692; font-size: 11px; }
.upload-list button { padding: 4px; }
.upload-list button svg { width: 14px; height: 14px; }
.upload-file-error { grid-column: 1 / -1; color: #9b4055; }

@media (max-width: 950px) {
  .library-controls { gap: 8px; }
  .library-facets { gap: 7px; }
  .library-facets .library-sort select { min-width: 90px; padding-left: 12px; }
}

@media (max-width: 820px) {
  .library-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .library-facets { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-facets:has(#shapeControl[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-facets .library-sort { margin: 0; }
  .library-facets .library-sort select { width: 100%; max-width: none; min-width: 0; }
  .library-search { order: 0; min-width: 0; }
  .sort-control { order: 0; }
  .reset-filters { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 640px) {
  body { min-width: 320px; }
  .library-topbar { padding-left: 8px; }
  .mobile-brand { display: block; }
  .desktop-folder { display: none; }
  .admin-access { min-height: 39px; }
  .library-heading { margin-bottom: 17px; }
  .library-view-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    border-radius: 22px;
    background: #e9edf2;
  }
  .library-view-switch a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 38px;
    padding: 0 6px;
    border-radius: 18px;
    color: #536987;
    font-size: 12px;
    white-space: nowrap;
  }
  .library-view-switch a.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 2px 6px #10234408;
  }
  .library-view-switch svg { width: 14px; height: 14px; }
  .gallery-favorite { right: 8px; bottom: 8px; }
  .management-form input:not([type=file]) { font-size: 16px; }
}

@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  .library-facets { display: none; }
  html.gallery-preview-open { overflow: hidden; overscroll-behavior: none; }
  .gallery-preview-open body {
    position: fixed;
    inset-inline: 0;
    top: var(--preview-scroll-offset);
  }
  .gallery-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #111a28;
    color: #f2f5fb;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .gallery-dialog[open] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .gallery-dialog-heading {
    gap: 10px;
    padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    border: 0;
  }
  .gallery-dialog-heading .icon-button {
    width: 44px;
    height: 44px;
    background: #ffffff14;
  }
  .preview-navigation { gap: 4px; }
  .preview-position { min-width: 30px; color: #b9c9df; }
  .gallery-dialog-image {
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
    background: #0a111c;
    overflow: hidden;
    touch-action: pinch-zoom;
  }
  .gallery-dialog-image img {
    height: 100%;
    min-height: 0;
    max-height: none;
    border-radius: 0;
  }
  .gallery-dialog-content {
    position: relative;
    max-height: none;
    padding: 6px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .gallery-dialog-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
  }
  .gallery-dialog-actions .secondary-button {
    min-height: 44px;
    background: #ffffff14;
  }
  .gallery-dialog-actions .delete-image { color: #f7b5c4; }
  .mobile-preview-info { display: inline-flex; }
  .mobile-preview-info[aria-expanded="true"] { background: #344761; }
  .preview-admin { grid-column: 1 / -1; }
  .gallery-dialog:not(.showing-preview-info) .preview-admin { display: none; }
  .preview-information {
    display: none;
    position: absolute;
    inset-inline: 0;
    bottom: 100%;
    z-index: 1;
    max-height: min(45dvh, 300px);
    overflow: auto;
    overscroll-behavior: contain;
    gap: 10px;
    padding: 15px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
    border-radius: 16px 16px 0 0;
    background: #202e43;
  }
  .showing-preview-info .preview-information { display: grid; }
  .preview-details { gap: 8px; }
  .preview-details dt { color: #b9c9df; }
}

html.image-fullscreen { overflow: hidden; overscroll-behavior: none; }

.image-fullscreen .gallery-dialog[open] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  overflow: hidden;
  overscroll-behavior: none;
}

.image-fullscreen .gallery-dialog-heading,
.image-fullscreen .gallery-dialog-content { display: none; }

.image-fullscreen .gallery-dialog-image {
  position: relative;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #0a111c;
  color: #f2f5fb;
  overflow: hidden;
  touch-action: pinch-zoom;
}

.image-fullscreen .gallery-dialog-image img {
  height: 100%;
  min-height: 0;
  max-height: none;
  border-radius: 0;
}

.image-fullscreen .preview-exit-fullscreen {
  display: inline-flex;
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  background: #101e32c7;
  color: #fff;
}

@media (pointer: coarse) {
  .gallery-favorite { width: 44px; height: 44px; }
}
