:root {
  color-scheme: light;
  --navy-950: #050d19;
  --navy-900: #081426;
  --navy-800: #10233d;
  --blue: #4f7cff;
  --blue-soft: #edf2ff;
  --teal: #2dd4bf;
  --ink: #142238;
  --muted: #64748b;
  --surface: #ffffff;
  --surface-soft: #f6f8fc;
  --border: #dbe3ef;
  --code: #0d1b2e;
  --topbar-height: 64px;
  --sidebar-width: 276px;
  --shadow: 0 18px 55px rgba(8, 20, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eef8;
  --muted: #9fb0c8;
  --surface: #081426;
  --surface-soft: #0d1b2e;
  --border: #203754;
  --blue-soft: #152b51;
  --code: #050d19;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: #315ee9; }
button, input { font: inherit; }
button { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: 3px;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: calc(var(--sidebar-width) - 24px);
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.topbar-brand img { border-radius: 8px; }
.topbar-brand em { color: var(--muted); font-size: 13px; font-style: normal; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-button, .github-link {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover, .github-link:hover { border-color: var(--border); background: var(--surface-soft); color: var(--ink); }
.icon-button svg, .github-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.github-link svg { fill: currentColor; stroke: none; }
.menu-button { display: none; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

.search-trigger {
  width: min(260px, 28vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 9px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.search-trigger:hover { border-color: color-mix(in srgb, var(--blue) 55%, var(--border)); }
.search-trigger svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.search-trigger span { flex: 1; }
kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--muted); font-size: 12px; }

.sidebar {
  position: fixed;
  inset: var(--topbar-height) auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  padding: 24px 20px 40px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-intro { display: flex; align-items: center; gap: 8px; margin: 0 8px 26px; color: var(--muted); font-size: 12px; }
.version-pill { padding: 2px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.nav-section + .nav-section { margin-top: 25px; }
.nav-section h2 { margin: 0 10px 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.nav-section ul { margin: 0; padding: 0; list-style: none; }
.nav-section a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 570; text-decoration: none; }
.nav-section a:hover { background: var(--surface-soft); color: var(--ink); }
.nav-section a[aria-current="page"] { background: var(--blue-soft); color: var(--blue); font-weight: 750; }
.nav-section img { width: 23px; height: 23px; border-radius: 6px; }

.main-shell { min-height: 100vh; margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 54px) clamp(28px, 6vw, 88px) 42px; }
.doc-content { width: min(100%, 820px); margin: 0 auto; }
.home-content { width: min(100%, 1080px); }
.eyebrow { margin-bottom: 12px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }

.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 { color: var(--ink); line-height: 1.2; letter-spacing: -0.025em; }
.doc-content h1 { margin: 0 0 24px; font-size: clamp(34px, 5vw, 52px); }
.doc-content h2 { margin: 54px 0 18px; padding-top: 5px; font-size: 29px; }
.doc-content h3 { margin: 34px 0 12px; font-size: 21px; }
.doc-content h4 { margin: 26px 0 10px; font-size: 17px; }
.doc-content p, .doc-content li { color: color-mix(in srgb, var(--ink) 84%, var(--muted)); }
.doc-content > p:first-of-type { font-size: 18px; color: var(--muted); }
.doc-content ul, .doc-content ol { padding-left: 1.35rem; }
.doc-content li + li { margin-top: 6px; }
.doc-content img { max-width: 100%; height: auto; }
.doc-content hr { margin: 48px 0; border: 0; border-top: 1px solid var(--border); }
.heading-anchor { margin-left: 8px; color: var(--muted); opacity: 0; text-decoration: none; }
h2:hover .heading-anchor, h3:hover .heading-anchor, h4:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }

.doc-content blockquote {
  margin: 28px 0;
  padding: 16px 20px;
  border: 1px solid color-mix(in srgb, var(--blue) 32%, var(--border));
  border-left: 4px solid var(--blue);
  border-radius: 0 12px 12px 0;
  background: var(--blue-soft);
}
.doc-content blockquote p { margin: 0; color: var(--ink); }

.doc-content table { display: block; width: 100%; margin: 28px 0; overflow-x: auto; border-collapse: collapse; font-size: 14px; }
.doc-content th, .doc-content td { padding: 12px 14px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.doc-content th { background: var(--surface-soft); color: var(--ink); font-weight: 750; }

.doc-content code { padding: 0.16em 0.38em; border-radius: 5px; background: var(--surface-soft); color: color-mix(in srgb, var(--blue) 80%, var(--ink)); font: 0.88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.doc-content pre { position: relative; margin: 24px 0; padding: 20px; overflow: auto; border: 1px solid #1c3554; border-radius: 12px; background: var(--code); box-shadow: 0 12px 28px rgba(5, 13, 25, 0.12); }
.doc-content pre code { padding: 0; background: transparent; color: #dbeafe; font-size: 13px; line-height: 1.65; }
.copy-button { position: absolute; top: 8px; right: 8px; padding: 5px 9px; border: 1px solid #31517c; border-radius: 6px; background: #10233d; color: #b9cae3; font-size: 11px; cursor: pointer; }
.copy-button:hover { color: white; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  gap: clamp(32px, 7vw, 90px);
  align-items: center;
  margin-bottom: 72px;
  padding: clamp(34px, 6vw, 68px);
  overflow: hidden;
  border: 1px solid #1b3556;
  border-radius: 24px;
  background: radial-gradient(circle at 82% 12%, rgba(45, 212, 191, .18), transparent 27%), radial-gradient(circle at 15% 92%, rgba(79, 124, 255, .22), transparent 36%), var(--navy-900);
  box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to right, transparent, black); }
.hero-copy, .hero-visual { position: relative; z-index: 1; }
.hero-badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid #31517c; border-radius: 999px; color: #b8c9e2; font-size: 12px; font-weight: 700; }
.hero-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.hero h1 { max-width: 650px; margin: 20px 0; color: white; font-size: clamp(42px, 6vw, 68px); line-height: 1.02; }
.hero h1 span { background: linear-gradient(100deg, #8aa7ff, var(--teal)); background-clip: text; color: transparent; }
.hero p { max-width: 620px; margin: 0; color: #b8c9e2 !important; font-size: 18px !important; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 45px; padding: 0 18px; border: 1px solid #31517c; border-radius: 10px; color: white; font-size: 14px; font-weight: 750; text-decoration: none; }
.button:hover { border-color: #587aa8; color: white; }
.button-primary { border-color: var(--blue); background: var(--blue); box-shadow: 0 8px 26px rgba(79,124,255,.28); }
.button-primary:hover { border-color: #7095ff; background: #648aff; }
.hero-visual { display: grid; place-items: center; }
.hero-visual img { width: min(100%, 290px); filter: drop-shadow(0 24px 35px rgba(0, 0, 0, .3)); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 26px 0 68px; }
.feature-card { min-height: 220px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(145deg, var(--surface), var(--surface-soft)); color: var(--ink); text-decoration: none; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.feature-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--blue) 50%, var(--border)); box-shadow: var(--shadow); color: var(--ink); }
.feature-card img { width: 48px; height: 48px; border-radius: 11px; }
.feature-card h3 { margin: 18px 0 8px; font-size: 20px; }
.feature-card p { margin: 0; color: var(--muted); font-size: 14px; }
.feature-card strong { display: block; margin-top: 18px; color: var(--blue); font-size: 13px; }

.architecture-panel { margin: 28px 0 68px; padding: clamp(20px, 4vw, 40px); border: 1px solid var(--border); border-radius: 18px; background: var(--surface-soft); }
.architecture-panel img { display: block; width: 100%; border-radius: 12px; }
.principles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 24px 0 64px; }
.principle { padding: 20px; border-left: 3px solid var(--teal); border-radius: 0 12px 12px 0; background: var(--surface-soft); }
.principle strong { display: block; margin-bottom: 4px; color: var(--ink); }
.principle span { color: var(--muted); font-size: 14px; }

.page-footer { width: min(100%, 820px); display: flex; justify-content: space-between; gap: 24px; margin: 80px auto 0; padding-top: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.home-content + .page-footer { width: min(100%, 1080px); }
.page-footer p { margin: 0; }
.page-footer a { font-weight: 650; text-decoration: none; }

.search-dialog { width: min(680px, calc(100vw - 32px)); max-height: min(680px, calc(100vh - 80px)); margin: 12vh auto 0; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 100px rgba(5,13,25,.35); }
.search-dialog::backdrop { background: rgba(5,13,25,.65); backdrop-filter: blur(5px); }
.search-panel { min-height: 190px; }
.search-box { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-box svg { width: 22px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 2; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 17px; }
.search-box button { padding: 3px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 11px; cursor: pointer; }
.search-status { padding: 22px; color: var(--muted); font-size: 13px; }
.search-results { max-height: 480px; margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
.search-results:empty { display: none; }
.search-result a { display: block; padding: 13px 14px; border-radius: 9px; color: var(--ink); text-decoration: none; }
.search-result a:hover, .search-result a:focus { background: var(--blue-soft); outline: 0; }
.search-result strong { display: block; }
.search-result span { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.nav-overlay { display: none; }

@media (max-width: 960px) {
  .topbar { padding: 0 14px; }
  .menu-button { display: grid; }
  .topbar-brand { min-width: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .nav-overlay { position: fixed; inset: var(--topbar-height) 0 0; z-index: 35; background: rgba(5,13,25,.48); }
  .nav-overlay.is-open { display: block; }
  .main-shell { margin-left: 0; padding-inline: clamp(20px, 5vw, 44px); }
}

@media (max-width: 720px) {
  .topbar-brand em, .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { width: 40px; justify-content: center; padding: 0; }
  .hero { grid-template-columns: 1fr; padding: 32px 24px; }
  .hero-visual { display: none; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature-card { min-height: auto; }
  .principles { grid-template-columns: 1fr; }
  .page-footer { flex-direction: column; }
}

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