:root {
  --bg: #0b1220;
  --panel: #0f1b33;
  --card: #0f1a2e;
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --border: rgba(255, 255, 255, 0.10);
  --brand: #7c5cff;
  --brand-2: #35c6ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  /* Text opacity levels */
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-dim: rgba(255, 255, 255, 0.45);
  --text-faint: rgba(255, 255, 255, 0.40);

  /* Semantic status colors */
  --success: rgba(34, 197, 94, 0.9);
  --warning: rgba(251, 191, 36, 0.85);
  --danger: rgba(239, 68, 68, 0.8);

  /* Overlay backgrounds */
  --overlay-subtle: rgba(255, 255, 255, 0.04);
  --overlay-light: rgba(255, 255, 255, 0.06);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 140ms;
  --t-med: 220ms;

  /* Auth + CTA (brand navy, subtle hover) */
  --brand-navy: #1e2a44;
  --brand-navy-hover: #243152;
  --brand-navy-border: rgba(255, 255, 255, 0.14);
  --brand-text: #e5e7eb;
  --brand-muted: rgba(229, 231, 235, 0.82);
}

/* ═══════════════════════════════
   Utility classes — semantic text
   ═══════════════════════════════ */
.u-text         { color: var(--text); }
.u-muted        { color: var(--muted); }
.u-secondary    { color: var(--text-secondary); }
.u-dim          { color: var(--text-dim); }
.u-faint        { color: var(--text-faint); }
.u-success      { color: var(--success); }
.u-warning      { color: var(--warning); }
.u-danger       { color: var(--danger); }
.u-bg-subtle    { background: var(--overlay-subtle); }
.u-bg-light     { background: var(--overlay-light); }

/* Screen-reader-only (alias for Bootstrap's .visually-hidden) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(100%);
  overflow: hidden;
  white-space: nowrap;
}

/* Accessible table captions — visually dim, not hidden */
table caption {
  caption-side: top;
  color: var(--text-dim);
  font-size: 0.82rem;
  padding-bottom: 0.4rem;
}

/* Nav dropdown menu items */
.nav-dropdown .dropdown-item {
  color: rgba(255, 255, 255, 0.90);
  padding: 6px 10px;
}
.nav-dropdown .dropdown-item.disabled {
  color: var(--text-faint);
  pointer-events: none;
}
.nav-dropdown .dropdown-divider {
  border-color: var(--border);
}

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

html,
body {
  height: 100%;
}

.app-body {
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%,
      rgba(124, 92, 255, 0.35),
      transparent 60%),
    radial-gradient(900px 500px at 80% 0%,
      rgba(53, 198, 255, 0.25),
      transparent 55%),
    radial-gradient(1200px 800px at 50% 110%,
      rgba(124, 92, 255, 0.18),
      transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-body > main {
  flex: 1;
}

.app-body > footer {
  margin-top: auto;
}

/* =========================
   Nav
   ========================= */

.app-nav {
  background: rgba(15, 27, 51, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.brand-wordmark {
  font-family: 'EB Garamond', 'Georgia', 'Times New Roman', serif;
  font-weight: 600;
  font-size: 1.15em;
  letter-spacing: 0.01em;
}

/* =========================
   Header
   ========================= */

.app-header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    rgba(15, 27, 51, 0.55),
    rgba(15, 27, 51, 0.0)
  );
}

.app-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-subtitle {
  color: var(--muted);
  font-size: 0.98rem;
}

/* =========================
   Cards
   ========================= */

.card {
  background: rgba(15, 26, 46, 0.72);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.92);
  transition:
    transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-med) var(--ease),
    background var(--t-med) var(--ease);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.16);
}

.card:active {
  transform: translateY(-1px);
}

/* =========================
   Surfaces
   ========================= */

.app-surface {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
}

/* =========================
   Forms
   ========================= */

.form-control,
.form-select,
.input-group-text {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 0.25rem rgba(124, 92, 255, 0.15);
}

.form-control::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

/* Prevent browser autofill from turning inputs white */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(15, 27, 51, 0.95) inset;
  -webkit-text-fill-color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
  transition: background-color 5000s ease-in-out 0s;
}

.form-select {
  cursor: pointer;
}

/* =========================
   Buttons (global)
   ========================= */

.btn {
  transition:
    transform var(--t-fast) var(--ease),
    filter var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0px) scale(0.99);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none;
  color: #081022;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(124, 92, 255, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.03);
  box-shadow: 0 14px 28px rgba(124, 92, 255, 0.26);
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.88);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.30);
  color: rgba(255, 255, 255, 0.95);
}

