@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Dark theme variables (default) */
:root {
  --grid-size: 20px;

  --primary-color: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-light: #0b1a33;

  --success-color: #22c55e;
  --success-hover: #16a34a;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --neutral-color: #94a3b8;

  --background: #0b1120;
  --surface: #0f172a;
  --surface-elevated: #111827;

  --border: #1f2937;
  --border-light: #172135;

  --text-primary: #e5e7eb;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-md: 0 10px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 30px rgba(0,0,0,0.45);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

/* Light theme variables */
html[data-theme="light"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;

    --success-color: #16a34a;
    --success-hover: #15803d;
    --warning-color: #f59e0b;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --neutral-color: #64748b;

    --background: #f1f5f9; /* slate-100 */
    --surface: #ffffff;
    --surface-elevated: #f8fafc; /* slate-50 */

    --border: #e2e8f0; /* slate-200 */
    --border-light: #f1f5f9; /* slate-100 */

    --text-primary: #0f172a; /* slate-900 */
    --text-secondary: #334155; /* slate-700 */
    --text-muted: #64748b; /* slate-500 */

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 12px rgba(0,0,0,0.07);
    --shadow-md: 0 10px 20px rgba(0,0,0,0.07);
    --shadow-lg: 0 20px 30px rgba(0,0,0,0.07);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  padding: 20px;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.header {
  background: linear-gradient(180deg, var(--surface) 0%, var(--background) 100%);
  color: var(--text-primary);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  flex-grow: 1;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

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

#theme-toggle-btn {
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}
#theme-toggle-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}


#manualSaveBtn {
  background: var(--primary-color);
  color: #0b1120;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius);
  transition: background 0.2s ease, transform 0.08s ease;
  border: 1px solid var(--primary-color);
}
#manualSaveBtn:hover { background: var(--primary-hover); transform: translateY(-1px); }

#saveStatus {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0b172a;
  color: var(--text-secondary);
}
#saveStatus.unsaved { background: #2a1809; color: #ffedd5; border-color: #7c2d12; }
#saveStatus.saving  { background: #131834; color: #c7d2fe; border-color: #1e3a8a; }
#saveStatus.saved   { background: #0f2b1d; color: #bbf7d0; border-color: #14532d; }

.main-nav {
  padding: 0;
  background: #0d1528;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  font-size: 14px;
}
.nav-btn:hover { color: var(--text-primary); background: #0b172a; }
.nav-btn.active {
  color: var(--primary-color);
  background: #0b172a;
  position: relative;
}
.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 12px; right: 12px;
  height: 3px;
  background: var(--primary-color);
  border-radius: 3px 3px 0 0;
}

.controls {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: #0c1426;
}

.control-group {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-group label {
  font-weight: 700;
  min-width: 140px;
  color: var(--text-secondary);
  font-size: 14px;
}

button {
  background: var(--primary-color);
  color: #071223;
  border: 1px solid var(--primary-color);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: background 0.2s ease, transform 0.06s ease;
  box-shadow: var(--shadow-sm);
}
button:hover { background: var(--primary-hover); }
button:active { transform: translateY(1px); }
button:disabled { background: #1f2a3a; border-color: #1f2a3a; color: #5b6b84; cursor: not-allowed; }

.secondary-btn {
  background: #0e182b;
  color: var(--text-secondary);
  border-color: var(--border);
}
.secondary-btn:hover { background: #0b172a; }

.danger-btn {
  background: var(--danger-color);
  color: #0b1120;
  border-color: var(--danger-color);
}
.danger-btn:hover { background: var(--danger-hover); }

.success-btn {
  background: var(--success-color);
  color: #05101f;
  border-color: var(--success-color);
}
.success-btn:hover { background: var(--success-hover); }

.warning-btn {
  background: var(--warning-color);
  color: #0b1120;
  border-color: var(--warning-color);
}
.warning-btn:hover { filter: brightness(0.95); }

input[type="file"], input[type="text"], input[type="number"], select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  background: #0d172a;
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-family: inherit;
}
input[type="file"]::file-selector-button {
  border: 1px solid var(--border);
  background: #0b172a;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
}
input[type="file"]:focus, input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
  background: #0c172c;
}

.view-container { display: block; }
.view-container.hidden { display: none; }

/* Classroom wrapper: scrollable area around the scaled classroom */
.classroom-wrapper {
  position: relative;
  background: #0a1326;
  margin: 22px 28px;
  border: 1px dashed #1a2a45;
  border-radius: var(--radius-lg);
  overflow: auto;            /* scroll/pan here */
  touch-action: pan-x pan-y; /* allow natural panning */
  box-shadow: var(--shadow-sm);
}

/* Classroom inner canvas (scaled on mobile pinch) */
.classroom {
  position: relative;
  /* Default size. This is dynamically adjusted by script.js to fit content. */
  min-height: 720px;
  min-width: 1200px;
  background-size: var(--grid-size) var(--grid-size);
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  transform-origin: top left;
}

/* NEW: Marquee selection box */
#marquee-box {
    position: absolute;
    border: 1px solid var(--primary-color);
    background-color: rgba(96, 165, 250, 0.2);
    display: none; /* Initially hidden */
    pointer-events: none; /* Allows clicks to pass through */
    z-index: 2000;
}

