:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --background: #09090b;
  --surface: #111113;
  --surface-raised: #18181b;
  --border: #2b2b30;
  --border-strong: #414148;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --accent: #2dd4bf;
  --warning: #fbbf24;
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { min-width: 320px; margin: 0; background: var(--background); }
button, input, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
a { color: inherit; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: #0c0c0e;
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-raised);
  font-size: 13px;
  font-weight: 700;
}
.brand > span:last-child { display: grid; gap: 0; }
.brand strong { font-size: 13px; line-height: 1.25; }
.brand small { color: var(--subtle); font-size: 10px; line-height: 1.35; }
.provider-link, .text-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.provider-link:hover, .text-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.primary-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 44px;
  padding: 0 24px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.96);
  backdrop-filter: blur(10px);
}
.primary-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 13px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.primary-nav a:hover { color: var(--text); }
.primary-nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); }
.primary-nav small { color: var(--subtle); font-size: 10px; }

main { padding: 20px 24px 40px; }
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  min-height: 78px;
  margin-bottom: 16px;
}
.eyebrow, .field > span, .detail-label, .detail-grid dt, .index-status > span {
  margin: 0;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
}
.page-heading h1 { margin: 2px 0 0; font-size: 21px; line-height: 1.25; }
.page-heading > div > p:last-child { max-width: 720px; margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.index-status {
  display: grid;
  min-width: 168px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.index-status strong { margin-top: 2px; font-size: 16px; }
.index-status small { color: var(--muted); font-size: 10px; }

.filter-bar {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) minmax(145px, 0.7fr) minmax(160px, 0.8fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.field { display: grid; gap: 5px; min-width: 0; }
.mobile-category { display: none; }
input, select {
  width: 100%;
  height: 36px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #35353a;
  border-radius: 5px;
  outline: none;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 13px;
}
input::placeholder { color: #686872; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid rgba(45, 212, 191, 0.8);
  outline-offset: 2px;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 20px;
  margin-top: 18px;
}
.category-rail {
  position: sticky;
  top: 58px;
  align-self: start;
  min-width: 0;
  max-height: calc(100vh - 76px);
  padding-right: 18px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  scrollbar-color: #3f3f46 transparent;
  scrollbar-width: thin;
}
.rail-heading { display: flex; align-items: center; justify-content: space-between; min-height: 38px; }
.rail-heading strong { font-size: 12px; }
.rail-heading button {
  border: 0;
  color: var(--subtle);
  background: transparent;
  font-size: 11px;
}
.rail-heading button:hover { color: var(--text); }
#category-list { display: grid; gap: 2px; }
#category-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 31px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  text-align: left;
}
#category-list button:hover { color: var(--text); background: var(--surface); }
#category-list button[aria-pressed="true"] { color: var(--text); background: var(--surface-raised); }
#category-list small { color: var(--subtle); font-size: 10px; }

.results { min-width: 0; }
.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  gap: 20px;
}
.result-heading strong { font-size: 13px; }
.result-heading span { margin-left: 7px; color: var(--muted); font-size: 11px; }
.result-heading p { margin: 0; color: var(--subtle); font-size: 10px; text-align: right; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.catalog-card {
  display: grid;
  grid-template-rows: 164px minmax(188px, auto);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.catalog-card:hover { border-color: var(--border-strong); }
.card-preview {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  border-bottom: 1px solid var(--border);
  background: #0d0d0f;
}
.card-preview img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 160ms ease; }
.card-preview:hover img { transform: scale(1.012); }
.preview-placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: #5d5d66; font-size: 11px; }
.access-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #d4d4d8;
  background: rgba(9, 9, 11, 0.88);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.access-free { border-color: rgba(45, 212, 191, 0.38); color: #5eead4; }
.access-pro, .access-premium, .access-elite { border-color: rgba(251, 191, 36, 0.38); color: var(--warning); }
.card-body { display: flex; min-width: 0; flex-direction: column; padding: 12px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--subtle); font-size: 10px; }
.card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body h2 { margin: 7px 0 0; overflow: hidden; font-size: 14px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.card-body > p {
  display: -webkit-box;
  margin: 4px 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--text);
  background: #232327;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.button:hover { border-color: #5b5b64; background: #2b2b30; }
.button.secondary { background: #151517; }
.button:disabled { cursor: not-allowed; opacity: 0.42; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.pagination[hidden] { display: none; }
.pagination strong { font-size: 12px; }
.pagination span { margin-left: 7px; color: var(--muted); font-size: 11px; }
.pagination-actions { display: flex; gap: 8px; }

.empty-state {
  grid-column: 1 / -1;
  padding: 52px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { font-size: 14px; }
.empty-state span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.empty-state .button { margin-top: 14px; }

dialog {
  width: min(960px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  background: #0d0d0f;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.76); }
.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  color: var(--muted);
  background: rgba(9, 9, 11, 0.82);
  font-size: 22px;
}
.dialog-close:hover { color: var(--text); }
.detail-preview { display: grid; width: 100%; height: 340px; place-items: center; overflow: hidden; border-bottom: 1px solid var(--border); background: #09090b; }
.detail-preview img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.detail-body { padding: 20px; }
.detail-body h2 { max-width: calc(100% - 40px); margin: 2px 0 0; font-size: 20px; line-height: 1.3; }
.detail-description { max-width: 760px; margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 18px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.detail-grid > div { min-width: 0; padding: 11px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.detail-grid > div:nth-child(3n) { border-right: 0; }
.detail-grid > div:nth-last-child(-n + 3) { border-bottom: 0; }
.detail-grid dt, .detail-grid dd { margin: 0; }
.detail-grid dd { margin-top: 3px; overflow-wrap: anywhere; font-size: 12px; font-weight: 600; }
.command-section { display: grid; gap: 6px; }
.command-section code { padding: 10px; overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; color: #d4d4d8; background: #08080a; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.detail-note { display: grid; gap: 1px; margin-top: 12px; padding-left: 10px; border-left: 2px solid var(--warning); }
.detail-note strong { font-size: 12px; }
.detail-note span { color: var(--muted); font-size: 11px; }
.detail-actions { display: flex; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -12px);
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  opacity: 0;
  color: var(--text);
  background: #17171a;
  font-size: 12px;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

.loading-card .card-preview, .loading-card span, .loading-card strong, .loading-card p {
  background: #242429;
  animation: pulse 1.3s ease-in-out infinite;
}
.loading-card .card-body span { width: 42%; height: 9px; border-radius: 3px; }
.loading-card .card-body strong { width: 70%; height: 14px; margin-top: 12px; border-radius: 3px; }
.loading-card .card-body p { width: 92%; height: 34px; margin-top: 10px; border-radius: 3px; }
@keyframes pulse { 50% { opacity: 0.55; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (max-width: 980px) {
  .filter-bar { grid-template-columns: minmax(250px, 1.5fr) repeat(3, minmax(130px, 0.7fr)); }
  .mobile-category { display: grid; }
  .catalog-layout { grid-template-columns: 1fr; }
  .category-rail { display: none; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-header, .primary-nav { padding-inline: 12px; }
  .provider-link { font-size: 0; }
  .provider-link span { font-size: 13px; }
  main { padding: 14px 12px 28px; }
  .page-heading { align-items: start; flex-direction: column; gap: 12px; }
  .index-status { width: 100%; padding: 8px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .catalog-grid { grid-template-columns: 1fr; }
  .catalog-card { grid-template-rows: 190px minmax(174px, auto); }
  .result-heading { align-items: start; flex-direction: column; gap: 2px; padding-bottom: 8px; }
  .result-heading p { text-align: left; }
  dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .detail-preview { height: 230px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid > div:nth-child(3n) { border-right: 1px solid var(--border); }
  .detail-grid > div:nth-child(2n) { border-right: 0; }
  .detail-grid > div:nth-last-child(-n + 3) { border-bottom: 1px solid var(--border); }
  .detail-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .detail-actions { align-items: stretch; flex-direction: column; }
}

@media (max-width: 420px) {
  .filter-bar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid > div { border-right: 0 !important; border-bottom: 1px solid var(--border) !important; }
  .detail-grid > div:last-child { border-bottom: 0 !important; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 8px; padding-block: 10px; }
}
