
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #0b0a2e;
  --purple: #6b1fa8;
  --violet: #9b2dff;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --muted-strong: rgba(255, 255, 255, 0.65);
  --panel: #17142c;
  --ink: #f3f0ff;
  --ink-muted: rgba(243, 240, 255, 0.68);
  --article-link: #c4a1ff;
  --code-bg: rgba(155, 45, 255, 0.18);
  --pre-bg: #0e0c1c;
  --pre-text: #f4f0ff;
  --panel-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.07);
  --card-hover: rgba(255, 255, 255, 0.12);
  --search-bg: rgba(0, 0, 0, 0.25);
  --search-placeholder: rgba(255, 255, 255, 0.45);
  --dropdown-bg: #140f2c;
  --chip-bg: rgba(155, 45, 255, 0.22);
  --chip-text: rgba(255, 255, 255, 0.9);
  --bg:
    radial-gradient(1000px 700px at 100% 0%, rgba(155, 45, 255, 0.45), transparent 55%),
    radial-gradient(900px 600px at 0% 100%, rgba(20, 40, 140, 0.45), transparent 50%),
    linear-gradient(135deg, #07061f 0%, #0b0a2e 42%, #3a1470 100%);
  --grid-line: rgba(255, 255, 255, 0.035);
  --theme-toggle-bg: rgba(255, 255, 255, 0.08);
  --theme-toggle-border: rgba(255, 255, 255, 0.18);
  --card-shadow: none;
  --callout-info-bg: rgba(155, 45, 255, 0.14);
  --callout-info-border: rgba(197, 161, 255, 0.35);
  --callout-info-label: #d4b8ff;
  --callout-warn-bg: rgba(255, 170, 60, 0.12);
  --callout-warn-border: rgba(255, 180, 90, 0.35);
  --callout-warn-label: #ffc878;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --navy: #f4f2fb;
    --purple: #6b1fa8;
    --violet: #7c3aed;
    --text: #12101f;
    --muted: rgba(18, 16, 31, 0.68);
    --muted-strong: rgba(18, 16, 31, 0.55);
    --panel: #ffffff;
    --ink: #12101f;
    --ink-muted: #5a5670;
    --article-link: #5b21b6;
    --code-bg: #f1ecfb;
    --pre-bg: #16122a;
    --pre-text: #f4f0ff;
    --panel-shadow: 0 18px 48px rgba(40, 20, 80, 0.12);
    --line: rgba(18, 16, 31, 0.12);
    --line-soft: rgba(18, 16, 31, 0.08);
    --card: rgba(255, 255, 255, 0.82);
    --card-hover: #ffffff;
    --search-bg: rgba(255, 255, 255, 0.9);
    --search-placeholder: rgba(18, 16, 31, 0.45);
    --dropdown-bg: #ffffff;
    --chip-bg: rgba(124, 58, 237, 0.12);
    --chip-text: #5b21b6;
    --bg:
      radial-gradient(900px 600px at 100% 0%, rgba(155, 45, 255, 0.16), transparent 55%),
      radial-gradient(800px 500px at 0% 100%, rgba(59, 130, 246, 0.12), transparent 50%),
      linear-gradient(160deg, #f7f5ff 0%, #efeafc 45%, #e4dff7 100%);
    --grid-line: rgba(18, 16, 31, 0.045);
    --theme-toggle-bg: rgba(18, 16, 31, 0.05);
    --theme-toggle-border: rgba(18, 16, 31, 0.12);
    --card-shadow: 0 10px 28px rgba(40, 20, 80, 0.08);
    --callout-info-bg: #f3ebff;
    --callout-info-border: #d5b8ff;
    --callout-info-label: #6b1fa8;
    --callout-warn-bg: #fff4e8;
    --callout-warn-border: #ffd19a;
    --callout-warn-label: #a65b00;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --navy: #f4f2fb;
  --purple: #6b1fa8;
  --violet: #7c3aed;
  --text: #12101f;
  --muted: rgba(18, 16, 31, 0.68);
  --muted-strong: rgba(18, 16, 31, 0.55);
  --panel: #ffffff;
  --ink: #12101f;
  --ink-muted: #5a5670;
  --article-link: #5b21b6;
  --code-bg: #f1ecfb;
  --pre-bg: #16122a;
  --pre-text: #f4f0ff;
  --panel-shadow: 0 18px 48px rgba(40, 20, 80, 0.12);
  --line: rgba(18, 16, 31, 0.12);
  --line-soft: rgba(18, 16, 31, 0.08);
  --card: rgba(255, 255, 255, 0.82);
  --card-hover: #ffffff;
  --search-bg: rgba(255, 255, 255, 0.9);
  --search-placeholder: rgba(18, 16, 31, 0.45);
  --dropdown-bg: #ffffff;
  --chip-bg: rgba(124, 58, 237, 0.12);
  --chip-text: #5b21b6;
  --bg:
    radial-gradient(900px 600px at 100% 0%, rgba(155, 45, 255, 0.16), transparent 55%),
    radial-gradient(800px 500px at 0% 100%, rgba(59, 130, 246, 0.12), transparent 50%),
    linear-gradient(160deg, #f7f5ff 0%, #efeafc 45%, #e4dff7 100%);
  --grid-line: rgba(18, 16, 31, 0.045);
  --theme-toggle-bg: rgba(18, 16, 31, 0.05);
  --theme-toggle-border: rgba(18, 16, 31, 0.12);
  --card-shadow: 0 10px 28px rgba(40, 20, 80, 0.08);
  --callout-info-bg: #f3ebff;
  --callout-info-border: #d5b8ff;
  --callout-info-label: #6b1fa8;
  --callout-warn-bg: #fff4e8;
  --callout-warn-border: #ffd19a;
  --callout-warn-label: #a65b00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
  background-attachment: fixed;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 55% at 50% 30%, #000 15%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text);
}

.brand img,
.footer-brand img {
  height: 42px;
  width: auto;
}

.logo-on-light { display: none !important; }
.logo-on-dark { display: block !important; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-on-dark { display: none !important; }
  :root:not([data-theme="dark"]) .logo-on-light { display: block !important; }
}
html[data-theme="light"] .logo-on-dark { display: none !important; }
html[data-theme="light"] .logo-on-light { display: block !important; }
html[data-theme="dark"] .logo-on-dark { display: block !important; }
html[data-theme="dark"] .logo-on-light { display: none !important; }

.brand-text {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 280px;
  justify-content: flex-end;
  max-width: 520px;
}

.theme-toggle {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(155, 45, 255, 0.45);
}
.theme-toggle svg { width: 1.1rem; height: 1.1rem; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.search-wrap {
  flex: 1 1 220px;
  max-width: 420px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--search-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}

.search-wrap input::placeholder { color: var(--search-placeholder); }
.search-wrap input:focus {
  border-color: rgba(155, 45, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(155, 45, 255, 0.2);
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--dropdown-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  z-index: 20;
  max-height: 360px;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}

.search-results.open { display: block; }

.search-results a {
  display: block;
  padding: 0.85rem 1rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}

.search-results a:hover { background: rgba(155, 45, 255, 0.12); }
.search-results .meta { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.search-results .empty { padding: 1rem; color: var(--muted); font-size: 0.9rem; }

.hero {
  margin-bottom: 2.5rem;
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 0.75rem;
}

.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 42ch;
  line-height: 1.55;
}

.rule {
  width: 64px;
  height: 3px;
  margin: 1rem 0 1.25rem;
  background: linear-gradient(90deg, var(--violet), transparent);
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-strong);
  margin-bottom: 1rem;
}

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

/* Homepage: one row on wide screens, wrap (no horizontal scroll) when narrower */
.topic-grid.topic-grid-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.topic-grid.topic-grid-row .topic-card {
  min-width: 0;
  padding: 1rem 0.9rem;
}

.topic-grid.topic-grid-row .topic-card h2 {
  font-size: 0.95rem;
  line-height: 1.25;
}

.topic-grid.topic-grid-row .topic-card .count {
  font-size: 0.8rem;
}

.topic-grid.topic-grid-row .topic-card .children {
  display: none;
}

@media (max-width: 1100px) {
  .topic-grid.topic-grid-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .topic-grid.topic-grid-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 420px) {
  .topic-grid.topic-grid-row {
    grid-template-columns: 1fr;
  }
}

.topic-card, .article-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem 1.25rem;
  box-shadow: var(--card-shadow, none);
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.topic-card:hover, .article-card:hover {
  background: var(--card-hover);
  border-color: rgba(155, 45, 255, 0.45);
  transform: translateY(-2px);
}

.topic-card h2, .article-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.45rem;
}

.topic-card .count, .article-card .meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.topic-card .children {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
}

.article-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.article-list .article-card h2 {
  font-size: 1.05rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.breadcrumbs a { color: var(--text); text-decoration: none; opacity: 0.85; }
.breadcrumbs a:hover { opacity: 1; text-decoration: underline; }
.breadcrumbs span.sep { opacity: 0.4; }

.article-shell {
  background: var(--panel);
  color: var(--ink);
  border-radius: 22px;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  box-shadow: var(--panel-shadow);
  border: 1px solid var(--line-soft);
  animation: rise 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.article-shell h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.6rem;
  color: var(--ink);
}

.article-meta {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}

.article-body {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink);
}

.article-body > * + * { margin-top: 1rem; }

.article-body h2, .article-body h3, .article-body h4 {
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-top: 1.6rem;
}

.article-body h2 { font-size: 1.35rem; }
.article-body h3 { font-size: 1.15rem; }
.article-body h4 { font-size: 1.05rem; }

.article-body a { color: var(--article-link); }
.article-body code, .article-body kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 5px;
}

.article-body pre {
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 1rem 1.1rem;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

.article-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.article-body img, .article-body figure img,
.callout-body img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 10px;
  display: block;
}

.article-body figure {
  margin: 1.25rem 0;
  text-align: center;
}
.article-body figure.aligncenter img,
.article-body .aligncenter img {
  margin-left: auto;
  margin-right: auto;
}
.article-body ul, .article-body ol { padding-left: 1.3rem; }
.article-body li img {
  margin-top: 0.65rem;
  margin-bottom: 0.65rem;
}
.article-body li + li { margin-top: 0.35rem; }

.callout {
  border-radius: 12px;
  padding: 1rem 1.1rem;
  border: 1px solid transparent;
}
.article-body video,
.callout-body video {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  background: #16122a;
  margin: 1rem 0;
}
.article-body asciinema-player,
.article-body .asciinema-player-container {
  max-width: 100%;
  margin: 1rem 0;
  display: block;
}


.callout-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.callout-info {
  background: var(--callout-info-bg);
  border-color: var(--callout-info-border);
}
.callout-info .callout-label { color: var(--callout-info-label); }

.callout-warning {
  background: var(--callout-warn-bg);
  border-color: var(--callout-warn-border);
}
.callout-warning .callout-label { color: var(--callout-warn-label); }

.site-footer {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-top {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) 2fr;
  gap: 2rem 2.5rem;
  padding-bottom: 1.75rem;
}
.footer-brand p {
  margin-top: 0.9rem;
  line-height: 1.55;
  max-width: 34ch;
  color: var(--muted);
}
.footer-brand img {
  height: 40px;
  width: auto;
}
.footer-cta {
  display: inline-block;
  margin-top: 1rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px solid var(--violet);
  padding-bottom: 0.15rem;
}
.footer-cta:hover { opacity: 0.9; }
.footer-cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
}
.footer-col h3 {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-col li + li { margin-top: 0.45rem; }
.footer-col a {
  color: var(--muted);
  text-decoration: none;
}
.footer-col a:hover { color: var(--text); }
.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.9rem;
  margin-top: 1rem;
}
.footer-social a {
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-social a:hover { color: var(--text); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.8rem;
}
.footer-bottom a {
  color: var(--muted);
  text-decoration: none;
}
.footer-bottom a:hover { color: var(--text); }

@media (max-width: 900px) {
  .footer-top { grid-template-columns: 1fr; }
  .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .footer-cols { grid-template-columns: 1fr; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

.asciinema-embed {
  position: relative;
  margin: 1.25rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: transparent;
  line-height: 0;
}
.asciinema-embed .asciinema-player-container,
.asciinema-embed asciinema-player,
.asciinema-embed .ap-wrapper,
.asciinema-embed iframe {
  display: block;
  width: 100% !important;
  max-width: 100%;
  margin: 0 !important;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
}
.asciinema-embed .asciinema-player,
.asciinema-embed .ap-player {
  border-radius: 12px;
  overflow: hidden;
}


