/* ═══════════════════════════════════════════════════════════════════════
   redesign.css — 2026 visual refresh (classroom + behaviour + app chrome).

   SCOPE / SAFETY
   ──────────────
   • Every selector below targets ONLY non-gamification UI. The gamification
     screen's files (gamification/, web-avatar/, src/game/, src/ancients*.js/css,
     vendor/three/) and its bespoke classes (.gamified-nav-btn, .avatar-card,
     .store-*, .leaderboard-*, .battle-*, .team-charter-*, .cq-*, .theme-ancients,
     …) are never selected here.
   • Existing shared classes (.modal-overlay, .secondary-btn, .success-btn, …)
     are restyled ONLY inside non-gamified containers (#classroomView, #dashboardView,
     #summaryView, #groupingView, #reportsView, #noiseMonitorView, .header,
     .main-nav, .app-modal). Gamified panels and modals therefore keep their
     current rendering unchanged.
   • Seating-chart cards (.seat, .student-name, .behavior-*) belong to the
     classroom view only — safe to restyle directly.

   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1. DESIGN TOKENS ──────────────────────────────────────────────────── */

/* Light theme (default when the OS does not request dark). */
:root,
html[data-theme="light"] {
  --bg-app: #F8F7F2;
  --bg-card: #FFFFFF;
  --bg-subtle: #EAE7DF;
  --bg-stat-tile: #EAE7DF;
  --color-primary: #183059;
  --color-primary-text: #FFFFFF;
  --color-accent: #3B7A57;
  /* Auth CTAs — Sign Up (teal) / Login (mustard). Deliberately their own tokens
     rather than --color-primary, which is navy in the light theme: these must
     read as teal + mustard whichever theme a classroom projector is on. */
  --brand-teal: #0E7C6B;
  --brand-teal-text: #FFFFFF;
  --brand-mustard: #D99A00;
  --brand-mustard-text: #2B1D00;
  --color-text: #1C2024;
  --color-text-muted: #6B7280;
  --border-card: #DCE6F2;
  --border-radius-card: 16px;
  --border-radius-tile: 12px;
  --border-radius-pill: 999px;
  --shadow-card: 0 4px 16px rgba(30, 35, 64, 0.08);
  --shadow-modal: 0 12px 40px rgba(30, 35, 64, 0.18);

  /* Semantic behavior colors (badge pills, stepper "+", stat accents). */
  --behavior-green: #3B7A57;
  --behavior-gold: #C58B2B;
  --behavior-teal: #3F8F86;
  --behavior-coral: #E0645A;
  --behavior-grey: #4B5563;
  --behavior-maroon: #8B2626;
  --behavior-orange: #E8892F;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

/* Dark theme. */
html[data-theme="dark"] {
  --bg-app: #1C1F23;
  --bg-card: #2B2E33;
  --bg-subtle: #22252A;
  --bg-stat-tile: #22252A;
  --color-primary: #4FA89E;
  --color-primary-text: #0B1A1A;
  --color-accent: #4FA89E;
  /* Auth CTAs — see the light theme for why these are their own tokens. */
  --brand-teal: #2FB3A0;
  --brand-teal-text: #06231F;
  --brand-mustard: #E3AC1F;
  --brand-mustard-text: #2B1D00;
  --color-text: #E6E8EB;
  --color-text-muted: #9AA0A6;
  --border-card: transparent;
  --border-radius-card: 16px;
  --border-radius-tile: 12px;
  --border-radius-pill: 999px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 12px 40px rgba(0, 0, 0, 0.55);

  --behavior-green: #3B7A57;
  --behavior-gold: #C58B2B;
  --behavior-teal: #3F8F86;
  --behavior-coral: #E0645A;
  --behavior-grey: #4B5563;
  --behavior-maroon: #8B2626;
  --behavior-orange: #E8892F;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

/* ── 2. APP CHROME (header / nav / shell) ──────────────────────────────── */

body {
  background: var(--bg-app);
  color: var(--color-text);
}

/* Soft cream page shell. In dark mode the .container blends with the app bg. */
.container {
  background: var(--bg-card);
  border-color: var(--border-card);
  box-shadow: var(--shadow-card);
}

/* Header: page title in the serif display face. */
.header {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-app));
  color: var(--color-text);
}
.header h1 {
  /* Same font as the rest of the page (Inter) — this used to be the Playfair
     Display heading serif, which made the title look like a different app.
     Centred by the header's 1fr auto 1fr grid. */
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0;
  text-align: center;
  color: var(--color-text);
}

