@font-face {
  font-family: 'Noto Sans KR';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./assets/fonts/NotoSansKR.woff2') format('woff2');
}

:root {
  --ink: #1f2933;
  --muted: #475569;
  --green: #285a46;
  --green-light: #eef5f0;
  --paper: #f8f9fa;
  --card: #fff;
  --line: #d5dce1;
  --red: #9b302c;
  --font: 'Noto Sans KR', 'Noto Sans CJK KR', 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
}

html { font-size: 18px; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 1rem/1.8 var(--font); letter-spacing: normal; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, summary { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--green); }
svg { display: block; }
:is(button, a, input, select, summary):focus-visible { outline: 3px solid #467aaf; outline-offset: 3px; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.55; overflow-wrap: anywhere; }
h1, h2 { font-size: 1.375rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; background: var(--green); color: white; padding: 10px 20px; }
.skip-link:focus { top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* The subject selector is the first visible content on every screen. */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  position: fixed;
  inset: 0 auto 0 0;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
  z-index: 20;
}
.brand { padding: 0 10px; margin-bottom: 26px; }
.brand-name { font-size: 1.375rem; font-weight: 700; }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; padding: 10px; border: 0; border-radius: 4px; background: transparent; text-align: left; color: var(--muted); }
.nav-item > span:first-of-type { min-width: 0; overflow-wrap: anywhere; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: #f1f4f3; }
.nav-item.active { background: var(--green-light); color: var(--green); font-weight: 700; }
.nav-badge { margin-left: auto; font-size: .875rem; flex: none; }
.sidebar-course { margin-top: 24px; padding: 18px 6px 0; border-top: 1px solid var(--line); }
.sidebar-course-label { margin: 0 0 10px; color: var(--muted); font-size: .875rem; font-weight: 600; }
.course-link { width: 100%; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 4px; border: 0; background: transparent; color: var(--muted); text-align: left; overflow-wrap: anywhere; }
.course-link.active { color: var(--green); font-weight: 700; }
.course-count { margin-left: auto; font-size: .875rem; }
.sidebar-bottom { margin-top: auto; padding: 24px 10px 0; }
.reset-link, .text-btn { min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); font-size: .875rem; text-decoration: underline; text-underline-offset: 3px; }
.main-wrap { margin-left: 200px; flex: 1; min-width: 0; }
.content { max-width: 1280px; margin: 0 auto; padding: 28px 32px 40px; }
.subject-selector { margin-bottom: 20px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 1.25rem; }
.section-head > span { color: var(--muted); font-size: .875rem; }
.subject-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.subject-card { min-width: 0; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); text-align: left; }
.subject-card:hover { border-color: var(--green); }
.subject-card.active { border-color: var(--green); background: var(--green-light); }
.subject-name { display: block; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.subject-card-meta { display: block; color: var(--muted); font-size: .875rem; word-break: keep-all; overflow-wrap: normal; }
.workspace-tabs { display: flex; flex-wrap: wrap; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.workspace-tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 10px 0; margin-bottom: -1px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 1rem; }
.workspace-tab svg { width: 17px; height: 17px; flex: none; }
.workspace-tab.active { border-bottom-color: var(--green); color: var(--green); font-weight: 700; }
.tab-count { font-size: .875rem; }
.mobile-nav { display: none; }
.hint-text, .topic-label { color: var(--muted); font-size: .875rem; }
.topic-label { overflow-wrap: anywhere; }

/* Shared controls and status messages. */
.toolbar, .toolbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.toolbar { justify-content: space-between; margin-bottom: 18px; }
.search-wrap { position: relative; min-width: 230px; flex: 1; }
.search-wrap svg { position: absolute; left: 12px; top: 15px; width: 17px; height: 17px; color: var(--muted); }
.search-input, select { min-height: 46px; padding: 9px 12px; border: 1px solid #b8c2ca; border-radius: 4px; background: #fff; max-width: 100%; font-size: 1rem; }
.search-input { width: 100%; padding-left: 39px; }
.search-input::placeholder { color: var(--muted); opacity: 1; }
.primary-btn, .secondary-btn, .danger-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 16px; border: 1px solid transparent; border-radius: 4px; font-size: 1rem; font-weight: 600; line-height: 1.7; }
.primary-btn { background: var(--green); color: #fff; }
.primary-btn:hover { background: #204a39; }
.secondary-btn { background: #fff; border-color: #b8c2ca; color: var(--ink); }
.secondary-btn:hover { background: #f0f4f2; }
.danger-btn { background: var(--red); color: #fff; }
.primary-btn svg, .secondary-btn svg, .danger-btn svg { width: 17px; height: 17px; flex: none; }
.segmented, .practice-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.segment { min-height: 44px; padding: 8px 13px; border: 1px solid #b8c2ca; border-radius: 4px; background: #fff; color: var(--muted); font-size: .9375rem; }
.segment.active { border-color: var(--green); color: var(--green); background: var(--green-light); font-weight: 700; }
.empty-state { grid-column: 1 / -1; padding: 40px 20px; text-align: center; }
.empty-state h3 { margin: 0 0 10px; }
.empty-state p { max-width: 540px; margin: 0 auto; color: var(--muted); }
.empty-state button { margin-top: 20px; }
.storage-warning { padding: 12px 16px; margin-bottom: 20px; border: 1px solid #dac8a9; background: #fff8e8; border-radius: 4px; color: #674b27; }
.source-notes { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9375rem; }
.source-notes summary, .source-details summary, .review-item summary, .lesson-question-list summary { cursor: pointer; padding: 6px 0; }
.source-notes p, .source-details p { margin: 8px 0; white-space: pre-line; overflow-wrap: anywhere; }
.page-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; color: var(--muted); font-size: .875rem; }
.page-footer .text-btn { margin-left: 10px; }
.toast { position: fixed; bottom: 24px; left: calc(50% + 100px); transform: translate(-50%, 12px); max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 4px; background: var(--green); color: #fff; font-size: 1rem; text-align: center; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 70; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.modal-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: #18232b80; z-index: 80; }
.modal { width: 100%; max-width: 500px; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.modal h2 { margin: 0 0 12px; }
.modal p { margin: 0 0 24px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* Related concept lessons. */
.lesson-overview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.lesson-overview-head h2 { margin: 0 0 8px; }
.lesson-overview-head p { max-width: 70ch; margin: 0; color: var(--muted); font-size: 1rem; }
.lesson-overview-progress { flex: none; font-size: 1.125rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.lesson-overview-progress small { display: block; margin-top: 3px; color: var(--muted); font-size: .875rem; font-weight: 400; }
.lesson-toolbar .search-wrap { min-width: 270px; }
.lesson-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.lesson-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.lesson-card:hover, .lesson-card.is-learned { border-color: #769582; }
.lesson-card-body { flex: 1; padding: 20px; }
.lesson-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lesson-number { color: var(--muted); font-size: .9375rem; font-weight: 600; flex: none; }
.lesson-check { margin-left: auto; color: var(--green); }
.lesson-check svg { width: 20px; height: 20px; }
.lesson-card h3 { margin: 0 0 10px; font-size: 1.25rem; }
.lesson-title-button { padding: 0; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; overflow-wrap: anywhere; }
.lesson-title-button:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.lesson-card-summary { margin: 0 0 16px; color: var(--ink); font-size: 1rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-relation { margin-bottom: 16px; padding-left: 12px; border-left: 2px solid #92ac9e; }
.lesson-relation span { font-size: .875rem; color: var(--muted); }
.lesson-relation p { margin: 4px 0 0; font-size: 1rem; font-weight: 500; line-height: 1.85; overflow-wrap: anywhere; }
.lesson-card-formats { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .875rem; }
.lesson-card-formats span { display: inline-flex; align-items: center; gap: 5px; }
.lesson-card-formats svg { width: 16px; height: 16px; flex: none; }
.lesson-card-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.lesson-card-footer button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: .9375rem; font-weight: 600; }
.lesson-card-footer button svg { width: 17px; height: 17px; }
.lesson-card-progress { height: 3px; background: #edf1ee; }
.lesson-card-progress span { display: block; height: 100%; background: #5e876e; }
.lesson-breadcrumb { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; color: var(--muted); font-size: .875rem; }
.lesson-back { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 1rem; }
.lesson-back svg { width: 18px; height: 18px; }
.lesson-detail-header { padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.lesson-context { margin: 0 0 6px; color: var(--muted); font-size: .875rem; }
.lesson-detail-header h2 { margin: 4px 0 12px; font-size: 1.5rem; }
.lesson-summary { max-width: 78ch; margin: 0; font-size: 1.0625rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-key-idea { margin-top: 18px; }
.lesson-key-idea > span { color: var(--muted); font-size: .875rem; }
.lesson-key-idea p { max-width: 78ch; margin: 5px 0 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-detail-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 18px; color: var(--muted); font-size: .875rem; }
.lesson-detail-meta .is-complete { color: var(--green); font-weight: 700; }
.lesson-detail-layout { display: grid; grid-template-columns: 165px minmax(0, 1fr); gap: 26px; align-items: start; }
.lesson-outline { position: sticky; top: 20px; padding-left: 14px; border-left: 2px solid var(--line); font-size: .875rem; }
.lesson-outline h3 { margin: 0 0 12px; font-size: 1rem; }
.lesson-outline ol { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.lesson-outline a { display: block; color: var(--muted); text-decoration: none; line-height: 1.8; overflow-wrap: anywhere; }
.lesson-outline a:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.lesson-reading { min-width: 0; }
.lesson-block, .lesson-diagram, .lesson-remember, .lesson-related { scroll-margin-top: 22px; margin-bottom: 26px; }
.lesson-section { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.lesson-block-heading { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.lesson-block-heading h3, .lesson-diagram h3 { margin: 0; font-size: 1.25rem; }
.lesson-section-number { color: var(--muted); font-size: .9375rem; line-height: 2.1; flex: none; }
.lesson-prose p { max-width: 78ch; margin: 0 0 16px; font-size: 1.0625rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-prose p:last-child { margin-bottom: 0; }
.lesson-comparison { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.comparison-scroll { width: 100%; max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 3px; }
.lesson-comparison table { width: 100%; border-collapse: collapse; color: var(--ink); font-size: .9375rem; line-height: 1.85; text-align: left; }
.lesson-comparison th, .lesson-comparison td { min-width: 110px; padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-comparison thead th { background: #edf2ef; font-weight: 700; }
.lesson-comparison tbody th { background: #f5f7f6; font-weight: 600; }
.lesson-comparison tr:last-child th, .lesson-comparison tr:last-child td { border-bottom: 0; }
.lesson-comparison tr > :last-child { border-right: 0; }
.lesson-source-hint { margin: 12px 0 0; color: var(--muted); font-size: .875rem; }

/* Diagrams retain their arrows, hierarchy, positions, and numerical scale. */
.lesson-diagram { min-width: 0; margin-inline: 0; padding: 20px; border: 1px solid var(--line); border-radius: 5px; background: #f3f6f4; }
.lesson-diagram figcaption { margin-bottom: 20px; }
.figure-note { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.flow-diagram { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 25px; margin: 0; padding: 0; list-style: none; }
.flow-diagram li { position: relative; flex: 1 1 0; min-width: 0; padding: 14px; border: 1px solid #bfcfc5; border-radius: 4px; background: #fff; }
.flow-step-number { display: block; margin-bottom: 5px; color: var(--muted); font-size: .875rem; font-weight: 600; }
.flow-diagram li strong { display: block; font-size: 1rem; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.flow-diagram li p { margin: 6px 0 0; color: var(--muted); font-size: .9375rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.flow-arrow { position: absolute; top: 30px; right: -23px; color: var(--green); font-size: 1.25rem; line-height: 1; z-index: 1; }
.cycle-diagram li:first-child { border-color: #7b9b87; }
.cycle-return { margin: 14px 0 0; padding: 8px 12px; border-top: 1px solid #bfcfc5; text-align: center; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.cycle-return span { display: inline-block; margin-right: 7px; font-size: 1.375rem; color: var(--green); }
.long-flow { flex-direction: column; gap: 25px; }
.long-flow li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0 10px; flex-basis: auto; }
.long-flow .flow-step-number { grid-row: 1 / 3; margin: 0; line-height: 2.1; }
.long-flow li strong, .long-flow li p { grid-column: 2; }
.long-flow li .flow-arrow { top: auto; right: auto; bottom: -23px; left: 50%; transform: rotate(90deg); }
.branch-root { max-width: 460px; margin: 0 auto; padding: 12px 18px; border: 1px solid #789682; border-radius: 4px; background: #e7f0eb; color: var(--ink); text-align: center; font-size: 1rem; font-weight: 700; white-space: pre-line; overflow-wrap: anywhere; }
.branch-children { position: relative; display: flex; flex-wrap: wrap; gap: 26px 18px; padding-top: 30px; }
.branch-children::before { content: ''; position: absolute; top: 0; left: 50%; width: 1px; height: 16px; background: #91a899; }
.branch-column { position: relative; flex: 1 1 160px; min-width: 0; padding: 14px; border: 1px solid #bfcfc5; border-radius: 4px; background: #fff; }
.branch-column::before { content: '↓'; position: absolute; top: -26px; left: calc(50% - 6px); color: var(--green); font-size: 1.25rem; line-height: 1; }
.branch-column h4 { margin: 0 0 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 1rem; }
.branch-column ul { margin: 0; padding: 0; list-style: none; }
.branch-column li { margin-top: 12px; padding-left: 10px; border-left: 2px solid #c9d7ce; }
.branch-column li strong { display: block; font-size: .9375rem; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
.branch-column li p { margin: 4px 0 0; color: var(--muted); font-size: .9375rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.position-map { width: 100%; max-width: 100%; overflow-x: auto; }
.position-map-heading, .position-level {
  display: grid;
  grid-template-columns: 72px 20px repeat(var(--position-columns), minmax(90px, 1fr));
  min-width: calc(100px + var(--position-columns) * 100px);
  gap: 0 8px;
  align-items: center;
}
.position-map-heading { padding-bottom: 12px; border-bottom: 1px solid #bfcec4; color: var(--muted); font-size: .875rem; align-items: end; }
.position-map-heading strong { font-size: .875rem; color: var(--ink); overflow-wrap: anywhere; }
.position-levels { margin: 0; padding: 0; list-style: none; }
.position-level { align-items: stretch; min-height: 66px; }
.position-label { align-self: center; color: var(--ink); font-size: .875rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.position-spine { position: relative; display: grid; place-items: center; }
.position-spine::before { content: ''; position: absolute; inset: 0 auto; width: 3px; background: #99b1a2; }
.position-spine i { width: 13px; height: 13px; border: 3px solid #f3f6f4; outline: 1px solid #8fa796; border-radius: 50%; background: #487252; z-index: 1; }
.position-level:first-child .position-spine::before { top: 50%; }
.position-level:last-child .position-spine::before { bottom: 50%; }
.position-cell { align-self: center; margin: 7px 0; padding: 9px 10px; border: 1px solid #c7d5cc; border-radius: 4px; background: #fff; color: var(--ink); font-size: .9375rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.position-cell:empty { border-color: transparent; background: transparent; }
.position-map-key { margin: 14px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.85; }
.position-map-key span { color: var(--green); }
.bar-scale { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 8px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.bar-diagram ul { margin: 0; padding: 0 0 0 12px; list-style: none; border-left: 2px solid #8ca495; }
.bar-diagram li { padding: 10px 0 16px; }
.bar-item-label { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 7px; font-size: .9375rem; }
.bar-item-label strong { font-weight: 600; }
.bar-item-label span { color: var(--green); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 20px; background: #dde6df; }
.bar-fill { height: 100%; min-width: 0; background: #60896d; }
.bar-baseline-note { margin: 10px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.85; }
.lesson-remember { padding: 20px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.memory-anchor { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; padding: 14px 16px; background: #f0f5f1; border-left: 3px solid #789880; }
.memory-anchor p { margin: 0; font-size: 1.0625rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-pitfalls { margin: 20px 0; padding-left: 15px; border-left: 3px solid #c0a56a; }
.lesson-pitfalls h4 { margin: 0 0 8px; font-size: 1rem; }
.lesson-pitfalls ul { margin: 0; padding-left: 20px; font-size: 1rem; line-height: 1.9; }
.lesson-pitfalls li { margin: 8px 0; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-review-notes { margin: 20px 0; padding: 14px 16px; border: 1px solid #dac8a9; border-radius: 4px; background: #fff8e8; }
.lesson-review-notes h4 { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; font-size: 1rem; color: #674b27; }
.lesson-review-notes h4 svg { width: 18px; height: 18px; flex: none; }
.lesson-review-notes p { margin: 10px 0 0; font-size: 1rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-study-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.lesson-study-actions .primary-btn { flex: 1; }
.lesson-study-note { margin: 12px 0 0; color: var(--muted); font-size: .875rem; line-height: 1.85; }
.lesson-complete { border-color: #789880; color: var(--green); background: var(--green-light); }
.lesson-related > div:last-child { display: flex; flex-direction: column; gap: 8px; }
.lesson-related button { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 1rem; text-align: left; }
.lesson-related svg { width: 18px; height: 18px; flex: none; }
.lesson-question-list { margin: 24px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 1rem; }
.lesson-question-list summary { font-weight: 600; }
.lesson-question-list > p { margin: 10px 0 0; color: var(--muted); font-size: .875rem; }
.lesson-question-list ul { margin: 0; padding: 0; list-style: none; }
.lesson-question-list li { display: flex; align-items: center; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.lesson-question-list li:last-child { border: 0; }
.lesson-question-list li > div { flex: 1; min-width: 0; }
.lesson-question-list li > div > span { color: var(--muted); font-size: .875rem; }
.lesson-question-list li p { margin: 4px 0 0; font-size: 1rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.lesson-question-list .secondary-btn { flex: none; font-size: .9375rem; padding: 8px 12px; }
.lesson-next-prev { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.lesson-next-prev button { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: .875rem; text-align: left; line-height: 1.8; }
.lesson-next-prev button:last-child { justify-content: flex-end; text-align: right; }
.lesson-next-prev button > span { min-width: 0; }
.lesson-next-prev button strong { display: block; color: var(--ink); font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.lesson-next-prev button svg { width: 18px; height: 18px; flex: none; }
.lesson-practice-context { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid #bfd0c4; border-radius: 4px; background: var(--green-light); }
.lesson-practice-context > div { min-width: 0; }
.lesson-practice-context span { display: block; color: var(--muted); font-size: .875rem; }
.lesson-practice-context strong { display: block; margin-top: 4px; font-size: 1rem; overflow-wrap: anywhere; }

/* Questions, explanations, and review use the same readable text sizes. */
.practice-summary { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 4px; background: #f0f5f1; }
.practice-summary svg { width: 20px; height: 20px; margin-top: 4px; flex: none; color: var(--green); }
.practice-summary p { margin: 0; color: var(--muted); font-size: .9375rem; }
.question-card { min-width: 0; padding: 26px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.question-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 20px; }
.question-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.question-index { color: var(--muted); font-size: .875rem; font-weight: 700; }
.chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: #f3f5f4; font-size: .875rem; }
.chip.converted { color: #674b27; background: #fff8e8; border-color: #dac8a9; }
.question-text { margin: 0 0 24px; font-size: 1.25rem; font-weight: 600; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 16px; border: 1px solid #bfc8cf; border-radius: 4px; background: #fff; font-size: 1rem; line-height: 1.8; text-align: left; }
.option:hover:not(:disabled) { border-color: #789880; background: #f4f8f5; }
.option:disabled { opacity: 1; }
.option.selected { border-color: var(--green); background: var(--green-light); box-shadow: inset 0 0 0 1px var(--green); }
.option.correct { border-color: #487652; background: #edf5ef; }
.option.wrong { border-color: #ab6b65; background: #fcf1ee; }
.option-label { display: grid; place-items: center; flex: 0 0 28px; width: 28px; min-height: 28px; border: 1px solid #c8d1d7; border-radius: 3px; background: #f4f6f5; color: var(--muted); font-size: .9375rem; }
.option.selected .option-label, .option.correct .option-label { background: var(--green); border-color: var(--green); color: #fff; }
.option.wrong .option-label { background: var(--red); border-color: var(--red); color: #fff; }
.option-text { flex: 1; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.option-status { width: 20px; height: 20px; margin-top: 4px; flex: none; color: var(--green); }
.option.wrong .option-status { color: var(--red); }
.question-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 20px; margin-top: 24px; border-top: 1px solid var(--line); }
.actions-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.question-footer-note { margin-top: 16px; color: var(--muted); font-size: .875rem; }
.bookmark-btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.bookmark-btn:hover { background: #edf3ee; }
.bookmark-btn.on { color: var(--green); }
.bookmark-btn.on svg { fill: #d2e5d5; }
.bookmark-btn svg { width: 21px; height: 21px; }
.feedback { margin-top: 24px; padding: 20px; border: 1px solid #bdd0c0; border-radius: 4px; background: #f0f6f1; }
.feedback.incorrect { border-color: #dcc6ae; background: #fff7ee; }
.feedback-heading { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 1rem; font-weight: 700; }
.feedback.incorrect .feedback-heading { color: #7b4f24; }
.feedback-heading svg { width: 20px; height: 20px; flex: none; }
.feedback-answer { margin: 14px 0; font-size: 1rem; white-space: pre-line; overflow-wrap: anywhere; }
.feedback-answer strong { display: block; margin-bottom: 5px; color: var(--muted); font-size: .875rem; }
.feedback-learn, .concept-text { color: var(--ink); font-size: 1rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.pitfall { margin-top: 16px; padding: 13px 15px; border: 1px solid #dac8a9; border-radius: 4px; background: #fff8e8; color: #674b27; font-size: 1rem; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.pitfall strong { display: block; margin-bottom: 5px; font-size: .9375rem; }
.source-details { margin-top: 18px; color: var(--muted); font-size: 1rem; line-height: 1.85; }
.keyboard-note { margin-top: 18px; color: var(--muted); font-size: .875rem; text-align: center; }
.kbd { padding: 1px 5px; border: 1px solid #c5cfd5; border-radius: 3px; background: #fff; font-size: .875rem; }
.session-score { color: var(--muted); font-size: .9375rem; }
.session-score strong { color: var(--green); }
.session-end { margin-top: 22px; padding: 22px 0; border-top: 1px solid var(--line); text-align: center; }
.session-end h3 { margin: 0 0 8px; }
.session-end p { color: var(--muted); }
.recall-mode-btn { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 0; border: 0; background: transparent; color: var(--green); font-size: 1rem; text-decoration: underline; text-underline-offset: 3px; }
.recall-mode-btn svg { width: 18px; height: 18px; }
.recall-tip { margin-bottom: 16px; padding: 11px 13px; background: #f0f5f1; color: var(--muted); font-size: .9375rem; }
.recall-blank { padding: 22px; border: 1px dashed #a8bcae; border-radius: 4px; background: #f5f8f5; text-align: center; }
.recall-blank p { margin: 0 0 14px; }
.recall-answer { text-align: left; font-size: 1.0625rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.recall-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.recall-grade-note { margin-top: 12px; color: var(--muted); font-size: .875rem; }
.concept-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
.concept-footer button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 5px 0; border: 0; background: transparent; color: var(--green); font-size: .9375rem; font-weight: 600; }
.concept-footer button svg { width: 17px; height: 17px; }

/* Exam controls, score summary, and mistakes. */
.exam-setup { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.setup-card, .exam-info { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.setup-card h3, .exam-info h3 { margin: 0 0 10px; }
.setup-card > p, .exam-info > p { margin: 0 0 22px; color: var(--muted); }
.field-label { display: block; margin: 20px 0 10px; font-size: 1rem; font-weight: 600; }
.full-select { width: 100%; }
.setup-start { width: 100%; margin-top: 24px; }
.setup-pool { margin: 14px 0 0; color: var(--muted); font-size: .875rem; text-align: center; }
.info-step { display: flex; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 1rem; }
.info-step > span { flex: none; color: var(--muted); font-size: .875rem; }
.info-step strong { display: block; margin-bottom: 4px; color: var(--ink); }
.exam-info .practice-summary { margin: 24px 0 0; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; align-items: start; }
.exam-sidebar { padding: 18px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.exam-sidebar h3 { margin: 0 0 14px; font-size: 1rem; }
.exam-time { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.exam-time > span { display: flex; align-items: center; gap: 5px; }
.exam-time svg { width: 17px; height: 17px; flex: none; }
.timer { color: var(--green); font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--red); }
.palette { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.palette button { position: relative; min-width: 0; min-height: 38px; padding: 6px 0; border: 1px solid #bfc9cf; border-radius: 3px; background: #fff; color: var(--muted); font-size: .875rem; }
.palette button.answered { background: #e5efe7; border-color: #9eb9a4; color: var(--green); }
.palette button.current { background: var(--green); border-color: var(--green); color: #fff; }
.palette button.flagged::after { content: ''; position: absolute; right: 3px; top: 3px; width: 5px; height: 5px; border-radius: 50%; background: #c38c29; }
.palette-key { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; color: var(--muted); font-size: .875rem; }
.palette-key span { display: flex; align-items: center; gap: 5px; }
.palette-key i { width: 8px; height: 8px; background: #91ac99; border-radius: 2px; }
.palette-key span:last-child i { background: #c38c29; border-radius: 50%; }
.exam-submit { width: 100%; margin-top: 20px; }
.exam-answered { margin: 10px 0 0; color: var(--muted); font-size: .875rem; text-align: center; }
.flag-btn { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 10px; border: 1px solid #bfc9cf; border-radius: 4px; background: #fff; color: var(--muted); font-size: .875rem; }
.flag-btn svg { width: 17px; height: 17px; flex: none; }
.flag-btn.on { border-color: #c1a66b; background: #fff6df; color: #735b23; }
.flag-btn.on svg { fill: #e6ca83; }
.exam-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 18px; color: var(--muted); font-size: .875rem; }
.progress-track { height: 5px; overflow: hidden; background: #e1e7e3; }
.progress-fill { height: 100%; background: #668b71; }
.exam-progress .progress-track { flex: 1; min-width: 60px; }
.result-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.result-copy h2 { margin: 4px 0 10px; }
.result-copy p { margin: 0; color: var(--muted); font-size: 1rem; }
.score-ring { flex: none; text-align: center; padding: 10px 14px; }
.score-content strong { display: block; color: var(--green); font-size: 2rem; font-weight: 700; line-height: 1.5; }
.score-content span { display: block; color: var(--muted); font-size: .875rem; }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.stat-card span { color: var(--muted); font-size: .9375rem; }
.stat-card strong { color: var(--green); font-size: 1.375rem; }
.stat-card.wrong strong { color: #805332; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.review-item { padding: 22px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.review-item-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.review-item .question-text { margin-bottom: 16px; font-size: 1.125rem; }
.review-status { padding: 3px 8px; border-radius: 3px; color: #805332; background: #fff3e6; font-size: .875rem; }
.review-item.correct .review-status { color: var(--green); background: var(--green-light); }
.review-answer { display: flex; flex-direction: column; gap: 10px; font-size: 1rem; }
.review-answer strong { display: block; margin-bottom: 4px; font-size: .875rem; }
.your-answer { color: #805332; white-space: pre-line; overflow-wrap: anywhere; }
.right-answer { color: var(--green); white-space: pre-line; overflow-wrap: anywhere; }
.review-explanation { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); font-size: 1rem; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.review-item details { margin-top: 14px; font-size: 1rem; color: var(--muted); }
.mistake-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; }
.mistake-toolbar p { margin: 0; color: var(--muted); font-size: 1rem; }
.mistake-toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 1100px) {
  .content { padding-inline: 24px; }
  .lesson-detail-layout { grid-template-columns: 1fr; }
  .lesson-outline { position: static; border-left: 0; border-bottom: 1px solid var(--line); padding: 0 0 18px; }
  .lesson-outline ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
  .exam-layout { grid-template-columns: 1fr; }
  .exam-sidebar { order: -1; }
  .palette { grid-template-columns: repeat(auto-fit, minmax(36px, 1fr)); max-height: 180px; overflow-y: auto; }
  .exam-submit { width: auto; }
  .exam-answered { text-align: left; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .content { padding: 20px 20px 104px; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: #fff;
    z-index: 50;
  }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 52px; padding: 5px 2px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: .875rem; line-height: 1.5; }
  .mobile-nav button span { overflow-wrap: anywhere; }
  .mobile-nav svg { width: 19px; height: 19px; }
  .mobile-nav button.active { color: var(--green); background: var(--green-light); font-weight: 700; }
  .toast { bottom: 90px; left: 50%; }
  .exam-setup { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content { padding: 18px 16px 104px; }
  .subject-grid { gap: 6px; }
  .subject-card { padding: 9px 8px; }
  .workspace-tabs { gap: 0; justify-content: space-between; }
  .workspace-tab { flex: 1; gap: 5px; padding: 10px 4px; font-size: .9375rem; }
  .workspace-tab svg { display: none; }
  .toolbar { align-items: flex-start; }
  .toolbar-left { width: 100%; }
  .search-wrap, .lesson-toolbar .search-wrap { flex-basis: 100%; min-width: 0; }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-overview-head { flex-wrap: wrap; gap: 12px; }
  .lesson-overview-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; text-align: left; font-size: 1rem; }
  .lesson-overview-progress small { margin: 0; }
  .lesson-card-body { padding: 18px; }
  .lesson-card-footer { padding-inline: 18px; }
  .lesson-detail-header h2 { font-size: 1.375rem; }
  .lesson-outline ol { grid-template-columns: 1fr; }
  .lesson-comparison, .lesson-diagram, .lesson-remember { padding: 16px; }
  .lesson-comparison th, .lesson-comparison td { padding: 11px 12px; }
  .flow-diagram { flex-direction: column; gap: 25px; }
  .flow-diagram li { display: grid; grid-template-columns: 25px minmax(0, 1fr); gap: 0 8px; flex-basis: auto; }
  .flow-step-number { grid-row: 1 / 3; margin: 0; line-height: 2.1; }
  .flow-diagram li strong, .flow-diagram li p { grid-column: 2; }
  .flow-diagram li .flow-arrow { top: auto; right: auto; bottom: -23px; left: 50%; transform: rotate(90deg); }
  .branch-column { flex-basis: 100%; }
  .lesson-study-actions { flex-direction: column; }
  .lesson-study-actions > button { width: 100%; }
  .lesson-question-list li { flex-wrap: wrap; }
  .lesson-question-list li > div { flex-basis: calc(100% - 56px); }
  .lesson-question-list .secondary-btn { margin-left: auto; }
  .lesson-next-prev { grid-template-columns: 1fr; }
  .lesson-practice-context { flex-wrap: wrap; }
  .question-card, .review-item, .setup-card, .exam-info { padding: 18px; }
  .question-top { flex-wrap: wrap; gap: 8px; }
  .question-meta { flex: 1; }
  .question-text { font-size: 1.1875rem; }
  .option { gap: 10px; padding: 13px 12px; }
  .question-actions { gap: 10px; }
  .question-actions > button, .question-actions .actions-right { flex: 0 1 auto; }
  .question-actions .primary-btn, .question-actions .secondary-btn { padding: 9px 12px; }
  .feedback { padding: 16px; }
  .keyboard-note { display: none; }
  .result-hero { flex-wrap: wrap; }
  .score-ring { padding: 0; text-align: left; }
  .result-stats { gap: 8px; }
  .stat-card { flex-direction: column; align-items: flex-start; padding: 12px 10px; }
  .stat-card span { font-size: .875rem; }
  .palette { grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); }
  .palette button { min-height: 44px; }
  .exam-sidebar { padding: 16px; }
  .modal { padding: 20px; }
  .recall-blank { padding: 16px; }
  .memory-anchor { padding: 12px; }
}

@media (max-width: 360px) {
  .subject-grid { display: flex; flex-wrap: wrap; }
  .subject-card { flex: 1 1 94px; }
  .mobile-nav button { font-size: .8125rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
