:root {
  color-scheme: dark;
  --surface: #0c0e17;
  --surface-container-lowest: #000000;
  --surface-container-low: #11131d;
  --surface-container: #171924;
  --surface-container-high: #1c1f2b;
  --surface-container-highest: #212433;
  --surface-bright: #282b3a;
  --on-surface: #f0f0fd;
  --on-surface-dim: #a6a8bd;
  --on-surface-faint: #8b8ea6;
  --primary: #81ecff;
  --primary-dim: #00d4ec;
  --on-primary: #04222b;
  --primary-gradient: linear-gradient(135deg, var(--primary), var(--primary-dim));
  --primary-a10: rgba(129, 236, 255, 0.10);
  --live: #75fd00;
  --building: #ffa44c;
  --error: #ff716c;
  --error-a20: rgba(255, 113, 108, 0.20);
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-display-lg: 3.5rem;
  --text-display: 2.25rem;
  --text-h3: 1.125rem;
  --text-body: 0.9375rem;
  --text-body-sm: 0.8125rem;
  --text-label: 0.75rem;
  --text-label-sm: 0.6875rem;
  --space-1: 0.25rem;
  --space-2: 0.4rem;
  --space-3: 0.65rem;
  --space-4: 0.9rem;
  --space-5: 1.35rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --radius-sm: 0.125rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.75rem;
  --ghost-border: 1px solid rgba(70, 71, 82, 0.15);
  --ghost-border-primary: 1px solid rgba(129, 236, 255, 0.20);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface); }
body { min-height: 100vh; margin: 0; background: var(--surface); color: var(--on-surface); font-family: var(--font-body); font-size: var(--text-body); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dim); }
button, input, select { font: inherit; }
code, pre, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.faint { color: var(--on-surface-faint); }
.label { color: var(--on-surface-faint); font-size: var(--text-label-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.nav { display: flex; align-items: center; gap: var(--space-5); min-height: 52px; padding: 0 var(--space-5); background: var(--surface-container-low); }
.nav-brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--on-surface); font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.nav-brand .mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--primary-gradient); color: var(--on-primary); font-size: 13px; font-weight: 800; box-shadow: 0 0 18px rgba(129, 236, 255, 0.35); }
.nav-brand .sub { color: var(--on-surface-faint); font-size: var(--text-label); font-weight: 500; }
.nav-links { display: flex; gap: var(--space-1); margin-left: var(--space-4); }
.nav-link { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); color: var(--on-surface-dim); font-size: var(--text-body-sm); font-weight: 500; }
.nav-link:hover { background: var(--surface-bright); color: var(--on-surface); }
.nav-link.active { background: var(--primary-a10); color: var(--primary); }
.nav-spacer { flex: 1 1 auto; }

.chip { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-label); font-weight: 600; letter-spacing: 0.02em; }
.chip-idle { color: var(--on-surface-faint); border: var(--ghost-border); }
.chip-primary { color: var(--primary); border: var(--ghost-border-primary); }

.page { width: min(1120px, calc(100% - 2 * var(--space-5))); min-height: calc(100vh - 130px); margin: 0 auto; }
.catalog-hero { position: relative; padding: clamp(3.5rem, 10vh, 7rem) 0 var(--space-7); overflow: hidden; }
.catalog-hero::before { position: absolute; z-index: -1; top: -70%; left: 30%; width: 760px; height: 760px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 212, 236, 0.14), transparent 70%); content: ""; }
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); padding: var(--space-1) var(--space-3); border: var(--ghost-border-primary); border-radius: var(--radius-sm); color: var(--primary); font-size: var(--text-label-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); }
.catalog-hero h1 { max-width: 18ch; font-size: clamp(2.5rem, 6vw, var(--text-display-lg)); letter-spacing: -0.035em; }
.grad { background: var(--primary-gradient); color: transparent; background-clip: text; -webkit-background-clip: text; }
.catalog-hero p { max-width: 60ch; margin: var(--space-5) 0 0; color: var(--on-surface-dim); font-size: 1.08rem; }

.search { display: flex; width: min(680px, 100%); margin-top: var(--space-6); padding: var(--space-2); border-radius: var(--radius-md); background: var(--surface-container-lowest); box-shadow: 0 0 0 1px rgba(129, 236, 255, 0.08), 0 18px 70px rgba(0, 0, 0, 0.28); }
.search input { flex: 1 1 auto; min-width: 0; padding: 0 var(--space-3); border: 0; background: transparent; color: var(--on-surface); }
.search input::placeholder { color: var(--on-surface-faint); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-md); cursor: pointer; color: inherit; font-size: var(--text-body-sm); font-weight: 600; }
.btn-primary { background: var(--primary-gradient); color: var(--on-primary); box-shadow: 0 6px 20px rgba(0, 212, 236, 0.18); }
.btn-primary:hover { color: var(--on-primary); filter: brightness(1.08); }
.btn-secondary { background: var(--surface-container-highest); color: var(--on-surface); border: var(--ghost-border-primary); }
.btn-secondary:hover { background: var(--surface-bright); color: var(--on-surface); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-a10); }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-4); }
.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: var(--space-4); padding-bottom: var(--space-7); }
.package-card { display: flex; min-height: 175px; padding: var(--space-5); flex-direction: column; border-radius: var(--radius-lg); background: var(--surface-container-highest); color: inherit; transition: background 140ms ease, transform 140ms ease; }
.package-card:hover { background: var(--surface-bright); color: inherit; transform: translateY(-2px); }
.package-card .chip { align-self: flex-start; }
.package-card h2 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-h3); overflow-wrap: anywhere; }
.package-card .meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: auto; color: var(--on-surface-faint); font-size: var(--text-label); }
.owner { color: var(--on-surface-dim); }
.loading, .empty, .error-state { grid-column: 1 / -1; padding: var(--space-6); border-radius: var(--radius-md); background: var(--surface-container-low); color: var(--on-surface-dim); }
.error-state { color: var(--error); border: 1px solid var(--error-a20); }
.load-more { grid-column: 1 / -1; justify-self: start; margin-top: var(--space-2); }