/* Make reset buttons feel consistent on dark backgrounds */
.app-body .btn-outline-secondary {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  color: rgba(255, 255, 255, 0.88) !important;
  border-radius: 12px !important;
}

.app-body .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(255, 255, 255, 0.30) !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

/* Custom hint button, keep it button-like if used anywhere */
.app-body .hint-btn {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.45rem 0.75rem !important;
  line-height: 1.2 !important;
  cursor: pointer;
  border-radius: 12px !important;
}

/* Hint + Reset (Adaptive) */
.app-body .btn-hint {
  background: linear-gradient(
    135deg,
    rgba(124, 92, 255, 0.32),
    rgba(53, 198, 255, 0.22)
  ) !important;
  border: 1px solid rgba(124, 92, 255, 0.70) !important;
  color: rgba(255, 255, 255, 0.95) !important;
  font-weight: 650 !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 22px rgba(124, 92, 255, 0.18) !important;
}

.app-body .btn-hint:hover {
  background: linear-gradient(
    135deg,
    rgba(124, 92, 255, 0.45),
    rgba(53, 198, 255, 0.30)
  ) !important;
  border-color: rgba(124, 92, 255, 0.90) !important;
  color: #ffffff !important;
  box-shadow: 0 14px 28px rgba(124, 92, 255, 0.24) !important;
}

.app-body .btn-hint:active {
  transform: translateY(0px) scale(0.99);
}

/* =========================
   Auth + CTA button styles
   Muted brand navy filled buttons with subtle hover
   ========================= */