/* Save button → primary. */
#manualSaveBtn {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
  border-radius: 10px;
  box-shadow: none;
}
#manualSaveBtn:hover { filter: brightness(1.08); }

/* Theme toggle → pill. */
#theme-toggle-btn {
  background: var(--bg-subtle);
  color: var(--color-text);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-pill);
  width: 42px;
  height: 42px;
  font-size: 18px;
}
#theme-toggle-btn:hover { background: var(--bg-card); }

#saveStatus {
  background: var(--bg-subtle);
  color: var(--color-text);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-pill);
}
#saveStatus.unsaved { background: color-mix(in srgb, var(--behavior-gold) 18%, var(--bg-card)); color: var(--behavior-gold); border-color: transparent; }
#saveStatus.saving  { background: color-mix(in srgb, var(--color-primary) 16%, var(--bg-card)); color: var(--color-primary); border-color: transparent; }
#saveStatus.saved   { background: color-mix(in srgb, var(--behavior-green) 16%, var(--bg-card)); color: var(--behavior-green); border-color: transparent; }

/* Main nav bar. */
.main-nav {
  background: var(--color-primary);
  border-bottom: none;
  padding: 8px;
  gap: 4px;
}
.nav-btn {
  background: transparent;
  color: var(--color-primary-text);
  border-radius: var(--border-radius-pill);
  padding: 9px 16px;
  font-weight: 600;
}
.nav-btn:hover { background: color-mix(in srgb, var(--color-primary-text) 14%, transparent); color: var(--color-primary-text); }
.nav-btn.active { background: var(--color-primary-text); color: var(--color-primary); }
.nav-btn.active::after { display: none; }

