:root {
  --bg: #0a0a0c;
  --bg-2: #111114;
  --panel: #16161b;
  --panel-2: #1d1d24;
  --border: #26262e;
  --border-soft: #1f1f25;
  --text: #ebebef;
  --text-soft: #c5c5cf;
  --muted: #7d7d8c;
  --accent: #b794ff;
  --accent-2: #6cc6ff;
  --accent-glow: rgba(183, 148, 255, 0.18);
  --good: #5dd394;
  --warn: #ffc663;
  --bad: #ff7a7a;
  --board-bg: #faf7ef;
  --board-ink: #2a2622;
  --board-rule: #d9d3c1;
  --board-accent: #9b5cff;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; outline: none; }

input, textarea, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #232330; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #b794ff, #8a5cff);
  border-color: #8a5cff;
  color: #0a0a0c;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.lg { padding: 14px 26px; font-size: 16px; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.send-btn {
  background: linear-gradient(180deg, #b794ff, #8a5cff);
  border: none;
  border-radius: 10px;
  color: #0a0a0c;
  cursor: pointer;
  padding: 8px 10px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: filter .12s, transform .05s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* App layout */
#app {
  display: grid;
  grid-template-columns: 56px 1fr;
  height: 100vh;
  position: relative;
}

/* Slim rail */
#rail {
  background: var(--bg-2);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
}
#rail .icon-btn { width: 36px; height: 36px; padding: 0; }
#rail-spacer { flex: 1; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  margin: 8px 0;
  transition: background .2s;
}
.dot.good { background: var(--good); box-shadow: 0 0 8px rgba(93, 211, 148, 0.6); }
.dot.bad  { background: var(--bad); box-shadow: 0 0 8px rgba(255, 122, 122, 0.6); }

/* Drawer */
#drawer {
  position: fixed; left: 56px; top: 0; bottom: 0;
  width: 280px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 50;
  display: flex; flex-direction: column;
  padding: 16px;
  gap: 12px;
  transform: translateX(0);
  transition: transform .2s ease;
  box-shadow: 16px 0 32px rgba(0,0,0,.3);
}
#drawer.collapsed { transform: translateX(-100%); box-shadow: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #0a0a0c;
}
.brand-title { font-weight: 700; font-size: 18px; }
.drawer-section-title {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-top: 4px;
}
#topics-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.topic-card {
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  position: relative;
}
.topic-card:hover { background: var(--panel); }
.topic-card.active { background: var(--panel); border-color: var(--border); }
.topic-card .name { font-weight: 500; font-size: 14px; }
.topic-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topic-card .mini-mastery {
  height: 3px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden;
}
.topic-card .mini-mastery > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.topic-card .del {
  position: absolute; top: 6px; right: 6px;
  opacity: 0; transition: opacity .12s;
  background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 16px;
}
.topic-card:hover .del { opacity: 1; }
.topic-card .del:hover { color: var(--bad); }
.drawer-foot {
  font-size: 12px; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--border-soft);
}

/* Main views */
#main {
  overflow: hidden;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(183, 148, 255, 0.08), transparent 60%),
    var(--bg);
}
.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view:not(.hidden) { display: flex; }

/* Hub */
#hub { overflow-y: auto; padding: 60px 24px; align-items: center; }
.hub-inner {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.hub-greet { margin-bottom: 8px; }
.hub-eyebrow {
  font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .12em;
  margin-bottom: 4px;
}
#hub-name {
  font-size: 56px; font-weight: 800; line-height: 1;
  margin: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-sub { color: var(--muted); font-size: 17px; margin: 16px 0 32px; }

.hub-composer { margin-bottom: 28px; }

.hub-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 40px;
}
.action-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s, transform .12s;
  display: flex; flex-direction: column; gap: 6px;
}
.action-card:hover { background: var(--panel-2); border-color: #353548; transform: translateY(-2px); }
.action-icon { font-size: 26px; line-height: 1; margin-bottom: 6px; }
.action-title { font-weight: 600; font-size: 15px; color: var(--text); }
.action-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }

.hub-recent {
  display: flex; flex-direction: column; gap: 8px;
}
.hub-recent:not(:empty)::before {
  content: "Pick up where you left off";
  display: block;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 8px;
}
.recent-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .12s, border-color .12s;
}
.recent-item:hover { background: var(--panel-2); border-color: #353548; }
.recent-item .ri-name { font-weight: 500; font-size: 14px; }
.recent-item .ri-meta { font-size: 12px; color: var(--muted); }

/* Conversation */
#conv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(10, 10, 12, 0.6);
  backdrop-filter: blur(12px);
}
.conv-title-wrap { flex: 1; min-width: 0; }
#conv-title { margin: 0; font-size: 16px; font-weight: 600; }
#conv-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.conv-mastery { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mastery-bar { width: 100px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.mastery-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }

