:root {
  color-scheme: light;

  /* ── Core ─────────────────────────────── */
  --bg:          #F5F3FF;
  --surface:     #ffffff;
  --surface-2:   #EDE9FE;
  --text:        #1E1B4B;
  --muted:       #6B7280;
  --line:        #DDD6FE;

  /* ── Brand ────────────────────────────── */
  --primary:     #6C3AE0;
  --primary-light: #8B5CF6;
  --primary-dark:  #4C1D95;
  --primary-bg:  #F5F3FF;

  /* ── Accent (gold) ────────────────────── */
  --accent:      #FFD166;
  --accent-light: #FDE68A;
  --accent-dark:  #F59E0B;

  /* ── Semantic ─────────────────────────── */
  --green:       #10B981;
  --green-bg:    #D1FAE5;
  --red:         #EF4444;
  --red-bg:      #FEE2E2;
  --amber:       #F59E0B;

  /* ── Legacy aliases (keep so nothing breaks) ── */
  --teal:        var(--primary);
  --teal-dark:   var(--primary-dark);
  --aqua:        var(--primary-light);
  --blue-accent: var(--primary);
  --gray:        var(--muted);

  /* ── Shared ──────────────────────────── */
  --shadow:      0 18px 45px rgba(30, 27, 75, 0.08);
  --radius:      10px;
  --font:        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(108, 58, 224, 0.06), rgba(245, 243, 255, 0) 360px),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: none;
  background: var(--text);
  backdrop-filter: none;
  color: rgba(255, 255, 255, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 26px;
}

.mobile-menu-button {
  display: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  font-weight: 650;
}

.brand-title {
  color: #fff;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.mode-button,
.ghost-button,
.primary-button,
.option-button {
  min-height: 42px;
  border-radius: var(--radius);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  font-weight: 750;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.25);
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 900;
}

.sidebar-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: transparent;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.user-name {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.user-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 22px;
  max-width: 1180px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  font-weight: 850;
}

.topbar p {
  max-width: 640px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Compact topbar for the study view: the panel header + assignment chooser
   already carry the context, so reclaim vertical space above the question. */
.topbar-compact {
  margin-bottom: 12px;
}
.topbar-compact h1 {
  font-size: clamp(20px, 2.4vw, 26px);
}
.topbar-compact p {
  display: none;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(108, 58, 224, 0.25);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost-button:hover {
  border-color: #a7c8d7;
  background: #f2f9fc;
}

.content {
  max-width: 1180px;
  margin: 0 auto;
}

.content.study-content {
  max-width: 1240px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 390px;
  gap: 18px;
  align-items: start;
}

.study-focus-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 0;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 850;
}

.panel-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
}

.stat {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
  font-weight: 850;
}

.stat-foot {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.mode-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.mode-button.active,
.mode-button:hover {
  border-color: rgba(108, 58, 224, 0.35);
  background: var(--surface-2);
}

.mode-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--teal-dark);
  font-size: 15px;
  font-weight: 900;
}

.mode-name {
  font-size: 14px;
  font-weight: 850;
}

.mode-desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.study-panel {
  overflow: hidden;
}

.study-card {
  padding: 18px;
}

.study-panel.focus .panel-header {
  justify-content: center;
  padding: 24px 28px 0;
  text-align: center;
}

.study-panel.focus .study-card {
  padding: 26px 34px 34px;
}

.study-panel.focus .question-meta {
  max-width: 760px;
  margin: 0 auto;
}

.study-panel.focus .prompt-word {
  margin: 30px auto 8px;
  max-width: 820px;
  text-align: center;
  font-size: clamp(46px, 8vw, 84px);
}

.study-panel.focus .prompt-type {
  text-align: center;
  font-size: 15px;
}

.study-panel.focus .definition-box {
  max-width: 820px;
  margin: 26px auto 0;
  padding: 24px;
  text-align: center;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.35;
}

