:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #f3f3f6;
  --border: #e5e6eb;
  --border-strong: #d4d5dc;
  --text: #15161a;
  --muted: #61636f;
  --faint: #8d8f9b;
  --accent: #ff9d00;
  --accent-strong: #d97a00;
  --accent-soft: #fff4e2;
  --accent-text: #8a4b00;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fff8db;
  --live: #cf222e;
  --live-soft: #ffebe9;
  --term-bg: #0f1116;
  --term-bar: #171a21;
  --term-border: #262a33;
  --term-text: #e6e7ee;
  --shadow: 0 1px 2px rgba(16, 17, 20, 0.04), 0 4px 16px rgba(16, 17, 20, 0.04);
  --shadow-hover: 0 2px 4px rgba(16, 17, 20, 0.06), 0 10px 28px rgba(16, 17, 20, 0.08);
  --radius: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f;
    --bg-soft: #111217;
    --surface: #14161b;
    --surface-2: #1b1d24;
    --border: #252830;
    --border-strong: #343844;
    --text: #ececf1;
    --muted: #a0a2b0;
    --faint: #737584;
    --accent: #ffad33;
    --accent-strong: #ffc266;
    --accent-soft: rgba(255, 157, 0, 0.12);
    --accent-text: #ffc266;
    --ok: #4ac26b;
    --ok-soft: rgba(74, 194, 107, 0.12);
    --warn: #e3b341;
    --warn-soft: rgba(227, 179, 65, 0.12);
    --live: #ff7b72;
    --live-soft: rgba(255, 123, 114, 0.12);
    --term-bg: #090a0d;
    --term-bar: #121419;
    --term-border: #252830;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --bg-soft: #111217;
  --surface: #14161b;
  --surface-2: #1b1d24;
  --border: #252830;
  --border-strong: #343844;
  --text: #ececf1;
  --muted: #a0a2b0;
  --faint: #737584;
  --accent: #ffad33;
  --accent-strong: #ffc266;
  --accent-soft: rgba(255, 157, 0, 0.12);
  --accent-text: #ffc266;
  --ok: #4ac26b;
  --ok-soft: rgba(74, 194, 107, 0.12);
  --warn: #e3b341;
  --warn-soft: rgba(227, 179, 65, 0.12);
  --live: #ff7b72;
  --live-soft: rgba(255, 123, 114, 0.12);
  --term-bg: #090a0d;
  --term-bar: #121419;
  --term-border: #252830;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.prose a,
.lede a,
.hero-sub a,
.builder-note a,
.section p a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.86em;
}

:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.35em;
}

kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  margin-right: 2px;
  border-radius: 8px;
  display: block;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.brand-slash {
  color: var(--faint);
  font-weight: 400;
}

.brand-sub {
  font-weight: 600;
  color: var(--text);
}

.search-trigger {
  flex: 1;
  max-width: 440px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--faint);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.search-trigger:hover {
  border-color: var(--border-strong);
}

.search-trigger svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.search-placeholder {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}

.topnav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: block;
  }
}

/* ---------- page frame ---------- */

.app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px 64px;
  min-height: calc(100vh - 160px);
}

.loading,
.empty {
  color: var(--muted);
  padding: 48px 0;
}

.hero {
  padding: 72px 0 40px;
  max-width: 760px;
}

.hero h1,
.page-head h1 {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
}

.lede {
  font-size: 18px;
  color: var(--text);
  margin: 0 0 10px;
}

.hero-sub {
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 680px;
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  height: 52px;
  padding: 0 14px 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--faint);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.hero-search:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.hero-search svg {
  width: 18px;
  height: 18px;
}

.hero-search span {
  flex: 1;
  text-align: left;
}

.stats {
  display: flex;
  gap: 22px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 14px;
}

.stats b {
  color: var(--text);
  font-weight: 600;
}

.page-head {
  padding: 56px 0 24px;
}

.section {
  padding: 28px 0 8px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2,
.section-title {
  font-size: 20px;
  letter-spacing: -0.015em;
  margin: 0 0 16px;
}

.section-head h2 {
  margin: 0;
}

.section-head small {
  font-size: 13px;
  font-weight: 500;
  color: var(--faint);
  margin-left: 8px;
}

.more {
  color: var(--accent-text);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
}

.sub-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin: 22px 0 10px;
}

/* ---------- trainers ---------- */

.trainer-block {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
  margin-bottom: 18px;
}

.page-head + .section .trainer-block {
  padding: 0;
  border: 0;
  background: none;
}

.trainer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.trainer-name {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
  color: var(--accent-text);
}

.trainer-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.trainer-blurb {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  max-width: 720px;
}

.trainer-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  font-size: 13.5px;
  color: var(--faint);
}

.mono-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(28px, 4.4vw, 44px) !important;
  letter-spacing: -0.02em !important;
}

.page-head .actions {
  margin-top: 18px;
}