#thread {
  flex: 1; overflow-y: auto;
  padding: 24px 24px 40px;
}

/* Message bubble */
.msg {
  max-width: 820px;
  margin: 0 auto 22px;
}
.msg .who {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.msg .who .who-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.msg.user .who .who-dot { background: var(--accent-2); }
.msg .body { line-height: 1.65; color: var(--text); }
.msg .body :first-child { margin-top: 0; }
.msg .body :last-child { margin-bottom: 0; }
.msg .body p { margin: 8px 0; }
.msg .body code { background: rgba(255,255,255,0.07); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, monospace; }
.msg .body pre { background: #050507; padding: 14px; border-radius: 10px; overflow-x: auto; border: 1px solid var(--border-soft); }
.msg .body pre code { padding: 0; background: none; }
.msg .body blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 12px; color: var(--text-soft); }
.msg.user .body {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 14px;
}

/* Composer */
.composer {
  padding: 12px 24px 20px;
  background: linear-gradient(180deg, transparent, var(--bg) 40%);
}
.hub-composer { padding: 0; background: none; }
.composer-wrap {
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 10px 10px 16px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.composer-wrap textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 0;
  resize: none;
  min-height: 24px;
  max-height: 220px;
  line-height: 1.5;
}
.composer-actions { display: flex; align-items: center; gap: 4px; }

/* ===== INLINE CARDS (tool outputs in chat) ===== */
.tool-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.tool-card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.tool-card-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0a0c;
}
.tool-card-title { font-weight: 600; font-size: 14px; }
.tool-card-sub { font-size: 12px; color: var(--muted); margin-left: auto; }

/* Whiteboard inline card */
.board-card {
  background: var(--board-bg);
  color: var(--board-ink);
  border-radius: 14px;
  padding: 24px 28px;
  margin: 16px 0;
  position: relative;
  font-family: "Patrick Hand", "Caveat", cursive;
  font-size: 19px;
  line-height: 1.55;
  background-image:
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, rgba(217, 211, 193, 0.5) 31px, rgba(217, 211, 193, 0.5) 32px);
  background-position: 0 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25), inset 0 0 0 1px rgba(217, 211, 193, .5);
}
.board-head {
  position: absolute; top: 8px; right: 14px;
  font-family: "Inter", sans-serif;
  font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em;
  color: #908370;
  display: flex; align-items: center; gap: 8px;
}
.board-head .dot { background: var(--board-accent); box-shadow: 0 0 6px var(--board-accent); }
.board-entries { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.board-entry { opacity: 0; transform: translateY(6px); animation: boardIn .4s ease forwards; }
.board-entry.title {
  font-family: "Caveat", cursive;
  font-size: 30px; font-weight: 700;
  color: var(--board-accent);
  margin-bottom: 8px;
  line-height: 1.1;
}
.board-entry.text { font-size: 19px; }
.board-entry.math { font-family: "KaTeX_Main", serif; padding: 4px 0; }
.board-entry.math .katex { font-size: 1.15em; }
.board-entry.callout {
  background: rgba(155, 92, 255, 0.12);
  border-left: 3px solid var(--board-accent);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: "Patrick Hand", cursive;
  color: #4a2a8a;
  font-weight: 600;
}
.board-entry.divider {
  height: 0; border-bottom: 2px dashed var(--board-rule);
  margin: 8px 0;
}
.board-entry.student {
  border-left: 3px solid var(--accent-2);
  padding-left: 10px;
  background: rgba(108, 198, 255, 0.08);
  border-radius: 4px;
}
.board-entry.student::after {
  content: " ← you";
  font-family: "Inter", sans-serif;
  font-size: 11px;
  color: #6cc6ff;
  letter-spacing: .04em;
  margin-left: 8px;
  opacity: .85;
}
@keyframes boardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Typewriter span for streaming text/math */
.typewriter::after {
  content: "▎";
  color: var(--board-accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0 } }

/* Practice card */
.practice-card .practice-item {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}
.practice-card .practice-item:first-of-type { border-top: none; padding-top: 0; }
.practice-card .pi-prompt { font-weight: 500; margin-bottom: 8px; }
.practice-card .pi-meta { font-size: 11px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .06em; }
.practice-card textarea { min-height: 60px; margin-bottom: 8px; font-size: 14px; }
.practice-card .pi-actions { display: flex; gap: 8px; }
.practice-card .pi-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border-left: 3px solid var(--muted);
  font-size: 14px;
}
.practice-card .pi-feedback.good { border-left-color: var(--good); }
.practice-card .pi-feedback.bad  { border-left-color: var(--bad); }
.practice-card .pi-feedback.mid  { border-left-color: var(--warn); }
.practice-card .pi-score {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: 11px;
  background: var(--panel); margin-right: 6px;
  font-weight: 600;
}