.btn-brand {
  background: var(--brand-navy) !important;
  border: 1px solid var(--brand-navy-border) !important;
  color: var(--brand-text) !important;
  border-radius: 12px;
  padding: 0.70rem 1.05rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

.btn-brand:hover,
.btn-brand:focus {
  background: var(--brand-navy-hover) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.btn-brand:active {
  transform: translateY(0px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

/* Brand outline button (navy family, not bright blue) */
.btn-brand-outline {
  background: transparent !important;
  border: 1px solid var(--brand-navy-border) !important;
  color: var(--brand-text) !important;
  border-radius: 12px;
  padding: 0.70rem 1.05rem;
  font-weight: 600;
  opacity: 0.92;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.btn-brand-outline:hover,
.btn-brand-outline:focus {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
  opacity: 1;
  transform: translateY(-1px);
}

.btn-quiet-link {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: rgba(229, 231, 235, 0.60) !important;
  padding: 0.70rem 0.85rem;
  border-radius: 12px;
  text-decoration: none !important;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease;
}

.btn-quiet-link:hover,
.btn-quiet-link:focus {
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(229, 231, 235, 0.90) !important;
}

/* Google button: closer to official look */
.btn-google {
  background: #ffffff !important;
  border: 1px solid #dadce0 !important;
  color: #3c4043 !important;
  border-radius: 10px;
  padding: 0.70rem 1rem;
  font-weight: 600;
  box-shadow: none !important;

  /* override global .btn hover lift */
  transform: none !important;
  filter: none !important;
}

.btn-google:hover,
.btn-google:focus {
  background: #f8f9fa !important;
  border-color: #dadce0 !important;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.30), 0 1px 3px rgba(60, 64, 67, 0.15) !important;

  transform: none !important;
  filter: none !important;
}

/* icon alignment */
.btn-google img {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  display: inline-block;
  vertical-align: middle;
}

.btn-google span {
  vertical-align: middle;
}

/* =========================
   Links
   ========================= */

a {
  color: rgba(53, 198, 255, 0.9);
  transition:
    color var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
}

a:hover {
  color: rgba(53, 198, 255, 1);
  opacity: 0.95;
}

/* =========================
   Nuke "code chip" styling everywhere
   ========================= */

:not(pre) > code,
code {
  font-family: inherit !important;
  font-size: inherit !important;
  color: rgba(255, 255, 255, 0.78) !important;
  background: transparent !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
}

/* =========================
   Answer choices
   ========================= */

.answer-choice {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.10) !important;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.answer-choice:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.16) !important;
}

.answer-choice.is-selected {
  background: rgba(124, 92, 255, 0.12);
  border-color: rgba(124, 92, 255, 0.38) !important;
}

.answer-choice input.form-check-input {
  cursor: pointer;
}

/* =========================
   Sticky action bar
   ========================= */

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(15, 26, 46, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding: 12px;
  margin-top: 20px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

@media (min-width: 768px) {
  .sticky-actions {
    border-radius: 12px;
  }
}

/* =========================
   Account dropdown theme
   ========================= */

.app-dropdown {
  background: rgba(15, 27, 51, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  border-radius: 14px;
  overflow: hidden;
  min-width: 240px;
}

.app-dropdown .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.10);
}

.app-dropdown .dropdown-item {
  color: rgba(255, 255, 255, 0.90);
  padding: 10px 14px;
}

.app-dropdown .dropdown-item:hover,
.app-dropdown .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
}

/* =========================
   Offcanvas (Desmos drawer)
   ========================= */

.app-offcanvas {
  background: rgba(15, 27, 51, 0.96);
  color: rgba(255, 255, 255, 0.92);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  width: min(560px, 92vw);
}

.app-offcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

/* =========================
   Desmos wrap
   ========================= */

.app-desmos-wrap {
  height: calc(100vh - 240px);
  min-height: 420px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.app-desmos {
  width: 100%;
  height: 100%;
}

.app-hidden {
  display: none !important;
}

/* =========================
   Desmos toolbar
   ========================= */

.app-desmos-toolbar {
  padding: 10px 10px 0 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

/* =========================
   Mode badge
   ========================= */

.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-badge-warn {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.88);
}

.app-badge-ok {
  background: rgba(46, 204, 113, 0.18);
  border-color: rgba(46, 204, 113, 0.30);
  color: rgba(255, 255, 255, 0.92);
}

/* =========================
   Preset button disabled feel
   ========================= */

.app-preset-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================
   Reduce motion
   ========================= */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* =========================
   Make muted text readable on dark backgrounds
   ========================= */

.app-body .text-muted {
  color: var(--muted) !important;
}

/* =========================
   Stoplight green for Correct alerts
   ========================= */

.alert-success-stoplight {
  background: rgba(0, 180, 60, 0.22) !important;
  border-color: rgba(0, 180, 60, 0.40) !important;
  color: #b6ffd0 !important;
}

.alert-danger-stoplight {
  background: rgba(53, 198, 255, 0.14) !important;
  border-color: rgba(53, 198, 255, 0.40) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

/* =========================
   Result chips (Correct / Not quite)
   ========================= */

.result-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1;
}

.result-chip-success {
  background: rgba(0, 180, 60, 0.18);
  border: 1px solid rgba(0, 180, 60, 0.45);
  color: #8fffa6;
}

.result-chip-danger {
  background: rgba(53, 198, 255, 0.14);
  border: 1px solid rgba(53, 198, 255, 0.40);
  color: rgba(255, 255, 255, 0.92);
}

/* Answer choice feedback highlights */
.choice-correct {
  background: rgba(0, 180, 60, 0.12) !important;
  border-color: rgba(0, 180, 60, 0.45) !important;
}

.choice-wrong {
  background: rgba(53, 198, 255, 0.10) !important;
  border-color: rgba(53, 198, 255, 0.35) !important;
}

/* =========================
   Inline spinner
   ========================= */

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0.7;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================
   Visualization panel
   ========================= */

.viz-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 26, 46, 0.72);
}

.viz-panel .viz-calc {
  border-radius: 10px;
  overflow: hidden;
}

/* =========================
   Insight tabs (Explain / Visualize)
   ========================= */

.insight-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  padding-bottom: 8px;
}

.tab-btn {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.80);
}

.tab-btn.active {
  background: rgba(124, 92, 255, 0.15);
  color: rgba(255, 255, 255, 0.95);
}

.viz-nudge {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* =========================
   Collapsible sections
   ========================= */

details.section-collapse > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.65rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.60);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.75rem;
  transition: color var(--t-fast) var(--ease);
}

details.section-collapse > summary:hover {
  color: rgba(255, 255, 255, 0.85);
}

details.section-collapse > summary::-webkit-details-marker {
  display: none;
}

details.section-collapse > summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.65rem;
  transition: transform 0.15s var(--ease);
  vertical-align: middle;
}

details.section-collapse[open] > summary::before {
  transform: rotate(90deg);
}

/* "See all" and overflow links — clear hover affordance */
.see-all-link {
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.20);
  padding-bottom: 1px;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.see-all-link:hover {
  border-bottom-style: solid;
  border-bottom-color: rgba(53, 198, 255, 0.60);
}

/* =========================
   Section groups
   ========================= */

.section-group {
  background: rgba(15, 26, 46, 0.50);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
}

.section-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.38);
  padding: 0.25rem 0;
  margin-bottom: 0;
}

/* Tighter collapsibles inside groups */
.section-group details.section-collapse {
  margin-bottom: 0;
}

.section-group details.section-collapse > summary {
  padding: 0.55rem 0;
}

