:root {
  color-scheme: light;
  --bg: #eef2f0;
  --panel: #ffffff;
  --panel-soft: #f5f8f6;
  --ink: #263238;
  --muted: #667273;
  --line: #d6dfdc;
  --accent: #1f4d5a;
  --accent-2: #9d5c39;
  --accent-3: #6c8c7d;
  --focus: #c88538;
  --shadow: 0 18px 45px rgba(38, 50, 56, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: #fbfdfc;
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

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

.eyebrow,
.label,
.search-label {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1,
.top-panel h2 {
  margin: 2px 0 0;
  line-height: 1.15;
}

.brand h1 {
  font-size: 20px;
}

.search-label {
  display: block;
  margin-bottom: 8px;
}

.search {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(207, 140, 68, 0.18);
}

.progress-card,
.insight-card {
  margin: 16px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe7e2;
}

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

.chapter-nav {
  display: grid;
  gap: 8px;
}

.chapter-link {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.chapter-link:hover,
.chapter-link.active {
  border-color: var(--line);
  background: #fff;
}

.chapter-link.active {
  box-shadow: 0 8px 20px rgba(38, 50, 56, 0.07);
}

.chapter-link .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-link .title {
  font-weight: 800;
}

.done-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d5ccbd;
}

.chapter-link.done .done-dot {
  background: var(--accent-3);
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 56px) 56px;
}

.top-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 20px;
  max-width: 1100px;
}

.top-panel h2 {
  font-size: clamp(28px, 4vw, 44px);
}

.subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button:focus-visible,
.chapter-link:focus-visible {
  outline: 3px solid rgba(207, 140, 68, 0.45);
  outline-offset: 2px;
}

.study-board {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 0.8fr);
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto 22px;
}

.map-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.map-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: cover;
}

.insight-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 180px;
  margin: 0;
  background: #fff;
  box-shadow: var(--shadow);
}

.insight-card p {
  margin: 10px 0 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
}

.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 34px clamp(18px, 4vw, 44px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.content h1,
.content h2,
.content h3 {
  line-height: 1.28;
}

.content h1 {
  margin: 0 0 22px;
  font-size: 34px;
}

.content h2 {
  margin: 34px 0 10px;
  padding-top: 8px;
  border-top: 1px solid #e3e9e6;
  font-size: 23px;
}

.content h3 {
  margin: 24px 0 8px;
  font-size: 18px;
}

.content p,
.content ul,
.content ol,
.content blockquote {
  margin: 0 0 16px;
}

.content ul,
.content ol {
  padding-left: 24px;
}

.content li {
  margin: 6px 0;
}

.content blockquote {
  padding: 12px 16px;
  border-left: 4px solid var(--accent-3);
  background: #f4f7f5;
  color: #3b4749;
}

.content a {
  color: var(--accent);
  font-weight: 700;
  text-underline-offset: 3px;
}

.content code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #edf2ef;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 15px;
}

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

.content th {
  background: #f4f7f5;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chapter-nav {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .top-panel,
  .study-board {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: start;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .main {
    padding: 18px;
  }

  .brand {
    grid-template-columns: 40px 1fr;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .top-panel h2 {
    font-size: 28px;
  }

  .subtitle {
    font-size: 16px;
  }

  .content {
    padding: 24px 18px;
  }

  .content h1 {
    font-size: 28px;
  }
}
