*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

:root {
  --bg: #111317;
  --panel: #1b2027;
  --panel-soft: #232a33;
  --line: rgba(214, 222, 232, 0.14);
  --text: #eef2f7;
  --muted: #9da9b8;
  --accent: #e6b450;
  --accent-2: #5fb7b2;
  --danger: #e86868;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #101215 0%, #151a20 45%, #101215 100%);
}

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(230, 180, 80, 0.75) rgba(18, 22, 28, 0.86);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(230, 180, 80, 0.75) rgba(18, 22, 28, 0.86);
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: rgba(18, 22, 28, 0.86);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(230, 180, 80, 0.92), rgba(95, 183, 178, 0.82));
  border: 2px solid rgba(18, 22, 28, 0.86);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #f0c669, #6fcac5);
}

*::-webkit-scrollbar-corner {
  background: rgba(18, 22, 28, 0.86);
}

button, input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  cursor: pointer;
}

a.link-btn {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  text-decoration: none;
}

a.link-btn:hover {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

a.link-btn.is-active {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

.topbar-actions button,
.topbar-actions .link-btn,
.view-actions button,
.view-actions .link-btn {
  min-height: 32px;
  padding: 0 0.65rem;
  font-size: 0.88rem;
}

#model-seen-btn {
  min-width: 8.8rem;
}

button:hover,
button.is-active {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

button.has-errors,
button.has-errors:hover {
  border-color: rgba(232, 104, 104, 0.62);
  background: rgba(120, 34, 34, 0.86);
  color: #ffd4d4;
}

button:disabled {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(37, 44, 54, 0.42);
  color: rgba(157, 169, 184, 0.48);
  cursor: not-allowed;
  opacity: 0.72;
}

button:disabled:hover {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(37, 44, 54, 0.42);
}

input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
  color: var(--text);
  padding: 0 0.75rem;
  outline: none;
}

input:focus {
  border-color: rgba(95, 183, 178, 0.65);
}

input:disabled {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(18, 22, 28, 0.55);
  color: rgba(157, 169, 184, 0.55);
  cursor: not-allowed;
}

.app-shell {
  width: min(1680px, calc(100vw - 28px));
  margin: 14px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 39, 0.92);
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  padding: 0.7rem 0 0.7rem 0.9rem;
  display: flex;
  align-items: center;
}

.topbar > .topbar-actions {
  padding: 0 0.9rem 0 0;
}

.topbar h1 {
  margin-top: 0.15rem;
  font-size: clamp(1.2rem, 2vw, 2rem);
  line-height: 1;
  font-weight: 750;
}

.app-title-link {
  color: inherit;
  text-decoration: none;
}

.app-version-stack {
  display: inline-grid;
  gap: 0.08rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.app-tagline {
  color: var(--accent-2);
  font-size: 0.38em;
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-version-label {
  color: var(--accent);
  font-size: 0.36em;
  font-weight: 400;
  white-space: nowrap;
  line-height: 1;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: end;
}

.stats-stack {
  display: grid;
  gap: 0.16rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 3.8rem minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.stats-card {
  min-height: 36px;
  display: grid;
  align-items: center;
  width: 100%;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(18, 22, 28, 0.82);
}

.stats-label,
.user-stats,
#stats {
  font-size: 0.92rem;
  line-height: 1.15;
}

.stats-label {
  color: var(--text);
  text-align: right;
}

#stats {
  color: var(--muted);
}

.user-stats {
  color: var(--accent-2);
}

.auth-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: end;
}

.auth-box input {
  width: 118px;
  min-height: 32px;
  font-size: 0.86rem;
}

.auth-box button {
  min-height: 32px;
  padding: 0 0.65rem;
  font-size: 0.86rem;
}

.auth-box span {
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.admin-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 39, 0.9);
}

.admin-users-list {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
}

.admin-audit-list {
  display: grid;
  gap: 1rem;
  padding: 0.9rem;
}

.admin-audit-section {
  display: grid;
  gap: 0.55rem;
}

.admin-user-card {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 28, 0.58);
}