.study-panel.focus .options {
  max-width: 820px;
  margin: 28px auto 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.study-panel.focus .option-button {
  min-height: 76px;
  padding: 16px 18px;
  font-size: 16px;
}

.study-panel.focus .feedback,
.study-panel.focus .study-actions,
.study-panel.focus .type-answer {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.study-panel.focus .study-actions {
  justify-content: center;
}

.study-panel.focus .type-answer {
  display: block;
  min-height: 164px;
  margin-top: 26px;
  font-size: 17px;
}

.study-panel.focus .flashcard {
  max-width: 820px;
  min-height: 420px;
  margin: 26px auto 0;
}

.study-panel.focus .flash-word {
  font-size: clamp(54px, 9vw, 96px);
}

.activity-panel {
  position: sticky;
  top: 24px;
}

.mode-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.mode-list .mode-button {
  min-height: 58px;
  padding: 10px;
}

.mode-list .mode-icon {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.mode-list .mode-desc {
  display: none;
}

.activity-summary {
  margin: 0 18px 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
}

.activity-word {
  margin: 9px 0 12px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 850;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-count {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(108, 58, 224, 0.12);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  text-transform: none;
  letter-spacing: 0;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff5e0;
  border: 1px solid #f0c060;
  color: #8a5a00;
  font-size: 11px;
  font-weight: 900;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.prompt-word {
  margin: 18px 0 6px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
  font-weight: 850;
}

.prompt-type {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

/* ── Pronunciation speak button ────────────────────────────────────────── */
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 15px !important;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
.speak-btn:hover {
  background: var(--bg-hover, rgba(0,0,0,0.05));
  border-color: var(--accent, #2563eb);
}
.speak-btn:active {
  transform: scale(0.9);
}
.speak-btn-sm {
  width: 24px;
  height: 24px;
  font-size: 12px !important;
  margin-left: 4px;
}
.speak-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
  display: block;
}
.speak-btn-sm .speak-icon {
  width: 13px;
  height: 13px;
}

/* Slow-pronunciation toggle (study panel header) */
.slow-audio-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.slow-audio-toggle:hover {
  border-color: var(--primary-light);
  color: var(--text);
}
.slow-audio-toggle.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* The focus study header is centered, so pin the toggle to the top-right
   corner instead of letting it push the title off-center. */
.study-panel.focus .panel-header {
  position: relative;
}
.study-panel.focus .slow-audio-toggle {
  position: absolute;
  top: 16px;
  right: 18px;
}

.definition-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: #253330;
  font-size: 15px;
  line-height: 1.5;
}

.options {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.option-button {
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.option-button:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.option-button.correct {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--green-bg);
  color: #065F46;
}

.option-button.wrong {
  border-color: rgba(239, 68, 68, 0.35);
  background: var(--red-bg);
  color: #991B1B;
}

.feedback {
  margin-top: 14px;
  padding: 13px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
}

.feedback.good {
  background: var(--green-bg);
  color: #065F46;
}

.feedback.bad {
  background: #FEF3C7;
  color: #92400E;
}

.study-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.type-answer {
  width: 100%;
  min-height: 112px;
  margin-top: 16px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.type-answer:focus {
  border-color: rgba(108, 58, 224, 0.55);
  box-shadow: 0 0 0 3px rgba(108, 58, 224, 0.1);
}

.flashcard {
  min-height: 300px;
  display: grid;
  align-content: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(108, 58, 224, 0.08), rgba(139, 92, 246, 0.05)),
    var(--surface);
  text-align: center;
  touch-action: pan-y;
  user-select: none;
}

.flash-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.flash-word {
  margin-top: 12px;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1;
  font-weight: 850;
}

.flash-def {
  max-width: 620px;
  margin: 18px auto 0;
  color: #263633;
  font-size: 17px;
  line-height: 1.55;
}

.mastery-list,
.history-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.word-row,
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.word-main {
  min-width: 0;
}

.word-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  font-weight: 850;
}

.word-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.tag.mastered {
  background: var(--green-bg);
  color: #065F46;
}

.tag.learning {
  background: var(--surface-2);
  color: var(--primary);
}

.tag.reinforce {
  background: #fff2df;
  color: #92530f;
}

.word-def {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.progress-mini {
  width: 96px;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eeee;
}

.progress-mini > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.column-panel {
  min-width: 0;
}

.empty {
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 18px 0 8px;
  font-size: 36px;
  line-height: 1;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.name-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  font-size: 15px;
  font-weight: 700;
}

.name-input:focus {
  border-color: rgba(108, 58, 224, 0.55);
  box-shadow: 0 0 0 3px rgba(108, 58, 224, 0.1);
}

.login-card .primary-button {
  width: 100%;
  margin-top: 12px;
}

.login-card .name-input + .name-input {
  margin-top: 10px;
}

.login-help {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.login-help strong {
  color: var(--text);
}

.review-band {
  margin-top: 18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--primary-bg);
}

.review-band strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.review-band p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.answer-reveal {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
}

.answer-reveal.correct {
  background: var(--green-bg);
  border-left-color: var(--green);
}

.answer-reveal.incorrect {
  background: #f4f9ff;
  border-left-color: var(--aqua);
}

.answer-reveal-label {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.answer-reveal.correct .answer-reveal-label {
  color: #065F46;
}

.answer-reveal.incorrect .answer-reveal-label {
  color: var(--blue-accent);
}

.answer-reveal-def {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}

.answer-reveal-example {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── AI Situations mode ───────────────────────────────────────────────── */

.ai-situation-box {
  margin: 18px 0 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--aqua);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(108, 58, 224, 0.05), rgba(76, 29, 149, 0.03));
  font-size: clamp(15px, 2.2vw, 19px);
  font-style: italic;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text);
}

.ai-loading {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 130px;
  color: var(--muted);
}

.ai-loading p {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
}

.ai-loading-dots {
  display: flex;
  gap: 7px;
}

.ai-loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--aqua);
  animation: dot-pulse 1.3s ease-in-out infinite;
}

.ai-loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.75); }
  40%            { opacity: 1;    transform: scale(1);    }
}

