:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --paper: #fffdf8;
  --paper-soft: #fbf7ef;
  --ink: #161b18;
  --muted: #68716d;
  --line: #ded7cc;
  --line-strong: #c9bfb1;
  --accent: #087f78;
  --accent-soft: #dff1ed;
  --accent-ink: #075c58;
  --warm: #b8664d;
  --shadow: 0 18px 44px rgba(28, 33, 30, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fffaf1 0, var(--bg) 420px),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 4px;
  background: transparent;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--warm));
}

.page-header,
.reading-layout,
.footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.page-header {
  padding: 24px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: #fffaf1;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.intro {
  max-width: 780px;
  padding: 62px 0 32px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-ink);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p,
li,
td,
th {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.8rem, 7vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.intro p:not(.eyebrow) {
  max-width: 690px;
  margin: 22px 0 0;
  color: #3f4945;
  font-size: clamp(1.03rem, 1.4vw, 1.18rem);
  line-height: 1.7;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.72);
  box-shadow: 0 10px 28px rgba(28, 33, 30, 0.06);
}

.section-tabs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 6px;
  color: #37433e;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.15;
}

.section-tabs a:hover,
.section-tabs a.active {
  background: var(--ink);
  color: white;
}

.reading-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 28px 0 70px;
}

.sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
}

.sidebar-inner {
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.78);
  box-shadow: 0 12px 30px rgba(28, 33, 30, 0.06);
}

.sidebar-title {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc {
  display: grid;
  gap: 3px;
  padding: 10px;
}

.toc a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: #3e4945;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 760;
  line-height: 1.28;
}

.toc a.depth-1 {
  margin-top: 5px;
  color: var(--ink);
  font-weight: 900;
}

.toc a.depth-2 {
  padding-left: 18px;
  color: #4c5853;
  font-size: 0.84rem;
}

.toc a:hover,
.toc a.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.document-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.document-content {
  padding: clamp(24px, 4vw, 48px);
}

.document-content section {
  scroll-margin-top: 18px;
}

.document-content section + section {
  margin-top: 54px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.document-content h1,
.document-content h2,
.document-content h3 {
  letter-spacing: 0;
}

.document-content h1 {
  margin: 0 0 32px;
  font-size: clamp(2.1rem, 4.5vw, 3.8rem);
  line-height: 1;
}

.document-content h2 {
  margin: 0 0 22px;
  font-size: clamp(1.55rem, 2.8vw, 2.35rem);
  line-height: 1.12;
}

.document-content h3 {
  margin: 28px 0 12px;
  color: #26312d;
  font-size: 1.08rem;
  line-height: 1.25;
}

.document-content p,
.document-content li {
  color: #3f4945;
  font-size: 1rem;
  line-height: 1.75;
}

.document-content p {
  margin: 0 0 12px;
}

.document-content ul {
  margin: 0 0 18px;
  padding-left: 22px;
}

.document-content li {
  margin: 6px 0;
}

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

.reply-line {
  margin-top: 18px;
  padding: 16px 18px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
}

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

.lead-table-wrap {
  width: 100%;
  margin: 18px 0 26px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.lead-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.lead-table th,
.lead-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
  line-height: 1.45;
}

.lead-table th {
  position: sticky;
  top: 0;
  background: #f1ebe0;
  color: #2b332f;
  font-weight: 900;
}

.lead-table tr:last-child td {
  border-bottom: 0;
}

.lead-table tr.total-row td {
  background: #f5fbf8;
  color: var(--ink);
  font-weight: 900;
}

.loading {
  min-height: 180px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0 40px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

@media (max-width: 980px) {
  .reading-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .sidebar-inner {
    max-height: 330px;
  }
}

@media (max-width: 640px) {
  .page-header,
  .reading-layout,
  .footer {
    width: calc(100% - 28px);
  }

  .intro {
    padding-top: 46px;
  }

  .section-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .section-tabs a {
    min-height: 44px;
  }

  .document-content {
    padding: 22px 18px;
  }
}
