:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-strong: #eef5f7;
  --ink: #17212b;
  --muted: #647184;
  --line: #d8e2ea;
  --teal: #0f7779;
  --green: #5d8542;
  --amber: #be7a16;
  --coral: #c95a45;
  --blue: #355f9c;
  --violet: #6859a7;
  --shadow: 0 18px 48px rgba(30, 47, 66, 0.12);
  --radius: 8px;
  --sidebar: 292px;
  --focus-ring: 0 0 0 3px rgba(15, 119, 121, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 119, 121, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(53, 95, 156, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar);
  padding: 24px;
  color: #f8fbfb;
  background: #13242d;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: auto;
  transition: opacity 180ms ease, padding 180ms ease, width 180ms ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding-right: 0;
  padding-left: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  border-right: 0;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #e7f4f1;
  color: var(--teal);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.brand-lockup h1,
.topbar h2,
.section-heading h3,
.panel h3,
.prompt-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  font-size: 1.2rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  opacity: 0.72;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.exam-timers {
  display: grid;
  gap: 10px;
}

.exam-timer {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.exam-timer strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.exam-time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.exam-time-grid span {
  min-width: 0;
  padding: 6px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  text-align: center;
}

.exam-time-grid b {
  display: block;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.exam-time-grid small,
.exam-timer p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.7rem;
}

.exam-timer p {
  margin: 8px 0 0;
  line-height: 1.35;
}

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

.nav-button {
  min-height: 46px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 0 12px;
}

.nav-button:hover,
.nav-button.active {
  background: #f8fbfb;
  color: #13242d;
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.main-area {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 26px;
}

.topbar h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.35rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  min-width: min(360px, 42vw);
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(30, 47, 66, 0.06);
}

.search-box:focus-within,
input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.search-box input,
.quick-add input,
.resource-filter input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.timer-widget {
  height: 46px;
  padding: 0 8px 0 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-widget span {
  min-width: 54px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-strong);
  display: grid;
  place-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-grid,
.dashboard-insights,
.exam-overview {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  margin-bottom: 18px;
}

.dashboard-insights {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  margin-bottom: 18px;
}

.exam-overview {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  margin-bottom: 18px;
}

.exam-overview .exam-timer {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 8px 28px rgba(30, 47, 66, 0.08);
}

.exam-overview .exam-time-grid span {
  background: var(--surface-strong);
}

.exam-overview .exam-time-grid small,
.exam-overview .exam-timer p {
  color: var(--muted);
}

.course-card,
.panel,
.prompt-card,
.question-controls,
.paper-editor,
.resource-panel,
.course-hero,
.lesson-card,
.lesson-page,
.lesson-toc,
.planner-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(30, 47, 66, 0.08);
}

.course-card {
  min-height: 190px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 16px;
  border-top: 6px solid var(--course-color);
}

.course-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.course-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.85rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e7edf2;
  overflow: hidden;
}

.progress-fill {
  width: var(--progress);
  height: 100%;
  background: var(--course-color);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 8px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.58fr);
  gap: 18px;
}

.progress-chart {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: 82px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.chart-row strong,
.chart-row span:last-child {
  font-size: 0.82rem;
}

.chart-bar {
  height: 18px;
  border-radius: 999px;
  background: #e7edf2;
  overflow: hidden;
}

.chart-fill {
  width: var(--progress);
  height: 100%;
  background: var(--course-color);
}

.exam-map {
  display: grid;
  gap: 10px;
}

.exam-day-card {
  padding: 12px;
  border: 1px solid #e3ebf1;
  border-radius: var(--radius);
  background: #f7fafc;
}

.exam-day-card h4 {
  margin: 0 0 8px;
}

.exam-slot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.exam-slot {
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--course-color);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.panel {
  padding: 18px;
}

.panel-head,
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status-pill {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eaf2f0;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.accent-panel {
  border-top: 6px solid var(--coral);
}

.action-list,
.weak-queue,
.resource-list,
.paper-list,
.planner-grid,
.topic-board {
  display: grid;
  gap: 10px;
}

.action-row,
.weak-row,
.resource-row,
.paper-row,
.topic-row,
.planner-task {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: var(--radius);
  background: #f7fafc;
  border: 1px solid #e3ebf1;
}

.action-row input,
.topic-row input,
.planner-task input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.action-row h4,
.topic-row h4,
.planner-task h4 {
  margin: 0 0 3px;
  font-size: 0.94rem;
}

.action-row p,
.topic-row p,
.planner-task p,
.resource-row p,
.paper-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.86rem;
}

.quick-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.quick-add input,
.question-controls select,
.question-controls input,
.question-controls textarea,
.abstract-grid textarea,
#courseNotes {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.quick-add input {
  height: 42px;
  padding: 0 12px;
}

