:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647084;
  --line: #d9e1ec;
  --soft: #edf4fb;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --red: #b42318;
  --green: #18794e;
  --shadow: 0 18px 45px rgba(25, 38, 63, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

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

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

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.search-label,
.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-input {
  width: 100%;
  margin-top: 8px;
  margin-bottom: 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

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

.chapter-button {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.chapter-button:hover {
  background: var(--soft);
}

.chapter-button.active {
  border-color: rgba(15, 118, 110, 0.32);
  background: #e7f5f2;
}

.chapter-button strong {
  display: block;
  font-size: 0.94rem;
  line-height: 1.25;
}

.chapter-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 36px) 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#chapterTitle {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  line-height: 1.08;
}

.topbar-actions {
  flex: none;
}

.ghost-button,
.primary-button,
.choice-button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.ghost-button:hover,
.choice-button:hover,
.small-button:hover {
  transform: translateY(-1px);
  border-color: #b9c7d8;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  padding: 9px 13px;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.small-button {
  padding: 7px 10px;
  font-size: 0.9rem;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.mode-tab {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.mode-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.content-panel,
.search-results {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(18px, 2.5vw, 28px);
}

.search-results {
  min-height: auto;
  margin-bottom: 16px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.summary-grid,
.guide-grid,
.care-grid,
.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.stat strong {
  display: block;
  font-size: 1.35rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.83rem;
}

.note-card,
.term-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 15px;
}

.note-card h3,
.term-card h3,
.result-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.note-card p,
.term-card p,
.result-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.term-card-button {
  display: block;
  width: 100%;
  color: inherit;
  text-align: left;
}

.term-card-button > span {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.term-coach-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(14px);
}

.term-coach-card {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
  padding: clamp(20px, 3vw, 30px);
}

.term-coach-close {
  float: right;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 7px 12px;
  font-weight: 800;
}

.term-coach-card h3 {
  margin: 0 0 16px;
  font-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1.02;
}

.pronunciation-box {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-radius: 16px;
  background: #eef7ff;
  padding: 16px;
}

.pronunciation-box span,
.term-coach-section span,
.related-terms > span {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pronunciation-box strong {
  display: block;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.25;
}

.term-coach-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.term-coach-section {
  margin-top: 12px;
  border-radius: 16px;
  background: #f8fafc;
  padding: 15px;
}

.term-coach-section p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}

.related-terms {
  margin-top: 14px;
}

.related-terms div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related-terms button {
  border: 0;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  padding: 8px 11px;
  font-weight: 800;
}

.bullet-list {
  margin: 0;
  padding-left: 20px;
}

.bullet-list li {
  margin: 7px 0;
  line-height: 1.48;
}

.callout {
  margin: 18px 0 0;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #edf8f6;
  padding: 13px 15px;
  line-height: 1.5;
}

.flashcard-wrap {
  display: grid;
  gap: 16px;
}

.flashcard {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: clamp(20px, 4vw, 38px);
  text-align: center;
}

.flashcard .label {
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flashcard .card-text {
  max-width: 820px;
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  line-height: 1.25;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
}

.quiz-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.quiz-question {
  margin: 0 0 16px;
  font-size: 1.24rem;
  line-height: 1.35;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice-button {
  width: 100%;
  padding: 12px 13px;
  text-align: left;
  line-height: 1.4;
}

.choice-button.correct {
  border-color: rgba(24, 121, 78, 0.55);
  background: #eaf7ef;
}

.choice-button.selected {
  border-color: rgba(37, 99, 235, 0.42);
  background: #eef4ff;
}

.choice-button.incorrect {
  border-color: rgba(180, 35, 24, 0.45);
  background: #fff0ef;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.question-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbff;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: -2px 0 16px;
}

.hint-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint-button {
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: 999px;
  background: #eef4ff;
  color: var(--blue);
  padding: 8px 12px;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.hint-button:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.44);
  background: #e4efff;
}

.hint-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 12px;
  background: #f6f9ff;
  padding: 14px;
}

.hint-block span {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hint-block .bullet-list {
  margin: 0;
}

.rationale {
  margin-top: 14px;
  border-radius: 8px;
  background: var(--soft);
  padding: 13px;
  color: var(--ink);
  line-height: 1.5;
}

.rationale h4 {
  margin: 14px 0 8px;
  font-size: 0.95rem;
}

.answer-line {
  margin-top: 8px;
}

.option-review {
  margin: 0;
  padding-left: 22px;
}

.option-review li {
  margin: 8px 0;
}

.progress-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 15px;
}

.progress-box strong {
  display: block;
  font-size: 2rem;
}

.progress-box span {
  color: var(--muted);
}

.progress-bar {
  height: 9px;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.progress-bar div {
  height: 100%;
  background: var(--accent);
}

.concept-map-wrap {
  display: grid;
  gap: 16px;
}

.map-focus {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.concept-map-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.concept-map {
  width: 100%;
  min-width: 860px;
  min-height: 520px;
  display: block;
}

.map-node rect {
  fill: #fff;
  stroke: #b8c7d8;
  stroke-width: 1.2;
  rx: 8;
}

.map-node.primary rect {
  fill: #e7f5f2;
  stroke: var(--accent);
}

.map-node.assessment rect {
  fill: #eff6ff;
  stroke: #7aa7e8;
}

.map-node.risk rect,
.map-node.alert rect {
  fill: #fff1f0;
  stroke: #e09a93;
}

.map-node.action rect {
  fill: #ecfdf3;
  stroke: #73bd91;
}

.map-node.teach rect {
  fill: #fff7ed;
  stroke: #e7aa63;
}

.map-node text {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.map-link {
  stroke: #91a6bd;
  stroke-width: 1.4;
}

.map-link-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fbfdff;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.map-takeaways {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-takeaways span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.reader-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 16px;
}

.reader-main {
  min-width: 0;
}

.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.reader-toolbar select,
.reader-toolbar input[type="range"] {
  min-height: 38px;
}

.page-frame {
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf4;
  padding: 12px;
}

.page-frame img {
  display: block;
  max-width: none;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 8px 26px rgba(25, 38, 63, 0.2);
}

.thumbnail-list {
  display: grid;
  gap: 8px;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}

.thumbnail-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  text-align: left;
}

.thumbnail-button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
}

.thumbnail-button img {
  display: block;
  width: 100%;
  border-radius: 4px;
}

.thumbnail-button span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

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

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

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

  .quiz-layout,
  .reader-grid {
    grid-template-columns: 1fr;
  }

  .thumbnail-list {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    max-height: none;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 18px 12px 28px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .topbar-actions button {
    width: 100%;
  }

  .mode-tab {
    flex: 1 1 130px;
  }
}

/* Apple-inspired polish layer */
:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --soft: #f2f7ff;
  --accent: #0071e3;
  --accent-strong: #005bb8;
  --blue: #0071e3;
  --red: #b42318;
  --green: #18794e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 10px 35px rgba(0, 0, 0, 0.06);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.94);
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 44%, #eef2f7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.24);
  outline-offset: 2px;
}

.app-shell {
  grid-template-columns: 336px minmax(0, 1fr);
}

.sidebar {
  border-right-color: rgba(0, 0, 0, 0.08);
  background: rgba(251, 251, 253, 0.78);
  backdrop-filter: blur(24px) saturate(180%);
  padding: 28px 18px;
}

.brand {
  gap: 14px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(145deg, #1d1d1f, #3a3a3c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 24px rgba(0, 0, 0, 0.16);
  font-size: 0.95rem;
}

.brand h1 {
  font-size: 1.12rem;
  font-weight: 760;
  letter-spacing: -0.01em;
}

.brand p {
  color: #73737a;
}

.search-label,
.field-label {
  color: #86868b;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.search-input {
  margin-top: 9px;
  margin-bottom: 20px;
  padding: 13px 14px;
  border-color: transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: box-shadow 180ms ease, background 180ms ease, transform 180ms ease;
}

.search-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.45), 0 10px 30px rgba(0, 113, 227, 0.08);
}

.chapter-nav {
  gap: 7px;
}

.chapter-button {
  padding: 13px 14px;
  border: 0;
  border-radius: 16px;
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease, color 180ms ease;
}

.chapter-button:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: translateX(2px);
}

.chapter-button.active {
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.chapter-button strong {
  font-size: 0.95rem;
  font-weight: 720;
  letter-spacing: -0.01em;
}

.chapter-button span {
  color: #767680;
}

.workspace {
  padding: 34px clamp(22px, 4vw, 56px) 54px;
}

.topbar {
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  color: #6e6e73;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

#chapterTitle {
  max-width: 980px;
  font-size: clamp(2rem, 4vw, 3.85rem);
  font-weight: 780;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.ghost-button,
.primary-button,
.choice-button,
.small-button,
.mode-tab,
.thumbnail-button {
  border-color: transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.ghost-button:hover,
.choice-button:hover,
.small-button:hover,
.mode-tab:hover,
.thumbnail-button:hover {
  transform: translateY(-1px);
  border-color: transparent;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 10px 24px rgba(0, 0, 0, 0.08);
}

.primary-button {
  border-color: transparent;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.2);
  color: #fff;
}

.primary-button:hover {
  background: #0077ed;
  transform: translateY(-1px);
}

.mode-tabs {
  display: inline-flex;
  max-width: 100%;
  gap: 4px;
  width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 18px 0;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.mode-tabs::-webkit-scrollbar {
  display: none;
}

.mode-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 15px;
  box-shadow: none;
  background: transparent;
  color: #6e6e73;
  font-weight: 700;
}

.mode-tab.active {
  border-color: transparent;
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

.content-panel,
.search-results {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 24px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: clamp(22px, 3vw, 34px);
}

.section-title {
  font-size: 1.28rem;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.summary-grid,
.guide-grid,
.care-grid,
.search-grid {
  gap: 16px;
}

.stat-row {
  gap: 14px;
  margin: 22px 0;
}

.stat,
.note-card,
.term-card,
.result-card,
.quiz-card,
.progress-box {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.stat {
  padding: 16px;
}

.stat strong {
  font-size: 1.68rem;
  font-weight: 780;
  letter-spacing: -0.035em;
}

.stat span,
.progress-box span {
  color: #73737a;
}

.note-card,
.term-card,
.result-card {
  padding: 18px;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.term-card-button {
  appearance: none;
  cursor: pointer;
}

.note-card:hover,
.term-card:hover,
.result-card:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

.note-card h3,
.term-card h3,
.result-card h3 {
  font-weight: 740;
  letter-spacing: -0.015em;
}

.note-card p,
.term-card p,
.result-card p,
.bullet-list li,
.callout,
.rationale,
.map-focus,
.term-coach-section p {
  color: #515154;
}

.term-card-button > span {
  color: var(--accent);
}

.term-coach-card {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.18);
}

.term-coach-close {
  border: 0;
  background: rgba(0, 0, 0, 0.055);
}

.pronunciation-box,
.term-coach-section {
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.08);
}

.related-terms button {
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
}

.callout {
  border-left: 0;
  border-radius: 18px;
  background: #eef7ff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.12);
}

.flashcard {
  min-height: 330px;
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 28px;
  background: linear-gradient(180deg, #fff 0%, #f7f9fc 100%);
  box-shadow: var(--shadow);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.flashcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.1);
}

.flashcard .label {
  color: var(--accent);
}

.flashcard .card-text {
  font-size: clamp(1.45rem, 2.8vw, 2.45rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}

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

.quiz-card {
  padding: clamp(20px, 2.4vw, 28px);
}

.quiz-question {
  font-size: clamp(1.28rem, 2vw, 1.65rem);
  font-weight: 660;
  letter-spacing: -0.025em;
}

.choices {
  gap: 12px;
}

.choice-button {
  border-radius: 16px;
  padding: 15px 16px;
  background: rgba(255, 255, 255, 0.8);
}

.choice-button.correct {
  background: #eaf8ef;
  box-shadow: inset 0 0 0 1px rgba(24, 121, 78, 0.26);
}

.choice-button.selected {
  background: #eef6ff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.28);
}

.choice-button.incorrect {
  background: #fff1f0;
  box-shadow: inset 0 0 0 1px rgba(180, 35, 24, 0.22);
}

.question-meta span,
.map-takeaways span {
  border: 0;
  background: rgba(0, 0, 0, 0.045);
  color: #6e6e73;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.hint-button {
  border: 0;
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.14);
}

.hint-button:hover {
  background: rgba(0, 113, 227, 0.14);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.22);
}

.hint-panel {
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fbff 0%, #f4f8ff 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.1);
  padding: 16px;
}

.hint-block span {
  color: var(--accent);
}

.rationale {
  border-radius: 18px;
  background: #f5f8ff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.1);
  padding: 18px;
}

.progress-box {
  align-self: start;
  position: sticky;
  top: 24px;
  padding: 18px;
}

.progress-box strong {
  font-size: 2.35rem;
  font-weight: 780;
  letter-spacing: -0.045em;
}

.progress-bar {
  height: 7px;
  background: rgba(0, 0, 0, 0.08);
}

.progress-bar div {
  background: var(--accent);
}

.concept-map-scroll,
.page-frame {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 22px;
  background: #fafafa;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65), var(--shadow-soft);
}

.concept-map {
  min-height: 560px;
}

.map-node rect {
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.06));
}

.map-node.primary rect {
  fill: #eef7ff;
  stroke: #88bff2;
}

.map-node text {
  font-size: 12.5px;
  font-weight: 760;
}

.reader-toolbar select,
.reader-toolbar input[type="range"] {
  accent-color: var(--accent);
}

.page-frame {
  background: #f2f2f5;
}

.page-frame img {
  border-radius: 10px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.18);
}

.thumbnail-list {
  gap: 10px;
}

.thumbnail-button {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  padding: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.thumbnail-button.active {
  box-shadow: inset 0 0 0 2px rgba(0, 113, 227, 0.8), 0 12px 26px rgba(0, 113, 227, 0.12);
}

.thumbnail-button img {
  border-radius: 10px;
}

.visual-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 20px;
  align-items: start;
}

.visual-hero,
.visual-study-panel {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.visual-hero {
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.visual-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #f5f5f7;
}

.visual-caption {
  padding: 18px 20px 20px;
}

.visual-caption span,
.visual-hook span,
.visual-prompt span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 780;
  text-transform: uppercase;
}

.visual-caption h3 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.05;
  font-weight: 780;
}