/* Quiz card */
.quiz-card .quiz-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.quiz-card .qq {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.quiz-card .qq-num { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.quiz-card .qq-prompt { font-weight: 500; margin-bottom: 8px; }
.quiz-card .qq-choice {
  display: block; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer;
  font-size: 14px;
}
.quiz-card .qq-choice:hover { background: var(--panel); }
.quiz-card .qq-choice input { width: auto; margin-right: 8px; }
.quiz-card .qq textarea { font-size: 14px; min-height: 48px; }
.quiz-result-summary {
  text-align: center;
  padding: 12px 0 20px;
}
.quiz-result-summary .big-score {
  font-size: 56px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}

/* Aids card */
.aids-card .aid {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.aids-card .aid-tactic {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: 10px;
  font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #0a0a0c;
}
.aids-card .aid-title { font-weight: 600; margin: 8px 0 4px; font-size: 14px; }
.aids-card .aid-content { font-size: 14px; color: var(--text-soft); white-space: pre-wrap; }

/* Math keyboard */
#math-keyboard {
  position: fixed; bottom: 100px; right: 24px;
  width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  z-index: 300;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.mk-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.mk-title { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.mk-tabs {
  display: flex; gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 8px;
}
.mk-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.mk-tab:hover { color: var(--text); }
.mk-tab.active { background: var(--panel-2); color: var(--text); }
#mk-keys {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
}
.mk-key {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 4px;
  cursor: pointer;
  font-family: "KaTeX_Main", serif;
  font-size: 16px;
  text-align: center;
  transition: background .1s, transform .05s;
  min-height: 40px;
  display: grid; place-items: center;
}
.mk-key:hover { background: #2a2a36; }
.mk-key:active { transform: translateY(1px); }
.mk-key .sub { font-size: 9px; color: var(--muted); display: block; margin-top: 2px; font-family: "Inter", sans-serif; }

/* Dialog */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(8px); }
dialog h2 { margin: 0 0 8px; font-size: 22px; }
dialog .dialog-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
dialog label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
dialog label input, dialog label textarea, dialog label select { margin-top: 6px; color: var(--text); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.welcome-logo {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 24px; color: #0a0a0c;
  margin: 0 auto 18px;
}
#welcome-dialog h2 { text-align: center; }
#welcome-dialog .dialog-sub { text-align: center; }
.welcome-input input { font-size: 17px; padding: 14px 16px; text-align: center; }

/* Loading */
.loading {
  color: var(--muted);
  font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px;
}
.loading::after {
  content: "";
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3 } 50% { opacity: 1 } }

/* Conv tabs */
.conv-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin-right: 8px; }
.ctab { background: transparent; border: none; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; }
.ctab:hover { color: var(--text); }
.ctab.active { background: var(--panel-2); color: var(--text); }

/* Board card — expand button + svg/graph entries */
.board-card { position: relative; }
.board-expand {
  position: absolute; top: 8px; right: 90px;
  background: rgba(155,92,255,.1);
  border: 1px solid rgba(155,92,255,.3);
  color: var(--board-accent);
  font-family: "Inter", sans-serif;
  font-size: 11px;
  padding: 4px 10px; border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase; letter-spacing: .06em;
}
.board-expand:hover { background: rgba(155,92,255,.2); }
.board-entry.svg, .board-entry.graph {
  background: white;
  border: 1px solid #d9d3c1;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}
.board-entry.svg svg, .board-entry.graph svg { display: block; width: 100%; height: auto; max-height: 360px; }
.board-entry.svg .svg-title, .board-entry.graph .graph-title {
  font-family: "Caveat", cursive;
  font-size: 22px;
  font-weight: 700;
  color: var(--board-accent);
  margin-bottom: 6px;
  text-align: center;
}
.graph-legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; font-family: "Inter", sans-serif; font-size: 12px; color: #5b5040; }
.graph-legend .lg-item { display: flex; align-items: center; gap: 6px; }
.graph-legend .lg-swatch { width: 14px; height: 3px; border-radius: 2px; }

/* Fullscreen whiteboard */
#fs-board {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex; flex-direction: column;
}
#fs-board.hidden { display: none; }
#fs-board-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.fs-title { flex: 1; display: flex; flex-direction: column; }
.fs-title strong { font-size: 16px; }
.fs-eyebrow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
#fs-board-body { flex: 1; display: grid; grid-template-columns: 1fr 380px; overflow: hidden; }
#fs-board-canvas {
  overflow-y: auto;
  padding: 28px;
  background: linear-gradient(180deg, rgba(155,92,255,.04), transparent 30%);
}
.fs-board-card {
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  max-width: 1100px;
  font-size: 22px;
}
.fs-board-card .board-entry.title { font-size: 36px; }
.fs-board-card .board-entry.text { font-size: 22px; }

#fs-chat {
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#fs-chat-thread {
  flex: 1; overflow-y: auto;
  padding: 16px;
}
#fs-chat-thread .msg { max-width: 100%; margin-bottom: 14px; }
#fs-chat-thread .msg.user .body { padding: 8px 12px; font-size: 14px; }
#fs-chat-thread .msg.assistant .body { font-size: 14px; }
#fs-chat .composer { padding: 12px; background: var(--bg-2); }

