:root {
  --bg: #f4f6fb;
  --ink: #191b22;
  --muted: #626977;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --line: #dfe4ef;
  --code-bg: #17191f;
  --code-ink: #f4f7ff;
  --brand: #2f7cff;
  --teal: #19a896;
  --coral: #ef7355;
  --shadow: 0 18px 48px rgba(34, 38, 48, 0.11);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #101219;
  --ink: #eef2fb;
  --muted: #aab3c2;
  --panel: #171a23;
  --panel-soft: #1d2230;
  --line: #2a3040;
  --code-bg: #0b0d12;
  --code-ink: #f3f7ff;
  --brand: #77a6ff;
  --teal: #35d0bd;
  --coral: #ff9478;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --panel-border: rgba(74, 86, 112, 0.42);
  --panel-border-soft: rgba(74, 86, 112, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(47, 124, 255, 0.08), rgba(25, 168, 150, 0.04) 320px, transparent 560px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(119, 166, 255, 0.14), rgba(53, 208, 189, 0.07) 320px, transparent 600px),
    var(--bg);
}

a {
  color: #1e63d6;
  text-decoration: none;
}

:root[data-theme="dark"] a {
  color: #8fb7ff;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(223, 228, 239, 0.9);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .site-header {
  background: rgba(18, 20, 28, 0.88);
  border-bottom-color: rgba(48, 55, 70, 0.9);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  color: #343944;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 650;
}

:root[data-theme="dark"] .top-nav a {
  color: #dce4f4;
}

.top-nav a:hover {
  background: #edf2ff;
  text-decoration: none;
}

:root[data-theme="dark"] .top-nav a:hover {
  background: #242b3b;
}

.top-nav .download-link {
  color: #ffffff;
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(47, 124, 255, 0.26);
}

:root[data-theme="dark"] .top-nav .download-link {
  color: #101219;
  background: #9abbff;
}

.top-nav .download-link:hover {
  background: #1e67df;
}

:root[data-theme="dark"] .top-nav .download-link:hover {
  background: #b1c9ff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  min-height: 40px;
  padding: 5px 11px 5px 6px;
  color: #263041;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(201, 211, 229, 0.92);
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 8px 22px rgba(36, 44, 62, 0.1);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.theme-toggle::before {
  content: "";
  display: block;
  width: 1px;
  height: 24px;
  margin-left: -14px;
  margin-right: 6px;
  background: var(--line);
}

.theme-toggle:hover {
  background: #ffffff;
  border-color: rgba(47, 124, 255, 0.38);
  box-shadow: 0 10px 26px rgba(47, 124, 255, 0.16);
  transform: translateY(-1px);
}

:root[data-theme="dark"] .theme-toggle {
  color: #eef4ff;
  background: rgba(30, 35, 48, 0.82);
  border-color: rgba(82, 94, 120, 0.95);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.26);
}

:root[data-theme="dark"] .theme-toggle:hover {
  background: #252c3d;
  border-color: rgba(119, 166, 255, 0.42);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.theme-toggle-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 58px;
  height: 30px;
  padding: 0 8px;
  color: #6d7482;
  background: linear-gradient(135deg, #f6d876, #f7a66f);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

:root[data-theme="dark"] .theme-toggle-track {
  color: #aeb8cb;
  background: linear-gradient(135deg, #26375f, #181c28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.theme-toggle-sun,
.theme-toggle-moon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
}

.theme-toggle-thumb {
  position: absolute;
  z-index: 1;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 3px 9px rgba(20, 24, 34, 0.24);
  transition: transform 180ms ease, background 180ms ease;
}

:root[data-theme="dark"] .theme-toggle-thumb {
  background: #eef4ff;
  transform: translateX(28px);
}

.theme-toggle-text {
  min-width: 36px;
  text-align: left;
}

.page-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
  width: min(1240px, calc(100% - 48px));
  margin: 34px auto 46px;
}

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(223, 228, 239, 0.95);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(34, 38, 48, 0.07);
}

:root[data-theme="dark"] .sidebar {
  background: rgba(23, 26, 35, 0.78);
  border-color: var(--panel-border-soft);
}

.sidebar-section + .sidebar-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar a {
  display: block;
  padding: 8px 10px;
  color: #303642;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}

:root[data-theme="dark"] .sidebar a {
  color: #dce4f4;
}

.sidebar a:hover {
  background: #edf2ff;
  color: #174ca8;
  text-decoration: none;
}

:root[data-theme="dark"] .sidebar a:hover {
  background: #242b3b;
  color: #b9ceff;
}

.content {
  min-width: 0;
}

.doc-card {
  min-height: 72vh;
  padding: clamp(26px, 5vw, 56px);
  background: var(--panel);
  border: 1px solid rgba(223, 228, 239, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .doc-card {
  border-color: var(--panel-border);
}

.doc-card > :first-child {
  margin-top: 0;
}

.doc-card h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

.doc-card h2 {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 26px;
  line-height: 1.2;
}

.doc-card h3 {
  margin-top: 28px;
  font-size: 20px;
}

.doc-card p {
  max-width: 850px;
}

.doc-card ul,
.doc-card ol {
  max-width: 860px;
  padding-left: 24px;
}

.doc-card li + li {
  margin-top: 5px;
}

.doc-card strong {
  font-weight: 750;
}

.doc-card hr {
  height: 1px;
  border: 0;
  background: var(--line);
}

.doc-card blockquote {
  margin: 24px 0;
  padding: 14px 18px;
  color: #344050;
  background: #eef7f5;
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
}

:root[data-theme="dark"] .doc-card blockquote {
  color: #dce6f5;
  background: #1b302f;
}

.doc-card code {
  padding: 2px 6px;
  color: #242834;
  background: #eef2f8;
  border-radius: 6px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

:root[data-theme="dark"] .doc-card code {
  color: #e9effb;
  background: #252b38;
}

.doc-card pre {
  max-width: 100%;
  overflow: auto;
  padding: 18px;
  color: var(--code-ink);
  background: var(--code-bg);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.doc-card pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.doc-card table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  margin: 22px 0;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.doc-card th,
.doc-card td {
  padding: 11px 13px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.doc-card th {
  color: #20242c;
  background: #f0f4fb;
  font-size: 14px;
}

:root[data-theme="dark"] .doc-card th {
  color: #f3f6fd;
  background: #222838;
}

.doc-card tr:last-child td {
  border-bottom: 0;
}

.doc-card a[href$=".md"],
.doc-card a[href$=".html"] {
  font-weight: 650;
}

.doc-card h1 + p {
  color: #3e4552;
  font-size: 19px;
}

:root[data-theme="dark"] .doc-card h1 + p {
  color: #cbd4e4;
}

.doc-card h2 + ul {
  padding: 18px 22px 18px 34px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 28px 24px 42px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 900px) {
  .site-header {
    position: static;
    align-items: flex-start;
    grid-template-columns: 1fr;
    padding: 16px 20px;
  }

  .top-nav {
    order: 2;
    justify-content: flex-start;
  }

  .page-shell {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 760px);
    margin-top: 18px;
  }

  .sidebar {
    position: static;
    order: 2;
  }

  .doc-card {
    padding: 24px 18px;
  }
}

@media (max-width: 560px) {
  .top-nav a {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 13px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .doc-card h1 {
    font-size: 34px;
  }
}