.ai-error {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* ── Use in Sentence mode ────────────────────────────────────────────────── */
.uis-definition {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.uis-textarea {
  width: 100%;
  min-height: 90px;
  margin-top: 16px;
  padding: 12px 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  line-height: 1.5;
}

.uis-textarea:focus {
  border-color: rgba(108, 58, 224, 0.55);
  box-shadow: 0 0 0 3px rgba(108, 58, 224, 0.1);
}

.uis-typed-sentence {
  margin: 14px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
  color: var(--text);
}

.evaluation-result {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
}

.evaluation-result.eval-correct {
  background: #f0faea;
  border-left-color: var(--amber);
}

.evaluation-result.eval-incorrect {
  background: #fff4ec;
  border-left-color: #e67e22;
}

.eval-label {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.eval-correct .eval-label {
  color: #3a6e1a;
}

.eval-incorrect .eval-label {
  color: #b45309;
}

.eval-feedback {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.grammar-note {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 13px;
  line-height: 1.45;
  color: #92400e;
}

.improved-sentence {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 13px;
  line-height: 1.45;
  color: #1e40af;
}

/* ── Unassigned student warning ───────────────────────────────────────────── */
.unassigned-warning {
  background: #fff8e1;
  border: 1px solid #f0c060;
  border-radius: 10px;
  padding: 12px 18px;
  color: #7a5200;
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ── Student management panel ─────────────────────────────────────────────── */
.student-list-simple {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.student-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.student-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.student-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.student-username {
  font-size: 12px;
  color: var(--muted);
}
.student-pw-badge {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 9px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.ghost-button.small {
  padding: 3px 10px;
  font-size: 12px;
  flex-shrink: 0;
}
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 4px;
}
.inline-form .name-input {
  flex: 1;
  min-width: 110px;
}

/* ── Student picker (inside class form) ───────────────────────────────────── */
.student-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
}
.student-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background 0.1s;
}
.student-picker label:hover { background: rgba(0,178,226,0.08); }

/* ── Difficulty badge ─────────────────────────────────────────────────────── */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--diff-color) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--diff-color) 35%, transparent);
  color: var(--diff-color);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.difficulty-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--diff-color);
  flex-shrink: 0;
}

.difficulty-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
}
.difficulty-bar {
  display: inline-block;
  width: 70px;
  height: 5px;
  background: var(--line, #e5e7eb);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}
.difficulty-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 2px;
}

@media (max-width: 480px) {
  .difficulty-bar { width: 50px; }
}

/* ── Cloze exercise ─────────────────────────────────────────────────────── */
.cloze-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  margin: 18px 0 22px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
}
.cloze-chip {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px;
  background: #ffffff;
  border: 2px solid #334155;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
  font-family: inherit;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 0 #334155;
}
.cloze-chip:active:not(:disabled):not(.used) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #334155;
}
.cloze-chip.selected {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.2), 0 2px 0 #000;
}
.cloze-chip.used {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
  border-style: dashed;
}
.cloze-chip:disabled { opacity: 0.4; cursor: default; box-shadow: none; }