.primary-button,
.secondary-button,
.filter-button,
.confidence-button {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

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

.secondary-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.segmented button,
.filter-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  padding: 0 12px;
}

.segmented button.active,
.filter-button.active,
.confidence-button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.course-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 18px;
  align-items: start;
}

.course-main {
  display: grid;
  gap: 18px;
}

.course-browser {
  display: block;
}

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

.lesson-card {
  min-height: 156px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 12px;
  align-content: space-between;
  border-top: 5px solid var(--course-color, var(--teal));
}

button.lesson-card {
  cursor: pointer;
}

button.lesson-card:hover {
  border-color: var(--course-color, var(--teal));
  background: #f8fbfb;
  transform: translateY(-1px);
}

.lesson-card-empty {
  border-top-color: var(--violet);
}

.lesson-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.lesson-card small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.lesson-card strong,
.lesson-card h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.lesson-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  font-size: 0.9rem;
}

.lesson-page {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.lesson-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.lesson-header h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2.2vw, 2rem);
}

.lesson-body {
  display: grid;
  grid-template-columns: minmax(210px, 270px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.lesson-toc {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 14px;
  box-shadow: none;
}

.lesson-toc h4 {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.lesson-toc a {
  display: block;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.83rem;
  line-height: 1.35;
}

.lesson-toc a:hover {
  background: #eef5f7;
  color: var(--ink);
}

.course-hero {
  min-height: 160px;
  padding: 18px;
  border-top: 8px solid var(--course-color);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,255,255,0.9)),
    repeating-linear-gradient(90deg, rgba(23,33,43,0.06) 0 1px, transparent 1px 18px);
  display: grid;
  grid-template-columns: 1fr minmax(160px, 240px);
  gap: 22px;
  align-items: center;
}

.course-hero h3 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
}

.course-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
  font-size: 0.94rem;
}

.course-visual {
  height: 150px;
  border-radius: var(--radius);
  background: #f2f6f8;
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 10px;
  padding: 18px;
}

.course-visual span {
  display: block;
  min-height: 40px;
  border-radius: 6px 6px 0 0;
  background: var(--course-color);
  opacity: var(--opacity);
}

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

.subsection-layout {
  display: grid;
  grid-template-columns: minmax(220px, 310px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.subsection-list,
.note-reader {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 28px rgba(30, 47, 66, 0.08);
}

.subsection-list {
  max-height: 640px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.subsection-button {
  width: 100%;
  padding: 10px;
  border: 1px solid #e3ebf1;
  border-radius: var(--radius);
  background: #fbfdfe;
  color: var(--ink);
  text-align: left;
}

.subsection-button.active {
  border-color: var(--course-color);
  background: #f3f8f8;
  box-shadow: inset 4px 0 0 var(--course-color);
}

.subsection-button small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.subsection-button strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.32;
}

.note-reader {
  min-height: 640px;
  max-height: 820px;
  overflow: auto;
  padding: 0;
}

.lesson-page .note-reader {
  min-height: calc(100vh - 190px);
  max-height: none;
  overflow: visible;
  border-top: 6px solid var(--course-color, var(--teal));
}

.reader-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.reader-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reader-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 900;
}

.reader-body {
  padding: 16px;
}

.lesson-page .reader-body {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 54px) 42px;
}

.reader-body h1,
.reader-body h2,
.reader-body h3 {
  margin: 18px 0 10px;
  letter-spacing: 0;
}

.reader-body h1 {
  font-size: 1.35rem;
}

.reader-body h2 {
  padding-top: 8px;
  border-top: 1px solid #e5edf2;
  font-size: 1.05rem;
}

.lesson-page .reader-body h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.2rem);
}

.lesson-page .reader-body h2 {
  margin-top: 28px;
  padding-top: 18px;
  font-size: clamp(1.15rem, 1.9vw, 1.45rem);
}

.reader-body h3 {
  font-size: 1rem;
}

