.reader {
  display: grid;
  grid-template-columns: 20.5rem minmax(0, 1fr);
  min-height: calc(100vh - 4.5rem);
}

.reader-sidebar {
  position: sticky;
  top: 4.5rem;
  height: calc(100vh - 4.5rem);
  overflow: hidden;
  background: var(--sidebar);
  color: var(--sidebar-text);
  transition: width 180ms ease, transform 180ms ease;
}

.reader.collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.reader.collapsed .reader-sidebar {
  width: 0;
  overflow: hidden;
}

.sidebar-toggle {
  position: fixed;
  top: 6.2rem;
  left: calc(20.5rem - 1.15rem);
  z-index: 70;
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.reader.collapsed .sidebar-toggle {
  left: 0.85rem;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  width: 20.5rem;
  height: 100%;
  padding: 2.8rem 1.5rem 0.9rem;
}

.sidebar-main {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.crumb {
  display: inline-flex;
  margin-bottom: 1.25rem;
  color: var(--sidebar-muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.sidebar-title {
  margin: 0 0 1.15rem;
  color: var(--sidebar-muted);
  font-size: 1.25rem;
  line-height: 1.2;
}

.sidebar-section-label {
  margin: 1.2rem 0 0.45rem;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.45rem;
  color: var(--sidebar-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.reset-button {
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-decoration: underline;
}

.progress-track {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--sidebar-strong);
}

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

.sidebar-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-progress {
  flex: 0 0 auto;
  margin: auto -0.35rem 0;
  padding: 0.7rem 0.35rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--sidebar);
}

.progress-scope {
  margin: 0 0 0.4rem;
  overflow: hidden;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.72rem 0.75rem 0.72rem 1rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.nav-item strong {
  min-width: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.nav-item small {
  display: none;
  margin-top: 0.35rem;
  color: var(--sidebar-muted);
  line-height: 1.35;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  color: var(--accent);
  font-weight: 900;
}

.status-icon.done {
  background: var(--accent);
  color: #ffffff;
}

.reader-content {
  min-width: 0;
  overflow-x: hidden;
  background: var(--surface);
}

.content-shell {
  width: 100%;
  max-width: var(--reader-width);
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 5rem) clamp(1.1rem, 6vw, 5rem) 5rem;
}

.kicker {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.content-shell h1 {
  margin: 0 0 1.35rem;
  color: var(--text);
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 1.04;
  overflow-wrap: anywhere;
}

.content-shell p,
.content-shell li {
  color: var(--text);
  font-size: 1.12rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.content-shell p {
  margin: 0 0 1.15rem;
}

.content-shell h2 {
  margin: 2rem 0 0.75rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.content-shell h3 {
  margin: 1.45rem 0 0.6rem;
  font-size: 1.2rem;
  line-height: 1.25;
}

.content-shell ul,
.content-shell ol {
  padding-left: 1.35rem;
}

.content-shell img,
.content-shell video,
.content-shell iframe {
  max-width: 100%;
  height: auto;
}

.content-shell a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.content-shell pre {
  max-width: 100%;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.45;
  white-space: pre;
}

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

.content-shell table {
  width: 100%;
  min-width: 38rem;
  border-collapse: collapse;
  background: var(--surface);
}

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

.content-shell th {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 900;
}

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

.test-yourself {
  display: grid;
  gap: 1.25rem;
  margin: 2.5rem 0;
  padding-top: 0.5rem;
  border-top: 2px solid var(--line);
}

.test-card,
.test-answer-key,
.qa-card {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg);
}

.test-card {
  padding: 1rem;
}

.test-section-title {
  margin-top: 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.test-mcq {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.test-mcq legend {
  margin-bottom: 0.8rem;
  color: var(--text);
  font-weight: 900;
  line-height: 1.45;
}

.mcq-options {
  display: grid;
  gap: 0.55rem;
}

.mcq-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  min-width: 0;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface);
}

.mcq-option input {
  margin-top: 0.28rem;
}

.option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.test-check-answer {
  min-height: 2.55rem;
  margin-top: 0.85rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 0.45rem;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.test-feedback {
  min-height: 1.5rem;
  margin: 0.7rem 0 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.45;
}

.test-feedback.correct {
  color: var(--accent);
}

.test-feedback.incorrect {
  color: var(--danger);
}

.test-answer-key,
.qa-card {
  overflow: hidden;
}

.test-answer-key summary,
.qa-card summary {
  cursor: pointer;
  padding: 0.9rem 1rem;
  color: var(--text);
  font-weight: 900;
  line-height: 1.4;
}

.test-answer-key[open] summary,
.qa-card[open] summary {
  border-bottom: 1px solid var(--line);
}

.answer-body {
  padding: 0.95rem 1rem 1rem;
}

.answer-body p:last-child,
.answer-body ol:last-child,
.answer-body ul:last-child {
  margin-bottom: 0;
}

.subject-overview-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 2rem;
}

.topic-preview {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg);
}

.subject-card {
  align-items: start;
  padding: 1.15rem;
}

.topic-preview h3 {
  margin: 0 0 0.35rem;
}

.subject-card h3 {
  margin-bottom: 0.7rem;
}

.subject-card ul {
  margin: 0;
  padding-left: 1.15rem;
}

.subject-card li {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.topic-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.lesson-actions,
.complete-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
}

.complete-button,
.test-yourself-button {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 3.4rem;
  padding: 0.85rem 1.35rem;
  border: 1px solid var(--accent);
  border-radius: 0.45rem;
  background: transparent;
  color: var(--accent);
  font-weight: 900;
}

.content-shell .test-yourself-button {
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

.complete-button .box {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid currentColor;
}

.complete-button.done {
  background: var(--accent);
  color: #ffffff;
}

@media (max-width: 860px) {
  .reader,
  .reader.collapsed {
    grid-template-columns: 1fr;
  }

  .reader-content {
    grid-column: 1;
    grid-row: 1;
  }

  .reader-sidebar {
    position: fixed;
    top: 4rem;
    left: 0;
    z-index: 60;
    width: 100vw;
    max-width: 100vw;
    height: calc(100vh - 4rem);
    box-shadow: var(--shadow);
  }

  .sidebar-inner {
    width: 100%;
    padding: 2.3rem 1.25rem 0.9rem;
  }

  .reader.collapsed .reader-sidebar {
    transform: translateX(-100%);
    width: 100vw;
  }

  .sidebar-toggle {
    top: 5.45rem;
    left: calc(100vw - 3.4rem);
  }

  .reader.collapsed .sidebar-toggle {
    left: 0.75rem;
  }

  .content-shell {
    padding: 4.4rem 1rem 4rem;
  }

  .content-shell h1 {
    font-size: clamp(1.8rem, 10vw, 2.6rem);
  }

  .content-shell p,
  .content-shell li {
    font-size: 1rem;
    line-height: 1.75;
  }

  .content-shell table {
    min-width: 34rem;
  }

  .topic-preview {
    grid-template-columns: 1fr;
  }

  .topic-preview > strong {
    justify-self: end;
  }

  .lesson-actions,
  .complete-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .complete-button,
  .test-yourself-button {
    justify-content: center;
    width: 100%;
  }
}
