:root {
  --bg: #f6f2ea;
  --bg-alt: #efe9de;
  --surface: #fffdf9;
  --ink: #1f2a30;
  --muted: #5c6a72;
  --accent: #b45309;
  --accent-soft: #fde8d7;
  --teal: #0f766e;
  --teal-soft: #e6f4f1;
  --border: #d9d0c3;
  --highlight: #fef3c7;
  --shadow: 0 1px 2px rgba(31, 42, 48, 0.05), 0 4px 12px rgba(31, 42, 48, 0.04);
  --radius: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Iowan Old Style", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

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

.doc-header {
  background: var(--ink);
  color: #f8f4ec;
  padding: 2rem 1.5rem 1.75rem;
  border-bottom: 4px solid var(--accent);
}

.doc-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
}

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #f3c98b;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.doc-header h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.15;
  margin: 0 0 0.4rem;
  max-width: 800px;
}

.doc-subtitle {
  margin: 0;
  color: #d8d1c6;
  font-size: 0.98rem;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.82rem;
  color: #d8d1c6;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
}

.badge.teal { background: var(--teal); }
.badge.ghost { background: transparent; border: 1px solid rgba(255,255,255,0.35); color: #f8f4ec; }

.doc-layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 2.5rem;
  padding: 2.25rem 1.5rem 4rem;
}

.doc-sidebar {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  font-size: 0.9rem;
}

.doc-sidebar h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.doc-sidebar ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}

.doc-sidebar li { margin: 0; }

.doc-sidebar a {
  display: block;
  padding: 0.35rem 0 0.35rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  line-height: 1.35;
}

.doc-sidebar a:hover,
.doc-sidebar a:focus {
  color: var(--ink);
  border-left-color: var(--accent);
}

.doc-content { min-width: 0; }

.doc-content section { margin-bottom: 2.75rem; }

.doc-content h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  line-height: 1.25;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.doc-content h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin: 1.5rem 0 0.4rem;
}

.doc-content p { margin: 0 0 1rem; }

.lead {
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 72ch;
}

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0;
}

.callout.info {
  border-left-color: var(--teal);
  background: var(--teal-soft);
}

.callout.warning {
  border-left-color: #b45309;
  background: var(--highlight);
}

.callout p:last-child { margin-bottom: 0; }

.callout strong { color: var(--ink); }

.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--bg-alt);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.tag.accent { background: var(--accent-soft); color: #7c2d12; border-color: #f3c9a8; }
.tag.teal { background: var(--teal-soft); color: #115e59; border-color: #b7e0d9; }

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0.9rem;
}

.step-list {
  counter-reset: step;
  list-style: none;
  margin: 1.25rem 0;
  padding: 0;
}

.step-list li {
  counter-increment: step;
  position: relative;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 0.9rem 3.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0.9rem;
  top: 0.9rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--ink);
  color: #f8f4ec;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-list li strong { display: block; margin-bottom: 0.15rem; }
.step-list li p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.exercise-box {
  background: var(--teal-soft);
  border: 1px solid #b7e0d9;
  border-left: 5px solid var(--teal);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin: 1.25rem 0;
}

.exercise-box h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: #115e59;
}

.exercise-box p { margin: 0 0 0.65rem; }
.exercise-box ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.exercise-box li { margin-bottom: 0.25rem; }

.quiz details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0.6rem 0;
  box-shadow: var(--shadow);
}

.quiz summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.quiz summary:hover { color: var(--accent); }

.quiz details p {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}

.next-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.next-links a {
  display: inline-block;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.next-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.next-links a.next {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.next-links a.next:hover {
  background: #92400e;
  border-color: #92400e;
  color: #fff;
}

.next-done {
  display: inline-block;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

.top-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .doc-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 1.5rem;
  }

  .doc-sidebar {
    position: static;
    order: -1;
  }

  .doc-sidebar ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
  }

  .doc-sidebar a {
    padding: 0.25rem 0;
    border-left: none;
    margin-left: 0;
  }

  .doc-sidebar a:hover,
  .doc-sidebar a:focus { border-left: none; text-decoration: underline; }
}

@media (max-width: 520px) {
  .doc-header { padding: 1.5rem 1rem 1.25rem; }
  .doc-layout { padding: 1.25rem 1rem 3rem; }
  .step-list li { padding-left: 2.9rem; }
}

@media print {
  body { background: #fff; color: #000; }
  .doc-header { background: #fff; color: #000; border-bottom: 2px solid #000; }
  .doc-header h1, .doc-subtitle, .eyebrow { color: #000; }
  .doc-sidebar { display: none; }
  .doc-layout { display: block; max-width: none; padding: 0; }
  .step-list li, .exercise-box, .callout, .table-wrap { box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .footer { border-top: 1px solid #000; }
}
