:root {
  --bg: #0B0B0B;
  --card: #141414;
  --orange: #F7931A;
  --white: #ffffff;
  --line: rgba(255, 255, 255, 0.08);
  --chip-line: rgba(255, 255, 255, 0.2);
  --muted: rgba(255, 255, 255, 0.6);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: Montserrat, Helvetica, Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: var(--white); }
a:hover { color: #ffb14a; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 80;
  padding: 8px 12px;
  background: var(--orange);
  color: #0B0B0B;
  font-weight: 700;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.site-nav .logo {
  display: block;
  height: 40px;
  width: auto;
}

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
}

.site-nav-links a {
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.site-nav-links a[aria-current="page"] {
  color: var(--orange);
}

.library-head {
  background: var(--bg);
  padding: 28px 16px 18px;
}

.library-head .wrap,
.filters .wrap,
.library .wrap,
.page-foot .wrap {
  width: min(1366px, 100%);
  margin: 0 auto;
}

.library-head h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--white);
}

.library-head .count {
  margin: 8px 0 0;
  color: var(--white);
  font-size: 16px;
  font-weight: 500;
}

.filters {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search {
  flex: 1 1 240px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--chip-line);
  border-radius: 10px;
  background: #111;
  color: var(--white);
  font: inherit;
  font-size: 15px;
}

.search::placeholder { color: var(--muted); }
.search:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.chip-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip,
.sort-btn,
.sheet-open,
.clear-all,
.empty button {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--chip-line);
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active,
.sort-btn.active {
  background: var(--orange);
  color: #0B0B0B;
  border-color: var(--orange);
}

.sort {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.clear-all {
  border: 0;
  height: auto;
  padding: 0;
  color: var(--orange);
  text-decoration: underline;
  background: none;
}

.sheet-open { display: none; }

.library {
  flex: 1;
  padding: 24px 16px 48px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--orange);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  outline: none;
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #111;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
}

.card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.ep-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(247, 147, 26, 0.12);
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
}

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

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.dl,
.copy-link,
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--chip-line);
  background: transparent;
  color: var(--white);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.dl[aria-disabled="true"],
.dl.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.dl:hover,
.copy-link:hover,
.icon-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.empty {
  display: none;
  text-align: center;
  padding: 64px 16px;
}

.empty.show { display: block; }

.empty h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 700;
}

.empty button {
  background: var(--orange);
  color: #0B0B0B;
  border-color: var(--orange);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(0, 0, 0, 0.86);
  padding: 24px;
}

.lightbox.open { display: flex; }

.lightbox-card {
  position: relative;
  width: min(1100px, 100%);
  max-height: 100%;
  margin: auto;
  overflow: auto;
  background: #111;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.lightbox-img-wrap {
  position: relative;
  background: #0B0B0B;
  border-radius: 10px;
  min-height: 200px;
}

.lightbox-img-wrap img {
  display: block;
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  margin: 0 auto;
}

.ratio-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.lightbox-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.lightbox h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.chart-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
}

.chart-id code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #ddd;
  background: #0B0B0B;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}

.nav-arrow,
.lb-close {
  position: absolute;
  top: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--chip-line);
  background: #0B0B0B;
  color: var(--white);
  font-size: 22px;
  cursor: pointer;
}

.lb-close { right: 16px; }
.nav-arrow.prev { left: 16px; top: 40%; }
.nav-arrow.next { right: 16px; top: 40%; }

.nav-arrow:hover,
.lb-close:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.sheet {
  display: none;
}

.page-foot {
  padding: 20px 16px 28px;
  color: #777;
  font-size: 13px;
  text-align: center;
}

.page-foot p { margin: 0 0 8px; }
.page-foot a { color: #F7931A; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 768px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .library-head,
  .filters,
  .library { padding-left: 24px; padding-right: 24px; }
}

@media (min-width: 1366px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 767px) {
  .library-head h1 { font-size: 28px; }
  .chip-groups { display: none; }
  .sheet-open { display: inline-flex; align-items: center; }
  .sort { margin-left: 0; }
  .lightbox {
    padding: 0;
    background: var(--bg);
  }
  .lightbox-card {
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    border: 0;
  }
  .nav-arrow { display: none; }
  .sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.55);
  }
  .sheet.open { display: block; }
  .sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    overflow: auto;
    background: #111;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px 24px;
  }
  .sheet .chip-groups { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover,
  .card:focus-visible { transform: none; }
}
