:root {
  --bg: #f4f5f2;
  --bg-wash: radial-gradient(circle at top left, rgba(255, 255, 255, 0.88), transparent 24%), radial-gradient(circle at 78% 12%, rgba(244, 241, 233, 0.7), transparent 22%), linear-gradient(180deg, #f8f8f5 0%, #f1f2ee 100%);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-2: #f6f6f2;
  --ink: #1f2623;
  --muted: #6c7770;
  --line: rgba(73, 84, 78, 0.12);
  --accent: #2f6b57;
  --accent-strong: #234f41;
  --accent-soft: #edf1ed;
  --accent-2: #8f6a2f;
  --shadow: 0 18px 42px rgba(24, 28, 25, 0.07);
  --shadow-soft: 0 8px 20px rgba(24, 28, 25, 0.04);
  --radius: 24px;
  --radius-sm: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "SF Pro Serif", "New York", "Iowan Old Style", Georgia, serif;
  color: var(--ink);
  background: var(--bg-wash);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none !important;
}

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

.library-rail,
.context-sidebar {
  border-right: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.library-rail {
  padding: 20px 14px 24px;
}

.context-sidebar {
  padding: 24px 20px 28px;
}

.library-rail-header {
  margin-bottom: 18px;
}

.brand-block h1,
.topbar h2,
.card h3,
.workspace-heading,
.chapter-tile h3,
.live-prompt {
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 10px;
  color: var(--muted);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
}

.brand-block h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
}

.subhead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.primary-nav,
.session-nav,
.rail-nav,
.rail-books {
  display: grid;
  gap: 10px;
}

.primary-nav { margin-top: 24px; }
.rail-books-block { margin-top: 24px; }
.session-nav-block { margin-top: 28px; }
.sidebar-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav-link,
.rail-link,
.session-link,
.ghost-button,
.solid-button,
.chip-button,
.prompt-link {
  border: 0;
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  text-align: left;
  transition: 180ms ease;
}

.nav-link:hover,
.rail-link:hover,
.session-link:hover,
.ghost-button:hover,
.solid-button:hover,
.chip-button:hover,
.prompt-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.nav-link.is-active,
.rail-link.is-active,
.session-link.is-active,
.chip-button.is-active {
  background: #eef1ee;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 6px 14px rgba(24, 28, 25, 0.04);
}

.session-link small {
  display: block;
  color: inherit;
  opacity: 0.78;
  margin-top: 6px;
}

.rail-link,
.rail-book-link {
  text-align: center;
  padding: 14px 10px;
}

.rail-book-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
  line-height: 0;
}

.rail-book-link:hover {
  transform: none;
  box-shadow: none;
}

.rail-book-link.is-active {
  background: transparent;
  box-shadow: 0 0 0 2px rgba(31, 38, 35, 0.12), 0 10px 22px rgba(24, 28, 25, 0.1);
}

.rail-book-cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: top center;
  border-radius: 0;
  box-shadow: 0 8px 18px rgba(24, 28, 25, 0.08);
}

.rail-book-fallback {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 18px rgba(24, 28, 25, 0.06);
}

.rail-book-fallback[hidden] {
  display: none;
}

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

.notes-panel {
  border-left: 0;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(16px);
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.notes-card {
  min-height: 100vh;
}

.notes-canvas-shell {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(to bottom, transparent 31px, rgba(96, 113, 103, 0.1) 32px),
    linear-gradient(90deg, rgba(73, 84, 78, 0.06) 39px, transparent 40px),
    var(--panel-2);
  background-size: 100% 32px, 100% 100%, auto;
  overflow: visible;
}

.notes-tool-group {
  position: sticky;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  width: 100%;
  padding: 14px 14px 0;
  pointer-events: none;
}

.notes-tool-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
}

.notes-tool-button.is-active {
  background: #28312d;
  color: #fff;
  border-color: #28312d;
}

.notes-tool-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.notes-canvas {
  display: block;
  width: 100%;
  min-height: 100vh;
  touch-action: none;
  cursor: crosshair;
}

.notes-canvas.is-erasing {
  cursor: cell;
}

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

.topbar h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 0.96;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: 0 0 auto;
}

.topbar-icon-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(18px);
}

.topbar-icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(24, 28, 25, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.topbar-icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(24, 28, 25, 0.08);
  background: rgba(255, 255, 255, 0.96);
}

.topbar-icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.view { display: none; }
.view.is-active { display: block; }

.grid,
.card-grid {
  display: grid;
  gap: 18px;
}

.card-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.05;
}

.card p,
.card li,
.note,
.inline-meta {
  font-size: 16px;
  line-height: 1.55;
}

.muted { color: var(--muted); }

.list {
  margin: 0;
  padding-left: 18px;
}
.list li + li { margin-top: 8px; }

.hero-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.hero-title {
  margin: 0;
  font-size: 44px;
  line-height: 0.95;
}

.workspace-summary {
  gap: 8px;
  padding: 4px 0 10px;
}

.workspace-hero-copy {
  display: grid;
  gap: 5px;
}

.workspace-meta {
  margin: 0;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}

