:root {
  color-scheme: dark;
  --background: #111210;
  --surface: #191b18;
  --surface-raised: #22241f;
  --line: #363a32;
  --text: #f4f2ea;
  --muted: #aaa99f;
  --green: #9bd46f;
  --coral: #ef826c;
  --focus: #f3c65f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(16px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 18, 16, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid #b7df98;
  border-radius: 8px;
  background: #0b0c0a;
  object-fit: cover;
}

.brand h1,
.brand p,
.gallery-heading h2,
.gallery-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quiet-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.quiet-button:hover {
  color: var(--text);
}

.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.filter-field {
  display: grid;
  min-width: 220px;
  gap: 6px;
}

.exclude-channels {
  position: relative;
  min-width: 150px;
}

.exclude-channels summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  padding: 0 12px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.exclude-channels summary::-webkit-details-marker {
  display: none;
}

.exclude-channel-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  width: max-content;
  min-width: 220px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
  padding: 6px;
}

.exclude-channel-options label {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  border-radius: 4px;
  padding: 7px 9px;
  cursor: pointer;
}

.exclude-channel-options label:hover {
  background: var(--surface);
}

.exclude-channel-options input {
  width: 16px;
  height: 16px;
}

.filter-field label,
.login-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f100e;
  color: var(--text);
  padding: 0 12px;
}

.author-field {
  position: relative;
}

.author-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.author-results button {
  display: block;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}

.author-results button:hover {
  background: #2b3027;
}

.clear-button,
.load-row button,
.login-form button,
#backfillButton {
  min-height: 42px;
  border: 1px solid #b8dd99;
  border-radius: 6px;
  background: var(--green);
  color: #17200f;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.selected-author {
  min-height: 42px;
  align-content: center;
  border-left: 3px solid var(--coral);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
}

.gallery-main {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 28px clamp(12px, 3vw, 42px) 64px;
}

.gallery-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.gallery-heading h2 {
  margin-top: 3px;
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: 0;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  align-items: start;
  gap: 14px;
}

.image-tile {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.image-button {
  position: relative;
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: zoom-in;
}

.image-button img,
.image-button video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: cover;
  background: #0b0c0a;
}

.video-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  background: rgba(10, 11, 9, 0.82);
  color: #fff;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
}

.tile-meta {
  display: grid;
  gap: 3px;
  padding: 11px 12px 12px;
}

.tile-meta strong,
.tile-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-meta strong {
  font-size: 14px;
}

.tile-meta span {
  color: var(--muted);
  font-size: 12px;
}

.load-row {
  display: grid;
  place-items: center;
  min-height: 92px;
}

.empty-state {
  padding: 72px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

dialog {
  color: var(--text);
}

dialog::backdrop {
  background: rgba(4, 5, 4, 0.84);
}

.image-dialog {
  width: min(1180px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0;
}

.dialog-close {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
}

.image-dialog > .dialog-close {
  position: absolute;
  z-index: 2;
  top: 6px;
  right: 6px;
  border-radius: 50%;
  background: rgba(10, 11, 9, 0.78);
}

.dialog-media {
  display: grid;
  min-height: 300px;
  max-height: calc(100vh - 150px);
  place-items: center;
  overflow: auto;
  background: #090a08;
}

.dialog-media img,
.dialog-media video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
}

.dialog-media [hidden] {
  display: none;
}

.dialog-details {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 24px;
  min-height: 92px;
  padding: 16px 20px;
}

.dialog-details p {
  margin: 0;
}

.dialog-artist {
  font-size: 17px;
  font-weight: 800;
}

#dialogContext {
  grid-row: 2;
  color: var(--muted);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  grid-row: 1 / span 2;
  grid-column: 2;
  gap: 8px;
}

.dialog-actions a {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  text-decoration: none;
}

.dialog-actions a:first-child {
  border-color: var(--green);
  color: var(--green);
}

.status-dialog {
  width: min(620px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-header h2 {
  margin: 0;
  font-size: 22px;
}

.status-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  margin: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-totals div {
  display: grid;
  gap: 3px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.status-totals div:last-child {
  border-right: 0;
}

.status-totals strong {
  font-size: 22px;
}

.status-totals span {
  color: var(--muted);
  font-size: 12px;
  text-transform: capitalize;
}

.status-list {
  margin-bottom: 18px;
}

.status-subheading {
  margin: 22px 0 8px;
  font-size: 15px;
}

.status-note {
  margin: -5px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.bandwidth-list {
  max-height: 250px;
  overflow: auto;
}

.status-list div {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.status-list span {
  color: var(--muted);
  font-size: 12px;
}

.status-actions {
  display: flex;
  gap: 8px;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(400px, 100%);
}

.login-panel {
  border-top: 3px solid var(--green);
  background: var(--surface);
  padding: 34px;
}

.login-panel .brand-mark {
  margin-bottom: 24px;
}

.login-panel h1,
.login-panel p {
  margin: 0;
}

.login-panel h1 {
  margin-top: 4px;
  font-size: 32px;
}

.login-subtitle {
  margin-top: 5px !important;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 7px;
  margin-top: 28px;
}

.login-form input + label {
  margin-top: 8px;
}

.login-form button {
  margin-top: 14px;
}

.form-error {
  margin-top: 18px !important;
  border-left: 3px solid var(--coral);
  color: #ffc0b4;
  padding-left: 10px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    display: grid;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .filter-field {
    min-width: 0;
  }

  .author-field {
    grid-column: 1 / -1;
  }

  .selected-author {
    grid-column: 1 / -1;
  }

  .exclude-channels {
    min-width: 0;
  }

  .exclude-channel-options {
    right: auto;
    left: 0;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tile-meta {
    padding: 9px;
  }

  .dialog-details {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    grid-row: auto;
    grid-column: auto;
  }
}

@media (max-width: 430px) {
  .brand p {
    display: none;
  }

  .quiet-button {
    min-height: 34px;
    font-size: 12px;
  }

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

  .author-field,
  .selected-author {
    grid-column: auto;
  }

  .clear-button {
    width: 100%;
  }

  .exclude-channel-options {
    right: 0;
    left: 0;
    width: auto;
    min-width: 0;
  }

  .gallery-main {
    padding-right: 8px;
    padding-left: 8px;
  }

  .gallery-heading {
    padding: 0 4px;
  }

  .gallery-heading h2 {
    font-size: 24px;
  }

  .dialog-actions {
    display: grid;
  }
}
