
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #737373;
  --border: #e5e5e5;
  --surface: #fafafa;
  --code-bg: #f4f4f5;
  --accent: #2b91f7;
  --radius: 10px;
  --header: 56px;
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a1a1a1;
    --border: #27272a;
    --surface: #111113;
    --code-bg: #18181b;
    --accent: #5aa9f9;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header) + 16px); }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.8; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; background: var(--code-bg); border-radius: 6px; padding: 0.12em 0.4em; }

.header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: var(--header); padding: 0 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.brand { color: var(--fg); font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__sub { margin-left: 8px; color: var(--muted); font-weight: 400; }
.search { flex: 1; max-width: 420px; margin-left: auto; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr) 200px; gap: 40px; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.sidebar, .toc { position: sticky; top: var(--header); align-self: start; max-height: calc(100dvh - var(--header)); overflow-y: auto; padding: 24px 0; }
.nav > summary { display: none; }
.nav__group + .nav__group { margin-top: 20px; }
.nav__label { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.nav__item a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--fg); font-size: 14px; line-height: 1.5; }
.nav__item a:hover { background: var(--surface); text-decoration: none; }
.nav__item a[aria-current="page"] { background: var(--code-bg); font-weight: 600; }
.nav__item[data-depth="1"] a { padding-left: 22px; font-size: 13px; }
.nav__item[data-depth="2"] a { padding-left: 34px; font-size: 13px; }
.toc li a { display: block; padding: 3px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.toc li[data-depth="3"] a { padding-left: 12px; }
.toc li a:hover { color: var(--fg); text-decoration: none; }

.main { min-width: 0; padding: 32px 0 64px; }
.prose { max-width: 760px; }
.prose h1 { margin: 0 0 24px; font-size: 30px; line-height: 1.35; letter-spacing: -0.02em; text-wrap: balance; }
.prose h2 { margin: 48px 0 12px; font-size: 21px; line-height: 1.45; border-top: 1px solid var(--border); padding-top: 24px; }
.prose h3 { margin: 32px 0 8px; font-size: 17px; line-height: 1.5; }
.prose h4 { margin: 24px 0 8px; font-size: 15px; }
.prose h1, .prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; color: var(--muted); opacity: 0; transition: opacity 120ms ease-out; }
.prose :is(h1, h2, h3, h4):hover .anchor { opacity: 1; text-decoration: none; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li + li { margin-top: 4px; }
.prose blockquote { margin: 0 0 14px; padding: 4px 16px; border-left: 3px solid var(--border); color: var(--muted); }
.prose pre { margin: 0 0 16px; padding: 14px 16px; overflow-x: auto; background: var(--code-bg); border-radius: var(--radius); line-height: 1.6; }
.prose pre code { padding: 0; background: none; font-size: 13px; }
.table { margin: 0 0 16px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
.table th, .table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.ref code { color: var(--accent); }
.lead { color: var(--muted); font-size: 16px; }
.lead--sub { font-size: 14px; }

.home__group { margin-top: 36px; }
.home__group h2 { border-top: 0; padding-top: 0; margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color 120ms ease-out, background-color 120ms ease-out; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--surface); text-decoration: none; }
.card__title { font-weight: 600; line-height: 1.5; }
.card__sub { color: var(--muted); font-size: 12px; line-height: 1.6; }

.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 0; list-style: none; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--fg); }
.site-footer p { margin: 0; }
.footer { max-width: 760px; margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }

/* Pagefind の UI を地の色へ寄せる */
.search { --pagefind-ui-scale: 0.72; --pagefind-ui-primary: var(--accent); --pagefind-ui-text: var(--fg); --pagefind-ui-background: var(--bg); --pagefind-ui-border: var(--border); --pagefind-ui-tag: var(--code-bg); --pagefind-ui-border-radius: 8px; --pagefind-ui-font: inherit; position: relative; }
.search .pagefind-ui__drawer { position: absolute; top: calc(100% + 6px); right: 0; width: min(560px, calc(100vw - 32px)); max-height: 70dvh; overflow-y: auto; padding: 8px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(0 0 0 / 0.12); }
.search .pagefind-ui__drawer:empty, .search .pagefind-ui__drawer:not(:has(.pagefind-ui__results-area)) { display: none; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 232px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .header { padding: 0 16px; gap: 12px; }
  .brand__sub { display: none; }
  .shell { display: block; padding: 0 16px; }
  .site-footer { padding: 24px 16px; }
  .sidebar { position: static; max-height: none; padding: 12px 0 0; overflow: visible; }
  .nav { border: 1px solid var(--border); border-radius: var(--radius); }
  .nav > summary { display: block; padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
  .nav > nav { padding: 4px 8px 12px; }
  .main { padding-top: 20px; }
  .prose h1 { font-size: 24px; }
  .prose h2 { font-size: 19px; }
  .anchor { display: none; }
}