html[data-theme="dark"] .main-nav {
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
html[data-theme="dark"] .nav-btn { color: var(--color-text-muted); }
html[data-theme="dark"] .nav-btn:hover { background: var(--bg-subtle); color: var(--color-text); }
html[data-theme="dark"] .nav-btn.active { background: var(--color-accent); color: #fff; }


/* ── 3. SHARED PRIMITIVES (namespaced .sc-*) ──────────────────────────── */

.sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 11px 22px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease, border-color 0.15s ease;
  box-shadow: none;
  line-height: 1.2;
  min-height: 44px;
}
.sc-btn:active { transform: translateY(1px); }
.sc-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sc-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.sc-btn--primary { background: var(--color-primary); color: var(--color-primary-text); }
.sc-btn--primary:hover { filter: brightness(1.08); }
.sc-btn--secondary { background: var(--bg-card); color: var(--color-text); border-color: var(--border-card); }
.sc-btn--secondary:hover { background: var(--bg-subtle); }
.sc-btn--danger { background: var(--behavior-maroon); color: #fff; }
.sc-btn--warning { background: var(--behavior-gold); color: #fff; }
.sc-btn--success { background: var(--behavior-green); color: #fff; }

/* Generic card */
.sc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
}

/* Pill (badge / label) */
.sc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--border-radius-pill);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  color: #fff;
}
.sc-pill--green  { background: var(--behavior-green); }
.sc-pill--gold   { background: var(--behavior-gold); }
.sc-pill--teal   { background: var(--behavior-teal); }
.sc-pill--coral  { background: var(--behavior-coral); }
.sc-pill--grey   { background: var(--behavior-grey); }
.sc-pill--maroon { background: var(--behavior-maroon); }
.sc-pill--orange { background: var(--behavior-orange); }

/* Stepper (segmented − count +) */
.sc-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-card);
  flex: none;
}
.sc-stepper__minus,
.sc-stepper__plus {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--color-text);
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.sc-stepper__minus:hover { background: var(--bg-subtle); }
.sc-stepper__plus { color: #fff; }
.sc-stepper__plus:hover { filter: brightness(1.08); }
.sc-stepper__count {
  min-width: 44px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sc-stepper button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

/* "+" stepper fills per behaviour tone (set via .is-<tone> from JS) */
.sc-stepper__plus.is-green  { background: var(--behavior-green); }
.sc-stepper__plus.is-gold   { background: var(--behavior-gold); }
.sc-stepper__plus.is-teal   { background: var(--behavior-teal); }
.sc-stepper__plus.is-coral  { background: var(--behavior-coral); }
.sc-stepper__plus.is-grey   { background: var(--behavior-grey); }
.sc-stepper__plus.is-maroon { background: var(--behavior-maroon); }
.sc-stepper__plus.is-orange { background: var(--behavior-orange); }

/* Avatar circle */
.sc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  overflow: hidden;
  flex: none;
}
.sc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Behaviour icon disc (cream circle) + PNG fallback handling */
.sc-icon-disc {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: #F8F7F2; /* fixed cream disc in both themes, per spec */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #243047;
}
.sc-icon-disc .ic { width: 22px; height: 22px; }
.sc-icon-disc img { width: 26px; height: 26px; }

.behavior-icon-wrap { display: inline-flex; }
.behavior-icon-fallback { display: inline-flex; }
.behavior-icon-img { display: none; }

/* ── 4. STUDENT SEAT CARD (classroom view) ─────────────────────────────── */

/* All seats share one muted-green accent (no gender colour split). */
.seat { --seat-accent: var(--behavior-green); }

.seat {
  position: absolute;
  width: clamp(104px, 26vw, 120px);
  height: auto;
  min-height: clamp(100px, 26vw, 120px);
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  cursor: grab;
  padding: 8px 8px 8px 14px;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  overflow: hidden;
  touch-action: none;
  transition: box-shadow 0.18s ease, transform 0.12s ease, border-color 0.18s ease, outline 0.18s ease, background 0.18s ease;
}

/* Accent tab: left edge in light mode, top edge bar in dark mode. */
.seat::before {
  content: '';
  position: absolute;
  pointer-events: none;
  background: var(--seat-accent, var(--color-accent));
  left: 5px;
  top: 10px;
  width: 7px;
  height: 40%;
  border-radius: 7px;
}
html[data-theme="dark"] .seat::before {
  left: 8px;
  right: 8px;
  top: 0;
  width: auto;
  height: 6px;
  border-radius: 0 0 6px 6px;
}

/* Occupied seat card layout */
.seat.occupied {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
.seat.occupied:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.seat.dragging {
  cursor: grabbing;
  transform: rotate(3deg) scale(1.04);
  z-index: 1000;
  opacity: 0.98;
  box-shadow: var(--shadow-modal);
  transition: none;
}

/* Selected (batch) state: primary outline + soft ring. */
.seat.selected {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

/* Name row: subtle rounded pill with circular avatar + name. */
.seat-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 5px 8px 5px 5px;
  min-width: 0;
}
.seat-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--seat-accent, var(--color-accent));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.seat-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Editable name (kept as the same .student-name element the JS edits). */
.student-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-text);
  background: transparent;
  border: none;
  padding: 2px 0;
  border-radius: 6px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.student-name[contenteditable="true"]:focus {
  background: var(--bg-card);
  outline: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

/* Stat tile grid (positive / negative / device). */
.behavior-display {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}
.behavior-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 4px 2px;
  background: var(--bg-stat-tile);
  border-radius: var(--border-radius-tile);
  color: var(--color-text);
  border: none;
  font-size: 10px;
}
.behavior-item__icon {
  display: inline-flex;
  color: inherit;
  line-height: 0;
}
.behavior-item__icon .ic { width: 15px; height: 15px; }
.behavior-item__count {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  color: inherit;
}