.visual-caption p {
  max-width: 780px;
  margin: 10px 0 0;
  color: #515154;
  font-size: 1.02rem;
  line-height: 1.55;
}

.visual-study-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  position: sticky;
  top: 24px;
}

.visual-hook,
.visual-cue,
.visual-prompt {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07);
}

.visual-hook {
  padding: 18px;
}

.visual-hook strong {
  display: block;
  font-size: 1.18rem;
  line-height: 1.38;
}

.visual-cue-grid {
  display: grid;
  gap: 10px;
}

.visual-cue {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.visual-cue span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef7ff;
  color: var(--accent);
  font-weight: 780;
}

.visual-cue p,
.visual-prompt p {
  margin: 0;
  color: #515154;
  line-height: 1.5;
}

.visual-prompt {
  padding: 18px;
  background: #eef7ff;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.12);
}

.drug-guide-layout {
  display: grid;
  gap: 18px;
}

.drug-guide-hero {
  border-radius: 26px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 247, 255, 0.9));
  box-shadow: var(--shadow-soft);
  padding: clamp(20px, 3vw, 30px);
}

.drug-guide-hero h3 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.drug-guide-hero > p {
  max-width: 880px;
  margin: 12px 0 0;
  color: #515154;
  font-size: 1.06rem;
  line-height: 1.55;
}

