:root {
  color-scheme: dark;
  /* Use the shared terminal palette when available; retain the local fallback. */
  --learn-bg: var(--bg-base, #101419);
  --learn-surface: var(--bg-surface, #171d25);
  --learn-border: var(--border-ghost, #303b49);
  --learn-text: var(--text-main, #e8edf4);
  --learn-muted: var(--text-muted, #a5b1c2);
  --learn-accent: var(--accent-green, #7de2c0);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--learn-bg);
  color: var(--learn-text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.7;
}

a { color: var(--learn-accent); }
a:hover { color: var(--accent-cyan, #b3f4de); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--learn-accent);
  outline-offset: 4px;
}

[hidden] { display: none !important; }
.brand-dot { color: var(--learn-accent); }
.site-content { min-height: 70vh; }
.site-nav { border-bottom: 1px solid var(--learn-border); }
.nav-inner, .footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1240px;
  margin-inline: auto;
  padding: 1.25rem clamp(0.75rem, 3vw, 2rem);
}
.site-brand { color: var(--learn-text); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.06em; text-decoration: none; }
.site-nav-links { display: flex; flex-wrap: wrap; gap: clamp(0.75rem, 3vw, 2rem); list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.site-nav-links a { color: var(--learn-muted); text-decoration: none; }
.site-nav-links a:hover { color: var(--learn-accent); }
.site-footer { border-top: 1px solid var(--learn-border); margin-top: 4rem; color: var(--learn-muted); font-size: 0.8rem; }
.footer-inner { flex-wrap: wrap; padding-block: 2rem; }
.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 1100;
  padding: 0.75rem 1rem;
  background: var(--learn-surface);
}
.skip-link:focus { top: 1rem; }

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  padding: 0;
  margin: 0 0 2rem;
  list-style: none;
  color: var(--learn-muted);
  font-size: 0.8rem;
}
.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.6rem;
  color: var(--learn-muted);
}
.breadcrumbs a { color: var(--learn-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--learn-accent); }

.article-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 3rem);
  max-width: 1400px;
  margin: 2.5rem auto;
  padding-inline: clamp(0.75rem, 3vw, 2rem);
}
.article-sidebar { position: sticky; top: 1.5rem; }
.article-main { min-width: 0; }
.article-nav {
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.25rem;
  border: 1px solid var(--learn-border);
  border-radius: 0.75rem;
  background: var(--learn-surface);
  font-size: 0.875rem;
}
.back-to-library { display: block; margin-bottom: 1.5rem; text-decoration: none; }
.article-nav summary { font-weight: 600; margin-block: 0.75rem; }
.article-nav ul { list-style: none; padding: 0; margin: 0; }
.article-nav li a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 0.35rem;
  color: var(--learn-muted);
  text-decoration: none;
}
.article-nav li a:hover, .article-nav a[aria-current="page"] {
  color: var(--learn-accent);
  background: var(--border-ghost, #203830);
}
.post { max-width: 900px; padding: 0.5rem 0.75rem 3rem; overflow-wrap: anywhere; }
.post-title { letter-spacing: -0.035em; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.2; margin-block: 0 1.5rem; }
.attribution {
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  background: var(--learn-surface);
  border-left: 3px solid var(--learn-accent);
  border-radius: 0 0.5rem 0.5rem 0;
  font-size: 0.85rem;
  color: var(--learn-muted);
}
.attribution strong { color: var(--learn-text); }
.attribution p { margin-bottom: 0.25rem; }
.attribution ul { margin-block: 0.25rem 0.75rem; padding-left: 1.25rem; }
.attribution > a { display: block; }
.post-content { line-height: 1.85; }
.post-content h2, .post-content h3 { margin-top: 2.25rem; line-height: 1.3; }
.post-content img { max-width: 100%; height: auto; border-radius: 0.35rem; }
.post-content pre {
  padding: 1.25rem;
  background: var(--bg-base, #0b0f14);
  border: 1px solid var(--learn-border);
  border-radius: 0.5rem;
  overflow-x: auto;
  line-height: 1.6;
}
.post-content code { color: var(--accent-green, #a6e8ce); font-family: "Fira Code", monospace; font-size: 0.85em; }
.post-content table { display: block; max-width: 100%; overflow-x: auto; margin-bottom: 1.5rem; }
.post-content td, .post-content th { padding: 0.5rem 0.75rem; border: 1px solid var(--learn-border); }
.post-content .rouge-table { display: table; margin: 0; width: 100%; }
.post-content .rouge-table td { border: 0; padding: 0 !important; }
.post-content .rouge-table pre { margin: 0; padding: 0; border: 0; }
.post-content .rouge-table .gutter { padding-right: 1.25rem !important; color: var(--learn-muted); user-select: none; }
.highlight .c, .highlight .c1, .highlight .cm { color: #98a6ba; }
.highlight .k, .highlight .kd, .highlight .kn { color: #d6acff; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #a6e8ce; }
.highlight .nf, .highlight .nc { color: #8ecbff; }
.highlight .m, .highlight .mi, .highlight .mf { color: #f0c88c; }
.post-content blockquote { padding-left: 1rem; border-left: 3px solid var(--learn-accent); color: var(--learn-muted); }
ul.tab { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; }
ul.tab a { display: block; padding: 0.4rem 1rem; border: 1px solid var(--learn-border); border-radius: 0.35rem; text-decoration: none; }
ul.tab .active a { background: var(--border-ghost, #203830); border-color: var(--learn-accent); }
ul.tab-content { list-style: none; padding: 0; }
ul.tab-content > li { display: none; }
ul.tab-content > li.active { display: block; }

@media (max-width: 767.98px) {
  .article-shell { grid-template-columns: minmax(0, 1fr); margin-top: 1rem; }
  .article-sidebar { position: static; }
  .article-nav { max-height: 18rem; }
  .post { padding-inline: 0.5rem; }
}
