@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #f4efe4;
  --bg-strong: #efe4d0;
  --surface: rgba(255, 250, 241, 0.88);
  --surface-strong: #fff9ef;
  --surface-deep: #113347;
  --surface-deep-2: #1b4b56;
  --ink: #16222a;
  --ink-soft: #42515c;
  --line: rgba(20, 34, 42, 0.12);
  --line-strong: rgba(20, 34, 42, 0.24);
  --accent: #c46732;
  --accent-2: #2d8f89;
  --accent-3: #d9a441;
  --success: #2b7a4b;
  --shadow: 0 24px 60px rgba(13, 25, 33, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-width: 335px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(212, 154, 68, 0.15), transparent 32%),
    radial-gradient(circle at right 18%, rgba(45, 143, 137, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f1e6 0%, #f1e8d6 100%);
  min-height: 100vh;
}

body.sidebar-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(17, 51, 71, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 51, 71, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  opacity: 0.8;
}

.site-shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 19, 25, 0.48);
  backdrop-filter: blur(4px);
  z-index: 35;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  height: 100vh;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(16, 48, 66, 0.98), rgba(24, 62, 74, 0.97)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 40%);
  color: #f4efe7;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 40;
  overflow-y: auto;
}

.brand-block,
.sidebar-section,
.compact-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
}

.brand-block {
  padding: 1.2rem 1.1rem;
}

.brand-block h1 {
  margin: 0.1rem 0 0.55rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.85rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.brand-copy {
  margin: 0;
  color: rgba(244, 239, 231, 0.78);
  line-height: 1.45;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-3);
}

.mode-nav {
  display: grid;
  gap: 0.55rem;
  margin: 1.1rem 0 1rem;
}

.mode-link {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.05);
  color: #f8f3ea;
  border-radius: 999px;
  padding: 0.82rem 1rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.mode-link:hover,
.mode-link:focus-visible {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.1);
}

.mode-link.is-active {
  background: linear-gradient(135deg, rgba(212, 154, 68, 0.28), rgba(255, 255, 255, 0.08));
  border-color: rgba(212, 154, 68, 0.42);
}

.sidebar-section {
  padding: 1rem;
  margin-top: 1rem;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-section h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 0.34rem 0.62rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(244, 239, 231, 0.9);
  font-size: 0.77rem;
  font-weight: 700;
}

.topic-nav {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.95rem;
}

.topic-button {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: var(--radius-md);
  padding: 0.95rem;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.topic-button:hover,
.topic-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
}

.topic-button.is-active {
  border-color: rgba(212, 154, 68, 0.52);
  background: linear-gradient(135deg, rgba(212, 154, 68, 0.18), rgba(255, 255, 255, 0.05));
}

.topic-button-title {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  font-weight: 700;
}

.topic-button-copy {
  margin-top: 0.45rem;
  color: rgba(244, 239, 231, 0.7);
  font-size: 0.88rem;
  line-height: 1.4;
}

.topic-meter {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-top: 0.75rem;
}

.topic-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-3), var(--accent));
}

.compact-panel {
  padding: 1rem;
}

.compact-list {
  margin: 0.8rem 0 0;
  padding-left: 1rem;
  line-height: 1.5;
  color: rgba(244, 239, 231, 0.78);
}

.main-column {
  padding: 1.2rem 1.3rem 2rem;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 0.95rem 1rem 1rem;
  margin-bottom: 1rem;
  position: relative;
  top: auto;
  z-index: 22;
  background: rgba(247, 241, 230, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 44px rgba(13, 25, 33, 0.12);
}

.topbar h2 {
  margin: 0.2rem 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
  letter-spacing: -0.03em;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.sidebar-toggle-button {
  display: none;
}

.ghost-button,
.primary-button,
.secondary-button,
.tiny-button,
.answer-button {
  appearance: none;
  border: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  font-family: inherit;
}

.ghost-button {
  padding: 0.85rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.ghost-button:hover,
.primary-button:hover,
.secondary-button:hover,
.tiny-button:hover,
.answer-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(13, 25, 33, 0.1);
}

.hero-strip {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.hero-strip.hero-strip-compact {
  grid-template-columns: 1fr;
}

.hero-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -25% -32% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 143, 137, 0.18), transparent 70%);
  pointer-events: none;
}

