:root {
  color-scheme: dark;
  --accent: #e2c08d;
  --accent-soft: rgba(226, 192, 141, 0.18);
  --accent-contrast: #121212;
  --border: #3d3528;
  --ink: #e0e0e0;
  --muted: #a9a9a9;
  --paper: #1a1a1a;
  --page: #0a0a0a;
  --topbar: rgba(25, 25, 25, 0.88);
  --shadow: rgba(0, 0, 0, 0.45);
  --table-head: #252525;
}

:root[data-theme='light'] {
  color-scheme: light;
  --accent: #8c7a58;
  --accent-soft: rgba(140, 122, 88, 0.15);
  --accent-contrast: #ffffff;
  --border: #d4cfc5;
  --ink: #1d1d1f;
  --muted: #6b6b6b;
  --paper: #ffffff;
  --page: #f5f5f7;
  --topbar: rgba(255, 255, 255, 0.9);
  --shadow: rgba(0, 0, 0, 0.08);
  --table-head: #f3f0ea;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #16130f 0%, var(--page) 220px);
  line-height: 1.6;
}

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

.page-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: var(--topbar);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px var(--shadow);
}

.topbar__nav {
  min-width: 0;
  flex: 1;
}

.topbar__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.hero {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 16px 48px var(--shadow);
  overflow: hidden;
}

.theme-toggle {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  text-decoration: none;
}

.hero__text {
  padding: 0 24px 32px;
}

.hero__text > p:first-child {
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
}

.hero__text > p:nth-child(2) {
  margin: 12px 0 28px;
  color: var(--muted);
}

#TOC {
  margin: 0;
  padding: 0;
}

#TOC ul {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}

#TOC a {
  display: block;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

h1 {
  margin: 52px 0 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  scroll-margin-top: 92px;
}

.hero__text > h1:first-of-type {
  margin-top: 36px;
}

h2 {
  margin: 32px 0 14px;
  color: var(--accent);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.3;
}

p,
ul,
table {
  margin: 0 0 16px;
}

ul {
  padding-left: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--border);
}

th {
  background: var(--table-head);
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100%, calc(100% - 20px));
  }

  .topbar {
    top: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    border-radius: 0 0 14px 14px;
  }

  .hero {
    border-radius: 18px;
  }

  .hero__text {
    padding: 0 16px 24px;
  }
}

@media print {
  .screen-only {
    display: none !important;
  }
}
