/* Search palette styles (lazy-injected when ready)
   plus a couple of misc utilities I didn't want to inline */

#palette {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
#palette.open { display: flex; }
.palette-bg {
  position: absolute; inset: 0;
  background: rgba(20, 16, 10, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.palette {
  position: relative;
  width: min(640px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  overflow: hidden;
}
.palette-in {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.palette-in input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  font: inherit;
  color: var(--ink);
  font-size: 15px;
}
.palette-in input::placeholder { color: var(--faint); }
.palette-results { padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette-section {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 10px 10px 6px;
}
.palette-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 10px; border-radius: 6px;
  color: var(--ink-2);
  font-size: 14px;
}
.palette-item:hover { background: var(--accent-2); color: var(--accent-ink); }
[data-theme="dark"] .palette-item:hover { color: var(--accent); }
.palette-item .kbd-row { color: var(--faint); }
/* Pagefind result rows: title above, excerpt below — overrides the single-row
   flex layout above for richer multi-line results. */
.palette-item.result { align-items: flex-start; padding: 10px; }
.palette-item.result .r-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.palette-item.result .r-ttl {
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.palette-item.result:hover .r-ttl { color: var(--accent-ink); }
[data-theme="dark"] .palette-item.result:hover .r-ttl { color: var(--accent); }
.palette-item.result .r-snip {
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.palette-item.result .r-snip mark {
  background: var(--accent-2);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
.palette-hint {
  padding: 8px 10px 12px;
  color: var(--faint);
  font-size: 12.5px;
}

/* Tweaks toggle button visual */
.tweaks-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999;
  width: 38px; height: 38px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, transform .15s, border-color .15s;
}
.tweaks-fab:hover { color: var(--ink); border-color: var(--line-2); transform: translateY(-1px); }

/* Reset behavior tweaks */
.tweaks .tw-row button[data-reset]:hover { color: var(--ink); }

/* ──────────────────────────────────────────────────
   GUIDE INDEX — section blocks with article lists
   (sticky meta column + list of article rows)
   ────────────────────────────────────────────────── */
.guide-sections {
  margin-top: var(--gap-3);
}
.guide-section {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--gap-4);
  padding: var(--gap-4) 0;
  border-top: 1px solid var(--line);
}
.guide-section:last-of-type { /* no extra bottom rule */ }

.gs-meta {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  align-self: start;
}
.gs-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .gs-num { color: var(--accent); }
.gs-num::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent);
  display: inline-block;
}
.gs-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 10px;
  text-wrap: balance;
}
.gs-title .gs-link {
  color: inherit;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease, color .15s ease;
}
.gs-title .gs-link:hover {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}
[data-theme="dark"] .gs-title .gs-link:hover { color: var(--accent); }
.gs-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--gap-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-ink);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .12s, background-color .12s, transform .12s;
}
.gs-open:hover { border-color: var(--accent); background: var(--accent-2); transform: translateY(-1px); }
[data-theme="dark"] .gs-open { color: var(--accent); }
.gs-open svg { transition: transform .15s; }
.gs-open:hover svg { transform: translateX(2px); }
.gs-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 var(--gap-2);
  max-width: 32ch;
}
.gs-stats {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.gs-stats span { display: inline-flex; align-items: center; gap: 6px; }
.gs-stats .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }

.gs-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.gs-row {
  display: grid;
  grid-template-columns: 64px minmax(0,1fr) auto;
  gap: var(--gap-2);
  align-items: baseline;
  padding: 16px 12px 16px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  transition: background-color .12s ease;
  position: relative;
}
.gs-row:last-child { border-bottom: 0; }
.gs-row:hover { background: var(--surface); }
.gs-row .num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.gs-row:hover .num { color: var(--accent); }
.gs-row .ttl {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.005em;
  line-height: 1.35;
  transition: color .12s ease;
}
.gs-row:hover .ttl { color: var(--accent-ink); }
[data-theme="dark"] .gs-row:hover .ttl { color: var(--accent); }
.gs-row .mins {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.gs-row .tags {
  display: inline-flex;
  gap: 6px;
  margin-left: 8px;
}
.gs-row .tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent-2);
  padding: 2px 5px;
  border-radius: 3px;
  vertical-align: middle;
}
[data-theme="dark"] .gs-row .tag { color: var(--accent); }
.gs-row .tag.new { color: var(--ok); background: color-mix(in oklab, var(--ok) 14%, transparent); }
.gs-row .tag.upd { color: var(--warn); background: color-mix(in oklab, var(--warn) 14%, transparent); }