/* Empty seats: dashed card with a centred muted label. */
.seat:not(.occupied) {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1.5px dashed var(--border-card);
  box-shadow: none;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
}
.seat:not(.occupied)::before { display: none; }


/* ── 4b. SEAT CARD — id-scoped overrides (win over style.css theme rules) ─ */

/* Gender keeps its old signalling through the accent colour (var overrides). */
#classroomView .seat { --seat-accent: var(--behavior-green); }

#classroomView .seat {
  position: absolute;
  width: clamp(104px, 26vw, 120px);
  height: auto;
  min-height: clamp(100px, 26vw, 120px);
  background: var(--bg-card);
  border: 1.5px solid var(--border-card);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-card);
  padding: 8px 8px 8px 14px;
  justify-content: flex-start;
  color: var(--color-text);
}
#classroomView .seat:hover { box-shadow: var(--shadow-card); border-color: var(--border-card); }
#classroomView .seat.dragging {
  box-shadow: var(--shadow-modal);
  transform: rotate(3deg) scale(1.04);
}
#classroomView .seat.selected {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

#classroomView .seat::before {
  content: '';
  position: absolute;
  pointer-events: none;
  background: var(--seat-accent, var(--color-accent));
  left: 5px;
  top: 10px;
  width: 7px;
  height: 40%;
  border-radius: 7px;
}
html[data-theme="dark"] #classroomView .seat::before {
  left: 8px;
  right: 8px;
  top: 0;
  width: auto;
  height: 6px;
  border-radius: 0 0 6px 6px;
}

#classroomView .seat-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 6px 10px;
  min-width: 0;
}

#classroomView .student-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--color-text);
  background: transparent;
  border: none;
  padding: 2px 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
#classroomView .student-name[contenteditable="true"]:focus {
  background: var(--bg-card);
  outline: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

#classroomView .behavior-display {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}
#classroomView .behavior-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 4px 2px;
  background: var(--bg-stat-tile);
  border-radius: var(--border-radius-tile);
  color: var(--color-text);
  border: none;
  font-size: 10px;
}
#classroomView .behavior-item__icon .ic { width: 15px; height: 15px; }
#classroomView .behavior-item__count {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  color: inherit;
}

/* Empty seats */
#classroomView .seat:not(.occupied) {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1.5px dashed var(--border-card);
  box-shadow: none;
  color: var(--color-text-muted);
}
#classroomView .seat:not(.occupied)::before { display: none; }

/* Hover lift + projector-view safety (mirrored seats keep their flip). */
#classroomView .seat.occupied:hover { transform: translateY(-2px); }
body.projector-active #classroomView .seat.occupied:hover { transform: scaleX(-1) translateY(-2px); }


/* ── 5. BEHAVIOR MODAL (#behaviorModal) ───────────────────────────────── */

/* Overlay: dark translucent wash with a soft blur behind the seating chart. */
#behaviorModal {
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#behaviorModal .modal-content.behavior-modal__panel {
  background: var(--bg-app);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-modal);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
html[data-theme="dark"] #behaviorModal .modal-content.behavior-modal__panel { background: var(--bg-card); }

/* Header: full-width primary band, rounded top corners only. */
.behavior-modal__header {
  background: var(--color-primary);
  color: var(--color-primary-text);
  padding: 18px 20px;
  text-align: center;
  border-radius: calc(var(--border-radius-card) - 1px) calc(var(--border-radius-card) - 1px) 0 0;
}
.behavior-modal__header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  color: inherit;
}