.admin-user-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.admin-user-card-head span,
.admin-user-card-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-shell .topbar {
  align-items: center;
  padding: 0.75rem 0.9rem;
}

.admin-shell .topbar > div:first-child {
  display: block;
  padding: 0;
}

.admin-shell .topbar h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.admin-shell .eyebrow {
  font-size: 0.66rem;
}

.admin-shell .content-head h2 {
  font-size: 1rem;
  line-height: 1.15;
}

#import-title {
  font-size: 0.95rem;
  line-height: 1.25;
  font-weight: 650;
}

.admin-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  padding: 0.9rem;
}

.admin-form input {
  min-height: 32px;
  font-size: 0.9rem;
}

.admin-form + .admin-form {
  padding-top: 0;
}

.admin-form-wide {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-form button {
  min-height: 28px;
  font-size: 0.8rem;
  min-width: 86px;
  padding: 0 0.65rem;
}

.admin-secondary-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.9rem 0.75rem;
  color: var(--muted);
}

.admin-secondary-actions button {
  min-height: 28px;
  padding: 0 0.55rem;
  font-size: 0.78rem;
}

.admin-secondary-actions span {
  font-size: 0.86rem;
}

.loaded-models {
  margin: 0 0.9rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
}

.loaded-models-head {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
}

.loaded-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.35rem;
  max-height: 260px;
  overflow: auto;
  padding: 0.75rem;
}

.loaded-models-grid span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.url-audit-list {
  display: grid;
  gap: 0.25rem;
  max-height: 300px;
  overflow: auto;
  padding: 0.55rem;
}

.url-audit-item {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1fr) minmax(260px, 1.5fr) auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12161c;
}

.url-audit-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 0.78rem;
  white-space: nowrap;
}

.url-audit-item span,
.url-audit-item a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.url-audit-item a {
  color: var(--accent-2);
  text-decoration: none;
}

.url-audit-item a:hover {
  text-decoration: underline;
}

.url-audit-item button {
  justify-self: end;
  min-height: 24px;
  padding: 0 0.48rem;
  font-size: 0.7rem;
}

.import-errors {
  margin: 0 0.9rem 0.9rem;
  border: 1px solid rgba(232, 104, 104, 0.34);
  border-radius: 8px;
  background: rgba(232, 104, 104, 0.06);
}

.import-error-list {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
}

.import-error-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(232, 104, 104, 0.22);
  border-radius: 6px;
  background: #12161c;
}

.import-error-item strong {
  color: var(--danger);
  font-size: 0.9rem;
}

.import-error-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
}

.import-error-meta button {
  min-height: 28px;
  padding: 0 0.65rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.import-error-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-error-item span,
.import-error-item small {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-error {
  min-height: 1.4rem;
  padding: 0 0.9rem 0.9rem;
  color: var(--danger);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0.6rem;
}

.admin-stats article:has(#heap-size-stat) {
  min-width: 10.5rem;
}

.view-stats-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-stats article {
  display: grid;
  gap: 0.18rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
}

.admin-stats span {
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-stats strong {
  font-size: 1.02rem;
  line-height: 1.1;
}

.admin-stats-actions {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0 0.6rem 0.6rem;
}

.admin-stats-actions button {
  grid-column: 5;
  justify-self: stretch;
  min-height: 28px;
  padding: 0 0.55rem;
  font-size: 0.76rem;
}

.log-list {
  display: grid;
  gap: 0.35rem;
  max-height: 420px;
  overflow: auto;
  padding: 0 0.9rem 0.9rem;
}

.log-item {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12161c;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
}

.view-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0 0.9rem 0.9rem;
}

.view-ranking {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
}

.view-ranking h3 {
  color: var(--accent);
  font-size: 0.92rem;
}

.view-ranking-row {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.45rem 0;
  border-top: 1px solid rgba(214, 222, 232, 0.08);
}

.view-ranking-row strong,
.view-ranking-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-ranking-row strong {
  color: var(--text);
  font-size: 0.85rem;
}

.view-ranking-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.small-empty {
  padding: 0.75rem 0;
  font-size: 0.85rem;
}

.sidebar,
.content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 39, 0.9);
}

