/* ── lockedinlikealion ── */
/* dark, clean, no slop */

:root {
  --bg: #0e0e10;
  --bg-raised: #17171a;
  --bg-hover: #1e1e22;
  --bg-input: #121214;
  --border: #2a2a2e;
  --border-light: #333338;
  --text: #e4e4e7;
  --text-dim: #8b8b94;
  --text-muted: #5a5a63;
  --accent: #c8a46e;
  --accent-dim: #a68a56;
  --green: #4ade80;
  --green-dim: #166534;
  --yellow: #facc15;
  --red: #f87171;
  --radius: 6px;
  --font: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--text); }

/* ── Nav ── */

nav {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 48px;
  display: flex;
  align-items: center;
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 400;
}
.nav-brand:hover { color: var(--accent); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 0.8rem;
}

.nav-user { color: var(--text-dim); }
.nav-link { color: var(--text-muted); }
.nav-link:hover { color: var(--text); }

/* ── Layout ── */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--text-dim);
  margin-top: 0.3rem;
  font-size: 0.85rem;
}

.breadcrumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

/* ── Buttons ── */

.btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.btn:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-small {
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
}

.btn-success {
  background: var(--green-dim);
  color: var(--green);
}

/* ── Auth ── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-box {
  width: 100%;
  max-width: 320px;
}

.auth-title {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 1.8rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.auth-form input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  transition: border-color 0.15s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form button {
  margin-top: 0.4rem;
}

.auth-switch {
  margin-top: 1.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.error-msg {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--red);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

/* ── Courses Grid ── */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.course-card {
  display: block;
  color: var(--text);
}

.course-card-inner {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  transition: all 0.2s;
  height: 100%;
}
.course-card:hover .course-card-inner {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.course-card h2 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.course-desc {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-bottom: 0.8rem;
}

.course-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Units ── */

.units-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.unit-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.unit-header {
  padding: 1rem 1.3rem;
  border-bottom: 1px solid var(--border);
}

.unit-header a {
  color: var(--text);
  display: block;
}
.unit-header a:hover { color: var(--accent); }

.unit-number, .unit-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.2rem;
}

.unit-header h2, .unit-card h2 {
  font-size: 1rem;
  font-weight: 500;
}

/* ── Problem Sets list ── */

.sets-list {
  display: flex;
  flex-direction: column;
}

.set-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.3rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.12s;
}
.set-item:last-child { border-bottom: none; }
.set-item:hover { background: var(--bg-hover); }

.set-info {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.85rem;
}

.set-type-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--border);
  color: var(--text-dim);
}
.set-type-badge.exam {
  background: rgba(200, 164, 110, 0.12);
  color: var(--accent);
}

.set-time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.check-mark {
  color: var(--green);
  font-size: 0.9rem;
}

.in-progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  display: inline-block;
}

.set-done {
  opacity: 0.6;
}
.set-done:hover { opacity: 1; }

/* ── Sets grid (unit page) ── */

.sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.set-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  color: var(--text);
  transition: all 0.2s;
  display: block;
}
.set-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.set-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.set-card h3 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.set-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.time-spent {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Overview ── */

.overview-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.overview-card h2 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--text-dim);
}

.overview-content {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.7;
}

/* ── Problem Set Page ── */

.problem-set-page {
  max-width: 760px;
}

.ps-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
}

.ps-header h1 {
  font-size: 1.2rem;
  font-weight: 500;
  margin-top: 0.3rem;
}

.ps-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.timer {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.timer-limit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timer-expired #timer-display {
  color: var(--red);
}

/* ── Calculator Drawer ── */

.calc-drawer {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.25s;
}