/* Body: internal scroll. */
.behavior-modal__body {
  overflow-y: auto;
  padding: 14px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* Footer with centered Done. */
.behavior-modal__footer {
  padding: 12px 16px 16px;
  display: flex;
  justify-content: center;
}

/* Gamification stat strip (unchanged data — reskinned chips). */
.behavior-modal__statbar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 9px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-pill);
}
.behavior-modal__statbar span {
  font-size: 11px;
  font-weight: 700;
}

/* One behaviour row: icon · label+pill · stepper */
.behavior-modal__row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-tile);
  padding: 8px 10px;
}
html[data-theme="dark"] .behavior-modal__row { background: var(--bg-subtle); }

.behavior-modal__mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.behavior-modal__label {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.25;
}
.behavior-modal__stat-impact { color: var(--color-text-muted); font-weight: 600; }

/* ── 6. OTHER NON-GAMIFIED MODALS + SCREENS (id-scoped) ───────────────── */

/* Non-gamified modal shells (report / AI modals). */
#commentReportModal .modal-content,
#igcseCommentReportModal .modal-content,
#aiResponseModal .modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-modal);
}
#commentReportModal h3,
#igcseCommentReportModal h3,
#aiResponseModal h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--color-text);
}

/* Shared controls/inputs/buttons INSIDE the six non-gamified views only. */
#classroomView .controls,
#dashboardView .controls,
#summaryView .controls,
#groupingView .controls,
#reportsView .controls,
#noiseMonitorView .controls {
  background: var(--bg-card);
  border-color: var(--border-card);
}
#classroomView .control-group label,
#dashboardView .control-group label,
#summaryView .control-group label,
#groupingView .control-group label,
#reportsView .control-group label,
#noiseMonitorView .control-group label {
  color: var(--color-text-muted);
  font-weight: 600;
}

#classroomView input[type="text"],
#classroomView input[type="number"],
#classroomView select,
#classroomView textarea,
#dashboardView input[type="text"],
#dashboardView input[type="number"],
#dashboardView select,
#dashboardView textarea,
#summaryView input[type="text"],
#summaryView input[type="number"],
#summaryView select,
#summaryView textarea,
#groupingView input[type="text"],
#groupingView input[type="number"],
#groupingView select,
#groupingView textarea,
#reportsView input[type="text"],
#reportsView input[type="number"],
#reportsView select,
#reportsView textarea,
#noiseMonitorView select,
#noiseMonitorView input[type="number"] {
  background: var(--bg-subtle);
  color: var(--color-text);
  border: 1px solid transparent;
  border-radius: 12px;
}
#classroomView input:focus,
#classroomView select:focus,
#classroomView textarea:focus,
#dashboardView input:focus,
#dashboardView select:focus,
#dashboardView textarea:focus,
#summaryView input:focus,
#summaryView select:focus,
#summaryView textarea:focus,
#groupingView input:focus,
#groupingView select:focus,
#groupingView textarea:focus,
#reportsView input:focus,
#reportsView select:focus,
#reportsView textarea:focus,
#noiseMonitorView select:focus,
#noiseMonitorView input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
  background: var(--bg-subtle);
}