@media (max-width: 720px) {
  .guide-section { grid-template-columns: 1fr; gap: var(--gap-2); }
  .gs-meta { position: static; }
  .gs-desc { max-width: 56ch; }
}

/* ──────────────────────────────────────────────────
   CHAT CTA — chat empty-state hero
   Centered card, hero textarea, 2×2 prompt grid.
   ────────────────────────────────────────────────── */
.chat-cta {
  margin-top: var(--gap-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: var(--gap-4);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-3);
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 16px 40px -20px rgba(0,0,0,.08);
}
[data-theme="dark"] .chat-cta {
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0,0,0,.4), 0 16px 40px -20px rgba(0,0,0,.6);
}

/* Cat avatar — circular, identifies Сейка */
.chat-cta .cta-cat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-cta .cta-cat svg {
  display: block;
  width: 38px;
  height: 38px;
}

.chat-cta-head { display: block; min-width: 0; }

/* Eyebrow row with avatar inline */
.chat-cta-head .eyebrow {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-cta-head .eyebrow::before { display: none; }

.chat-cta-head h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.15;
  color: var(--ink);
  margin: 14px 0 8px;
  max-width: none;
  text-wrap: balance;
}
.chat-cta-head h2 em {
  color: var(--accent-ink);
  font-style: normal;
  font-weight: 600;
}
[data-theme="dark"] .chat-cta-head h2 em { color: var(--accent); }
.chat-cta-head p {
  margin: 0 0 var(--gap-2);
  color: var(--muted);
  font-size: 14.5px;
  max-width: none;
  line-height: 1.55;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* Hero textarea */
.chat-cta-input {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px 62px;
  min-height: 132px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
[data-theme="dark"] .chat-cta-input { background: var(--bg); }
.chat-cta-input:hover { border-color: var(--line-2); }
.chat-cta-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 12%, transparent);
}
.chat-cta-input input,
.chat-cta-input textarea {
  background: transparent;
  border: 0;
  outline: 0;
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.55;
  padding: 0;
  resize: none;
  min-height: 4.5em;
  display: block;
}
.chat-cta-input input::placeholder,
.chat-cta-input textarea::placeholder { color: var(--faint); }

.chat-cta-input button {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  cursor: pointer;
  transition: transform .12s ease, background-color .12s ease, opacity .12s;
  opacity: 0.85;
}
.chat-cta-input button:hover { background: var(--accent-ink); transform: translateY(-1px); opacity: 1; }
[data-theme="dark"] .chat-cta-input button { background: var(--accent); color: var(--bg); opacity: 1; }
[data-theme="dark"] .chat-cta-input button:hover { background: var(--accent-ink); }
.chat-cta-input button svg { display: block; }
.chat-cta-input button .label { display: none; }

/* Disabled legacy button */
.chat-cta-btn { display: none; }

/* Suggested prompts — quiet 2×2 grid, subtle and clickable */
.chat-cta-preview {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.chat-cta-preview .lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.chat-cta-preview ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.chat-cta-preview li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 1.4;
  font-style: normal;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease, transform .12s ease;
  text-wrap: balance;
}
.chat-cta-preview li::before {
  content: "+";
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-2);
  transition: transform .15s ease;
}
.chat-cta-preview li:hover {
  color: var(--ink);
  border-color: var(--line-2);
  transform: translateY(-1px);
}
.chat-cta-preview li:hover::before {
  transform: rotate(90deg);
}
[data-theme="dark"] .chat-cta-preview li::before {
  background: color-mix(in oklab, var(--accent) 18%, transparent);
}
.chat-cta-preview li + li::before { content: "+"; color: var(--accent); font-style: normal; }

@media (max-width: 720px) {
  .chat-cta { padding: var(--gap-3); }
  .chat-cta-head h2 { font-size: 22px; }
  .chat-cta-preview ul { grid-template-columns: 1fr; }
}

/* Small fine-print line under the chat shortcuts */
.fine-band {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gap-3);
}
.chat-cta-fine {
  margin: 0 auto;
  padding: 14px 0 16px;
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.5;
  letter-spacing: -0.001em;
  text-align: center;
  max-width: none;
}
.chat-cta-fine a {
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  transition: color .12s, border-color .12s;
}
.chat-cta-fine a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
[data-theme="dark"] .chat-cta-fine a:hover { color: var(--accent); }