/* ── Questions ── */

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.question-block {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.q-number {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.q-points {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.q-text {
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.q-image {
  max-width: 100%;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

/* ── Question Parts ── */

.q-parts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.q-part {
  display: flex;
  gap: 0.8rem;
}

.part-label {
  color: var(--accent);
  font-weight: 500;
  font-size: 0.85rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.part-body {
  flex: 1;
}

.part-text {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 0.6rem;
}

/* ── Answer Input ── */

.answer-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-family: var(--font);
  font-size: 0.82rem;
  resize: vertical;
  min-height: 60px;
  line-height: 1.6;
  transition: border-color 0.15s;
}
.answer-input:focus {
  outline: none;
  border-color: var(--accent);
}
.answer-input::placeholder {
  color: var(--text-muted);
}

/* ── Solution Reveal ── */

.answer-reveal {
  margin-top: 0.8rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.answer-label {
  font-size: 0.7rem;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.answer-text {
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 0.8rem;
}

/* ── Self Grade ── */

.self-grade {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.self-grade span {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 0.3rem;
}

.grade-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}
.grade-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.grade-btn.active[data-grade="correct"] {
  border-color: var(--green);
  color: var(--green);
  background: rgba(74, 222, 128, 0.06);
}
.grade-btn.active[data-grade="partial"] {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(250, 204, 21, 0.06);
}
.grade-btn.active[data-grade="incorrect"] {
  border-color: var(--red);
  color: var(--red);
  background: rgba(248, 113, 113, 0.06);
}

/* ── Footer ── */

.ps-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Upload ── */

.upload-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 700px) {
  .upload-section { grid-template-columns: 1fr; }
}

.upload-info h3 {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.8rem;
  color: var(--text-dim);
}

.json-example {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.72rem;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-dim);
}

.upload-form textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.8rem;
  font-family: var(--font);
  font-size: 0.78rem;
  resize: vertical;
  line-height: 1.5;
  transition: border-color 0.15s;
}
.upload-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.upload-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.8rem;
  gap: 0.8rem;
}

.file-label {
  cursor: pointer;
}

.upload-status {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
}
.upload-status.success {
  color: var(--green);
  background: rgba(74, 222, 128, 0.06);
  border: 1px solid rgba(74, 222, 128, 0.15);
}
.upload-status.error {
  color: var(--red);
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.15);
}

/* ── Modal ── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}

.modal-content {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.modal-content h2 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.modal-content input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.15s;
}
.modal-content input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

/* ── Empty State ── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.empty-state h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  color: var(--text-dim);
}

/* ── Utilities ── */

.hidden { display: none !important; }

/* ── Animations ── */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.35s ease-out both;
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── Responsive ── */

@media (max-width: 600px) {
  .container { padding: 1.2rem; }
  nav { padding: 0 1.2rem; }
  .page-header { flex-direction: column; }
  .ps-header { flex-direction: column; }
  .ps-footer { flex-direction: column; gap: 0.8rem; }
  .course-grid { grid-template-columns: 1fr; }
  .header-actions { margin-top: 0.5rem; }
}


/* ════════════════════════════════════════════
   IMMERSIVE PROBLEM SET MODE
   ════════════════════════════════════════════ */

/* Override body for full-height layout */
.ps-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── Top bar ── */

.ps-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}

.ps-back {
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.ps-back:hover { color: var(--accent); }
.ps-back-label { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.ps-topbar-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ps-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.ps-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 60px;
  text-align: right;
}
.ps-timer.timer-expired { color: var(--red); }
.timer-of { font-size: 0.7rem; color: var(--text-muted); margin-left: 0.3rem; }

.ps-timer-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.ps-timer-btn:hover { color: var(--accent); }

/* ── Main split ── */

.ps-main {
  --ps-tools-w: 400px;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7px min(var(--ps-tools-w, 400px), 72vw);
  overflow: hidden;
  position: relative;
}

.ps-main.tools-panel-hidden {
  grid-template-columns: 1fr 0 0 !important;
}

.ps-col-resizer {
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: opacity 0.15s;
}
.ps-col-resizer:hover {
  background: var(--accent);
  opacity: 0.85;
}
.ps-col-resizer.hidden {
  display: none;
  width: 0;
  min-width: 0;
  padding: 0;
  border: none;
}

/* ── Question column ── */

.ps-question-col {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.question-slide {
  display: none;
  width: 100%;
  max-width: 700px;
  animation: slideIn 0.2s ease-out;
}
.question-slide.active { display: flex; flex-direction: column; gap: 1rem; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── The question card — academic, not chrome ── */

.question-card {
  background: #1c1c1f;
  border: 1px solid #2e2e33;
  border-radius: 8px;
  padding: 2.2rem 2.4rem;
  /* Use a readable font for academic content */
  font-family: 'Georgia', 'Charter', 'Palatino', 'Times New Roman', serif;
  color: #deded8;
  line-height: 1.8;
}

.qcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  font-family: var(--font);
}

.qcard-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.qcard-pts {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.qcard-stem {
  font-size: 1rem;
  line-height: 1.85;
  margin-bottom: 1.4rem;
  white-space: pre-wrap;
}

.qcard-image-wrap {
  margin: 1.2rem 0;
  text-align: center;
}
.qcard-image {
  max-width: 100%;
  max-height: 320px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #111;
}

/* ── Answer area ── */

.qcard-answer-area {
  margin-top: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.qpart {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.qpart:first-child { border-top: none; padding-top: 0; }

.qpart-left { flex-shrink: 0; padding-top: 0.1rem; }

.qpart-label {
  display: inline-block;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 1.8rem;
}

.qpart-right { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }

.qpart-text {
  font-size: 0.96rem;
  line-height: 1.75;
  color: #deded8;
}

.qpart-pts {
  font-family: var(--font);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.answer-input {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  font-family: var(--font);
  font-size: 0.82rem;
  resize: vertical;
  min-height: 64px;
  line-height: 1.6;
  transition: border-color 0.15s;
}
.answer-input:focus { outline: none; border-color: var(--accent); }
.answer-input::placeholder { color: var(--text-muted); }

.single-answer { min-height: 80px; }

/* ── Per-part scratch paper ── */

.part-scratch {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #141416;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 220px;
  transition: max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
}

.part-scratch-expanded {
  max-height: min(78vh, 1200px);
  box-shadow: 0 0 0 1px rgba(200, 164, 110, 0.15), 0 12px 48px rgba(0, 0, 0, 0.35);
}

.part-scratch-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font);
}

.part-scratch-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-right: auto;
}

.part-scratch-zoom-pill {
  font-size: 0.65rem;
  color: var(--text-dim);
  min-width: 2.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.part-scratch-icon-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.part-scratch-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.part-scratch-text-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.part-scratch-text-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wbc-toolbar-compact {
  padding: 4px 6px;
  gap: 2px;
}

.wb-pad-viewport {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #0d0d0f;
  position: relative;
  touch-action: pan-x pan-y;
}

.part-scratch-expanded .wb-pad-viewport {
  min-height: min(52vh, 640px);
}

.wb-pad-sheet {
  display: inline-block;
  transform-origin: top left;
  will-change: transform;
}

.wb-pad-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
  vertical-align: top;
}

.wbc-action.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(200, 164, 110, 0.1);
}

/* ── Solution reveal ── */

.qcard-solution {
  margin-top: 0.5rem;
}

.solution-divider {
  height: 1px;
  background: linear-gradient(to right, var(--accent), transparent);
  margin: 1.2rem 0 1rem;
  opacity: 0.4;
}

.solution-label {
  font-family: var(--font);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
  margin-bottom: 0.8rem;
}

.solution-part {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}
.solution-part-label { flex-shrink: 0; }

.solution-text {
  font-size: 0.96rem;
  line-height: 1.8;
  color: #c8c8c0;
  white-space: pre-wrap;
}

@keyframes solAppear {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sol-appear { animation: solAppear 0.25s ease-out; }

/* ── Per-question action bar ── */

.q-action-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--font);
}

.btn-reveal {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  padding: 0.5rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}
.btn-reveal:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.grade-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.grade-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.grade-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.grade-btn:hover { border-color: var(--border-light); color: var(--text); }
.grade-btn.active[data-grade="correct"]   { border-color: var(--green);  color: var(--green);  background: rgba(74,222,128,0.07); }
.grade-btn.active[data-grade="partial"]   { border-color: var(--yellow); color: var(--yellow); background: rgba(250,204,21,0.07); }
.grade-btn.active[data-grade="incorrect"] { border-color: var(--red);    color: var(--red);    background: rgba(248,113,113,0.07); }

/* ── End screen ── */

.end-screen.active { display: flex; flex-direction: column; align-items: center; }

.end-card {
  width: 100%;
  max-width: 560px;
  background: #1c1c1f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.5rem;
  text-align: center;
  font-family: var(--font);
}

.end-title {
  font-size: 2rem;
  font-weight: 300;
  color: var(--accent);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.end-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.end-grades {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.end-grade-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.end-grade-num {
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
}
.end-grade-item.correct .end-grade-num   { color: var(--green); }
.end-grade-item.partial .end-grade-num   { color: var(--yellow); }
.end-grade-item.incorrect .end-grade-num { color: var(--red); }
.end-grade-item.ungraded .end-grade-num  { color: var(--text-muted); }

.end-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.end-q-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.end-q-row:hover { border-color: var(--accent); color: var(--text); }
.end-q-num { color: var(--text-dim); }
.end-q-grade { text-transform: capitalize; }
.end-q-row.correct   { color: var(--green);  border-color: rgba(74,222,128,0.2);  }
.end-q-row.partial   { color: var(--yellow); border-color: rgba(250,204,21,0.2);  }
.end-q-row.incorrect { color: var(--red);    border-color: rgba(248,113,113,0.2); }

.end-actions { display: flex; gap: 0.8rem; justify-content: center; }

/* ── Tools column ── */

.ps-tools-col {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.ps-tools-col.tools-hidden {
  width: 0;
  min-width: 0;
  max-width: 0;
  border-left: none;
  overflow: hidden;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.calc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  font-family: var(--font);
}

.calc-panel-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.calc-expand-btn {
  background: rgba(200, 164, 110, 0.1);
  border: 1px solid rgba(200, 164, 110, 0.35);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.68rem;
  padding: 0.22rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.calc-expand-btn:hover {
  background: rgba(200, 164, 110, 0.18);
  border-color: var(--accent);
}

.calc-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #faf8f4;
}

.desmos-host {
  flex: 1;
  min-height: 220px;
  width: 100%;
}

.tools-toggle {
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: var(--text-dim);
  font-size: 0.75rem;
  transition: all 0.15s;
}
.tools-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Tool blocks ── */

.tool-block {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tool-block:last-child { border-bottom: none; flex: 1; }

.tool-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.tool-block-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tool-block-actions {
  display: flex;
  gap: 0.3rem;
}
.tool-block-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  transition: color 0.12s;
}
.tool-block-actions button:hover { color: var(--accent); }

.tool-block-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: height 0.2s;
}

.tool-block-body.tool-minimized {
  height: 0 !important;
  overflow: hidden;
}

/* ── Whiteboard toolbar ── */

.wb-toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.wb-tool {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  transition: all 0.12s;
}
.wb-tool:hover { color: var(--text); border-color: var(--border); }
.wb-tool.active { color: var(--accent); border-color: var(--accent); background: rgba(200,164,110,0.08); }

.wb-toolbar input[type="color"] {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  background: none;
}

/* ── Bottom nav ── */

.ps-footer {
  height: 48px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 1rem;
  flex-shrink: 0;
  background: var(--bg);
}

.ps-progress-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.ps-progress-dots::-webkit-scrollbar { display: none; }

.pdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  padding: 0;
}
.pdot:hover          { background: var(--text-muted); }
.pdot.pdot-current   { background: var(--accent); transform: scale(1.3); }
.pdot.pdot-answered  { background: var(--text-muted); }
.pdot.pdot-correct   { background: var(--green); }
.pdot.pdot-partial   { background: var(--yellow); }
.pdot.pdot-incorrect { background: var(--red); }

.ps-nav-center {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.ps-nav-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ps-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ps-nav-btn:disabled { opacity: 0.3; cursor: default; }

.ps-nav-pos {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.ps-footer-right { flex-shrink: 0; }

/* ── Tool expand modals ── */

.tool-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 1.5rem;
}

.tool-modal-inner {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tool-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.tool-modal-header button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  transition: all 0.12s;
}
.tool-modal-header button:hover { border-color: var(--accent); color: var(--accent); }

#wb-modal-canvas {
  cursor: crosshair;
  display: block;
  background: #17171a;
  touch-action: none;
}

/* ── KaTeX in question cards ── */

.katex-content .katex-display {
  margin: 0.8rem 0;
  overflow-x: auto;
}

.katex-content .katex {
  font-size: 1.05em;
}

/* ── Practice mode banner ── */

.practice-banner {
  background: rgba(200,164,110,0.07);
  border: 1px solid rgba(200,164,110,0.2);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 1rem;
  text-align: center;
  font-family: var(--font);
}

.source-badge {
  font-family: var(--font);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Responsive problem set ── */

@media (max-width: 900px) {
  .ps-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .ps-col-resizer { display: none; }
  .ps-tools-col {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: min(42vh, 380px);
    min-height: 200px;
  }
  .tools-toggle { display: none; }
}

@media (max-width: 600px) {
  .ps-topbar { padding: 0 0.8rem; }
  .ps-back-label { display: none; }
  .ps-question-col { padding: 1rem; }
  .question-card { padding: 1.4rem 1.2rem; }
}


/* ════════════════════════════════════════════
   CANVAS TOOLBAR (wbc-*)
   ════════════════════════════════════════════ */

.wbc-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 8px;
  background: #111113;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.wbc-tool {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 7px;
  border-radius: 4px;
  transition: all 0.12s;
  line-height: 1;
  min-width: 28px;
  text-align: center;
}
.wbc-tool:hover { color: var(--text); border-color: var(--border); }
.wbc-tool.active { color: var(--accent); border-color: var(--accent); background: rgba(200,164,110,0.1); }

.wbc-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0;
  flex-shrink: 0;
}
.wbc-swatch:hover { transform: scale(1.2); }
.wbc-swatch.active { border-color: white; transform: scale(1.15); }

.wbc-size {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.12s;
  min-width: 24px;
  text-align: center;
}
.wbc-size:hover  { color: var(--text); border-color: var(--border); }
.wbc-size.active { color: var(--accent); border-color: var(--accent); }

.wbc-action {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 7px;
  border-radius: 4px;
  transition: all 0.12s;
}
.wbc-action:hover { color: var(--text); border-color: var(--border); }

.wbc-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

/* "Solve" launch button */
.focus-launch-btn {
  background: rgba(200,164,110,0.08);
  border: 1px solid rgba(200,164,110,0.25);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.28rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}
.focus-launch-btn:hover {
  background: rgba(200,164,110,0.15);
  border-color: var(--accent);
}

/* ════════════════════════════════════════════
   FOCUS MODE (full-screen canvas)
   ════════════════════════════════════════════ */

.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #121214;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Compact question strip at top */
.focus-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #111113;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
  min-height: 52px;
}

.focus-strip-inner {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex: 1;
  overflow: hidden;
}

.focus-q-label {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.focus-q-text {
  font-family: 'Georgia', serif;
  font-size: 0.82rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.focus-strip-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.focus-reveal-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.focus-reveal-btn:hover { border-color: var(--green); color: var(--green); }

.focus-done-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.focus-done-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Full canvas area — scrollable sheet */
.focus-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #1a1916;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0.5rem;
}

#wb-focus-canvas {
  display: block;
  flex-shrink: 0;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
}

/* Floating toolbar at bottom of focus mode */
.focus-toolbar {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(17, 17, 19, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

/* On iPad, make focus toolbar slightly larger for finger-friendliness */
@media (min-width: 768px) and (pointer: coarse) {
  .focus-toolbar {
    padding: 8px 14px;
    gap: 5px;
    border-radius: 14px;
    bottom: 12px;
  }
  .wbc-tool, .wbc-action { padding: 6px 10px; font-size: 1rem; min-width: 36px; }
  .wbc-swatch { width: 22px; height: 22px; }
  .focus-strip { padding: 0.8rem 1.2rem; min-height: 60px; }
  .focus-q-text { font-size: 0.9rem; }
}

/* ════════════════════════════════════════════
   NOTES PAGE
   ════════════════════════════════════════════ */

.notes-page .page-header { margin-bottom: 1.5rem; }

.notes-filter {
  display: flex;
  gap: 0.4rem;
}

.notes-filter-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.notes-filter-btn:hover { color: var(--text); border-color: var(--border-light); }
.notes-filter-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(200,164,110,0.07); }

.notes-unit-section {
  margin-bottom: 2.5rem;
}

.notes-unit-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.8rem;
}

.note-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.18s;
  color: var(--text);
  animation: fadeIn 0.3s ease-out both;
}
.note-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Grade accent on left edge */
.note-card.grade-correct   { border-left: 3px solid var(--green); }
.note-card.grade-partial   { border-left: 3px solid var(--yellow); }
.note-card.grade-incorrect { border-left: 3px solid var(--red); }

