:root {
  --bg: #ffffff;
  --fg: #1e2129;
  --muted: #5b6170;
  --border: #dfe2e8;
  --surface: #f4f5f8;
  --primary: #1d63ed;
  --primary-soft: rgba(29, 99, 237, 0.1);
  --primary-glow: rgba(29, 99, 237, 0.15);
  --code-bg: #f4f5f8;
  --pre-bg: #0b1220;
  --pre-fg: #e6e9ef;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131a;
    --fg: #e6e9ef;
    --muted: #9aa2b1;
    --border: #2a303b;
    --surface: #1a1f28;
    --primary: #5b8cff;
    --primary-soft: rgba(91, 140, 255, 0.14);
    --primary-glow: rgba(91, 140, 255, 0.2);
    --code-bg: #1a1f28;
    --pre-bg: #080b10;
    --pre-fg: #e6e9ef;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f131a;
  --fg: #e6e9ef;
  --muted: #9aa2b1;
  --border: #2a303b;
  --surface: #1a1f28;
  --primary: #5b8cff;
  --primary-soft: rgba(91, 140, 255, 0.14);
  --primary-glow: rgba(91, 140, 255, 0.2);
  --code-bg: #1a1f28;
  --pre-bg: #080b10;
  --pre-fg: #e6e9ef;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  user-select: none;
}

.catalog {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) 1rem 4rem;
}

.loading { color: var(--muted); }

/* Header */
.catalog-header { margin-bottom: 2.5rem; }
.catalog-brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; }
.catalog-brand-logo {
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 0.5rem;
  background: var(--primary); color: #fff; font-size: 1.25rem;
}
.catalog-eyebrow {
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
}
.catalog-title { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; line-height: 1.15; margin: 0 0 0.5rem; }
.catalog-subtitle { color: var(--muted); margin: 0; max-width: 46rem; }
.catalog-subtitle code { font-size: 0.85em; }

/* Grid of blades */
.catalog-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
}
.catalog-card {
  display: flex; align-items: flex-start; gap: 1rem; height: 100%;
  padding: 1.25rem; border: 1px solid var(--border); border-radius: 0.85rem;
  background: var(--bg); color: inherit; text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.catalog-card:hover, .catalog-card:focus-visible {
  border-color: var(--primary); box-shadow: 0 6px 24px var(--primary-glow);
  transform: translateY(-2px); outline: none;
}
.catalog-card-icon {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; border-radius: 0.6rem;
  font-size: 1.75rem; color: var(--primary); background: var(--primary-soft);
}
.catalog-card-body { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; flex: 1 1 0%; }
.catalog-card-title { font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.catalog-card-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.catalog-card-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.catalog-card-arrow { flex: 0 0 auto; align-self: center; color: var(--muted); transition: transform 0.15s; }
.catalog-card:hover .catalog-card-arrow, .catalog-card:focus-visible .catalog-card-arrow { transform: translateX(3px); color: var(--primary); }

.catalog-chip {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font-size: 0.72rem; font-weight: 500; padding: 0.15rem 0.55rem;
  border-radius: 999px; background: var(--surface); color: var(--muted);
}
.catalog-chip .material-symbols-outlined { font-size: 0.85rem; }
.catalog-chip-primary { color: var(--primary); background: var(--primary-soft); }

.catalog-footer { margin-top: 3rem; color: var(--muted); font-size: 0.82rem; }

/* Kit page */
.kit-back {
  display: inline-flex; align-items: center; gap: 0.3rem; margin-bottom: 1.5rem;
  color: var(--muted); text-decoration: none; font-size: 0.88rem; font-weight: 500;
}
.kit-back:hover { color: var(--primary); }
.kit-back .material-symbols-outlined { font-size: 1.1rem; }

.kit-header { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.75rem; }
.kit-header .catalog-card-icon { width: 3.25rem; height: 3.25rem; font-size: 2rem; }
.kit-header-body { min-width: 0; flex: 1; }
.kit-header h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); line-height: 1.2; margin: 0 0 0.5rem; }
.kit-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.pull {
  display: flex; align-items: center; gap: 0.5rem; max-width: 100%;
  padding: 0.35rem 0.4rem 0.35rem 0.75rem; border: 1px solid var(--border); border-radius: 0.6rem;
  background: var(--surface); font: 0.8rem/1.4 "JetBrains Mono", ui-monospace, monospace;
}
.pull code { overflow-x: auto; white-space: nowrap; background: none; padding: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: 0.5rem;
  background: var(--bg); color: var(--fg); font: 500 0.8rem/1.4 Inter, sans-serif;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn .material-symbols-outlined { font-size: 1rem; }

/* Rendered README */
.markdown { border-top: 1px solid var(--border); padding-top: 1.5rem; overflow-wrap: anywhere; }
.markdown > h1:first-child { display: none; }
.markdown > h1:first-child + p:has(> code:only-child) { display: none; }
.markdown h2 { font-size: 1.35rem; margin: 2.25rem 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 1rem; }
.markdown li + li { margin-top: 0.25rem; }
.markdown code {
  font: 0.86em "JetBrains Mono", ui-monospace, monospace;
  background: var(--code-bg); padding: 0.12em 0.4em; border-radius: 0.35rem;
}
.markdown .code-block { position: relative; margin: 0 0 1rem; }
.markdown pre {
  margin: 0; padding: 1rem 3rem 1rem 1rem; overflow-x: auto;
  background: var(--pre-bg); color: var(--pre-fg); border-radius: 0.6rem;
}
.markdown pre code { background: none; padding: 0; font-size: 0.82rem; line-height: 1.6; color: inherit; }
.copy {
  position: absolute; top: 0.5rem; right: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.06); color: #c9d1e0; cursor: pointer;
}
.copy:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.copy .material-symbols-outlined { font-size: 1.05rem; }
.markdown .table-wrap { overflow-x: auto; margin: 0 0 1rem; }
.markdown table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.markdown th, .markdown td { text-align: left; vertical-align: top; padding: 0.5rem 0.75rem; border: 1px solid var(--border); }
.markdown th { background: var(--surface); font-weight: 600; }
.markdown blockquote { margin: 0 0 1rem; padding: 0.25rem 1rem; border-left: 3px solid var(--primary); color: var(--muted); }