/* Primary CTA in the topnav — light-blue, hardcoded for reliability */
.topnav a.topnav-cta,
.topnav-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  height: 34px;
  padding: 0 16px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-transform: none;
  color: #1E3A8A;
  background: #DBEAFE;
  border: 1px solid #93C5FD;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.topnav a.topnav-cta::after,
.topnav-cta::after {
  content: none;
}
.topnav a.topnav-cta:hover,
.topnav-cta:hover {
  color: #1E3A8A;
  background: #BFDBFE;
  border-color: #60A5FA;
}
.topnav a.topnav-cta:hover::after,
.topnav-cta:hover::after {
  opacity: 1;
  transform: translateX(2px);
}
[data-theme="dark"] .topnav a.topnav-cta,
[data-theme="dark"] .topnav-cta {
  color: #BFDBFE;
  background: #1E3A8A;
  border-color: #3B82F6;
}
[data-theme="dark"] .topnav a.topnav-cta:hover,
[data-theme="dark"] .topnav-cta:hover {
  color: #DBEAFE;
  background: #1E40AF;
  border-color: #60A5FA;
}

/* Below ~1080px: collapse the search trigger to icon-only and hide kbd hint */
@media (max-width: 1080px) {
  .search-trigger { width: auto; padding: 0 8px; }
  .search-trigger .placeholder,
  .search-trigger kbd { display: none; }
}

/* page intro stats — small, monospace strip */
.guide-intro {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-3);
  padding: var(--gap-2) 0 0;
  margin: var(--gap-2) 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.guide-intro .item { display: inline-flex; align-items: baseline; gap: 8px; }
.guide-intro .item .v {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.guide-intro .item .l { text-transform: uppercase; }

/* ──────────────────────────────────────────────────
   ARTICLE PROSE EXTRAS — compare cards, blockquote
   ────────────────────────────────────────────────── */
.prose blockquote {
  margin: var(--gap-3) 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.55;
  font-style: italic;
  max-width: 64ch;
}
.prose blockquote p { margin: 0 0 8px; }
.prose blockquote cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: var(--gap-3) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.compare-col { padding: var(--gap-2) var(--gap-2) var(--gap-2); }
.compare-col + .compare-col { border-left: 1px solid var(--line); }
.compare-col h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 var(--gap);
}
[data-theme="dark"] .compare-col h4 { color: var(--accent); }
.compare-col ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.compare-col li { margin-bottom: 6px; line-height: 1.5; }
.compare-col li strong { color: var(--ink); font-weight: 600; }

@media (max-width: 720px) {
  .compare { grid-template-columns: 1fr; }
  .compare-col + .compare-col { border-left: 0; border-top: 1px solid var(--line); }
}

/* small inline kbd-style key labels inside prose */
.prose .keymark {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  background: var(--accent-2);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
[data-theme="dark"] .prose .keymark { color: var(--accent); }

/* figure / source attribution */
.prose figure {
  margin: var(--gap-3) 0;
  padding: 0;
}
.prose figure .fig-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.prose figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 8px;
  display: flex;
  gap: 10px;
}
.prose figcaption .num {
  color: var(--accent-ink);
  font-weight: 600;
}
[data-theme="dark"] .prose figcaption .num { color: var(--accent); }

/* article share / actions strip in head */
.article-actions {
  display: flex;
  gap: 6px;
  margin-top: var(--gap-2);
}
.article-actions button {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .12s, border-color .12s, background-color .12s;
}
.article-actions button:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface-2); }
.article-actions svg { width: 12px; height: 12px; }

/* nav-card extras — snippet line under the title */
.article-foot { border-top: 0; padding-top: 0; }
.nav-card { display: block; padding: 16px 18px; }
.nav-card .ttl {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.nav-card .snip {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 38ch;
}
.nav-card.next .snip { margin-left: auto; }
.nav-card:hover .snip { color: var(--ink-2); }

/* Right-rail list of all guide sections (used on section pages) */

/* Right-rail — project title + section list, minimal styling */
.rail-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--ink);
  text-wrap: balance;
  padding: 4px 0 var(--gap-2);
  transition: color .12s ease;
}
.rail-title:hover { color: var(--accent-ink); }
[data-theme="dark"] .rail-title:hover { color: var(--accent); }