/* ---------- cards and tiles ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.grid-narrow {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card,
.tile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.card:hover,
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.card[hidden] {
  display: none;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-title strong {
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title span {
  font-size: 13px;
  color: var(--faint);
}

.card-desc,
.tile-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot,
.tile-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  font-size: 13px;
}

.card-project {
  color: var(--faint);
}

.tile-kicker {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-text);
}

.tile-title {
  font-size: 18px;
  letter-spacing: -0.015em;
}

.tile-count {
  color: var(--accent-text);
  font-weight: 500;
}

.avatar {
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.avatar-xs {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.avatar-md {
  width: 40px;
  height: 40px;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 14px;
}

.avatar-letter {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
}

.avatar-stack {
  display: flex;
}

.avatar-stack .avatar {
  margin-right: -6px;
  box-shadow: 0 0 0 2px var(--surface);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chip-mono {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.chip-soft {
  background: transparent;
}

.pbadges {
  display: flex;
  gap: 6px;
}

.pbadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--faint);
}

.pbadge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--faint);
}

.pbadge.is-verified {
  color: var(--ok);
}

.pbadge.is-verified i {
  background: var(--ok);
  border-color: var(--ok);
}

/* ---------- browse ---------- */

.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  margin-bottom: 18px;
}

.filter-search {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  max-width: 420px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-label {
  width: 80px;
  font-size: 13px;
  color: var(--faint);
  font-weight: 500;
}

.result-count {
  color: var(--faint);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- pills / segmented controls ---------- */

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.pill:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
}

.pill.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.pill:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pill:focus-visible,
.btn:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- three-column layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 190px;
  gap: 40px;
  padding-top: 28px;
}

.sidebar-inner,
.toc-inner {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-title,
.toc-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  font-weight: 600;
  margin-bottom: 10px;
}

.tree-trainer {
  margin-bottom: 14px;
}

.tree-label {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  padding: 4px 8px;
}

.tree-project {
  display: block;
  padding: 5px 8px;
  margin-top: 2px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.tree-models {
  margin: 2px 0 6px 10px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.tree-model {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--muted);
}

.tree-project:hover,
.tree-model:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree-project.is-current,
.tree-model.is-current {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.toc-inner a {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
  font-size: 13.5px;
  color: var(--muted);
}

.toc-inner a:hover {
  color: var(--text);
  border-left-color: var(--accent);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--faint);
  margin-bottom: 18px;
}

.crumbs a:hover {
  color: var(--text);
}

.crumbs .crumb-sep {
  color: var(--border-strong);
}

.recipe-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.recipe-head-body {
  min-width: 0;
}

.recipe-head h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 2px 0 10px;
  overflow-wrap: anywhere;
}

.muted-org {
  color: var(--faint);
  font-weight: 500;
}

.recipe-head .lede {
  font-size: 16px;
  color: var(--muted);
  max-width: 760px;
}

.recipe-head .chips {
  margin: 14px 0 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--text);
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s;
}

.btn:hover {
  opacity: 0.88;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  opacity: 1;
  background: var(--surface-2);
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
}

.btn.is-done {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-soft);
}

.hf {
  font-size: 15px;
}

/* ---------- command builder ---------- */

.builder {
  margin: 28px 0 8px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
}

