:root {
  color-scheme: dark;
  --bg: #0c1117;
  --panel: #151c24;
  --panel-strong: #1d2731;
  --text: #edf3f8;
  --muted: #9aa9b7;
  --line: #2b3846;
  --teal: #2dd4bf;
  --teal-dark: #14b8a6;
  --amber: #fbbf24;
  --red: #fb7185;
  --blue: #60a5fa;
  --shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
.action-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111821;
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.action-button:hover {
  border-color: #4b6073;
  background: #1b2530;
}

button:disabled {
  cursor: not-allowed;
  color: #667685;
  background: #111821;
}

.disclaimer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 8, 13, 0.78);
  backdrop-filter: blur(10px);
}

.disclaimer-backdrop[hidden] {
  display: none;
}

.disclaimer-panel {
  width: min(100%, 640px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid #355063;
  border-radius: 8px;
  background: #111923;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
}

.disclaimer-panel h2 {
  margin-bottom: 14px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.08;
}

.disclaimer-panel p {
  color: #becad5;
  line-height: 1.55;
}

.disclaimer-panel button {
  margin-top: 8px;
  border-color: var(--teal);
  background: rgba(45, 212, 191, 0.16);
  color: #ccfbf1;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(70px, 12vw) minmax(0, 1fr) minmax(70px, 12vw);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  background: rgba(2, 6, 10, 0.94);
  backdrop-filter: blur(8px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-close {
  grid-column: 3;
  justify-self: end;
  min-width: 92px;
}

.lightbox-frame {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

.lightbox-frame img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 154px);
  object-fit: contain;
  border-radius: 8px;
  background: #05080d;
}

.lightbox-caption {
  display: grid;
  gap: 4px;
  padding: 12px 0 0;
}

.lightbox-caption h2,
.lightbox-caption p {
  margin: 0;
}

.lightbox-caption h2 {
  font-size: 1rem;
}

.lightbox-caption p {
  color: var(--muted);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.lightbox-nav {
  grid-row: 2;
  align-self: center;
  min-height: 72px;
  border-color: #344456;
  background: rgba(255, 255, 255, 0.06);
}

.lightbox-prev {
  grid-column: 1;
}

.lightbox-next {
  grid-column: 3;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 44px) 22px;
  background: #090d12;
  color: #f8fbfd;
  border-bottom: 4px solid var(--teal);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: var(--teal);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.live-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.live-actions button {
  border-color: #314052;
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.live-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.live-actions button:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: #93a3b1;
}

main {
  padding: 22px clamp(16px, 4vw, 44px) 44px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--panel);
}

.notice[hidden] {
  display: none;
}

.notice.success {
  border-left-color: var(--teal);
}

.notice.error {
  border-left-color: var(--red);
}

.notice.info {
  border-left-color: var(--blue);
}

.notice span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(240px, 1fr) minmax(160px, 220px) auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  text-transform: uppercase;
}

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

input::placeholder {
  color: #6d7c8b;
}

input:focus,
select:focus,
button:focus-visible,
.action-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 1px;
}

.view-tabs,
.layout-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout-tabs[hidden] {
  display: none;
}

.view-tabs button.active,
.layout-tabs button.active {
  border-color: var(--teal);
  background: rgba(45, 212, 191, 0.16);
  color: #ccfbf1;
}

.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 12px;
}

.results-heading h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.result-count {
  color: var(--muted);
  font-weight: 700;
}

.results {
  min-height: 240px;
}

.scroll-sentinel {
  width: 100%;
  height: 1px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.asset-card {
  display: grid;
  grid-template-rows: 190px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.asset-preview,
.file-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0f1720;
  color: var(--muted);
  font-weight: 800;
}

.asset-preview img,
.file-thumb img,
.image-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-failed {
  border: 1px dashed #4c5d6d;
}

.asset-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.asset-body h3 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.key-line,
.file-key {
  margin: 0;
  color: var(--muted);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #334353;
  border-radius: 999px;
  background: var(--panel-strong);
  color: #c7d3df;
  font-size: 0.76rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.package-list {
  display: grid;
  gap: 6px;
}

.package-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid #293746;
  border-radius: 6px;
  background: #101821;
}

.file-type {
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.package-name {
  overflow: hidden;
  color: #cdd8e3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-size {
  color: var(--muted);
  font-size: 0.82rem;
}

.image-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  min-height: 0;
}

.image-strip:empty {
  display: none;
}

.image-strip img {
  height: 54px;
  border-radius: 6px;
  background: #0f1720;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.file-list,
.image-list,
.image-gallery {
  display: grid;
  gap: 10px;
}

.image-gallery {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.image-card {
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.image-card-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #0f1720;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  cursor: zoom-in;
}

.image-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-card-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.file-row.with-thumb {
  grid-template-columns: 94px minmax(0, 1fr) auto;
}

.file-thumb {
  width: 94px;
  height: 70px;
  border-radius: 6px;
}

.image-open-button {
  padding: 0;
  border: 0;
  cursor: zoom-in;
}

.file-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.single-panel {
  display: grid;
  place-items: center;
}

.empty-state {
  width: min(100%, 540px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .topbar,
  .results-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-actions {
    justify-content: flex-start;
  }

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

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

  .view-tabs,
  .layout-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }

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

  .file-row,
  .file-row.with-thumb {
    grid-template-columns: 1fr;
  }

  .file-thumb {
    width: 100%;
    height: 160px;
  }

  .lightbox {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 12px;
  }

  .lightbox-close {
    grid-column: 1 / -1;
  }

  .lightbox-frame {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .lightbox-frame img {
    max-height: calc(100vh - 210px);
  }

  .lightbox-nav {
    grid-row: 3;
    min-height: 44px;
  }

  .lightbox-prev {
    grid-column: 1;
  }

  .lightbox-next {
    grid-column: 2;
  }

  .actions {
    align-items: stretch;
  }

  .actions > * {
    flex: 1 1 120px;
  }

  .package-row {
    grid-template-columns: 1fr;
  }
}