.sidebar {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 118px);
  overflow: hidden;
}

.sidebar-head,
.content-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-head {
  display: grid;
}

.sidebar-count {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
  text-align: center;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  cursor: pointer;
}

.sidebar-toggle input {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.sidebar h2,
.content h2 {
  font-size: 1rem;
}

.model-list,
.gallery-list {
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
}

.list-limit-note {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(18, 22, 28, 0.7);
  font-size: 0.82rem;
}

.model-card,
.gallery-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.45rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  text-decoration: none;
}

.model-card:hover,
.gallery-card:hover,
.browser-model-card:hover,
.favorite-image-card:hover {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

.favorite-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: rgba(230, 180, 80, 0.34);
  background: rgba(18, 22, 28, 0.82);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.favorite-btn.is-favorite {
  color: var(--accent);
  border-color: rgba(230, 180, 80, 0.72);
}

.favorite-btn:disabled {
  opacity: 0.45;
}

.seen-btn,
.seen-badge {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid rgba(95, 183, 178, 0.34);
  border-radius: 8px;
  background: rgba(18, 22, 28, 0.82);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.seen-btn.is-seen,
.seen-badge {
  color: var(--accent-2);
  border-color: rgba(95, 183, 178, 0.72);
}

.seen-btn:disabled {
  opacity: 0.45;
}

.image-seen-toggle {
  padding: 0;
  cursor: pointer;
}

.image-seen-toggle:disabled {
  cursor: default;
}

.model-card img,
.gallery-card img {
  width: 72px;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: #11161c;
}

.sidebar-hover-preview {
  position: fixed;
  z-index: 60;
  width: 240px;
  padding: 0.5rem;
  border: 1px solid rgba(230, 180, 80, 0.38);
  border-radius: 10px;
  background: rgba(18, 22, 28, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.sidebar-hover-preview.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sidebar-hover-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1.15;
  border-radius: 8px;
  object-fit: cover;
  background: #11161c;
}

.sidebar-hover-preview-caption {
  padding: 0.45rem 0.2rem 0.1rem;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 1.2;
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  text-transform: capitalize;
}

.card-sub {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.gallery-list {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.gallery-list.latest-gallery-list {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.latest-gallery-card {
  display: block;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.latest-gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px 6px 0 0;
  object-fit: cover;
}

.latest-gallery-card > div {
  display: grid;
  gap: 0.15rem;
  padding: 0.55rem 0.6rem 0.65rem;
}

.selected-gallery-bar {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.8rem;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 22, 28, 0.42);
}

.selected-gallery-bar[hidden] {
  display: none;
}

.selected-gallery-cover {
  position: relative;
  width: 78px;
}

.selected-gallery-cover img {
  display: block;
  width: 78px;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: #11161c;
}

.selected-gallery-main {
  min-width: 0;
}

.selected-gallery-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 750;
}

.selected-gallery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}

.selected-gallery-actions .gallery-action-btn {
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0 0.6rem;
  font-size: 0.88rem;
  line-height: 1.1;
  border-radius: 6px;
  white-space: nowrap;
  vertical-align: middle;
}

.selected-gallery-actions .gallery-seen-btn {
  width: 7rem;
  min-width: 7rem;
  text-align: center;
}

.selected-gallery-actions .favorite-btn {
  position: static;
}

.selected-gallery-actions .seen-btn {
  position: static;
}

.model-browser {
  display: grid;
  gap: 0.8rem;
  padding: 0.8rem;
}

.model-browser[hidden],
.favorites-view[hidden] {
  display: none;
}

.favorites-view {
  display: grid;
  gap: 1rem;
  padding: 0.8rem;
}

.favorites-section {
  display: grid;
  gap: 0.55rem;
}

.favorites-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.favorites-section h3 {
  color: var(--text);
  font-size: 0.95rem;
}

.favorites-section-head button {
  min-height: 32px;
  padding: 0 0.65rem;
  font-size: 0.86rem;
}

.favorite-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.favorite-image-group {
  display: grid;
  gap: 0.2rem;
  padding: 0.38rem 0.55rem 0.38rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 28, 0.52);
}

.favorite-image-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  list-style: none;
  line-height: 1.1;
}

.favorite-image-group-summary::-webkit-details-marker {
  display: none;
}

.favorite-image-group-summary span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.favorite-image-item {
  display: grid;
  gap: 0.45rem;
}

.favorite-image-card {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  text-decoration: none;
}

.favorite-image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px 6px 0 0;
  object-fit: cover;
  background: #11161c;
}

