:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-2: #eef4fb;
  --surface-3: #e7eff9;
  --text: #1c2734;
  --muted: #617083;
  --line: #d7e1ee;
  --brand: #176fc1;
  --brand-2: #0b4f91;
  --brand-3: #79b8ef;
  --accent: #e7a93a;
  --good: #19734a;
  --warn: #9b6416;
  --danger: #a33b3b;
  --code: #102235;
  --shadow: 0 18px 45px rgba(28, 57, 88, .10);
  --radius: 16px;
  --sidebar: 286px;
  --content: 920px;
}

html[data-theme="dark"] {
  --bg: #101821;
  --surface: #17222e;
  --surface-2: #1d2b39;
  --surface-3: #243546;
  --text: #edf5ff;
  --muted: #adbac9;
  --line: #314457;
  --brand: #58a9ef;
  --brand-2: #8dc8f7;
  --brand-3: #2c7fc7;
  --accent: #f0bd57;
  --good: #70d4a7;
  --warn: #f0c471;
  --danger: #f08a8a;
  --code: #0c131b;
  --shadow: 0 18px 45px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% -10%, rgba(23,111,193,.10), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-2); }
img { max-width: 100%; }
button, input { font: inherit; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -100px;
  z-index: 999;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: .7rem 1rem;
  border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background:
    linear-gradient(90deg, rgba(5,41,78,.97), rgba(10,85,153,.97));
  color: #fff;
  box-shadow: 0 8px 28px rgba(6, 41, 74, .18);
}
.topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(30deg, rgba(255,255,255,.16) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.16) 87.5%, rgba(255,255,255,.16)),
    linear-gradient(150deg, rgba(255,255,255,.16) 12%, transparent 12.5%, transparent 87%, rgba(255,255,255,.16) 87.5%, rgba(255,255,255,.16));
  background-size: 44px 76px;
}
.topbar-inner {
  position: relative;
  z-index: 1;
  max-width: 1500px;
  margin: 0 auto;
  min-height: 72px;
  padding: 0 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #66b9ff, #0b61a8);
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.32);
  font-size: .88rem;
}
.brand small { display: block; font-size: .68rem; font-weight: 600; opacity: .75; letter-spacing: .04em; text-transform: uppercase; }
.topbar-spacer { flex: 1; }

.search-wrap { position: relative; width: min(420px, 38vw); }
.search-input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 12px;
  padding: .67rem .9rem .67rem 2.4rem;
  outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,.7); }
.search-input:focus { border-color: rgba(255,255,255,.65); background: rgba(255,255,255,.18); }
.search-icon { position: absolute; left: .85rem; top: .65rem; opacity: .75; }
.search-results {
  position: absolute;
  top: calc(100% + .55rem);
  left: 0;
  right: 0;
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--text);
  max-height: 420px;
  overflow-y: auto;
}
.search-results.is-open { display: block; }
.search-result { display: block; padding: .8rem .95rem; text-decoration: none; border-bottom: 1px solid var(--line); }
.search-result:last-child { border-bottom: 0; }
.search-result strong { display: block; color: var(--text); }
.search-result span { display: block; color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.search-empty { padding: .9rem; color: var(--muted); }

.icon-btn {
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.10);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.17); }
.menu-btn { display: none; }

.layout {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) 230px;
  gap: 2rem;
  padding: 2rem 1.2rem 4rem;
}
.sidebar {
  position: sticky;
  top: 94px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding-right: .2rem;
}
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .8rem;
}
.nav-group + .nav-group { margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.nav-label {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 800;
  padding: .35rem .65rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--text);
  text-decoration: none;
  padding: .48rem .65rem;
  border-radius: 9px;
  font-size: .92rem;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: linear-gradient(90deg, rgba(23,111,193,.14), rgba(23,111,193,.04)); color: var(--brand-2); font-weight: 750; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.nav-link.active .nav-dot { background: var(--brand); box-shadow: 0 0 0 4px rgba(23,111,193,.12); }
.sidebar-help { margin-top: 1rem; padding: .8rem; color: var(--muted); font-size: .8rem; }
.sidebar-help a { font-weight: 700; }

main { min-width: 0; }
.article {
  max-width: var(--content);
  margin: 0 auto;
}
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.6rem, 3vw, 2.7rem);
  background:
    radial-gradient(circle at 90% 0%, rgba(113,184,239,.20), transparent 20rem),
    linear-gradient(145deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 1.6rem;
}
.hero::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -120px;
  width: 280px;
  height: 280px;
  border: 34px solid rgba(23,111,193,.08);
  border-radius: 50%;
}
.eyebrow { color: var(--brand); font-weight: 800; text-transform: uppercase; letter-spacing: .09em; font-size: .75rem; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.08; margin: .45rem 0 .8rem; letter-spacing: -.035em; }
.hero p { max-width: 760px; font-size: 1.06rem; color: var(--muted); margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border-radius: 10px;
  padding: .65rem .9rem;
  font-weight: 750;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.btn-primary { background: linear-gradient(145deg, var(--brand), var(--brand-2)); color: white; border-color: transparent; }
.btn-primary:hover { color: white; filter: brightness(1.05); }

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(28,57,88,.05);
  padding: clamp(1.25rem, 2vw, 2rem);
  margin: 1.25rem 0;
}
.section > :first-child { margin-top: 0; }
.section > :last-child { margin-bottom: 0; }

h2 { font-size: 1.62rem; line-height: 1.22; letter-spacing: -.02em; margin: 2.2rem 0 .8rem; scroll-margin-top: 95px; }
.section h2:first-child { margin-top: 0; }
h3 { font-size: 1.15rem; line-height: 1.35; margin: 1.5rem 0 .55rem; scroll-margin-top: 95px; }
h4 { margin-bottom: .35rem; }
p { margin: .75rem 0 1rem; }
ul, ol { padding-left: 1.35rem; }
li + li { margin-top: .35rem; }