/* Notebook view */
#notebook-view {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(108, 198, 255, 0.06), transparent 60%),
    var(--bg);
}
.notebook-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  max-width: 820px; margin: 0 auto 20px;
  padding: 0 12px;
}
.nb-title-wrap h3 { margin: 0; font-size: 20px; }
.nb-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.nb-actions { display: flex; gap: 8px; }

#notebook-page {
  max-width: 820px;
  margin: 0 auto;
  background: #fbfaf5;
  color: #2a2622;
  border-radius: 6px;
  padding: 56px 64px;
  min-height: 70vh;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  position: relative;
  background-image:
    linear-gradient(to right, transparent 56px, #f7c2c2 56px, #f7c2c2 58px, transparent 58px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 27px, #d9e2f0 27px, #d9e2f0 28px);
  background-position: 0 0;
}
#notebook-page::before {
  content: "";
  position: absolute;
  left: 28px; top: 28px; bottom: 28px;
  width: 0;
  border-left: 1px dashed #c5c5c5;
}
#notebook-list { font-family: "Patrick Hand", "Caveat", cursive; font-size: 18px; line-height: 28px; }
#notebook-list:empty::before {
  content: "Your notebook will fill up as your tutor writes things worth keeping.";
  color: #88827a;
  font-style: italic;
  font-size: 16px;
}
.nb-note { margin-bottom: 24px; position: relative; }
.nb-note .nb-tag {
  display: inline-block;
  font-family: "Inter", sans-serif;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ffd45c;
  color: #4a3a00;
  margin-right: 8px;
  vertical-align: 2px;
}
.nb-note .nb-tag.formula { background: #b794ff; color: #2c1759; }
.nb-note .nb-tag.definition { background: #6cc6ff; color: #073a5a; }
.nb-note .nb-tag.example { background: #5dd394; color: #074725; }
.nb-note .nb-tag.reminder { background: #ff9b6b; color: #4a1a00; }
.nb-note .nb-title {
  font-family: "Caveat", cursive;
  font-size: 26px;
  font-weight: 700;
  color: #1a1410;
  line-height: 1.1;
  display: inline;
}
.nb-note .nb-body { margin-top: 8px; color: #2a2622; }
.nb-note .nb-body p { margin: 4px 0; }
.nb-note .nb-body code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: 14px; }
.nb-note .nb-body .katex { font-family: "KaTeX_Main", serif; font-size: 1.05em; }
.nb-note .nb-edit {
  position: absolute; top: 0; right: 0;
  font-family: "Inter", sans-serif; font-size: 11px;
  background: transparent; border: 1px solid transparent;
  color: #88827a; cursor: pointer; padding: 2px 8px; border-radius: 4px;
  opacity: 0; transition: opacity .12s, border-color .12s;
}
.nb-note:hover .nb-edit { opacity: 1; border-color: #d9d3c1; }
.nb-note .nb-edit:hover { background: rgba(0,0,0,.05); }

/* Print */
@media print {
  body { background: white !important; }
  #app, #rail, #drawer, #conv-head, #thread, #chat-form, #math-keyboard, #fs-board, dialog, .notebook-toolbar {
    display: none !important;
  }
  #notebook-view, .view, #conversation, main { display: block !important; background: white !important; }
  #notebook-page {
    box-shadow: none !important;
    background: white !important;
    background-image: none !important;
    color: #000 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  #notebook-page::before { display: none !important; }
  .nb-note { page-break-inside: avoid; }
  .nb-edit { display: none !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26262e; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #353548; }