.section-group details.section-collapse:last-of-type:not([open]) > summary {
  border-bottom: none;
}

/* Flatten top-level cards inside grouped collapsibles */
.section-group details.section-collapse > .card,
.section-group details.section-collapse > .card:hover {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  transform: none;
}

/* =========================
   Teacher page mini-nav
   ========================= */

.teacher-tier-nav {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  padding: 0.3rem;
  background: rgba(15, 26, 46, 0.40);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
}

.teacher-tier-nav a {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.50);
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.teacher-tier-nav a:hover {
  background: rgba(99, 102, 241, 0.12);
  color: rgba(255, 255, 255, 0.80);
}

/* Tier labels */
.tier-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(99, 102, 241, 0.55);
  margin-bottom: 0.15rem;
}

.tier-desc {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 1rem;
}

/* =========================
   Student insight drawer
   ========================= */

.insight-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.insight-drawer-overlay.open {
  opacity: 1;
}

.insight-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 90vw);
  height: 100vh;
  background: var(--surface, #0d1117);
  border-left: 1px solid var(--border);
  z-index: 1050;
  padding: 1.25rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s var(--ease);
}

.insight-drawer.open {
  transform: translateX(0);
}

/* Quick view button */
.btn-quick-view {
  background: none;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 999px;
  color: rgba(99, 102, 241, 0.6);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  white-space: nowrap;
}

.btn-quick-view:hover {
  border-color: rgba(99, 102, 241, 0.5);
  color: rgba(99, 102, 241, 0.9);
}

/* =========================
   Teacher data tables
   ========================= */

.teacher-table {
  --bs-table-bg: transparent;
  --bs-table-color: rgba(255, 255, 255, 0.88);
  --bs-table-border-color: rgba(255, 255, 255, 0.05);
}

.teacher-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.42);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 0.6rem 0.5rem;
}

.teacher-table td {
  padding: 0.55rem 0.5rem;
  border-bottom-color: rgba(255, 255, 255, 0.04) !important;
}

.teacher-table tbody tr {
  transition: background var(--t-fast) var(--ease);
}

.teacher-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.teacher-table tbody tr:last-child td {
  border-bottom-color: transparent !important;
}

/* Secondary metric columns (quieter) */
.teacher-table .col-secondary {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.48);
}

.teacher-table .col-secondary strong {
  color: rgba(255, 255, 255, 0.62);
  font-weight: 600;
}

/* =========================
   Assignment form container
   ========================= */

.assignment-form-wrap {
  margin-top: 0.75rem;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.assignment-empty-state {
  padding: 1rem 0;
}

/* =========================
   Mini progress bar (assignment tables)
   ========================= */

.progress-mini {
  width: 56px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex-shrink: 0;
}

.progress-mini-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width var(--t-med) var(--ease);
}

/* =========================
   Command bar (teacher class header)
   ========================= */