.error { color: var(--muted); }

/* Comparison page */
.markdown.page > h1:first-child { display: block; }
.cmp-stats {
  display: grid; gap: 0.75rem; margin: 0 0 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}
.cmp-stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  padding: 1rem; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--bg);
}
.cmp-stat .material-symbols-outlined { font-size: 1rem; color: var(--muted); }
.cmp-stat-before { color: var(--muted); font-size: 0.85rem; text-decoration: line-through; text-decoration-color: var(--border); }
.cmp-stat-after { font-weight: 700; font-size: 1.2rem; line-height: 1.25; color: var(--primary); }
.cmp-stat-label { color: var(--muted); font-size: 0.78rem; line-height: 1.4; margin-top: 0.2rem; }

.cmp-columns {
  display: grid; gap: 1rem; margin: 0 0 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
.cmp-col { padding: 1.25rem; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--surface); }
.cmp-col-after { border-color: var(--primary); background: var(--bg); box-shadow: 0 6px 24px var(--primary-glow); }
.cmp-col-eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.cmp-col-after .cmp-col-eyebrow { color: var(--primary); }
.markdown .cmp-col h2 { border: 0; padding: 0; margin: 0.35rem 0 0.6rem; font-size: 1.25rem; }
.markdown .cmp-col h2 code { font-size: 0.95em; }
.cmp-col p { font-size: 0.9rem; }
.cmp-col ul { font-size: 0.88rem; padding-left: 1.1rem; margin: 0; }

.markdown tbody th { background: none; white-space: nowrap; }
.markdown td:last-child { background: var(--primary-soft); }

