:root {
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --line: #e2e8f0;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #111833;
    --surface-2: #19213f;
    --text: #e5e9f5;
    --muted: #b4bdd3;
    --subtle: #8b95ad;
    --line: #26304f;
    --ok: #34d399;
    --ok-bg: #0d2a22;
    --warn: #fbbf24;
    --warn-bg: #2a2110;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #111833;
  --surface-2: #19213f;
  --text: #e5e9f5;
  --muted: #b4bdd3;
  --subtle: #8b95ad;
  --line: #26304f;
  --ok: #34d399;
  --ok-bg: #0d2a22;
  --warn: #fbbf24;
  --warn-bg: #2a2110;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 var(--font);
  overflow-x: hidden;
}

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; background: var(--brand); color: var(--brand-ink); border-radius: 8px;
}
.skip:focus { top: 12px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; letter-spacing: -.02em;
}
.brand-mark.has-logo { background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.hero-title { display: flex; align-items: center; gap: 16px; }
.hero-title .brand-mark { width: 64px; height: 64px; border-radius: 16px; font-size: 28px; box-shadow: var(--shadow); }
.hero-title h1 { margin: 10px 0 12px; }
@media (max-width: 560px) { .hero-title .brand-mark { width: 48px; height: 48px; border-radius: 12px; font-size: 22px; } }

.hub .card .card-head { display: flex; align-items: center; gap: 12px; }
.hub .card .brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--subtle); }

.switcher { margin-left: auto; display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.switcher a {
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.switcher a:hover { color: var(--text); }
.switcher a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; }

@media (max-width: 760px) {
  .switcher { display: none; }
  .theme-btn { margin-left: auto; }
}

.hero { border-bottom: 1px solid var(--line); background:
  radial-gradient(1200px 300px at 10% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
  var(--surface); }
.hero-inner { max-width: 1200px; margin: 0 auto; padding: 48px 16px 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand);
}
.hero h1 { margin: 10px 0 12px; font-size: clamp(30px, 5vw, 48px); line-height: 1.1; letter-spacing: -.025em; }
.hero p.lead { margin: 0; max-width: 70ch; font-size: 18px; color: var(--muted); }
.meta { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 14px;
}
.chip b { color: var(--text); font-weight: 600; }

.mobile-switch { display: none; margin-top: 20px; }
.mobile-switch select {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
@media (max-width: 760px) { .mobile-switch { display: block; } }

.glance { max-width: 1200px; margin: 0 auto; padding: 32px 16px 0; }
.glance h2 { font-size: 20px; margin: 0 0 14px; }
.glance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card .k { font-size: 13px; font-weight: 700; color: var(--subtle); text-transform: uppercase; letter-spacing: .05em; }
.card .v { margin-top: 6px; color: var(--text); font-size: 15px; line-height: 1.55; }
.card.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-bg); }
.card.ok .k { color: var(--ok); }

.layout {
  max-width: 1200px; margin: 0 auto; padding: 32px 16px 64px;
  display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

.toc { position: sticky; top: calc(var(--header-h) + 20px); max-height: calc(100vh - var(--header-h) - 40px); overflow: auto; }
.toc-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--subtle); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4;
  border-left: 2px solid transparent;
}
.toc a::before { content: counter(toc); color: var(--subtle); font-variant-numeric: tabular-nums; min-width: 1.4em; }
.toc a:hover { background: var(--surface-2); color: var(--text); }
.toc a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); border-left-color: var(--brand); font-weight: 600; }

.toc-mobile { display: none; }
@media (max-width: 960px) {
  .toc { display: none; }
  .toc-mobile {
    display: block; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .toc-mobile summary { cursor: pointer; padding: 14px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; }
  .toc-mobile summary::-webkit-details-marker { display: none; }
  .toc-mobile summary::after { content: "+"; color: var(--subtle); font-weight: 400; }
  .toc-mobile[open] summary::after { content: "–"; }
  .toc-mobile ol { margin: 0; padding: 0 16px 14px 36px; }
  .toc-mobile li { padding: 4px 0; }
  .toc-mobile a { color: var(--muted); text-decoration: none; }
}

.doc { min-width: 0; }
.doc section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px clamp(18px, 3vw, 36px); box-shadow: var(--shadow); margin-bottom: 16px;
}
.doc h2 { margin: 0 0 12px; font-size: 22px; line-height: 1.3; letter-spacing: -.01em; display: flex; gap: 12px; align-items: baseline; }
.doc h2 .num {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-size: 14px; font-weight: 800;
}
.doc h3 { margin: 22px 0 8px; font-size: 17px; }
.doc p, .doc li { color: var(--muted); }
.doc p { margin: 0 0 12px; max-width: 75ch; }
.doc ul { margin: 0 0 12px; padding-left: 22px; max-width: 75ch; }
.doc li { margin: 6px 0; }
.doc strong { color: var(--text); }
.doc code { font-size: .92em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); word-break: break-all; }

.note {
  margin: 14px 0; padding: 14px 16px; border-radius: 12px;
  background: var(--surface-2); border-left: 4px solid var(--brand); color: var(--muted);
}
.note.warn { background: var(--warn-bg); border-left-color: var(--warn); }
.note p:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
th, td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); color: var(--text); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
td { color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--text); font-weight: 600; }

.perm { display: grid; gap: 10px; margin: 12px 0; }
.perm-item { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.perm-item .name { font-weight: 700; color: var(--text); }
.perm-item .why { color: var(--muted); }
@media (max-width: 560px) { .perm-item { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }

.hub { max-width: 1200px; margin: 0 auto; padding: 32px 16px 64px; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.hub a.card { text-decoration: none; display: flex; flex-direction: column; gap: 8px; transition: transform .15s ease, border-color .15s ease; }
.hub a.card:hover { transform: translateY(-2px); border-color: var(--brand); }
.hub .card h2 { margin: 0; font-size: 19px; color: var(--text); }
.hub .card p { margin: 0; color: var(--muted); font-size: 15px; }
.hub .card .go { margin-top: auto; padding-top: 8px; font-weight: 700; color: var(--brand); font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .hub a.card { transition: none; } .hub a.card:hover { transform: none; } }

.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 24px 16px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; color: var(--subtle); font-size: 14px; }
.footer a { color: var(--muted); }

.to-top {
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top svg { width: 18px; height: 18px; }

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f4f6; --text: #000; --muted: #222; --line: #ccc; --shadow: none; }
  .topbar, .toc, .toc-mobile, .to-top, .mobile-switch, .theme-btn { display: none !important; }
  .layout { display: block; padding: 0; }
  .doc section { break-inside: avoid; box-shadow: none; border: 0; padding: 12px 0; }
  .hero { background: none; }
  a { color: #000; }
}
