/* Colour schemes: the six accent variables are overridden by body[data-scheme] (see color-schemes.js) */
:root, body {
  --accent:#4a90a4; --accent-2:#7dd3c0; --accent-dark:#003b5c; --accent-soft:#a8c5d1; --accent-tint:#e8f4f8; --accent-darkest:#001f3f;
  --accent-rgb:74,144,164; --accent-dark-rgb:0,59,92; --accent-2-rgb:125,211,192; --accent-darkest-rgb:0,31,63;
 --bg-1:#7ba8bd; --bg-2:#a8d5e2; --bg-3:#88c5d8; --dark-1:#0d1620; --dark-2:#1a2332;
}
body[data-scheme="forest"] { --accent:#6fbf92; --accent-2:#bfeed3; --accent-dark:#3f8f66; --accent-soft:#cfe8da; --accent-tint:#eef8f2; --accent-darkest:#2e6b4b; --accent-rgb:111,191,146; --accent-dark-rgb:63,143,102; --accent-2-rgb:191,238,211; --accent-darkest-rgb:46,107,75; --bg-1:#8cc4a5; --bg-2:#b0dcc3; --bg-3:#9bcfb2; --dark-1:#14221a; --dark-2:#20352a; }
body[data-scheme="crimson"] { --accent:#c2485a; --accent-2:#f0a3ae; --accent-dark:#6e1426; --accent-soft:#e0b4bb; --accent-tint:#fbeaed; --accent-darkest:#3d0a15;  --accent-rgb:194,72,90; --accent-dark-rgb:110,20,38; --accent-2-rgb:240,163,174; --accent-darkest-rgb:61,10,21; --bg-1:#c98a95; --bg-2:#efc3ca; --bg-3:#dba0aa; --dark-1:#1c0e12; --dark-2:#2e171d; }
body[data-scheme="violet"] { --accent:#7b5cc4; --accent-2:#c3b0f0; --accent-dark:#3a2275; --accent-soft:#cbc0e6; --accent-tint:#f0ecfa; --accent-darkest:#1f1244;  --accent-rgb:123,92,196; --accent-dark-rgb:58,34,117; --accent-2-rgb:195,176,240; --accent-darkest-rgb:31,18,68; --bg-1:#a592cf; --bg-2:#cfc3ef; --bg-3:#b7a6e0; --dark-1:#150f22; --dark-2:#241a38; }
body[data-scheme="sunset"] { --accent:#d9822b; --accent-2:#f6c27a; --accent-dark:#7a3d05; --accent-soft:#e8cfae; --accent-tint:#fdf1e2; --accent-darkest:#432103;  --accent-rgb:217,130,43; --accent-dark-rgb:122,61,5; --accent-2-rgb:246,194,122; --accent-darkest-rgb:67,33,3; --bg-1:#d1a06a; --bg-2:#f2d3a6; --bg-3:#e3b887; --dark-1:#1f1409; --dark-2:#33220f; }
body[data-scheme="rose"] { --accent:#d0588f; --accent-2:#f4aacb; --accent-dark:#7a1f4d; --accent-soft:#e6bdd2; --accent-tint:#fcebf3; --accent-darkest:#43102a;  --accent-rgb:208,88,143; --accent-dark-rgb:122,31,77; --accent-2-rgb:244,170,203; --accent-darkest-rgb:67,16,42; --bg-1:#cf93b0; --bg-2:#f1c6dc; --bg-3:#e0a8c4; --dark-1:#1d0e16; --dark-2:#301925; }
body[data-scheme="slate"] { --accent:#5b6b7f; --accent-2:#a9b8c9; --accent-dark:#243142; --accent-soft:#c0c8d2; --accent-tint:#eef1f5; --accent-darkest:#131b26;  --accent-rgb:91,107,127; --accent-dark-rgb:36,49,66; --accent-2-rgb:169,184,201; --accent-darkest-rgb:19,27,38; --bg-1:#8b98a8; --bg-2:#c3ccd7; --bg-3:#a3afbd; --dark-1:#10151c; --dark-2:#1d2530; }
body[data-scheme="logo"] { --accent:#1f8a8a; --accent-2:#f0a830; --accent-dark:#004878; --accent-soft:#bcd9dc; --accent-tint:#eaf5f4; --accent-darkest:#002f52; --accent-rgb:31,138,138; --accent-dark-rgb:0,72,120; --accent-2-rgb:240,168,48; --accent-darkest-rgb:0,47,82; --bg-1:#6fb8b4; --bg-2:#d9e6a8; --bg-3:#e8c070; --dark-1:#0b1c22; --dark-2:#16303a; }
body[data-scheme="logo-blue"] { --accent:#1878a8; --accent-2:#30a8c0; --accent-dark:#004878; --accent-soft:#b9d3e2; --accent-tint:#e8f2f8; --accent-darkest:#002f52; --accent-rgb:24,120,168; --accent-dark-rgb:0,72,120; --accent-2-rgb:48,168,192; --accent-darkest-rgb:0,47,82; --bg-1:#6fa7c4; --bg-2:#9fd0e0; --bg-3:#82bdd6; --dark-1:#0b1822; --dark-2:#16293a; }
body[data-scheme="logo-green"] { --accent:#489060; --accent-2:#9fcf7a; --accent-dark:#1f5c3c; --accent-soft:#c2dcc9; --accent-tint:#eaf5ed; --accent-darkest:#103a24; --accent-rgb:72,144,96; --accent-dark-rgb:31,92,60; --accent-2-rgb:159,207,122; --accent-darkest-rgb:16,58,36; --bg-1:#7fbf8f; --bg-2:#c9e6a8; --bg-3:#a0d3a8; --dark-1:#0e1e16; --dark-2:#18311f; }
body[data-scheme="logo-amber"] { --accent:#e8962a; --accent-2:#f6cf7a; --accent-dark:#8a4f06; --accent-soft:#ecd5ae; --accent-tint:#fdf1de; --accent-darkest:#573103; --accent-rgb:232,150,42; --accent-dark-rgb:138,79,6; --accent-2-rgb:246,207,122; --accent-darkest-rgb:87,49,3; --bg-1:#e3b872; --bg-2:#f8e0a8; --bg-3:#efc88a; --dark-1:#211608; --dark-2:#35240d; }
body[data-scheme="pshs"] { --accent:#0b8294; --accent-2:#2fe0f0; --accent-dark:#12202b; --accent-soft:#bfe6ec; --accent-tint:#e6f8fa; --accent-darkest:#070d12; --accent-rgb:11,130,148; --accent-dark-rgb:18,32,43; --accent-2-rgb:47,224,240; --accent-darkest-rgb:7,13,18; --bg-1:#5fbfcb; --bg-2:#b4ecf3; --bg-3:#84d7e2; --dark-1:#07090c; --dark-2:#121a22; }
body[data-scheme="spotify"] { --accent:#15863d; --accent-2:#8ff0b0; --accent-dark:#14572e; --accent-soft:#c0ebcf; --accent-tint:#e8f8ee; --accent-darkest:#0b3019; --accent-rgb:21,134,61; --accent-dark-rgb:20,87,46; --accent-2-rgb:143,240,176; --accent-darkest-rgb:11,48,25; --bg-1:#83d8a1; --bg-2:#c7f8d8; --bg-3:#a5e3bb; --dark-1:#04130a; --dark-2:#082312; }
body[data-scheme="youtube"] { --accent:#e62117; --accent-2:#ff9a94; --accent-dark:#7a0d08; --accent-soft:#f8c1be; --accent-tint:#fce9e8; --accent-darkest:#430704; --accent-rgb:230,33,23; --accent-dark-rgb:122,13,8; --accent-2-rgb:255,154,148; --accent-darkest-rgb:67,7,4; --bg-1:#f1857f; --bg-2:#ffccca; --bg-3:#f5a6a2; --dark-1:#1b0302; --dark-2:#310503; }
body[data-scheme="facebook"] { --accent:#0e71f1; --accent-2:#8bbcff; --accent-dark:#0b3c85; --accent-soft:#bed9fb; --accent-tint:#e8f1fe; --accent-darkest:#062149; --accent-rgb:14,113,241; --accent-dark-rgb:11,60,133; --accent-2-rgb:139,188,255; --accent-darkest-rgb:6,33,73; --bg-1:#80b4f8; --bg-2:#c5deff; --bg-3:#a3c9fa; --dark-1:#020d1d; --dark-2:#041835; }
body[data-scheme="instagram"] { --accent:#c13584; --accent-2:#fcaf45; --accent-dark:#5b2a86; --accent-soft:#eec6dd; --accent-tint:#f9ebf3; --accent-darkest:#32174a; --accent-rgb:193,53,132; --accent-dark-rgb:91,42,134; --accent-2-rgb:252,175,69; --accent-darkest-rgb:50,23,74; --bg-1:#dd90bb; --bg-2:#fed7a2; --bg-3:#e6aece; --dark-1:#14091d; --dark-2:#241136; }
body[data-scheme="discord"] { --accent:#5865f2; --accent-2:#a9b1ff; --accent-dark:#2b3299; --accent-soft:#d0d4fb; --accent-tint:#eef0fe; --accent-darkest:#181c54; --accent-rgb:88,101,242; --accent-dark-rgb:43,50,153; --accent-2-rgb:169,177,255; --accent-darkest-rgb:24,28,84; --bg-1:#a3aaf8; --bg-2:#d4d8ff; --bg-3:#bcc1fa; --dark-1:#090b22; --dark-2:#11143d; }
body[data-scheme="twitch"] { --accent:#9146ff; --accent-2:#c9a6ff; --accent-dark:#4a1f99; --accent-soft:#e0cbff; --accent-tint:#f4ecff; --accent-darkest:#291154; --accent-rgb:145,70,255; --accent-dark-rgb:74,31,153; --accent-2-rgb:201,166,255; --accent-darkest-rgb:41,17,84; --bg-1:#c299ff; --bg-2:#e4d2ff; --bg-3:#d3b5ff; --dark-1:#100722; --dark-2:#1e0c3d; }
body[data-scheme="reddit"] { --accent:#db3b00; --accent-2:#ffb08f; --accent-dark:#8a2500; --accent-soft:#ffcbb8; --accent-tint:#ffece6; --accent-darkest:#4c1400; --accent-rgb:219,59,0; --accent-dark-rgb:138,37,0; --accent-2-rgb:255,176,143; --accent-darkest-rgb:76,20,0; --bg-1:#ff9973; --bg-2:#ffd8c7; --bg-3:#ffb599; --dark-1:#1e0800; --dark-2:#370f00; }
body[data-scheme="linkedin"] { --accent:#0a66c2; --accent-2:#7fb8ee; --accent-dark:#06376b; --accent-soft:#bad4ee; --accent-tint:#e6f0f9; --accent-darkest:#031e3b; --accent-rgb:10,102,194; --accent-dark-rgb:6,55,107; --accent-2-rgb:127,184,238; --accent-darkest-rgb:3,30,59; --bg-1:#78abdd; --bg-2:#bfdcf6; --bg-3:#9dc2e7; --dark-1:#010c18; --dark-2:#02162b; }
.scheme-picker { display:grid; grid-template-columns:repeat(auto-fill, minmax(88px, 1fr)); gap:10px 6px; margin-top:6px; justify-items:stretch; }
.scheme-swatch { width:100%; box-sizing:border-box; text-align:center; white-space:nowrap; display:flex; flex-direction:column; align-items:center; gap:4px; font-size:11px; cursor:pointer; background:none; border:2px solid transparent; border-radius:10px; padding:6px; color:inherit; }
.scheme-swatch .dot { width:34px; height:34px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px #cbd5e0; }
.scheme-swatch.selected { border-color:var(--accent); }
body {
  box-sizing: border-box;
}

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

html,
body {
  height: 100%;
  width: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
  color: #2d3748;
  position: relative;
}

.bg-float {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  user-select: none;
  opacity: 0;
  animation: bgFloat var(--dur) ease-in-out var(--delay) infinite alternate;
  font-size: var(--size);
}

@keyframes bgFloat {
  0%   { transform: translate(0, 0) rotate(var(--r0)); opacity: 0; }
  10%  { opacity: var(--op); }
  90%  { opacity: var(--op); }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r1)); opacity: 0; }
}

body.dark-mode .bg-float { --op: 0.18; }

body.dark-mode {
  background: linear-gradient(135deg, var(--dark-1) 0%, var(--dark-2) 100%);
  color: var(--accent-tint);
}

body.dark-mode::before {
  opacity: 0.18;
}

.app-wrapper {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.header {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  padding: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

body.dark-mode .header {
  background: linear-gradient(135deg, var(--accent-darkest) 0%, var(--accent-dark) 100%);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.header-brand:hover {
  transform: translateY(-2px);
}

.header-brand-text {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-brand-icon {
  display: flex;
  align-items: center;
}

/* Responsive header logo (DMEG) */
.header-logo-img {
  width: clamp(40px, 6vw, 72px);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.22));
}

/* Icon images in sidebar/nav */
.sidebar-icon-img,
.nav-icon-img {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  flex: 0 0 20px;
}

.sidebar-icon-img__img,
.nav-icon-img__img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.menu-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }
}

.header h1 {
  font-size: 24px;
  color: white;
  margin: 0;
}

.header .tagline {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.header-btn .btn-icon {
  display: none;
}

.header-btn .btn-text {
  display: inline;
}

.header-btn.nav-toggle-btn {
  display: block;
}

@media (max-width: 768px) {
  .header-btn.nav-toggle-btn {
    display: none;
  }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .header-brand-text > div:last-child {
    display: none;
  }

  .header-top {
    padding: 12px 20px;
  }

  .header h1 {
    font-size: 20px;
  }

  .header .tagline {
    font-size: 12px;
  }

  .header-btn .btn-text {
    display: none;
  }

  .header-btn .btn-icon {
    display: inline;
  }

  .header-btn {
    padding: 10px;
    min-width: 40px;
  }
}

/* ===== Header lockup improvements (for your exact HTML) ===== */

/* Layout: let brand + actions share space nicely */
.header-top{
  gap: 18px;
}

/* Brand: ensure it can shrink properly without breaking */
.header-brand{
  min-width: 0;
}

/* Keep menu icon + brand aligned */
.header-brand-text{
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0; /* critical: prevents overflow issues */
}

/* Logo shouldn't shrink */
.header-brand-icon{
  flex: 0 0 auto;
}

/* Text column next to logo */
.header-brand-text > div:not(.header-brand-icon){
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0; /* allows ellipsis */
}

/* Title polish */
.header-brand-text h1{
  font-weight: 780;
  letter-spacing: 0.2px;
  line-height: 1.05;
  font-size: clamp(18px, 2.1vw, 32px);
  margin: 0;

  /* Optional: if title gets too long, keep it in one line */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw; /* prevents pushing actions off-screen */
}

/* Tagline polish */
.header-brand-text .tagline{
  margin: 0;
  font-size: clamp(12px, 1.15vw, 16px);
  line-height: 1.25;
  color: rgba(255,255,255,0.88);

  /* keep line length readable */
  max-width: 52ch;

  /* graceful trim if space is tight */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions: don't force-wrap too early */
.header-actions{
  flex: 0 0 auto;
  gap: 10px;
}

/* Optional: a subtle divider line for a more “product” feel */
.header{
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

/* Tablet: allow 2-line title if you prefer readability over ellipsis */
@media (max-width: 980px){
  .header-brand-text h1{
    white-space: normal;      /* allow wrap */
    line-height: 1.1;
    max-width: 56vw;
  }
}

/* Mobile: you already hide the tagline container; keep title readable */
@media (max-width: 768px){
  .header-brand-text h1{
    font-size: 20px;
    max-width: 60vw;
  }

  /* If you want tagline to still appear on mobile, remove your existing rule
     that hides the entire text block and instead just hide tagline:
     .header-brand-text .tagline { display:none; }
  */
}

.nav-menu {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.nav-menu.open {
  max-height: 300px;
  padding: 16px 40px;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav-links li {
  margin: 0;
}

.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.3s ease;
  display: block;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  width: 280px;
  height: 100%;
  background: #2d3748;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  transition: left 0.3s ease;
  z-index: 200;
  overflow-y: auto;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0;
}

.sidebar-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sidebar-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.question-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: flex-end;
  margin-bottom: 15px;
}

.icon-btn {
  background: #f0f4f8;
  border: 2px solid #3f8fa6;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
  transition: 0.2s ease;
}

.icon-btn:hover {
  background: #d9edf2;
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


.sidebar-section {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-menu li {
  margin-bottom: 8px;
}

.sidebar-menu a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
}

.sidebar-menu a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  display: none;
}

.sidebar-overlay.open {
  display: block;
}

/* ── AI Disclosure ── */
.ai-disclosure-section {
  background: #f7f9fc;
  padding: 40px 24px;
  border-top: 3px solid #2d6a8f;
}
body.dark-mode .ai-disclosure-section {
  background: #1a202c;
  border-top-color: var(--accent);
}
.ai-disclosure-inner {
  max-width: 760px;
  margin: 0 auto;
}
.ai-disclosure-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a3a4a;
  margin: 0 0 4px;
}
body.dark-mode .ai-disclosure-title { color: #e2e8f0; }
.ai-disclosure-subtitle {
  font-size: 13px;
  color: #718096;
  margin: 0 0 20px;
}
.ai-disclosure-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 24px;
}
body.dark-mode .ai-disclosure-card {
  background: #2d3748;
  border-color: #4a5568;
}
.ai-disclosure-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0;
}
.ai-disclosure-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 8px 0;
}
body.dark-mode .ai-disclosure-divider { border-color: #4a5568; }
.ai-disc-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}
.ai-disc-icon--ai {
  background: #e6f7f5;
  color: #2d9e8f;
  border: 1px solid #b2e4df;
}
.ai-disc-icon--check {
  background: #fff8e6;
  color: #d69e2e;
  border: 1px solid #f6e0a0;
}
.ai-disc-text {
  font-size: 14px;
  color: #4a5568;
  line-height: 1.6;
  margin: 0;
  padding-top: 6px;
}
body.dark-mode .ai-disc-text { color: #a0aec0; }
body.dark-mode .ai-disc-icon--ai  { background: #1a3a38; border-color: #2d6b65; }
body.dark-mode .ai-disc-icon--check { background: #3a2e10; border-color: #7a5c10; }

.footer {
  background: #2d3748;
  color: white;
  padding: 40px 20px 20px;
  margin-top: auto;
  border-top: 3px solid #d6d6d6;
}

body.dark-mode .footer {
  border-top-color: #1a2332;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 32px;
  margin-bottom: 32px;
}

.footer-section h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--accent);
}

body.dark-mode .footer-section h3 {
  color: var(--accent-2);
}

.footer-section p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 12px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.footer-links a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--accent);
}

body.dark-mode .footer-links a:hover {
  color: var(--accent-2);
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}
.footer-ai-disclosure-link {
  display: inline-block;
  margin-top: 8px;
  color: #4ecdc4;
  font-size: 13px;
  text-decoration: none;
}
.footer-ai-disclosure-link:hover { text-decoration: underline; }

.main-content {
  flex: 1;
  padding: 40px 20px;
  width: 100%;
  display: flex;
  gap: 30px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }
}

.content-area {
  flex: 1;
  min-width: 0;
}

.right-sidebar {
  width: 350px;
  flex-shrink: 0;
  display: none;
}

@media (min-width: 1025px) {
  .right-sidebar {
    display: block;
  }
}

.right-sidebar-card {
  background: #fffef7;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid #d6d6d6;
  margin-bottom: 24px;
  position: sticky;
  top: 90px;
}

body.dark-mode .right-sidebar-card {
  background: #1a2332;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: #2d3748;
}

.sidebar-card-title {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark-mode .sidebar-card-title {
  color: var(--accent-tint);
}

.sidebar-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #d6d6d6;
  padding-bottom: 0;
}

body.dark-mode .sidebar-tabs {
  border-bottom-color: #2d3748;
}

.sidebar-tab, .sidebar-ptab {
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #718096;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  margin-bottom: -2px;
}

body.dark-mode .sidebar-tab, body.dark-mode .sidebar-ptab {
  color: var(--accent-soft);
}

.sidebar-tab.active, .sidebar-ptab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

body.dark-mode .sidebar-tab.active, body.dark-mode .sidebar-ptab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.sidebar-leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-leaderboard-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  transition: all 0.3s ease;
}

body.dark-mode .sidebar-leaderboard-item {
  background: #0d1620;
  border-color: #2d3748;
}

.sidebar-leaderboard-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-leaderboard-item.current-user {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.05);
}

body.dark-mode .sidebar-leaderboard-item.current-user {
  border-color: var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.1);
}

.sidebar-rank {
  font-size: 16px;
  font-weight: 700;
  color: #718096;
  min-width: 30px;
  text-align: center;
}

body.dark-mode .sidebar-rank {
  color: var(--accent-soft);
}

.sidebar-rank.rank1 {
  color: #f6ad55;
}

.sidebar-rank.rank2 {
  color: #cbd5e0;
}

.sidebar-rank.rank3 {
  color: #ed8936;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  margin: 0 12px;
}

body.dark-mode .sidebar-avatar {
  background: var(--accent-dark);
}

.sidebar-info {
  flex: 1;
  min-width: 0;
}

.sidebar-name {
  font-size: 14px;
  font-weight: 600;
  color: #2d3748;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-mode .sidebar-name {
  color: var(--accent-tint);
}

.sidebar-score {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

body.dark-mode .sidebar-score {
  color: var(--accent-2);
}

.view-all-link {
  display: block;
  text-align: center;
  padding: 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.3s ease;
  margin-top: 12px;
}

body.dark-mode .view-all-link {
  color: var(--accent-2);
}

.view-all-link:hover {
  background: rgba(var(--accent-rgb), 0.1);
}

body.dark-mode .view-all-link:hover {
  background: rgba(var(--accent-2-rgb), 0.1);
}

.view {
  display: none;
  width: 100%;
}

.view.active {
  display: block;
}

/* Homepage Styles */
.homepage-container {
  max-width: 1200px;
  margin: 0 auto;
}

.homepage-hero {
  text-align: center;
  padding: 60px 20px;
  margin-bottom: 40px;
}

.homepage-title {
  font-size: 48px;
  font-weight: 800;
  color: white;
  margin-bottom: 20px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  line-height: 1.2;
}

.homepage-subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 32px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  line-height: 1.6;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.homepage-cta {
  background: white;
  color: var(--accent);
  border: none;
  padding: 16px 40px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .homepage-cta {
  background: var(--accent-dark);
  color: white;
}

.homepage-cta:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

body.dark-mode .homepage-cta:hover {
  background: var(--accent);
}

/* ── Title progression ladder ── */
.header-title-ladder-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px;
  background: rgba(0,0,0,0.15);
  border-top: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}
.header-title-ladder-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
  flex-shrink: 0;
}
.title-ladder {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 2px;
  flex: 1;
  padding-bottom: 0;
}
.title-ladder::-webkit-scrollbar { display: none; }
.title-rung {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 3px 6px;
  cursor: default;
  transition: transform 0.2s;
  min-width: 48px;
  flex-shrink: 0;
}
.title-rung:hover {
  transform: translateY(-2px);
}
.title-rung-icon { font-size: 16px; line-height: 1; }
.title-rung--active {
  position: relative;
}
.title-rung--active .title-rung-icon {
  filter: drop-shadow(0 0 5px rgba(255, 220, 80, 1));
  transform: scale(1.5);
  display: inline-block;
}
.title-rung--active::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffd700;
  margin: 3px auto 0;
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
}
.title-rung-arrow {
  font-size: 14px;
  color: rgba(255,255,255,0.30);
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
}
body.dark-mode .title-rung {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
body.dark-mode .title-rung:hover { background: rgba(255,255,255,0.16); }

.scroll-down-button {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  animation: bounce 2s infinite;
}

body.dark-mode .scroll-down-button {
  background: rgba(26, 35, 50, 0.95);
  border-color: var(--accent-2);
}

.scroll-down-button:hover {
  transform: translateX(-50%) translateY(-5px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  animation: none;
}

.scroll-down-button.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-15px);
  }
  60% {
    transform: translateX(-50%) translateY(-7px);
  }
}

@media (max-width: 768px) {
  .scroll-down-button {
    bottom: 25px;
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
}

.topics-section-title {
  font-size: 32px;
  font-weight: 700;
  color: white;
  text-align: center;
  margin-bottom: 40px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.topics-loading-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 60px;
}
.skeleton-card {
  height: 220px;
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(255,255,255,0.35) 25%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0.35) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
body.dark-mode .skeleton-card {
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 60px;
}

.topic-subject-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #4f46e5;
  background: #eef2ff;
  border: 1.5px solid #c7d2fe;
  border-radius: 20px;
  padding: 5px 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 16px 0 12px;
}
body.dark-mode .topic-subject-heading {
  color: #a5b4fc;
  background: #1e1b4b;
  border-color: #3730a3;
}

.topic-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 16px;
}

.topic-card {
  background: #fffef7;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

body.dark-mode .topic-card {
  background: #1a2332;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.topic-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  border-color: var(--accent);
}

body.dark-mode .topic-card:hover {
  border-color: var(--accent-2);
}

.topic-card.locked {
  opacity: 0.7;
  cursor: not-allowed;
}

.topic-card.locked:hover {
  transform: translateY(-4px);
}

.topic-icon {
  font-size: 64px;
  margin-bottom: 20px;
  display: block;
}

.topic-title {
  font-size: 24px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 12px;
}

body.dark-mode .topic-title {
  color: var(--accent-tint);
}

.topic-description {
  font-size: 15px;
  color: #718096;
  margin-bottom: 20px;
  line-height: 1.6;
  min-height: 72px;
}

body.dark-mode .topic-description {
  color: var(--accent-soft);
}

.topic-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding-top: 16px;
  border-top: 2px solid #d6d6d6;
}

body.dark-mode .topic-meta {
  border-top-color: #2d3748;
}

.topic-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #718096;
}

body.dark-mode .topic-meta-item {
  color: var(--accent-soft);
}

.topic-meta-icon {
  font-size: 16px;
}

.topic-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s ease;
}

body.dark-mode .topic-button {
  background: var(--accent-dark);
}

.topic-button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .topic-button:hover {
  background: var(--accent);
}

.topic-card.locked .topic-button {
  background: #cbd5e0;
  color: #718096;
  cursor: not-allowed;
}

body.dark-mode .topic-card.locked .topic-button {
  background: #2d3748;
  color: #4a5568;
}

.topic-card.locked .topic-button:hover {
  transform: none;
  box-shadow: none;
}

.lock-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(203, 213, 224, 0.9);
  color: #2d3748;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

body.dark-mode .lock-badge {
  background: rgba(45, 55, 72, 0.9);
  color: var(--accent-soft);
}

@media (max-width: 768px) {
  .homepage-title {
    font-size: 36px;
  }

  .homepage-subtitle {
    font-size: 18px;
  }

  .topics-grid {
    grid-template-columns: 1fr;
  }
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 30px;
  width: 100%;
}

.skill-subject-section {
  margin-top: 16px;
}

.skill-topic-section {
  margin-top: 20px;
}

.skill-topic-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: #4b5563;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #f9fafb;
  border-left: 3px solid #c7d2fe;
  border-radius: 0 8px 8px 0;
}
body.dark-mode .skill-topic-heading {
  color: #d1d5db;
  background: #1f2937;
  border-left-color: #4338ca;
}

.skill-topic-icon {
  font-size: 1.1em;
}

.skill-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 12px;
}

.skill-card {
  background-color: #fffef7;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border: 3px solid transparent;
  min-height: 150px;
}

.skill-card-content {
  margin-bottom: 20px;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.mode-button {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  text-align: center;
}

.practice-mode-btn {
  background: #48bb78;
  color: white;
  border-color: #48bb78;
}

.practice-mode-btn:hover {
  background: #38a169;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.challenge-mode-btn {
  background: #ed8936;
  color: white;
  border-color: #ed8936;
}

.challenge-mode-btn:hover {
  background: #dd6b20;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(237, 137, 54, 0.3);
}

body.dark-mode .practice-mode-btn {
  background: #2f855a;
  border-color: #2f855a;
}

body.dark-mode .practice-mode-btn:hover {
  background: #48bb78;
}

body.dark-mode .challenge-mode-btn {
  background: #c05621;
  border-color: #c05621;
}

body.dark-mode .challenge-mode-btn:hover {
  background: #ed8936;
}

body.dark-mode .skill-card {
  background-color: #1a2332;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.skill-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Coming-soon placeholder card */
.skill-card.skill-coming-soon {
  border: 2px dashed #cbd5e0;
  background: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 6px,
    rgba(0,0,0,0.018) 6px,
    rgba(0,0,0,0.018) 12px
  );
  opacity: 0.75;
}
.skill-card.skill-coming-soon .mode-button[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.coming-soon-badge {
  display: inline-block;
  background: #ecc94b;
  color: #744210;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
body.dark-mode .skill-card.skill-coming-soon {
  border-color: #4a5568;
  background: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 6px,
    rgba(255,255,255,0.03) 6px,
    rgba(255,255,255,0.03) 12px
  );
}
body.dark-mode .coming-soon-badge {
  background: #744210;
  color: #fefcbf;
}

/* Locked skill card (unmet prerequisites) */
.skill-card.skill-locked {
  opacity: 0.65;
  border-color: #cbd5e0;
  background-color: #f7f8fa;
  cursor: default;
}
.skill-card.skill-locked:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: none;
}
.skill-card.skill-locked .mode-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}
body.dark-mode .skill-card.skill-locked {
  background-color: #111827;
  border-color: #374151;
}

/* Prerequisite badge */
.skill-prereqs {
  margin: 8px 0 4px;
  font-size: 12px;
}
.prereq-locked {
  color: #c05621;
  font-weight: 600;
}
.prereq-met {
  color: #38a169;
  font-weight: 500;
}
body.dark-mode .prereq-locked { color: #fbd38d; }
body.dark-mode .prereq-met   { color: #68d391; }

.skill-title {
  font-size: 20px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 12px;
}

body.dark-mode .skill-title {
  color: var(--accent-tint);
}

.skill-description {
  font-size: 14px;
  color: #718096;
  margin-bottom: 16px;
  line-height: 1.5;
}

body.dark-mode .skill-description {
  color: var(--accent-soft);
}

.skill-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #d6d6d6;
}

body.dark-mode .skill-progress {
  border-top-color: #2d3748;
}

.progress-bar-container {
  flex: 1;
  height: 8px;
  background: #d6d6d6;
  border-radius: 4px;
  overflow: hidden;
  margin-right: 12px;
}

body.dark-mode .progress-bar-container {
  background: #2d3748;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #48bb78, #38a169);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.score-badge {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

body.dark-mode .score-badge {
  color: var(--accent-2);
}

.section-title {
  font-size: 28px;
  color: white;
  margin-bottom: 20px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.5px;
}

.back-button {
  background: #fffef7;
  color: var(--accent);
  border: 2px solid #d6d6d6;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.dark-mode .back-button {
  background: #1a2332;
  color: var(--accent-2);
  border-color: #2d3748;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.back-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.practice-container {
  background: #fffef7;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid #d6d6d6;
}

body.dark-mode .practice-container {
  background: #1a2332;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border-color: #2d3748;
}

.mode-indicator {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.mode-indicator.practice {
  background: #c6f6d5;
  color: #22543d;
  border: 2px solid #48bb78;
}

.mode-indicator.challenge {
  background: #feebc8;
  color: #7c2d12;
  border: 2px solid #ed8936;
}

body.dark-mode .mode-indicator.practice {
  background: #1a3a2e;
  color: #9ae6b4;
}

body.dark-mode .mode-indicator.challenge {
  background: #3a2415;
  color: #fbd38d;
}

/* ---- Challenge HUD ---- */
.challenge-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff8f0;
  border: 2px solid #ed8936;
  border-radius: 12px;
  padding: 10px 18px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

body.dark-mode .challenge-hud {
  background: #3a2415;
  border-color: #c05621;
}

.hud-lives {
  font-size: 20px;
  letter-spacing: 2px;
}

.hud-score {
  font-size: 20px;
  font-weight: 700;
  color: #c05621;
  margin-left: auto;
}

body.dark-mode .hud-score { color: #fbd38d; }

.hud-best {
  font-size: 13px;
  font-weight: 600;
  color: #975a16;
  opacity: 0.85;
}

body.dark-mode .hud-best { color: #f6ad55; }

.hud-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 700;
  color: #e53e3e;
  animation: streakPulse 0.6s ease;
}

@keyframes streakPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ---- Round Summary Modal ---- */
.round-summary-content {
  text-align: center;
}

.round-summary-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 24px 0;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.summary-stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}

body.dark-mode .summary-stat-value { color: var(--accent-2); }

.summary-stat-label {
  font-size: 13px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-pb-banner {
  background: linear-gradient(135deg, #f6c90e, #f39c12);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 15px;
  padding: 8px 20px;
  border-radius: 20px;
  margin-bottom: 8px;
  animation: streakPulse 0.6s ease;
}

.summary-speed-banner {
  background: linear-gradient(135deg, #6ee7f7, var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 8px 20px;
  border-radius: 20px;
  margin-bottom: 8px;
  animation: streakPulse 0.6s ease;
}

.hud-pb-hint {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(var(--accent-rgb), 0.75);
  border-radius: 20px;
  padding: 5px 14px;
  margin: -4px auto 8px;
  max-width: fit-content;
  animation: slideIn 0.4s ease;
}
body.dark-mode .hud-pb-hint { background: rgba(var(--accent-2-rgb), 0.25); }

.summary-pb-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.summary-pb-label { color: #718096; }
.summary-pb-value { font-weight: 700; color: var(--accent); font-size: 16px; }
body.dark-mode .summary-pb-label { color: #a0aec0; }
body.dark-mode .summary-pb-value { color: var(--accent-2); }

.summary-title-earned {
  display: inline-block;
  background: linear-gradient(135deg, #f6e05e, #ed8936);
  color: #744210;
  font-weight: 700;
  font-size: 15px;
  padding: 5px 16px;
  border-radius: 20px;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}
body.dark-mode .summary-title-earned {
  background: linear-gradient(135deg, #d69e2e, #c05621);
  color: #fff;
}

.summary-message {
  font-size: 16px;
  color: #4a5568;
  margin-bottom: 24px;
}

body.dark-mode .summary-message { color: #a0aec0; }

.leader-title-badge {
  font-size: 12px;
  background: linear-gradient(135deg, #f6e05e44, #ed893644);
  border: 1px solid #ed893688;
  border-radius: 10px;
  padding: 1px 8px;
  font-weight: 600;
  color: #744210;
  margin-right: 4px;
}
body.dark-mode .leader-title-badge {
  background: linear-gradient(135deg, #d69e2e22, #c0562122);
  border-color: #c0562166;
  color: #f6e05e;
}

.summary-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-button-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.modal-button-secondary:hover {
  background: #cbd5e0;
}

body.dark-mode .modal-button-secondary {
  background: #2d3748;
  color: #e2e8f0;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Let #question-controls wrap onto its own row instead of shrinking
     below its buttons' natural width and overflowing past the card edge
     on narrow screens (same overlap bug class as the teach-toolbar). */
  flex-wrap: wrap;
  row-gap: 8px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #d6d6d6;
}

body.dark-mode .question-header {
  border-bottom-color: #2d3748;
}

.question-number {
  font-size: 18px;
  color: #718096;
  font-weight: 600;
}

.current-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

body.dark-mode .current-score {
  color: var(--accent-2);
}

.question-text {
  font-size: 24px;
  color: #2d3748;
  margin-bottom: 30px;
  line-height: 1.6;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 24px 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.07);
}

body.dark-mode .question-text {
  color: var(--accent-tint);
  background: rgba(26, 35, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.question-diagram {
  margin: 30px 0;
  text-align: center;
}
body.dark-mode .question-diagram {
  margin: 30px 0;
  text-align: center;
  color: white;
}

.question-diagram svg {
  max-width: 100%;
  height: auto;
}

body.dark-mode .question-diagram svg {
  filter: invert(1) hue-rotate(180deg);
}

.answer-input {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  margin-bottom: 20px;
  transition: border-color 0.3s ease;
  background: #fffef7;
}

body.dark-mode .answer-input {
  background: #0d1620;
  border-color: #2d3748;
  color: var(--accent-tint);
}

.answer-input:focus {
  outline: none;
  border-color: var(--accent);
}

body.dark-mode .answer-input:focus {
  border-color: var(--accent-2);
}

.answer-input:disabled {
  background: #f7fafc;
  color: #a0aec0;
  cursor: not-allowed;
}

body.dark-mode .answer-input:disabled {
  background: #0d1620;
  color: #4a5568;
}

.submit-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

body.dark-mode .submit-button {
  background: var(--accent-dark);
}

.submit-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .submit-button:hover:not(:disabled) {
  background: var(--accent);
}

.submit-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Multiple-choice answer area ───────────────────────────────────────────── */
.mc-label {
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 12px;
}
body.dark-mode .mc-label { color: #a0c4d8; }

.mc-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 560px) {
  .mc-choices { grid-template-columns: 1fr 1fr; }
}

.mc-choice-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid #d6d6d6;
  border-radius: 10px;
  background: #fffef7;
  cursor: pointer;
  font-size: 17px;
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  width: 100%;
}
body.dark-mode .mc-choice-btn {
  background: #0d1620;
  border-color: #2d3748;
  color: var(--accent-tint);
}

.mc-choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #f0f8fb;
  transform: translateX(3px);
}
body.dark-mode .mc-choice-btn:hover:not(:disabled) {
  background: #112233;
  border-color: var(--accent-2);
}

.mc-choice-btn.selected {
  border-color: var(--accent);
  background: #e0f4f8;
  font-weight: 600;
}
body.dark-mode .mc-choice-btn.selected {
  border-color: var(--accent-2);
  background: #0a2840;
}

.mc-choice-btn.correct-reveal {
  border-color: #48bb78;
  background: #c6f6d5;
  color: #22543d;
}
body.dark-mode .mc-choice-btn.correct-reveal {
  border-color: #48bb78;
  background: #1a3d2a;
  color: #9ae6b4;
}

.mc-choice-btn.wrong-reveal {
  border-color: #f56565;
  background: #fed7d7;
  color: #742a2a;
  opacity: 0.7;
}
body.dark-mode .mc-choice-btn.wrong-reveal {
  border-color: #f56565;
  background: #3d1a1a;
  color: #feb2b2;
}

.mc-choice-btn:disabled { cursor: not-allowed; }

@keyframes mc-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.mc-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.mc-choice-btn.selected .mc-letter { background: #2c6e7a; }
.mc-choice-btn.correct-reveal .mc-letter { background: #48bb78; }
.mc-choice-btn.wrong-reveal .mc-letter { background: #f56565; }
body.dark-mode .mc-letter { background: #2d6a7a; }

.feedback {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.correct {
  background: #c6f6d5;
  color: #22543d;
  border: 2px solid #48bb78;
}

.feedback.incorrect {
  background: #fed7d7;
  color: #742a2a;
  border: 2px solid #f56565;
}

.explanation {
  margin-top: 10px;
  font-size: 14px;
  opacity: 0.9;
}

.next-button {
  background: #48bb78;
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 12px;
}

.next-button:hover {
  background: #38a169;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

/* Affective Input Panel Styles */
.affective-panel {
  margin-top: 30px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.08) 0%, rgba(var(--accent-2-rgb), 0.08) 100%);
  border: 2px solid var(--accent);
  border-radius: 12px;
  animation: slideIn 0.4s ease;
}

body.dark-mode .affective-panel {
  background: linear-gradient(135deg, rgba(var(--accent-dark-rgb), 0.3) 0%, rgba(var(--accent-2-rgb), 0.1) 100%);
  border-color: var(--accent-2);
}

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

.affective-title {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 24px;
  text-align: center;
}

body.dark-mode .affective-title {
  color: var(--accent-tint);
}

.affective-inputs {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 24px;
}

.affective-input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.affective-label {
  font-size: 16px;
  font-weight: 600;
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark-mode .affective-label {
  color: var(--accent-tint);
}

.affective-icon {
  font-size: 20px;
}

.affective-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #d6d6d6;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

body.dark-mode .affective-slider {
  background: #2d3748;
}

.affective-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.affective-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-dark);
}

body.dark-mode .affective-slider::-webkit-slider-thumb {
  background: var(--accent-2);
}

body.dark-mode .affective-slider::-webkit-slider-thumb:hover {
  background: #9ae6cf;
}

.affective-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.affective-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-dark);
}

body.dark-mode .affective-slider::-moz-range-thumb {
  background: var(--accent-2);
}

body.dark-mode .affective-slider::-moz-range-thumb:hover {
  background: #9ae6cf;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #718096;
  padding: 0 4px;
}

body.dark-mode .slider-labels {
  color: var(--accent-soft);
}

.emotion-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.emotion-btn {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 12px;
  padding: 16px;
  font-size: 32px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 70px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark-mode .emotion-btn {
  background: #0d1620;
  border-color: #2d3748;
}

.emotion-btn:hover {
  transform: scale(1.1);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .emotion-btn:hover {
  border-color: var(--accent-2);
  box-shadow: 0 4px 12px rgba(var(--accent-2-rgb), 0.3);
}

.emotion-btn.selected {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.15);
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}

body.dark-mode .emotion-btn.selected {
  border-color: var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.2);
  box-shadow: 0 0 0 3px rgba(var(--accent-2-rgb), 0.2);
}

.submit-affective-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

body.dark-mode .submit-affective-btn {
  background: var(--accent-dark);
}

.submit-affective-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .submit-affective-btn:hover {
  background: var(--accent);
}

/* ── Fuzzy Engine Transparency Feedback ── */
.affective-feedback { margin-top: 12px; }

.fuzzy-feedback {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
}
body.dark-mode .fuzzy-feedback { background: #0f2a3a; border-color: #164e63; }

.fuzzy-feedback-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; margin-bottom: 8px;
}
.fuzzy-badge {
  font-size: 11px; font-weight: 700; border-radius: 99px;
  padding: 2px 8px; margin-left: auto;
}
.fuzzy-badge-increased  { background: #dcfce7; color: #166534; }
.fuzzy-badge-decreased  { background: #fee2e2; color: #991b1b; }
.fuzzy-badge-maintained { background: #fef9c3; color: #854d0e; }
body.dark-mode .fuzzy-badge-increased  { background: #14532d; color: #86efac; }
body.dark-mode .fuzzy-badge-decreased  { background: #450a0a; color: #fca5a5; }
body.dark-mode .fuzzy-badge-maintained { background: #422006; color: #fde68a; }

.fuzzy-feedback-body {
  margin-bottom: 6px; color: #374151;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
body.dark-mode .fuzzy-feedback-body { color: #d1d5db; }

.fuzzy-diff-chip {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px;
}

.fuzzy-feedback-reason {
  color: #6b7280; font-size: 12px; font-style: italic; margin-bottom: 8px;
}
body.dark-mode .fuzzy-feedback-reason { color: #9ca3af; }

.fuzzy-details { font-size: 12px; color: #6b7280; }
.fuzzy-details summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.fuzzy-inputs-grid {
  display: grid; grid-template-columns: 1fr auto;
  gap: 2px 16px; margin-top: 6px; padding: 8px;
  background: rgba(0,0,0,.04); border-radius: 6px;
}
body.dark-mode .fuzzy-inputs-grid { background: rgba(255,255,255,.05); }
.fuzzy-inputs-grid span:nth-child(even) { font-weight: 600; text-align: right; }

/* Adaptive Difficulty Indicator */
.difficulty-indicator {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.difficulty-easy {
  background: #c6f6d5;
  color: #22543d;
}

.difficulty-medium {
  background: #feebc8;
  color: #7c2d12;
}

.difficulty-hard {
  background: #fed7d7;
  color: #742a2a;
}

body.dark-mode .difficulty-easy {
  background: #1a3a2e;
  color: #9ae6b4;
}

body.dark-mode .difficulty-medium {
  background: #3a2415;
  color: #fbd38d;
}

body.dark-mode .difficulty-hard {
  background: #3a1a1a;
  color: #fc8181;
}

.show-solution-button {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 12px;
}

body.dark-mode .show-solution-button {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.show-solution-button:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .show-solution-button:hover:not(:disabled) {
  background: var(--accent-2);
  color: var(--accent-darkest);
}

.show-solution-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #cbd5e0;
  color: #cbd5e0;
}

.hint-button {
  background: transparent;
  color: #48bb78;
  border: 2px solid #48bb78;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 12px;
}

.hint-button:hover:not(:disabled) {
  background: #48bb78;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.hint-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #cbd5e0;
  color: #cbd5e0;
}

.hint-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: 8px;
  background: #f0fff4;
  border: 2px solid #48bb78;
  display: none;
}

body.dark-mode .hint-box {
  background: #1a3a2e;
  border-color: #48bb78;
}

.hint-box.show {
  display: block;
}

.hint-title {
  font-size: 18px;
  font-weight: 700;
  color: #22543d;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark-mode .hint-title {
  color: #9ae6b4;
}

.hint-content {
  background: #f0fff4;
  padding: 16px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.8;
  color: #2d3748;
  border: 1px solid #9ae6b4;
  overflow-x: auto;
}

/* Long MathJax equations (e.g. competition-problem hints) scroll horizontally
   instead of overflowing their containing box. */
mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

body.dark-mode .hint-content {
  background: #0f1f1a;
  border-color: #2d4a3e;
  color: #c6f6d5;
}

.hint-content strong {
  color: #22543d;
  display: block;
  margin-top: 12px;
  margin-bottom: 6px;
}

body.dark-mode .hint-content strong {
  color: #9ae6b4;
}

.hint-content strong:first-child {
  margin-top: 0;
}

.hint-formula {
  background: #e6f4ea;
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-family: "Courier New", monospace;
  border-left: 4px solid #48bb78;
}

body.dark-mode .hint-formula {
  background: #0a1510;
  color: #9ae6b4;
}

.solution-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: 8px;
  background: #edf2f7;
  border: 2px solid #cbd5e0;
  display: none;
}

body.dark-mode .solution-box {
  background: #0d1620;
  border-color: #2d3748;
}

.solution-box.show {
  display: block;
}

.solution-title {
  font-size: 18px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark-mode .solution-title {
  color: var(--accent-tint);
}

.solution-steps {
  list-style: none;
  padding: 0;
}

.solution-step {
  padding: 12px;
  margin-bottom: 10px;
  background: #fffef7;
  border-radius: 6px;
  border-left: 4px solid var(--accent);
  font-size: 15px;
  line-height: 1.6;
  color: #4a5568;
  border: 1px solid #d6d6d6;
  border-left: 4px solid var(--accent);
}

body.dark-mode .solution-step {
  background: #1a2332;
  border-left-color: var(--accent-2);
  color: var(--accent-soft);
  border-color: #2d3748;
}

.solution-step strong {
  color: #2d3748;
  display: block;
  margin-bottom: 4px;
}

body.dark-mode .solution-step strong {
  color: var(--accent-tint);
}

.solution-final {
  margin-top: 16px;
  padding: 16px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

body.dark-mode .solution-final {
  background: var(--accent-dark);
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px 0;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: #fffef7;
  border-radius: 12px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
  border: 2px solid #d6d6d6;
  margin: auto;
  max-height: 90vh;
  overflow-y: auto;
}

body.dark-mode .modal-content {
  background: #1a2332;
  border-color: #2d3748;
}

.modal-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  color: #742a2a;
  margin-bottom: 16px;
}

.modal-message {
  font-size: 16px;
  color: #4a5568;
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: underline;
  margin-bottom: 24px;
  font-weight: 600;
}

body.dark-mode .modal-link {
  color: var(--accent-2);
}

.modal-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 40px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.dark-mode .modal-button {
  background: var(--accent-dark);
}

.modal-button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .modal-button:hover {
  background: var(--accent);
}

/* Auth Modal Styles */
.auth-modal {
  max-width: 450px;
  position: relative;
}

.auth-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 24px;
  color: #718096;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.auth-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2d3748;
}

body.dark-mode .auth-close {
  color: var(--accent-soft);
}

body.dark-mode .auth-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-tint);
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
}

body.dark-mode .auth-title {
  color: var(--accent-tint);
}

.auth-subtitle {
  font-size: 16px;
  color: #718096;
  margin-bottom: 32px;
}

body.dark-mode .auth-subtitle {
  color: var(--accent-soft);
}

.auth-form {
  width: 100%;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 8px;
}

body.dark-mode .form-group label {
  color: var(--accent-tint);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  transition: border-color 0.3s ease;
  background: #fffef7;
  color: #2d3748;
}

body.dark-mode .form-group input[type="text"],
body.dark-mode .form-group input[type="email"],
body.dark-mode .form-group input[type="password"] {
  background: #0d1620;
  border-color: #2d3748;
  color: var(--accent-tint);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

body.dark-mode .form-group input:focus {
  border-color: var(--accent-2);
}

.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4a5568;
  cursor: pointer;
  font-weight: 400;
}

body.dark-mode .checkbox-label {
  color: var(--accent-soft);
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}

.auth-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

body.dark-mode .auth-link {
  color: var(--accent-2);
}

body.dark-mode .auth-link:hover {
  color: #9ae6cf;
}

.auth-button {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 24px;
}

body.dark-mode .auth-button {
  background: var(--accent-dark);
}

.auth-button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .auth-button:hover {
  background: var(--accent);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: #a0aec0;
  font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #d6d6d6;
}

body.dark-mode .auth-divider::before,
body.dark-mode .auth-divider::after {
  border-bottom-color: #2d3748;
}

.auth-divider span {
  padding: 0 12px;
}

.auth-footer {
  text-align: center;
  font-size: 15px;
  color: #4a5568;
}

body.dark-mode .auth-footer {
  color: var(--accent-soft);
}

/* Google Sign-In button */
.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: #fff;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: #3c4043;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  margin-bottom: 4px;
}
.google-signin-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
body.dark-mode .google-signin-btn {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}
body.dark-mode .google-signin-btn:hover {
  background: #374151;
}

/* User Menu */
.user-menu {
  position: relative;
  display: none;
  align-items: center;
  gap: 8px;
}

.user-menu.active {
  display: flex;
}

.nav-title-chip {
  display: none;
  align-items: center;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  cursor: default;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}
.nav-title-chip:hover {
  background: rgba(255,255,255,0.26);
}
body.dark-mode .nav-title-chip {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.20);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.user-avatar:hover {
  background: var(--accent-dark);
  border-color: white;
}

body.dark-mode .user-avatar {
  background: var(--accent-dark);
}

body.dark-mode .user-avatar:hover {
  background: var(--accent);
}

.user-dropdown {
  position: absolute;
  top: 50px;
  right: 0;
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  display: none;
  z-index: 100;
}

body.dark-mode .user-dropdown {
  background: #1a2332;
  border-color: #2d3748;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-dropdown.show {
  display: block;
}

.user-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid #d6d6d6;
}

body.dark-mode .user-dropdown-header {
  border-bottom-color: #2d3748;
}

.user-dropdown-name {
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}

body.dark-mode .user-dropdown-name {
  color: var(--accent-tint);
}

.user-dropdown-email {
  font-size: 13px;
  color: #718096;
}

body.dark-mode .user-dropdown-email {
  color: var(--accent-soft);
}

.user-dropdown-menu {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.user-dropdown-menu li {
  margin: 0;
}

.user-dropdown-menu a,
.user-dropdown-menu button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: #4a5568;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.3s ease;
}

body.dark-mode .user-dropdown-menu a,
body.dark-mode .user-dropdown-menu button {
  color: var(--accent-soft);
}

.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover {
  background: #f7fafc;
}

body.dark-mode .user-dropdown-menu a:hover,
body.dark-mode .user-dropdown-menu button:hover {
  background: #2d3748;
}

.user-dropdown-divider {
  height: 1px;
  background: #d6d6d6;
  margin: 8px 0;
}

body.dark-mode .user-dropdown-divider {
  background: #2d3748;
}

/* Avatar Selection Styles */
.avatar-section {
  margin-bottom: 24px;
  text-align: left;
}

/* Collapsible avatar picker — collapsed by default, showing just the current
   selection, so a 70+ option grid doesn't dominate the register/edit forms. */
.avatar-picker { border: none; }
.avatar-picker-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.avatar-picker-summary::-webkit-details-marker { display: none; }
body.dark-mode .avatar-picker-summary { border-color: #2d3748; }
.avatar-picker-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: #f7fafc;
  flex-shrink: 0;
}
body.dark-mode .avatar-picker-preview { background: #0d1620; }
.avatar-picker-text {
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  flex: 1;
}
body.dark-mode .avatar-picker-text { color: var(--accent-tint); }
.avatar-picker-chevron {
  color: #a0aec0;
  transition: transform 0.2s ease;
}
.avatar-picker[open] .avatar-picker-chevron { transform: rotate(180deg); }
.avatar-picker .avatar-grid {
  margin-top: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 2px;
}

.avatar-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 12px;
}

body.dark-mode .avatar-label {
  color: var(--accent-tint);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.avatar-option {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  background: #f7fafc;
}

body.dark-mode .avatar-option {
  background: #0d1620;
}

.avatar-option:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

body.dark-mode .avatar-option:hover {
  border-color: var(--accent-2);
}

.avatar-option.selected {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

body.dark-mode .avatar-option.selected {
  border-color: var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.1);
  box-shadow: 0 0 0 2px rgba(var(--accent-2-rgb), 0.2);
}

/* Leaderboard Styles */
.leaderboard-container {
  background: #fffef7;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid #d6d6d6;
}

body.dark-mode .leaderboard-container {
  background: #1a2332;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border-color: #2d3748;
}

/* Leaderboard type switcher (Score / Badges) */
.leaderboard-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.leaderboard-type-tab {
  background: #e2e8f0;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.2s ease;
}
.leaderboard-type-tab.active {
  background: var(--accent);
  color: #fff;
}
.leaderboard-type-tab:hover:not(.active) { background: #cbd5e0; }
body.dark-mode .leaderboard-type-tab { background: #2d3748; color: var(--accent-soft); }
body.dark-mode .leaderboard-type-tab.active { background: var(--accent); color: #fff; }
body.dark-mode .leaderboard-type-tab:hover:not(.active) { background: #3d4a5c; }

.leaderboard-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
  border-bottom: 2px solid #d6d6d6;
  padding-bottom: 0;
}

body.dark-mode .leaderboard-tabs {
  border-bottom-color: #2d3748;
}

.leaderboard-tab {
  background: transparent;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #718096;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  margin-bottom: -2px;
}

body.dark-mode .leaderboard-tab {
  color: var(--accent-soft);
}

.leaderboard-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

body.dark-mode .leaderboard-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.leaderboard-tab:hover:not(.active) {
  color: #4a5568;
}

body.dark-mode .leaderboard-tab:hover:not(.active) {
  color: var(--accent-tint);
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 20px;
  margin-bottom: 12px;
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  transition: all 0.3s ease;
}

body.dark-mode .leaderboard-item {
  background: #0d1620;
  border-color: #2d3748;
}

.leaderboard-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaderboard-item.current-user {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.05);
}

body.dark-mode .leaderboard-item.current-user {
  border-color: var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.1);
}

.leaderboard-rank {
  font-size: 24px;
  font-weight: 700;
  color: #718096;
  min-width: 50px;
  text-align: center;
}

body.dark-mode .leaderboard-rank {
  color: var(--accent-soft);
}

.leaderboard-rank.top3 {
  font-size: 28px;
}

.leaderboard-rank.rank1 {
  color: #f6ad55;
}

.leaderboard-rank.rank2 {
  color: #cbd5e0;
}

.leaderboard-rank.rank3 {
  color: #ed8936;
}

.leaderboard-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  margin: 0 20px;
}

body.dark-mode .leaderboard-avatar {
  background: var(--accent-dark);
}

.leaderboard-info {
  flex: 1;
}

.leaderboard-name {
  font-size: 18px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}

body.dark-mode .leaderboard-name {
  color: var(--accent-tint);
}

.leaderboard-stats {
  font-size: 14px;
  color: #718096;
}

body.dark-mode .leaderboard-stats {
  color: var(--accent-soft);
}

.leaderboard-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-left: 20px;
}

body.dark-mode .leaderboard-score {
  color: var(--accent-2);
}

/* Badges Styles */
.badges-container {
  background: #fffef7;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid #d6d6d6;
}

body.dark-mode .badges-container {
  background: #1a2332;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  border-color: #2d3748;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.badge-card {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s ease;
}

body.dark-mode .badge-card {
  background: #0d1620;
  border-color: #2d3748;
}

.badge-card.earned {
  border-color: #48bb78;
  background: rgba(72, 187, 120, 0.05);
}

body.dark-mode .badge-card.earned {
  background: rgba(72, 187, 120, 0.1);
}

.badge-card.locked {
  opacity: 0.5;
}

.badge-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.badge-icon {
  font-size: 64px;
  margin-bottom: 12px;
  filter: grayscale(100%);
}

.badge-card.earned .badge-icon {
  filter: grayscale(0%);
  animation: badgePop 0.5s ease;
}

@keyframes badgePop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.badge-name {
  font-size: 18px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
}

body.dark-mode .badge-name {
  color: var(--accent-tint);
}

.badge-description {
  font-size: 14px;
  color: #718096;
  line-height: 1.5;
}

body.dark-mode .badge-description {
  color: var(--accent-soft);
}

.badge-progress {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #d6d6d6;
}

body.dark-mode .badge-progress {
  border-top-color: #2d3748;
}

.badge-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

body.dark-mode .badge-progress-bar {
  background: rgba(255, 255, 255, 0.1);
}

.badge-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 10px;
  transition: width 0.5s ease;
}

body.dark-mode .badge-progress-fill {
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 100%);
}

.badge-card.earned .badge-progress-fill {
  background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
}

.badge-progress-text {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
}

body.dark-mode .badge-progress-text {
  color: var(--accent-2);
}

.badge-card.earned .badge-progress-text {
  color: #48bb78;
}
body.dark-mode .badge-progress {
  border-top-color: #2d3748;
  color: var(--accent-2);
}

.badge-card.earned .badge-progress {
  color: #48bb78;
}

.badge-earned-date {
  font-size: 12px;
  color: #718096;
  margin-top: 8px;
  font-style: italic;
}

body.dark-mode .badge-earned-date {
  color: var(--accent-soft);
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

body.dark-mode .stat-card {
  background: #0d1620;
  border-color: #2d3748;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

body.dark-mode .stat-value {
  color: var(--accent-2);
}

.stat-label {
  font-size: 14px;
  color: #718096;
  font-weight: 600;
}

body.dark-mode .stat-label {
  color: var(--accent-soft);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #718096;
}

body.dark-mode .empty-state {
  color: var(--accent-soft);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.empty-state-subtitle {
  font-size: 14px;
}

/* Teacher Styles */
.teacher-only {
  display: none !important;
}

body.teacher-mode .teacher-only {
  display: block !important;
}

body.teacher-mode .nav-links .teacher-only {
  display: list-item !important;
}

.teacher-dashboard {
  max-width: 1200px;
  margin: 0 auto;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.dashboard-card {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.dark-mode .dashboard-card {
  background: #1a2332;
  border-color: #2d3748;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

body.dark-mode .dashboard-card:hover {
  border-color: var(--accent-2);
}

.dashboard-card-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.dashboard-card-title {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 12px;
}

body.dark-mode .dashboard-card-title {
  color: var(--accent-tint);
}

.dashboard-card-value {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

body.dark-mode .dashboard-card-value {
  color: var(--accent-2);
}

.dashboard-card-label {
  font-size: 14px;
  color: #718096;
}

body.dark-mode .dashboard-card-label {
  color: var(--accent-soft);
}

.quick-actions {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 12px;
  padding: 32px;
}

body.dark-mode .quick-actions {
  background: #1a2332;
  border-color: #2d3748;
}

.quick-actions h3 {
  font-size: 24px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 20px;
}

body.dark-mode .quick-actions h3 {
  color: var(--accent-tint);
}

.action-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

body.dark-mode .action-btn {
  background: var(--accent-dark);
}

.action-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .action-btn:hover {
  background: var(--accent);
}

.teacher-container {
  max-width: 1200px;
  margin: 0 auto;
}

.teacher-back {
  margin-bottom: 20px;
}

.classes-grid,
.lessons-grid,
.worksheets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

/* ── Lesson sequence builder ── */
.lesson-skill-adder { position: relative; }
.lesson-skill-adder input {
  width: 100%; padding: 10px 14px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: 14px; box-sizing: border-box;
}
.lesson-skill-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 200;
  background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); max-height: 220px; overflow-y: auto;
}
body.dark-mode .lesson-skill-dropdown { background: #1e2d3d; border-color: #3d4f63; }
.lesson-skill-option {
  padding: 10px 14px; font-size: 13px; cursor: pointer; transition: background .15s;
}
.lesson-skill-option:hover { background: #f0f4ff; }
body.dark-mode .lesson-skill-option:hover { background: #2a3f55; }
.lesson-skill-option.already-added { opacity: .45; cursor: default; }
.lesson-seq-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
}
.lesson-sequence { display: flex; flex-direction: column; gap: 6px; }
.lesson-seq-row {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 8px 12px;
}
body.dark-mode .lesson-seq-row { background: #1a2d3e; border-color: #2d3f52; }
.lesson-seq-num {
  min-width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lesson-seq-title { flex: 1; font-size: 13px; font-weight: 500; }
.lesson-seq-controls { display: flex; gap: 4px; }
.lesson-seq-btn {
  border: none; background: transparent; cursor: pointer; padding: 3px 6px;
  border-radius: 4px; font-size: 11px; color: #718096; transition: background .15s;
}
.lesson-seq-btn:hover:not(:disabled) { background: #e2e8f0; color: #2d3748; }
.lesson-seq-btn:disabled { opacity: .3; cursor: default; }
.lesson-seq-remove:hover:not(:disabled) { background: #fed7d7 !important; color: #c53030 !important; }

/* ── Lesson cards (richer layout) ── */
.lesson-card-header { margin-bottom: 10px; }
.lesson-card-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.lesson-card-meta { display: flex; gap: 16px; font-size: 12px; color: #718096; }
.lesson-seq-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.lesson-seq-chip {
  background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 500;
  border-radius: 6px; padding: 3px 9px;
}
body.dark-mode .lesson-seq-chip { background: #2d3a5e; color: #a5b4fc; }
.lesson-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.lesson-deliver-btn {
  flex: 1; padding: 9px 0; background: #6b46c1; color: #fff; border: none;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.lesson-deliver-btn:hover { background: #553c9a; }
.lesson-delete-btn {
  padding: 9px 14px; background: transparent; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 14px; cursor: pointer; color: #718096; transition: all .15s;
}
.lesson-delete-btn:hover { background: #fed7d7; border-color: #fc8181; color: #c53030; }

/* ── Lesson nav bar in teach-view ── */
.teach-lesson-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent); color: #fff; padding: 8px 16px; gap: 12px;
}
body.dark-mode .teach-lesson-bar { background: #2a5f72; }
.teach-lesson-info { display: flex; flex-direction: column; align-items: center; flex: 1; }
.teach-lesson-name { font-size: 13px; font-weight: 700; }
.teach-lesson-pos { font-size: 11px; opacity: .8; }
.teach-lesson-nav-btn {
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.4);
  color: #fff; border-radius: 6px; padding: 5px 12px; font-size: 12px;
  font-weight: 600; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.teach-lesson-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.35); }
.teach-lesson-nav-btn:disabled { opacity: .4; cursor: default; }

/* Teacher answer panel */
.teach-answer-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 12px 0 4px;
  padding: 10px 16px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 8px;
  font-size: 0.95rem;
}
body.dark-mode .teach-answer-panel {
  background: #2d2408;
  border-color: #d97706;
}
.teach-answer-label {
  font-weight: 600;
  color: #92400e;
  white-space: nowrap;
}
body.dark-mode .teach-answer-label { color: #fbbf24; }
.teach-answer-value {
  font-family: monospace;
  font-size: 1rem;
  color: #1e40af;
  font-weight: 600;
  background: rgba(255,255,255,.6);
  padding: 2px 8px;
  border-radius: 4px;
}
body.dark-mode .teach-answer-value {
  color: #93c5fd;
  background: rgba(0,0,0,.3);
}
.teach-answer-hint {
  font-size: 0.82rem;
  color: #78716c;
  font-style: italic;
}
body.dark-mode .teach-answer-hint { color: #a8a29e; }

/* Answer input placeholder hint */
#answer-input::placeholder { color: #94a3b8; font-style: italic; }

.class-card,
.lesson-card,
.worksheet-card {
  background: #fffef7;
  border: 2px solid #d6d6d6;
  border-radius: 12px;
  padding: 24px;
  transition: all 0.3s ease;
}

body.dark-mode .class-card,
body.dark-mode .lesson-card,
body.dark-mode .worksheet-card {
  background: #1a2332;
  border-color: #2d3748;
}

.class-card:hover,
.lesson-card:hover,
.worksheet-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

body.dark-mode .class-card:hover,
body.dark-mode .lesson-card:hover,
body.dark-mode .worksheet-card:hover {
  border-color: var(--accent-2);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
}

body.dark-mode .card-title {
  color: var(--accent-tint);
}

.card-code {
  background: var(--accent);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

body.dark-mode .card-code {
  background: var(--accent-dark);
}

.card-description {
  font-size: 14px;
  color: #718096;
  margin-bottom: 16px;
  line-height: 1.5;
}

body.dark-mode .card-description {
  color: var(--accent-soft);
}

.card-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  padding-top: 16px;
  border-top: 1px solid #d6d6d6;
}

body.dark-mode .card-meta {
  border-top-color: #2d3748;
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #718096;
}

body.dark-mode .card-meta-item {
  color: var(--accent-soft);
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  text-align: center;
}

.card-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

body.dark-mode .card-btn.primary {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.card-btn.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

body.dark-mode .card-btn.primary:hover {
  background: var(--accent);
}

.card-btn.secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

body.dark-mode .card-btn.secondary {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.card-btn.secondary:hover {
  background: var(--accent);
  color: white;
}

body.dark-mode .card-btn.secondary:hover {
  background: var(--accent-2);
  color: var(--accent-darkest);
}

.teacher-modal {
  max-width: 500px;
}

.large-modal {
  max-width: 700px;
}

.skills-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding: 16px;
  background: #f7fafc;
  border-radius: 8px;
  border: 1px solid #d6d6d6;
}

body.dark-mode .skills-checkboxes {
  background: #0d1620;
  border-color: #2d3748;
}

.skill-checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fffef7;
  border-radius: 6px;
  border: 1px solid #d6d6d6;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.dark-mode .skill-checkbox-item {
  background: #1a2332;
  border-color: #2d3748;
}

.skill-checkbox-item:hover {
  border-color: var(--accent);
}

body.dark-mode .skill-checkbox-item:hover {
  border-color: var(--accent-2);
}

.skill-checkbox-item input[type="checkbox"] {
  cursor: pointer;
}

.skill-checkbox-label {
  flex: 1;
  cursor: pointer;
}

.skill-checkbox-title {
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}

body.dark-mode .skill-checkbox-title {
  color: var(--accent-tint);
}

.skill-checkbox-desc {
  font-size: 13px;
  color: #718096;
}

body.dark-mode .skill-checkbox-desc {
  color: var(--accent-soft);
}

/* Chatbot Styles */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  font-size: 32px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: all 0.3s ease;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.chatbot-fab:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 28px rgba(var(--accent-rgb), 0.5);
  animation: none;
}

body.dark-mode .chatbot-fab {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent-darkest) 100%);
  box-shadow: 0 4px 20px rgba(var(--accent-dark-rgb), 0.6);
}

body.dark-mode .chatbot-fab:hover {
  box-shadow: 0 6px 28px rgba(var(--accent-dark-rgb), 0.7);
}

@media (max-width: 768px) {
  .chatbot-fab {
    width: 56px;
    height: 56px;
    font-size: 28px;
    bottom: 20px;
    right: 20px;
  }
}

.chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 550px;
  background: #fffef7;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 2px solid #d6d6d6;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.chatbot-container.open {
  display: flex;
}

body.dark-mode .chatbot-container {
  background: #1a2332;
  border-color: #2d3748;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.chatbot-header {
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--accent-dark);
}

body.dark-mode .chatbot-header {
  background: linear-gradient(135deg, var(--accent-darkest) 0%, var(--accent-dark) 100%);
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.chatbot-title-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 2px 0;
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.9;
  margin: 0;
}

.chatbot-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatbot-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

body.dark-mode .chatbot-message-avatar {
  background: var(--accent-dark);
}

.chatbot-message.user .chatbot-message-avatar {
  background: #48bb78;
}

body.dark-mode .chatbot-message.user .chatbot-message-avatar {
  background: #2f855a;
}

.chatbot-message-bubble {
  background: #f7fafc;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #2d3748;
  border: 1px solid #e2e8f0;
}

body.dark-mode .chatbot-message-bubble {
  background: #0d1620;
  color: var(--accent-tint);
  border-color: #2d3748;
}

.chatbot-message.user .chatbot-message-bubble {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

body.dark-mode .chatbot-message.user .chatbot-message-bubble {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #718096;
  animation: typingBounce 1.4s infinite;
}

.chatbot-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

.chatbot-input-container {
  padding: 16px;
  border-top: 2px solid #d6d6d6;
  background: #fffef7;
}

body.dark-mode .chatbot-input-container {
  border-top-color: #2d3748;
  background: #0d1620;
}

.chatbot-input-wrapper {
  display: flex;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #d6d6d6;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
  background: #fffef7;
  color: #2d3748;
}

body.dark-mode .chatbot-input {
  background: #1a2332;
  border-color: #2d3748;
  color: var(--accent-tint);
}

.chatbot-input:focus {
  border-color: var(--accent);
}

body.dark-mode .chatbot-input:focus {
  border-color: var(--accent-2);
}

.chatbot-send-btn {
  background: var(--accent);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

body.dark-mode .chatbot-send-btn {
  background: var(--accent-dark);
}

.chatbot-send-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: scale(1.05);
}

body.dark-mode .chatbot-send-btn:hover:not(:disabled) {
  background: var(--accent);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chatbot-suggestion {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.dark-mode .chatbot-suggestion {
  background: rgba(var(--accent-2-rgb), 0.1);
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.chatbot-suggestion:hover {
  background: var(--accent);
  color: white;
}

body.dark-mode .chatbot-suggestion:hover {
  background: var(--accent-2);
  color: var(--accent-darkest);
}

@media (max-width: 768px) {
  .chatbot-container {
    width: min(380px, calc(100% - 20px));       /* a corner panel, not the whole screen: the question stays visible above it */
    height: min(55vh, 440px);
    bottom: 90px;
    right: 10px;
  }

  .chatbot-fab {
    bottom: 16px;
    right: 16px;
  }
}

@view-transition {
  navigation: auto;
}

.badge-card {
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.badge-card.locked {
  opacity: 0.75;
}

.progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4ade80, #22c55e);
}

.solution-diagram {
  list-style: none;
  margin: 1rem 0;
  text-align: center;
}

.diagram-wrapper svg {
  max-width: 100%;
  height: auto;
}

/* ── Teacher Class Detail ── */
.class-detail-tabs { display:flex; gap:8px; margin:18px 0 0; flex-wrap:wrap; }
.class-tab {
  padding:10px 20px; border:2px solid var(--accent); border-radius:8px;
  background:transparent; color:var(--accent); font-weight:600; cursor:pointer;
  transition:all .2s;
}
.class-tab.active, .class-tab:hover { background:var(--accent); color:#fff; }
body.dark-mode .class-tab { border-color:var(--accent-2); color:var(--accent-2); }
body.dark-mode .class-tab.active, body.dark-mode .class-tab:hover { background:var(--accent-2); color:#0d1620; }
.class-tab-panel { margin-top:20px; }
.tab-hint { color:#718096; font-size:14px; margin-bottom:14px; }

/* Roster */
.roster-card {
  display:flex; align-items:center; gap:14px;
  background:#fff; border:1px solid #e2e8f0; border-radius:10px;
  padding:14px 18px; margin-bottom:10px; cursor:pointer;
  transition:box-shadow .2s;
}
.roster-card:hover { box-shadow:0 4px 12px rgba(0,0,0,.08); }
body.dark-mode .roster-card { background:#0d1620; border-color:#2d3748; }
.roster-avatar { font-size:28px; width:44px; text-align:center; }
.roster-name { font-weight:700; font-size:16px; color:#2d3748; }
body.dark-mode .roster-name { color:var(--accent-tint); }
.roster-meta { font-size:13px; color:#718096; margin-top:2px; }
.roster-skills { margin-left:auto; display:flex; gap:6px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.risk-badge {
  padding:3px 10px; border-radius:20px; font-size:12px; font-weight:700;
}
.risk-badge.good  { background:#d1fae5; color:#065f46; }
.risk-badge.warn  { background:#fef3c7; color:#92400e; }
.risk-badge.risk  { background:#fee2e2; color:#991b1b; }
body.dark-mode .risk-badge.good  { background:#065f46; color:#d1fae5; }
body.dark-mode .risk-badge.warn  { background:#78350f; color:#fef3c7; }
body.dark-mode .risk-badge.risk  { background:#7f1d1d; color:#fee2e2; }

/* Heatmap */
.heatmap-row {
  display:flex; align-items:center; gap:12px;
  padding:10px 0; border-bottom:1px solid #e2e8f0;
}
body.dark-mode .heatmap-row { border-color:#2d3748; }
.heatmap-skill-name { width:200px; font-weight:600; font-size:14px; flex-shrink:0; }
.heatmap-bar-wrap { flex:1; background:#e2e8f0; border-radius:6px; height:18px; overflow:hidden; }
body.dark-mode .heatmap-bar-wrap { background:#2d3748; }
.heatmap-bar { height:100%; border-radius:6px; transition:width .4s; }
.heatmap-pct { width:48px; text-align:right; font-size:13px; font-weight:700; }

/* Assign Skills */
/* Assign skill collapsible picker */
.assign-picker {
  border: 2px solid #e2e8f0; border-radius: 10px; overflow: hidden;
  max-height: 340px; overflow-y: auto; background: #fff;
  margin-bottom: 2px;
}
body.dark-mode .assign-picker { background: #1a2535; border-color: #2d3748; }

.assign-grade-hdr {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: #f1f5f9; border: none; border-bottom: 1px solid #e2e8f0;
  cursor: pointer; font-size: 13px; font-weight: 700; color: #334155;
  text-align: left; user-select: none;
}
.assign-grade-hdr:hover { background: #e2e8f0; }
body.dark-mode .assign-grade-hdr { background: #1e293b; border-color: #2d3748; color: #94a3b8; }
body.dark-mode .assign-grade-hdr:hover { background: #263245; }

.assign-grade-arrow { font-size: 11px; color: #64748b; min-width: 12px; }
.assign-grade-count { margin-left: auto; font-size: 11px; font-weight: 500; color: #94a3b8; }

.assign-skill-item {
  padding: 8px 14px 8px 28px; font-size: 14px; color: #374151; cursor: pointer;
  border-bottom: 1px solid #f1f5f9; outline: none;
}
.assign-skill-item:last-child { border-bottom: none; }
.assign-skill-item:hover { background: #f0f9ff; }
.assign-skill-item:focus { background: #e0f2fe; }
.assign-skill-item.assign-skill-selected {
  background: #dbeafe; color: #1d4ed8; font-weight: 600;
}
body.dark-mode .assign-skill-item { color: #cbd5e1; border-color: #1e293b; }
body.dark-mode .assign-skill-item:hover { background: #1e3a5f; }
body.dark-mode .assign-skill-item.assign-skill-selected { background: #1e3a5f; color: #60a5fa; }

.assigned-skill-row {
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 14px; background:#f7fafc; border-radius:8px; margin-bottom:8px;
}
body.dark-mode .assigned-skill-row { background:#1a2535; }
.assigned-skill-name { font-weight:600; flex:1; }
.assigned-skill-difficulty {
  font-size:12px; font-weight:600; padding:4px 8px; border-radius:6px;
  border:1px solid #cbd5e0; background:#fff; color:#4a5568; cursor:pointer;
}
body.dark-mode .assigned-skill-difficulty { background:#0f1621; border-color:#2d3748; color:#cbd5e1; }

.assign-difficulty-row { display:flex; align-items:center; gap:10px; }
.assign-difficulty-label { font-size:13px; font-weight:600; color:#4a5568; }
body.dark-mode .assign-difficulty-label { color:#cbd5e1; }
.assign-difficulty-select {
  font-size:13px; font-weight:600; padding:6px 10px; border-radius:8px;
  border:1px solid #cbd5e0; background:#fff; color:#2d3748; cursor:pointer;
}
body.dark-mode .assign-difficulty-select { background:#1a2535; border-color:#2d3748; color:#cbd5e1; }

/* Assigned skills grouped by subject */
.asl-group { margin-bottom: 6px; }
.asl-group-hdr {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 700;
  color: #334155; text-align: left; user-select: none;
}
.asl-group-hdr[aria-expanded="true"] { border-radius: 8px 8px 0 0; border-bottom-color: transparent; }
.asl-group-hdr:hover { background: #e2e8f0; }
body.dark-mode .asl-group-hdr { background: #1e293b; border-color: #2d3748; color: #94a3b8; }
body.dark-mode .asl-group-hdr:hover { background: #263245; }
.asl-arrow { font-size: 11px; color: #64748b; min-width: 12px; }
.asl-group-title { flex: 1; }
.asl-group-count {
  background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 99px; min-width: 20px; text-align: center;
}
body.dark-mode .asl-group-count { background: #2d3748; color: #94a3b8; }
.asl-group-body .assigned-skill-row {
  border-radius: 0; border: 1px solid #e2e8f0; border-top: none; margin-bottom: 0;
}
.asl-group-body .assigned-skill-row:last-child { border-radius: 0 0 8px 8px; }
body.dark-mode .asl-group-body .assigned-skill-row { border-color: #2d3748; }
.unassign-btn {
  background:#fee2e2; color:#991b1b; border:none; padding:4px 12px;
  border-radius:6px; cursor:pointer; font-size:13px; font-weight:600;
}
.unassign-btn:hover { background:#fecaca; }

/* Student skill detail modal */
.student-skill-row {
  display:flex; align-items:center; gap:10px;
  padding:10px 0; border-bottom:1px solid #e2e8f0;
}
body.dark-mode .student-skill-row { border-color:#2d3748; }
.stu-skill-name { width:190px; font-size:14px; font-weight:600; flex-shrink:0; }
.stu-skill-bar-wrap { flex:1; background:#e2e8f0; border-radius:6px; height:14px; overflow:hidden; }
body.dark-mode .stu-skill-bar-wrap { background:#2d3748; }
.stu-skill-bar { height:100%; border-radius:6px; }
.stu-skill-pct { width:42px; text-align:right; font-size:13px; font-weight:700; }
.stu-diff-badge {
  width:60px; text-align:center; font-size:12px; padding:2px 6px;
  border-radius:12px; background:#e0f2fe; color:#0369a1; font-weight:600;
}
body.dark-mode .stu-diff-badge { background:#0c4a6e; color:#bae6fd; }
.student-skill-row-clickable { cursor:pointer; border-radius:8px; transition:background .12s; }
.student-skill-row-clickable:hover { background:#f7fafc; }
body.dark-mode .student-skill-row-clickable:hover { background:#2d3748; }
.stu-skill-path-arrow { font-size:20px; color:#a0aec0; flex-shrink:0; width:14px; text-align:center; }

/* Student skill learning-path modal */
.skill-path-row { display:flex; gap:10px; }
.skill-path-line { display:flex; flex-direction:column; align-items:center; flex-shrink:0; }
.skill-path-dot { width:12px; height:12px; border-radius:50%; margin-top:4px; flex-shrink:0; }
.skill-path-connector { flex:1; width:2px; background:#e2e8f0; min-height:24px; margin-top:2px; }
body.dark-mode .skill-path-connector { background:#2d3748; }
.skill-path-body { flex:1; padding-bottom:16px; }
.skill-path-head { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.skill-path-num { font-size:12px; font-weight:700; color:#718096; text-transform:uppercase; letter-spacing:.03em; }
.skill-path-result { font-size:14px; font-weight:700; }
.skill-path-when { font-size:12px; color:#a0aec0; margin-left:auto; }
.skill-path-meta { font-size:13px; color:#718096; display:flex; gap:14px; margin-top:2px; flex-wrap:wrap; }
.skill-path-tags { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.skill-path-tag {
  font-size:11px; padding:2px 8px; border-radius:10px;
  background:#edf2f7; color:#4a5568; font-weight:600;
}
body.dark-mode .skill-path-tag { background:#2d3748; color:#cbd5e0; }
.skill-path-tag--rapid { background:#fefcbf; color:#744210; }
.skill-path-tag--rapid.in-run { background:#fbd38d; color:#7b341e; }
body.dark-mode .skill-path-tag--rapid { background:#5f4b0d; color:#faf089; }
body.dark-mode .skill-path-tag--rapid.in-run { background:#7b4a12; color:#fbd38d; }
.skill-path-rapid-banner { margin:0 0 14px; padding:10px 12px; border-radius:8px; background:#fffaf0; border:1px solid #fbd38d; color:#7b341e; font-size:13px; line-height:1.5; text-align:left; }
body.dark-mode .skill-path-rapid-banner { background:#3a2a10; border-color:#7b4a12; color:#fbd38d; }
.rapid-flags-panel { margin:0 0 16px; padding:12px 14px; border:1px solid #fbd38d; background:#fffaf0; border-radius:10px; color:#7b341e; }
.rapid-flags-panel--clear { border-color:#c6f6d5; background:#f0fff4; color:#276749; font-size:13px; padding:8px 14px; }
.rapid-flags-head { font-size:15px; }
.rapid-flags-count { font-size:12px; font-weight:600; background:#fbd38d; border-radius:10px; padding:1px 8px; margin-left:6px; }
.rapid-flags-sub { font-size:12px; opacity:.85; margin:4px 0 8px; line-height:1.45; }
.rapid-flags-row { display:flex; gap:10px; align-items:flex-start; padding:6px 0; border-top:1px solid rgba(123,74,18,.15); flex-wrap:wrap; }
.rapid-flags-student { background:none; border:none; padding:2px 0; font:inherit; font-weight:700; color:#2d3748; cursor:pointer; text-decoration:underline dotted; min-width:140px; text-align:left; }
.rapid-flags-skills { display:flex; flex-wrap:wrap; gap:6px; flex:1; }
.rapid-flags-skill { font:inherit; font-size:12px; padding:3px 10px; border-radius:12px; border:1px solid #f6ad55; background:#fff; color:#7b341e; cursor:pointer; }
.rapid-flags-skill:hover, .rapid-flags-student:hover { background:#feebc8; }
body.dark-mode .rapid-flags-panel { background:#3a2a10; border-color:#7b4a12; color:#fbd38d; }
body.dark-mode .rapid-flags-panel--clear { background:#12301f; border-color:#276749; color:#9ae6b4; }
body.dark-mode .rapid-flags-student { color:#e2e8f0; }
body.dark-mode .rapid-flags-skill { background:#1a202c; border-color:#7b4a12; color:#fbd38d; }
body.dark-mode .rapid-flags-skill:hover, body.dark-mode .rapid-flags-student:hover { background:#4a3515; }
.stu-rapid-flag { font-size:11px; font-weight:700; padding:2px 8px; border-radius:10px; background:#fbd38d; color:#7b341e; white-space:nowrap; cursor:help; }
body.dark-mode .stu-rapid-flag { background:#7b4a12; color:#fbd38d; }
.skill-path-body[role="button"] { cursor:pointer; border-radius:8px; margin:0 0 6px; padding:4px 8px 12px; outline:none; transition:background .15s; min-width:0; }
.skill-path-body[role="button"]:hover, .skill-path-body[role="button"]:focus-visible { background:rgba(99,102,241,.07); }
.skill-path-toggle { color:#6366f1; font-weight:600; margin-left:auto; }
.skill-path-detail { text-align:left; margin-top:10px; padding:10px 12px; border:1px solid #e2e8f0; border-radius:8px; background:#fff; cursor:default; }
.skill-path-detail[hidden] { display:none; }
.skill-path-detail-label { display:block; font-size:11px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; color:#718096; margin-bottom:3px; }
.skill-path-q { font-size:15px; color:#1a202c; line-height:1.6; overflow-x:auto; }
.skill-path-q--missing { font-size:13px; color:#a0aec0; font-style:italic; }
.skill-path-answers { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:10px; }
.skill-path-ans { padding:6px 10px; border-radius:6px; overflow-x:auto; font-size:14px; }
.skill-path-ans.ok { background:#f0fff4; border:1px solid #c6f6d5; }
.skill-path-ans.no { background:#fff5f5; border:1px solid #fed7d7; }
.skill-path-typed { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; word-break:break-word; }
.skill-path-none { color:#a0aec0; font-style:italic; }
@media (max-width:520px) { .skill-path-answers { grid-template-columns:1fr; } }
body.dark-mode .skill-path-detail { background:#1a202c; border-color:#2d3748; }
body.dark-mode .skill-path-q { color:#e2e8f0; }
body.dark-mode .skill-path-ans.ok { background:#12301f; border-color:#276749; }
body.dark-mode .skill-path-ans.no { background:#351a1a; border-color:#9b2c2c; }

/* ── Teacher Home View ── */
.th-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.th-greeting { font-size: 26px; font-weight: 800; color: #2d3748; margin: 0; }
body.dark-mode .th-greeting { color: var(--accent-tint); }
.th-subtitle { color: #2d3748; margin: 4px 0 0; font-size: 16px; font-weight: 600; text-shadow: 0 1px 2px rgba(255,255,255,.55); }
body.dark-mode .th-subtitle { color: var(--accent-tint); text-shadow: none; }

.th-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px; margin-bottom: 28px;
}
@media (max-width: 900px) { .th-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .th-tiles { grid-template-columns: repeat(2, 1fr); } }

/* Quick actions bar */
.th-quick-actions {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 16px 20px; margin-top: 24px;
}
body.dark-mode .th-quick-actions { background: #0d1620; border-color: #2d3748; }
.th-qa-label {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #718096; margin-bottom: 12px;
}
body.dark-mode .th-qa-label { color: #4a5568; }
.th-qa-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.th-qa-btn {
  display: flex; align-items: center; gap: 7px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 9px 16px; font-size: 13px; font-weight: 500; color: #374151;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.th-qa-btn:hover { background: #f0f4ff; border-color: #a5b4fc; color: #3730a3; }
.th-qa-btn i { font-size: 15px; }
body.dark-mode .th-qa-btn { background: #1a2535; border-color: #2d3748; color: #cbd5e1; }
body.dark-mode .th-qa-btn:hover { background: #1e3a5f; border-color: #60a5fa; color: #93c5fd; }
.th-tile {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 22px 18px; text-align: center; cursor: pointer;
  transition: box-shadow .2s, transform .15s;
}
.th-tile:hover { box-shadow: 0 6px 20px rgba(0,0,0,.09); transform: translateY(-2px); }
body.dark-mode .th-tile { background: #0d1620; border-color: #2d3748; }
.th-tile-warn { border-color: #fc8181; background: #fff5f5; }
body.dark-mode .th-tile-warn { background: #2d1a1a; border-color: #fc8181; }
.th-tile-icon { font-size: 28px; margin-bottom: 8px; }
.th-tile-value { font-size: 32px; font-weight: 800; color: #2d3748; line-height: 1; }
body.dark-mode .th-tile-value { color: var(--accent-tint); }
.th-tile-warn .th-tile-value { color: #c53030; }
.th-tile-label { font-size: 13px; color: #718096; margin-top: 6px; font-weight: 500; }

.th-panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 900px) { .th-panels { grid-template-columns: 1fr; } }
.th-panel {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 22px;
}
body.dark-mode .th-panel { background: #0d1620; border-color: #2d3748; }
.th-panel-title { font-size: 16px; font-weight: 700; color: #2d3748; margin: 0 0 4px; }
body.dark-mode .th-panel-title { color: var(--accent-tint); }
.th-panel-hint { font-size: 13px; color: #718096; margin: 0 0 16px; }
.th-loading { color: #718096; font-size: 14px; }

/* At-risk alert rows */
.th-alert-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid #f0f4f8; cursor: pointer;
}
.th-alert-row:last-child { border-bottom: none; }
body.dark-mode .th-alert-row { border-color: #2d3748; }
.th-alert-row:hover .th-alert-name { text-decoration: underline; }
.th-alert-avatar { font-size: 22px; width: 36px; text-align: center; }
.th-alert-info { flex: 1; min-width: 0; }
.th-alert-name { font-weight: 600; font-size: 14px; color: #2d3748; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.dark-mode .th-alert-name { color: var(--accent-tint); }
.th-alert-meta { font-size: 12px; color: #718096; margin-top: 2px; }
.th-alert-badge { flex-shrink: 0; }

/* Weak skill rows */
.th-skill-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid #f0f4f8;
}
.th-skill-row:last-child { border-bottom: none; }
body.dark-mode .th-skill-row { border-color: #2d3748; }
.th-skill-name { width: 180px; font-size: 13px; font-weight: 600; color: #2d3748; flex-shrink: 0; }
body.dark-mode .th-skill-name { color: var(--accent-tint); }
.th-skill-bar-wrap { flex: 1; background: #e2e8f0; border-radius: 6px; height: 14px; overflow: hidden; }
body.dark-mode .th-skill-bar-wrap { background: #2d3748; }
.th-skill-bar { height: 100%; border-radius: 6px; }
.th-skill-pct { width: 40px; text-align: right; font-size: 13px; font-weight: 700; }

/* Join requests badge on tab button */
.requests-badge {
  display: inline-block;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
  min-width: 18px;
  text-align: center;
}

/* Roster toolbar */
.roster-toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* Remove button on roster cards */
.roster-remove-btn {
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  color: #a0aec0;
  font-size: 13px;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.roster-remove-btn:hover { background: #fee2e2; color: #c53030; border-color: #fc8181; }
body.dark-mode .roster-remove-btn { border-color: #4a5568; color: #718096; }
body.dark-mode .roster-remove-btn:hover { background: #7f1d1d; color: #fc8181; border-color: #e53e3e; }

/* Join-by-code bar in find-class-view */
.fc-code-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.fc-code-bar input {
  flex: 1;
  min-width: 160px;
  max-width: 260px;
  padding: 10px 14px;
  font-size: 15px;
  letter-spacing: 0.08em;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  font-family: inherit;
}
body.dark-mode .fc-code-bar input { background: #0d1620; border-color: #4a5568; color: var(--accent-tint); }

/* Student class banner on homepage */
.student-class-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
  max-width: 100%;
}
.scb-card {
  display: inline-flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, #ebf8ff 0%, #e0f2fe 100%);
  border: 1.5px solid #90cdf4;
  border-radius: 14px;
  padding: 12px 18px;
  box-shadow: 0 2px 8px rgba(144, 205, 244, 0.25);
  flex: 1 1 300px;
  box-sizing: border-box;
  min-width: 0;
}
body.dark-mode .scb-card {
  background: linear-gradient(135deg, #1a2f45 0%, #1e3a5f 100%);
  border-color: #2b6cb0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.scb-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.scb-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 auto; }
.scb-info { min-width: 0; }
.scb-class-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a365d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.dark-mode .scb-class-name { color: #bee3f8; }
.scb-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #2b6cb0;
  margin-top: 2px;
}
body.dark-mode .scb-meta { color: #90cdf4; }
.scb-dot { opacity: 0.5; }
.scb-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.scb-divider {
  width: 1px;
  height: 14px;
  background: #90cdf4;
  opacity: 0.6;
}
body.dark-mode .scb-divider { background: #2b6cb0; }
.scb-link {
  font-size: 12px;
  font-weight: 600;
  color: #2b6cb0;
  text-decoration: none;
  white-space: nowrap;
}
.scb-link:hover { text-decoration: underline; }
body.dark-mode .scb-link { color: #90cdf4; }
.scb-leave-btn {
  font-size: 12px;
  font-weight: 600;
  color: #c53030;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.scb-leave-btn:hover { text-decoration: underline; }
body.dark-mode .scb-leave-btn { color: #fc8181; }

/* ── Teacher Presentation (Teach) Mode ── */
/* ── Teach toolbar ── */
.teach-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Always allow the two halves to wrap onto separate rows — relying on a
     fixed pixel breakpoint to predict when content overflows is brittle
     (a long skill name like "PMO Challenge: Algebra" plus five full-label
     buttons can overflow even a ~1200px window), so let the browser's own
     flex-wrap overflow handling decide at ANY width instead. */
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: #1e293b;
  border-radius: 12px;
  margin-bottom: 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.teach-toolbar-left  { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; flex-wrap: wrap; }
/* flex-shrink: 0 — never let this half shrink below its buttons' natural
   width (that's what caused the overlap: a shrunk-but-not-wrapped flex
   item overflows its own box and draws over its sibling). If it doesn't
   fit next to the left half, it wraps below instead. */
.teach-toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* Below this width, additionally collapse every icon+label button down to
   icon-only (the label text still reaches the user via the button's title
   tooltip), so the toolbar stays compact instead of just wrapping tall. */
@media (max-width: 900px) {
  .teach-toolbar { gap: 8px; }
  .teach-toolbar-right { width: 100%; gap: 4px; }
  .teach-ctrl-btn { padding: 6px 9px; font-size: 11px; }
  .teach-zoom-group { gap: 2px; }
  .teach-ctrl-label { display: none; }
}

/* Inline selects in toolbar */
.teach-select {
  background: rgba(255,255,255,0.12);
  color: #f1f5f9;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 220px;
}
.teach-select:focus { outline: none; border-color: rgba(255,255,255,0.5); }
.teach-diff-select { max-width: 100px; }
.teach-select option { background: #1e293b; color: #f1f5f9; }

.teach-exit-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.25);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.teach-exit-btn:hover { background: rgba(255,255,255,0.1); }

.teach-meta { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }

.teach-skill-badge {
  display: inline-block;
  background: #6b46c1;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

/* Shared control button style */
.teach-ctrl-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
}
.teach-ctrl-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.teach-ctrl-btn:active { transform: translateY(0); }

.teach-ctrl-pick     { background: #7c3aed; color: #fff; }
.teach-ctrl-pick:hover { background: #6d28d9 !important; }

#student-picker-modal { z-index: 2147483647; }
.teach-ctrl-hint     { background: #fef3c7; color: #92400e; }
.teach-ctrl-solution { background: #dbeafe; color: #1e40af; }
.teach-ctrl-next     { background: #10b981; color: #fff; }
.teach-ctrl-fs       { background: #475569; color: #f1f5f9; }

/* Question container */
.teach-container {
  max-width: 860px;
  margin: 0 auto;
}
.teach-question-text {
  font-size: 1.25rem;
  line-height: 1.8;
  color: #1a202c;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.93);
  border-radius: 14px;
  padding: 24px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(0, 0, 0, 0.07);
}
.teach-skill-desc {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #4a5568;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.85);
  border-left: 4px solid #6b46c1;
  border-radius: 8px;
  padding: 12px 18px;
}
body.dark-mode .teach-skill-desc {
  color: #cbd5e0;
  background: rgba(26, 35, 50, 0.85);
}
.ws-present-qnum {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 8px;
}
body.dark-mode .ws-present-qnum { color: #64748b; }
body.dark-mode .teach-question-text {
  color: var(--accent-tint);
  background: rgba(26, 35, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
#teach-question-diagram {
  margin: 20px 0;
  text-align: center;
}

/* Present Skill modal: difficulty picker */
.present-difficulty-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.present-diff-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.present-diff-option input[type="radio"] { accent-color: #6b46c1; }
.diff-chip {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.diff-chip.easy   { background: #d1fae5; color: #065f46; }
.diff-chip.medium { background: #fef3c7; color: #92400e; }
.diff-chip.hard   { background: #fee2e2; color: #991b1b; }
body.dark-mode .diff-chip.easy   { background: #065f46; color: #d1fae5; }
body.dark-mode .diff-chip.medium { background: #78350f; color: #fef3c7; }
body.dark-mode .diff-chip.hard   { background: #7f1d1d; color: #fee2e2; }

/* Teach view fullscreen — driven by JS class for reliability */
#teach-view.teach-fullscreen {
  background: #ffffff !important;
  padding: 0 0 48px !important;
  overflow-y: auto !important;
}
#teach-view.teach-fullscreen .teach-toolbar {
  border-radius: 0 !important;
  margin: 0 0 32px !important;
  padding: 14px 32px !important;
}
#teach-view.teach-fullscreen .teach-container {
  padding: 0 64px !important;
  max-width: 100% !important;
}
#teach-view.teach-fullscreen .teach-question-text {
  font-size: 1.9rem !important;
  line-height: 2.1 !important;
  color: #1a202c !important;
}
#teach-view.teach-fullscreen .hint-box,
#teach-view.teach-fullscreen .solution-box {
  background: #f8fafc !important;
  color: #1a202c !important;
}
#teach-view.teach-fullscreen .hint-title,
#teach-view.teach-fullscreen .solution-title {
  color: #2d3748 !important;
}
#teach-view.teach-fullscreen .hint-content,
#teach-view.teach-fullscreen .solution-steps,
#teach-view.teach-fullscreen .solution-final {
  color: #2d3748 !important;
}

/* Teach zoom controls */
.teach-zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 2px 6px;
}
.teach-ctrl-zoom {
  background: transparent !important;
  color: #f1f5f9 !important;
  border: none !important;
  padding: 5px 8px !important;
  font-size: 13px !important;
  font-weight: 700;
  border-radius: 6px;
  min-width: 30px;
}
.teach-ctrl-zoom:hover:not(:disabled) { background: rgba(255,255,255,0.15) !important; }
.teach-ctrl-zoom:disabled { opacity: 0.35; cursor: default; }
.teach-zoom-label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  min-width: 38px;
  text-align: center;
}

/* ── Worksheet Generator ─────────────────────────────────────────────────── */

/* Hide leaderboard sidebar while worksheet builder is open */
body.ws-mode .right-sidebar { display: none !important; }
body.ws-mode .main-content  { max-width: 100% !important; }

body.sim-mode .right-sidebar            { display: none !important; }
body.sim-mode .sidebar                  { display: none !important; }
body.sim-mode .header                   { display: none !important; }
body.sim-mode .header-title-ladder-wrap { display: none !important; }
body.sim-mode footer                    { display: none !important; }
body.sim-mode .main-content             { max-width: 100% !important; }
body.sim-mode .app-wrapper              { padding-top: 0 !important; }

/* Two-panel builder layout */
#worksheet-gen-view { display: none; flex-direction: column; height: 100vh; overflow: hidden; }
#worksheet-gen-view.active { display: flex; }

.ws-builder {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Left panel ─────────────────────────────────────────────────────────── */
.ws-left-panel {
  width: 280px;
  flex-shrink: 0;
  background: #1e293b;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ws-left-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.ws-left-title { font-weight: 700; font-size: 0.9rem; flex: 1; }

/* ── Accordions ─────────────────────────────────────────────────────────── */
.ws-accordion {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ws-accordion:last-child { flex: 1; display: flex; flex-direction: column; overflow: hidden; border-bottom: none; }
.ws-accordion:last-child .ws-accordion-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.ws-accordion-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 9px 14px;
  cursor: pointer;
  text-align: left;
  user-select: none;
}
.ws-accordion-hdr:hover { color: #cbd5e1; background: rgba(255,255,255,0.04); }
.ws-accordion-arrow { font-size: 0.65rem; transition: transform 0.15s; }
.ws-accordion-hdr[aria-expanded="false"] .ws-accordion-arrow { transform: rotate(-90deg); }
.ws-accordion-badge {
  background: #3b82f6;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 2px;
}
.ws-accordion-sub { color: #475569; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.7rem; }

.ws-accordion-body { overflow: hidden; }
.ws-accordion-hdr[aria-expanded="false"] + .ws-accordion-body { display: none; }

/* ── Topic tree ─────────────────────────────────────────────────────────── */
.ws-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.ws-sets-actions { padding: 6px 0 2px; }

.ws-tree-grade-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
.ws-tree-grade-hdr:hover { color: #cbd5e1; }

.ws-tree-grade-body { display: none; }
.ws-tree-grade.open > .ws-tree-grade-body { display: block; }

.ws-tree-sec-hdr {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px 5px 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #7dd3fc;
  cursor: pointer;
  user-select: none;
}
.ws-tree-sec-hdr:hover { color: #bae6fd; }

.ws-tree-sec-body { display: none; }
.ws-tree-section.open > .ws-tree-sec-body { display: block; }

.ws-tree-skill {
  padding: 5px 14px 5px 32px;
  font-size: 0.82rem;
  color: #cbd5e1;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.ws-tree-skill:hover {
  background: rgba(255,255,255,0.08);
  border-left-color: #60a5fa;
  color: #f1f5f9;
}

.ws-tree-arrow { font-size: 0.65rem; opacity: 0.7; }

/* ── Bottom status bar ──────────────────────────────────────────────────── */
.ws-bottom-bar {
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 14px;
  max-height: 200px;
  overflow-y: auto;
}

.ws-bottom-stats {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 8px;
}
.ws-bottom-stats strong { color: #f1f5f9; }

.ws-sets-empty { font-size: 0.75rem; color: #475569; font-style: italic; padding: 4px 0; display: block; }
.ws-sets-list { padding: 6px 10px; overflow-y: auto; max-height: 240px; }
.ws-sets-actions { padding: 0 10px 8px; }

.ws-set-count-input,
.ws-spacer-lines-input {
  width: 36px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  color: #cbd5e1;
  font-size: 0.7rem;
  text-align: center;
  padding: 1px 2px;
  -moz-appearance: textfield;
}
.ws-set-count-input::-webkit-inner-spin-button,
.ws-set-count-input::-webkit-outer-spin-button,
.ws-spacer-lines-input::-webkit-inner-spin-button,
.ws-spacer-lines-input::-webkit-outer-spin-button { opacity: 1; }

.ws-set-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 5px;
  margin-bottom: 3px;
  font-size: 0.75rem;
  cursor: grab;
}
.ws-set-item:active { cursor: grabbing; }
.ws-set-item.ws-set-dragging { opacity: 0.4; }
.ws-set-item.ws-set-drag-over {
  border: 1px dashed #60a5fa;
  background: rgba(96,165,250,0.1);
}
.ws-set-drag {
  color: #475569;
  font-size: 0.9rem;
  line-height: 1;
  cursor: grab;
  flex-shrink: 0;
}
.ws-set-title { flex: 1; color: #cbd5e1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-set-meta  { color: #64748b; white-space: nowrap; font-size: 0.7rem; }
.ws-set-remove {
  background: none; border: none; color: #475569;
  cursor: pointer; padding: 1px 4px; border-radius: 3px; font-size: 0.65rem;
}
.ws-set-remove:hover { background: rgba(239,68,68,0.2); color: #f87171; }

/* Instruction / custom-question / diagram-set rows in the Question Sets
   list — draggable like a regular set, but no difficulty badge (it
   doesn't apply), just a short label + text preview. */
.ws-set-meta--text { overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.ws-set-remove-item {
  background: none; border: none; color: #475569;
  cursor: pointer; padding: 1px 4px; border-radius: 3px; font-size: 0.65rem;
  flex-shrink: 0;
}
.ws-set-remove-item:hover { background: rgba(239,68,68,0.2); color: #f87171; }

/* ── Add-questions modal ────────────────────────────────────────────────── */
.ws-builder { position: relative; }

.ws-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.ws-modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: min(860px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ws-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ws-modal-title { font-size: 1rem; font-weight: 700; color: #1e293b; }
.ws-modal-close {
  background: none; border: none; font-size: 1.1rem;
  color: #94a3b8; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.ws-modal-close:hover { background: #f1f5f9; color: #475569; }

.ws-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ws-modal-left {
  width: 260px;
  flex-shrink: 0;
  padding: 18px;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ws-modal-section { display: flex; flex-direction: column; gap: 8px; }
.ws-modal-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.ws-modal-count-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 1rem;
  width: 80px;
  color: #1e293b;
}
.ws-modal-count-input:focus { outline: 2px solid #3b82f6; border-color: transparent; }

.ws-preset-row { display: flex; gap: 6px; }
.ws-preset-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ws-preset-btn:hover { background: #e0f2fe; border-color: #7dd3fc; color: #0369a1; }
.ws-preset-active { background: #2563eb !important; border-color: #2563eb !important; color: #fff !important; }

.ws-modal-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#ws-modal-multipart-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ws-multipart-btn {
  text-align: left;
  white-space: normal;
  line-height: 1.3;
}
.ws-modal-btn-ok {
  background: #2563eb; color: #fff; border: none;
  border-radius: 7px; padding: 9px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: background 0.12s;
}
.ws-modal-btn-ok:hover { background: #1d4ed8; }
.ws-modal-btn-cont {
  background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0;
  border-radius: 7px; padding: 8px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.12s;
}
.ws-modal-btn-cont:hover { background: #dcfce7; }
.ws-modal-btn-cancel {
  background: none; color: #94a3b8; border: none;
  border-radius: 7px; padding: 6px; font-size: 0.82rem;
  cursor: pointer; text-align: center;
}
.ws-modal-btn-cancel:hover { color: #475569; }

.ws-modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ws-sample-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  flex-shrink: 0;
}
.ws-sample-more-btn {
  background: none; border: 1px solid #cbd5e1; border-radius: 5px;
  color: #475569; font-size: 0.75rem; padding: 3px 8px; cursor: pointer;
}
.ws-sample-more-btn:hover { background: #f1f5f9; }

.ws-sample-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ws-sample-item { border-bottom: 1px solid #f1f5f9; padding-bottom: 14px; }
.ws-sample-item:last-child { border-bottom: none; }
.ws-sample-q   { font-size: 0.88rem; color: #1e293b; margin-bottom: 6px; line-height: 1.5; }
.ws-sample-diagram svg { max-width: 100%; height: auto; }
.ws-sample-diagram { margin: 6px 0; }
.ws-sample-ans { font-size: 0.8rem; color: #dc2626; font-weight: 600; }
.ws-sample-empty { font-size: 0.82rem; color: #94a3b8; font-style: italic; }

.ws-ctrl-new      { background: #475569 !important; color: #fff !important; }
.ws-ctrl-regen    { background: #0f766e !important; color: #fff !important; }
.ws-ctrl-print    { background: #059669 !important; color: #fff !important; }
.ws-ctrl-download { background: #7c3aed !important; color: #fff !important; }
.ws-ctrl-save     { background: #0369a1 !important; color: #fff !important; }
.ws-ctrl-present  { background: #b45309 !important; color: #fff !important; }

/* ── Saved worksheets panel ─────────────────────────────────────────────── */
.ws-load-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
}
.ws-load-btn:hover { background: rgba(255,255,255,0.12); color: #cbd5e1; }

.ws-accordion-hdr--flex { cursor: pointer; }
.ws-accordion-hdr--flex .ws-saved-bar-close { margin-left: auto; }
.ws-saved-bar-close {
  background: none; border: none; color: #64748b;
  cursor: pointer; font-size: 0.7rem; padding: 0 2px;
}
.ws-saved-bar-close:hover { color: #f87171; }
.ws-saved-list { display: flex; flex-direction: column; gap: 4px; padding: 6px 10px 10px; max-height: 200px; overflow-y: auto; }
.ws-saved-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 5px;
  padding: 5px 6px;
}
.ws-saved-info  { flex: 1; min-width: 0; }
.ws-saved-title { display: block; font-size: 0.75rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-saved-meta  { font-size: 0.65rem; color: #64748b; }
.ws-saved-load-btn {
  background: #2563eb; color: #fff; border: none;
  border-radius: 4px; padding: 3px 7px; font-size: 0.7rem; cursor: pointer; flex-shrink: 0;
}
.ws-saved-load-btn:hover { background: #1d4ed8; }
.ws-saved-del-btn {
  background: none; border: none; color: #475569;
  cursor: pointer; font-size: 0.65rem; padding: 2px 4px;
}
.ws-saved-del-btn:hover { color: #f87171; }

.ws-legacy-import {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(96,165,250,0.12);
  border: 1px dashed #60a5fa;
  border-radius: 5px;
  padding: 5px 6px;
  margin-bottom: 4px;
  font-size: 0.65rem;
  color: #cbd5e1;
}
.ws-legacy-import-btn {
  background: #2563eb; color: #fff; border: none;
  border-radius: 4px; padding: 3px 7px; font-size: 0.65rem; cursor: pointer; flex-shrink: 0;
}
.ws-legacy-import-btn:hover { background: #1d4ed8; }

/* ── Toast notification ─────────────────────────────────────────────────── */
.ws-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.ws-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ws-toast-warn { background: #92400e; }

/* ── Presentation overlay ───────────────────────────────────────────────── */
.ws-present-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 200;
  overflow-y: auto;
  padding: 0 0 48px;
}
.ws-present-overlay .teach-toolbar {
  border-radius: 0;
  margin: 0 0 32px;
  padding: 14px 32px;
  position: sticky;
  top: 0;
}
.ws-present-overlay .teach-container {
  padding: 0 64px;
  max-width: 100%;
}
.ws-present-overlay .teach-question-text,
#teach-view.teach-fullscreen .teach-question-text {
  background: rgba(255, 255, 255, 0.93);
  border-radius: 14px;
  padding: 28px 36px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(0, 0, 0, 0.07);
}
.ws-present-counter {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ws-present-prev-btn { background: #6366f1; color: #fff; }
.ws-present-prev-btn:disabled { opacity: 0.3; cursor: default; }
.teach-ctrl-next:disabled    { opacity: 0.3; cursor: default; }

/* Fullscreen: hide browser chrome by going truly full */
.ws-present-fullscreen {
  position: fixed !important;
}
body.dark-mode .ws-present-overlay {
  background: #0f172a;
}
body.dark-mode .ws-present-overlay .teach-question-text {
  color: var(--accent-tint);
  background: rgba(26, 35, 50, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

/* 2-up presentation layout */
.ws-present-overlay.ws-present-2up .teach-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.ws-present-panel {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px 32px;
}
body.dark-mode .ws-present-panel { border-color: #334155; }
.ws-present-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ws-present-panel-num {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
}
.ws-present-panel-sol-btn {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #6366f1;
  color: #6366f1;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
}
.ws-present-panel-sol-btn:hover { background: #6366f1; color: #fff; }
.ws-present-panel-solution {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  display: none;
}
body.dark-mode .ws-present-panel-solution { border-color: #334155; }

/* Layout segmented control */
.ws-layout-seg { display: flex; border-radius: 8px; overflow: hidden; border: 1px solid #475569; }
.ws-layout-seg-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  background: transparent;
  color: #94a3b8;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ws-layout-seg-btn + .ws-layout-seg-btn { border-left: 1px solid #475569; }
.ws-layout-seg-btn.active { background: #6366f1; color: #fff; }
.ws-layout-seg-btn:not(.active):hover { background: #334155; color: #e2e8f0; }

/* ── Right panel ────────────────────────────────────────────────────────── */
.ws-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.ws-right-toolbar {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  padding: 7px 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
@media (prefers-color-scheme: dark) {
  .ws-right-toolbar { background: #0f172a; border-bottom-color: #1e293b; }
}
.ws-toolbar-collapse-btn,
.ws-sidebar-toggle-btn {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  color: #64748b;
  width: 22px;
  height: 22px;
  line-height: 1;
  font-size: 0.7rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.ws-toolbar-collapse-btn { order: -1; }
.ws-sidebar-toggle-btn { order: -2; }
.ws-toolbar-collapse-btn:hover,
.ws-sidebar-toggle-btn:hover { background: rgba(0,0,0,0.05); color: #334155; }
.ws-toolbar-collapse-btn[aria-expanded="false"],
.ws-sidebar-toggle-btn[aria-expanded="false"] { transform: rotate(180deg); }
@media (prefers-color-scheme: dark) {
  .ws-toolbar-collapse-btn, .ws-sidebar-toggle-btn { border-color: #334155; color: #94a3b8; }
  .ws-toolbar-collapse-btn:hover, .ws-sidebar-toggle-btn:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
}
.ws-right-toolbar.ws-toolbar-collapsed { padding-top: 4px; padding-bottom: 4px; }
.ws-right-toolbar.ws-toolbar-collapsed .ws-hint-text,
.ws-right-toolbar.ws-toolbar-collapsed .ws-toolbar-actions { display: none; }

.ws-left-panel.ws-sidebar-hidden { display: none; }
.ws-hint-text { font-size: 0.8rem; color: #64748b; }
.ws-hint-text kbd {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.75rem;
  font-family: monospace;
}
.ws-toolbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}
.ws-tb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ws-tb-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border-radius: 8px;
  background: rgba(100, 116, 139, 0.07);
}
@media (prefers-color-scheme: dark) {
  .ws-tb-group { background: rgba(148, 163, 184, 0.08); }
}
.ws-tb-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.ws-tb-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.ws-tb-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ws-tb-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
}
.ws-tb-check input[type="checkbox"] { cursor: pointer; }
@media (prefers-color-scheme: dark) {
  .ws-tb-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
  .ws-tb-btn:hover { background: #273549; }
  .ws-tb-check { background: #1e293b; border-color: #334155; color: #e2e8f0; }
}

.ws-preview-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 24px;
  background: #e2e8f0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
@media (prefers-color-scheme: dark) { .ws-preview-wrap { background: #0f172a; } }

/* ── Printable sheet ─────────────────────────────────────────────────────── */
.ws-sheet {
  background: #fff;
  color: #111;
  width: 816px;
  min-height: 1248px;
  padding: 48px 54px 56px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Header */
.ws-pshs-header { display: none; width: 100%; height: auto; margin-bottom: 6px; }
.ws-quarter-exam-mode .ws-pshs-header { display: block; }
.ws-quarter-exam-mode .ws-header-top { display: none; }
.ws-quarter-exam-mode .ws-problem { margin-bottom: 12px; }

/* Quarter Exam mode — single-line Name / Year and Section / Date, replacing the
   usual brand-line + Name/Date/Score block entirely. */
.ws-qe-meta-line { display: none; align-items: baseline; gap: 10px; font-size: 12px; margin: 8px 0 10px; flex-wrap: wrap; }
.ws-quarter-exam-mode .ws-qe-meta-line { display: flex; }
.ws-qe-name-blank { flex: 2 1 160px; border-bottom: 1px solid #111; height: 14px; }
.ws-qe-ys-blank   { flex: 1.4 1 100px; border-bottom: 1px solid #111; height: 14px; }
.ws-qe-date-blank { flex: 1 1 70px; border-bottom: 1px solid #111; height: 14px; }
.ws-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.ws-brand-line { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ws-brand-logo { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.ws-school-name { font-size: 11px; color: #6b7280; font-style: italic; display: flex; align-items: center; gap: 6px; }
.ws-school-name-input {
  border: none;
  outline: none;
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  font-family: Arial, Helvetica, sans-serif;
  background: transparent;
  padding: 0;
  width: 220px;
  flex-shrink: 0;
}
.ws-school-name-input:focus { background: #fffbeb; border-radius: 3px; color: #111; }
.ws-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 4px 8px;
  font-size: 12px;
  align-items: end;
}
.ws-meta-label { font-weight: 600; white-space: nowrap; }
.ws-meta-line  { border-bottom: 1px solid #111; width: 120px; height: 14px; }

/* Editable title on sheet */
.ws-title-bar  { text-align: center; margin: 6px 0 4px; }
.ws-title-input {
  border: none;
  outline: none;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  color: #111;
  background: transparent;
  width: 100%;
  letter-spacing: -0.3px;
}
.ws-title-input:focus { background: #fffbeb; border-radius: 3px; }

.ws-header-fields {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
}
.ws-header-field {
  border: none;
  border-bottom: 1px dashed #9ca3af;
  outline: none;
  font-size: 11px;
  color: #6b7280;
  font-family: Arial, Helvetica, sans-serif;
  background: transparent;
  text-align: center;
  width: 160px;
}
.ws-header-field:focus { border-bottom-color: #3b82f6; color: #111; }
.ws-header-field::placeholder { color: #d1d5db; }

.ws-rule { border: none; border-top: 2px solid #111; margin: 7px 0; }
.ws-directions { font-size: 12px; margin: 0 0 12px; }
.ws-directions-input {
  border: none;
  outline: none;
  font-size: 12px;
  font-family: Arial, Helvetica, sans-serif;
  color: #111;
  background: transparent;
  padding: 0;
  width: calc(100% - 90px);
  min-width: 200px;
}
.ws-directions-input:focus { background: #fffbeb; border-radius: 3px; }

.ws-empty-msg { color: #9ca3af; font-size: 13px; font-style: italic; }

/* Problems */
.ws-problems {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 26px;
  counter-reset: ws-item;
}
/* Instruction block — full-width row, editor-only chrome */
.ws-instruction {
  grid-column: 1 / -1;
  counter-increment: none;
  margin: 6px 0 10px;
  padding: 7px 10px 7px 10px;
  border: 1.5px dashed #60a5fa;
  border-radius: 4px;
  background: #eff6ff;
  position: relative;
  list-style: none;
}
.ws-instruction-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.ws-instruction-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #3b82f6;
  font-weight: 700;
  user-select: none;
}
.ws-instr-bold-btn {
  width: 20px;
  height: 18px;
  line-height: 1;
  padding: 0;
  border: 1px solid #93c5fd;
  border-radius: 3px;
  background: #fff;
  color: #3b82f6;
  font-size: 11px;
  cursor: pointer;
}
.ws-instr-bold-btn:hover { background: #dbeafe; }
.ws-instruction-text {
  font-size: 12.5px;
  min-height: 20px;
  outline: none;
  color: #111;
}
.ws-instruction-text b { font-weight: 700; }
.ws-instruction-text:empty::before {
  content: 'Type instructions here…';
  color: #9ca3af;
}
.ws-instr-del {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.ws-instr-del:hover { color: #ef4444; }

/* Spacer/Lines block — no question text/number */
.ws-spacer {
  grid-column: 1 / -1;
  counter-increment: none;
  margin: 6px 0 10px;
  padding: 7px 10px;
  border: 1.5px dashed #a3a3a3;
  border-radius: 4px;
  background: #fafafa;
  list-style: none;
}
/* Plain empty space — no rules, just height */
.ws-spacer-blank {
  height: calc(var(--ws-spacer-lines, 1) * 1.6em);
}
/* Ruled writing lines */
.ws-spacer-lines {
  display: flex;
  flex-direction: column;
  gap: 1.4em;
}
.ws-spacer-rule {
  border-bottom: 1px solid #999;
  height: 1px;
}
.ws-spacer-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
}
.ws-spacer-ctrl label { display: flex; align-items: center; gap: 4px; }
.ws-spacer-count { width: 46px; font-size: 11px; padding: 1px 4px; }

/* Stimulus (shared diagram) header */
.ws-stimulus {
  grid-column: 1 / -1;
  counter-increment: none;
  margin: 6px 0 10px;
  padding: 7px 10px 10px 10px;
  border: 1.5px dashed #a78bfa;
  border-radius: 4px;
  background: #f5f3ff;
  position: relative;
  list-style: none;
}
.ws-stimulus-label { font-size: 12.5px; color: #111; padding-right: 20px; }
.ws-stimulus-range { font-weight: 700; color: #7c3aed; margin-right: 4px; }
.ws-stimulus-text { outline: none; }
.ws-stimulus .ws-diagram { margin: 6px 0 0 0; }
.ws-stimulus-del {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.ws-stimulus-del:hover { color: #ef4444; }

/* Manual (hand-written) question */
.ws-manual-q {
  display: block;
  font-size: 12.5px;
  outline: none;
  min-height: 18px;
  margin-left: 22px;
  text-indent: -22px;
}
.ws-manual-q:empty::before { content: attr(data-placeholder); color: #9ca3af; }
.ws-manual-q::before { content: counter(ws-item) "."; font-weight: 700; margin-right: 6px; }
.ws-problem.ws-manual::before { content: none; }
.ws-manual-answer-row {
  margin: 4px 0 0 22px;
  font-size: 11px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ws-manual-answer {
  font-size: 11px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 2px 6px;
  flex: 1;
  max-width: 200px;
}

/* Per-question type toggle (screen only) */
.ws-qtype-bar { display: flex; gap: 4px; margin-bottom: 5px; }
.ws-qt-btn {
  font-size: 10px;
  padding: 1px 8px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: none;
  color: #6b7280;
  cursor: pointer;
  line-height: 1.6;
}
.ws-qt-btn.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.ws-qt-btn:hover:not(.active) { border-color: #3b82f6; color: #3b82f6; }

.ws-problem {
  counter-increment: ws-item;
  margin-bottom: 6px;
  break-inside: avoid;
  min-width: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  transition: border-color 0.12s;
  box-sizing: border-box;
}
.ws-problem:hover { border-color: #bfdbfe; }
.ws-problem-selected { border-color: #3b82f6 !important; background: #eff6ff; }

.ws-problem::before {
  content: counter(ws-item) ".";
  font-weight: 700;
  font-size: 13px;
  display: inline-block;
  width: 22px;
}
.ws-problem-q { display: inline; word-break: break-word; }
.ws-diagram { margin: 4px 0 0 22px; }
.ws-diagram svg { max-width: 100%; height: auto; }
.ws-figure-label { font-size: 10.5px; font-weight: 700; color: #475569; text-align: center; margin-top: 2px; }
.ws-work-box {
  margin: 4px 0 0 22px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  height: 48px;
  background: #fafafa;
}

/* Multiple choice */
.ws-mc-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin: 6px 0 4px 22px;
}
.ws-mc-choices--single {
  grid-template-columns: 1fr;
}
.ws-mc-choice { display: flex; align-items: baseline; gap: 4px; }
.ws-mc-letter { font-weight: 700; min-width: 16px; }

/* Answer key */
.ws-key-section { margin-top: 14px; }
.ws-key-title   { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.ws-key-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  font-size: 12px;
  padding-left: 0;
  margin: 0;
  list-style: none;
}
.ws-key-item {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 8px;
}
.ws-key-qnum {
  font-weight: 700;
  min-width: 28px;
  padding-top: 2px;
}
.ws-key-body { flex: 1; }
.ws-key-question {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}
.ws-solution-steps {
  margin: 2px 0 4px 12px;
  padding-left: 12px;
  font-size: 11.5px;
  line-height: 1.6;
}
.ws-solution-steps li { margin-bottom: 3px; }
.ws-step-label {
  font-weight: 600;
  margin-right: 4px;
}
.ws-step-detail { display: block; margin-left: 8px; color: #374151; }
.ws-key-final {
  font-weight: 700;
  font-size: 12px;
  color: #1d4ed8;
  margin-top: 3px;
}
.ws-step-answer { margin: 0; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  nav, header, .sidebar, #sidebar-overlay,
  .ws-left-panel, .ws-right-toolbar { display: none !important; }

  .main-content { padding: 0 !important; margin: 0 !important; }
  .view { display: none !important; }
  #worksheet-gen-view { display: flex !important; height: auto !important; overflow: visible !important; }
  .ws-builder { display: block !important; }
  .ws-right-panel { display: block !important; overflow: visible !important; }

  .ws-preview-wrap {
    padding: 0 !important;
    background: none !important;
    overflow: visible !important;
    display: block !important;
  }
  .ws-sheet {
    width: 100% !important;
    min-height: unset !important;
    box-shadow: none !important;
    padding: 0.45in 0.55in !important;
    font-size: 11.5pt !important;
  }
  .ws-problem { border: none !important; background: none !important; cursor: default !important; }
  .ws-problem-selected { border: none !important; background: none !important; }
  .ws-instruction { background: none !important; border: none !important; border-bottom: 1px solid #ccc !important; padding: 4px 0 6px !important; margin-bottom: 8px !important; }
  .ws-instruction-label, .ws-instr-del, .ws-instr-bold-btn, .ws-qtype-bar { display: none !important; }
  .ws-spacer { background: none !important; border: none !important; padding: 0 !important; margin: 6px 0 14px !important; }
  .ws-spacer-ctrl { display: none !important; }
  .ws-stimulus { background: none !important; border: none !important; border-bottom: 1px solid #ccc !important; padding: 4px 0 6px !important; margin-bottom: 8px !important; }
  .ws-stimulus-del { display: none !important; }
  .ws-manual-answer-row { display: none !important; }
  .ws-problem { margin-bottom: 6px !important; }
  .ws-work-box {
    height: 48pt !important;
    background: none !important;
    border-color: #999 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .ws-title-input, .ws-header-field { border: none !important; background: none !important; }
  @page { margin: 0; size: 8.5in 13in; }
}

/* ── Simulations ──────────────────────────────────────────────────────────── */
.sim-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.sim-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sim-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: var(--accent, #4ecdc4);
}

.sim-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.sim-card-body {
  flex: 1;
}

.sim-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin: 0 0 6px;
}

.sim-card-desc {
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
  line-height: 1.55;
  margin: 0 0 10px;
}

.sim-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sim-tag {
  font-size: 11px;
  font-weight: 600;
  background: rgba(78,205,196,0.12);
  color: #4ecdc4;
  border-radius: 20px;
  padding: 2px 10px;
  border: 1px solid rgba(78,205,196,0.25);
}

.sim-card-launch {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent, #4ecdc4);
  text-align: right;
}

/* ── Simulation Runner layout ────────────────────────────────────────────── */
body.sim-mode .main-content {
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  height: 100vh;
  max-width: 100% !important;
}

body.sim-mode .content-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#simulation-runner-view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

#simulation-runner-view .teach-toolbar {
  margin-bottom: 0;
  flex-shrink: 0;
}

.sim-runner-frame {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
  min-height: 0;
  background: #111827;
}

/* =============================================================
   Admin Panel & Messaging Styles
============================================================= */

/* --- Inbox badge (header button) --- */
.inbox-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
#inbox-btn { position: relative; }

/* --- Sidebar badges --- */
.sidebar-msg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 6px;
  line-height: 1;
}

/* --- View-As Banner --- */
#view-as-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #f59e0b;
  color: #1f2937;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#view-as-banner .view-as-exit-btn {
  background: #1f2937;
  color: #f59e0b;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}

/* --- Admin Panel wrap --- */
.admin-panel-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
}
/* Question Bank Viewer */
.qb-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.qb-source-select { min-width: 260px; max-width: 100%; }
.qb-difficulty-select { max-width: 140px; }
.qb-jump-row { display: flex; gap: 6px; align-items: center; }
.qb-jump-input { max-width: 100px; }
.qb-nav-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.qb-position-label {
  font-weight: 700;
  font-size: 14px;
  color: #4a5568;
  min-width: 140px;
  text-align: center;
}
body.dark-mode .qb-position-label { color: #cbd5e1; }
.qb-fn-label {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #2c6e7a;
  background: rgba(44,110,122,.09);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}
body.dark-mode .qb-fn-label { color: #7dd3e8; background: rgba(125,211,232,.12); }
.qb-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 16px;
  padding: 22px;
}
body.dark-mode .qb-card {
  background: #1e2530;
  border-color: rgba(255,255,255,.08);
}
.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.admin-panel-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.3px;
}
.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: rgba(0,0,0,.05);
  border-radius: 14px;
  padding: 5px;
  width: fit-content;
}
body.dark-mode .admin-tabs { background: rgba(255,255,255,.07); }
.admin-tab {
  padding: 8px 20px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #374151;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, color .15s, box-shadow .15s;
}
body.dark-mode .admin-tab { color: #d1d5db; }
.admin-tab.active {
  background: #6366f1;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.admin-tab:hover:not(.active) {
  background: rgba(99,102,241,.12);
  color: #4f46e5;
}
body.dark-mode .admin-tab:hover:not(.active) { color: #a5b4fc; }
.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #d1d5db;
  font-size: 14px;
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
body.dark-mode .admin-search-input {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}
.admin-search-input::placeholder { color: #9ca3af; }
.admin-create-btn {
  padding: 10px 20px;
  border-radius: 10px;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
  transition: background .15s, box-shadow .15s;
}
.admin-create-btn:hover { background: #4f46e5; box-shadow: 0 4px 12px rgba(99,102,241,.4); }

/* --- Users Table --- */
.admin-users-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 14px;
}
.admin-users-table thead tr {
  background: none;
}
.admin-users-table th {
  padding: 8px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #6b7280;
}
body.dark-mode .admin-users-table th { color: #9ca3af; }
.admin-users-table tbody tr {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border-radius: 10px;
  transition: box-shadow .15s, transform .1s;
}
body.dark-mode .admin-users-table tbody tr { background: #1f2937; }
.admin-users-table td {
  padding: 12px 14px;
  color: #111827;
  border: none;
}
body.dark-mode .admin-users-table td { color: #f3f4f6; }
.admin-users-table td:first-child { border-radius: 10px 0 0 10px; }
.admin-users-table td:last-child { border-radius: 0 10px 10px 0; }
.admin-users-table tbody tr:hover {
  box-shadow: 0 3px 10px rgba(99,102,241,.18);
  transform: translateY(-1px);
}
.admin-status-chip {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.admin-status-chip.active { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.admin-status-chip.inactive { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
body.dark-mode .admin-status-chip.active { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
body.dark-mode .admin-status-chip.inactive { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
.admin-actions { display: flex; gap: 6px; }
.admin-action-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid #6366f1;
  background: rgba(99,102,241,.08);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #4f46e5;
  transition: background .15s, box-shadow .15s;
}
body.dark-mode .admin-action-btn { color: #a5b4fc; border-color: #4f46e5; background: rgba(99,102,241,.15); }
.admin-action-btn:hover { background: #6366f1; color: #fff; box-shadow: 0 2px 6px rgba(99,102,241,.3); }
.admin-action-btn.danger { border-color: #f87171; color: #ef4444; background: rgba(239,68,68,.06); }
.admin-action-btn.danger:hover { background: #ef4444; color: #fff; box-shadow: 0 2px 6px rgba(239,68,68,.3); }
.admin-empty { text-align: center; color: #6b7280; padding: 32px; font-size: 14px; }
body.dark-mode .admin-empty { color: #9ca3af; }

/* --- View As Panel --- */
#admin-viewas-panel { display: none; }
.admin-viewas-hint {
  font-size: 14px;
  color: #4b5563;
  margin-bottom: 14px;
  font-weight: 500;
}
body.dark-mode .admin-viewas-hint { color: #9ca3af; }
.admin-viewas-search {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #d1d5db;
  font-size: 14px;
  background: #fff;
  color: #111827;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: block;
}
body.dark-mode .admin-viewas-search {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}
.admin-viewas-search::placeholder { color: #9ca3af; }
.admin-viewas-list { display: flex; flex-direction: column; gap: 6px; }
.admin-viewas-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: box-shadow .15s, transform .1s;
}
.admin-viewas-row:hover {
  box-shadow: 0 3px 10px rgba(99,102,241,.18);
  transform: translateY(-1px);
}
body.dark-mode .admin-viewas-row { background: #1f2937; }
.admin-viewas-avatar { font-size: 26px; flex-shrink: 0; }
.admin-viewas-name { flex: 1; font-weight: 700; font-size: 15px; color: #111827; }
body.dark-mode .admin-viewas-name { color: #f9fafb; }
.admin-viewas-role {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #6366f1;
  padding: 2px 10px;
  border-radius: 20px;
  margin-right: 10px;
  text-transform: capitalize;
}
.admin-viewas-role.role-teacher { background: #0891b2; }
.admin-viewas-role.role-admin { background: #d97706; }

/* --- Admin User Modal --- */
#admin-user-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,.5);
  align-items: center;
  justify-content: center;
}
#admin-user-modal.open { display: flex; }
.admin-modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
body.dark-mode .admin-modal-box { background: #1f2937; color: #f9fafb; }
.admin-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
}
.admin-modal-field {
  margin-bottom: 14px;
}
.admin-modal-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  opacity: .8;
}
.admin-modal-field input,
.admin-modal-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  font-size: 14px;
  background: transparent;
  color: inherit;
  box-sizing: border-box;
}
body.dark-mode .admin-modal-field input,
body.dark-mode .admin-modal-field select {
  border-color: #4b5563;
  background: #111827;
}
.admin-modal-field input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
}
.admin-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.admin-modal-cancel {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
}
.admin-modal-submit {
  padding: 8px 18px;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.admin-modal-submit:hover { background: #4f46e5; }

/* =============================================================
   Messaging View
============================================================= */
.messaging-wrap {
  display: flex;
  height: calc(100vh - 80px);
  max-width: 1100px;
  margin: 0 auto;
  gap: 0;
}
.messaging-sidebar {
  width: 200px;
  min-width: 160px;
  border-right: 1px solid rgba(0,0,0,.1);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
body.dark-mode .messaging-sidebar { border-right-color: rgba(255,255,255,.08); }
.msg-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
  text-align: left;
  font-weight: 500;
  transition: background .15s;
}
.msg-folder:hover { background: rgba(99,102,241,.1); }
.msg-folder.active { background: rgba(99,102,241,.18); color: #6366f1; }
.compose-btn-wrap { margin-top: auto; padding-top: 12px; }
.compose-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.compose-btn:hover { background: #4f46e5; }
.messaging-main {
  flex: 1;
  display: flex;
  min-width: 0;
}
#msg-list {
  width: 300px;
  min-width: 240px;
  border-right: 1px solid rgba(0,0,0,.1);
  overflow-y: auto;
}
body.dark-mode #msg-list { border-right-color: rgba(255,255,255,.08); }
.msg-row {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,.06);
  transition: background .12s;
}
body.dark-mode .msg-row { border-bottom-color: rgba(255,255,255,.06); }
.msg-row:hover, .msg-row.selected { background: rgba(99,102,241,.1); }
.msg-row.unread .msg-row-from { font-weight: 700; }
.msg-row.unread .msg-row-subject { font-weight: 600; }
.msg-row-avatar { font-size: 24px; flex-shrink: 0; }
.msg-row-body { flex: 1; min-width: 0; }
.msg-row-from { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row-subject { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.msg-row-snippet { font-size: 12px; opacity: .5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row-date { font-size: 11px; opacity: .5; flex-shrink: 0; white-space: nowrap; }
.msg-empty { text-align: center; opacity: .6; padding: 24px 12px; font-size: 14px; }
#msg-detail {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  display: none;
}
.msg-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.msg-detail-avatar { font-size: 32px; }
.msg-detail-meta { flex: 1; }
.msg-detail-from { font-weight: 700; font-size: 15px; }
.msg-detail-date { font-size: 12px; opacity: .6; }
.msg-detail-btns { margin-left: auto; }
.msg-action-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid #f87171;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  font-size: 13px;
}
.msg-action-btn:hover { background: #fee2e2; color: #991b1b; }
.msg-detail-subject {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0,0,0,.1);
}
body.dark-mode .msg-detail-subject { border-bottom-color: rgba(255,255,255,.1); }
.msg-detail-body { font-size: 15px; line-height: 1.7; white-space: pre-wrap; }

/* --- Compose Modal --- */
#compose-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,.5);
  align-items: center;
  justify-content: center;
}
#compose-modal.open { display: flex; }
.compose-modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
body.dark-mode .compose-modal-box { background: #1f2937; color: #f9fafb; }
.compose-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
}
.compose-field {
  margin-bottom: 14px;
}
.compose-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  opacity: .8;
}
.compose-field input,
.compose-field select,
.compose-field textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  font-size: 14px;
  background: transparent;
  color: inherit;
  box-sizing: border-box;
  font-family: inherit;
}
body.dark-mode .compose-field input,
body.dark-mode .compose-field select,
body.dark-mode .compose-field textarea {
  border-color: #4b5563;
  background: #111827;
}
.compose-field textarea { resize: vertical; min-height: 120px; }
.compose-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.compose-cancel {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
}
.compose-submit {
  padding: 8px 18px;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.compose-submit:hover { background: #4f46e5; }

/* Responsive messaging */
@media (max-width: 640px) {
  .messaging-wrap { flex-direction: column; height: auto; }
  .messaging-sidebar { width: 100%; min-width: unset; flex-direction: row; border-right: none; border-bottom: 1px solid rgba(0,0,0,.1); padding: 8px; }
  .compose-btn-wrap { margin-top: 0; padding-top: 0; margin-left: auto; }
  #msg-list { width: 100%; border-right: none; }
  .messaging-main { flex-direction: column; }
}

/* Admin panel and messaging take full width — hide right sidebar */
#admin-panel-view.active ~ aside.right-sidebar,
#messaging-view.active ~ aside.right-sidebar { display: none !important; }

body.full-width-view .right-sidebar { display: none !important; }
body.full-width-view .main-content  { max-width: 100% !important; }

/* ── Problem Sets ─────────────────────────────────────────────────────────── */
.ps-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: box-shadow .15s;
}
.ps-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
body.dark-mode .ps-card { background: #0d1620; border-color: #2d3748; }

.ps-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.ps-card-title { font-size: 15px; font-weight: 600; }
.ps-card-desc { font-size: 13px; color: #718096; margin-top: 2px; }
.ps-status-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.ps-card-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: #718096; margin-bottom: 14px; }
.ps-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ps-student-card {
  display: flex; align-items: center; gap: 16px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 16px 20px; margin-bottom: 12px;
}
body.dark-mode .ps-student-card { background: #0d1620; border-color: #2d3748; }

.ps-question-block input:focus {
  outline: none;
  border-color: #6b46c1;
  box-shadow: 0 0 0 3px rgba(107,70,193,.15);
}

/* ── Markdown tables in question text ─────────────────────────────────────── */
.md-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
  width: auto;
}
.md-table th, .md-table td {
  border: 1px solid #cbd5e0;
  padding: 7px 14px;
  text-align: left;
}
.md-table thead tr { background: #edf2f7; }
.md-table tbody tr:nth-child(even) { background: #f7fafc; }
body.dark-mode .md-table th, body.dark-mode .md-table td { border-color: #4a5568; }
body.dark-mode .md-table thead tr { background: #2d3748; }
body.dark-mode .md-table tbody tr:nth-child(even) { background: #1a202c; }

/* ── Problem Sets inside class banner card ────────────────────────────────── */
/* Grid, not a stacked list — the card's own width already stretches to fill
   its row (.scb-card { flex: 1 1 300px }), so a single-column list left a
   wide dead zone. Rows now wrap into as many ~280px columns as fit. */
.scb-ps-section {
  margin-top: 12px;
  border-top: 1px solid rgba(0,0,0,.08);
  padding-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px 24px;
}
body.dark-mode .scb-ps-section { border-color: rgba(255,255,255,.1); }
.scb-ps-header { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.scb-ps-header-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 2px 0;
  font-size: 13px; font-weight: 700; color: #2b6cb0;
  text-transform: none; letter-spacing: normal;
  cursor: pointer;
}
.scb-ps-header-toggle:hover { color: #1a4971; text-decoration: underline; }
body.dark-mode .scb-ps-header-toggle { color: #90cdf4; }
body.dark-mode .scb-ps-header-toggle:hover { color: #bee3f8; }
.scb-ps-chevron { font-size: 10px; }
.scb-ps-list { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.scb-ps-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(107, 70, 193, .04);
  transition: background .15s ease;
}
.scb-ps-row:hover { background: rgba(107, 70, 193, .08); }
body.dark-mode .scb-ps-row { background: rgba(255,255,255,.035); }
body.dark-mode .scb-ps-row:hover { background: rgba(255,255,255,.06); }
.scb-ps-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.scb-ps-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scb-ps-meta { font-size: 12px; color: #a0aec0; }
.scb-ps-chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.scb-ps-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; line-height: 1.6;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.scb-ps-chip-due { color: #e53e3e; background: rgba(252, 129, 129, .16); }
body.dark-mode .scb-ps-chip-due:not([style*="a0aec0"]) { color: #feb2b2; }
.scb-ps-take-btn { flex-shrink: 0; padding: 5px 14px; font-size: 13px; border-radius: 8px; border: none; cursor: pointer; background: #6b46c1; color: #fff; font-weight: 600; }
.scb-ps-take-btn:disabled { opacity: .5; cursor: not-allowed; background: #a0aec0; }

/* ── Problem Set Group Builder Form ───────────────────────────────────────── */
.ps-form-shell { border-radius: 16px; overflow: hidden; }
.ps-form-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
  background: #fff; flex-shrink: 0;
}
body.dark-mode .ps-form-header { background: #0d1620; border-color: #2d3748; }
.ps-form-body {
  display: flex; overflow: hidden; flex: 1; min-height: 0;
}
.ps-form-left {
  flex: 1; min-width: 0; overflow-y: auto;
  padding: 16px 18px; border-right: 1px solid #e2e8f0;
}
body.dark-mode .ps-form-left { border-color: #2d3748; }
.ps-form-right {
  width: 260px; flex-shrink: 0; overflow-y: auto;
  padding: 16px 14px; background: #f8fafc;
}
body.dark-mode .ps-form-right { background: #1a2535; }
.ps-form-section-label { font-size: 12px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.ps-preset-btn {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 8px 14px; margin-bottom: 12px; border: 1px solid #d6bcfa;
  border-radius: 8px; background: linear-gradient(135deg, #faf5ff, #f3e8ff);
  color: #553c9a; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.ps-preset-btn:hover { background: #e9d8fd; }
body.dark-mode .ps-preset-btn { background: #2d1f4a; border-color: #6b46c1; color: #d6bcfa; }
body.dark-mode .ps-preset-btn:hover { background: #3c2a63; }
.ps-skill-list { max-height: 260px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px; }
body.dark-mode .ps-skill-list { border-color: #2d3748; }
.ps-skill-row {
  padding: 6px 10px; font-size: 13px; cursor: pointer; border-radius: 6px;
  transition: background .15s;
}
.ps-skill-row:hover { background: #edf2f7; }
body.dark-mode .ps-skill-row:hover { background: #2d3748; }
.ps-skill-selected { background: #e9d8fd !important; font-weight: 600; color: #6b46c1; }
body.dark-mode .ps-skill-selected { background: #44337a !important; color: #d6bcfa; }
.ps-add-group-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px; margin-top: 6px; border: 1px dashed #9f7aea;
  border-radius: 8px; background: #faf5ff;
}
body.dark-mode .ps-add-group-bar { background: #2d1f4a; border-color: #6b46c1; }
.ps-add-skill-name { font-size: 13px; font-weight: 600; color: #553c9a; flex: 1; min-width: 80px; }
.ps-add-count { width: 56px; padding: 4px 8px; border: 1px solid #d6bcfa; border-radius: 6px; font-size: 13px; }
.ps-add-mc-count { width: 48px; }
.ps-add-mc-of { font-size: 12px; color: #6b46c1; white-space: nowrap; }
.ps-diff-btns { display: flex; gap: 4px; }
.ps-diff-btn { padding: 4px 10px; border: 1px solid #d6bcfa; border-radius: 6px; font-size: 12px; cursor: pointer; background: #fff; color: #553c9a; transition: background .15s; }
.ps-diff-btn:hover { background: #e9d8fd; }
.ps-diff-active { background: #6b46c1 !important; color: #fff !important; border-color: #6b46c1 !important; }
.ps-add-group-btn { padding: 5px 14px; background: #6b46c1; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ps-add-group-btn:hover { background: #553c9a; }
.ps-total-q { font-size: 12px; color: #6b46c1; font-weight: 700; margin-left: 6px; }
.ps-groups-list { display: flex; flex-direction: column; gap: 6px; }
.ps-group-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; font-size: 13px;
}
body.dark-mode .ps-group-row { background: #0d1620; border-color: #2d3748; }
.ps-group-skill { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-group-diff { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.ps-diff-badge-easy { background: #c6f6d5; color: #276749; }
.ps-diff-badge-medium { background: #fefcbf; color: #744210; }
.ps-diff-badge-hard { background: #fed7d7; color: #822727; }
.ps-group-count { width: 50px; padding: 3px 6px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 12px; text-align: center; }
.ps-group-mc-count { width: 42px; }
.ps-group-mc-label { font-size: 11px; color: #6b46c1; font-weight: 600; flex-shrink: 0; }
.ps-group-remove { background: none; border: none; color: #a0aec0; cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px; }
.ps-group-remove:hover { color: #e53e3e; }

/* ── Problem Set Take Modal (one-question-at-a-time) ───────────────────────── */
.ps-take-shell { border-radius: 16px; overflow: hidden; }
.ps-take-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid #e2e8f0;
  background: #fff; flex-shrink: 0;
}
body.dark-mode .ps-take-header { background: #0d1620; border-color: #2d3748; }
.ps-take-title { font-size: 17px; font-weight: 700; }
.ps-take-timer {
  font-size: 15px; font-weight: 700; color: #e53e3e;
  background: #fed7d7; padding: 5px 14px; border-radius: 8px;
}
.ps-take-body {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
/* Left question panel */
.ps-take-main {
  flex: 1; display: flex; flex-direction: column;
  padding: 24px 26px; overflow-y: auto; gap: 0;
}
.ps-q-panel {
  flex: 1;
}
.ps-q-skill-label { font-size: 11px; color: #a0aec0; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; text-align: left; }
.ps-part-banner {
  font-size: 13px; font-weight: 700; color: #6b46c1; letter-spacing: .04em;
  padding: 8px 12px; margin-bottom: 14px; border-radius: 8px;
  background: #faf5ff; border: 1px solid #d6bcfa; text-align: center;
}
body.dark-mode .ps-part-banner { background: #2d1f4a; border-color: #6b46c1; color: #d6bcfa; }
.ps-q-text { font-size: 16px; line-height: 1.6; margin-bottom: 18px; text-align: left; }
.ps-answer-input {
  width: 100%; padding: 10px 14px; border: 2px solid #e2e8f0;
  border-radius: 9px; font-size: 15px; outline: none; transition: border .18s;
  background: #f7fafc;
}
.ps-answer-input:focus { border-color: #6b46c1; background: #fff; }
body.dark-mode .ps-answer-input { background: #1a2332; border-color: #2d3748; color: #e2e8f0; }
body.dark-mode .ps-answer-input:focus { border-color: #9f7aea; background: #0d1620; }
/* Nav row */
.ps-take-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 22px; gap: 12px;
}
.ps-nav-btn {
  padding: 9px 22px; border-radius: 9px; border: 1.5px solid #6b46c1;
  background: #fff; color: #6b46c1; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.ps-nav-btn:hover:not(:disabled) { background: #6b46c1; color: #fff; }
.ps-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
body.dark-mode .ps-nav-btn { background: #0d1620; border-color: #9f7aea; color: #c4b5fd; }
body.dark-mode .ps-nav-btn:hover:not(:disabled) { background: #6b46c1; color: #fff; }
.ps-q-counter { font-size: 13px; color: #a0aec0; font-weight: 600; }
/* Right item table sidebar */
.ps-take-sidebar {
  width: 160px; flex-shrink: 0;
  background: #f7fafc; border-left: 1px solid #e2e8f0;
  display: flex; flex-direction: column;
  padding: 18px 14px; gap: 10px; overflow-y: auto;
}
body.dark-mode .ps-take-sidebar { background: #0a1220; border-color: #2d3748; }
.ps-item-table-label { font-size: 11px; font-weight: 700; color: #a0aec0; text-transform: uppercase; letter-spacing: .07em; }
.ps-item-table {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}
.ps-item-btn {
  aspect-ratio: 1; border-radius: 6px; border: 1.5px solid #e2e8f0;
  background: #fff; color: #4a5568; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.ps-item-btn:hover { border-color: #6b46c1; color: #6b46c1; }
.ps-item-btn.ps-item-current { background: #6b46c1; color: #fff; border-color: #6b46c1; }
.ps-item-btn.ps-item-answered { background: #c6f6d5; color: #276749; border-color: #9ae6b4; }
body.dark-mode .ps-item-btn { background: #1a2332; border-color: #2d3748; color: #a0aec0; }
body.dark-mode .ps-item-btn.ps-item-current { background: #6b46c1; color: #fff; border-color: #6b46c1; }
body.dark-mode .ps-item-btn.ps-item-answered { background: #1c4532; color: #9ae6b4; border-color: #276749; }
/* Legend */
.ps-item-legend { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #718096; }
.ps-item-legend > span { display: flex; align-items: center; gap: 5px; }
.ps-legend-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.ps-legend-current { background: #6b46c1; }
.ps-legend-answered { background: #c6f6d5; border: 1px solid #9ae6b4; }
.ps-legend-blank { background: #fff; border: 1.5px solid #e2e8f0; }
body.dark-mode .ps-legend-blank { background: #1a2332; border-color: #2d3748; }
/* Submit button in sidebar */
.ps-take-submit-btn { margin-top: auto; padding: 10px 0; font-size: 14px; width: 100%; border-radius: 9px; }

/* On phones, a fixed 160px side column for the item grid eats a big chunk of
   the already-narrow width the question needs. Un-wrap the sidebar (display:
   contents drops its own box, leaving its children as direct flex items of
   .ps-take-body) and reorder those children into a compact item strip pinned
   above the question, and the submit button pinned below it -- the question
   itself gets the full width and the most vertical room in between. */
@media (max-width: 768px) {
  .ps-take-shell { width: 100vw !important; max-width: 100vw !important; height: 100vh; max-height: 100vh; border-radius: 0; }
  .ps-take-body { flex-direction: column; }
  .ps-take-main { order: 2; padding: 16px; }
  .ps-take-sidebar {
    display: contents;
  }
  .ps-item-table-label {
    order: 1; padding: 10px 16px 6px; background: #f7fafc; border-bottom: 1px solid #e2e8f0;
  }
  body.dark-mode .ps-item-table-label { background: #0a1220; border-color: #2d3748; }
  .ps-item-table {
    order: 1;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 6px; padding: 0 16px 10px; max-height: 96px; overflow-y: auto;
    background: #f7fafc; border-bottom: 1px solid #e2e8f0;
  }
  body.dark-mode .ps-item-table { background: #0a1220; border-color: #2d3748; }
  /* The color legend is just a key for the item-grid colors already visible
     above -- drop it on phones to save vertical space for the question. */
  .ps-item-legend { display: none; }
  .ps-take-submit-btn { order: 3; margin: 0; border-radius: 0; padding: 14px 0; flex-shrink: 0; }
}

/* ── Teacher PS Results Modal ───────────────────────────────────────────────── */
.ps-results-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.ps-results-table thead tr {
  border-bottom: 2px solid #e2e8f0;
}
.ps-results-table th {
  padding: 8px 8px; font-weight: 600; color: #4a5568;
}
.ps-result-summary-row td {
  padding: 10px 8px; border-bottom: 1px solid #e2e8f0;
  transition: background .12s;
}
.ps-result-summary-row:hover td { background: #f7fafc; }
body.dark-mode .ps-result-summary-row:hover td { background: #0d1620; }
body.dark-mode .ps-results-table thead tr { border-color: #2d3748; }
body.dark-mode .ps-result-summary-row td { border-color: #2d3748; }
.ps-result-name { font-weight: 600; }
/* Detail row */
.ps-result-detail-cell {
  padding: 0 8px 12px 8px;
  background: #f7fafc;
  border-bottom: 2px solid #e2e8f0;
}
body.dark-mode .ps-result-detail-cell { background: #0a1220; border-color: #2d3748; }
.ps-detail-section { padding: 10px 0 4px; }
.ps-detail-section + .ps-detail-section { border-top: 1px dashed #e2e8f0; margin-top: 8px; }
body.dark-mode .ps-detail-section + .ps-detail-section { border-color: #2d3748; }
.ps-detail-attempt-header {
  font-size: 12px; color: #718096; margin-bottom: 10px; padding: 6px 10px;
  background: #edf2f7; border-radius: 6px;
}
body.dark-mode .ps-detail-attempt-header { background: #1a2332; color: #a0aec0; }
/* Q&A list */
.ps-qa-list { display: flex; flex-direction: column; gap: 6px; }
.ps-qa-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 10px; background: #fff; border-radius: 7px;
  border: 1px solid #e2e8f0;
}
body.dark-mode .ps-qa-item { background: #0d1620; border-color: #2d3748; }
.ps-qa-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: #e9d8fd; color: #6b46c1; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.ps-qa-content { flex: 1; min-width: 0; }
.ps-qa-question { font-size: 13px; color: #2d3748; margin-bottom: 4px; }
body.dark-mode .ps-qa-question { color: #e2e8f0; }
.ps-qa-answers { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.ps-qa-label { color: #a0aec0; }
.ps-qa-student-ans { font-weight: 600; }
.ps-ans-correct { color: #276749; }
.ps-ans-wrong   { color: #c53030; }
.ps-qa-correct-ans { color: #276749; font-weight: 600; }
body.dark-mode .ps-ans-correct { color: #9ae6b4; }
body.dark-mode .ps-ans-wrong   { color: #fc8181; }
body.dark-mode .ps-qa-correct-ans { color: #9ae6b4; }
.ps-qa-badge {
  margin-left: auto; font-size: 13px; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ps-badge-correct { background: #c6f6d5; color: #276749; }
.ps-badge-wrong   { background: #fed7d7; color: #c53030; }
.ps-badge-partial { background: #feebc8; color: #9c4221; width: auto; padding: 0 6px; border-radius: 10px; }
.ps-ans-partial   { color: #9c4221; }
body.dark-mode .ps-ans-partial   { color: #fbd38d; }
body.dark-mode .ps-badge-partial { background: #744210; color: #fbd38d; }

.ps-qa-override-controls { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.ps-ov-btn, .ps-ov-reset {
  width: 20px; height: 20px; padding: 0; border-radius: 5px; border: 1px solid #cbd5e0;
  background: #fff; color: #718096; font-size: 11px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ps-ov-btn:hover, .ps-ov-reset:hover { border-color: #4a90d9; color: #4a90d9; }
.ps-ov-btn:disabled, .ps-ov-reset:disabled { opacity: 0.5; cursor: default; }
.ps-ov-btn.ps-ov-active { background: #4a90d9; border-color: #4a90d9; color: #fff; }
.ps-ov-reset { color: #a0aec0; }
body.dark-mode .ps-ov-btn, body.dark-mode .ps-ov-reset { background: #2d3748; border-color: #4a5568; color: #a0aec0; }
body.dark-mode .ps-ov-btn:hover, body.dark-mode .ps-ov-reset:hover { border-color: #63b3ed; color: #63b3ed; }
body.dark-mode .ps-ov-btn.ps-ov-active { background: #4a90d9; border-color: #4a90d9; color: #fff; }

/* ── Student PS result & review screen ─────────────────────────────────────── */
.ps-result-screen { display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; }
.ps-result-hero { text-align: center; padding: 40px 32px 24px; flex-shrink: 0; }
.ps-result-score { font-size: 36px; font-weight: 800; color: #6b46c1; margin-bottom: 6px; }
.ps-review-panel {
  overflow-y: auto; border-top: 1px solid #e2e8f0;
  padding: 16px 24px 24px; display: flex; flex-direction: column; gap: 10px;
}
body.dark-mode .ps-review-panel { border-color: #2d3748; }
.ps-review-item {
  background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 12px 14px;
}
body.dark-mode .ps-review-item { background: #0d1620; border-color: #2d3748; }
.ps-review-item-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.ps-review-qtext { font-size: 14px; line-height: 1.55; margin-bottom: 8px; }
.ps-review-answers { display: flex; flex-direction: column; gap: 4px; }
.ps-review-ans-row { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ── Handout maker ─────────────────────────────────────────────────────── */
.ho-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 200; }
.ho-modal { background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); width: min(1180px, 96vw); height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.ho-hdr { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid #e2e8f0; flex-shrink: 0; }
.ho-hdr-title { font-size: 1rem; font-weight: 700; color: #1e293b; }
.ho-close { background: none; border: none; font-size: 1.1rem; color: #94a3b8; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.ho-close:hover { background: #f1f5f9; color: #475569; }
.ho-body { display: flex; flex: 1; min-height: 0; }
.ho-left { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; padding: 12px 14px; border-right: 1px solid #e2e8f0; gap: 10px; min-height: 0; }
.ho-right { flex: 1; min-width: 0; background: #e2e8f0; }
.ho-right iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.ho-opt-row label { display: block; font-size: 0.8rem; color: #475569; }
.ho-opt-row input[type=text], .ho-opt-row input[type=number] { display: block; width: 100%; margin-top: 3px; padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.85rem; }
.ho-opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ho-check { display: flex !important; align-items: center; gap: 6px; margin-top: 4px; }
.ho-list-hdr { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: #334155; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
.ho-link { background: none; border: none; color: #2563eb; cursor: pointer; font-size: 0.78rem; padding: 0; }
.ho-list { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; }
.ho-group { margin-bottom: 8px; }
.ho-group-hdr { display: flex; gap: 6px; font-weight: 700; font-size: 0.8rem; color: #1e3a8a; padding: 4px 0; cursor: pointer; }
.ho-limit-note { color: #64748b; font-size: 0.74rem; line-height: 1.35; }
.ho-type-badge { color: #64748b; font-size: 0.72rem; white-space: nowrap; }
.ho-skill-row { display: flex; gap: 6px; font-size: 0.82rem; color: #334155; padding: 2px 0 2px 18px; cursor: pointer; }
.ho-none { color: #94a3b8; font-size: 0.85rem; }
.ho-footer { display: flex; align-items: center; gap: 8px; border-top: 1px solid #e2e8f0; padding-top: 8px; }
.ho-count { flex: 1; font-size: 0.78rem; color: #64748b; }
.ho-btn { padding: 6px 12px; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; cursor: pointer; font-size: 0.82rem; }
.ho-btn:hover:not(:disabled) { background: #f1f5f9; }
.ho-btn--primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.ho-btn--primary:hover:not(:disabled) { background: #1d4ed8; }
.ho-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (prefers-color-scheme: dark) {
  .ho-modal { background: #1e293b; }
  .ho-hdr, .ho-left, .ho-footer, .ho-list-hdr { border-color: #334155; }
  .ho-hdr-title, .ho-list-hdr { color: #e2e8f0; }
  .ho-opt-row label, .ho-skill-row, .ho-count { color: #cbd5e1; }
  .ho-opt-row input[type=text], .ho-opt-row input[type=number] { background: #0f172a; border-color: #334155; color: #e2e8f0; }
  .ho-group-hdr { color: #93c5fd; }
  .ho-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
}

/* Practice leaderboard */
.leaderboard-caption { font-size:13px; line-height:1.5; color:#4a5568; background:#f7fafc; border:1px solid #e2e8f0; border-radius:8px; padding:8px 12px; margin:0 0 12px; text-align:left; }
body.dark-mode .leaderboard-caption { background:#1a202c; border-color:#2d3748; color:#cbd5e0; }
.leaderboard-type-tab[hidden] { display:none; }

/* Practice leaderboard: my progress toward qualifying */
.pq-card { margin:0 0 14px; padding:12px 14px; border:1px solid #bee3f8; background:#ebf8ff; border-radius:10px; text-align:left; color:#2a4365; }
.pq-head { font-size:14px; line-height:1.5; margin-bottom:8px; }
.pq-head--ok { margin-bottom:0; }
.pq-card:has(.pq-head--ok) { border-color:#c6f6d5; background:#f0fff4; color:#22543d; }
.pq-skill { padding:8px 0 4px; }
.pq-skill + .pq-skill { border-top:1px solid rgba(66,153,225,.25); }
.pq-skill-top { display:flex; justify-content:space-between; gap:8px; font-weight:600; font-size:14px; }
.pq-skill-pct { font-variant-numeric:tabular-nums; }
.pq-bar { height:8px; border-radius:6px; background:#bee3f8; overflow:hidden; margin:4px 0; }
.pq-bar-fill { height:100%; border-radius:6px; background:#3182ce; transition:width .4s ease; }
.pq-bar-fill.done { background:#38a169; }
.pq-skill--big .pq-bar { height:12px; }
.pq-sub { display:grid; grid-template-columns:1fr 1fr; gap:12px; font-size:12px; margin-top:6px; }
.pq-sub .pq-bar { height:6px; }
.pq-need { font-size:12px; margin-top:6px; opacity:.9; }
.pq-warn { font-size:12px; margin-top:6px; padding:6px 8px; border-radius:6px; background:#fffaf0; border:1px solid #fbd38d; color:#7b341e; }
.pq-more-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; margin:10px 0 2px; opacity:.75; }
@media (max-width:520px) { .pq-sub { grid-template-columns:1fr; } }
body.dark-mode .pq-card { background:#1a2a3d; border-color:#2c5282; color:#bee3f8; }
body.dark-mode .pq-card:has(.pq-head--ok) { background:#12301f; border-color:#276749; color:#9ae6b4; }
body.dark-mode .pq-bar { background:#2d3748; }
body.dark-mode .pq-warn { background:#3a2a10; border-color:#7b4a12; color:#fbd38d; }

/* Sidebar: Practice leaderboard */
#sidebar-practice-card[hidden] { display:none; }
.sidebar-me-row { display:flex; align-items:center; gap:8px; margin-top:8px; padding:8px 10px; border-radius:8px; background:#ebf8ff; color:#2a4365; font-size:13px; }
.sidebar-me-row strong { font-variant-numeric:tabular-nums; }
.sidebar-me-hint { margin-top:8px; font-size:12px; line-height:1.4; color:#718096; }
body.dark-mode .sidebar-me-row { background:#1a2a3d; color:#bee3f8; }
body.dark-mode .sidebar-me-hint { color:var(--accent-soft); }

/* New-version notice */
#app-update-bar { position:fixed; left:50%; bottom:16px; transform:translateX(-50%); z-index:10050; display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:center; max-width:min(680px, calc(100vw - 24px)); padding:10px 14px; border-radius:12px; background:#2c5282; color:#fff; box-shadow:0 6px 24px rgba(0,0,0,.28); font-size:14px; line-height:1.4; }
#app-update-bar button { font:inherit; font-weight:700; border:none; border-radius:8px; padding:6px 14px; cursor:pointer; }
#app-update-now { background:#fff; color:#2c5282; }
#app-update-later { background:transparent; color:#bee3f8; text-decoration:underline; }

/* Topic taxonomy tags: grade · subject · class/contest · contest names */
.topic-tags { display:flex; flex-wrap:wrap; gap:5px; margin:2px 0 8px; }
.topic-tag { font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; background:#edf2f7; color:#4a5568; }
.topic-tag.tag-grade { background:#e6f0ff; color:#2b5fb4; }
.topic-tag.tag-subject { background:#e8f7ee; color:#23764a; }
.topic-tag.tag-class { background:#fff4dc; color:#8a5a00; }
.topic-tag.tag-contest { background:#fde8ec; color:#a3213b; }
.topic-tag.tag-contest-name { background:#a3213b; color:#fff; }
body.dark-mode .topic-tag { background:#2d3748; color:#cbd5e0; }
body.dark-mode .topic-tag.tag-contest-name { background:#c0405a; color:#fff; }

#app-toast { position:fixed; left:50%; top:24px; transform:translate(-50%,-20px); background:#2f855a; color:#fff; font-weight:700; font-size:15px;
  padding:12px 26px; border-radius:999px; box-shadow:0 8px 24px rgba(0,0,0,.28); z-index:100000; opacity:0; pointer-events:none; transition:opacity .25s, transform .25s; }
#app-toast.show { opacity:1; transform:translate(-50%,0); }

/* Soft shadow so the hero text stays readable on pale colour schemes */
.homepage-title, .homepage-subtitle, .topics-section-title { text-shadow: 0 1px 3px rgba(0,0,0,.35), 0 2px 12px rgba(0,0,0,.25); }

/* Badge preview popup */
.badge-card { cursor: pointer; }
.badge-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.badge-preview-overlay { position:fixed; inset:0; background:rgba(15,23,42,.55); display:none; align-items:center; justify-content:center; z-index:100001; padding:16px; }
.badge-preview-overlay.show { display:flex; }
.badge-preview-card { position:relative; background:#fff; color:#2d3748; border-radius:18px; padding:28px 26px 24px; max-width:360px; width:100%; text-align:center; box-shadow:0 20px 50px rgba(0,0,0,.35); }
body.dark-mode .badge-preview-card { background:#1a2332; color:#e2e8f0; }
.badge-preview-close { position:absolute; top:10px; right:12px; background:none; border:none; font-size:18px; cursor:pointer; color:inherit; opacity:.7; }
.badge-preview-icon { font-size:96px; line-height:1.1; width:150px; height:150px; margin:0 auto 10px; display:flex; align-items:center; justify-content:center; border-radius:50%; background:radial-gradient(circle at 35% 30%, var(--accent-tint), var(--accent-soft)); box-shadow:0 0 0 6px rgba(var(--accent-rgb),.25); }
.badge-preview-card.locked .badge-preview-icon { filter:grayscale(1); opacity:.55; background:#e2e8f0; box-shadow:0 0 0 6px rgba(148,163,184,.3); }
.badge-preview-name { font-size:22px; margin:6px 0 4px; }
.badge-preview-status { font-weight:700; font-size:14px; margin-bottom:10px; }
.badge-preview-card.earned .badge-preview-status { color:#2f855a; }
.badge-preview-card.locked .badge-preview-status { color:#718096; }
.badge-preview-how { font-size:14px; line-height:1.5; margin:0; }
.badge-preview-tag { display:inline-block; margin-top:12px; font-size:12px; font-weight:700; padding:3px 10px; border-radius:999px; background:var(--accent-tint); color:var(--accent-dark); }

.class-focus-editor { display:flex; align-items:center; gap:10px; margin:6px 0 4px; flex-wrap:wrap; }
.class-focus-editor label { font-weight:600; font-size:.9rem; }
.class-focus-editor select { padding:6px 10px; border-radius:8px; border:1px solid var(--border-color, #cbd5e0); background:var(--card-bg, #fff); color:inherit; }

.class-group { grid-column:1 / -1; margin-bottom:14px; }
.class-group-summary { display:flex; align-items:center; gap:10px; cursor:pointer; font-weight:700; font-size:1.05rem; padding:8px 4px; list-style:none; user-select:none; }
.class-group-summary::-webkit-details-marker { display:none; }
.class-group-summary::before { content:"▸"; display:inline-block; transition:transform .15s; }
.class-group[open] > .class-group-summary::before { transform:rotate(90deg); }
.class-group-count { background:rgba(79,70,229,.15); color:inherit; border-radius:999px; padding:1px 10px; font-size:.8rem; font-weight:600; }
.class-group-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(320px, 1fr)); gap:24px; margin-top:8px; }

.asl-quarter > .asl-quarter-hdr { font-weight:700; font-size:1.02rem; }
.asl-quarter > .asl-group-body { padding-left:12px; border-left:3px solid rgba(79,70,229,.25); margin-left:6px; }

.topic-quarter { margin-bottom:12px; }
.topic-quarter-summary { display:flex; align-items:center; gap:10px; cursor:pointer; font-weight:700; font-size:1.1rem; padding:8px 4px; list-style:none; user-select:none; }
.topic-quarter-summary::-webkit-details-marker { display:none; }
.topic-quarter-summary::before { content:"▸"; display:inline-block; transition:transform .15s; }
.topic-quarter[open] > .topic-quarter-summary::before { transform:rotate(90deg); }
.topic-quarter-count { background:rgba(79,70,229,.15); border-radius:999px; padding:1px 10px; font-size:.8rem; font-weight:600; }

.assign-quarter { margin:2px 0 6px; }
.assign-quarter-summary { display:flex; align-items:center; gap:8px; cursor:pointer; font-weight:700; font-size:.85rem; padding:5px 8px; list-style:none; user-select:none; }
.assign-quarter-summary::-webkit-details-marker { display:none; }
.assign-quarter-summary::before { content:"▸"; display:inline-block; transition:transform .15s; }
.assign-quarter[open] > .assign-quarter-summary::before { transform:rotate(90deg); }
.assign-quarter-count { background:rgba(79,70,229,.15); border-radius:999px; padding:0 8px; font-size:.75rem; font-weight:600; }

/* Admin home dashboard */
.th-tiles.th-tiles-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .th-tiles.th-tiles-4 { grid-template-columns: repeat(2, 1fr); } }
.tha-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #edf2f7; }
.tha-row:last-child { border-bottom: 0; }
body.dark-mode .tha-row { border-color: #2d3748; }
.tha-row-info { flex: 1; min-width: 0; }
.tha-row-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tha-row-meta { font-size: 12px; color: #718096; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tha-row .admin-action-btn { flex: none; }

/* Admin user form error: coloured and boxed so it stands out; field names inside are bold */
#admin-user-form-error { background: #fff1f0; border: 1px solid #fc8181; border-left: 4px solid #e53e3e;
  color: #c53030; border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 14px; font-weight: 500; text-align: left; }
#admin-user-form-error strong { color: #9b1c1c; font-weight: 800; }
body.dark-mode #admin-user-form-error { background: #3b1a1a; border-color: #c53030; color: #feb2b2; }
body.dark-mode #admin-user-form-error strong { color: #fff5f5; }

/* ── Admin panel polish ─────────────────────────────────────────────────────────────────────── */
.admin-header-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-page-title { margin: 0; }
.admin-page-sub { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: #2d3748; text-shadow: 0 1px 2px rgba(255,255,255,.5); }
body.dark-mode .admin-page-sub { color: #cbd5e1; text-shadow: none; }
.admin-new-btn, .admin-header-actions .primary-btn {
  padding: 11px 22px; border: none; border-radius: 12px; cursor: pointer; font-weight: 800; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 4px 14px rgba(99,102,241,.4); transition: transform .12s, box-shadow .12s;
}
.admin-new-btn:hover, .admin-header-actions .primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(99,102,241,.5); }
.admin-tabs { background: rgba(255,255,255,.55); backdrop-filter: blur(6px); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
body.dark-mode .admin-tabs { background: rgba(17,24,39,.55); }
.admin-search-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-search-box { position: relative; flex: 1; min-width: 240px; max-width: 520px; }
.admin-search-box .admin-search-input { width: 100%; box-sizing: border-box; padding-left: 40px; border-radius: 12px; }
.admin-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; pointer-events: none; }
.admin-count { font-size: 13px; font-weight: 700; color: #2d3748; background: rgba(255,255,255,.6); padding: 5px 12px; border-radius: 999px; }
body.dark-mode .admin-count { color: #e5e7eb; background: rgba(255,255,255,.1); }
.admin-card { background: rgba(255,255,255,.72); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.7); border-radius: 18px; padding: 8px 14px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.08); overflow-x: auto; }
body.dark-mode .admin-card { background: rgba(17,24,39,.72); border-color: rgba(255,255,255,.08); }
.admin-users-table { border-spacing: 0 6px; }
.admin-users-table th { padding: 10px 14px 4px; color: #4b5563; }
.admin-th-actions { text-align: right; }
.admin-users-table tbody tr { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.admin-users-table tbody tr:hover { background: #f5f3ff; }
body.dark-mode .admin-users-table tbody tr:hover { background: #2a3350; }
.admin-avatar { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; font-size: 20px; background: linear-gradient(135deg, #e0e7ff, #c7d2fe); box-shadow: inset 0 0 0 2px rgba(255,255,255,.8); }
body.dark-mode .admin-avatar { background: linear-gradient(135deg, #312e81, #3730a3); box-shadow: none; }
.admin-name { font-weight: 800; color: #111827; }
body.dark-mode .admin-name { color: #f9fafb; }
.admin-muted { color: #6b7280 !important; font-size: 13px; }
body.dark-mode .admin-muted { color: #9ca3af !important; }
.admin-grade-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #e0f2fe; color: #075985; }
body.dark-mode .admin-grade-chip { background: rgba(56,189,248,.18); color: #7dd3fc; }
.admin-section { font-size: 12px; font-weight: 700; color: #6b7280; }
.admin-status-chip::before { content: "●"; font-size: 8px; margin-right: 6px; vertical-align: 1px; }
.admin-status-chip.active { border: none; } .admin-status-chip.inactive { border: none; }
.admin-actions { justify-content: flex-end; }
.admin-empty { padding: 40px; }
.admin-view-as-desc { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: #2d3748; text-shadow: 0 1px 2px rgba(255,255,255,.5); }
body.dark-mode .admin-view-as-desc { color: #cbd5e1; text-shadow: none; }
.admin-view-as-search-row { margin-bottom: 14px; }
.admin-viewas-list { background: rgba(255,255,255,.72); border-radius: 18px; padding: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.08); }
body.dark-mode .admin-viewas-list { background: rgba(17,24,39,.72); }
@media (max-width: 720px) { .admin-header-row { align-items: flex-start; } .admin-users-table th:nth-child(4), .admin-users-table td:nth-child(4) { display: none; } }

/* Admin: teaching subjects */
.admin-subject-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.admin-subject-check { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-weight: 700; font-size: 13px; cursor: pointer; border: 1.5px solid #c7d2fe; }
.admin-subject-check input { accent-color: #6366f1; }
body.dark-mode .admin-subject-check { background: rgba(99,102,241,.18); color: #c7d2fe; border-color: #4f46e5; }
.admin-subjects-note { display: block; margin-top: 6px; color: #6b7280; font-size: 12px; }
.admin-subject-chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #e0e7ff; color: #3730a3; }
.admin-subject-chip.s-chemistry { background: #dcfce7; color: #166534; }
.admin-subject-chip.s-nce { background: #fef3c7; color: #92400e; }
body.dark-mode .admin-subject-chip { background: rgba(99,102,241,.25); color: #c7d2fe; }
body.dark-mode .admin-subject-chip.s-chemistry { background: rgba(34,197,94,.2); color: #86efac; }
body.dark-mode .admin-subject-chip.s-nce { background: rgba(245,158,11,.2); color: #fcd34d; }

/* Teacher: delete class */
.class-focus-editor { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.class-delete-btn { margin-left: auto; padding: 8px 16px; border-radius: 10px; border: 1.5px solid #f87171; background: rgba(239,68,68,.08); color: #dc2626; font-weight: 700; font-size: 13px; cursor: pointer; transition: background .15s, color .15s; }
.class-delete-btn:hover { background: #ef4444; color: #fff; }
body.dark-mode .class-delete-btn { color: #fca5a5; border-color: #ef4444; }

/* ── Messages: Gmail-style layout ─────────────────────────────────────────────────────────────── */
.messaging-page-head { max-width: 1100px; margin: 0 auto; padding: 28px 20px 14px; }
.messaging-page-head .section-title { margin: 0; }
.messaging-wrap {
  height: auto; min-height: 460px; max-height: calc(100vh - 210px); margin: 0 auto 28px;
  background: rgba(255,255,255,.78); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.7); border-radius: 22px; box-shadow: 0 10px 34px rgba(0,0,0,.1); overflow: hidden;
}
body.dark-mode .messaging-wrap { background: rgba(17,24,39,.78); border-color: rgba(255,255,255,.08); }
.messaging-sidebar { width: 236px; min-width: 200px; padding: 18px 12px 18px 10px; background: rgba(99,102,241,.05); border-right: 1px solid rgba(0,0,0,.06); gap: 2px; }
.messaging-sidebar-header { padding: 0 6px 16px; }
.msg-compose-btn {
  display: inline-flex; align-items: center; gap: 12px; padding: 15px 26px 15px 20px; border: none; border-radius: 18px; cursor: pointer;
  font-size: 15px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 6px 18px rgba(99,102,241,.45); transition: transform .12s, box-shadow .12s;
}
.msg-compose-btn:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(99,102,241,.55); }
.msg-compose-icon { font-size: 18px; }
.msg-folder { padding: 9px 14px 9px 16px; border-radius: 0 999px 999px 0; font-size: 14px; font-weight: 600; gap: 14px; margin-right: -12px; width: calc(100% + 12px); box-sizing: border-box; }
.msg-folder-icon { font-size: 16px; }
.msg-folder-name { flex: 1; }
.msg-folder:hover { background: rgba(99,102,241,.1); }
.msg-folder.active { background: #dfe6ff; color: #312e81; font-weight: 800; }
body.dark-mode .msg-folder.active { background: rgba(99,102,241,.3); color: #e0e7ff; }
.msg-unread-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #6366f1; color: #fff; font-size: 12px; font-weight: 800; align-items: center; justify-content: center; }
.messaging-main { background: transparent; }
#msg-list { flex: 1; width: auto; min-width: 0; border-right: none; overflow-y: auto; }
.messaging-main:has(#msg-detail[style*="block"]) #msg-list { flex: none; width: 360px; border-right: 1px solid rgba(0,0,0,.06); }
.msg-list-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: baseline; justify-content: space-between; padding: 16px 22px 12px; background: rgba(255,255,255,.9); border-bottom: 1px solid rgba(0,0,0,.06); backdrop-filter: blur(6px); }
body.dark-mode .msg-list-head { background: rgba(17,24,39,.9); border-color: rgba(255,255,255,.08); }
.msg-list-title { font-size: 18px; font-weight: 800; }
.msg-list-count { font-size: 12px; font-weight: 700; color: #6366f1; background: rgba(99,102,241,.12); padding: 3px 11px; border-radius: 999px; }
.msg-row { position: relative; align-items: center; gap: 14px; padding: 12px 22px; background: rgba(120,130,150,.07); border-bottom: 1px solid rgba(0,0,0,.05); }
.msg-row.unread { background: #fff; }
body.dark-mode .msg-row { background: rgba(255,255,255,.04); }
body.dark-mode .msg-row.unread { background: rgba(255,255,255,.1); }
.msg-row:hover { background: #f5f3ff; box-shadow: inset 3px 0 0 #6366f1; }
body.dark-mode .msg-row:hover { background: rgba(99,102,241,.2); }
.msg-row.selected { background: #eef2ff; box-shadow: inset 3px 0 0 #6366f1; }
.msg-row-avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; background: linear-gradient(135deg, #e0e7ff, #c7d2fe); flex: none; }
body.dark-mode .msg-row-avatar { background: linear-gradient(135deg, #312e81, #3730a3); }
.msg-row-body { min-width: 0; display: grid; grid-template-columns: 190px 1fr; align-items: baseline; column-gap: 16px; flex: 1; }
.messaging-main:has(#msg-detail[style*="block"]) .msg-row-body { grid-template-columns: 1fr; }
.msg-row-from { font-size: 14px; font-weight: 500; }
.msg-row-to { opacity: .6; font-weight: 600; }
.msg-row-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.msg-row-subject { font-weight: 500; opacity: 1; }
.msg-row-snippet { opacity: .55; font-size: 14px; }
.msg-row.unread .msg-row-from, .msg-row.unread .msg-row-subject { font-weight: 800; }
.msg-row-date { font-size: 12px; font-weight: 600; opacity: .6; }
.msg-row.unread .msg-row-date { opacity: 1; color: #4f46e5; font-weight: 800; }
.msg-row-dot { width: 9px; height: 9px; border-radius: 50%; background: #6366f1; flex: none; box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.msg-empty { padding: 56px 12px; font-size: 15px; }
#msg-detail { padding: 24px 34px 30px; background: rgba(255,255,255,.92); }
body.dark-mode #msg-detail { background: rgba(17,24,39,.92); }
.msg-back-btn { margin-bottom: 14px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid #c7d2fe; background: #eef2ff; color: #4338ca; font-weight: 700; font-size: 13px; cursor: pointer; }
.msg-back-btn:hover { background: #6366f1; color: #fff; }
.msg-detail-subject { order: -1; font-size: 24px; font-weight: 800; letter-spacing: -.2px; border: none; padding-bottom: 6px; margin: 4px 0 18px; }
#msg-detail-content { display: flex; flex-direction: column; }
.msg-detail-avatar { width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.msg-detail-from { font-size: 16px; font-weight: 800; }
.msg-detail-date { font-size: 12.5px; opacity: .65; }
.msg-detail-body { font-size: 15.5px; line-height: 1.75; padding: 16px 18px; border-radius: 14px; background: rgba(99,102,241,.06); }
.msg-action-btn { border-radius: 999px; padding: 7px 16px; font-weight: 700; }
@media (max-width: 860px) {
  .messaging-wrap { max-height: none; }
  .msg-row-body { grid-template-columns: 1fr !important; }
  .messaging-main:has(#msg-detail[style*="block"]) #msg-list { width: 100%; border-right: none; display: none; }
}

/* ── Compose pop-up (Gmail "New message" style) ───────────────────────────────────────────────── */
#compose-modal { background: rgba(15,23,42,.55); backdrop-filter: blur(3px); }
.modal-content.compose-pop { padding: 0; width: min(640px, calc(100vw - 24px)); max-width: 640px; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: composeIn .18s ease-out; }
body.dark-mode .modal-content.compose-pop { background: #1f2937; color: #f9fafb; }
@keyframes composeIn { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 14px 22px; background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; }
.compose-head-title { font-size: 16px; font-weight: 800; letter-spacing: .1px; }
.compose-head-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 15px; cursor: pointer; transition: background .15s; }
.compose-head-close:hover { background: rgba(255,255,255,.34); }
.compose-form { display: flex; flex-direction: column; padding: 4px 0 0; }
.compose-row { display: flex; align-items: center; gap: 12px; padding: 4px 22px; border-bottom: 1px solid rgba(0,0,0,.08); }
body.dark-mode .compose-row { border-bottom-color: rgba(255,255,255,.1); }
.compose-row label { width: 64px; flex: none; font-size: 13px; font-weight: 800; color: #6366f1; }
.compose-row select, .compose-row input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: inherit; font-size: 15px; padding: 12px 0; font-family: inherit; }
.compose-row:focus-within { background: rgba(99,102,241,.05); }
.compose-body { border: none; outline: none; resize: vertical; min-height: 200px; padding: 16px 22px; font-size: 15px; line-height: 1.65; background: transparent; color: inherit; font-family: inherit; }
.compose-foot { display: flex; align-items: center; gap: 12px; padding: 14px 22px 18px; border-top: 1px solid rgba(0,0,0,.06); background: rgba(99,102,241,.04); }
.compose-send { padding: 11px 28px; border: none; border-radius: 999px; font-size: 15px; font-weight: 800; color: #fff; cursor: pointer; background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 5px 16px rgba(99,102,241,.45); transition: transform .12s, box-shadow .12s; }
.compose-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(99,102,241,.55); }
.compose-send:disabled { opacity: .6; cursor: wait; }
.compose-discard { margin-left: auto; padding: 9px 18px; border-radius: 999px; border: 1.5px solid transparent; background: transparent; color: #6b7280; font-weight: 700; font-size: 14px; cursor: pointer; }
.compose-discard:hover { background: rgba(239,68,68,.08); color: #dc2626; border-color: rgba(239,68,68,.35); }

/* Class messages */
.compose-class-note { padding: 9px 22px; font-size: 13px; font-weight: 700; color: #3730a3; background: #eef2ff; border-bottom: 1px solid rgba(99,102,241,.2); }
body.dark-mode .compose-class-note { background: rgba(99,102,241,.2); color: #c7d2fe; }
.msg-class-tag { display: inline-block; padding: 1px 9px; margin-right: 4px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #3730a3; background: #e0e7ff; }
.msg-class-count { margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #166534; background: #dcfce7; }
/* Students only read: no Compose, no Sent folder */
body.messages-readonly #compose-msg-btn { display: none; }

/* Reply box under an open message */
.msg-reply { margin-top: 20px; }
.msg-reply-open { padding: 9px 22px; border-radius: 999px; border: 1.5px solid #c7d2fe; background: #fff; color: #4338ca; font-weight: 800; font-size: 14px; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.msg-reply-open:hover { background: #6366f1; color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.35); }
body.dark-mode .msg-reply-open { background: transparent; color: #c7d2fe; border-color: #4f46e5; }
.msg-reply-box { border: 1.5px solid #c7d2fe; border-radius: 16px; background: #fff; overflow: hidden; box-shadow: 0 6px 20px rgba(99,102,241,.12); }
body.dark-mode .msg-reply-box { background: #1f2937; border-color: #4f46e5; }
.msg-reply-note { padding: 9px 16px; font-size: 12.5px; font-weight: 700; color: #3730a3; background: #eef2ff; }
body.dark-mode .msg-reply-note { background: rgba(99,102,241,.2); color: #c7d2fe; }
.msg-reply-box textarea { display: block; width: 100%; box-sizing: border-box; border: none; outline: none; resize: vertical; min-height: 110px; padding: 14px 16px; font-size: 15px; line-height: 1.6; font-family: inherit; background: transparent; color: inherit; }
.msg-reply-actions { display: flex; align-items: center; gap: 12px; padding: 10px 16px 14px; }
.msg-reply-sent { padding: 18px; font-weight: 700; color: #166534; background: #f0fdf4; }

/* Compose: e-mail copy option */
.compose-email-copy { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 22px; font-size: 14px; border-top: 1px solid rgba(0,0,0,.06); cursor: pointer; }
.compose-email-copy input { width: 18px; height: 18px; accent-color: #6366f1; flex: none; }
.compose-email-copy small { flex-basis: 100%; margin-left: 28px; color: #92400e; font-weight: 600; }
.compose-email-copy.disabled { opacity: .75; cursor: not-allowed; }

/* Conversation (thread) under an open message */
.msg-thread { margin-top: 18px; border: 1.5px solid #e0e7ff; border-radius: 14px; overflow: hidden; background: rgba(99,102,241,.04); }
body.dark-mode .msg-thread { border-color: rgba(99,102,241,.35); }
.msg-thread-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 16px; border: none; background: transparent; color: #4338ca; font-weight: 800; font-size: 14px; cursor: pointer; text-align: left; }
body.dark-mode .msg-thread-toggle { color: #c7d2fe; }
.msg-thread-toggle:hover { background: rgba(99,102,241,.1); }
.msg-thread-caret { display: inline-block; width: 14px; transition: transform .15s; }
.msg-thread.open .msg-thread-caret { transform: rotate(90deg); }
.msg-thread-count { margin-left: auto; min-width: 22px; padding: 0 8px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: #6366f1; color: #fff; font-size: 12px; }
.msg-thread-item { border-top: 1px solid rgba(99,102,241,.15); }
.msg-thread-item.current { background: rgba(99,102,241,.1); }
.msg-thread-head { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; font-size: 13.5px; }
.msg-thread-head:hover { background: rgba(99,102,241,.08); }
.msg-thread-avatar { font-size: 18px; flex: none; }
.msg-thread-who { font-weight: 800; flex: none; }
.msg-thread-item.mine .msg-thread-who { color: #4338ca; }
.msg-thread-snippet { flex: 1; min-width: 0; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread-when { flex: none; font-size: 12px; opacity: .65; }
.msg-thread-body { padding: 4px 16px 14px 44px; font-size: 14.5px; line-height: 1.65; }

/* Admin: e-mail diagnostics */
.admin-email-status { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 18px; }
.admin-email-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); font-size: 14px; }
body.dark-mode .admin-email-row { background: #1f2937; }
.admin-email-row b { min-width: 190px; }
.admin-email-row span:last-child { color: #4b5563; word-break: break-word; }
body.dark-mode .admin-email-row span:last-child { color: #d1d5db; }
.admin-email-row.bad { box-shadow: inset 3px 0 0 #ef4444, 0 1px 3px rgba(0,0,0,.06); }
.admin-email-row.ok { box-shadow: inset 3px 0 0 #22c55e, 0 1px 3px rgba(0,0,0,.06); }
.admin-email-test { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-email-test .admin-search-input { flex: 1; min-width: 240px; }
.admin-email-result { margin-top: 14px; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6; background: #f3f4f6; }
.admin-email-result.ok { background: #f0fdf4; color: #166534; }
.admin-email-result.bad { background: #fef2f2; color: #991b1b; }

/* Question bank: audit all problem types */
.qb-audit-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 10px 0; position: sticky; top: 0; z-index: 5; background: var(--bg-card, #fff); padding: 8px 0; }
.qb-audit-item { margin-bottom: 14px; }
.qb-audit-item.qb-flagged { border: 2px solid #dc2626; }
.qb-flag { color: #dc2626; font-weight: 700; margin-left: 8px; }
.qb-audit-choice { padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 8px; margin: 3px 0; display: flex; gap: 8px; align-items: center; }
.qb-audit-choice.correct-reveal { border-color: #059669; background: #d1fae5; color: #064e3b; }
.qb-audit-ahint { font-size: 0.85em; opacity: 0.75; margin: 6px 0; }
#qb-audit-list.qb-only-flagged .qb-audit-item[data-flagged="0"] { display: none; }
body.dark-mode .qb-audit-bar { background: var(--bg-card, #1e293b); }
body.dark-mode .qb-audit-choice.correct-reveal { background: #064e3b; color: #d1fae5; }

/* Question bank audit: print / save as PDF */
#qb-print-root { display: none; }
@media print {
  body.qb-printing > *:not(#qb-print-root) { display: none !important; }
  body.qb-printing #qb-print-root { display: block !important; position: static !important; left: auto !important; width: auto !important; padding: 0; background: #fff; color: #000; }
  body.qb-printing #qb-print-root .qb-audit-item { break-inside: avoid; margin-bottom: 10px; box-shadow: none; border: 1px solid #94a3b8; padding: 8px; }
  body.qb-printing #qb-print-root .qb-audit-item.qb-flagged { border: 2px solid #dc2626; }
  body.qb-printing #qb-print-root .qb-audit-choice.correct-reveal { background: #d1fae5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.qb-printing #qb-print-root svg { max-width: 100%; height: auto; }
}

.stu-last-activity { font-size: 12px; color: #718096; white-space: nowrap; background: rgba(160,174,192,.16); border-radius: 10px; padding: 3px 8px; }
body.dark-mode .stu-last-activity { color: #a0aec0; }

.roster-last-activity { font-size: 12px; color: #718096; margin-top: 2px; }
body.dark-mode .roster-last-activity { color: #a0aec0; }

.ps-not-submitted { margin: 2px 0 10px; padding-left: 2px; }
.ps-not-submitted summary { cursor: pointer; font-size: 13px; font-weight: 600; color: #c05621; }
.ps-not-submitted ul { margin: 6px 0 0 18px; padding: 0; columns: 2; font-size: 13px; color: #4a5568; }
body.dark-mode .ps-not-submitted ul { color: #cbd5e0; }
@media (max-width: 600px) { .ps-not-submitted ul { columns: 1; } }

.teach-note > summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
.teach-note[open] > summary { margin-bottom: 6px; }

.ps-quarter { margin-bottom: 14px; }
.ps-quarter-head { cursor: pointer; font-weight: 700; font-size: 1.05rem; padding: 8px 4px; margin-bottom: 8px; }
.ps-quarter-count { font-weight: 500; font-size: .85rem; opacity: .7; margin-left: 8px; }
.scb-ps-quarter { margin-bottom: 4px; display: flex; flex-direction: column; gap: 8px; }
.scb-ps-quarter > .ps-quarter-head { font-size: 12px; font-weight: 700; color: #4a5568; padding: 2px 0; margin: 0; }
.scb-ps-quarter .ps-quarter-count { font-size: 11px; font-weight: 600; margin-left: 4px; }
body.dark-mode .scb-ps-quarter > .ps-quarter-head { color: #cbd5e0; }

/* Math keypad above typed answers */
.math-keypad { margin-bottom: 8px; }
.mk-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.mk-fn-row { display: none; }
.mk-fn-row.open { display: flex; }
.mk-btn {
  min-width: 38px; height: 34px; padding: 0 10px; border: none; border-radius: 8px; cursor: pointer;
  background: #1e4a6b; color: #fff; font-weight: 700; font-size: 15px; font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,.18); transition: transform .08s ease, background .15s ease;
}
.mk-btn:hover { background: #276089; }
.mk-btn:active { transform: translateY(1px); box-shadow: none; }
.mk-btn.active { background: #2b7a9e; }
.mk-btn.mk-clr { background: #b9461f; }
.mk-btn.mk-expand { background: #6b46c1; border: 2px dashed rgba(255,255,255,.55); }
.mk-btn.mk-expand:hover { background: #7c58d4; }
.mk-btn.mk-expand::after { content: "▾"; margin-left: 5px; font-size: 11px; display: inline-block; transition: transform .15s ease; }
.mk-btn.mk-expand.active { background: #4c2f94; border-style: solid; }
.mk-btn.mk-expand.active::after { transform: rotate(180deg); }
.mk-fn-row .mk-btn { background: #3a6b8c; font-weight: 600; font-size: 14px; }
@media (max-width: 480px) { .mk-btn { min-width: 34px; height: 32px; padding: 0 8px; } }
.mk-preview { margin-top: 6px; padding: 8px 12px; border-radius: 8px; background: rgba(30,74,107,.07); color: #2d3748; font-size: 17px; overflow-x: auto; }
body.dark-mode .mk-preview { background: rgba(255,255,255,.08); color: #e2e8f0; }

/* Question Bank collapsible skill picker */
.qb-picker { position: relative; display: inline-block; min-width: 260px; max-width: 100%; }
.qb-picker-btn { width: 100%; text-align: left; cursor: pointer; }
.qb-picker-panel { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; width: max(100%, 380px); max-height: 60vh; overflow: hidden; display: flex; flex-direction: column; background: #fff; border: 1px solid #cbd5e0; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.qb-picker-search { margin: 8px; padding: 7px 10px; border: 1px solid #cbd5e0; border-radius: 8px; font-size: 14px; }
.qb-picker-list { overflow-y: auto; min-height: 0; padding: 0 6px 8px; }
.qb-picker-section { position: sticky; top: 0; z-index: 1; margin: 6px 0 2px; padding: 5px 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: #667eea; border-radius: 6px; }
.qb-picker-year { margin: 6px 0 1px; padding: 2px 8px; font-size: 11px; font-weight: 700; color: #667eea; border-bottom: 1px solid rgba(102,126,234,.3); }
.qb-picker-group > summary { cursor: pointer; font-weight: 700; font-size: 13px; padding: 7px 8px; color: #2d3748; border-radius: 6px; }
.qb-picker-group > summary:hover { background: rgba(66,153,225,.1); }
.qb-picker-count { font-weight: 500; opacity: .6; margin-left: 4px; }
.qb-picker-item { display: block; width: 100%; text-align: left; padding: 6px 12px 6px 22px; border: none; background: none; cursor: pointer; font-size: 14px; color: #2d3748; border-radius: 6px; font-family: inherit; }
.qb-picker-list > .qb-picker-item { padding-left: 8px; font-weight: 600; }
.qb-picker-item:hover { background: rgba(66,153,225,.12); }
.qb-picker-item.selected { background: rgba(66,153,225,.22); font-weight: 700; }
body.dark-mode .qb-picker-panel { background: #1a202c; border-color: #4a5568; }
body.dark-mode .qb-picker-search { background: #2d3748; color: #e2e8f0; border-color: #4a5568; }
body.dark-mode .qb-picker-group > summary, body.dark-mode .qb-picker-item { color: #e2e8f0; }

/* Bug-report button and dialog */
.ps-bug-btn { background: none; border: 0; cursor: pointer; font-size: 1rem; padding: 0 4px; opacity: .75; }
.ps-bug-btn:hover { opacity: 1; }
.bug-report-modal { text-align: left; max-width: 460px; }
.bug-report-title { margin: 0 0 6px; }
.bug-report-desc { margin: 0 0 10px; opacity: .8; font-size: .92rem; }
.bug-report-note { width: 100%; box-sizing: border-box; padding: 8px; border-radius: 8px; border: 1px solid #c9c9c9; font: inherit; }
body.dark-mode .bug-report-note { background: #0f1722; color: inherit; border-color: #2d3748; }
.bug-report-msg { margin-top: 8px; font-size: .92rem; }
.bug-report-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.admin-bug-card { border: 1px solid #d6d6d6; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
body.dark-mode .admin-bug-card { border-color: #2d3748; }
.admin-bug-card summary { cursor: pointer; }
.bug-item-line { margin: 6px 0; }

/* Skill picker inside the teacher's presentation toolbar (dark bar) and the Present-a-skill dialog */
.teach-toolbar-left .qb-picker { min-width: 220px; max-width: 320px; }
.teach-toolbar-left .qb-picker-btn { background: rgba(255,255,255,0.12); color: #f1f5f9; border: 1px solid rgba(255,255,255,0.3); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.teach-toolbar-left .qb-picker-btn:hover { background: rgba(255,255,255,0.2); }
#present-skill-modal .qb-picker { display: block; width: 100%; }
#present-skill-modal .qb-picker-panel { position: static; margin-top: 6px; max-height: 40vh; box-shadow: none; }

/* Admin research tab */
.admin-research-out { margin-top: 14px; }
.rs-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.rs-stat { background: #fff; border-radius: 12px; padding: 10px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; min-width: 110px; }
.rs-stat b { font-size: 1.25rem; } .rs-stat span { font-size: .78rem; opacity: .7; }
body.dark-mode .rs-stat { background: #1f2937; }
.rs-h { margin: 22px 0 6px; font-size: 1.05rem; }
.rs-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rs-table th, .rs-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid rgba(128,128,128,.18); }
.rs-table .rs-num, .rs-table th.rs-num { text-align: right; font-variant-numeric: tabular-nums; }
.rs-best td:first-child { font-weight: 700; }
.rs-bar { display: inline-block; width: 100%; min-width: 90px; height: 9px; border-radius: 5px; background: rgba(128,128,128,.2); overflow: hidden; vertical-align: middle; }
.rs-bar i { display: block; height: 100%; background: #3b82f6; } .rs-bar.neg i { background: #ef4444; } .rs-bar.auc i { background: #10b981; }
.rs-small { font-size: .88rem; line-height: 1.5; margin: 8px 0; } .rs-muted { opacity: .6; }
.rs-note { background: #fef3c7; color: #78350f; padding: 8px 12px; border-radius: 10px; font-size: .88rem; }

.rs-off { color: #dc2626; font-weight: 600; }

.admin-research-field { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; opacity: .9; }
.admin-research-field .admin-search-input { font-weight: 400; }

/* Admin experiment section */
.exp-sep { border: 0; border-top: 1px solid rgba(128,128,128,.3); margin: 26px 0 6px; }
.exp-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 10px 0; }
.exp-check { font-size: .85rem; display: flex; gap: 6px; align-items: center; padding-bottom: 6px; }
.exp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 8px 0 12px; }
.exp-label { font-size: .78rem; font-weight: 700; margin-bottom: 4px; }
.exp-list { max-height: 190px; overflow: auto; border: 1px solid rgba(128,128,128,.3); border-radius: 10px; padding: 6px 10px; font-size: .86rem; background: rgba(255,255,255,.5); }
body.dark-mode .exp-list { background: rgba(17,24,39,.5); }
.exp-list label { display: flex; gap: 6px; align-items: center; padding: 2px 0; }
.exp-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.exp-badge.off { background: #e5e7eb; color: #374151; } .exp-badge.dry { background: #fef3c7; color: #92400e; } .exp-badge.on { background: #d1fae5; color: #065f46; }
.exp-warn { background: #fee2e2; color: #7f1d1d; padding: 8px 12px; border-radius: 10px; font-size: .88rem; margin: 6px 0; }

.topic-track-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.topic-track-chip { border: 1px solid #cbd5e0; background: #fff; color: #2d3748; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.topic-track-chip:hover { border-color: #667eea; }
.topic-track-chip.active { background: #667eea; border-color: #667eea; color: #fff; }
body.dark-mode .topic-track-chip { background: #2d3748; color: #e2e8f0; border-color: #4a5568; }
body.dark-mode .topic-track-chip.active { background: #667eea; color: #fff; }

.class-edit-btn { border: 1px solid #cbd5e0; background: #fff; color: #2d3748; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.class-edit-btn:hover { border-color: #667eea; color: #5a67d8; }
body.dark-mode .class-edit-btn { background: #2d3748; color: #e2e8f0; border-color: #4a5568; }

.ho-section { position: sticky; top: 0; z-index: 1; margin: 8px 0 2px; padding: 5px 10px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: #667eea; border-radius: 6px; }
.ho-year { margin: 6px 0 1px; padding: 2px 10px; font-size: 11px; font-weight: 700; color: #667eea; border-bottom: 1px solid rgba(102,126,234,.3); }

.ps-skill-section { position: sticky; top: 0; z-index: 1; margin: 6px 0 2px; padding: 4px 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: #667eea; border-radius: 6px; }
.ps-skill-year { margin: 4px 0 1px; padding: 2px 8px; font-size: 11px; font-weight: 700; color: #667eea; border-bottom: 1px solid rgba(102,126,234,.3); }
.ps-skill-topic { margin: 3px 0 0; padding: 2px 8px; font-size: 11px; font-weight: 600; color: #718096; }
