:root {
  color-scheme: light;
  --bg: #ffffff;
  --tile: #f3f4f0;
  --line: #dfe3dc;
  --ink: #121a16;
  --muted: #5d6b63;
  --accent: #d94e2a;
  --accent-soft: #fbe3da;
  --ok: #1f7a66;
  --ok-soft: #e6f4f0;
  --band: #121a16;
  --band-tile: #1f2924;
  --band-ink: #eef2ee;
  --band-muted: #9aa8a0;
  --band-line: #34413a;
  --band-accent: #f0704a;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", Meiryo, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.75 var(--sans);
  font-synthesis: none;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, pre, blockquote { margin: 0; padding: 0; }
h1, h2, h3, h4 { line-height: 1.3; letter-spacing: -.015em; }
a { color: inherit; text-underline-offset: .22em; }
button { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); }

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

.wrap {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
}

.mono { color: var(--muted); font: .76rem/1.55 var(--mono); letter-spacing: .04em; }
.fine { color: var(--muted); font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  transform: translateY(calc(-100% - 16px));
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.skip-link:focus { transform: none; }

/* Header */
.navbar {
  position: sticky;
  z-index: 12;
  top: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  padding-block: 12px;
  font-size: .92rem;
}
.nav a { text-decoration: none; }
.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.logo .dot { color: var(--accent); }
.logo-sub {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tile);
  color: var(--muted);
  font: 700 .72rem/1.2 var(--mono);
  letter-spacing: .04em;
  text-transform: lowercase;
}

.nav .links {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 20px;
  margin-left: 14px;
  overflow-x: auto;
}
.nav .links a { color: var(--muted); white-space: nowrap; }
.nav .links a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .42em;
}
.nav a:not(.btn, .logo):hover { color: var(--ink); text-decoration: underline; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.lang-link {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: .84rem;
  white-space: nowrap;
}
.lang-link:hover { border-color: var(--ink); color: var(--ink); text-decoration: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--band-tile); }
.btn.soft { border-color: var(--line); background: var(--tile); color: var(--ink); }
.btn.soft:hover { background: var(--line); }

.menu-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  font-size: .86rem;
  font-weight: 700;
  cursor: pointer;
}

/* 3-column Documentation Shell */
.docs-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 220px;
  gap: 36px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 72px;
}

/* Sidebar */
.docs-sidebar {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-right: 12px;
}
.side-group + .side-group {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.side-title {
  margin-bottom: 8px;
  padding-inline: 10px;
  color: var(--muted);
  font: 700 .72rem/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.side-nav { list-style: none; display: grid; gap: 4px; }
.side-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.4;
  text-decoration: none;
}
.side-nav a:hover { background: var(--tile); color: var(--ink); }
.side-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 700;
}
.side-nav a[aria-current="page"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
  flex: none;
}
.side-nav a[aria-current="page"] span { flex: 1; }