/* Canvas thumbnail area */
.note-canvas-wrap {
  position: relative;
  width: 100%;
  height: 130px;
  background: #f0ede6;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.note-canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.85;
}

.note-canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Card body */
.note-card-body {
  padding: 0.75rem;
}

.note-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.note-q-num {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

.note-set-label {
  font-family: var(--font);
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.note-grade {
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: auto;
}
.note-grade-correct   { color: var(--green);  background: rgba(74,222,128,0.07); }
.note-grade-partial   { color: var(--yellow); background: rgba(250,204,21,0.07); }
.note-grade-incorrect { color: var(--red);    background: rgba(248,113,113,0.07); }

.note-q-text {
  font-family: 'Georgia', serif;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── iPad / large touch screen optimizations ── */

/* Prevent text selection while drawing */
.ps-tools-col, .focus-overlay { -webkit-user-select: none; user-select: none; }

/* Larger touch targets on iPad for navigation buttons */
@media (min-width: 768px) and (pointer: coarse) {
  .ps-nav-btn { width: 44px; height: 44px; font-size: 1.1rem; }
  .pdot { width: 12px; height: 12px; }
  .ps-footer { height: 60px; padding: 0 1.5rem; }
  .ps-topbar { height: 52px; }
  .focus-launch-btn { padding: 0.4rem 1rem; font-size: 0.8rem; }
  .btn-reveal { padding: 0.65rem 1.8rem; font-size: 0.85rem; }
  .grade-btn  { padding: 0.45rem 1rem; font-size: 0.82rem; }
  .question-card { padding: 2rem 2.2rem; }
  .qcard-stem { font-size: 1.05rem; }
}

/* ════════════════════════════════════════════
   ps-immersive fullscreen canvas layout
   ════════════════════════════════════════════ */

.ps-body.ps-immersive {
  --ps-calc-w: 320px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  background: #141416;
}

.ps-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  padding-top: max(0.4rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 0.72rem;
  background: #111113;
  z-index: 60;
}

.ps-hud-back {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  flex-shrink: 0;
}
.ps-hud-back:hover { color: var(--accent); }

.ps-hud-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ps-hud-set {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ps-hud-pos {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.ps-hud-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ps-hud-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 48px;
}
.ps-hud-time.timer-expired { color: var(--red); }

.ps-hud-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}
.ps-hud-btn:hover,
.ps-hud-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.ps-immersive-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.ps-main-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overscroll-behavior: none;
}

.ps-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fbf9f4;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.ps-canvas-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #fbf9f4;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#wb-main-canvas {
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: #fbf9f4;
}

.wb-toolbar-floating {
  display: flex;
  align-items: center;
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  max-width: min(680px, calc(100vw - 1rem));
  flex-wrap: wrap;
  justify-content: center;
  background: rgba(17, 17, 19, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.wb-toolbar-floating .wbc-tool {
  font-size: 0.65rem;
  text-transform: lowercase;
}

.ps-calc-drawer {
  position: relative;
  flex-shrink: 0;
  align-self: stretch;
  width: 0;
  max-width: 0;
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid transparent;
  background: #faf8f4;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  z-index: 45;
  transition: width 0.22s ease, max-width 0.22s ease, border-color 0.15s ease;
}

body.ps-calc-open .ps-calc-drawer {
  width: var(--ps-calc-w, 320px);
  max-width: min(var(--ps-calc-w, 320px), 92vw);
  border-left-color: var(--border);
}

.ps-calc-drawer.ps-calc-dragging {
  transition: none;
}

.ps-calc-resize-handle {
  flex-shrink: 0;
  width: 7px;
  margin-left: -1px;
  cursor: col-resize;
  touch-action: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.07), rgba(0, 0, 0, 0.02));
  border-left: 1px solid rgba(0, 0, 0, 0.06);
}

.ps-calc-resize-handle:hover {
  background: rgba(200, 164, 110, 0.22);
}

.ps-calc-drawer-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ps-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font);
  font-size: 0.7rem;
  flex-shrink: 0;
  background: #efede8;
}