.favorite-image-meta {
  padding: 0.55rem 0.6rem 0.65rem;
}

.favorite-image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.favorite-image-actions button {
  min-height: 32px;
  padding: 0 0.55rem;
  font-size: 0.86rem;
}

.letter-bar,
.pager-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.letter-bar {
  justify-content: center;
}

.letter-bar a,
.letter-bar button {
  min-width: 32px;
  min-height: 28px;
  padding: 0 0.45rem;
  font-size: 0.76rem;
  border-radius: 6px;
}

.browser-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.55rem;
}

.browser-model-card {
  position: relative;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  text-decoration: none;
}

.browser-model-card img {
  width: 82px;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: #11161c;
}

.pager-row {
  justify-content: center;
  color: var(--muted);
}

.pager-row a,
.pager-row button {
  min-height: 28px;
  padding: 0 0.6rem;
  font-size: 0.78rem;
  border-radius: 6px;
}

.image-grid {
  --tile: 190px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 8px;
  padding: 0.8rem;
}

.image-grid.large {
  --tile: 280px;
}

.image-tile {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #11161c;
}

.image-tile-loading {
  display: grid;
  gap: 0;
  overflow: hidden;
  pointer-events: none;
}

.image-tile-skeleton {
  aspect-ratio: 1;
  background: rgba(214, 222, 232, 0.08);
}

.image-tile-loading-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(214, 222, 232, 0.12);
}

.image-tile-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -40%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: image-tile-loading-slide 1s ease-in-out infinite;
}

.card-image-host {
  position: relative;
}

.card-image-host::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: rgba(214, 222, 232, 0.06);
  opacity: 0;
  pointer-events: none;
}

.card-image-host::after {
  display: none;
}

.card-image-host.is-loading::before {
  opacity: 1;
}

.card-image-host.is-loading img {
  opacity: 0.18;
}

.card-image-host.is-error img {
  opacity: 0.12;
}

.card-image-host.is-loading > .card-image-progress {
  opacity: 1;
}

.card-image-progress {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(214, 222, 232, 0.12);
  opacity: 0;
  pointer-events: none;
}

.card-image-progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -40%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: image-tile-loading-slide 1s ease-in-out infinite;
}

.image-tile.is-seen img {
  filter: saturate(0.78) brightness(0.82);
}

.image-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.image-tile:hover img {
  transform: scale(1.035);
}

.empty {
  padding: 2rem;
  color: var(--muted);
}

.favorites-empty {
  display: grid;
  gap: 0.4rem;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 28, 0.58);
  text-align: center;
}

.favorites-empty strong {
  color: var(--text);
  font-size: 1rem;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.view-actions button {
  padding: 0 0.7rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.88);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-media {
  position: relative;
  display: grid;
  place-items: center;
  min-width: min(96vw, 320px);
  min-height: min(78vh, 320px);
}

.lightbox img {
  max-width: min(96vw, 1600px);
  max-height: 92vh;
  object-fit: contain;
  transition: opacity 160ms ease;
}

.lightbox img.is-pending {
  opacity: 0;
}

.lightbox img.is-loading {
  opacity: 0.18;
}

.lightbox img.is-error {
  opacity: 0.08;
}

.lightbox-loading {
  position: absolute;
  inset: auto 50% 50%;
  transform: translate(-50%, 50%);
  display: grid;
  gap: 0.55rem;
  width: min(280px, calc(100vw - 48px));
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 19, 23, 0.88);
  backdrop-filter: blur(6px);
}

