:root {
  --bg: #0a0d16;
  --bg-soft: #10152a;
  --panel: #141a2e;
  --panel-2: #181f38;
  --border: #2a3252;
  --text: #eef1fb;
  --text-dim: #9aa3c4;
  --text-faint: #6b7398;
  --blue: #4d8dff;
  --violet: #a374e8;
  --cyan: #38e0d0;
  --pink: #ff5fa8;
  --amber: #ffb84d;
  --green: #3ee08a;
  --font-display: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
h3,
.display {
  font-family: var(--font-display);
  font-weight: 700;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  color: var(--pink);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
}

.section-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
}

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

#nav-root,
#nav-root *,
#nav-root *::before,
#nav-root *::after {
  box-sizing: border-box;
}

#nav-root {
  line-height: 1.5;
}

#nav-root .display {
  font-family: var(--font-display);
  font-weight: 700;
}

#nav-root .mono {
  font-family: var(--font-mono);
}

@media (max-width: 900px) {
  .nav-bar { padding: 16px 24px !important; }
  .nav-links { display: none !important; }
  .menu-toggle { display: inline-flex !important; }
}

@media (max-width: 600px) {
  .nav-bar { padding: 14px 20px !important; }
  .nav-npm-text { display: none !important; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .nav-npm-text { display: none !important; }
}

/* --- Mobile menu (invented; not part of the #590 canvas) --- */

html.mobile-nav-open {
  overflow: hidden;
}

.menu-toggle .mnt-bar {
  transition: transform .22s ease, opacity .22s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.menu-toggle.is-open .mnt-bar-top {
  transform: translateY(5px) rotate(45deg);
}

.menu-toggle.is-open .mnt-bar-mid {
  opacity: 0;
}

.menu-toggle.is-open .mnt-bar-bottom {
  transform: translateY(-5px) rotate(-45deg);
}

.mobile-nav-panel {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  padding: 96px 24px 32px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
  transition: opacity .26s ease, transform .26s ease;
  overflow: hidden;
}

.mobile-nav-panel.is-open {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.mobile-diagram-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.mobile-diagram-bg .mdb-edge {
  animation: mobile-diagram-dash 3s linear infinite;
}

@keyframes mobile-diagram-dash {
  to {
    stroke-dashoffset: -40;
  }
}

.mobile-watermark {
  position: absolute;
  right: -44px;
  bottom: -33px;
  opacity: 0.05;
  transform: rotate(-8deg);
  pointer-events: none;
}

.mobile-links {
  display: flex;
  flex-direction: column;
}

.mobile-link {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  text-shadow: 0 2px 16px rgba(10, 13, 22, 0.8);
}

.mobile-link:last-of-type {
  border-bottom: none;
}

.mobile-install {
  margin-top: auto;
  align-self: flex-start;
}

@media (prefers-reduced-motion: reduce) {
  .menu-toggle .mnt-bar,
  .mobile-nav-panel,
  .mobile-diagram-bg .mdb-edge {
    transition-duration: 0.001ms !important;
    animation: none !important;
  }
}

@media (min-width: 901px) {
  /* Safety net for a viewport resize while the menu is open (e.g. a phone
   * rotated past the breakpoint) — the toggle that would close it is gone
   * by then, since it's hidden by the rule above this block. */
  .mobile-nav-panel.is-open {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

@media (max-width: 900px) {
  .section-px {
    padding-left: 32px !important;
    padding-right: 32px !important;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 600px) {
  .section-px {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
  }

  .footer-bottom-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
}

#theme-pills {
  --t-bg: #FFFFFF;
  --t-fg: #27272A;
}
.theme-pills {
  display: flex;
  gap: 0.3rem;
  overflow: visible;
  padding: 4px;
  margin: -4px;
  position: relative;
  z-index: 2;
}
.theme-pills-inline {
  display: flex;
  gap: 0.3rem;
}
@media (max-width: 1024px) {
  .theme-pills-inline {
    display: none;
  }
}
.theme-pill {
  display: flex;
  align-items: center;
  height: 30px;
  gap: 8px;
  padding: 0 14px 0 12px;
  border: none;
  border-radius: 8px;
  background: color-mix(in srgb, var(--t-bg) 97%, var(--t-fg));
  color: color-mix(in srgb, var(--t-fg) 80%, var(--t-bg));
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s,
    background 0.15s,
    box-shadow 0.2s,
    transform 0.1s;
}
.theme-pill:hover {
  color: var(--t-fg);
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.theme-pill.active {
  color: var(--t-fg);
  background: var(--t-bg);
  font-weight: 600;
}
.theme-pill:active {
  transform: translateY(0.5px);
}
.theme-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.theme-more-wrapper {
  position: relative;
}
.theme-more-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--t-bg);
  border-radius: 12px;
  padding: 6px;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  z-index: 1002;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.theme-more-dropdown.open {
  display: flex;
}
.theme-more-dropdown .theme-pill {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  box-shadow: none;
}
.theme-more-dropdown .theme-pill:hover {
  background: color-mix(in srgb, var(--t-bg) 92%, var(--t-fg));
}
.theme-more-dropdown .theme-pill.active {
  background: var(--t-bg);
}

/**
 * Blog-page-only CSS for the redesign (#607, part of #590/#591).
 *
 * blog.ts writes this file concatenated *after* tokens.tsx's
 * designBaseCss(), primitives.tsx's primitivesCss(), nav.tsx's navCss(),
 * and footer.tsx's footerCss() — see that file's `main()`. Those four
 * cover the palette/base elements, `.card`/`.pill`/`.section-eyebrow`, and
 * the Nav/Footer responsive rules; this file holds only what's specific to
 * the blog's own layout: the base reset (the shared modules don't ship
 * one — see tokens.tsx's header comment), the two heading sizes that need
 * a viewport-based override, the featured-post/archive-grid responsive
 * behaviour, and the rendered-Markdown `.prose` typography.
 *
 * `.section-px` (the full-bleed horizontal-gutter hook used throughout
 * blog-page.tsx) already gets its responsive narrowing from footerCss();
 * see that function's doc comment for why re-declaring it here would be
 * redundant rather than wrong.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 0;
}

/* -- Page heading (blog index) -- */
.page-h1 {
  font-size: 52px;
}

@media (max-width: 600px) {
  .page-h1 {
    font-size: 34px;
  }
}

/* -- Featured post -- */
@media (max-width: 900px) {
  .featured-card {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .featured-visual {
    width: 100% !important;
    max-width: 360px;
  }
}

@keyframes blog-float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
}

.float-anim {
  animation: blog-float 3.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .float-anim {
    animation: none;
  }
}

/* -- Archive grid -- */
@media (max-width: 900px) {
  .archive-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 600px) {
  .archive-grid {
    grid-template-columns: 1fr !important;
  }
}

/* -- Post body typography (rendered Markdown, spliced into .prose) -- */
.prose {
  font-size: 17px;
  line-height: 1.9;
  color: var(--text);
}

.prose > * + * {
  margin-top: 1.15em;
}

.prose h2 {
  font-size: 26px;
  line-height: 1.3;
  margin-top: 2em;
}

.prose h3 {
  font-size: 20px;
  line-height: 1.35;
  margin-top: 1.75em;
}

.prose h4,
.prose h5,
.prose h6 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-top: 1.5em;
}

.prose p,
.prose li {
  line-height: 1.9;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.4em;
}

.prose blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.1em;
  color: var(--text-dim);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.prose img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* A ```mermaid-render fence (blog.ts), rendered at build time to an inline
   SVG via the same renderMermaidSVG the per-diagram-type gallery pages use
   (pages.ts) — always a white card (DEFAULT_SWATCH), same as there, so it
   reads as a deliberate "printed diagram" accent against this page's dark
   background rather than trying to re-theme the diagram itself per post. */
.prose .mermaid-diagram {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.prose .mermaid-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--cyan);
  background: var(--panel-2);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

/* Shiki emits its own inline background-color per theme (blog.ts uses
   'github-dark', close to --bg); this only handles layout, matching
   demo/diagram-page.css's .source-panel. */
.prose pre {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow-x: auto;
  padding: 20px 24px;
}

.prose pre code {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

/* GFM tables: marked's `table` renderer (blog.ts) wraps the raw <table> in
   this div so a wide table scrolls in its own box, matching .prose pre's
   overflow-x handling above instead of widening the page body. */
.prose .table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

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

.prose th {
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
}

.prose tr:last-child td {
  border-bottom: none;
}