.hero-card h3 {
  margin: 0.3rem 0 0.5rem;
  font-size: 1rem;
}

.hero-card strong {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.7rem;
  display: block;
  line-height: 1;
}

.hero-card p {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.reader-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 0.95rem 1.05rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.reader-summary-block {
  padding: 0.5rem 0.55rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.36);
  border: 1px solid rgba(17, 51, 71, 0.08);
}

.reader-summary-block strong {
  display: block;
  margin-top: 0.18rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.22rem;
  line-height: 1.08;
}

.reader-summary-block p:last-child {
  margin: 0.42rem 0 0;
  color: var(--ink-soft);
  line-height: 1.48;
  font-size: 0.9rem;
}

.view-root {
  display: grid;
  gap: 1rem;
}

.panel,
.card,
.reader-layout,
.reader-sidebar,
.reader-content,
.lab-card,
.flashcard-stage,
.quiz-card,
.result-card,
.glossary-card,
.search-card,
.dashboard-hero,
.roadmap-card,
.essay-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.dashboard-hero {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.2rem;
}

.dashboard-hero h3,
.panel-title,
.section-title,
.reader-content h3 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  letter-spacing: -0.02em;
}

.dashboard-hero h3 {
  font-size: clamp(1.7rem, 2vw, 2.6rem);
  line-height: 1.03;
}

.dashboard-hero p {
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.chip-row,
.action-row,
.metric-row,
.pill-row,
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.55rem 0.78rem;
  background: rgba(196, 103, 50, 0.12);
  color: #8d4218;
  font-size: 0.86rem;
  font-weight: 700;
}

.dashboard-grid,
.metrics-grid,
.topic-card-grid,
.practice-grid,
.lab-grid,
.glossary-grid,
.search-grid {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.topic-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.practice-grid,
.glossary-grid,
.search-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.roadmap-card,
.card,
.result-card,
.glossary-card,
.search-card,
.essay-card {
  padding: 1.2rem;
}

.roadmap-card h4,
.card h4,
.glossary-card h4,
.search-card h4,
.essay-card h4 {
  margin: 0;
  font-size: 1rem;
}

.subtle {
  color: var(--ink-soft);
}

.small {
  font-size: 0.9rem;
}

.primary-button {
  padding: 0.9rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #e0874e);
  color: #fff7ef;
  font-weight: 700;
}

.secondary-button,
.tiny-button,
.answer-button {
  background: rgba(17, 51, 71, 0.08);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 700;
}

.secondary-button {
  padding: 0.82rem 1rem;
}

.tiny-button {
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.tiny-button.is-active,
.segment-button.is-active {
  background: rgba(45, 143, 137, 0.14);
  color: #155e5a;
  border-color: rgba(45, 143, 137, 0.28);
}

.answer-button {
  padding: 0.75rem 0.95rem;
}

.topic-card {
  position: relative;
  overflow: hidden;
}

.topic-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.topic-card p {
  line-height: 1.55;
  color: var(--ink-soft);
}

.reader-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-areas: "sidebar content";
  gap: 1rem;
  overflow: visible;
  align-items: start;
  background: transparent;
  border: none;
  box-shadow: none;
}

.exam-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.sidebar,
.reader-sidebar,
.exam-sidebar,
.notes-input,
.equation-tex {
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar,
.reader-sidebar::-webkit-scrollbar,
.exam-sidebar::-webkit-scrollbar,
.notes-input::-webkit-scrollbar,
.equation-tex::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.reader-sidebar {
  grid-area: sidebar;
  padding: 1.15rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(239, 228, 208, 0.44));
  position: sticky;
  top: var(--reader-sticky-top, 108px);
  max-height: var(--reader-sidebar-height, calc(100vh - 126px));
  align-self: start;
  overflow-y: auto;
}

.exam-sidebar {
  padding: 1.15rem;
  position: sticky;
  top: var(--reader-sticky-top, 108px);
  max-height: var(--reader-sidebar-height, calc(100vh - 126px));
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(238, 229, 211, 0.55));
}

.exam-sidebar-block + .exam-sidebar-block {
  margin-top: 1rem;
}

.exam-selector-panel {
  padding: 1.3rem;
}

.exam-selector-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1rem;
}

