:root {
  color-scheme: light;
  --bg-page: #fff9f2;
  --bg-elevated: #fffdf9;
  --bg-cream: #fff6e8;
  --text-primary: #513b42;
  --text-muted: #806b72;
  --divider: #513b421a;
  --accent: #b8426b;
  --accent-hover: #9e345a;
  --accent-soft: #fbe9ef;
  --accent-mid: #f1c5d3;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius-card: 16px;
  --radius-pill: 999px;
  --max-content: 760px;
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-mid);
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-hover); }

/* ---------- header ---------- */

.page-head {
  border-bottom: 1px solid var(--divider);
  background: var(--bg-cream);
}
.page-head-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 16px 32px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  flex: none;
}
.page-head h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
}
.tagline {
  margin: 14px 0 0;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: 1rem;
}
.tagline strong { color: var(--text-primary); }

/* ---------- layout ---------- */

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 64px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding-top: 32px;
}
.sidebar-inner {
  background: var(--bg-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
  padding: 16px;
}
.sidebar-title {
  margin: 0 0 8px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 2px solid transparent;
}
.sidebar a:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

main {
  min-width: 0;
  max-width: var(--max-content);
  padding-top: 32px;
}

/* ---------- content ---------- */

section {
  padding-top: 24px;
  margin-top: 8px;
  border-top: 1px solid var(--divider);
  scroll-margin-top: 20px;
}
section:first-of-type {
  border-top: none;
  padding-top: 0;
}

h2 {
  font-size: 1.5rem;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1.1rem;
  margin: 28px 0 10px;
  color: var(--text-primary);
}
p { margin: 0 0 14px; }
ul, ol {
  margin: 0 0 14px;
  padding-left: 1.3em;
}
li { margin-bottom: 6px; }
li ul { margin-top: 6px; margin-bottom: 0; }

strong { color: var(--text-primary); }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 6px;
}
a code { color: var(--accent); }
a:hover code { color: var(--accent-hover); }

/* ---------- table ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-card);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: none;
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-cream);
}
td code { white-space: nowrap; }

/* ---------- footer ---------- */

.page-foot {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.page-foot p { margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-bottom: 48px;
  }
  .sidebar {
    position: static;
    max-height: none;
    padding-top: 20px;
    order: 0;
  }
  .sidebar-inner {
    padding: 12px;
  }
  .sidebar ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .sidebar a {
    border-left: none;
    border: 1px solid transparent;
    padding: 6px 10px;
    font-size: 0.85rem;
  }
  .sidebar a.active {
    border-color: var(--accent-mid);
  }
  main {
    max-width: 100%;
    padding-top: 8px;
  }
  .page-head-inner {
    padding: 28px 16px 24px;
  }
  .page-head h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  th, td { padding: 8px 10px; }
}

/* table cells wrap on narrow screens instead of causing page-level scroll */
@media (max-width: 640px) {
  th, td { white-space: normal; word-break: break-all; }
}
