/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #f1f2f7;
  --surface: #ffffff;
  --surface-sunken: #f4f5f9;
  --border: #e5e6ee;
  --border-strong: #d8dae6;
  --text: #16162a;
  --text-soft: #4a4d63;
  --muted: #757a8c;
  --brand: #4a2fa6;
  --brand-hover: #3f2790;
  --brand-soft: #efecfa;
  --brand-ink: #4a2fa6;
  --ink: #1b1b2e;
  --amber-bg: #fdf0d5;
  --amber-ink: #96620a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 43, .05);
  --shadow-md: 0 6px 22px -8px rgba(20, 20, 43, .18);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shell: 1360px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* --------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand-mark {
  /* the source PNG carries its own padding, so it needs a slightly larger box
     than a flat 32px mark to read at the same weight as the wordmark */
  width: 210px; height: 38px;
  object-fit: contain;
  display: block;
}
.brand-name { font-weight: 700; font-size: 21px; letter-spacing: -.2px; color: #4f38a2; }
.brand-sub { color: var(--muted); font-size: 17px; }

.search { position: relative; flex: 1 1 auto; max-width: 460px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px;
  fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14.5px;
  color: var(--text);
}
.search input::placeholder { color: #8f93a4; }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

/* ----------------------------------------------------------------- hero */
.hero { background: var(--surface); border-bottom: 1px solid var(--border); }
.hero-inner {
  max-width: var(--shell); margin: 0 auto; padding: 30px 32px 34px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.hero h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: -.5px; }
.hero p { margin: 0; color: var(--muted); font-size: 14.5px; }
.hero-cta { margin-left: auto; }

.btn-dark {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff;
  border: 0; border-radius: 11px; cursor: pointer;
  padding: 14px 22px; font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow-md);
}
.btn-dark:hover { background: #2a2a44; }
.btn-dark .play {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center; flex: none;
}
.btn-dark .play svg { width: 9px; height: 9px; fill: #fff; }
.btn-dark .hint { color: rgba(255, 255, 255, .6); font-weight: 400; font-size: 13.5px; }

/* --------------------------------------------------------------- layout */
.catalog {
  max-width: var(--shell); margin: 0 auto; padding: 30px 32px 72px;
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 44px;
}

.facets { position: sticky; top: 92px; align-self: start; }
.facet-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  margin: 8px 0 12px; padding-left: 12px;
}
.facet {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 0; background: transparent; cursor: pointer; text-align: left;
  padding: 9px 12px; border-radius: 9px;
  font-size: 14.5px; color: var(--text-soft);
}
.facet:hover { background: rgba(74, 47, 166, .05); }
.facet.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.facet-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.facet.is-active .facet-count { color: var(--brand-ink); }

.results-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
.results-title { font-size: 15px; font-weight: 600; color: var(--text-soft); }

.btn-quiet {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 9px 16px; cursor: pointer;
  font-size: 14px; color: var(--text-soft); box-shadow: var(--shadow-sm);
}
.btn-quiet:hover { border-color: #c3c6d6; color: var(--text); }
.btn-quiet[disabled] { opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 24px; }

.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 0;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.card:hover { border-color: #b9a9ec; box-shadow: 0 8px 26px -12px rgba(74, 47, 166, .35); transform: translateY(-1px); }

.card-head { display: flex; gap: 15px; align-items: flex-start; }
.sigil {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; letter-spacing: .4px;
}
.sigil.lg { width: 58px; height: 58px; border-radius: 14px; font-size: 16px; }
.card-title { margin: 0; font-size: 17px; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.slug { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.card-desc {
  margin: 15px 0 20px; color: var(--text-soft); font-size: 14.5px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  overflow: hidden;
}

.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  background: var(--amber-bg); color: var(--amber-ink);
  padding: 3px 8px; border-radius: 5px;
}

.card-foot {
  margin-top: auto; border-top: 1px solid var(--border);
  padding: 14px 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.chip {
  background: var(--surface-sunken); color: var(--text-soft);
  border-radius: 6px; padding: 4px 10px; font-size: 13px;
}
.version { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.metric {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums;
}
.metric svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.empty {
  grid-column: 1 / -1;
  background: var(--surface); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); padding: 56px 24px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 16px; }

.loading { padding: 80px 32px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------------- detail */
.detail { max-width: var(--shell); margin: 0 auto; padding: 26px 32px 80px; }
.back {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-soft); font-size: 14.5px; padding: 6px 0 0; margin-bottom: 20px;
}
.back:hover { color: var(--brand); }
.back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 26px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 30px; box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.panel:last-child { margin-bottom: 0; }
.panel > h2 { margin: 0; font-size: 18px; letter-spacing: -.2px; }
.panel-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.panel-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.panel-head h1 { margin: 0 0 4px; font-size: 27px; letter-spacing: -.5px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-desc { margin: 0; color: var(--text-soft); font-size: 15.5px; line-height: 1.65; }

.triggers { display: grid; gap: 12px; margin-top: 18px; }
.trigger {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-sunken); border-radius: var(--radius-sm);
  padding: 13px 18px; color: var(--text-soft); font-size: 14.5px;
}
.trigger svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.prompts { display: grid; gap: 12px; margin-top: 18px; }
.prompt {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-sunken); border-radius: var(--radius-sm);
  padding: 11px 11px 11px 18px;
}
.prompt code { font-family: var(--mono); font-size: 13.5px; color: var(--text-soft); flex: 1; word-break: break-word; }
.btn-copy {
  flex: none; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 6px 14px; cursor: pointer; font-size: 13.5px; color: var(--text-soft);
}
.btn-copy:hover { border-color: #c3c6d6; color: var(--text); }

.changelog { margin-top: 8px; }
.change-row {
  display: grid; grid-template-columns: 90px 110px minmax(0, 1fr);
  gap: 18px; align-items: baseline;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.change-row:last-child { border-bottom: 0; padding-bottom: 0; }
.change-row .v { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.change-row .d { color: var(--muted); font-size: 13.5px; }
.change-row .n { color: var(--text-soft); font-size: 14.5px; }

/* ------------------------------------------------------------- sidecard */
.side { position: sticky; top: 92px; }
.btn-primary {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 15px 20px; cursor: pointer; font-size: 15.5px; font-weight: 600;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.meta-list { margin: 22px 0 0; padding: 22px 0 0; border-top: 1px solid var(--border); display: grid; gap: 14px; }
.meta-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.meta-row dt { color: var(--muted); font-size: 14.5px; }
.meta-row dd { margin: 0; font-weight: 600; font-size: 14.5px; text-align: right; }
.meta-row dd .unit { color: var(--muted); font-weight: 400; margin-left: 4px; }

.requires { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 11px; }
.requires li { position: relative; padding-left: 18px; color: var(--text-soft); font-size: 14.5px; }
.requires li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 6px; border-radius: 50%; background: #a596e0;
}

/* ------------------------------------------------------------ file view */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 22px; }
.tab {
  border: 1px solid transparent; background: var(--surface-sunken);
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
  font-family: var(--mono); font-size: 13px; color: var(--text-soft);
}
.tab:hover { border-color: var(--border-strong); }
.tab.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.md { color: var(--text-soft); font-size: 14.8px; line-height: 1.7; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); line-height: 1.35; margin: 1.7em 0 .6em; letter-spacing: -.2px; }
.md h1 { font-size: 22px; }
.md h2 { font-size: 18.5px; padding-top: .5em; border-top: 1px solid var(--border); }
.md h3 { font-size: 16px; }
.md h4 { font-size: 14.8px; }
.md p { margin: 0 0 1em; }
.md ul, .md ol { margin: 0 0 1em; padding-left: 1.35em; }
.md li { margin: .35em 0; }
.md a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.md strong { color: var(--text); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.8em 0; }
.md blockquote {
  margin: 0 0 1em; padding: 2px 0 2px 18px;
  border-left: 3px solid #cfc6ef; color: var(--muted);
}
.md code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: 5px; padding: 1.5px 5px;
}
.md pre {
  background: #1b1b2e; color: #e8e6f5;
  border-radius: 10px; padding: 16px 18px; overflow-x: auto; margin: 0 0 1.2em;
}
.md pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 13px; line-height: 1.6; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 1.2em; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 9px 13px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-sunken); color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 14px);
  background: var(--ink); color: #fff; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ----------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .detail-grid > .side { order: -1; }
}

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; gap: 14px; padding: 12px 20px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .hero-inner, .catalog, .detail { padding-left: 20px; padding-right: 20px; }
  .catalog { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .facets { position: static; }
  .facet-label { padding-left: 0; }
  .facet-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .facet-strip .facet {
    width: auto; flex: none; background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
  }
  .facet-strip .facet.is-active { background: var(--brand-soft); border-color: #cdc2f0; }
  .hero-cta { margin-left: 0; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 22px 20px; }
  .change-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