.exam-set-card {
  appearance: none;
  width: 100%;
  text-align: left;
  padding: 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.exam-set-card:hover,
.exam-set-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(45, 143, 137, 0.26);
  box-shadow: 0 16px 32px rgba(13, 25, 33, 0.08);
}

.exam-set-card.is-active {
  background: linear-gradient(180deg, rgba(45, 143, 137, 0.12), rgba(255, 255, 255, 0.78));
  border-color: rgba(45, 143, 137, 0.34);
}

.exam-set-card h4,
.exam-option-copy,
.exam-score-panel h3 {
  margin: 0;
}

.exam-set-card p {
  line-height: 1.55;
  color: var(--ink-soft);
}

.exam-main {
  display: grid;
  gap: 1rem;
}

.exam-question-palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.exam-palette-button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(17, 51, 71, 0.06);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.62rem 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.exam-palette-button:hover,
.exam-palette-button:focus-visible {
  transform: translateY(-1px);
}

.exam-palette-button.is-current {
  border-color: rgba(196, 103, 50, 0.4);
  background: rgba(196, 103, 50, 0.14);
}

.exam-palette-button.is-answered {
  background: rgba(45, 143, 137, 0.1);
  border-color: rgba(45, 143, 137, 0.18);
}

.exam-palette-button.is-correct {
  background: rgba(43, 122, 75, 0.16);
  border-color: rgba(43, 122, 75, 0.28);
  color: #1d5c39;
}

.exam-palette-button.is-wrong {
  background: rgba(196, 103, 50, 0.16);
  border-color: rgba(196, 103, 50, 0.26);
  color: #8d4218;
}

.exam-topic-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.exam-topic-item p {
  margin-bottom: 0;
}

.exam-question-panel,
.exam-score-panel,
.exam-guidance-panel {
  padding: 1.3rem;
}

.exam-options {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.2rem;
}

.exam-option {
  appearance: none;
  display: grid;
  grid-template-columns: 44px 1fr 28px;
  gap: 0.85rem;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 1rem 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.exam-option:hover,
.exam-option:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(17, 51, 71, 0.24);
  box-shadow: 0 16px 32px rgba(13, 25, 33, 0.08);
}

.exam-option[disabled] {
  cursor: default;
}

.exam-option.is-selected {
  border-color: rgba(45, 143, 137, 0.3);
  background: rgba(45, 143, 137, 0.08);
}

.exam-option.is-correct {
  border-color: rgba(43, 122, 75, 0.32);
  background: rgba(43, 122, 75, 0.1);
}

.exam-option.is-wrong {
  border-color: rgba(196, 103, 50, 0.34);
  background: rgba(196, 103, 50, 0.1);
}

.exam-option-letter,
.exam-option-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  border-radius: 999px;
  font-weight: 800;
}

.exam-option-letter {
  background: rgba(17, 51, 71, 0.1);
}