.cloze-sentences {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 8px 0 18px;
}
.cloze-sentence-row {
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}
.cloze-sentence-row.row-correct {
  background: #f0fdf4;
  border-color: #86efac;
  box-shadow: 0 1px 2px rgba(22, 163, 74, 0.08);
}
.cloze-sentence-row.row-wrong {
  background: #fef2f2;
  border-color: #fca5a5;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.08);
}
.cloze-sentence {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
}
.cloze-blank {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 36px;
  padding: 4px 14px;
  margin: 0 4px;
  background: #fff;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  font-weight: 700;
  font-family: inherit;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.2;
}
.cloze-blank:active:not(:disabled) {
  border-color: var(--text);
  background: #f1f5f9;
}
.cloze-blank.filled {
  background: var(--surface-2);
  border-style: solid;
  border-color: #6366f1;
  color: #3730a3;
}
.cloze-blank.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #14532d;
}
.cloze-blank.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #7f1d1d;
  text-decoration: line-through;
}
.cloze-blank:disabled { cursor: default; }
.cloze-correct-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #86efac;
  font-size: 14px;
  color: #16a34a;
  font-weight: 600;
}
.cloze-correct-hint strong { color: #14532d; }

.cloze-results {
  text-align: center;
  font-size: 18px;
  margin: 18px 0 8px;
  color: var(--text);
}
.cloze-results strong { font-size: 24px; }

@media (max-width: 480px) {
  .cloze-pool {
    padding: 12px;
    gap: 8px;
    margin: 14px 0 18px;
    /* On mobile, the sticky pool sits at the top so it's always reachable */
  }
  .cloze-chip {
    padding: 9px 13px;
    font-size: 13px;
    min-height: 38px;
    box-shadow: 0 2px 0 #334155;
  }
  .cloze-sentence-row {
    padding: 14px 14px;
  }
  .cloze-sentence {
    font-size: 15px;
    line-height: 1.7;
  }
  .cloze-blank {
    min-width: 72px;
    min-height: 34px;
    padding: 3px 10px;
    font-size: 13px;
    margin: 2px 3px;
  }
}

.assignment-strip {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 18px 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.assignment-strip strong {
  color: var(--text);
}

.assignment-chooser {
  padding: 14px 18px;
}

.assignment-chooser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.assignment-chooser-header strong {
  font-size: 15px;
  font-weight: 850;
  display: block;
}

.assignment-chooser-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.assignment-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.assignment-controls .ghost-button.active {
  border-color: rgba(108, 58, 224, 0.35);
  background: rgba(108, 58, 224, 0.06);
  color: var(--teal-dark);
}

.assignment-current {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
}

.assignment-current strong {
  font-size: 14px;
  font-weight: 850;
}

.assignment-current span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.teacher-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.teacher-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.teacher-form .type-answer {
  margin-top: 0;
  min-height: 150px;
}

/* Labeled field used in the profile + class edit form (date picker, etc).
   Stacks the label above the input with consistent spacing. */
.date-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.date-field small {
  font-weight: 500;
  color: var(--muted);
}
.checkbox-field {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

/* ── Teacher Alerts panel ───────────────────────────────────────────────
   Sits above the dashboard grid. Three cards (inactive / risky quizzes /
   tough words). Click a card to expand the detail list. Colour-coded but
   muted; this is glanceable info, not a siren. */
.alerts-panel {
  margin-bottom: 14px;
  padding: 18px;
}
.alerts-panel.loading { opacity: .7; }
.alerts-panel.empty .panel-title {
  color: var(--green, #10B981);
}
.alerts-count {
  display: inline-grid;
  place-items: center;
  margin-left: 8px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.alert-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.alert-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(108, 58, 224, 0.10);
}
.alert-card.open {
  border-color: var(--primary);
}
.alert-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}
.alert-title {
  font-size: 14px;
  font-weight: 850;
  color: var(--text);
}
.alert-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}
.alert-chevron {
  color: var(--muted);
  font-size: 14px;
}
.alert-body {
  border-top: 1px solid var(--line);
  max-height: 280px;
  overflow-y: auto;
}
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.alert-row:last-child { border-bottom: 0; }
.alert-row strong { color: var(--text); }
.alert-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.alert-metric {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 850;
  color: var(--primary);
  background: var(--primary-bg, rgba(108, 58, 224, 0.08));
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.alert-more {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
@media (max-width: 620px) {
  .alerts-grid { grid-template-columns: 1fr; }
}

/* ── Mastery cheatsheet ─────────────────────────────────────────────────
   Collapsible reference card on the teacher dashboard explaining what each
   tone means and how the underlying score is computed. Compact when closed
   so it doesn't compete with the data. */
.mastery-guide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 0;
  overflow: hidden;
}
.mastery-guide > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 850;
  color: var(--text);
  user-select: none;
}
.mastery-guide > summary::before {
  content: "ⓘ";
  margin-right: 8px;
  font-size: 16px;
  color: var(--primary);
}
.mastery-guide-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.mastery-guide-body {
  padding: 6px 18px 20px;
  border-top: 1px solid var(--line);
}
.mastery-buckets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 16px 0 22px;
}
.mastery-bucket {
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  border-left-width: 5px;
}
.mastery-bucket.tone-none { border-left-color: var(--line); }
.mastery-bucket.tone-bad  { border-left-color: #EF4444; }
.mastery-bucket.tone-warn { border-left-color: #F59E0B; }
.mastery-bucket.tone-good { border-left-color: #10B981; }
.bucket-name {
  font-size: 14px;
  font-weight: 850;
  color: var(--text);
}
.bucket-range {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 3px;
}
.bucket-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.mastery-section-h {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text);
}
.mastery-section-p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.mastery-section-p strong { color: var(--text); }
.mastery-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0 14px;
}
.mastery-table th,
.mastery-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.mastery-table th {
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--primary-bg, rgba(108, 58, 224, 0.05));
}
.mastery-table td.num,
.mastery-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 850; }
.mastery-table td.num.positive { color: #047857; }
.mastery-table td.num.negative { color: #b91c1c; }
.mastery-table tr:last-child td { border-bottom: 0; }
.mastery-levels {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: grid;
  gap: 6px;
}
.mastery-levels li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.mastery-levels .level-num {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-bg, rgba(108, 58, 224, 0.1));
  color: var(--primary);
  font-size: 11px;
  font-weight: 850;
}
@media (max-width: 620px) {
  .mastery-buckets { grid-template-columns: 1fr 1fr; }
}

/* ── Activity badge + mastery legend (student detail header) ───────────── */
/* Inline "active 2d ago" badge next to the student name. */
.activity-badge {
  display: inline-block;
  margin-left: 10px;
  vertical-align: middle;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.activity-badge.tone-good { background: rgba(16, 185, 129, .14); color: #047857; }
.activity-badge.tone-warn { background: rgba(245, 158, 11, .15); color: #b45309; }
.activity-badge.tone-bad  { background: rgba(239, 68, 68, .14);  color: #b91c1c; }

/* Mastery legend strip — quick visual of how the student's words split. */
.mastery-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 18px 12px;
}
.legend-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border: 1px solid transparent;
}
.legend-pill.tone-good { background: rgba(16, 185, 129, .12); color: #047857; }
.legend-pill.tone-warn { background: rgba(245, 158, 11, .14); color: #b45309; }
.legend-pill.tone-bad  { background: rgba(239, 68, 68, .12);  color: #b91c1c; }
.legend-pill.tone-none { background: var(--bg);               color: var(--muted); border-color: var(--line); }

/* Traffic-light tinting on each word row of the student detail list. The
   left-edge stripe is the dominant cue; the tag carries the textual label. */
.student-word-row.tone-good { border-left: 4px solid #10B981; }
.student-word-row.tone-warn { border-left: 4px solid #F59E0B; }
.student-word-row.tone-bad  { border-left: 4px solid #EF4444; }
.student-word-row.tone-none { border-left: 4px solid var(--line); }

.tag.tone-good { background: rgba(16, 185, 129, .12); color: #047857; }
.tag.tone-warn { background: rgba(245, 158, 11, .14); color: #b45309; }
.tag.tone-bad  { background: rgba(239, 68, 68, .12);  color: #b91c1c; }
.tag.tone-none { background: var(--bg);               color: var(--muted); }

/* ── Student Groups ─────────────────────────────────────────────────────
   Teacher-owned cohorts. Used in the Groups tab (CRUD), in the quiz form
   (chips above the student picker), and as small chips under each student
   row in the Students tab. */
.group-chip {
  --group-color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--group-color) 12%, transparent);
  color: var(--group-color);
  border: 1.5px solid color-mix(in srgb, var(--group-color) 25%, transparent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.group-chip.small { font-size: 11px; padding: 3px 8px; }
.group-chip-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background: var(--group-color);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}
.group-chip.toggle {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s;
}
.group-chip.toggle:hover { transform: translateY(-1px); }
.group-chip.toggle.on {
  background: var(--group-color);
  color: #fff;
  border-color: var(--group-color);
}
.group-chip.toggle.on .group-chip-count {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* "Assign by group" strip inside the quiz form step 3. */
.assign-by-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}
.assign-by-group-label {
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.assign-by-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Student picker rows that are covered by an active group selection get a
   subtle highlight so the teacher can see "yes, they're in via the group". */
.student-picker label.covered-by-group {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-radius: 8px;
  padding: 2px 6px;
}
.student-picker label.covered-by-group::after {
  content: "in group";
  margin-left: 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Groups tab — group cards. */
.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px 18px 0;
}
.group-card {
  --group-color: var(--primary);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--group-color);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.group-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.group-card-head strong {
  flex: 1;
  font-weight: 850;
  color: var(--text);
}
.group-card-count {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.group-card-members {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.group-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.group-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--group-color);
  border: 1.5px solid color-mix(in srgb, var(--group-color) 40%, transparent);
}

/* Color picker in the create/edit form. */
.group-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 6px;
  flex-wrap: wrap;
}
.group-color-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.group-swatch-option {
  cursor: pointer;
  position: relative;
}
.group-swatch-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.group-swatch-option .group-swatch {
  width: 22px;
  height: 22px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.group-swatch-option input[type="radio"]:checked + .group-swatch {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--group-color);
}

/* Student rows: chips below the username. */
.student-group-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* "Claim existing student" collapsible block under the Add student form.
   Keeps the secondary action out of the way until the teacher needs it. */
.claim-block {
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.claim-block > summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  color: var(--primary);
  list-style: none;
  user-select: none;
}
.claim-block > summary::before {
  content: "+ ";
  font-weight: 900;
}
.claim-block[open] > summary::before {
  content: "− ";
}

.word-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfc;
}

.word-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px 120px;
  gap: 10px;
}

.selected-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.selected-summary strong {
  color: var(--text);
  white-space: nowrap;
}

.word-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.word-picker label[hidden] {
  display: none;
}

.word-picker label span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.word-picker label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.word-picker label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.word-picker label:hover {
  border-color: var(--line);
  background: var(--surface);
}

.class-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.class-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.class-row-info { flex: 1; min-width: 0; }
.class-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.class-row.active {
  border-color: rgba(108, 58, 224, 0.35);
  background: rgba(108, 58, 224, 0.06);
}
.class-row.editing {
  border-color: var(--blue-accent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Danger ghost button (delete) */
.ghost-button.danger {
  color: var(--red);
  border-color: #FECACA;
}
.ghost-button.danger:hover { background: #fdf1f0; }

/* Inline edit panel */
.class-edit-panel {
  border: 1px solid var(--blue-accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: #f7f9ff;
  padding: 16px;
  margin-bottom: 2px;
}
.class-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 14px;
}
.edit-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.progress-table {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.student-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.student-metrics,
.student-weakness {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.student-metrics span,
.student-weakness span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--primary-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.student-metrics strong {
  color: var(--text);
}

.teacher-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.teacher-student-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.teacher-inspector-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.student-index-panel {
  position: sticky;
  top: 24px;
}

.student-search-box {
  padding: 18px 18px 0;
}

.teacher-student-list.compact {
  max-height: 560px;
  overflow: auto;
}

.teacher-student-card {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.teacher-student-card:hover,
.teacher-student-card.active {
  border-color: rgba(108, 58, 224, 0.35);
  background: rgba(108, 58, 224, 0.06);
}

.teacher-student-card.compact {
  grid-template-columns: 1fr;
}

.teacher-student-card[hidden] {
  display: none;
}

.teacher-student-bars {
  display: grid;
  gap: 10px;
}

.metric-bar {
  display: grid;
  gap: 6px;
}

.metric-bar > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-bar strong {
  color: var(--text);
}

.teacher-word-stat {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.teacher-word-stat strong {
  color: var(--amber);
  font-size: 24px;
  line-height: 1;
}

.student-detail-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.student-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 18px 18px 0;
}

.student-summary-strip .stat {
  min-height: 92px;
  padding: 13px;
}

.student-word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-footnote {
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .sidebar-footer {
    position: static;
    margin-top: 12px;
  }

  .main {
    padding: 20px 14px 28px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .dashboard-grid,
  .study-focus-grid,
  .teacher-grid,
  .teacher-dashboard-grid,
  .teacher-inspector-grid,
  .assignment-chooser,
  .columns {
    grid-template-columns: 1fr;
  }

  .student-index-panel {
    position: static;
  }

  .activity-panel {
    position: static;
  }

  .mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body {
    background:
      linear-gradient(180deg, rgba(108, 58, 224, 0.08), rgba(245, 243, 255, 0) 260px),
      var(--bg);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px;
    background: var(--text);
    backdrop-filter: none;
  }

  .brand {
    margin-bottom: 0;
  }

  .brand-title {
    font-size: 15px;
  }

  .brand-subtitle,
  .sidebar-footer,
  .nav {
    display: none;
  }

  .mobile-menu-button {
    margin-left: auto;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 12px;
    font-weight: 850;
  }

  .sidebar:focus-within .nav,
  .sidebar:hover .nav,
  .sidebar.menu-open .nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 10px;
  }

  .sidebar:focus-within .nav button,
  .sidebar:hover .nav button,
  .sidebar.menu-open .nav button {
    justify-content: flex-start;
    min-height: 42px;
    padding: 0 10px;
  }

  .sidebar.menu-open .sidebar-footer {
    display: flex;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .main {
    padding: 10px 8px 18px;
  }

  .topbar {
    display: none;
  }

  .content.study-content {
    max-width: 100%;
  }

  .study-focus-grid,
  .study-panel,
  .activity-panel {
    min-width: 0;
    width: 100%;
  }

  .stats-row,
  .mode-grid,
  .mode-list,
  .study-panel.focus .options {
    grid-template-columns: 1fr;
  }

  .study-panel.focus .panel-header {
    padding: 14px 12px 0;
  }

  .study-panel.focus .study-card {
    padding: 14px 12px 18px;
  }

  .study-panel.focus .question-meta {
    font-size: 11px;
  }

  .study-panel.focus .prompt-word {
    margin-top: 14px;
    text-align: center;
    font-size: clamp(28px, 10vw, 44px);
  }

  .study-panel.focus .prompt-type {
    text-align: center;
  }

  .study-panel.focus .definition-box {
    text-align: center;
    font-size: 17px;
    padding: 14px;
  }

  .study-panel.focus .options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
  }

  .study-panel.focus .option-button {
    min-height: 56px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .study-panel.focus .study-actions {
    position: sticky;
    bottom: 10px;
    z-index: 5;
  }

  .study-panel.focus .study-actions .primary-button,
  .study-panel.focus .study-actions .ghost-button {
    min-height: 48px;
    flex: 1 1 auto;
  }

  .study-panel.focus .flashcard {
    min-height: 240px;
  }

  .study-panel.focus .flash-word {
    font-size: 36px;
  }

  .swipe-hint {
    display: flex;
    justify-content: space-between;
    padding: 6px 4px 0;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .word-row,
  .history-row,
  .class-row {
    grid-template-columns: 1fr;
  }

  .word-picker {
    grid-template-columns: 1fr;
  }

  /* Stack quiz-builder / edit-form inputs so narrow phones don't squeeze
     fields to ~134px and truncate their placeholders. Placed after the base
     `.edit-form-row` rule (line ~1739) so source order lets it win. */
  .edit-form-row {
    grid-template-columns: 1fr;
  }

  /* On narrow screens, stack the header so the slow-audio toggle drops below
     the centered title instead of pinning it to the corner (avoids overlap). */
  .study-panel.focus .panel-header {
    flex-direction: column;
    align-items: center;
  }
  .study-panel.focus .slow-audio-toggle {
    position: static;
    margin: 10px auto 0;
  }

  .assignment-chooser {
    padding: 12px;
    margin-bottom: 10px;
  }

  .assignment-chooser summary strong {
    font-size: 14px;
  }

  .assignment-chooser summary small {
    font-size: 11px;
  }

  .change-label {
    min-height: 28px;
    font-size: 12px;
  }

  .assignment-select-wrap {
    margin-top: 10px;
  }

  .activity-panel .panel-header {
    display: none;
  }

  .activity-panel {
    order: -1;
  }

  .activity-panel .panel-note {
    display: none;
  }

  .mode-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
    scrollbar-width: none;
  }

  .mode-list::-webkit-scrollbar {
    display: none;
  }

  .mode-list .mode-button {
    flex: 0 0 124px;
    min-height: 46px;
    padding: 8px;
  }

  .mode-list .mode-name {
    font-size: 12px;
  }

  .mode-list .mode-icon {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .activity-summary {
    display: none;
  }

  .study-panel.focus .options {
    grid-template-columns: 1fr;
  }

  .student-summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .word-tools,
  .assignment-controls,
  .student-row,
  .teacher-student-card,
  .student-word-row {
    grid-template-columns: 1fr;
  }

  .student-summary-strip {
    grid-template-columns: 1fr;
  }

  .teacher-word-stat {
    justify-items: start;
  }

  .progress-mini {
    width: 100%;
  }

  .topbar h1,
  .login-card h1 {
    font-size: 30px;
  }
}

/* ── Hero CTA (student dashboard) ───────────────────────────────────────── */
.hero-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
  background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 100%);
  color: #fff;
  border-radius: 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(30, 27, 75, 0.2);
}
.hero-cta-text h2 {
  margin: 0 0 4px 0;
  font-size: 22px;
  font-weight: 700;
}
.hero-cta-text p {
  margin: 0;
  font-size: 14px;
  opacity: 0.85;
}
.hero-cta-button {
  font-size: 16px;
  padding: 12px 24px;
  flex-shrink: 0;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.hero-cta-button:hover { transform: translateY(-1px); }
.hero-cta-button:active { transform: translateY(0); }

.mode-picker-collapsible {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.mode-picker-collapsible summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  list-style: none;
}
.mode-picker-collapsible summary::-webkit-details-marker { display: none; }
.mode-picker-collapsible summary strong { color: var(--text); }
.mode-picker-collapsible[open] summary { margin-bottom: 12px; }

/* ── Teacher sub-tabs ───────────────────────────────────────────────────── */
.teacher-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 6px;
  background: var(--surface-2, #f1f5f9);
  border-radius: 12px;
  overflow-x: auto;
}
.teacher-tab {
  flex: 1;
  min-width: max-content;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.teacher-tab:hover { background: rgba(0, 0, 0, 0.04); color: var(--text); }
.teacher-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.teacher-tab-count {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  background: var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-weight: 700;
}
.teacher-tab.active .teacher-tab-count {
  background: var(--surface-2);
  color: var(--primary);
}

/* ── Quiz stepper ───────────────────────────────────────────────────────── */
.quiz-stepper { gap: 0; }
.quiz-step {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px dashed var(--line);
}
.quiz-step:last-of-type { border-bottom: none; }
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.step-body { flex: 1; min-width: 0; }
.step-body h3 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-body h3 small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.step-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 999px;
}

/* ── Vocabulary bank list ───────────────────────────────────────────────── */
.vocab-bank-list { display: flex; flex-direction: column; gap: 6px; }
.vocab-bank-row {
  display: grid;
  grid-template-columns: 1fr 100px 2fr;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  font-size: 13px;
  align-items: center;
}
.vocab-bank-row .muted { color: var(--muted); font-size: 12px; }

/* ── Vocabulary toolbar + table (Teacher › Vocabulary tab) ─────────────── */
.vocab-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  padding: 0 18px 14px;
}
.vocab-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 14px 14px;
  max-height: 560px;
  overflow-y: auto;
}
.vocab-row {
  display: grid;
  grid-template-columns: 1.6fr 2fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}
.vocab-row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.vocab-row-main strong { font-size: 14px; color: var(--text); }
.vocab-row-main .muted { font-size: 12px; color: var(--muted); }
.vocab-row-def { color: var(--text); line-height: 1.45; }
.vocab-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vocab-row-actions { display: flex; gap: 6px; }
.vocab-row-actions .ghost-button.danger { color: #b91c1c; }
.vocab-row-actions .ghost-button.danger:hover { background: rgba(239,68,68,.12); }

/* Edit-mode row: stacks everything top-down for readability. */
.vocab-row.editing {
  grid-template-columns: 1fr;
  border-color: var(--primary);
  background: var(--primary-bg, rgba(108,58,224,.04));
}
.vocab-row.editing textarea { min-height: 60px; }

.vocab-legacy-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(245,158,11,.16);
  color: #92400e;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 999px;
}

.vocab-upload-feedback { padding: 0 18px 16px; }
.vocab-upload-feedback .dup-list { margin: 6px 0 0 18px; color: var(--muted); font-size: 12px; }
.vocab-upload-feedback details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}

/* ── Generic modal (used by Import) ────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 24px;
}
.modal-card {
  background: var(--surface);
  border-radius: 14px;
  width: min(640px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 22px;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(15,23,42,.35);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.import-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.import-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.import-row .muted { font-size: 12px; color: var(--muted); }

@media (max-width: 620px) {
  .vocab-toolbar { grid-template-columns: 1fr; }
  .vocab-row { grid-template-columns: 1fr; gap: 6px; }
  .vocab-row-meta { justify-content: flex-start; }
}
.vocab-bank-def { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── User menu dropdown ─────────────────────────────────────────────────── */
.user-chip-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}
.user-chip-button:hover { background: rgba(255, 255, 255, 0.06); }
.user-chip-button.open { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.1); }
.user-chip-text { flex: 1; min-width: 0; }
.user-chip-text .user-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.user-chip-text .user-meta { font-size: 11px; color: rgba(255, 255, 255, 0.4); }
.user-chip-caret { color: rgba(255, 255, 255, 0.4); transition: transform 0.15s ease; }
.user-chip-button.open .user-chip-caret { transform: rotate(180deg); }

.user-menu {
  display: none;
  flex-direction: column;
  margin-top: 6px;
  padding: 4px;
  background: #2D2854;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
}
.user-menu.open { display: flex; }
.user-menu-item {
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  transition: background 0.1s ease;
}
.user-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.user-menu-item.danger:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }

/* Direct Log-out button in the sidebar footer. Always visible (no nested
   dropdown) so the action is reachable in one tap on mobile too. */
.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.logout-button:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

/* ── Study Hub ─────────────────────────────────────────────────────────── */
/* Entry screen for the Study view: pick an exercise type. Replaces dropping
   the student straight into "whatever mode loaded last", which felt jarring. */
.study-hub {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.study-hub-header {
  margin-bottom: 18px;
}
.study-hub-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 850;
  color: var(--text);
}
.study-hub-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.study-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.study-hub-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.study-hub-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(108, 58, 224, 0.12);
}
.study-hub-card:active { transform: translateY(0); }
.study-hub-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-bg, rgba(108, 58, 224, 0.1));
  color: var(--primary);
  font-size: 14px;
  font-weight: 850;
}
.study-hub-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.study-hub-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.study-hub-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.study-hub-arrow {
  flex: 0 0 auto;
  font-size: 18px;
  color: var(--muted);
  transition: transform 0.15s, color 0.15s;
}
.study-hub-card:hover .study-hub-arrow {
  color: var(--primary);
  transform: translateX(2px);
}

/* Back row above the exercise — returns to the hub. */
.study-back-row {
  margin-bottom: 10px;
}
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.back-button:hover {
  border-color: var(--primary);
  background: var(--primary-bg, rgba(108, 58, 224, 0.06));
}

/* On mobile the Activity sidebar is hidden (the hub replaces it), so the
   study panel takes full width. */
@media (max-width: 620px) {
  .study-hub {
    padding: 16px;
  }
  .study-hub-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .study-hub-card {
    padding: 12px;
    min-height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── Lex mascot ─────────────────────────────────────────────────────────── */
.lex {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.lex-feedback {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.lex-feedback .lex {
  margin-top: 2px;
}
