:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --fg: #1d2129;
  --muted: #5c6370;
  --border: #e3e6ea;
  --accent: #6d28d9;
  --accent-soft: #ede9fe;
  --code-bg: #f6f8fa;
  --term-bg: #16181d;
  --term-fg: #e6e6e6;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #161920;
    --fg: #e6e8eb;
    --muted: #9aa1ac;
    --border: #262a33;
    --accent: #a78bfa;
    --accent-soft: #241d3a;
    --code-bg: #161b22;
  }
  .shiki,
  .shiki span {
    color: var(--shiki-dark) !important;
    background-color: var(--shiki-dark-bg) !important;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 var(--sans);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05em 0.35em;
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 1.2em;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}
pre.shiki { background: var(--code-bg) !important; }
pre code { font-size: inherit; }

.inner, main { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Header and footer */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { font-weight: 800; font-size: 1.35rem; letter-spacing: 0.04em; color: var(--fg); }
.logo:hover { text-decoration: none; }
nav { display: flex; gap: 20px; flex-wrap: wrap; font-size: 0.95rem; }
nav a { color: var(--muted); }
nav a[aria-current="page"], nav a:hover { color: var(--fg); text-decoration: none; }
nav .lang { border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; }

.site-footer { border-top: 1px solid var(--border); margin-top: 80px; color: var(--muted); font-size: 0.9rem; }
.site-footer .inner { padding: 24px 20px; }

/* Landing page */
/* Grid items may shrink below their content, so long code lines scroll inside their box. */
.hero > *, .split > *, .doc > * { min-width: 0; }
section { margin: 72px 0; }
h1, h2, h3 { line-height: 1.25; }
.hero { display: grid; grid-template-columns: 1fr 1.05fr; gap: 48px; align-items: center; margin-top: 56px; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); margin: 0 0 0.4em; letter-spacing: -0.01em; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 0 0 1.6em; }
.hero-code pre { margin: 0; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); }

.button {
  display: inline-block;
  padding: 0.6em 1.2em;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 600;
  margin: 0 8px 8px 0;
}
.button:hover { text-decoration: none; background: var(--bg-soft); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { filter: brightness(1.08); background: var(--accent); }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; background: var(--bg-soft); }
.card h3 { margin: 0 0 0.4em; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.split { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 40px; align-items: start; }
.split h2 { margin-top: 0; }
.split p { color: var(--muted); }
pre.terminal { background: var(--term-bg); color: var(--term-fg); border-color: var(--term-bg); }

.download table, .prose table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; }

.security { border-top: 1px solid var(--border); padding-top: 40px; }
.notfound { min-height: 40vh; }

/* Documentation pages */
main.wide { max-width: 1240px; }
.doc { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 48px; margin-top: 32px; }
.toc { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; font-size: 0.88rem; }
.toc summary { font-weight: 700; margin: 0 0 0.5em; cursor: pointer; }
@media (min-width: 901px) { .toc summary { pointer-events: none; list-style: none; } .toc summary::-webkit-details-marker { display: none; } }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.25em 0; }
.toc li.d3 { padding-left: 14px; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--fg); }

.prose { min-width: 0; }
.prose h1 { font-size: 2.1rem; margin-top: 0; }
.prose h2 { margin-top: 2.2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.prose h3 { margin-top: 1.8em; }
.prose h2, .prose h3 { scroll-margin-top: 76px; position: relative; }
.prose .anchor { position: absolute; left: -1.1em; color: var(--muted); opacity: 0; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; text-decoration: none; }
.prose blockquote { margin: 0 0 1.2em; padding: 0.2em 1em; border-left: 3px solid var(--accent); background: var(--accent-soft); }

@media (max-width: 900px) {
  .hero, .split { grid-template-columns: 1fr; gap: 28px; }
  .features { grid-template-columns: 1fr 1fr; }
  .doc { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
}

@media (max-width: 600px) {
  .features { grid-template-columns: 1fr; }
  nav { gap: 12px; font-size: 0.88rem; }
  section { margin: 48px 0; }
  .prose .anchor { display: none; }
}
