:root {
  color-scheme: light;
  --bg: #faf6f0;
  --surface: #fffdfa;
  --surface-2: #f3ece1;
  --text: #2b241c;
  --muted: #8a7d6d;
  --accent: #b45309;
  --accent-soft: #fbe9d0;
  --link: #0f766e;
  --border: #e5dacb;
  --shadow: 0 1px 3px rgba(60, 40, 10, 0.08), 0 8px 24px rgba(60, 40, 10, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17120d;
  --surface: #201a13;
  --surface-2: #2a2218;
  --text: #f2e9dc;
  --muted: #a8947c;
  --accent: #f59e0b;
  --accent-soft: #3a2c15;
  --link: #5eead4;
  --border: #3a2f22;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Header ---------- */

.site-header {
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px 40px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.site-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.site-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 46ch;
}

.theme-toggle {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, background 0.3s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(10deg);
}

/* ---------- Main ---------- */

.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.step-section {
  margin-top: 44px;
}

.step-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.step-badge {
  background: var(--accent);
  color: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
}

.step-name {
  margin: 0;
  font-size: 1.6rem;
}

.step-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Chapter tiles ---------- */

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.chapter-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chapter-wrap:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(60, 40, 10, 0.12), 0 12px 28px rgba(60, 40, 10, 0.1);
}

.chapter-tile {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chapter-tile-info {
  min-width: 0;
}

.chapter-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
}

.chapter-count {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 10px;
}

.chapter-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.3s ease, color 0.2s ease;
}

.chapter-wrap.open .chapter-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* ---------- Accordion panel ---------- */

.chapter-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.chapter-wrap.open .chapter-panel {
  grid-template-rows: 1fr;
}

.chapter-panel-inner {
  overflow: hidden;
  border-top: 1px solid var(--border);
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.topic-item {
  border-bottom: 1px solid var(--border);
}

.topic-item:last-child {
  border-bottom: 0;
}

.topic-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px;
  color: var(--link);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.topic-link:hover {
  background: var(--surface-2);
  color: var(--accent);
  padding-left: 22px;
}

.topic-arrow {
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s ease, transform 0.15s ease;
}

.topic-link:hover .topic-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 20px 36px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    padding-top: 36px;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }
}