.lightbox-loading[hidden] {
  display: none;
}

.lightbox-loading-bar {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(214, 222, 232, 0.12);
}

.lightbox-loading-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -40%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: lightbox-loading-slide 1s ease-in-out infinite;
}

.lightbox-loading.is-error .lightbox-loading-bar {
  background: rgba(232, 104, 104, 0.18);
}

.lightbox-loading.is-error .lightbox-loading-bar::after {
  inset: 0;
  width: auto;
  background: rgba(232, 104, 104, 0.72);
  animation: none;
}

.lightbox-loading.is-error .lightbox-loading-text {
  color: #f2b1b1;
}

.lightbox-loading-text {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

@keyframes image-tile-skeleton {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@keyframes image-tile-loading-slide {
  from { left: -40%; }
  to { left: 100%; }
}

@keyframes lightbox-loading-slide {
  from { left: -40%; }
  to { left: 100%; }
}

.icon-btn,
.nav-btn {
  position: fixed;
  z-index: 90;
  display: grid;
  place-items: center;
  border: 1px solid rgba(214, 222, 232, 0.14);
  background: rgba(17, 19, 23, 0.84);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.icon-btn {
  top: 8px;
  min-width: 34px;
  min-height: 34px;
  font-size: 1.05rem;
}

.lightbox-favorite {
  right: 48px;
  border-color: rgba(230, 180, 80, 0.42);
  color: var(--muted);
}

.lightbox-download {
  right: 128px;
  border-color: rgba(214, 222, 232, 0.3);
  background: rgba(25, 30, 37, 0.92);
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 700;
}

.lightbox-seen {
  right: 88px;
  border-color: rgba(95, 183, 178, 0.42);
  color: var(--muted);
}

#close-lightbox {
  right: 8px;
  font-size: 1.2rem;
}

.lightbox-favorite.is-favorite {
  color: var(--accent);
  border-color: rgba(230, 180, 80, 0.78);
}

.lightbox-seen.is-seen {
  color: var(--accent-2);
  border-color: rgba(95, 183, 178, 0.78);
}

.lightbox-download:disabled,
.lightbox-favorite:disabled {
  opacity: 0.45;
}

.lightbox-seen:disabled {
  opacity: 0.45;
}

.nav-btn {
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 52px;
  font-size: 1.45rem;
  border-radius: 8px;
}

.nav-btn.prev { left: 8px; }
.nav-btn.next { right: 8px; }

.icon-btn:hover,
.nav-btn:hover {
  background: rgba(34, 40, 49, 0.94);
  border-color: rgba(230, 180, 80, 0.34);
}

.icon-btn:disabled,
.nav-btn:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.nav-btn:disabled:hover {
  background: rgba(17, 19, 23, 0.84);
  border-color: rgba(214, 222, 232, 0.14);
}

.caption {
  position: fixed;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  max-width: min(860px, calc(100vw - 20px));
  padding: 0.38rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(214, 222, 232, 0.12);
  background: rgba(17, 19, 23, 0.84);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  backdrop-filter: blur(10px);
}

@media (max-width: 820px) {
  .topbar,
  .content-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .model-list {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }

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

  .icon-btn {
    top: 6px;
    min-width: 30px;
    min-height: 30px;
  }

  .lightbox-seen {
    right: 78px;
  }

  .lightbox-download {
    right: 114px;
  }

  .lightbox-favorite {
    right: 42px;
  }

  #close-lightbox {
    right: 6px;
  }

  .nav-btn {
    width: 30px;
    height: 46px;
  }

  .nav-btn.prev { left: 6px; }
  .nav-btn.next { right: 6px; }

  .view-stats-grid,
  .view-stats-summary {
    grid-template-columns: 1fr;
  }

  .url-audit-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .url-audit-item button {
    justify-self: start;
  }

  .selected-gallery-bar {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .selected-gallery-bar img {
    width: 64px;
  }

  .selected-gallery-cover {
    width: 64px;
  }

  .selected-gallery-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
