:root {
  --bg: #f8f6f0;
  --bg-card: #ffffff;
  --bg-soft: #f0ece0;
  --text: #161618;
  --text-muted: #5c5c66;
  --text-faint: #8d8d97;
  --border: #d6d3c9;
  --border-strong: #b8b4a8;
  --accent: #1c5d3a;
  --accent-light: #d5e0d4;
  --highlight: #fbedc6;
  --highlight-strong: #f5d77a;
  --shadow: 0 1px 2px rgba(22, 22, 24, 0.04), 0 4px 12px rgba(22, 22, 24, 0.06);

  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Public Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 400;
  font-feature-settings: 'kern', 'liga', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}
a:hover { color: var(--text); }

/* === Page header === */
.page-header {
  background: var(--text);
  color: #f8f6f0;
  padding: 56px 32px 48px;
  border-bottom: 1px solid #2b2b2f;
}
.page-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: end;
}
.page-header h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3.25rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.page-header .subtitle {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #b3a890;
  margin: 0 0 24px;
  font-weight: 500;
}
.page-header .meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #8d8276;
  margin: 0;
  letter-spacing: 0.02em;
}
.page-header .meta strong {
  color: #d5cdb6;
  font-weight: 500;
}
.print-button {
  background: transparent;
  border: 1px solid #4a4a52;
  color: #f8f6f0;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.print-button:hover {
  background: #2b2b2f;
  border-color: #6a6a72;
}

/* === Layout === */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px 80px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 56px;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 0 24px 64px;
  }
}

/* === Sticky TOC === */
.toc {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 32px 0;
  border-right: 1px solid var(--border);
  padding-right: 24px;
  font-size: 0.875rem;
}
.toc h2 {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  font-weight: 500;
  margin: 0 0 16px;
}
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}
.toc > ol > li {
  counter-increment: toc;
  margin-bottom: 4px;
}
.toc > ol > li > a::before {
  content: counter(toc, decimal-leading-zero) ' ';
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 0.75rem;
  margin-right: 8px;
}
.toc a {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 4px 0;
  line-height: 1.4;
  border-left: 2px solid transparent;
  padding-left: 12px;
  margin-left: -14px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.toc a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}
.toc ol ol {
  margin: 4px 0 8px 24px;
}
.toc ol ol a {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
}
.toc ol ol a::before { content: none; }

@media (max-width: 1024px) {
  .toc {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0 0 24px;
  }
  details.toc-collapse {
    margin-bottom: 24px;
  }
  details.toc-collapse summary {
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-faint);
    padding: 12px 0;
    list-style: none;
  }
  details.toc-collapse summary::-webkit-details-marker { display: none; }
  details.toc-collapse summary::after {
    content: ' ▾';
  }
  details.toc-collapse[open] summary::after {
    content: ' ▴';
  }
}

/* === Main content === */
main {
  padding: 32px 0;
  max-width: 760px;
  min-width: 0;
}

section {
  margin-bottom: 80px;
  scroll-margin-top: 24px;
}

section.hero {
  margin-bottom: 64px;
}

/* === Headings === */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 12px;
  display: block;
}
h2.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0 0 8px;
  color: var(--text);
}
.section-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin: 0 0 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.section-meta strong {
  color: var(--text-muted);
  font-weight: 500;
}

h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 48px 0 16px;
  color: var(--text);
  scroll-margin-top: 24px;
}
h4 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 28px 0 12px;
  color: var(--text);
  scroll-margin-top: 24px;
}

/* === Body content === */
p {
  margin: 0 0 16px;
}
strong {
  font-weight: 600;
  color: var(--text);
}
ul, ol {
  margin: 0 0 16px;
  padding-left: 24px;
}
li {
  margin-bottom: 6px;
}
li::marker {
  color: var(--text-faint);
}

/* Numbered clauses (regulation paragraphs) */
.clause {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  margin: 0 0 16px;
}
.clause__num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-faint);
  padding-top: 4px;
}
.clause__body {
  margin: 0;
}
.clause__body strong:first-child {
  color: var(--text);
}

/* Sub-clauses (a, b, c, d) inside .clause__body */
.subclauses {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  counter-reset: sub;
}
.subclauses li {
  counter-increment: sub;
  position: relative;
  padding-left: 28px;
  margin-bottom: 8px;
}
.subclauses li::before {
  content: counter(sub, lower-alpha) '.';
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-faint);
}

/* Paragraph anchors (§ 1, § 2 ...) */
.para-anchor {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 500;
  margin: 40px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
  display: block;
  scroll-margin-top: 24px;
}

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 2px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-feature-settings: 'tnum';
}
thead {
  background: var(--bg-soft);
}
th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
td code, td .doc-link {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
td.status {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  white-space: nowrap;
}
td.status.ok::before {
  content: '✓ ';
  color: var(--accent);
  font-weight: 600;
}

/* === Code === */
code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--text);
}
pre {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg-soft);
  padding: 16px 20px;
  margin: 0 0 24px;
  overflow-x: auto;
  border-radius: 2px;
  border: 1px solid var(--border);
  line-height: 1.6;
}
pre code {
  background: transparent;
  padding: 0;
}