/* Seats */
.seat {
  position: absolute;
  width: clamp(96px, 26vw, 120px);
  height: clamp(96px, 26vw, 120px);
  background: #0d172a;
  border: 1px solid #1e2b45;
  border-radius: var(--radius);
  cursor: grab;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  padding: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.12s ease, border-color 0.2s ease, outline 0.2s ease;
  touch-action: none; /* prevents touch scroll while dragging a seat */
}

.seat:hover { box-shadow: var(--shadow); border-color: #2a3a58; }
.seat.dragging { cursor: grabbing; transform: rotate(3deg) scale(1.04); z-index: 1000; opacity: 0.98; box-shadow: var(--shadow-md); transition: none; }
.seat.occupied { background: #0e192f; border-color: #26476e; }
.seat.male     { border-color: #1e40af; }
.seat.female   { border-color: #9333ea; }

/* Style for multi-selected seats */
.seat.selected {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: var(--shadow-md) !important; /* Override hover effects */
  border-color: var(--primary-color);
}

.student-name {
  font-weight: 800;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: #0b172a;
  border: 1px solid #223552;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.2;
}
.student-name[contenteditable="true"]:focus {
  background: #0c1d35;
  outline: 2px solid var(--primary-color);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.behavior-display {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 10px;
  gap: 6px;
  margin-top: 8px;
}
.behavior-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: #0b172a;
  color: var(--text-secondary);
  border: 1px solid #223552;
}

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #075985;
  color: #dbeafe;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  z-index: 2000;
  display: none;
  box-shadow: var(--shadow-md);
  border: 1px solid #0ea5e9;
  font-weight: 800;
}
.toast.error { background: #7f1d1d; border-color: #ef4444; color: #fecaca; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(2, 6, 23, 0.55);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1500;
  padding: 16px;
}
.modal-content {
  background: #0f172a;
  padding: 24px 28px 28px 28px;
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  max-width: 90vw;
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h3 { margin-bottom: 14px; font-size: 18px; font-weight: 800; color: var(--text-primary); }
#customModal .modal-content { text-align: left; }
#customModalMessage { margin: 10px 0; color: var(--text-secondary); line-height: 1.6; font-size: 14px; }
#customModalInput { display: none; width: 100%; margin-top: 8px; }

/* Behavior rows */
.modal-behavior-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  width: 100%;
  transition: background 0.2s ease;
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.modal-behavior-row:hover { background: #0b172a; }
.modal-behavior-name { font-size: 14px; font-weight: 700; flex-grow: 1; text-align: left; color: var(--text-primary); }
.modal-behavior-actions { display: flex; align-items: center; gap: 10px; }
.modal-behavior-actions button { width: 34px; height: 34px; border-radius: 8px; padding: 0; }
.modal-behavior-count { font-size: 16px; font-weight: 900; min-width: 42px; text-align: center; color: var(--text-primary); }

/* Delete zone */
#deleteZone {
  position: fixed;
  bottom: -150px;
  left: 0;
  width: 100%;
  height: 80px;
  background: #2a0e12;
  border-top: 3px dashed #ef4444;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: transform 0.3s ease, bottom 0.3s ease;
  pointer-events: none;
}
#deleteZone.active { bottom: 0; pointer-events: all; box-shadow: var(--shadow-lg); }
#deleteZone.hover  { background: #3f0f15; }
#deleteZone::after {
  content: '🗑️ Drag here to delete seat';
  font-size: 16px;
  color: #fecaca;
  font-weight: 900;
}

/* Dashboard, Grouping, Grades */
#dashboardContainer { padding: 22px 28px; }
#dashboardHeader {
  font-size: 22px; font-weight: 900; color: var(--text-primary);
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.student-card { background: #0e172a; border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.student-card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); background: #0b172a; }
.card-header h3 { font-size: 16px; font-weight: 900; color: var(--text-primary); }
.card-body { padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.behavior-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 8px; font-weight: 800; }
.behavior-list { list-style: none; padding: 0; }
.behavior-list li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 6px 0; }
.behavior-list .count { font-weight: 900; font-size: 16px; }
.behavior-list .positive .count { color: var(--success-color); }
.behavior-list .negative .count { color: var(--danger-color); }
.card-footer { padding: 14px; background: #0b172a; border-top: 1px solid var(--border); text-align: center; }
.net-score-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.net-score-display { font-size: 28px; font-weight: 900; }
.net-score-positive { color: var(--success-color); }
.net-score-negative { color: var(--danger-color); }
.net-score-neutral { color: var(--text-muted); }

#groupingControls {
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: #0c1628;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
#groupingResults { padding: 22px 28px; }
.grouping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.group-card { background: #0f182b; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.group-card:hover { box-shadow: var(--shadow-md); }
.group-card-header { padding: 12px 14px; background: #0b172a; color: var(--text-primary); font-weight: 800; font-size: 14px; }
.group-card-body { padding: 14px; }
.group-card-body li { padding: 8px 0; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); }

#gradesTableContainer { padding: 0 28px 22px 28px; overflow-x: auto; }
.grades-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 14px; white-space: nowrap; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.grades-table th, .grades-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border-light); background: #0f182b; color: var(--text-primary); font-size: 13px; }
.grades-table th:first-child, .grades-table td:first-child { position: sticky; left: 0; background: #0b172a; border-right: 2px solid var(--border); z-index: 2; }
.grades-table th { background: #101a31; color: var(--text-secondary); font-weight: 900; position: sticky; top: 0; cursor: grab; z-index: 1; }
.grades-table .assessment-header[contenteditable="true"]:focus { outline: 2px solid rgba(96,165,250,0.35); background: #0f172a; padding: 2px 6px; border-radius: var(--radius-sm); }
.grades-table tbody tr { cursor: grab; transition: background 0.15s ease; }
.grades-table tbody tr:hover td { background: #0c1628; }
.grades-table .grade-input { width: 100%; min-width: 120px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; background: #0c172c; color: var(--text-primary); }
.grades-table .grade-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(96,165,250,0.2); background: #0b172a; }
.grades-table .dragging { opacity: 0.6; background: #0b1a33; }
.grades-table .drag-over { border-bottom: 3px solid var(--primary-color); }
.grades-table th.drag-over-col { border-right: 3px solid var(--primary-color); }

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #0b172a; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #1f2a3e; border-radius: 8px; border: 2px solid #0b172a; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* Confetti */
#confetti-container { position: fixed; top:0; left:0; width:100%; height:100%; pointer-events:none; z-index:9999; overflow:hidden; }
.confetti { position: absolute; width: 10px; height: 10px; top:-20px; opacity:0; border-radius: 50%; animation: fall 4s linear forwards; }
@keyframes fall { 0% { transform: translateY(0vh) rotateZ(0deg); opacity:1; } 100% { transform: translateY(105vh) rotateZ(720deg); opacity:0; } }

/* AI output */
#aiPromptInput { width: 100%; min-height: 120px; resize: vertical; }
#aiOutputContainer {
  margin-top: 14px; padding: 14px;
  background: #0e182b; color: var(--text-primary);
  border-radius: var(--radius);
  white-space: pre-wrap; word-wrap: break-word;
  min-height: 100px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Helpers */
.placeholder { text-align: center; padding: 50px 32px; color: var(--text-muted); font-size: 15px; }
.section-info { padding: 22px 28px; }
.divider { margin: 18px 0; border: none; border-top: 1px solid var(--border); }

/* Accordion styles */
.accordion { display: grid; gap: 10px; }
.accordion-item { background: #0b1528; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.accordion-header {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: #0b172a;
  color: var(--text-secondary);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  cursor: pointer;
}
.accordion-header:hover { background: #0c1a31; color: var(--text-primary); }
.accordion-caret { transition: transform 0.2s ease; }
.accordion-item.open .accordion-caret { transform: rotate(90deg); }
.accordion-panel {
  display: none;
  padding: 14px;
  background: #0c1426;
  border-top: 1px solid var(--border-light);
}
.accordion-item.open .accordion-panel { display: block; }

/* --- Light Theme Overrides --- */
html[data-theme="light"] #manualSaveBtn,
html[data-theme="light"] .danger-btn,
html[data-theme="light"] .success-btn,
html[data-theme="light"] .warning-btn {
    color: #ffffff;
}
html[data-theme="light"] #saveStatus.unsaved { background: #fffbeb; color: #b45309; border-color: #fde68a; }
html[data-theme="light"] #saveStatus.saving { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
html[data-theme="light"] #saveStatus.saved { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
html[data-theme="light"] .main-nav { background: var(--surface-elevated); }
html[data-theme="light"] .nav-btn { color: var(--text-secondary); }
html[data-theme="light"] .nav-btn:hover { background: var(--background); color: var(--text-primary); }
html[data-theme="light"] .nav-btn.active { background: var(--background); }
html[data-theme="light"] .controls { background: var(--surface-elevated); }
html[data-theme="light"] .control-group label { color: var(--text-primary); font-weight: 800; }
html[data-theme="light"] .secondary-btn { background: #e9eef4; color: var(--text-secondary); border-color: #d1d9e3; }
html[data-theme="light"] .secondary-btn:hover { background: #dfe6ee; }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { background: var(--surface); border-color: #cbd5e1; }
html[data-theme="light"] input[type="file"]::file-selector-button { background: var(--surface-elevated); border-color: var(--border); }
html[data-theme="light"] input:focus,
html[data-theme="light"] select:focus,
html[data-theme="light"] textarea:focus { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); background: var(--surface); }
html[data-theme="light"] .classroom-wrapper { background: #e9eef4; border-color: #d1d9e3; }
html[data-theme="light"] .classroom { background-image: linear-gradient(to right, rgba(0, 0, 0, 0.06) 1px, transparent 1px), linear-gradient(to bottom, rgba(0, 0, 0, 0.06) 1px, transparent 1px); }
html[data-theme="light"] .seat { background: var(--surface-elevated); border-color: #d1d9e3; }
html[data-theme="light"] .seat.occupied { background: var(--surface); border-color: #a5b4fc; }
html[data-theme="light"] .seat.male { border-color: #60a5fa; }
html[data-theme="light"] .seat.female { border-color: #c084fc; }
html[data-theme="light"] .student-name { background: #f1f5f9; border: 1px solid #e2e8f0; }
html[data-theme="light"] .student-name[contenteditable="true"]:focus { background: #ffffff; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
html[data-theme="light"] .behavior-item { background: #f1f5f9; border: 1px solid #e2e8f0; }
html[data-theme="light"] .toast { background: #1e40af; color: #dbeafe; border-color: #60a5fa; }
html[data-theme="light"] .toast.error { background: #991b1b; color: #fee2e2; border-color: #ef4444; }
html[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.45); }
html[data-theme="light"] .modal-content { background: var(--surface); }
html[data-theme="light"] .modal-behavior-row:hover { background: var(--surface-elevated); }
html[data-theme="light"] #deleteZone { background: #fef2f2; border-top-color: var(--danger-color); }
html[data-theme="light"] #deleteZone::after { color: #b91c1c; }
html[data-theme="light"] .student-card,
html[data-theme="light"] #groupingControls,
html[data-theme="light"] .group-card { background: var(--surface); }
html[data-theme="light"] .card-header,
html[data-theme="light"] .card-footer,
html[data-theme="light"] .group-card-header { background: var(--surface-elevated); }
html[data-theme="light"] .grades-table { border-color: var(--border); }
html[data-theme="light"] .grades-table th, 
html[data-theme="light"] .grades-table td { background: var(--surface); border-bottom-color: var(--border); border-right-color: var(--border-light); }
html[data-theme="light"] .grades-table th:first-child, 
html[data-theme="light"] .grades-table td:first-child { background: var(--surface-elevated); border-right-color: var(--border); }
html[data-theme="light"] .grades-table th { background: var(--surface-elevated); }
html[data-theme="light"] .grades-table tbody tr:hover td { background: var(--surface-elevated); }
html[data-theme="light"] .grades-table .grade-input:focus { background: var(--surface); }
html[data-theme="light"] .grades-table .dragging { background: var(--primary-light); }
html[data-theme="light"] ::-webkit-scrollbar-track { background: #e2e8f0; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbd5e1; border-color: #e2e8f0; }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
html[data-theme="light"] #aiOutputContainer { background: var(--surface-elevated); }
html[data-theme="light"] .accordion-item { background: var(--surface-elevated); }
/* FIXED: Make accordion headers visible in light mode */
html[data-theme="light"] .accordion-header { background: var(--surface-elevated); color: var(--text-secondary); }
html[data-theme="light"] .accordion-header:hover { background: var(--background); color: var(--text-primary); }
html[data-theme="light"] .accordion-panel { background: var(--surface); }

/* Mobile tweaks */
@media (max-width: 768px) {
  body { padding: 12px; }
  .container { border-radius: var(--radius-lg); }
  .header { padding: 14px 16px; }
  .header h1 { font-size: 18px; }
  .controls { padding: 16px; }
  .classroom-wrapper { margin: 16px; }
  .control-group { flex-direction: column; align-items: flex-start; gap: 10px; }
  .control-group label { min-width: auto; }
  .dashboard-grid, .grouping-grid { grid-template-columns: 1fr; }
  #dashboardContainer { padding: 16px; }
  #gradesTableContainer { padding: 0 16px 16px 16px; }
  .seat { width: clamp(110px, 32vw, 140px); height: clamp(110px, 32vw, 140px); }
  .student-name { font-size: 12px; -webkit-line-clamp: 3; }
}