.exam-option-index {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.exam-option-copy {
  line-height: 1.65;
  color: var(--ink);
}

.exam-explanation {
  margin-top: 1rem;
  padding: 1rem 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.exam-explanation.is-correct {
  border-color: rgba(43, 122, 75, 0.24);
  background: rgba(43, 122, 75, 0.08);
}

.exam-explanation.is-wrong {
  border-color: rgba(196, 103, 50, 0.24);
  background: rgba(196, 103, 50, 0.08);
}

.exam-explanation h4,
.exam-guidance-grid h4 {
  margin: 0;
}

.exam-explanation p:last-child {
  margin-bottom: 0;
}

.exam-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.exam-score-grid,
.exam-guidance-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.exam-score-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.exam-score-box span {
  display: block;
  margin-top: 0.22rem;
}

.exam-guidance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chapter-progress-panel,
.reader-sidebar-tools {
  margin-top: 1rem;
}

.chapter-progress-panel {
  padding: 0.9rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.chapter-progress-panel strong,
.chapter-progress-panel span {
  font-size: 0.88rem;
}

.reader-sidebar-tools {
  display: grid;
  gap: 0.75rem;
}

.sidebar-field,
.reader-control-group {
  display: grid;
  gap: 0.45rem;
}

.sidebar-field span,
.reader-control-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.reader-sidebar .section-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.section-jump {
  appearance: none;
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.92rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.section-jump:hover,
.section-jump:focus-visible {
  transform: translateX(2px);
  border-color: rgba(17, 51, 71, 0.24);
}

.section-jump.is-active {
  background: rgba(45, 143, 137, 0.12);
  border-color: rgba(45, 143, 137, 0.3);
}

.reader-content {
  grid-area: content;
  padding: 1.5rem;
  min-width: 0;
  overflow: visible;
}

.reader-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(17, 51, 71, 0.08);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.reader-copy {
  font-size: 1rem;
  line-height: 1.74;
}

.compact-copy {
  font-size: 0.96rem;
  line-height: 1.68;
}

.reader-utility-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.95rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.reader-control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.segment-button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(17, 51, 71, 0.06);
  color: var(--ink);
  padding: 0.58rem 0.8rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.segment-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(13, 25, 33, 0.08);
}

.reader-status-note {
  margin: -0.2rem 0 0.95rem;
  color: #155e5a;
  font-size: 0.92rem;
  font-weight: 700;
}

.reader-shortcut-note {
  margin: 0;
  width: 100%;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.reader-copy p {
  margin: 0 0 1rem;
}

.reader-copy h4,
.reader-copy h5 {
  margin: 1.6rem 0 0.65rem;
  font-size: 1.02rem;
  scroll-margin-top: calc(var(--reader-sticky-top, 108px) + 0.8rem);
}

.reader-copy code,
.inline-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92em;
  padding: 0.14rem 0.38rem;
  border-radius: 0.45rem;
  background: rgba(17, 51, 71, 0.08);
}

.reader-copy a {
  color: #0e6f8d;
}

.md-figure {
  margin: 1.35rem 0 1.6rem;
  padding: 0.95rem;
  border-radius: 24px;
  border: 1px solid rgba(17, 51, 71, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 238, 225, 0.95)),
    radial-gradient(circle at top right, rgba(45, 143, 137, 0.08), transparent 36%);
  box-shadow: 0 20px 40px rgba(17, 34, 42, 0.08);
}

.md-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(17, 51, 71, 0.1);
}

.md-figure figcaption {
  margin-top: 0.8rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.58;
}

.section-hero {
  margin-top: 0.2rem;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 235, 220, 0.96)),
    radial-gradient(circle at top right, rgba(45, 143, 137, 0.12), transparent 36%);
}

.section-hero figcaption {
  font-weight: 700;
}

.reader-copy .mjx-chtml,
.equation-tex .mjx-chtml,
.math-display .mjx-chtml,
.lab-result .mjx-chtml {
  font-size: 1.02em !important;
}

.math-display {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(17, 51, 71, 0.06);
  border: 1px solid rgba(17, 51, 71, 0.1);
  text-align: center;
}

.md-list {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
}

.md-list li {
  margin-bottom: 0.45rem;
  line-height: 1.64;
}

.reader-bottom-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}

.lesson-panel,
.section-toolkit-panel,
.companion-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.lesson-panel {
  margin-bottom: 1rem;
}

.section-toolkit-panel {
  margin-top: 1rem;
}

.chapter-companion-dock {
  margin-top: 1rem;
  padding: 1.15rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(241, 232, 214, 0.7)),
    radial-gradient(circle at top right, rgba(45, 143, 137, 0.1), transparent 34%);
  border-color: rgba(45, 143, 137, 0.16);
}

.section-lesson-note {
  margin: 0.35rem 0 1rem;
}

.study-doc {
  margin-top: 1rem;
}

.study-doc-block + .study-doc-block {
  margin-top: 1.15rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(17, 51, 71, 0.1);
}

.study-doc-block h4 {
  margin: 0 0 0.65rem;
}

.study-doc-block h5 {
  margin: 0 0 0.35rem;
}

.study-doc-block p {
  line-height: 1.72;
}

.linear-outline-list,
.linear-equation-stack,
.linear-example-stack {
  margin-top: 0.65rem;
}

.linear-equation-stack,
.linear-example-stack {
  display: grid;
  gap: 0.85rem;
}

.equation-note {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(17, 51, 71, 0.1);
  background: rgba(255, 255, 255, 0.56);
}

.equation-note p:last-child,
.linked-example p:last-child,
.companion-collapsed-copy {
  margin-bottom: 0;
}

.study-card h4,
.companion-card h4,
.companion-card h5 {
  margin: 0;
}