.toc .sections-rail { list-style: none; padding: 0; margin: 0; }
.toc .sections-rail li { margin: 0; }
.toc .sections-rail li a {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: -0.005em;
  line-height: 1.4;
  transition: color .12s, background-color .12s, border-color .12s;
}
.toc .sections-rail li a:hover {
  color: var(--ink);
  background: var(--surface);
  border-left-color: var(--line-2);
}
.toc .sections-rail li a.active {
  color: var(--accent-ink);
  background: var(--accent-2);
  border-left-color: var(--accent);
  font-weight: 500;
}
[data-theme="dark"] .toc .sections-rail li a.active { color: var(--accent); }
.toc .sections-rail .c { display: none; }
.toc .sections-rail .n {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  opacity: .55;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  transition: opacity .12s;
}
.toc .sections-rail li a:hover .n { opacity: .9; }
.toc .sections-rail li a.active .n { color: currentColor; opacity: .55; }
.toc .sections-rail .n svg { display: block; margin: 0 auto; opacity: .7; transition: opacity .12s; }
.toc .sections-rail li a:hover .n svg { opacity: 1; }
.toc .sections-rail .t { line-height: 1.35; }

/* ──────────────────────────────────────────────────
   GLOSSARY — alpha bar + dt/dd term list
   ────────────────────────────────────────────────── */
.alpha-bar {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin: var(--gap-2) 0 0;
}
.alpha-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.alpha-sep {
  width: 1px;
  background: var(--line);
  margin: 0 6px;
}
.alpha-bar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 4px;
  letter-spacing: 0.02em;
  transition: color .12s, background-color .12s;
}
.alpha-bar a:hover { color: var(--ink); background: var(--surface); }
.alpha-bar a.active { color: var(--accent-ink); background: var(--accent-2); }
[data-theme="dark"] .alpha-bar a.active { color: var(--accent); }

.wiki { margin-top: var(--gap-4); }
.gloss-letter {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: var(--gap-4) 0 var(--gap-2);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--topbar-h) + 70px);
}
[data-theme="dark"] .gloss-letter { color: var(--accent); }
.gloss-letter:first-of-type { margin-top: 0; }

.wiki dl { margin: 0; padding: 0; }
.wiki .term {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--gap-3);
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.wiki .term:last-child { border-bottom: 0; }
.wiki dt {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 0;
}
.wiki dt a {
  color: var(--accent-ink);
  border-bottom: 1px solid transparent;
  transition: border-color .12s, color .12s;
}
[data-theme="dark"] .wiki dt a { color: var(--accent); }
.wiki dt a:hover { border-bottom-color: currentColor; }
.wiki dd {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0;
  max-width: 64ch;
}
.wiki dd code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent-ink);
  background: var(--accent-2);
  padding: 1px 5px;
  border-radius: 3px;
}
[data-theme="dark"] .wiki dd code { color: var(--accent); }

@media (max-width: 720px) {
  .wiki .term { grid-template-columns: 1fr; gap: 4px; }
}

/* ──────────────────────────────────────────────────
   MOBILE — comprehensive responsive pass
   Loaded last so it wins on cascade tie.
   ────────────────────────────────────────────────── */

/* Mobile (≤720px): collapse to single column, hide right rail behind the
   hamburger drawer, switch topnav to compact. Higher specificity + !important
   so the inline grid-template-columns on .app is overridden. */
