:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --warn-bg: #fef3c7;
  --warn-line: #b45309;
  --note-bg: #ecfdf5;
  --note-line: #15803d;
  --code-bg: #f1f5f9;
  --header: #1e3a5f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

header.top {
  background: var(--header);
  color: #fff;
  padding: 40px 16px 32px;
}
header.top .inner { max-width: 1100px; margin: 0 auto; }
header.top h1 { margin: 0 0 6px; font-size: 2rem; line-height: 1.2; }
header.top p { margin: 0; opacity: 0.85; }
header.top .badge {
  display: inline-block;
  background: #fbbf24;
  color: #1e293b;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 80px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
}

nav.toc {
  position: sticky;
  top: 16px;
  align-self: start;
  font-size: 0.9rem;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
nav.toc strong { display: block; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.06em; }
nav.toc ol { margin: 0; padding-left: 28px; }
nav.toc li { margin: 4px 0; }
nav.toc a { color: var(--text); text-decoration: none; }
nav.toc a:hover { color: var(--accent); text-decoration: underline; }

main { min-width: 0; }

section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 24px;
}

h2 { margin-top: 0; font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.15rem; margin-top: 28px; }

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

figure { margin: 20px 0; }
figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
figure.narrow img { max-width: 420px; }
figcaption { font-size: 0.875rem; color: var(--muted); margin-top: 6px; }

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
}
.callout.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.callout.note { border-color: var(--note-line); background: var(--note-bg); }
.callout p { margin: 6px 0; }
.callout > strong:first-child { display: block; }

.table-wrap { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); }

code, kbd {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
pre {
  background: var(--code-bg);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
}
pre code { background: none; padding: 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

dl.glossary dt { font-weight: 700; margin-top: 12px; }
dl.glossary dd { margin: 2px 0 0 0; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px 16px 48px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  nav.toc { position: static; max-height: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
  .two-col { grid-template-columns: 1fr; }
  section { padding: 20px 16px; }
  header.top h1 { font-size: 1.5rem; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  nav.toc { position: static; max-height: none; overflow: visible; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin: 16px 0 24px; break-after: page; }
  section { border: none; padding: 0; margin: 0 0 24px; }
  section + section { break-before: page; }
  figure, .callout, tr, pre, dl.glossary dt { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  figure img { max-height: 125mm; width: auto; max-width: 100%; margin: 0 auto; }
  header.top { padding: 24px 16px; }
  a { color: var(--accent); text-decoration: none; }
  footer { display: none; }
}