.section-recall-card {
  grid-column: 1 / -1;
}

.outline-list,
.companion-stack,
.compact-equation-list {
  display: grid;
  gap: 0.7rem;
}

.outline-link {
  appearance: none;
  width: 100%;
  text-align: left;
  padding: 0.72rem 0.82rem;
  border: 1px solid var(--line);
  background: rgba(17, 51, 71, 0.05);
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.outline-link:hover,
.outline-link:focus-visible {
  transform: translateX(2px);
  background: rgba(45, 143, 137, 0.1);
}

.outline-link.is-subheading {
  margin-left: 1rem;
  width: calc(100% - 1rem);
}

.linked-example p,
.study-card p,
.companion-card p {
  line-height: 1.6;
}

.linked-example strong {
  display: block;
  margin-bottom: 0.18rem;
}

.companion-header p,
.companion-header h3 {
  margin-bottom: 0.25rem;
}

.companion-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(17, 51, 71, 0.08);
}

.chapter-companion-dock.is-collapsed .companion-header {
  padding-bottom: 0;
  border-bottom: none;
}

.companion-collapsed-copy {
  margin-top: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.64;
}

.companion-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.companion-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(17, 51, 71, 0.06);
  color: var(--ink);
  padding: 0.58rem 0.78rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.companion-tab:hover,
.companion-tab:focus-visible {
  transform: translateY(-1px);
}

.companion-tab.is-active {
  background: rgba(45, 143, 137, 0.14);
  border-color: rgba(45, 143, 137, 0.3);
  color: #155e5a;
}

.companion-body {
  margin-top: 1rem;
}

.companion-card-grid {
  display: grid;
  gap: 0.8rem;
}

.dense-stack {
  gap: 0.9rem;
}

.compact-card {
  box-shadow: none;
}

.notes-input {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font: inherit;
  line-height: 1.55;
}

.notes-input:focus {
  outline: 2px solid rgba(45, 143, 137, 0.22);
  border-color: rgba(45, 143, 137, 0.3);
}

.equation-grid,
.worked-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.equation-card,
.worked-card {
  padding: 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.equation-card h4,
.worked-card h4 {
  margin: 0;
}

.equation-card p,
.worked-card p {
  color: var(--ink-soft);
  line-height: 1.6;
}

.equation-tex {
  margin: 0.85rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(17, 51, 71, 0.08), rgba(45, 143, 137, 0.05));
  border: 1px solid rgba(17, 51, 71, 0.1);
  overflow-x: auto;
}

.mini-panel {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.mini-panel h4 {
  margin: 0 0 0.65rem;
}

.mini-panel ul {
  margin: 0;
  padding-left: 1rem;
  line-height: 1.6;
}

.practice-toolbar,
.search-toolbar,
.glossary-toolbar,
.flashcard-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.toolbar-spacer {
  flex: 1;
}

.select,
.input,
.range-input {
  width: 100%;
  font: inherit;
}

.select,
.input {
  min-width: 220px;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.practice-layout,
.search-layout,
.glossary-layout,
.lab-layout {
  display: grid;
  gap: 1rem;
}

.practice-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.quiz-card {
  padding: 1.3rem;
}

.quiz-card h3,
.lab-card h3,
.flashcard-stage h3 {
  margin: 0 0 0.6rem;
  font-family: "Fraunces", Georgia, serif;
}

.question-counter {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.question-text {
  margin: 1rem 0 1.2rem;
  font-size: 1.12rem;
  line-height: 1.6;
}

.answer-block {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(45, 143, 137, 0.08);
  border: 1px solid rgba(45, 143, 137, 0.14);
}

.answer-block.is-hidden {
  display: none;
}

.confidence-grid {
  display: grid;
  gap: 0.6rem;
}

.confidence-button {
  width: 100%;
  text-align: left;
  padding: 0.78rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-weight: 700;
}

.confidence-button.is-active {
  border-color: rgba(196, 103, 50, 0.32);
  background: rgba(196, 103, 50, 0.1);
}

.result-card h4 {
  margin: 0;
}

.metric-box {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(17, 51, 71, 0.08);
}

.metric-box strong {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.55rem;
  margin-bottom: 0.2rem;
}

.flashcard-stage {
  padding: 1.4rem;
  display: grid;
  gap: 1rem;
}

.flashcard {
  position: relative;
  min-height: 280px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 238, 224, 0.96)),
    linear-gradient(135deg, rgba(45, 143, 137, 0.08), transparent 50%);
  padding: 1.4rem;
  overflow: hidden;
}

.flashcard::after {
  content: "";
  position: absolute;
  right: -3rem;
  bottom: -3rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 103, 50, 0.15), transparent 70%);
}

