:root {
  color-scheme: light dark;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #d8dee4;
  --soft-bg: #f6f8fa;
  --heading-accent: #7aa2f7;
  --note-bg: #f0f8f3;
  --note-border: #38a169;
  --link: #0969da;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e6edf3;
    --muted: #9aa4b2;
    --border: #30363d;
    --soft-bg: #161b22;
    --heading-accent: #5b8def;
    --note-bg: #102018;
    --note-border: #5fbf7a;
    --link: #58a6ff;
  }
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: Canvas;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 32px 64px;
}

h1, h2, h3, h4 {
  scroll-margin-top: 84px;
}

h1, h2, h3, h4 {
  line-height: 1.35;
  margin: 1.8em 0 0.65em;
}

h1 {
  margin-top: 0;
  margin-bottom: 1.1em;
  font-size: 2.15rem;
  font-weight: 750;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5em;
}

h2 {
  margin-top: 3em;
  margin-bottom: 0.8em;
  font-size: 1.65rem;
  font-weight: 750;
  border-bottom: 2px solid var(--border);
  padding: 0.25em 0 0.45em;
}

h3 {
  margin-top: 2em;
  margin-bottom: 0.6em;
  padding-left: 0.65em;
  font-size: 1.28rem;
  font-weight: 700;
  border-left: 4px solid var(--heading-accent);
}

h4 {
  margin-top: 1.65em;
  margin-bottom: 0.5em;
  font-size: 1.05rem;
  font-weight: 700;
}

p {
  margin: 0.75em 0;
}

ul, ol {
  padding-left: 1.6em;
  margin: 0.75em 0 1em;
}

li + li {
  margin-top: 0.25em;
}

a {
  color: var(--link);
}

.sticky-doc-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  color: var(--text);
  background: Canvas;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(31, 35, 40, 0.08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.sticky-doc-nav.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.sticky-doc-nav-inner {
  max-width: 960px;
  min-height: 48px;
  margin: 0 auto;
  padding: 7px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.sticky-doc-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.sticky-doc-select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sticky-doc-select-text {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.sticky-doc-select {
  max-width: min(56vw, 420px);
  min-width: 220px;
  color: var(--text);
  background: Canvas;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 0.9rem;
}

.image-figure {
  margin: 14px 0 22px;
}

.image-figure img {
  display: block;
  height: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.image-figure figcaption {
  max-width: 100%;
  margin-top: 0.35em;
  color: var(--muted);
  font-size: 0.85em;
  line-height: 1.35;
  text-align: center;
}

.image-row {
  display: grid;
  align-items: flex-start;
  gap: 16px;
  margin: 14px 0 22px;
}

.image-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-row-item {
  min-width: 0;
}

.image-row-item p {
  margin: 0;
}

.image-row-item .image-figure {
  width: 100%;
  margin: 0;
}

.image-row-item .image-figure img {
  width: 100%;
  height: auto;
}

blockquote {
  margin: 1em 0;
  padding: 0.85em 1em;
  color: var(--text);
  background: var(--note-bg);
  border-left: 4px solid var(--note-border);
  border-radius: 0 6px 6px 0;
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.12em 0.32em;
  overflow-wrap: anywhere;
}

pre {
  margin: 1em 0;
  padding: 1em;
  overflow-x: auto;
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.9em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.toc {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1em 1.2em;
}

.toc ul {
  margin-bottom: 0;
}

.doc-footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.doc-footer hr {
  display: none;
}

.doc-footer p {
  margin: 0.35em 0;
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  main {
    padding: 24px 18px 48px;
  }

  .sticky-doc-nav-inner {
    min-height: 54px;
    padding: 7px 18px;
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .sticky-doc-select {
    max-width: calc(100vw - 36px);
    min-width: 0;
    width: calc(100vw - 36px);
  }
}
