:root {
  color-scheme: light;
  --background: #fbfbf8;
  --surface: #ffffff;
  --surface-muted: #f5f3ee;
  --surface-code: #f6f8fa;
  --header-background: rgba(255, 255, 255, 0.96);
  --text: #1f2328;
  --muted: #59605d;
  --faint: #7b827d;
  --border: #ddd9cc;
  --border-strong: #c8c2b4;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --accent-warm: #b45309;
  --code-border: #d8dee4;
  --inline-code-border: rgba(216, 222, 228, 0.8);
  --shadow: 0 2px 8px rgba(31, 35, 40, 0.08);
  --diagram-filter: none;
  --syntax-text: #24292f;
  --syntax-comment: #6a737d;
  --syntax-keyword: #cf222e;
  --syntax-string: #0a3069;
  --syntax-number: #0550ae;
  --syntax-name: #8250df;
  --syntax-variable: #953800;
  --syntax-delete-text: #82071e;
  --syntax-delete-background: #ffebe9;
  --syntax-insert-text: #116329;
  --syntax-insert-background: #dafbe1;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #11120f;
  --surface: #181916;
  --surface-muted: #20211d;
  --surface-code: #151612;
  --header-background: rgba(17, 18, 15, 0.96);
  --text: #f0eee7;
  --muted: #b9b7ad;
  --faint: #8f8c82;
  --border: #313229;
  --border-strong: #4b4c40;
  --accent: #49c5b6;
  --accent-strong: #7ddbd0;
  --accent-warm: #d7a05c;
  --code-border: #383a32;
  --inline-code-border: rgba(80, 83, 72, 0.85);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  --diagram-filter: invert(0.92) hue-rotate(180deg) saturate(0.9) brightness(0.95);
  --syntax-text: #d7dacd;
  --syntax-comment: #8e9386;
  --syntax-keyword: #ff8f84;
  --syntax-string: #9bd3ff;
  --syntax-number: #7cc7ff;
  --syntax-name: #d7b7ff;
  --syntax-variable: #e6b36d;
  --syntax-delete-text: #ffd4cf;
  --syntax-delete-background: #5a1917;
  --syntax-insert-text: #bdf3c1;
  --syntax-insert-background: #173f24;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
}

[hidden] {
  display: none !important;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: 0;
  height: 2px;
  background: var(--accent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--header-background);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 750;
}

.brand img {
  flex: none;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 14px;
}

.top-nav a {
  color: var(--muted);
}

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

.search-open,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.search-open:hover,
.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.search-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.theme-toggle-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.theme-toggle-icon::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
}

:root[data-theme="dark"] .theme-toggle-icon::after {
  background: transparent;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 880px) 220px;
  gap: 36px;
  width: min(1420px, calc(100% - 40px));
  margin: 0 auto;
}

.sidebar,
.toc {
  position: sticky;
  top: 65px;
  align-self: start;
  height: calc(100vh - 65px);
  overflow: auto;
}

.sidebar {
  padding: 32px 28px 48px 0;
  border-right: 1px solid var(--border);
}

.toc {
  padding: 32px 0 48px 0;
}

.toc p,
.nav-section p {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.nav-section {
  display: grid;
  gap: 3px;
  margin-bottom: 26px;
}

.nav-section a,
.toc a {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.nav-section a {
  padding: 5px 0;
}

.toc a {
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--border);
}

.toc a[data-level="3"] {
  padding-left: 22px;
  font-size: 13px;
}

.nav-section a:hover,
.toc a:hover {
  color: var(--accent-strong);
}

.nav-section a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.page {
  min-width: 0;
  padding: 48px 0 84px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 22px;
  color: var(--faint);
  font-size: 13px;
}

.breadcrumbs a {
  color: var(--faint);
}

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

.breadcrumbs span::before {
  content: "/";
  margin-right: 6px;
  color: var(--border-strong);
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.25;
}

h1 {
  margin: 0 0 14px;
  font-size: 44px;
  letter-spacing: 0;
}

h2 {
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 25px;
}

h3 {
  margin-top: 30px;
  font-size: 19px;
}

h4 {
  margin-top: 24px;
  font-size: 16px;
}

p,
li {
  color: var(--muted);
}

p {
  margin: 14px 0;
}

li {
  margin: 6px 0;
}

strong {
  color: var(--text);
}

hr {
  height: 1px;
  border: 0;
  background: var(--border);
}

table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 24px 0;
}

th,
td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-muted);
  color: var(--text);
}

code {
  padding: 2px 5px;
  border: 1px solid var(--inline-code-border);
  border-radius: 5px;
  background: var(--surface-code);
  color: var(--text);
  font-size: 0.92em;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 0;
  background: transparent;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.highlight,
.code-frame {
  position: relative;
  margin: 18px 0;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--surface-code);
}

.highlight pre {
  margin: 0;
}

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.copy-code:hover {
  color: var(--text);
}

.highlight code {
  color: var(--syntax-text);
}