.hero-summary {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.library-card {
  display: grid;
  gap: 16px;
  align-content: space-between;
}

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

.library-meta span {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--accent-soft);
  color: var(--muted);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.dashboard-session-actions,
.live-actions,
.inline-actions,
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.solid-button {
  background: #28312d;
  color: #fff;
  box-shadow: 0 10px 22px rgba(24, 28, 25, 0.12);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.75);
}

.emphasis-button {
  background: #eef1ee;
  color: var(--ink);
  box-shadow: none;
}

.kicker {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.chapter-tile {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 128px;
  padding: 16px 16px 14px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 24px rgba(24, 28, 25, 0.05);
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.chapter-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(24, 28, 25, 0.08);
  background: rgba(255, 255, 255, 0.96);
}

.chapter-tile h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.08;
}

.chapter-tile .muted {
  margin: 6px 0 0;
  font-size: 14px;
}

.live-shell {
  display: grid;
  gap: 16px;
}

.live-card {
  padding: 32px;
}

.live-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.live-prompt {
  margin: 18px 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

.note {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.prompt-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.prompt-link {
  background: var(--panel-2);
}

.section-tabs {
  margin-top: 12px;
}

.question-list {
  margin-top: 16px;
}

.question-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.chapter-actions {
  margin-top: 24px;
}

.chapter-intro-card,
.chapter-intro-head {
  display: grid;
  gap: 10px;
}

.chapter-intro-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.chapter-position {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.handout-session + .handout-session {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.empty-state-copy {
  margin: 0;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}

.live-mode body,
body.live-mode {
  background: #141414;
}

body.live-mode .library-rail,
body.live-mode .context-sidebar {
  background: rgba(18, 18, 18, 0.95);
  color: #f2eee7;
  border-right-color: rgba(255,255,255,0.12);
}
body.live-mode .notes-panel {
  background: rgba(18, 18, 18, 0.95);
  border-left-color: rgba(255,255,255,0.12);
}
body.live-mode .main-panel,
body.live-mode .topbar h2,
body.live-mode .brand-block h1,
body.live-mode .subhead,
body.live-mode .sidebar-label,
body.live-mode .eyebrow,
body.live-mode .nav-link,
body.live-mode .rail-link,
body.live-mode .session-link,
body.live-mode .ghost-button,
body.live-mode .chapter-tile,
body.live-mode .card,
body.live-mode .card p,
body.live-mode .card li,
body.live-mode .muted,
body.live-mode .note,
body.live-mode .live-progress {
  color: #f2eee7;
}
body.live-mode .card,
body.live-mode .nav-link,
body.live-mode .rail-link,
body.live-mode .ghost-button,
body.live-mode .chapter-tile,
body.live-mode .prompt-link,
body.live-mode .topbar-icon-button {
  background: #1f1f1f;
  border-color: rgba(255,255,255,0.12);
  box-shadow: none;
}
body.live-mode .topbar-icon-group {
  background: rgba(31, 31, 31, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
body.live-mode .session-link {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
body.live-mode .nav-link.is-active,
body.live-mode .rail-link.is-active,
body.live-mode .chip-button.is-active,
body.live-mode .solid-button {
  background: #e0b369;
  color: #17120c;
  border-color: #e0b369;
}
body.live-mode .session-link.is-active {
  background: transparent;
  color: #f2eee7;
  border-color: transparent;
}
body.live-mode .rail-book-cover,
body.live-mode .rail-book-fallback {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}
body.live-mode .rail-book-fallback {
  background: #1f1f1f;
  color: #f2eee7;
}
body.live-mode .rail-book-link.is-active {
  box-shadow: 0 0 0 2px rgba(224, 179, 105, 0.85), 0 14px 28px rgba(0, 0, 0, 0.28);
}
body.live-mode .prompt-link { background: #232323; }
body.live-mode .emphasis-button {
  background: #262626;
  color: #f2eee7;
  border-color: rgba(255,255,255,0.12);
}
body.live-mode .note,
body.live-mode .handout-session + .handout-session { border-color: rgba(255,255,255,0.12); }
body.live-mode .notes-canvas-shell {
  border-color: rgba(255,255,255,0.16);
  background:
    linear-gradient(to bottom, transparent 31px, rgba(255,255,255,0.08) 32px),
    linear-gradient(90deg, rgba(224, 179, 105, 0.14) 39px, transparent 40px),
    #181818;
}
body.live-mode .notes-tool-button {
  background: rgba(31, 31, 31, 0.96);
  color: #f2eee7;
  border-color: rgba(255,255,255,0.12);
}
body.live-mode .notes-tool-button.is-active {
  background: #e0b369;
  color: #17120c;
  border-color: #e0b369;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .library-rail,
  .context-sidebar {
    position: static;
    height: auto;
    border-bottom: 1px solid var(--line);
  }
  .library-rail {
    border-right: 0;
    padding-bottom: 18px;
  }
  .context-sidebar {
    border-right: 0;
  }
  .notes-panel {
    position: static;
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .notes-card {
    min-height: 0;
  }
  .notes-canvas-shell {
    min-height: 360px;
  }
  .card-grid.two-up,
  .card-grid.three-up { grid-template-columns: 1fr; }
  .chapter-grid { grid-template-columns: 1fr; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .workspace-summary,
  .chapter-intro-head {
    grid-template-columns: 1fr;
  }
  .rail-books {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}