/* Buttons inside the non-gamified views (kept out of gamified panels). */
#classroomView .secondary-btn,
#dashboardView .secondary-btn,
#summaryView .secondary-btn,
#groupingView .secondary-btn,
#reportsView .secondary-btn,
#noiseMonitorView .secondary-btn {
  background: var(--bg-card);
  color: var(--color-text);
  border: 1.5px solid var(--border-card);
  border-radius: 10px;
  box-shadow: none;
}
#classroomView .secondary-btn:hover,
#dashboardView .secondary-btn:hover,
#summaryView .secondary-btn:hover,
#groupingView .secondary-btn:hover,
#reportsView .secondary-btn:hover,
#noiseMonitorView .secondary-btn:hover { background: var(--bg-subtle); color: var(--color-text); }
#classroomView .danger-btn,
#dashboardView .danger-btn,
#summaryView .danger-btn,
#groupingView .danger-btn,
#reportsView .danger-btn,
#noiseMonitorView .danger-btn {
  background: var(--behavior-maroon);
  color: #fff;
  border-color: var(--behavior-maroon);
  border-radius: 10px;
  box-shadow: none;
}
#classroomView .success-btn,
#dashboardView .success-btn,
#summaryView .success-btn,
#groupingView .success-btn,
#reportsView .success-btn,
#noiseMonitorView .success-btn {
  background: var(--behavior-green);
  color: #fff;
  border-color: var(--behavior-green);
  border-radius: 10px;
  box-shadow: none;
}
#classroomView .warning-btn,
#dashboardView .warning-btn,
#summaryView .warning-btn,
#groupingView .warning-btn,
#reportsView .warning-btn,
#noiseMonitorView .warning-btn {
  background: var(--behavior-gold);
  color: #fff;
  border-color: var(--behavior-gold);
  border-radius: 10px;
  box-shadow: none;
}
#classroomView button,
#dashboardView button,
#summaryView button,
#groupingView button,
#reportsView button,
#noiseMonitorView button {
  box-shadow: none;
  border-radius: 10px;
}

/* Disabled buttons must LOOK disabled. The global button:disabled rule in
   style.css is overridden by the higher-specificity view-scoped .success-btn /
   .danger-btn / .secondary-btn rules above, so disabled buttons kept their
   coloured "enabled" look (e.g. the Noise Monitor Start button stayed green
   and seemed to flicker instead of disabling). */
#classroomView button:disabled,
#dashboardView button:disabled,
#summaryView button:disabled,
#groupingView button:disabled,
#reportsView button:disabled,
#noiseMonitorView button:disabled {
  background: var(--bg-subtle);
  color: var(--color-text-muted);
  border-color: transparent;
  cursor: not-allowed;
  opacity: 0.6;
}




/* Toast — white card, semantic left border, bell icon. */
html[data-theme] .toast {
  background: var(--bg-card);
  color: var(--color-text);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--color-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
/* An EMPTY toast must never render. It is position:fixed at the top centre with
   z-index 2000, so a bare pill showed as a white oval hovering over the whole
   page — the display:flex above outranks style.css's default display:none, so
   until the first toast was ever shown that ghost sat over the header. */
html[data-theme] .toast:empty { display: none; }
html[data-theme] .toast.error {
  background: var(--bg-card);
  color: var(--color-text);
  border-left-color: var(--behavior-maroon);
}
.toast .ic { width: 18px; height: 18px; flex: none; color: var(--color-primary); }

/* Behaviour row tones anywhere behaviours are listed. */
.behavior-tone-green  { background: var(--behavior-green); }
.behavior-tone-gold   { background: var(--behavior-gold); }
.behavior-tone-teal   { background: var(--behavior-teal); }
.behavior-tone-coral  { background: var(--behavior-coral); }
.behavior-tone-grey   { background: var(--behavior-grey); }
.behavior-tone-maroon { background: var(--behavior-maroon); }
.behavior-tone-orange { background: var(--behavior-orange); }

/* ── 7. ACCESSIBILITY + RESPONSIVE ────────────────────────────────────── */

/* Consistent visible keyboard focus across the refresh. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .header { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .header h1 { font-size: 20px; }
  #mainNav { padding: 6px; }
  .behavior-modal__row { flex-wrap: wrap; }
  .behavior-modal__label { font-size: 15px; }
}


/* Toast icon (JS adds a bell svg). */
.toast__icon { display: inline-flex; color: var(--color-primary); line-height: 0; }
.toast.error .toast__icon { color: var(--behavior-maroon); }
.toast__icon .ic { width: 18px; height: 18px; }

/* Vector-icon alignment inside small UI buttons (batch bar, pick list, statbar). */
.bm-btn-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  vertical-align: -0.15em;
}
.bm-btn-icon .ic,
.pick-behavior-btn .ic,
.batch-award-btn .ic { width: 1em; height: 1em; }
.bm-btn-icon .behavior-icon-wrap,
.batch-award-btn .behavior-icon-wrap { display: inline-flex; }
.behavior-modal__statbar .ic { vertical-align: -0.2em; }