/* On-page TOC */
.docs-toc {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  font-size: .84rem;
}
.toc-title {
  margin-bottom: 10px;
  color: var(--muted);
  font: 700 .72rem/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.toc-list { list-style: none; display: grid; gap: 6px; }
.toc-list a {
  display: block;
  color: var(--muted);
  line-height: 1.4;
  text-decoration: none;
}
.toc-list a:hover,
.toc-list a.is-active {
  color: var(--accent);
}
.toc-list li.toc-sub { padding-left: 12px; font-size: .8rem; }

/* Main Content */
.docs-main { min-width: 0; max-width: 780px; }

.crumb { margin-bottom: 14px; color: var(--muted); font-size: .82rem; }
.crumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.crumb li + li::before { content: "/"; margin-right: 8px; color: var(--line); }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

.doc-head {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.doc-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  font: 700 .74rem/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.doc-head h1 {
  font-size: clamp(1.85rem, 3.8vw, 2.55rem);
  font-weight: 700;
}
.doc-lead {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.doc-body section {
  padding-top: 36px;
  scroll-margin-top: 84px;
}
.doc-body h2 {
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 1.42rem;
}
.doc-body h3 {
  margin: 24px 0 10px;
  font-size: 1.12rem;
  scroll-margin-top: 84px;
}
.doc-body p { margin-top: 12px; }
.doc-body p:first-child { margin-top: 0; }
.doc-body ul, .doc-body ol {
  margin-top: 12px;
  padding-left: 1.35em;
  display: grid;
  gap: 6px;
}
.doc-body li > strong { color: var(--ink); }
.doc-body a { color: var(--accent); text-decoration: underline; }
.doc-body a:hover { color: var(--ink); }

.doc-body code:not(pre code) {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tile);
  font-size: .86em;
}

/* Badges / chips */
.chip {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tile);
  color: var(--muted);
  font: 700 .74rem/1.5 var(--mono);
  white-space: nowrap;
}
.chip.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.chip.accent { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* Callouts */
.callout {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--tile);
  font-size: .95rem;
}
.callout.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-left-color: var(--accent); background: var(--accent-soft); }
.callout-title {
  margin-bottom: 4px;
  font-size: .88rem;
  font-weight: 700;
}

/* Code Blocks */
.code-block {
  margin-top: 16px;
  border: 1px solid var(--band-line);
  border-radius: 10px;
  background: var(--band);
  color: var(--band-ink);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--band-line);
  background: var(--band-tile);
  color: var(--band-muted);
  font: .75rem/1.4 var(--mono);
}
.copy-btn {
  padding: 3px 10px;
  border: 1px solid var(--band-line);
  border-radius: 6px;
  background: transparent;
  color: var(--band-ink);
  font: 700 .74rem/1.4 var(--sans);
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--band-accent); color: var(--band-accent); }
.code-block pre {
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .84rem;
  line-height: 1.6;
}

/* Tables */
.tbl {
  max-width: 100%;
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tbl table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: .9rem;
}
.tbl th, .tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.tbl tbody tr:last-child th,
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl thead th {
  background: var(--tile);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 700 .74rem/1.5 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tbl th[scope="row"] { font-weight: 700; white-space: nowrap; }

/* Card Grids */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.doc-card {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tile);
  text-decoration: none !important;
  color: var(--ink) !important;
}
.doc-card:hover { border-color: var(--ink); }
.doc-card .mono { color: var(--accent); }
.doc-card strong { font-size: 1.02rem; }
.doc-card p { margin-top: 0; color: var(--muted); font-size: .88rem; }

/* Pager */
.docs-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.pager-link {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
}
.pager-link:hover { border-color: var(--ink); background: var(--tile); }
.pager-link.next { text-align: right; grid-column: 2; }
.pager-link strong { color: var(--ink); font-size: .96rem; }

/* Footer */
.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
  padding-block: 24px 36px;
  border-top: 1px solid var(--line);
}
.foot .logo { font-size: 1.15rem; }
.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  color: var(--muted);
  font-size: .84rem;
}
.foot a { text-decoration: none; }
.foot nav a:hover { color: var(--ink); text-decoration: underline; }

/* Responsive */
@media (max-width: 1120px) {
  .docs-shell { grid-template-columns: 230px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .docs-shell { grid-template-columns: 1fr; gap: 20px; padding-top: 18px; }
  .docs-sidebar {
    position: static;
    max-height: none;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--tile);
  }
  .docs-sidebar:not(.is-open) { display: none; }
  .doc-cards, .docs-pager { grid-template-columns: 1fr; }
  .pager-link.next { grid-column: auto; text-align: left; }
}

@media (max-width: 680px) {
  .nav { flex-wrap: wrap; gap: 8px 12px; }
  .nav .links { order: 3; flex: 1 0 100%; margin-left: 0; padding-top: 4px; }
  .nav-actions .btn { display: none; }
}
