:root {
  --navy: #0f172a;
  --navy-dark: #1e1b4b;
  --ink: #0f172a;
  --bg: #f8f9fe;
  --card: #ffffff;
  --border: #e8ecf8;
  --border-subtle: #f1f4fb;
  --muted: #64748b;
  --purple-primary: #5b4fe9;
  --purple-hover: #4d41df;
  --purple-soft: #f4f2ff;
  --purple-border: #e0d7fe;
  --purple-light: #ece9fe;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --green-text: #047857;
  --green-border: #a7f3d0;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --amber-text: #b45309;
  --amber-border: #fde68a;
  --red: #ef4444;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(91, 79, 233, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple-primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* Shell Layout */
.shell {
  display: flex;
  min-height: 100vh;
}

/* Global Top Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 68px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
}
.brand-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}
.course-picker {
  display: flex;
  flex-direction: column;
  padding: 6px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.course-picker:hover {
  border-color: var(--purple-primary);
}
.course-picker-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 6px;
}
.course-picker-sub {
  font-size: 11px;
  color: var(--muted);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.role-pill-switcher {
  display: flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px;
  border: 1px solid #e2e8f0;
}
.role-pill {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.role-pill:hover {
  color: var(--navy);
}
.role-pill.active {
  background: var(--purple-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(91, 79, 233, 0.25);
}
.top-nav-item {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.top-nav-item:hover {
  color: var(--navy);
}
.top-nav-item.active {
  color: var(--purple-primary);
  border-bottom-color: var(--purple-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.notif-btn {
  position: relative;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-btn:hover { background: #f1f5f9; color: var(--navy); }
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid #ffffff;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.user-profile:hover { background: #f8f9fe; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--purple-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* View as: demo identity picker with a real server-side role boundary */
.viewer-pop { position: relative; }
.viewer-pop > summary { list-style: none; }
.viewer-pop > summary::-webkit-details-marker { display: none; }
.viewer-form {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.viewer-note {
  margin: 0 0 2px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}
.viewer-opt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  text-align: left;
  cursor: pointer;
}
.viewer-opt:hover { background: #f8f9fe; border-color: var(--border); }
.viewer-opt small {
  font-weight: 500;
  color: var(--muted);
  text-transform: capitalize;
}
.viewer-opt.on { background: var(--purple-soft); border-color: var(--purple-border); }

/* Sidebar */
.sidebar {
  width: 230px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 24px 14px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  z-index: 90;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.side-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  transition: all 0.15s ease;
}
.side-nav-item:hover {
  background: #f8fafc;
  color: var(--navy);
}
.side-nav-item.active {
  background: var(--purple-soft);
  color: var(--purple-primary);
}
.side-nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.help-side-card {
  background: var(--purple-soft);
  border: 1px solid var(--purple-border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.help-side-card:hover {
  border-color: var(--purple-primary);
  box-shadow: var(--shadow-sm);
}
.help-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.help-text {
  font-size: 12px;
  color: var(--navy);
  line-height: 1.4;
  font-weight: 500;
}
.help-text strong {
  display: block;
  font-weight: 700;
}

/* Sidebar attribution: which model this deployment answers with. Sits in the
   sidebar's own column, below the cards, so it never overlaps navigation. */
.provider-badge {
  margin-top: 12px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid #cbe89f;
  background: linear-gradient(135deg, #f5ffe2 0%, #e9fbf2 55%, #eaf2ff 100%);
  display: flex;
  gap: 9px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.provider-mark {
  width: 25px;
  height: 25px;
  flex-shrink: 0;
  border-radius: 7px;
  background: linear-gradient(140deg, #8fd100 0%, #5aa000 55%, #2f7d32 100%);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.provider-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.provider-kicker {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4d7c0f;
}
.provider-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #76b900;
  flex-shrink: 0;
}
.provider-chip {
  margin-left: auto;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #e2e8f0;
  color: #475569;
}
.provider-name {
  font-size: 12px;
  font-weight: 700;
  color: #10240f;
  line-height: 1.3;
  margin-top: 2px;
}
.provider-sub {
  font-size: 10px;
  color: #3f6b52;
  line-height: 1.35;
  margin-top: 1px;
}
/* Demo mode never calls the model, so the badge must not claim it does. */
.provider-badge.is-demo {
  background: #f8fafc;
  border-color: var(--border);
}
.provider-badge.is-demo .provider-mark {
  background: linear-gradient(140deg, #cbd5e1, #94a3b8);
}
.provider-badge.is-demo .provider-kicker {
  color: var(--muted);
}
.provider-badge.is-demo .provider-dot {
  background: #94a3b8;
}
.provider-badge.is-demo .provider-name {
  color: var(--navy);
}
.provider-badge.is-demo .provider-sub {
  color: var(--muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main-content {
  flex: 1;
  padding: 24px 32px 48px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

/* Page Header & Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--purple-primary); }
.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}
.page-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 20px;
}

/* Two-Column Practice Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 24px;
  align-items: start;
}

/* Question Hero Card */
.question-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.question-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.question-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.approval-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.question-prompt {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
}
.problem-math-hero {
  text-align: center;
  padding: 20px 0;
  font-size: 26px;
  color: var(--navy);
}

/* Stepper */
.stepper-container {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  position: relative;
}
.stepper-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.stepper-line {
  position: absolute;
  top: 15px;
  left: 30px;
  right: 30px;
  height: 3px;
  background: #e2e8f0;
  z-index: 1;
}
.stepper-line-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green) 0%, var(--purple-primary) 50%, #e2e8f0 100%);
  transition: width 0.3s ease;
}
.stepper-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}
.stepper-circle.completed {
  background: var(--green);
  color: #ffffff;
}
.stepper-circle.active {
  background: var(--purple-primary);
  color: #ffffff;
  box-shadow: 0 0 0 4px var(--purple-light);
}
.stepper-circle.upcoming {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  color: #64748b;
}
.stepper-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-top: 8px;
  max-width: 120px;
}

/* Workspace Tabs */
.tab-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.tab-pill {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #ffffff;
  color: #64748b;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.tab-pill.active {
  background: var(--purple-primary);
  color: #ffffff;
}

/* Your Working Card */
.working-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.working-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 18px;
}

/* Step Rows */
.step-item {
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: #ffffff;
  transition: border-color 0.15s ease;
}
.step-item.active-step {
  border-color: var(--purple-border);
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(91, 79, 233, 0.04);
}
.step-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.step-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.step-num-bubble {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-num-bubble.done {
  background: var(--green-bg);
  color: var(--green-text);
}
.step-math-display {
  font-size: 17px;
  color: var(--navy);
  font-family: KaTeX_Main, serif;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-pill.verified {
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
}
.status-pill.needs-correction {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

/* Nested Hint Box */
.nested-hint-box {
  margin-top: 12px;
  background: var(--purple-soft);
  border: 1px solid var(--purple-border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.hint-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--purple-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.hint-body {
  font-size: 13px;
  color: var(--navy);
  line-height: 1.5;
}
.hint-body strong {
  display: block;
  color: var(--purple-primary);
  margin-bottom: 2px;
}

/* Active Step Input Form */
.input-row-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.math-prefix {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
}
math-field {
  flex: 1;
  font-size: 1.25rem;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fbfdff;
  transition: all 0.15s ease;
}
math-field:focus-within {
  border-color: var(--purple-primary);
  outline: 3px solid var(--purple-light);
}

/* Quick Math Toolbar */
.math-quick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.symbol-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}
.symbol-btn:hover {
  background: #f8fafc;
  border-color: var(--purple-primary);
  color: var(--purple-primary);
}

.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--purple-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}
.link-btn:hover { text-decoration: underline; }
.btn-primary {
  background: var(--purple-primary);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(91, 79, 233, 0.25);
}
.btn-primary:hover {
  background: var(--purple-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Next Step Banner */
.next-banner {
  margin-top: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.next-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.lock-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.next-banner-text strong {
  display: block;
  font-size: 13px;
  color: var(--navy);
}
.next-banner-text span {
  font-size: 12px;
  color: var(--muted);
}
.btn-continue {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #e2e8f0;
  color: #94a3b8;
  border: none;
  cursor: not-allowed;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-continue.unlocked {
  background: var(--purple-primary);
  color: #ffffff;
  cursor: pointer;
}

/* Right Support Cards */
.support-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.support-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.support-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}
.support-card-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple-primary);
  border: 1px solid var(--purple-border);
}

/* AI Tutor Bubble */
.tutor-chat-box {
  margin-top: 14px;
}
.tutor-msg-bubble {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--navy);
}
.tutor-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.tutor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.btn-tutor-action {
  flex: 1;
  min-width: 95px;
  background: #ffffff;
  border: 1px solid var(--purple-border);
  color: var(--purple-primary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.btn-tutor-action:hover {
  background: var(--purple-soft);
  border-color: var(--purple-primary);
}

/* Practice tutor chat — the AI Math Tutor panel holds a real conversation */
.tutor-msg-bubble.student {
  background: var(--purple-soft);
  border-color: var(--purple-border);
  justify-content: flex-end;
  margin-top: 8px;
}
.tutor-msg-bubble + .tutor-msg-bubble { margin-top: 8px; }
.tutor-chat-card { border-left: 3px solid var(--purple-primary); }
.tutor-chat-hint { border-left: 3px solid #f59e0b; background: #fffbeb; }
.tutor-chat-ok { border-left: 3px solid #16a34a; background: #f0fdf4; }
.tutor-mode-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; flex-wrap: wrap;
}
.tutor-mode-row .pill-badge { margin-right: auto; }
.tutor-input-row { display: flex; gap: 8px; margin-top: 12px; }
.tutor-input-row input {
  flex: 1; min-width: 0;
  border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 11px; font-size: 13px; font-family: inherit;
}
.tutor-input-row button { white-space: nowrap; }
.tutor-typing { display: inline-flex; gap: 4px; align-items: center; }
.tutor-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--purple-border); animation: practiceTutorBlink 1.2s infinite;
}
.tutor-typing i:nth-child(2) { animation-delay: .2s; }
.tutor-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes practiceTutorBlink { 0%,80%,100% { opacity: .3 } 40% { opacity: 1 } }

/* Keyboard Panel Tray */
.math-keyboard-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 12px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}
.palette-key {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.palette-key:hover {
  background: var(--purple-soft);
  border-color: var(--purple-primary);
  color: var(--purple-primary);
}

/* Modal for Notes & Examples */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #ffffff;
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  padding: 24px;
}

/* Common UI Elements */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--green-bg); color: var(--green-text); }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--purple-soft); color: var(--purple-primary); }
.btn { background: var(--purple-primary); color: #ffffff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; display: inline-block; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.btn:hover { background: var(--purple-hover); }
.btn.ghost { background: #ffffff; color: var(--ink); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--purple-border); color: var(--purple-primary); background: var(--purple-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--purple-primary); }
.btn.ghost:disabled:hover { background: #ffffff; color: var(--ink); border-color: var(--border); }

/* Floating Math Tutor widget (student pages only) */
@keyframes float-tutor-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.float-tutor-btn {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 300;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5B3DF5;
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 13px 20px 13px 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(91, 61, 245, 0.45);
  animation: float-tutor-bob 3s ease-in-out infinite;
  transition: background 0.15s ease, transform 0.15s ease;
}
.float-tutor-btn:hover { background: #4c32d8; transform: translateY(-2px); }
.float-tutor-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #5B3DF5, 0 8px 24px rgba(91, 61, 245, 0.45);
}
.float-tutor-btn .float-tutor-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.float-tutor-unread {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  display: none;
}
.float-tutor-unread.show { display: block; }
.float-tutor-panel {
  position: fixed;
  right: 20px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 300;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.float-tutor-panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.float-tutor-drag { display: none; }
.float-tutor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px 14px;
  background: #5B3DF5;
  color: #ffffff;
  flex-shrink: 0;
}
.float-tutor-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.float-tutor-titles { flex: 1; min-width: 0; }
.float-tutor-titles strong { display: block; font-size: 14px; line-height: 1.3; }
.float-tutor-online {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
}
.float-tutor-online .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; display: inline-block;
}
.float-tutor-stepstrip { display: block; font-size: 11.5px; opacity: 0.95; margin-top: 2px; }
.float-tutor-stepstrip .sdot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px; vertical-align: 1px;
}
.float-tutor-stepstrip .sdot.done { background: #ffffff; }
.float-tutor-stepstrip .sdot.current { background: transparent; border: 2px solid #ffffff; width: 6px; height: 6px; }
.float-tutor-stepstrip .sdot.upcoming { background: rgba(255, 255, 255, 0.35); }
.float-tutor-iconbtn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 28px; height: 28px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.float-tutor-iconbtn:hover { background: rgba(255, 255, 255, 0.3); }
.float-tutor-iconbtn:focus-visible { outline: 2px solid #ffffff; outline-offset: 1px; }
.float-tutor-graded {
  background: var(--amber-bg, #fffbeb);
  color: var(--amber-text);
  border-bottom: 1px solid var(--amber-border, #fde68a);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  flex-shrink: 0;
}
.float-tutor-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.float-tutor-msg {
  display: flex;
  gap: 8px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--navy, #0f172a);
  max-width: 100%;
}
.float-tutor-msg .who {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #EDE9FF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}
.float-tutor-msg .bubble {
  background: #EDE9FF;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 10px 13px;
  max-width: 88%;
  overflow-wrap: anywhere;
}
.float-tutor-msg.student { justify-content: flex-end; }
.float-tutor-msg.student .bubble {
  background: #5B3DF5;
  color: #ffffff;
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}
.float-tutor-stepcard {
  border-left: 4px solid #5B3DF5;
  background: #f8f7ff;
  border-radius: 0 12px 12px 0;
  padding: 10px 13px;
  max-width: 88%;
}
.float-tutor-stepcard strong { display: block; font-size: 13px; color: #5B3DF5; margin-bottom: 2px; }
.float-tutor-hintcard {
  background: var(--amber-bg, #fffbeb);
  border: 1px solid var(--amber-border, #fde68a);
  border-radius: 12px;
  padding: 10px 13px;
  max-width: 88%;
  /* The hint card keeps a pale background in every theme, so pin a dark body
     color; otherwise dark mode's light message text renders invisibly. */
  color: #78350f;
}
.float-tutor-hintcard strong { display: block; font-size: 13px; color: var(--amber-text); margin-bottom: 2px; }
.float-tutor-success { color: var(--green-text, #047857); font-weight: 700; }
/* Steady, low-contrast card for "you're not behind" moments: the idle nudge,
   and a student who says they are lost or fed up. */
.float-tutor-support {
  background: var(--purple-soft, #f5f3ff);
  border: 1px solid var(--purple-border, #ddd6fe);
  border-radius: 12px;
  padding: 10px 13px;
  max-width: 88%;
  /* Same reason as the hint card: this background stays pale in dark mode,
     so the message text must be pinned dark or it goes invisible. */
  color: #4c1d95;
}
.float-tutor-recap {
  border: 1px solid var(--green-border, #a7f3d0);
  border-radius: 12px;
  overflow: hidden;
  max-width: 94%;
}
.float-tutor-recap-head {
  background: var(--green, #10b981);
  color: #ffffff;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 13px;
}
.float-tutor-recap-body { padding: 10px 13px; font-size: 13.5px; background: #ffffff; }
.float-tutor-recap-body ol { margin: 6px 0 6px 18px; padding: 0; }
.float-tutor-recap-body li { margin-bottom: 4px; }
.float-tutor-recap-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.float-tutor-recap-actions button {
  background: #ffffff;
  border: 1px solid #5B3DF5;
  color: #5B3DF5;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.float-tutor-recap-actions button:hover { background: #EDE9FF; }
.float-tutor-typing .bubble { display: inline-flex; gap: 5px; align-items: center; padding: 12px 16px; }
.float-tutor-typing .bubble span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5B3DF5; display: inline-block;
  animation: float-tutor-blink 1s infinite;
}
.float-tutor-typing .bubble span:nth-child(2) { animation-delay: 0.2s; }
.float-tutor-typing .bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes float-tutor-blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.float-tutor-empty {
  text-align: center;
  color: var(--muted, #64748b);
  font-size: 13.5px;
  padding: 24px 12px;
}
.float-tutor-empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.float-tutor-quick {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.float-tutor-chip {
  background: #ffffff;
  border: 1px solid #5B3DF5;
  color: #5B3DF5;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.float-tutor-chip:hover { background: #EDE9FF; }
.float-tutor-chip:focus-visible { outline: 2px solid #5B3DF5; outline-offset: 1px; }
.float-tutor-input {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #e8ecf8);
  flex-shrink: 0;
  max-height: 25%;
  overflow: hidden;
}
.float-tutor-fieldrow {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.float-tutor-input textarea {
  flex: 1;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.4;
  min-height: 38px;
  max-height: calc(1.4em * 4 + 18px);
  overflow-y: auto;
  scrollbar-width: none;
}
.float-tutor-input textarea::-webkit-scrollbar { display: none; }
.float-tutor-input textarea:focus {
  border-color: #5B3DF5;
  outline: 2px solid rgba(91, 61, 245, 0.25);
}
.float-tutor-count { font-size: 10.5px; color: var(--muted, #64748b); align-self: center; min-width: 30px; text-align: right; }
.float-tutor-fx {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  font-style: italic;
  color: #5B3DF5;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.float-tutor-fx:hover { border-color: #5B3DF5; background: #EDE9FF; }
.float-tutor-toolbar {
  border-bottom: 1px solid var(--border, #e8ecf8);
  margin-bottom: 6px;
  padding-bottom: 6px;
  position: relative;
  max-height: 40px;
}
.float-tutor-toolbar::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 6px;
  width: 22px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--card, #ffffff));
}
.float-tutor-toolrow {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.float-tutor-toolrow::-webkit-scrollbar { display: none; }
.float-tutor-toolbar button {
  flex: 0 0 auto;
  min-width: 36px;
  height: 32px;
  padding: 0 7px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.float-tutor-toolbar button:hover::after,
.float-tutor-toolbar button:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.float-tutor-sep {
  flex: 0 0 auto;
  width: 1px;
  height: 22px;
  background: var(--border, #e8ecf8);
  margin: 0 2px;
}
.float-tutor-preview {
  max-height: 32px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--muted, #64748b);
  border-top: 1px solid var(--border, #e8ecf8);
  margin-top: 6px;
  padding-top: 4px;
}
.float-tutor-confirm {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.float-tutor-confirm button {
  flex: 1;
  border: 1px solid #5B3DF5;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.float-tutor-confirm button[data-confirm="yes"] {
  background: #5B3DF5;
  color: #ffffff;
}
.float-tutor-confirm button[data-confirm="no"] {
  background: #ffffff;
  color: #5B3DF5;
}
.float-tutor-mathkeys button:hover { border-color: #5B3DF5; color: #5B3DF5; }
.float-tutor-send {
  background: #5B3DF5;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.float-tutor-send:hover { background: #4c32d8; }
.float-tutor-send:disabled { opacity: 0.55; cursor: not-allowed; }
.float-tutor-send:focus-visible, .float-tutor-close:focus-visible { outline: 3px solid #ffffff; outline-offset: 1px; }
.float-tutor-retry {
  margin: 0 14px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .float-tutor-btn {
    width: 56px; height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .float-tutor-btn .float-tutor-label { display: none; }
  .float-tutor-panel {
    left: 0; right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
  }
  .float-tutor-drag {
    display: block;
    width: 44px; height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    margin: 8px auto 0;
  }
  .float-tutor-head { padding-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .float-tutor-btn { animation: none; }
  .float-tutor-panel { transition: none; }
  .float-tutor-typing .bubble span { animation: none; opacity: 1; }
}
@media (prefers-color-scheme: dark) {
  .float-tutor-panel { background: #1e1b2e; border-color: #3b3654; }
  .float-tutor-msg { color: #ede9fe; }
  .float-tutor-msg .bubble { background: #2e2950; }
  .float-tutor-msg.student .bubble { background: #5B3DF5; color: #ffffff; }
  .float-tutor-stepcard { background: #26214a; }
  .float-tutor-input textarea { background: #26214a; border-color: #3b3654; color: #ede9fe; }
  .float-tutor-toolbar { border-color: #3b3654; }
  .float-tutor-toolbar button { background: #1e1b2e; border-color: #3b3654; color: #ede9fe; }
  .float-tutor-preview { border-color: #3b3654; }
  .float-tutor-recap-body { background: #26214a; }
  .float-tutor-chip { background: transparent; }
  .float-tutor-fx { background: #26214a; border-color: #3b3654; }
}

/* Utility classes used across templates */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 7px; margin: 6px 0; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--purple-primary); cursor: pointer; }

/* Responsive adjustments */
@media (max-width: 1024px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .header-center { display: none; }
}
@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .main-content { padding: 16px; }
  .top-header { padding: 0 16px; }
  /* Identity picker: avatar stays, the long name and the dropdown width give
     room so the control cannot push the header off-screen. */
  .viewer-pop .user-name { display: none; }
  .viewer-form { max-width: calc(100vw - 24px); }
}

/* Practice workspace — single guided card */
.pkg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}
.pkg-label { font-size: 14px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.pkg-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
}
.pkg-select {
  flex: 1;
  min-width: 240px;
  max-width: none;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--navy);
}
.pkg-select:focus {
  outline: 3px solid var(--purple-light);
  border-color: var(--purple-primary);
}
.practice-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
}
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #eef1f8;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple-primary), #7c6ff5);
  transition: width 0.3s ease;
}
.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 34px;
  text-align: right;
}
.practice-card .question-number { color: var(--navy); }
.question-body {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 18px 20px 16px;
  margin-bottom: 18px;
}
.question-body .question-prompt { margin-bottom: 6px; }
.question-body .problem-math-hero { padding: 14px 0 18px; }
/* The question in words: what the student is asked to do with the maths. */
.question-task {
  margin: -6px 0 16px;
  padding: 9px 12px;
  border-left: 3px solid var(--purple-border);
  border-radius: 0 8px 8px 0;
  background: var(--purple-soft);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--navy);
  text-align: center;
}
.work-hint {
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  margin: 0;
}
.answer-box { position: relative; }
.answer-plain {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px 16px 40px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--navy);
  background: #fbfdff;
  resize: vertical;
}
.answer-plain:focus {
  outline: 3px solid var(--purple-light);
  border-color: var(--purple-primary);
}
.answer-box math-field { display: block; width: 100%; min-height: 96px; padding: 14px 16px 40px; border-radius: 12px; }
.answer-box [hidden] { display: none !important; }
.input-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.input-toggle:hover {
  color: var(--purple-primary);
  border-color: var(--purple-border);
  background: var(--purple-soft);
}
.math-quick-bar { flex-wrap: wrap; }
.practice-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.practice-actions .btn-primary { min-width: 172px; }
.btn-outline {
  background: #ffffff;
  border: 1px solid var(--purple-border);
  color: var(--purple-primary);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-outline:hover { background: var(--purple-soft); border-color: var(--purple-primary); }
.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 4px;
}
.text-btn:hover { color: var(--purple-primary); }
.step-feedback {
  margin-top: 18px;
  background: var(--purple-soft);
  border: 1px solid var(--purple-border);
  border-radius: 12px;
  padding: 14px 16px;
}
.step-feedback.ok { background: var(--green-bg); border-color: var(--green-border); }
.step-feedback-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-primary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.step-feedback.ok .step-feedback-head { color: var(--green-text); }
.step-feedback-body { font-size: 14px; line-height: 1.6; color: #334155; }
.step-feedback-body ol { margin: 8px 0 0 18px; padding: 0; }
.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}
.btn-ghost {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-ghost:hover {
  border-color: var(--purple-border);
  color: var(--purple-primary);
  background: var(--purple-soft);
}
.btn-outline:disabled, .btn-ghost:disabled, .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.ungraded-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.ungraded-note svg { color: var(--purple-primary); flex-shrink: 0; }
.ungraded-note strong { color: var(--navy); font-weight: 700; }
.practice-tutor-card { margin-top: 20px; }
@media (max-width: 640px) {
  .practice-actions .btn-primary { min-width: 0; flex: 1; }
  .practice-card { padding: 18px; }
}

/* Lesson section editor (instructor canvas + student lesson body) */
.sec-preview { font-size: 15.5px; line-height: 1.7; color: var(--navy); }
.sec-preview p { margin: 0 0 10px; }
.sec-preview ol { margin: 0 0 10px; padding-left: 22px; }
.sec-preview li { margin-bottom: 6px; }
.sec-preview h4 { margin: 14px 0 6px; font-size: 15px; }
.sec-edit { margin-top: 12px; }
.sec-edit summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--purple-primary);
}
.sec-edit textarea,
.sec-body {
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fbfdff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
}
.sec-body:focus {
  border-color: var(--purple-primary);
  outline: 3px solid var(--purple-light);
}

/* Practice workspace: work on the left, tutor guidance on the right */
.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}
.tutor-rail { position: sticky; top: 16px; margin-bottom: 0; }
.tutor-rail .tutor-chat-box {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
.q-dots { display: flex; gap: 6px; margin-left: 12px; }
.q-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--muted);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.q-dot:hover { border-color: var(--purple-primary); color: var(--purple-primary); }
.q-dot.current {
  background: var(--purple-primary);
  border-color: var(--purple-primary);
  color: #fff;
}
.q-dot.solved { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }
.q-dot.skipped { border-style: dashed; }
.work-head { font-size: 14px; margin: 4px 0 8px; }
.work-list { list-style: none; margin: 0 0 14px; padding: 0; }
.work-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f8;
  font-size: 14px;
}
.work-row:last-child { border-bottom: none; }
.work-row.empty, .work-row.solved, .work-row.skipped { color: var(--navy); }
.work-n {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green-text);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.work-row.incorrect .work-n, .work-row.empty .work-n {
  background: var(--purple-soft); color: var(--purple-primary);
}
.work-row p { margin: 3px 0 0; font-size: 13px; }
.work-good { color: var(--green-text); }
.work-bad { color: var(--amber-text); }
.answer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.answer-foot .muted { font-size: 12px; }
.step-feedback.bad { background: var(--amber-bg); border-color: var(--amber-border); }
.step-feedback.bad .step-feedback-head { color: var(--amber-text); }
.rail-block { margin-top: 14px; }
.rail-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.rail-note { font-size: 12px; margin: 8px 0 0; }
.rail-steps { list-style: none; margin: 0; padding: 0; }
.rail-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--muted);
}
.rail-step.done { color: var(--green-text); }
.rail-step.now { color: var(--navy); font-weight: 700; }
.rail-step-n {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #eef1f8;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rail-step.done .rail-step-n { background: var(--green-bg); color: var(--green-text); }
.rail-step.now .rail-step-n { background: var(--purple-primary); color: #fff; }
.rail-step-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint-meter { display: flex; gap: 6px; }
.hint-seg {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #eef1f8;
}
.hint-seg.used { background: #fbbf24; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  border: 1px solid var(--purple-border);
  border-radius: 999px;
  background: #fff;
  color: var(--purple-primary);
  font-size: 12.5px; font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip-btn:hover { background: var(--purple-soft); }
@media (max-width: 900px) {
  .practice-grid { grid-template-columns: minmax(0, 1fr); }
  .tutor-rail { position: static; }
}