/* === Hero / opening === */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 32px;
  margin: 0 0 32px;
  box-shadow: var(--shadow);
}
.hero-card p:last-child { margin-bottom: 0; }
.hero-card .lead {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--text);
  margin: 0 0 16px;
}

/* === Highlights / pull quotes === */
.callout {
  background: var(--highlight);
  border-left: 3px solid var(--highlight-strong);
  padding: 20px 24px;
  margin: 24px 0;
  font-size: 0.9375rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--text); }

/* === Doc cards (links to other sections) === */
.doc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 32px;
}
.doc-grid a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s ease;
}
.doc-grid a:last-child { border-bottom: none; }
.doc-grid a:hover {
  background: var(--bg-soft);
}
.doc-grid .doc-area {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-muted);
}
.doc-grid .doc-name {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text);
}
.doc-grid .doc-arrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.875rem;
}

/* === Footer === */
footer {
  background: var(--text);
  color: #b3a890;
  padding: 48px 32px;
  margin-top: 80px;
  font-size: 0.875rem;
}
footer .footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
}
@media (max-width: 768px) {
  footer .footer-inner { grid-template-columns: 1fr; gap: 32px; }
}
footer h3 {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #8d8276;
  font-weight: 500;
  margin: 0 0 12px;
}
footer p {
  margin: 0 0 8px;
  color: #d5cdb6;
}
footer a {
  color: #d5cdb6;
  text-decoration: underline;
  text-underline-offset: 2px;
}
footer a:hover { color: #f8f6f0; }
footer .legal {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #8d8276;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #2b2b2f;
}

/* === Print styles === */
@media print {
  @page {
    size: A4;
    margin: 18mm 16mm 18mm 18mm;
  }
  html { scroll-behavior: auto; }
  body {
    background: white;
    color: black;
    font-size: 10.5pt;
    line-height: 1.5;
  }
  .page-header {
    background: white;
    color: black;
    padding: 0 0 16pt;
    border-bottom: 1pt solid black;
    margin-bottom: 24pt;
    page-break-after: avoid;
  }
  .page-header__inner {
    display: block;
  }
  .page-header h1 {
    font-size: 24pt;
    margin: 0 0 6pt;
  }
  .page-header .subtitle {
    font-size: 8pt;
    color: #666;
    margin: 0 0 8pt;
  }
  .page-header .meta {
    font-size: 8pt;
    color: #666;
  }
  .page-header .meta strong {
    color: black;
  }
  .print-button { display: none !important; }

  .layout {
    display: block;
    padding: 0;
    max-width: 100%;
  }
  .toc { display: none; }
  details.toc-collapse { display: none; }
  main {
    padding: 0;
    max-width: 100%;
  }
  section {
    margin-bottom: 0;
    page-break-before: always;
    padding-top: 0;
  }
  section.hero {
    page-break-before: auto;
  }
  h2.section-title {
    font-size: 18pt;
    page-break-after: avoid;
  }
  h3 {
    font-size: 13pt;
    margin-top: 18pt;
    page-break-after: avoid;
  }
  h4 {
    font-size: 11pt;
    page-break-after: avoid;
  }
  table { page-break-inside: avoid; }
  .table-wrap {
    background: white;
    border: 0.5pt solid #999;
  }
  thead {
    background: #f0f0f0;
  }
  th, td {
    border-bottom: 0.5pt solid #999;
    padding: 6pt 8pt;
  }
  .hero-card, .callout {
    box-shadow: none;
    border: 0.5pt solid #999;
    background: #f8f8f8;
  }
  .callout { border-left: 2pt solid #666; }
  .doc-grid { border: 0.5pt solid #999; }
  .doc-grid a {
    color: black;
    border-bottom: 0.5pt solid #ccc;
  }
  pre {
    background: #f8f8f8;
    border: 0.5pt solid #999;
  }
  a {
    color: black;
    text-decoration: none;
  }
  a[href^="http"]::after,
  a[href^="mailto"]::after {
    content: ' (' attr(href) ')';
    font-family: var(--font-mono);
    font-size: 0.75em;
    color: #666;
  }
  .clause {
    page-break-inside: avoid;
  }
  footer {
    background: white;
    color: black;
    padding: 16pt 0 0;
    border-top: 1pt solid black;
    margin-top: 24pt;
    page-break-before: avoid;
  }
  footer h3 { color: black; }
  footer p, footer a { color: black; }
  footer .legal { color: #666; border-top: 0.5pt solid #999; }
  footer .footer-inner { display: block; }
  footer .footer-inner > div { margin-bottom: 12pt; }
}

/* Selection */
::selection {
  background: var(--highlight-strong);
  color: var(--text);
}

.toc a.toc-active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}