.reader-body ul {
  margin: 8px 0 16px;
  padding-left: 22px;
}

.reader-body p,
.reader-body li {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.reader-body blockquote {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--teal);
  background: #f2f8f8;
  color: var(--muted);
}

.reader-source-heading {
  color: var(--muted);
}

.source-details {
  margin: 8px 0 22px;
  padding: 0;
  border: 1px solid #dce6ed;
  border-radius: var(--radius);
  background: #fbfdfe;
}

.source-details summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.source-details pre {
  margin: 0;
  border: 0;
  border-top: 1px solid #dce6ed;
  border-radius: 0 0 var(--radius) var(--radius);
}

.reader-body pre {
  margin: 10px 0 16px;
  padding: 14px;
  border: 1px solid #dce6ed;
  border-radius: var(--radius);
  background: #0f1720;
  color: #f6fbfc;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre;
}

.reader-body .source-details pre {
  margin: 0;
  border: 0;
  border-top: 1px solid #dce6ed;
  border-radius: 0 0 var(--radius) var(--radius);
}

.reader-empty,
.reader-error {
  padding: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.topic-row {
  min-height: 78px;
}

.note-panel textarea {
  width: 100%;
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.resource-panel {
  position: sticky;
  top: 20px;
  padding: 16px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.course-browser .resource-panel {
  position: static;
  max-height: none;
}

.resource-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.resource-row {
  width: 100%;
  border: 1px solid #e3ebf1;
  text-align: left;
  background: #fbfdfe;
  grid-template-columns: 1fr auto;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}

.resource-row strong {
  display: block;
  margin-bottom: 4px;
}

.resource-row small,
.paper-row small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pdf-preview {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.preview-head {
  min-height: 42px;
  padding: 0 12px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.preview-head span {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.preview-head a {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

#pdfFrame {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  background: #f8fafc;
}

.question-lab {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.question-controls {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.question-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.question-controls select {
  min-height: 42px;
  padding: 0 10px;
  color: var(--ink);
}

.confidence {
  display: grid;
  gap: 8px;
}

.confidence > span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.confidence-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.confidence-button {
  background: #f7fafc;
  border-color: var(--line);
}

.prompt-card {
  min-height: 360px;
  padding: 24px;
  border-top: 8px solid var(--blue);
}

.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.prompt-meta span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf2f8;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
}

.prompt-card h3 {
  font-size: 1.25rem;
  margin-bottom: 10px;
}

.prompt-card p {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.6;
}

details {
  margin-top: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

summary {
  cursor: pointer;
  font-weight: 900;
}

.paper-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.paper-list {
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding-right: 4px;
}

.paper-row {
  grid-template-columns: 1fr;
  text-align: left;
  cursor: pointer;
}

.paper-row.active {
  border-color: var(--violet);
  background: #f3f0fb;
}

.paper-editor {
  padding: 20px;
}

.paper-focus {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.paper-focus h3 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.paper-focus p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.abstract-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.abstract-grid textarea {
  min-height: 140px;
  padding: 12px;
  color: var(--ink);
  line-height: 1.5;
  resize: vertical;
}

.planner-grid {
  grid-template-columns: repeat(4, minmax(220px, 1fr));
}

.planner-card {
  padding: 16px;
  border-top: 6px solid var(--course-color);
  min-height: 230px;
}

.planner-card h3 {
  margin: 0 0 10px;
}

.planner-card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.planner-task {
  grid-template-columns: 22px 1fr;
  margin-top: 8px;
}

.search-results {
  display: none;
  position: fixed;
  top: 86px;
  right: 28px;
  width: min(620px, calc(100vw - 40px));
  max-height: min(680px, calc(100vh - 120px));
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.search-results.active {
  display: grid;
  gap: 8px;
}

.search-result {
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid #e3ebf1;
  background: #fbfdfe;
}

.search-result h4 {
  margin: 0 0 4px;
}

.search-result p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }

  .course-layout,
  .paper-layout,
  .question-lab,
  .two-column,
  .lesson-body,
  .dashboard-insights {
    grid-template-columns: 1fr;
  }

  .resource-panel,
  .lesson-toc {
    position: static;
    max-height: none;
  }

  .planner-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    width: auto;
    padding: 16px;
  }

  body.sidebar-collapsed .sidebar {
    width: 0;
    height: 0;
    padding: 0;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-button {
    min-height: 62px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
    font-size: 0.78rem;
    padding: 8px 4px;
  }

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

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

  .main-area {
    padding: 18px;
  }

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

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 0;
  }

  .timer-widget {
    justify-content: space-between;
  }

  .dashboard-grid,
  .topic-board,
  .planner-grid,
  .abstract-grid,
  .subsection-layout,
  .lesson-grid,
  .exam-overview {
    grid-template-columns: 1fr;
  }

  .lesson-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .reader-actions {
    justify-content: flex-start;
  }

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

  .course-visual {
    height: 110px;
  }

  .note-reader,
  .subsection-list {
    max-height: none;
  }

  .lesson-page {
    padding: 12px;
  }

  #pdfFrame {
    height: 360px;
  }
}

@media (max-width: 520px) {
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .paper-list {
    max-height: none;
  }

  .prompt-card,
  .panel,
  .paper-editor,
  .resource-panel,
  .question-controls {
    padding: 14px;
  }
}

/* ─── Streak badge ─────────────────────────────────────────── */
.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 46px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 800;
  color: var(--amber);
  white-space: nowrap;
}

.streak-badge svg {
  width: 18px;
  height: 18px;
  fill: var(--amber);
  stroke: none;
}

.streak-badge #streakCount {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.streak-badge small {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

/* ─── Question source tag ──────────────────────────────────── */
.prompt-source {
  margin-top: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.prompt-body {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.65;
}

.q-lab-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Note reader: tables ──────────────────────────────────── */
.reader-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 0.88rem;
}

.reader-body th {
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 800;
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.reader-body td {
  padding: 7px 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.45;
}

.reader-body tr:nth-child(even) td {
  background: var(--surface-strong);
}

/* ─── Note reader: math display ────────────────────────────── */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.reader-body .katex {
  font-size: 1em;
}

/* ─── Note reader: definition / theorem boxes ──────────────── */
.reader-body blockquote {
  margin: 14px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--teal);
  background: #f0f8f8;
  color: var(--ink);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.93rem;
  line-height: 1.6;
}

.reader-body .def-box {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ═══════════════════════════════════════════════════════════
   New components: week grid, lesson tabs, PDF viewer, features
   ═══════════════════════════════════════════════════════════ */

.course-card {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(30, 47, 66, 0.14);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.week-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--course-color);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: 0 8px 20px rgba(30, 47, 66, 0.06);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.week-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(30, 47, 66, 0.12);
}
.week-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.week-num {
  color: var(--course-color);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.week-card h4 {
  margin: 0;
  font-size: 1rem;
}
.week-card.done {
  background: #f7fcf9;
}
.done-pill {
  background: #e2f3e6;
  color: var(--green);
}
.week-topics {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.week-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.week-actions .secondary-button,
.week-actions .primary-button {
  padding: 7px 12px;
  font-size: 0.82rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.week-card-empty {
  grid-column: 1 / -1;
  border-left-color: var(--muted);
}

/* Lesson tabs + PDF viewer */
.lesson-tabs {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px;
  background: var(--surface-strong);
  gap: 4px;
}
.tab-button {
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
}
.tab-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(30, 47, 66, 0.1);
}
.pdf-viewer {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  min-height: 70vh;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.pdf-toolbar p {
  margin: 0;
  font-weight: 700;
}
#pdfFrame {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: #e8eef3;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.hidden { display: none !important; }

/* Flashcards */
.flashcard-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: start;
}
.flashcard {
  min-height: 320px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 16px;
  box-shadow: 0 8px 28px rgba(30, 47, 66, 0.08);
}
.flashcard-front,
.flashcard-back {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  min-height: 120px;
  font-size: 1.05rem;
  line-height: 1.55;
}
.flashcard-back {
  background: rgba(15, 119, 121, 0.08);
  border: 1px solid rgba(15, 119, 121, 0.2);
}
.flashcard-stats {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(30, 47, 66, 0.06);
}
.flashcard-stats h4 {
  margin: 0 0 10px;
}
.flashcard-stats p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.flashcard-stats label {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}
.flashcard-stats select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* Formula sheet */
.formula-sheet {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--course-color, var(--teal));
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(30, 47, 66, 0.08);
}
.formula-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.formula-header h3 {
  margin: 0;
}
.formula-section {
  margin-top: 18px;
}
.formula-section h4 {
  margin: 0 0 10px;
  color: var(--course-color, var(--teal));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}
.formula-item {
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fbfdff;
  margin-bottom: 8px;
}
.formula-item strong {
  display: block;
  margin-bottom: 4px;
}
.formula-item .formula-math {
  padding: 6px 0;
  overflow-x: auto;
}
.formula-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

@media print {
  .sidebar,
  .topbar,
  .section-heading { display: none; }
  .formula-sheet { box-shadow: none; }
  body { background: #fff; }
}

/* Distribution gallery */
.distribution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.distribution-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(30, 47, 66, 0.06);
}
.distribution-card.discrete { border-top: 6px solid var(--teal); }
.distribution-card.continuous { border-top: 6px solid var(--violet); }
.distribution-card header h4 { margin: 8px 0 4px; }
.distribution-card header p { margin: 0 0 10px; color: var(--muted); font-size: 0.88rem; }
.distribution-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
}
.distribution-card dt {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 2px;
}
.distribution-card dd {
  margin: 0;
  overflow-x: auto;
}

/* Markov solver */
.markov-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}
.markov-layout textarea {
  width: 100%;
  min-height: 180px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
.markov-controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.markov-output {
  font-size: 0.9rem;
  line-height: 1.5;
}
.markov-output h4 {
  margin: 14px 0 6px;
  color: var(--blue);
}
.markov-output ul {
  margin: 6px 0;
  padding-left: 18px;
}
.matrix-table {
  border-collapse: collapse;
  margin: 6px 0 14px;
  font-variant-numeric: tabular-nums;
}
.matrix-table th,
.matrix-table td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: center;
  min-width: 52px;
}
.matrix-table th {
  background: var(--surface-strong);
  color: var(--blue);
  font-weight: 700;
}

/* Glossary */
.glossary-term {
  border-bottom: 1px dotted var(--teal);
  cursor: help;
}
.glossary-tooltip {
  position: absolute;
  z-index: 999;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0b1a22;
  color: #f2f8f8;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-size: 0.86rem;
  line-height: 1.4;
  pointer-events: none;
}
.glossary-tooltip strong { display: block; margin-bottom: 4px; }
.glossary-tooltip p { margin: 0 0 4px; opacity: 0.92; }
.glossary-tooltip small { opacity: 0.7; }

/* Reader improvements */
.note-reader {
  padding: 30px 36px;
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 65vh;
}
.note-reader .reader-body {
  max-width: 900px;
  line-height: 1.7;
  font-size: 1rem;
}
.note-reader h1 {
  margin: 0 0 20px;
  font-size: 1.9rem;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--course-color, var(--teal));
}
.note-reader h2 {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 1.35rem;
}
.note-reader h3 {
  margin-top: 24px;
  color: var(--course-color, var(--teal));
}
.note-reader h4 {
  margin-top: 18px;
}
.note-reader p,
.note-reader li { line-height: 1.7; }
.note-reader blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--course-color, var(--teal));
  background: var(--surface-strong);
  border-radius: 4px;
  color: var(--muted);
}
.note-reader code {
  padding: 1px 6px;
  background: var(--surface-strong);
  border-radius: 3px;
  font-size: 0.92em;
}
.note-reader pre {
  padding: 12px;
  background: #0f1a22;
  color: #e5eef2;
  border-radius: 6px;
  overflow-x: auto;
}
.note-reader table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
}
.note-reader th,
.note-reader td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}
.note-reader th {
  background: var(--surface-strong);
}
.katex-display {
  margin: 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Prompt body / confidence buttons (already styled above; ensure visible) */
.confidence-button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  font-weight: 700;
  color: var(--ink);
}
.confidence-button.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* Lesson body grid: fixed layout for TOC + reader/PDF */
.lesson-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
}
.lesson-page {
  padding: 20px;
}
.lesson-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.lesson-header h3 {
  margin: 0;
}

/* Question lab tweaks */
.question-lab {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.question-controls {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.question-controls label {
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.question-controls select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.prompt-card {
  padding: 22px;
}
.prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.prompt-meta span {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.prompt-body { line-height: 1.6; }
details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--teal);
  margin-top: 8px;
}

@media (max-width: 1000px) {
  .markov-layout,
  .lesson-body,
  .question-lab,
  .flashcard-wrap,
  .dashboard-insights,
  .two-column {
    grid-template-columns: minmax(0, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