/* ── OpenMoji emoji images (rendered app-wide via openmoji.js) ────────── */
.emoji {
  height: 1.2em;
  width: auto;
  vertical-align: -0.2em;
  display: inline-block;
  pointer-events: none;
}
/* Shown when an emoji has no curated SVG (openmoji.js → fallbackNode()).
   Given the SAME box as .emoji on purpose: a plain emoji glyph has a taller
   line box than a 1.2em image, so if anything ever swapped between the two the
   surrounding layout would jump. Matching the metrics removes that risk. */
.emoji-fallback {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  vertical-align: -0.2em;
  pointer-events: none;
}
#classroomView .behavior-item__icon .emoji { width: 18px; height: 18px; vertical-align: baseline; }
.sc-icon-disc .emoji { width: 26px; height: 26px; vertical-align: baseline; }
.bm-btn-icon .emoji,
.batch-award-btn .emoji,
.pick-behavior-btn .emoji { height: 1em; width: 1em; vertical-align: -0.15em; }
.behavior-modal__statbar .emoji,
.toast__icon .emoji { height: 1.1em; vertical-align: -0.2em; }

/* Gamified screen: the only OpenMoji icons kept there are the RPG stat emojis
   (HP/AP/XP/GP in gamification/character-sheet.js) — rendered 150% larger than
   the base 1.2em above so they read clearly against the dark character sheet. */
#gamifiedView .emoji { height: 1.8em; vertical-align: -0.3em; }

/* ── Classroom sub-tabs ──────────────────────────────────────────────────
   Dashboard / Summary / Random Selector / Noise Monitor used to be top-level
   nav tabs. They now live INSIDE #classroomView as .sub-pane siblings, sharing
   one .sub-nav bar at the top of that tab; switchView() swaps the visible pane
   (and keeps the Classroom main tab active while they are open). */
.sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 12px 28px 0;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 4px;
}
.sub-nav-btn {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  border-radius: var(--border-radius-pill);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.sub-nav-btn:hover { background: var(--bg-subtle); color: var(--color-text); }
.sub-nav-btn.active {
  color: var(--color-primary-text);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* ── Settings tab (id kept as #reportsView so existing rules still match) ── */
.settings-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--color-text);
  padding: 18px 28px 0;
}

/* ── Sign Up / Login (header) ────────────────────────────────────────────
   Two clearly-labelled entry points: teal = create a login, mustard = return
   to an existing one. Both are filled and high-contrast so they read as THE
   actions on the page (Hick's law: one obvious way in beats five). */
.btn-teal,
.btn-mustard {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: filter 120ms ease, transform 120ms ease;
}
.btn-teal { background: var(--brand-teal); color: var(--brand-teal-text); }
.btn-mustard { background: var(--brand-mustard); color: var(--brand-mustard-text); }
.btn-teal:hover, .btn-mustard:hover { filter: brightness(1.08); }
.btn-teal:active, .btn-mustard:active { transform: translateY(1px); }
.btn-teal:focus-visible, .btn-mustard:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* ── The Student / Teacher chooser (gamification/auth.js) ────────────────
   Two big tappable rows, colour-coded to match the buttons that opened them,
   so the choice is obvious on a tablet at the front of the room. */
.auth-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-tile);
  background: var(--bg-subtle);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}
.auth-choice:hover { transform: translateY(-1px); }
.auth-choice:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }
.auth-choice__icon { font-size: 24px; line-height: 1; }
.auth-choice__text { display: flex; flex-direction: column; gap: 2px; }
.auth-choice__text small { color: var(--color-text-muted); font-size: 12px; }
.auth-choice--teal { border-left: 4px solid var(--brand-teal); }
.auth-choice--mustard { border-left: 4px solid var(--brand-mustard); }