.builder-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.builder-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.builder-summary {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.is-verified {
  color: var(--ok);
  background: var(--ok-soft);
}

.status.is-untested {
  color: var(--warn);
  background: var(--warn-soft);
}

.status.is-live {
  color: var(--live);
  background: var(--live-soft);
}

.status-sm {
  height: 20px;
  font-size: 11.5px;
  padding: 0 8px;
  margin-left: 6px;
}

.builder-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.brow {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.blabel {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.text-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.text-input:focus,
.filter-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.text-input-sm {
  width: 220px;
  height: 32px;
}

.extras {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}

.inline-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.toggle input:checked + span {
  background: var(--accent);
}

.toggle input:checked + span::after {
  transform: translateX(14px);
}

.toggle input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13.5px;
}

.terminal {
  border: 1px solid var(--term-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--term-bg);
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 6px;
  background: var(--term-bar);
  border-bottom: 1px solid var(--term-border);
}

.tabs {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
}

.tab {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: #9a9cab;
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--term-text);
}

.tab.is-on {
  background: #232731;
  color: var(--term-text);
}

.btn-term {
  background: #232731;
  border-color: #343844;
  color: var(--term-text);
}

.btn-term.is-done {
  background: rgba(74, 194, 107, 0.15);
  border-color: #4ac26b;
  color: #4ac26b;
}

.builder-note {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- code ---------- */

pre.code {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--term-bg);
  color: var(--term-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  border-radius: 10px;
}

.terminal pre.code {
  border-radius: 0;
}

.terminal-code {
  min-height: 92px;
}

.terminal-code.is-script {
  max-height: 520px;
}

pre.code code {
  font-size: inherit;
  background: none;
  border: 0;
  padding: 0;
}

.section pre.code,
.prose pre.code {
  margin: 12px 0;
  border: 1px solid var(--term-border);
}

.hljs-comment,
.hljs-quote {
  color: #7d8293;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: #ff9e64;
}

.hljs-string,
.hljs-attr-value {
  color: #a6da95;
}

.hljs-variable,
.hljs-template-variable,
.hljs-attr,
.hljs-attribute {
  color: #7dcfff;
}

.hljs-number,
.hljs-literal,
.hljs-meta {
  color: #f5bde6;
}

.hljs-title,
.hljs-section,
.hljs-name {
  color: #ffd21e;
}

.hljs-addition {
  color: #a6da95;
  background: rgba(166, 218, 149, 0.08);
}

.hljs-deletion {
  color: #ff7b72;
  background: rgba(255, 123, 114, 0.08);
}

.hljs-subst {
  color: var(--term-text);
}

/* ---------- recipe sections ---------- */

.main > .section {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 28px;
}

.main > .section:first-of-type {
  border-top: 0;
}

.kv {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: -1px;
}

.kv-row:nth-child(odd) {
  background: var(--bg-soft);
}

.kv-key {
  color: var(--muted);
  white-space: nowrap;
}

.kv-key.mono {
  font-size: 12.5px;
}

.kv-val {
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table th,
.table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  background: var(--bg-soft);
  font-weight: 600;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-list a,
.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.file-list a:hover,
.file-btn:hover {
  border-color: var(--accent);
}

.file-list code {
  border: 0;
  background: none;
  padding: 0;
}

.patch {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.patch summary {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-soft);
}

.patch pre.code {
  margin: 0;
  border: 0;
  border-radius: 0;
  max-height: 560px;
}

.recipe-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--faint);
}

.recipe-foot a:hover {
  color: var(--text);
}

/* ---------- markdown ---------- */

.prose {
  font-size: 15px;
  max-width: 820px;
}

.prose h2 {
  font-size: 19px;
  margin: 30px 0 10px;
  letter-spacing: -0.01em;
}

.prose h3 {
  font-size: 16px;
  margin: 24px 0 8px;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 12px;
}

.prose li {
  margin: 4px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
}

.prose th {
  background: var(--bg-soft);
}

.anchor {
  color: var(--faint);
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.12s;
}

.prose h2:hover .anchor,
.prose h3:hover .anchor {
  opacity: 1;
}

/* ---------- palette and modal ---------- */

.palette,
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
}

.palette[hidden],
.modal[hidden] {
  display: none;
}

.palette-backdrop,
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 14, 0.45);
  backdrop-filter: blur(3px);
}

.palette-box {
  position: relative;
  width: 100%;
  max-width: 620px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.palette-input-row svg {
  width: 18px;
  height: 18px;
  color: var(--faint);
}

.palette-input-row input {
  flex: 1;
  height: 56px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.palette-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.palette-results a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
}

.palette-results a.is-active,
.palette-results a:hover {
  background: var(--accent-soft);
}

.pi-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pi-main b {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-main small {
  color: var(--faint);
  font-size: 12.5px;
}

.pi-kind {
  font-size: 12px;
  color: var(--faint);
}

.palette-empty {
  padding: 18px 12px;
  color: var(--muted);
}

.modal {
  padding-top: 6vh;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 980px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--term-border);
  border-radius: 14px;
  background: var(--term-bg);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  background: var(--term-bar);
  border-bottom: 1px solid var(--term-border);
  color: var(--term-text);
}

.modal-title {
  font-family: var(--mono);
  font-size: 13.5px;
}

.modal-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.modal-actions .btn-ghost {
  background: #232731;
  border-color: #343844;
  color: var(--term-text);
}

.modal-actions .icon-btn {
  color: #9a9cab;
}

.modal-actions .icon-btn:hover {
  background: #232731;
  color: var(--term-text);
}

.modal-code {
  flex: 1;
  overflow: auto;
  border-radius: 0;
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 14px;
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-note {
  margin: 0;
  font-size: 13px;
  color: var(--faint);
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 210px minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 18px;
  }
  .sidebar {
    display: none;
  }
  .topnav a:not(:last-of-type) {
    display: none;
  }
  .search-placeholder {
    display: none;
  }
  .search-trigger {
    flex: 0 0 auto;
    width: 64px;
  }
  .brow {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .kv {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .topbar-inner,
  .app,
  .footer-inner {
    padding-left: 16px;
    padding-right: 16px;
  }
  .topbar-inner {
    gap: 10px;
  }
  .topnav a {
    display: none;
  }
  .hero {
    padding: 44px 0 28px;
  }
  .recipe-head {
    flex-direction: column;
    gap: 14px;
  }
  .builder {
    padding: 16px;
    margin-left: -4px;
    margin-right: -4px;
  }
  .builder-head {
    flex-direction: column;
    gap: 10px;
  }
  .text-input-sm {
    width: 100%;
  }
  .inline-input {
    width: 100%;
  }
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-label {
    width: 100%;
  }
  .trainer-head {
    flex-direction: column;
    gap: 10px;
  }
  .trainer-block {
    padding: 16px;
  }
}