@media (max-width: 720px) {
  body div.app,
  body div.app[style] {
    grid-template-columns: minmax(0, 1fr) !important;
    max-width: 760px !important;
    gap: 0 !important;
    padding: 0 var(--gap-2) !important;
  }
  body aside.toc { display: none !important; }
  .main { padding: var(--gap-2) 0 var(--gap-3) !important; }
  .main { padding: var(--gap-2) 0 var(--gap-3) !important; }

  .topbar-inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
  }
  /* Keep top nav visible; hide brand-level CTA pill to save space */
  .topnav { gap: 0; }
  .topnav a {
    padding: 6px 8px;
    font-size: 12.5px;
  }
  .topnav a.topnav-cta,
  .topnav-cta {
    padding: 0 12px;
    height: 32px;
    font-size: 12.5px;
  }
  .top-actions .icon-btn[data-tweaks-toggle] { display: none; }
  .top-actions { gap: 4px; }

  /* Hero / page heads: scale down */
  .hero h1, .article-head h1 {
    font-size: clamp(26px, 7vw, 34px) !important;
    margin-top: 8px !important;
    line-height: 1.1 !important;
  }
  .hero .lede, .article-head .lede {
    font-size: 15px !important;
  }
  .hero { display: block !important; }
  .hero-mascot { display: none !important; }
  .hero-bubble { display: none !important; }

  /* Stat blocks: stack inline */
  header[style*="grid-template-columns: 1fr auto"] {
    grid-template-columns: 1fr !important;
    align-items: start !important;
  }
  .stat { display: inline-flex; gap: 8px; align-items: baseline; }
  .stat .num { font-size: 18px !important; }

  /* Guide section: stack meta + list */
  .guide-section {
    grid-template-columns: 1fr !important;
    gap: var(--gap-2) !important;
  }
  .gs-meta { position: static !important; }

  /* Article row (index): collapse columns */
  .gs-row {
    grid-template-columns: 64px 1fr !important;
    gap: 8px !important;
    padding: 12px 8px !important;
  }
  .gs-row .mins,
  .gs-row .tags { display: none !important; }

  /* Article list (section pages) */
  .article-row {
    grid-template-columns: auto 1fr !important;
    gap: 10px !important;
    padding: 14px 0 !important;
  }
  .article-row .right {
    grid-column: 1 / -1 !important;
    margin-top: 4px !important;
    justify-self: start !important;
  }

  /* Glossary: stack dt and dd */
  .wiki .term,
  .term {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }
  .alpha-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }
  .alpha-sep { display: none; }

  /* Author hello (О Сейке): stack vertically */
  .author-hello {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .author-hello .ah-mascot { padding-top: 0 !important; }
  .author-hello .ah-bubble {
    width: 100% !important;
    max-width: none !important;
  }
  .author-hello .ah-bubble::before,
  .author-hello .ah-bubble::after { display: none !important; }

  /* Promises: tighten */
  .promises li {
    grid-template-columns: 24px 1fr !important;
    gap: 10px !important;
    padding: 14px 0 !important;
  }
  .promises li::before {
    width: 20px !important;
    height: 20px !important;
  }

  /* Chat CTA: stack and shrink */
  .chat-cta { padding: var(--gap-2) !important; }
  .chat-cta-head h2 { font-size: 20px !important; }
  .chat-cta-input { padding: 14px 14px 56px !important; }
  .chat-cta-preview ul { grid-template-columns: 1fr !important; }

  /* Nav cards: stack with next on top, prev below; reset right-alignment. */
  .article-foot {
    grid-template-columns: 1fr !important;
    gap: var(--gap) !important;
  }
  .article-foot .nav-card.next { order: -1; }
  .nav-card.next { text-align: left !important; }
  .nav-card.next .snip { margin-left: 0 !important; }

  /* See-also cards */
  .see-also { grid-template-columns: 1fr !important; }

  /* Footer: stack */
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: var(--gap-2) var(--gap-2);
  }
  .footer-inner .links {
    flex-wrap: wrap;
    gap: 6px 14px;
  }

  /* Breadcrumb wraps cleanly */
  .breadcrumb { font-size: 12px; flex-wrap: wrap; }
}

/* Small phones: even tighter */
@media (max-width: 420px) {
  .hero h1, .article-head h1 { font-size: 24px !important; }
  .chat-cta-head h2 { font-size: 18px !important; }
  .chat-cta-input button { width: 34px !important; height: 34px !important; }
  .brand-name { display: none; }
  /* On very small phones, hide non-essential top-nav items, keep CTA */
  .topnav a:not(.topnav-cta):not(.active) { display: none; }
}

/* Mobile rail-menu button (📑) — opens the right rail in a drawer */
.icon-btn.mobile-menu { display: none; }
@media (max-width: 720px) {
  .icon-btn.mobile-menu { display: inline-flex; }
}

/* Mobile rail drawer — collapsed right-side panel from below the topbar */
body.has-mobile-menu aside.toc {
  display: block !important;
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  bottom: 0;
  background: var(--bg);
  padding: var(--gap-3);
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  max-width: none;
  width: 100%;
  border-top: 1px solid var(--line);
}
body.has-mobile-menu aside.toc .toc-title {
  margin-top: var(--gap-3);
}
body.has-mobile-menu aside.toc .toc-title:first-of-type {
  margin-top: 0;
}
body.has-mobile-menu aside.toc .rail-title {
  font-size: 18px;
}
body.has-mobile-menu aside.toc ul li a {
  padding: 12px 10px !important;
  font-size: 15px !important;
}
body.has-mobile-menu aside.toc .sections-rail li a {
  padding: 12px 10px !important;
  font-size: 15px !important;
}

