:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-soft: #eef4f0;
  --text: #17211b;
  --muted: #607066;
  --line: #d9e2dc;
  --accent: #147d64;
  --accent-strong: #0f5e4b;
  --accent-soft: #d9f1e9;
  --warning: #b25c24;
  --shadow: 0 18px 44px rgba(30, 45, 36, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111715;
  --panel: #18211d;
  --panel-soft: #202c27;
  --text: #eef5f1;
  --muted: #aab9b1;
  --line: #2f4038;
  --accent: #45c5a5;
  --accent-strong: #74dcc2;
  --accent-soft: #173f35;
  --warning: #f0a05d;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px;
  z-index: 30;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
}

.sidebar-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.search-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ghost-button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.module-list {
  display: grid;
  gap: 10px;
}

.module {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.module-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: var(--panel-soft);
  color: var(--text);
  padding: 12px;
  text-align: left;
  font-weight: 750;
}

.module-toggle:hover {
  background: var(--accent-soft);
}

.module-title {
  min-width: 0;
}

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

.module-toggle small {
  color: var(--muted);
  font-weight: 600;
}

.module-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transition: transform 160ms ease;
  transform: rotate(45deg) translateY(-2px);
}

.module-toggle[aria-expanded="false"] .module-chevron {
  transform: rotate(-45deg);
}

.chapter-links {
  display: grid;
  gap: 4px;
  padding: 8px;
}

.module.collapsed .chapter-links {
  display: none;
}

.chapter-link {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.chapter-link:hover,
.chapter-link.active {
  background: var(--accent-soft);
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.chapter-link.complete .status-dot {
  background: var(--accent);
}

.chapter-link span:last-child {
  line-height: 1.35;
}

.content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  padding: 0 28px;
  z-index: 20;
}

.icon-button {
  display: none;
  width: 42px;
}

.progress-wrap {
  display: flex;
  width: min(420px, 100%);
  align-items: center;
  gap: 12px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 180ms ease;
}

.chapter {
  width: min(980px, calc(100% - 40px));
  margin: 34px auto 72px;
}

.chapter-header {
  margin-bottom: 22px;
}

.chapter-header p {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-weight: 750;
}

.chapter-header h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.06;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 750;
}

.section {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 16px 18px;
  font-size: 1.08rem;
}

.section-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.text-block {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
}

.list-block {
  margin: 0;
  padding-left: 22px;
  line-height: 1.65;
}

.note-box {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px;
  line-height: 1.55;
}

.warning-box {
  border-left-color: var(--warning);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

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

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.examples,
.practice-list {
  display: grid;
  gap: 10px;
}

.example-pair {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-soft);
}

.example-pair strong,
.practice-list li {
  display: block;
  color: var(--text);
}

.example-pair span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 25;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 330px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
  }

  .topbar {
    padding: 0 16px;
  }

  .chapter {
    width: min(100% - 28px, 980px);
    margin-top: 24px;
  }

  .progress-wrap {
    font-size: 0.82rem;
  }
}