.flashcard-label {
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  font-weight: 700;
}

.flashcard-front,
.flashcard-back {
  position: relative;
  z-index: 1;
}

.flashcard-front p,
.flashcard-back p {
  font-size: 1.18rem;
  line-height: 1.6;
  margin: 1rem 0 0;
}

.flashcard-back.is-hidden {
  display: none;
}

.lab-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lab-card {
  padding: 1.3rem;
}

.lab-card p {
  color: var(--ink-soft);
  line-height: 1.58;
}

.field-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  font-weight: 700;
  font-size: 0.88rem;
}

.field input[type="number"],
.field input[type="text"] {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
  background: rgba(255, 255, 255, 0.82);
}

.range-row {
  display: grid;
  gap: 0.3rem;
}

.range-row output {
  color: var(--ink-soft);
  font-weight: 700;
}

.lab-result,
.lab-note {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(17, 51, 71, 0.08);
}

.canvas-wrap {
  margin-top: 1rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(230, 242, 239, 0.72));
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.glossary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.glossary-card p,
.search-card p {
  margin-bottom: 0;
  color: var(--ink-soft);
  line-height: 1.58;
}

.search-card button {
  margin-top: 0.9rem;
}

.empty-state {
  padding: 1.4rem;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

.footer-note {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

body.reader-focus-mode .reader-layout {
  grid-template-columns: 1fr;
  grid-template-areas: "content";
}

body.reader-focus-mode .reader-sidebar {
  display: none;
}

body.reader-focus-mode .reader-content {
  max-width: 960px;
  margin: 0 auto;
}

body.reader-scale-compact .reader-copy {
  font-size: 0.96rem;
  line-height: 1.68;
}

body.reader-scale-large .reader-copy {
  font-size: 1.08rem;
  line-height: 1.86;
}

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

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(380px, 86vw);
    min-height: 100vh;
    overflow-y: auto;
    box-shadow: 0 28px 64px rgba(8, 20, 29, 0.28);
    transform: translateX(calc(-100% - 12px));
    transition: transform 220ms ease;
  }

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

  .hero-strip,
  .reader-summary-strip,
  .dashboard-grid,
  .topic-card-grid,
  .metrics-grid,
  .reader-bottom-grid,
  .equation-grid,
  .worked-grid,
  .practice-grid,
  .exam-selector-grid,
  .exam-score-grid,
  .exam-guidance-grid,
  .glossary-grid,
  .lab-grid {
    grid-template-columns: 1fr;
  }

  .reader-layout,
  .exam-layout,
  .practice-layout,
  .dashboard-hero {
    grid-template-columns: 1fr;
    height: auto;
  }

  .reader-layout {
    grid-template-areas:
      "content"
      "sidebar";
  }

  .reader-sidebar,
  .exam-sidebar,
  .reader-content {
    overflow: visible;
  }

  .reader-sidebar {
    position: static;
    top: auto;
    max-height: none;
    border-bottom: 1px solid var(--line);
  }

  .exam-sidebar {
    position: static;
    top: auto;
    max-height: none;
    order: 2;
  }

  .exam-main {
    order: 1;
  }

  .sidebar-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .main-column {
    padding: 0.9rem 0.8rem 1.4rem;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    top: 0.45rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .ghost-button,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .reader-control-actions,
  .reader-utility-bar {
    width: 100%;
  }

  .reader-summary-strip,
  .reader-control-actions > *,
  .segment-button {
    width: 100%;
  }

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

  .section-toolkit-grid {
    grid-template-columns: 1fr;
  }

  .exam-question-palette {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .exam-option {
    grid-template-columns: 38px 1fr;
  }

  .exam-option-index {
    display: none;
  }

  .practice-grid,
  .search-grid {
    grid-template-columns: 1fr;
  }

  .select,
  .input {
    min-width: 0;
  }
}
