:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1a202c;
  --muted: #5a6577;
  --accent: #2b6cb0;
  --accent-soft: #eef4fb;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

.layout { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  width: 280px;
  flex: 0 0 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.brand a { color: var(--accent); text-decoration: none; }

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.nav-unit {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 4px;
  font-weight: 600;
}

.nav-link {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover { background: var(--accent-soft); }

.nav-link.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---- content ---- */
.content {
  flex: 1;
  min-width: 0;
  max-width: 820px;
  padding: 32px 48px 64px;
  background: var(--panel);
  margin: 0 auto;
}

.crumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.crumb a { color: var(--accent); text-decoration: none; }

.lede { color: var(--muted); font-size: 16px; }

h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 20px; }
h2 { font-size: 22px; margin: 36px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { font-size: 18px; margin: 26px 0 8px; }

p { margin: 12px 0; }

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

/* ---- quotes (literal quotations) ---- */
blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 4px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
  color: #475569;
  font-style: italic;
}

/* ---- callouts (labelled boxes) ---- */
.example, .tip, .note, .keypoint {
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  border: 1px solid;
  border-left-width: 5px;
  font-size: 0.97em;
}

.example::before, .tip::before, .note::before, .keypoint::before {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.example {
  background: #f0fdf4;
  border-color: #86efac;
  border-left-color: #22c55e;
}
.example::before { content: "Example"; color: #16a34a; }

.tip {
  background: #eff6ff;
  border-color: #bfdbfe;
  border-left-color: #3b82f6;
}
.tip::before { content: "Tip"; color: #2563eb; }

.note {
  background: #fffbeb;
  border-color: #fde68a;
  border-left-color: #f59e0b;
}
.note::before { content: "Note"; color: #b45309; }

.keypoint {
  background: #faf5ff;
  border-color: #e9d5ff;
  border-left-color: #a855f7;
}
.keypoint::before { content: "Key point"; color: #7e22ce; }

/* ---- tables ---- */
table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 15px; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); }

code {
  background: var(--accent-soft);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

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

ul, ol { padding-left: 24px; }
li { margin: 4px 0; }

img, svg { max-width: 100%; height: auto; }

.foot {
  margin-top: 48px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ---- theme toggle ---- */
.theme-toggle {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--accent-soft); }

/* ---- dark theme: forest (dark grey-chocolate base) ---- */
html[data-theme="dark"] {
  --bg: #1b1a17;
  --panel: #23211d;
  --ink: #e8e3d5;
  --muted: #a29b8b;
  --accent: #86b36a;
  --accent-soft: #2a2e25;
  --border: #3c3a31;
}
html[data-theme="dark"] blockquote {
  background: #26231d;
  border-left-color: #6b5433;
  color: #d3cdb8;
}
html[data-theme="dark"] th { background: #2a2e25; }
html[data-theme="dark"] code { background: #2a2e25; }
html[data-theme="dark"] .example {
  background: #1f2a1e;
  border-color: #3e5a3c;
  border-left-color: #5f9e5f;
}
html[data-theme="dark"] .example::before { color: #83c083; }
html[data-theme="dark"] .tip {
  background: #1e2933;
  border-color: #33475a;
  border-left-color: #4a7fb0;
}
html[data-theme="dark"] .tip::before { color: #7fb3e0; }
html[data-theme="dark"] .note {
  background: #2c271c;
  border-color: #5c4d2a;
  border-left-color: #c0913f;
}
html[data-theme="dark"] .note::before { color: #d9b45f; }
html[data-theme="dark"] .keypoint {
  background: #2a2333;
  border-color: #4a3f5c;
  border-left-color: #a87fbf;
}
html[data-theme="dark"] .keypoint::before { color: #c9a0e0; }

.unit h2 { border: none; margin: 28px 0 8px; }
.unit ul { list-style: none; padding-left: 0; }
.unit li { margin: 6px 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 24px 20px 48px; }
}