.highlight .c,
.highlight .cm,
.highlight .cp,
.highlight .c1,
.highlight .cs {
  color: var(--syntax-comment);
}

.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt {
  color: var(--syntax-keyword);
}

.highlight .s,
.highlight .sa,
.highlight .sb,
.highlight .sc,
.highlight .dl,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .s1,
.highlight .ss {
  color: var(--syntax-string);
}

.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .il,
.highlight .mo {
  color: var(--syntax-number);
}

.highlight .na,
.highlight .nc,
.highlight .nd,
.highlight .ne,
.highlight .nf,
.highlight .nx {
  color: var(--syntax-name);
}

.highlight .nb,
.highlight .bp,
.highlight .nv,
.highlight .vc,
.highlight .vg,
.highlight .vi,
.highlight .vm {
  color: var(--syntax-variable);
}

.highlight .o,
.highlight .ow {
  color: var(--syntax-number);
}

.highlight .gd {
  color: var(--syntax-delete-text);
  background: var(--syntax-delete-background);
}

.highlight .gi {
  color: var(--syntax-insert-text);
  background: var(--syntax-insert-background);
}

.lead {
  max-width: 760px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.55;
}

.search-dialog {
  width: min(720px, calc(100% - 32px));
  max-height: min(720px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.search-dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.search-form {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.search-form h2 {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  font-size: 18px;
}

.search-form div {
  flex: 1;
  min-width: 0;
}

.search-form input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-code);
  color: var(--text);
  font: inherit;
}

.search-form button,
.module-builder button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.search-form button:hover,
.module-builder button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.search-results {
  display: grid;
  gap: 0;
  max-height: 520px;
  overflow: auto;
}

.search-result {
  display: block;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
}

.search-result:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

.search-result strong {
  display: block;
  margin-bottom: 4px;
}

.search-result p {
  margin: 0;
  font-size: 14px;
}

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

.intro {
  margin: 0 0 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.quickstart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin: 24px 0;
}

.quickstart h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  font-size: 18px;
}

.quickstart > *,
.home-grid > *,
.link-grid > *,
.module-grid > *,
.path-grid > *,
.feature-grid > *,
.doc-grid > *,
.tool-grid > *,
.module-matrix > *,
.dependency-output > *,
.module-builder,
.dependency-output,
.code-frame {
  min-width: 0;
}

.home-grid,
.link-grid,
.module-grid,
.path-grid,
.feature-grid,
.doc-grid,
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.doc-grid.three,
.module-matrix {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-panel,
.link-card,
.module-card,
.path-card,
.callout,
.metadata-list div,
.decision,
.tool-card,
.module-choice,
.page-nav a {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.home-panel,
.link-card,
.module-card,
.path-card,
.decision,
.tool-card,
.module-choice,
.page-nav a {
  padding: 18px;
}

.link-card {
  color: inherit;
}

.link-card:hover,
.tool-card:hover,
.page-nav a:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.home-panel h2,
.link-card h3,
.module-card h3,
.path-card h3,
.decision h3,
.tool-card h3,
.module-choice h3 {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  font-size: 18px;
}

.home-panel p,
.link-card p,
.module-card p,
.path-card p,
.decision p,
.tool-card p,
.module-choice p {
  margin: 0;
}

.module-choice {
  display: grid;
  gap: 8px;
}

.module-choice label {
  display: flex;
  align-items: start;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.module-choice input {
  margin-top: 5px;
}

.module-builder {
  display: grid;
  gap: 18px;
  margin: 24px 0;
}

.module-builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dependency-output {
  display: grid;
  gap: 14px;
}

.page-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  color: inherit;
}

.page-nav span {
  display: block;
  color: var(--faint);
  font-size: 13px;
}

.page-nav strong {
  display: block;
}

.page-nav a:last-child {
  text-align: right;
}

.toc a[aria-current="true"] {
  color: var(--text);
  border-left-color: var(--accent);
}

.callout {
  margin: 24px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
}

.callout p {
  margin: 0;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

.metadata-list {
  display: grid;
  gap: 10px;
}

.metadata-list div {
  padding: 12px 14px;
}

.metadata-list strong {
  display: block;
}

.diagram {
  margin: 28px 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.diagram img {
  display: block;
  width: 100%;
  height: auto;
  filter: var(--diagram-filter);
}

.page-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 14px;
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .shell {
    display: block;
    width: min(100% - 32px, 900px);
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 20px 0 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .page {
    padding: 32px 0 64px;
  }

  .quickstart,
  .home-grid,
  .link-grid,
  .module-grid,
  .path-grid,
  .feature-grid,
  .doc-grid,
  .doc-grid.three,
  .tool-grid,
  .module-matrix,
  .page-nav {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }
}

@media (max-width: 520px) {
  .header-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .search-form {
    align-items: stretch;
    flex-direction: column;
  }

  .page-nav a:last-child {
    text-align: left;
  }
}