.command-bar {
  background: rgba(15, 26, 46, 0.72);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.command-bar .btn-group .btn {
  border-radius: 0;
}

.command-bar .btn-group .btn:first-child {
  border-top-left-radius: 0.375rem;
  border-bottom-left-radius: 0.375rem;
}

.command-bar .btn-group .btn:last-child {
  border-top-right-radius: 0.375rem;
  border-bottom-right-radius: 0.375rem;
}

/* =========================
   Essay Coach
   ========================= */

.ec-score-hero {
  background: rgba(15, 26, 46, 0.60);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
}

.ec-progress {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.ec-progress-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s var(--ease);
}

.ec-progress-bar.ec-green  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.ec-progress-bar.ec-blue   { background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.ec-progress-bar.ec-red    { background: linear-gradient(90deg, #ef4444, #f87171); }
.ec-progress-bar.ec-gray   { background: rgba(255, 255, 255, 0.18); }

.ec-pct-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
}

/* Component cards */
.ec-component {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  border-left: 3px solid transparent;
  transition: background var(--t-fast) var(--ease);
}

.ec-component.ec-earned {
  background: rgba(34, 197, 94, 0.08);
  border-left-color: rgba(34, 197, 94, 0.50);
}

.ec-component.ec-developing {
  background: rgba(251, 191, 36, 0.08);
  border-left-color: rgba(251, 191, 36, 0.55);
}

.ec-component.ec-missing {
  background: rgba(239, 68, 68, 0.06);
  border-left-color: rgba(239, 68, 68, 0.35);
}

.ec-component-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.ec-component-header .ec-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ec-component-header .ec-name {
  font-weight: 600;
  font-size: 0.88rem;
  flex: 1;
}

.ec-component-header .ec-pts {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.ec-badge-developing {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.22);
  border: 1px solid rgba(251, 191, 36, 0.40);
  color: #fbbf24;
}

.ec-detail {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
}

.ec-detail .ec-label {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.ec-detail .ec-next-step {
  background: rgba(124, 92, 255, 0.10);
  border: 1px solid rgba(124, 92, 255, 0.20);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.84rem;
  margin-top: 0.35rem;
}

.ec-detail details {
  margin-top: 0.4rem;
}

.ec-detail details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--brand-2);
  list-style: none;
}

.ec-detail details > summary::-webkit-details-marker { display: none; }

.ec-detail details > summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.4rem;
  font-size: 0.6rem;
  transition: transform 0.15s var(--ease);
  vertical-align: middle;
}

.ec-detail details[open] > summary::before {
  transform: rotate(90deg);
}

.ec-detail .ec-exemplar {
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
}

.ec-detail .ec-tips {
  margin: 0.35rem 0 0 0;
  padding-left: 1.2rem;
  font-size: 0.82rem;
}

.ec-detail .ec-tips li {
  margin-bottom: 0.2rem;
  color: var(--muted);
}

/* Overall summary */
.ec-overall {
  background: rgba(53, 198, 255, 0.08);
  border: 1px solid rgba(53, 198, 255, 0.18);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Revision priorities */
.ec-priorities {
  counter-reset: ec-pri;
  padding: 0;
  list-style: none;
  margin: 0;
}

.ec-priorities li {
  counter-increment: ec-pri;
  padding: 0.45rem 0 0.45rem 2rem;
  position: relative;
  font-size: 0.84rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ec-priorities li:last-child { border-bottom: none; }

.ec-priorities li::before {
  content: counter(ec-pri);
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: rgba(124, 92, 255, 0.18);
  border: 1px solid rgba(124, 92, 255, 0.30);
  color: var(--brand-2);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Section headers */
.ec-section-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ec-section-head.ec-head-green { color: #4ade80; }
.ec-section-head.ec-head-red   { color: #f87171; }

/* =========================
   Mobile responsiveness
   ========================= */

/* Touch-friendly tap targets */
@media (max-width: 767.98px) {
  /* Buttons: minimum 44px height for touch */
  .btn-sm {
    min-height: 38px;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Cards: tighter padding on mobile */
  .card-body {
    padding: 0.85rem;
  }

  /* Tables: smaller text, tighter cells */
  .teacher-table th,
  .teacher-table td {
    padding: 0.4rem 0.35rem;
    font-size: 0.78rem;
  }

  /* Badge text: slightly larger for readability */
  .badge {
    font-size: 0.68rem;
    padding: 0.3em 0.55em;
  }

  /* Metric card headings: scale down */
  .card .h4,
  .card .h5 {
    font-size: 1.1rem;
  }

  /* Footer links: wrap into grid on mobile */
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }
  .footer-links .footer-sep {
    display: none;
  }

  /* Dropdown menus: constrain to viewport */
  .dropdown-menu {
    max-width: calc(100vw - 2rem);
    min-width: auto !important;
  }

  /* Button groups: stack vertically on mobile */
  .btn-group-mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .btn-group-mobile-stack .btn {
    border-radius: 0.375rem !important;
  }

  /* Feedback rubric columns: full width stack */
  .feedback-columns {
    flex-direction: column;
  }
  .feedback-columns .feedback-section {
    min-width: 0 !important;
    width: 100%;
  }

  /* Daily briefing: stack columns */
  .briefing-grid .col-md-6 {
    margin-bottom: 0.75rem;
  }

  /* Command bar: wrap more aggressively */
  .command-bar {
    gap: 0.35rem;
  }
  .command-bar .btn-group {
    flex-wrap: wrap;
  }

  /* Progress bars in tables: wider on mobile */
  .progress-inline {
    min-width: 60px;
  }

  /* Offcanvas width on small screens */
  .offcanvas {
    width: min(100vw, 560px) !important;
  }

  /* Form selects: full width on mobile */
  .form-select-mobile-full {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Writing Process card: readable on small screens */
  .writing-process-card .card-body {
    padding: 0.75rem;
  }
  .writing-process-card .h6 {
    font-size: 0.88rem;
  }

  /* Essay coach components: tighter on mobile */
  .ec-component {
    padding: 0.65rem 0.75rem;
  }
  .ec-score-hero {
    padding: 0.85rem 1rem;
  }

  /* Teacher metric cards: 2-column grid on mobile */
  .metric-grid-mobile {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .metric-grid-mobile .card-body {
    padding: 0.65rem;
  }
}