.lead-grid, .card-grid, .two-col, .three-col {
  display: grid;
  gap: 1rem;
}
.lead-grid { grid-template-columns: repeat(3, 1fr); margin: 1.25rem 0; }
.card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.05rem;
}
.card h3, .card h4 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.card-kicker { color: var(--brand); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.callout {
  border-left: 4px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 12px 12px 0;
  padding: .95rem 1rem;
  margin: 1rem 0;
}
.callout strong:first-child { display: inline-block; margin-bottom: .15rem; }
.callout.tip { border-color: var(--good); }
.callout.warn { border-color: var(--warn); }
.callout.danger { border-color: var(--danger); }
.callout.beginner { border-color: var(--accent); }

.badges { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}
.badge.beginner { color: #86550d; background: #fff5dc; border-color: #f0d89a; }
html[data-theme="dark"] .badge.beginner { color: #ffd88d; background: #3a2f1b; border-color: #6b5426; }
.badge.advanced { color: var(--brand-2); }

.steps { counter-reset: guide-step; list-style: none; padding: 0; margin: 1rem 0; }
.steps > li {
  counter-increment: guide-step;
  position: relative;
  padding: .85rem .9rem .85rem 3.3rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  margin: .65rem 0;
}
.steps > li::before {
  content: counter(guide-step);
  position: absolute;
  left: .85rem;
  top: .78rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-weight: 800;
  font-size: .82rem;
}

kbd {
  display: inline-block;
  padding: .05rem .36rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 700 .82em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .07rem .3rem;
}
pre {
  position: relative;
  overflow: auto;
  background: var(--code);
  color: #ecf6ff;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  padding: 1rem;
  line-height: 1.55;
}
pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.copy-btn {
  position: absolute;
  right: .55rem;
  top: .55rem;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  color: #fff;
  border-radius: 7px;
  padding: .28rem .55rem;
  cursor: pointer;
  font-size: .72rem;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: .72rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

.guide-shot {
  margin: 1.25rem 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  background: var(--surface-2);
}
.guide-shot img { width: 100%; display: block; background: #fff; }
.guide-shot figcaption { padding: .7rem .9rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; background: var(--surface); }

.advanced-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  margin: 1rem 0;
  overflow: hidden;
}
.advanced-box > summary {
  cursor: pointer;
  list-style: none;
  padding: .85rem 1rem;
  font-weight: 800;
  color: var(--brand-2);
}
.advanced-box > summary::-webkit-details-marker { display: none; }
.advanced-box > summary::before { content: "▸"; display: inline-block; margin-right: .5rem; transition: transform .15s ease; }
.advanced-box[open] > summary::before { transform: rotate(90deg); }
.advanced-inner { padding: 0 1rem 1rem; border-top: 1px solid var(--line); }

.toc {
  position: sticky;
  top: 94px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding: .85rem;
  border-left: 1px solid var(--line);
}
.toc-title { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; margin-bottom: .55rem; }
.toc a { display: block; color: var(--muted); font-size: .82rem; text-decoration: none; padding: .26rem 0; }
.toc a:hover { color: var(--brand); }
.toc a.toc-h3 { padding-left: .7rem; font-size: .78rem; }

.next-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.next-link {
  display: block;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: .9rem 1rem;
  text-decoration: none;
}
.next-link small { color: var(--muted); display: block; }
.next-link strong { color: var(--text); }
.next-link.next { text-align: right; }

.page-footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 1.2rem 2.5rem;
  color: var(--muted);
  font-size: .8rem;
}
.footer-inner { border-top: 1px solid var(--line); padding-top: 1rem; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

.home-quicklinks { display: grid; grid-template-columns: repeat(4,1fr); gap: .85rem; }
.quicklink { text-decoration: none; border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 1rem; color: var(--text); }
.quicklink:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(28,57,88,.08); }
.quicklink strong { display: block; margin-bottom: .25rem; }
.quicklink span { display: block; color: var(--muted); font-size: .84rem; }

.faq details { border-top: 1px solid var(--line); padding: .8rem 0; }
.faq details:first-child { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 780; }
.faq details p:last-child { margin-bottom: 0; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: var(--sidebar) minmax(0,1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .topbar-inner { min-height: 64px; }
  .brand small { display: none; }
  .search-wrap { width: auto; flex: 1; }
  .menu-btn { display: inline-grid; place-items: center; }
  .layout { display: block; padding-top: 1rem; }
  .sidebar {
    position: fixed;
    z-index: 150;
    left: .75rem;
    top: 74px;
    width: min(330px, calc(100vw - 1.5rem));
    max-height: calc(100vh - 86px);
    transform: translateX(calc(-100% - 2rem));
    transition: transform .2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 64px 0 0; z-index: 140; background: rgba(0,0,0,.38); }
  .lead-grid, .three-col { grid-template-columns: 1fr; }
  .home-quicklinks { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 620px) {
  .topbar-inner { padding: 0 .7rem; gap: .55rem; }
  .brand-text { display: none; }
  .search-input { padding-left: 2.1rem; }
  .layout { padding-left: .7rem; padding-right: .7rem; }
  .section, .hero { border-radius: 15px; padding: 1.15rem; }
  .card-grid, .two-col, .next-links { grid-template-columns: 1fr; }
  .next-link.next { text-align: left; }
  .home-quicklinks { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
  .page-footer { padding-left: .7rem; padding-right: .7rem; }
}

@media print {
  .topbar, .sidebar, .toc, .next-links, .page-footer, .copy-btn { display: none !important; }
  .layout { display: block; padding: 0; }
  .article { max-width: none; }
  .section, .hero { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