.drug-guide-stats,
.drug-framework-grid,
.interaction-grid,
.drug-card-grid {
  display: grid;
  gap: 12px;
}

.drug-guide-stats {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-top: 18px;
}

.drug-guide-stats span,
.drug-framework-card,
.interaction-card,
.drug-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07);
}

.drug-guide-stats span {
  padding: 14px;
  color: #515154;
}

.drug-guide-stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
}

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

.drug-framework-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
}

.drug-framework-card span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
  font-weight: 800;
}

.drug-framework-card p,
.interaction-card p,
.drug-detail-block p {
  margin: 0;
  color: #515154;
  line-height: 1.5;
}

.interaction-grid {
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
}

.interaction-card {
  border-left: 4px solid rgba(180, 35, 24, 0.72);
  padding: 16px;
}

.interaction-card h4 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.interaction-card p + p {
  margin-top: 8px;
}

.drug-card-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.drug-card {
  overflow: hidden;
}

.drug-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(165px, 0.45fr);
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  padding: 18px;
}

.drug-card-head span,
.drug-detail-block span {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drug-card-head h4 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1.05;
}

.drug-name-pair {
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.04);
  padding: 12px;
}

.drug-name-pair strong {
  display: block;
  color: #6e6e73;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drug-name-pair p {
  margin: 3px 0 9px;
  color: var(--ink);
  line-height: 1.35;
}