/* Hub pages have no aside.toc, so app.js adds body.no-rail — open the topnav as the drawer. */
body.no-rail.has-mobile-menu .topnav {
  display: flex !important;
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  bottom: 0;
  background: var(--bg);
  flex-direction: column;
  justify-content: flex-start; /* override the mobile .topnav justify-content:center */
  align-items: stretch;
  padding: var(--gap-3);
  gap: 4px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  border-top: 1px solid var(--line);
}
body.no-rail.has-mobile-menu .topnav a {
  display: flex !important; /* links are display:none on mobile; reveal them in the drawer */
  padding: 14px 10px !important;
  font-size: 16px !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0 !important;
}
body.no-rail.has-mobile-menu .topnav a:last-of-type { border-bottom: 0 !important; }
body.no-rail.has-mobile-menu .topnav a.topnav-cta {
  margin-top: 12px !important;
  margin-left: 0 !important;
  justify-content: center !important;
  height: 48px !important;
  border-radius: var(--radius) !important;
}

/* The topbar's backdrop-filter makes it a containing block for fixed children,
   which traps the .topnav drawer inside its 52px height. Drop it while the
   drawer is open so the fixed panel fills the viewport. */
body.has-mobile-menu .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* When drawer is open, prevent body scroll behind */
body.has-mobile-menu {
  overflow: hidden;
}

/* ──────────────────────────────────────────────────
   CODE BLOCKS — Shiki dual-theme (github-light + github-dark)
   ────────────────────────────────────────────────── */

/* Framed code block with the design's surface fill. Syntax highlighting
   uses Shiki's github-light / github-dark themes (color-only, no per-token
   backgrounds). Light mode keeps the inline shiki colors; dark mode swaps
   to --shiki-dark-* CSS variables. */
.prose pre.astro-code {
  background: var(--surface) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: var(--gap-2) 0;
}

/* The design system's .prose code rule paints inline code as a pill —
   suppress that styling for the <code> that wraps a code block, so the pre
   shows a single flat surface, not a nested pill. */
.prose pre.astro-code code,
.prose pre.astro-code .line,
.prose pre.astro-code span {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  color: inherit;
}

/* Dark theme — swap each token's color/style to its --shiki-dark-* var. */
[data-theme='dark'] .prose pre.astro-code,
[data-theme='dark'] .prose pre.astro-code span {
  color: var(--shiki-dark) !important;
  font-style: var(--shiki-dark-font-style) !important;
  font-weight: var(--shiki-dark-font-weight) !important;
  text-decoration: var(--shiki-dark-text-decoration) !important;
}

/* When the topnav collapses on mobile, the grid removes its cell and
   .top-actions slides next to the brand. Push it back to the right edge. */
@media (max-width: 720px) {
  .topbar-inner .top-actions { margin-left: auto; }
}

/* Sейка callout — small cat avatar in place of label */
.callout .cat-note {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  width: 56px;
  flex-shrink: 0;
  align-self: start;
  margin-top: -4px;
  margin-left: -4px;
}
.callout .cat-note svg { display: block; }

/* Stacked layout: cat in col 1, body wrapper in col 2 with tag above text. */
.callout > div > .tag { display: block; margin-bottom: 4px; }
.callout > div > p { margin: 0; }

/* When the callout has a title (.tag), shift the cat down so it sits next
   to the body paragraph rather than next to the tag. */
.callout:has(.tag) .cat-note { margin-top: 22px; }

/* When the article starts with a callout (e.g., <Privet> intro), drop the
   article-head's bottom border — the callout itself reads as the divider. */
.article-head:has(+ .prose > .callout:first-child) {
  border-bottom: 0;
  padding-bottom: 0;
}

/* Variant tag colours using design tokens. */
.callout.next     { border-left-color: var(--ok); }
.callout.next     .tag { color: var(--ok); }
.callout.practice { border-left-color: oklch(55% 0.10 200); }
.callout.practice .tag { color: oklch(45% 0.10 200); }
[data-theme="dark"] .callout.practice .tag { color: oklch(72% 0.12 200); }
.callout.source   { border-left-color: oklch(50% 0.08 280); }
.callout.source   .tag { color: oklch(42% 0.08 280); }
[data-theme="dark"] .callout.source .tag { color: oklch(78% 0.08 280); }
.callout.brief    { border-left-color: oklch(65% 0.10 90); }
.callout.brief    .tag { color: oklch(48% 0.10 90); }
[data-theme="dark"] .callout.brief .tag { color: oklch(82% 0.10 90); }
.callout.change   { border-left-color: oklch(58% 0.16 0); }
.callout.change   .tag { color: oklch(48% 0.16 0); }
[data-theme="dark"] .callout.change .tag { color: oklch(74% 0.16 0); }

/* Sequential callouts */
.callout + .callout { margin-top: var(--gap-2); }
