:root {
  color-scheme: light;
  --ink: #16212a;
  --muted: #58656f;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --line: #d7dde0;
  --accent: #165a72;
  --accent-soft: #e7f1f4;
  --warm: #8a4c2c;
  --max: 72rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.62;
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.14em; }
a:focus-visible { outline: 3px solid #e1a65a; outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 20;
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 1rem; }

.site-bar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}

.site-bar__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  font-size: 0.92rem;
}

.site-bar a { font-weight: 650; text-decoration: none; }
.site-bar__label { color: var(--muted); }

.layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.content { min-width: 0; }
.content > :first-child { margin-top: 0; }

h1, h2, h3 {
  line-height: 1.17;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.2rem, 6vw, 4.4rem); margin: 0 0 0.4rem; max-width: 18ch; }
h2 { font-size: clamp(1.55rem, 3vw, 2.1rem); margin-top: 3.2rem; padding-top: 0.3rem; border-top: 2px solid var(--ink); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); margin-top: 2.2rem; }

p { max-width: 72ch; }
.content > p:first-of-type { color: var(--muted); font-size: 1.08rem; }

.content img {
  display: block;
  width: 100%;
  max-height: 31rem;
  object-fit: cover;
  margin: 1.35rem 0 0.75rem;
  border-radius: 0.45rem;
  box-shadow: 0 1px 0 rgba(22, 33, 42, 0.12);
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.8rem 1.1rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}

ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 0.35rem; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3rem 0 2rem;
  font-size: 0.93rem;
  background: var(--surface);
}

th, td { padding: 0.7rem 0.75rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--accent-soft); font-weight: 700; }
tbody tr:nth-child(even) { background: #f7f8f6; }

.toc-panel {
  position: sticky;
  top: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface);
  padding: 1rem 1.1rem;
  font-size: 0.9rem;
}
.toc-panel .toc { margin: 0; }
.toc-panel .toctitle { display: block; font-weight: 750; margin-bottom: 0.5rem; }
.toc-panel ul { list-style: none; padding: 0; margin: 0; }
.toc-panel ul ul { padding-left: 0.85rem; margin-top: 0.3rem; border-left: 1px solid var(--line); }
.toc-panel li + li { margin-top: 0.45rem; }
.toc-panel a { color: var(--ink); text-decoration: none; }
.toc-panel a:hover { color: var(--accent); text-decoration: underline; }

.page-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}
.page-footer__inner { max-width: var(--max); margin: 0 auto; padding: 1.3rem clamp(1rem, 4vw, 2.5rem); }

@media (max-width: 54rem) {
  .layout { grid-template-columns: 1fr; }
  .toc-panel { position: static; grid-row: 1; }
  .toc-panel ul ul { display: none; }
  .site-bar__label { display: none; }
  table { display: block; overflow-x: auto; }
}

@media (max-width: 36rem) {
  body { font-size: 0.97rem; }
  .layout { padding-top: 1.25rem; }
  h2 { margin-top: 2.5rem; }
  th, td { min-width: 8.5rem; padding: 0.58rem; }
}

@media print {
  @page { size: A4; margin: 13mm; }
  body { background: white; font-size: 9.5pt; line-height: 1.42; }
  .site-bar, .toc-panel, .skip-link, .page-footer { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  h1 { font-size: 24pt; }
  h2 { font-size: 16pt; margin-top: 1.5rem; break-after: avoid; }
  h3 { font-size: 12pt; break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  table { font-size: 7.8pt; break-inside: auto; }
  tr, img { break-inside: avoid; }
  .content img { max-height: 9cm; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
}