.drug-name-pair p:last-child {
  margin-bottom: 0;
}

.drug-card-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.drug-detail-block {
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.92);
  padding: 13px;
}

.drug-detail-block .bullet-list {
  margin: 0;
}

.empty-state {
  border-color: rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

  .sidebar {
    border-bottom-color: rgba(0, 0, 0, 0.08);
  }

  .workspace {
    padding: 26px clamp(16px, 4vw, 32px) 40px;
  }

  .mode-tabs {
    display: flex;
  }

  .progress-box {
    position: static;
  }

  .visual-layout {
    grid-template-columns: 1fr;
  }

  .visual-study-panel {
    position: static;
  }

  .drug-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #chapterTitle {
    font-size: clamp(1.85rem, 10vw, 2.7rem);
  }

  .content-panel,
  .search-results {
    border-radius: 20px;
    padding: 18px;
  }

  .mode-tab {
    flex: 0 0 auto;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
  }

  .visual-hero,
  .visual-study-panel {
    border-radius: 18px;
  }

  .visual-caption {
    padding: 16px;
  }

  .visual-hero img {
    aspect-ratio: 4 / 3;
  }

  .term-coach-backdrop {
    padding: 12px;
  }

  .term-coach-card {
    max-height: calc(100vh - 24px);
    border-radius: 20px;
  }

  .term-coach-grid {
    grid-template-columns: 1fr;
  }

  .drug-card-head {
    grid-template-columns: 1fr;
  }

  .drug-guide-stats,
  .drug-framework-grid,
  .interaction-grid {
    grid-template-columns: 1fr;
  }
}

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