#package-view { padding: var(--space-7) 0; }
.package-head { position: relative; padding: var(--space-6); border-radius: var(--radius-lg); background: var(--surface-container); overflow: hidden; }
.package-head::after { position: absolute; top: -190px; right: -170px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 212, 236, 0.12), transparent 70%); content: ""; pointer-events: none; }
.package-breadcrumb { margin-bottom: var(--space-5); font-size: var(--text-body-sm); }
.package-title-row { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); }
.package-title h1 { font-size: clamp(2rem, 6vw, var(--text-display)); overflow-wrap: anywhere; }
.package-title .facts { display: flex; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; }
.package-published { margin-top: var(--space-3); color: var(--on-surface-faint); font-size: var(--text-body-sm); }
.version-picker { display: flex; align-items: center; gap: var(--space-2); }
select { min-height: 34px; padding: var(--space-2) var(--space-3); border: 0; border-bottom: 2px solid transparent; border-radius: var(--radius-sm); outline: 0; background: var(--surface-container-lowest); color: var(--on-surface); }
select:focus { border-bottom-color: var(--primary); }

.install { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-6); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-container-lowest); }
.install code { min-width: 0; flex: 1 1 auto; color: var(--on-surface); font-size: var(--text-body-sm); overflow-x: auto; white-space: nowrap; }
.install .label { flex: none; }
.copy-confirm { color: var(--live); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-4); margin-top: var(--space-4); align-items: start; }
.panel { border-radius: var(--radius-md); background: var(--surface-container); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: var(--space-3); min-height: 38px; padding: var(--space-2) var(--space-3); background: var(--surface-container-high); }
.panel-head .title { color: var(--on-surface-dim); font-size: var(--text-label); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.panel-head .path { min-width: 0; margin-left: auto; color: var(--on-surface-faint); font-size: var(--text-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-code { min-height: 360px; max-height: 70vh; margin: 0; padding: var(--space-5); background: var(--surface-container-lowest); color: var(--on-surface-dim); font-size: var(--text-body-sm); line-height: 1.65; overflow: auto; tab-size: 4; }
.file-list { padding: var(--space-2) 0; }
.file-button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 0; background: transparent; color: var(--on-surface-dim); cursor: pointer; text-align: left; font-family: var(--font-mono); font-size: var(--text-label); }
.file-button:hover { background: var(--surface-bright); color: var(--on-surface); }
.file-button.active { background: var(--primary-a10); color: var(--primary); }
.file-button span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-size { flex: none; color: var(--on-surface-faint); }
.dependency-list { margin-top: var(--space-4); padding: var(--space-4); }
.dependency-row { display: grid; grid-template-columns: minmax(80px, 0.7fr) minmax(120px, 1fr) auto; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-container-low); font-size: var(--text-body-sm); }
.dependency-row + .dependency-row { margin-top: var(--space-2); }
.dependency-row .range { color: var(--building); }
.empty-dependencies { color: var(--on-surface-faint); font-size: var(--text-body-sm); }

.empty-state { max-width: 600px; margin: 15vh auto; padding: var(--space-7); border-radius: var(--radius-lg); background: var(--surface-container); text-align: center; }
.empty-state h1 { margin: var(--space-3) 0; font-size: var(--text-display); }
.empty-state p { margin: 0 0 var(--space-5); color: var(--on-surface-dim); }
.foot { display: flex; width: min(1120px, calc(100% - 2 * var(--space-5))); min-height: 78px; margin: 0 auto; align-items: center; justify-content: space-between; gap: var(--space-4); color: var(--on-surface-faint); font-size: var(--text-body-sm); }

@media (max-width: 760px) {
  .nav-brand .sub { display: none; }
  .nav { gap: var(--space-3); padding: 0 var(--space-4); }
  .nav-links { margin-left: 0; }
  .page, .foot { width: min(100% - 2 * var(--space-4), 1120px); }
  .catalog-hero { padding-top: var(--space-7); }
  .package-title-row { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .file-panel { grid-row: 1; }
  .dependency-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .install { align-items: stretch; flex-wrap: wrap; }
  .install code { width: 100%; flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