.ps-calc-expand,
.ps-calc-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}
.ps-calc-close {
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.35rem;
}

.ps-calc-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ps-calc-drawer .desmos-host {
  flex: 1;
  min-height: 200px;
}

.ps-problem-strip {
  flex-shrink: 0;
  max-height: min(42vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  border-bottom: 1px solid var(--border);
  background: #111113;
  -webkit-overflow-scrolling: touch;
}

.ps-problem-strip .ps-q-slide {
  display: none;
}
.ps-problem-strip .ps-q-slide.active {
  display: block;
}

.ps-q-card-compact {
  padding: 0.55rem 1rem 0.35rem;
  border: none;
  background: transparent;
  max-width: 900px;
  margin: 0 auto;
}

.ps-problem-strip .qcard-header {
  margin-bottom: 0.35rem;
}

.ps-problem-strip .qcard-stem {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 0.45rem;
}

.ps-problem-strip .qcard-image-wrap {
  margin: 0.35rem 0;
}
.ps-problem-strip .qcard-image {
  max-height: 140px;
  width: auto;
}

.ps-problem-strip .qcard-answer-area {
  margin-top: 0.25rem;
}

.ps-problem-strip .ps-q-slide.active .qpart:not(.qpart-active) {
  display: none;
}

.ps-q-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 900px;
  margin: 0 auto;
}

.ps-q-actions .btn-reveal {
  margin: 0;
}

.qpart-active {
  outline: 1px solid rgba(200, 164, 110, 0.45);
  border-radius: 6px;
  padding: 0.35rem;
  margin: -0.35rem;
}

.ps-end-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.ps-end-screen.hidden {
  display: none !important;
}

.desmos-modal-host {
  flex: 1;
  min-height: 0;
}

.ps-immersive-footer {
  flex-shrink: 0;
}

.ps-immersive .ps-footer {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