.cmp-fates { list-style: none; padding: 0; display: grid; gap: 0.6rem; }
.markdown .cmp-fates li + li { margin-top: 0; }
.cmp-fates li {
  display: flex; gap: 0.85rem; align-items: flex-start;
  padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: 0.75rem; font-size: 0.9rem;
}
.cmp-fates strong { display: block; margin-bottom: 0.15rem; }
.cmp-fate {
  flex: 0 0 6.5rem; display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
}
.cmp-fate .material-symbols-outlined { font-size: 0.9rem; }
.cmp-fate-removed { color: #c0392b; background: rgba(192, 57, 43, 0.1); }
.cmp-fate-replaced { color: #b7791f; background: rgba(183, 121, 31, 0.12); }
.cmp-fate-kept { color: #2d9568; background: rgba(45, 149, 104, 0.12); }

.cmp-tradeoffs li { margin-bottom: 0.4rem; }

/* Component diagrams (inline SVG, colors from the theme tokens) */
:root {
  --dg-removed: #c0392b;
  --dg-removed-bg: rgba(192, 57, 43, 0.07);
  --dg-replaced: #b7791f;
  --dg-replaced-bg: rgba(183, 121, 31, 0.08);
  --dg-kept: #2d9568;
  --dg-kept-bg: rgba(45, 149, 104, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dg-removed: #ff8a7a; --dg-removed-bg: rgba(255, 138, 122, 0.08);
    --dg-replaced: #f2c46d; --dg-replaced-bg: rgba(242, 196, 109, 0.08);
    --dg-kept: #6fd3a5; --dg-kept-bg: rgba(111, 211, 165, 0.08);
  }
}
:root[data-theme="dark"] {
  --dg-removed: #ff8a7a; --dg-removed-bg: rgba(255, 138, 122, 0.08);
  --dg-replaced: #f2c46d; --dg-replaced-bg: rgba(242, 196, 109, 0.08);
  --dg-kept: #6fd3a5; --dg-kept-bg: rgba(111, 211, 165, 0.08);
}

.dg { margin: 0 0 1.75rem; }
.dg figcaption { font-size: 0.92rem; margin-bottom: 0.6rem; }
.dg figcaption .cmp-col-eyebrow { margin-right: 0.35rem; }
.cmp-col-eyebrow-after { color: var(--primary); }
.dg-scroll {
  overflow-x: auto; border: 1px solid var(--border); border-radius: 0.85rem;
  background: var(--surface); padding: 0.75rem;
}
.dg svg { display: block; width: 100%; min-width: 640px; height: auto; font-family: Inter, Helvetica, Arial, sans-serif; }
.dg text { text-anchor: middle; }
.dg .dg-label, .dg .dg-note { text-anchor: start; }

.dg-frame { fill: var(--bg); stroke: var(--border); stroke-width: 1.5; }
.dg-group { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dg-sandbox { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 2; }
.dg-actor { fill: var(--bg); stroke: var(--primary); stroke-width: 1.5; }
.dg-box { fill: var(--bg); stroke: var(--border); stroke-width: 1.5; }
.dg-primary { stroke: var(--primary); }
.dg-dashed { stroke-dasharray: 5 4; stroke: var(--muted); fill: transparent; }
.dg-kept { stroke: var(--dg-kept); fill: var(--dg-kept-bg); }
.dg-removed { stroke: var(--dg-removed); fill: var(--dg-removed-bg); stroke-dasharray: 6 4; }
.dg-replaced { stroke: var(--dg-replaced); fill: var(--dg-replaced-bg); stroke-dasharray: 6 4; }
.dg-warn { stroke: var(--dg-removed); fill: var(--bg); }

.dg-title { fill: var(--fg); font-size: 13px; font-weight: 600; }
.dg-sub { fill: var(--muted); font-size: 11px; }
.dg-label { fill: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.dg-label-primary { fill: var(--primary); }
.dg-note { fill: var(--muted); font-size: 11px; font-style: italic; }
.dg-line { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.dg-head { fill: var(--muted); }

.dg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.9rem; margin: 0.6rem 0 0; color: var(--muted); font-size: 0.78rem; }
.dg-key { display: inline-block; width: 1.1rem; height: 0.7rem; margin-right: 0.35rem; vertical-align: -0.05rem; border-radius: 0.2rem; border: 1.5px solid; }
.dg-key-removed { border-color: var(--dg-removed); border-style: dashed; background: var(--dg-removed-bg); }
.dg-key-replaced { border-color: var(--dg-replaced); border-style: dashed; background: var(--dg-replaced-bg); }
.dg-key-kept { border-color: var(--dg-kept); background: var(--dg-kept-bg); }
.dg-key-primary { border-color: var(--primary); background: var(--bg); }
.dg-key-dashed { border-color: var(--muted); border-style: dashed; }
.cmp-more { color: var(--muted); font-size: 0.88rem; border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 2rem; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cmp-fate-removed { color: #ff8a7a; }
  :root:not([data-theme="light"]) .cmp-fate-replaced { color: #f2c46d; }
  :root:not([data-theme="light"]) .cmp-fate-kept { color: #6fd3a5; }
}
:root[data-theme="dark"] .cmp-fate-removed { color: #ff8a7a; }
:root[data-theme="dark"] .cmp-fate-replaced { color: #f2c46d; }
:root[data-theme="dark"] .cmp-fate-kept { color: #6fd3a5; }

@media (max-width: 560px) {
  .cmp-fates li { flex-direction: column; gap: 0.4rem; }
  .cmp-fate { flex-basis: auto; }
  .markdown tbody th { white-space: normal; }
}

@media (max-width: 560px) {
  .catalog-card-arrow { display: none; }
  .kit-header .catalog-card-icon { display: none; }
}
