/* ============================================================================
   Manage Classes — kanban-style class & student management
   Design system: 4px spacing scale, restrained palette, soft elevation.
   ============================================================================ */

/* ----- Design tokens ----- */
.manage-classes {
  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Color palette */
  --c-bg: #f6f7fb;
  --c-surface: #ffffff;
  --c-surface-2: #fafbfd;
  --c-border: #e7e8ee;
  --c-border-strong: #d4d6df;
  --c-divider: #f0f1f5;

  --c-text: #1f2230;
  --c-text-muted: #6b6f80;
  --c-text-subtle: #9398a8;

  --c-brand: #6564b6;
  --c-brand-strong: #5353a6;
  --c-brand-soft: #f0eef9;
  --c-brand-soft-hover: #e5e2f5;
  --c-accent: #8ea5f6;

  --c-danger: #c0392b;
  --c-danger-soft: #fdecea;
  --c-success: #1a7f5f;

  /* Initials chip palette — distinguishable, on-brand */
  --c-chip-1: linear-gradient(135deg, #8ea5f6, #6564b6);
  --c-chip-2: linear-gradient(135deg, #b5e0d3, #5fb18a);
  --c-chip-3: linear-gradient(135deg, #f6c98e, #d68b3c);
  --c-chip-4: linear-gradient(135deg, #f49bb8, #c95588);
  --c-chip-5: linear-gradient(135deg, #a6c6f7, #4a7fc9);

  /* Brand-color helpers. The SVG empty-state illustration repeats these
     two stops as static hex values in its <linearGradient> — keep that
     in sync if you change the colors here. */
  --brand-gradient: linear-gradient(180deg, #8ea5f6, #6564b6);
  --focus-ring: 0 0 0 3px rgba(101, 100, 182, 0.18);
  --focus-ring-strong: 0 0 0 3px rgba(101, 100, 182, 0.4);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(20, 24, 40, 0.04), 0 1px 3px rgba(20, 24, 40, 0.06);
  --shadow-2: 0 2px 6px rgba(20, 24, 40, 0.06), 0 8px 24px rgba(20, 24, 40, 0.08);
  --shadow-modal: 0 8px 40px rgba(20, 24, 40, 0.18), 0 2px 8px rgba(20, 24, 40, 0.10);
  --shadow-drop: 0 0 0 2px rgba(101, 100, 182, 0.35), 0 8px 24px rgba(101, 100, 182, 0.18);

  /* Motion */
  --t-fast: 120ms;
  --t-normal: 180ms;
  --t-slow: 280ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  font-family: "Lexend Deca", "Noto Sans", Helvetica, sans-serif;
  color: var(--c-text);
}

.manage-classes,
.manage-classes * {
  box-sizing: border-box;
}

.manage-classes {
  min-height: 100vh;
  background: var(--c-bg);
}

[x-cloak] { display: none !important; }

/* ----- Page header bar ----- */
.page-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Full-width header band, sits below the site banner and above the board.
   Explicit background overrides header.css's bare `header { background: ... }`
   rule that matches every <header> element. The subtle vertical gradient
   gives the band its own visual surface separate from both the cyan site
   nav above and the calm board area below. */
.page-header {
  background:
    linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
  border-bottom: 1px solid var(--c-divider);
  box-shadow: 0 1px 0 rgba(20, 24, 40, 0.02);
  margin-bottom: var(--space-6);
  position: relative;
  display: block;
  height: auto;
  padding: 0;
}

.page-header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
}

.page-header-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text);
  line-height: 1.1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

/* Brand accent bar before the title — gives the page a designed identity */
.page-title::before {
  content: '';
  flex-shrink: 0;
  width: 4px;
  height: 1.4em;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
}

.page-header-subtitle {
  margin: 0;
  padding-left: calc(4px + var(--space-3)); /* align under the title text (after the bar) */
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--c-text-muted);
  letter-spacing: 0;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ----- Search ----- */
.search-input {
  width: 260px;
  padding: var(--space-2) var(--space-4) var(--space-2) calc(var(--space-4) + 18px);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6f80' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M21 21l-4.3-4.3'/></svg>") no-repeat var(--space-3) center;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}

.search-input::placeholder { color: var(--c-text-subtle); }

.search-input:hover { border-color: var(--c-border-strong); }

.search-input:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: var(--focus-ring);
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border-strong);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(101, 100, 182, 0.25);
}

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

.btn-primary {
  background: var(--brand-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(101, 100, 182, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #7a94f0, #5856a8);
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(101, 100, 182, 0.32);
}

.btn-primary:focus-visible {
  box-shadow: var(--focus-ring-strong);
}

.btn-large { padding: var(--space-3) var(--space-5); font-size: 1rem; }
.btn-small { padding: var(--space-1) var(--space-3); font-size: 0.85rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--c-text);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(101, 100, 182, 0.35);
}

/* ----- States: loading / error / empty ----- */
.state-block {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--c-text-muted);
}

.state-block-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: 4rem var(--space-4);
}

.state-block-empty .empty-illustration {
  width: 96px;
  height: 96px;
  opacity: 0.85;
}

.state-block-empty h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--c-text);
}

.state-block-empty p {
  margin: 0;
  max-width: 36ch;
  color: var(--c-text-muted);
}

.state-block-empty .btn { margin-top: var(--space-3); }

.state-block-error {
  background: var(--c-danger-soft);
  border: 1px solid #f4b6b6;
  color: var(--c-danger);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.state-block-error .btn {
  background: white;
  color: var(--c-text);
}

/* ----- Board ----- */
.classes-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-strong) transparent;
}

.classes-board::-webkit-scrollbar { height: 10px; }
.classes-board::-webkit-scrollbar-track { background: transparent; }
.classes-board::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid var(--c-bg);
}

/* ----- Class column ----- */
.class-column {
  flex: 0 0 320px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  min-height: 280px;
  transition: border-color var(--t-normal), box-shadow var(--t-normal), transform var(--t-normal);
}

.class-column.drop-target {
  border-color: var(--c-brand);
  box-shadow: var(--shadow-drop);
  transform: translateY(-1px);
}

/* Class column header */
.class-header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--c-divider);
}

.class-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 28px;
}

.class-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--c-text);
  line-height: 1.3;
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.class-menu { position: relative; flex-shrink: 0; }

.class-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  min-width: 160px;
  z-index: 30;
  overflow: hidden;
  padding: var(--space-1);
  animation: menu-pop var(--t-fast) var(--ease);
}

@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.menu-item:hover { background: var(--c-divider); }
.menu-item-danger { color: var(--c-danger); }
.menu-item-danger:hover { background: var(--c-danger-soft); }

.class-header-meta {
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.student-count {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  font-weight: 500;
}

/* ----- Class code pill ----- */
.class-code-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  padding: 2px var(--space-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-brand-soft);
  color: var(--c-brand-strong);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.class-code-pill:hover {
  background: var(--c-brand-soft-hover);
  border-color: var(--c-brand);
}

.class-code-pill:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.class-code-pill-disabled {
  background: var(--c-surface-2);
  color: var(--c-text-subtle);
  text-decoration: line-through;
}

.class-code-pill-disabled:hover {
  background: var(--c-divider);
  border-color: var(--c-border-strong);
  color: var(--c-text-muted);
}

.class-code-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.75;
}

.class-code-pill:hover .class-code-icon { opacity: 1; }

.class-code-generate {
  margin-left: auto;
  padding: 2px var(--space-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--c-text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.class-code-generate:hover {
  background: var(--c-brand-soft);
  border-color: var(--c-brand);
  color: var(--c-brand-strong);
}

.class-code-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- Student list ----- */
.student-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 80px;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.student-list::-webkit-scrollbar { width: 6px; }
.student-list::-webkit-scrollbar-track { background: transparent; }
.student-list::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: var(--radius-pill);
}

/* ----- Student card ----- */
.student-card {
  position: relative;
  display: grid;
  grid-template-columns: 18px 36px minmax(0, 1fr) max-content;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--c-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: grab;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
}

.student-card.selected {
  background: var(--c-brand-soft);
  border-color: var(--c-brand);
}

.student-card > .student-info { min-width: 0; width: 100%; }

.student-card:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  box-shadow: var(--shadow-1);
}

.student-card:active { cursor: grabbing; }

.student-card.dragging {
  opacity: 0.4;
  transform: scale(0.97);
}

.student-card:focus-visible {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: var(--focus-ring);
}

/* Checkbox sits in column 1 of the card grid. Opacity 0 by default and
   0.5 on card hover; full opacity once checked or while any selection is
   live in the page (so the user can find the rest of the checkboxes). */
.student-select {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast);
  accent-color: var(--c-brand);
  pointer-events: auto;
}

.student-card:hover .student-select,
.student-card.selected .student-select,
.manage-classes.has-selection .student-select {
  opacity: 1;
}

.student-select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

.student-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  letter-spacing: 0.02em;
}

.student-initials.chip-1 { background: var(--c-chip-1); }
.student-initials.chip-2 { background: var(--c-chip-2); }
.student-initials.chip-3 { background: var(--c-chip-3); }
.student-initials.chip-4 { background: var(--c-chip-4); }
.student-initials.chip-5 { background: var(--c-chip-5); }

.student-info { min-width: 0; }

.student-name {
  font-size: 0.92rem;
  color: var(--c-text);
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.student-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.multi-enroll-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--c-brand-strong);
  background: var(--c-brand-soft);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  cursor: help;
  line-height: 1.4;
  user-select: none;
}

.student-remove-btn {
  width: 26px;
  height: 26px;
  color: var(--c-text-subtle);
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
  font-size: 1.05rem;
}

.student-card:hover .student-remove-btn,
.student-remove-btn:focus-visible {
  opacity: 1;
}

.student-remove-btn:hover {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.student-list-empty {
  text-align: center;
  color: var(--c-text-subtle);
  font-size: 0.88rem;
  padding: var(--space-6) var(--space-4);
  font-style: italic;
}

/* ----- Add student button (inside column) ----- */
.add-student-btn {
  margin: var(--space-2);
  margin-top: 0;
  padding: var(--space-3);
  background: transparent;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-md);
  color: var(--c-text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.add-student-btn:hover {
  background: var(--c-brand-soft);
  border-color: var(--c-brand);
  color: var(--c-brand-strong);
}

.add-student-btn:focus-visible {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: var(--focus-ring);
}

/* ----- New class column tile ----- */
.new-class-column {
  flex: 0 0 240px;
  align-self: stretch;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: transparent;
  border: 1.5px dashed var(--c-border-strong);
  border-radius: var(--radius-lg);
  color: var(--c-text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.new-class-column:hover {
  background: var(--c-surface);
  border-color: var(--c-brand);
  color: var(--c-brand-strong);
  transform: translateY(-1px);
}

.new-class-column:focus-visible {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(101, 100, 182, 0.2);
}

.new-class-plus {
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 300;
}

/* ----- Mobile FAB ----- */
.fab {
  display: none;
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(101, 100, 182, 0.4);
  z-index: 50;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(101, 100, 182, 0.5);
}

.fab:active { transform: translateY(0); }

/* ----- Modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 40, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
  animation: backdrop-fade var(--t-normal) var(--ease);
}

/* Animate opacity only — animating backdrop-filter forces a per-frame
   re-rasterisation of the blurred region, which can drop frames on
   weak GPUs. The static .modal-backdrop rule already declares the blur
   at full strength; it just appears under the fade. */
@keyframes backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop var(--t-slow) var(--ease);
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* Explicit background overrides header.css's bare `header { background: ... }`
   rule that matches every <header> element including our modal-header. */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--c-divider);
  background: var(--c-surface);
  height: auto;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.005em;
}

.modal-body {
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--c-divider);
  background: var(--c-surface-2);
}

/* ----- Forms ----- */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-text);
}

.form-input,
.form-input-search {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.form-input::placeholder,
.form-input-search::placeholder { color: var(--c-text-subtle); }

.form-input:focus,
.form-input-search:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: var(--focus-ring);
}

.form-error {
  margin: var(--space-3) 0 0;
  color: var(--c-danger);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-error::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ----- Empty-state actions row ----- */
.empty-state-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-3);
}

.empty-state-or {
  font-size: 0.9rem;
  color: var(--c-text-subtle);
  font-style: italic;
}

/* ----- Create-class radio (How do you want to add students?) ----- */
.create-intent {
  margin: var(--space-4) 0 0;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.create-intent legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-text);
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.radio-row:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border-strong);
}

.radio-row input[type="radio"] {
  margin: 0;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--c-brand);
  cursor: pointer;
}

.radio-row input[type="radio"]:checked + span strong {
  color: var(--c-brand-strong);
}

.radio-row:has(input:checked) {
  background: var(--c-brand-soft);
  border-color: var(--c-brand);
}

.radio-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.radio-row strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--c-text);
}

.radio-help {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  font-weight: 400;
  line-height: 1.35;
}

/* ----- Roster import modal ----- */
.form-help {
  margin: 0 0 var(--space-3);
  font-size: 0.9rem;
  color: var(--c-text-muted);
  line-height: 1.5;
}

.form-example {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  background: var(--c-surface-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--radius-md);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  color: var(--c-text-muted);
  white-space: pre-wrap;
}

.form-textarea {
  resize: vertical;
  min-height: 200px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.roster-review {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--c-divider);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--c-surface-2);
}

.roster-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--c-surface);
  border: 1px solid var(--c-divider);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.roster-row-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.78rem;
  color: white;
  background: var(--c-text-subtle);
  user-select: none;
}

.roster-row-existing .roster-row-marker { background: var(--c-success); }
.roster-row-new      .roster-row-marker { background: var(--c-brand); }
.roster-row-skipped  .roster-row-marker { background: var(--c-text-subtle); }
.roster-row-error    .roster-row-marker { background: var(--c-danger); }

.roster-row-error { border-color: #f4b6b6; background: var(--c-danger-soft); }
.roster-row-skipped { opacity: 0.6; }

.roster-row-body { min-width: 0; }
.roster-row-name {
  font-weight: 500;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.roster-row-meta {
  margin-top: 2px;
  display: flex;
  gap: var(--space-2);
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

.roster-row-level {
  background: var(--c-brand-soft);
  color: var(--c-brand-strong);
  font-weight: 600;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
}

.roster-row-status {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  white-space: nowrap;
}

.roster-row-error .roster-row-status { color: var(--c-danger); font-weight: 500; }

.roster-summary {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-top: var(--space-3);
  font-size: 0.85rem;
  color: var(--c-text-muted);
  font-weight: 500;
}

.roster-summary-error { color: var(--c-danger); }

/* ----- Student picker (Add student modal) ----- */
.student-picker {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--c-divider);
  border-radius: var(--radius-md);
}

.student-picker-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--c-divider);
  transition: background var(--t-fast);
}

.student-picker-row:last-child { border-bottom: none; }
.student-picker-row:hover { background: var(--c-surface-2); }

.student-picker-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--c-text-subtle);
  font-style: italic;
}

/* ----- Bulk action bar ----- */
.bulk-bar {
  position: fixed;
  bottom: var(--space-5);
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 var(--space-3);
}

.bulk-bar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  pointer-events: auto;
  max-width: 100%;
  animation: toast-rise var(--t-slow) var(--ease);
}

.bulk-summary {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: 0.92rem;
  color: var(--c-text);
  white-space: nowrap;
}

.bulk-count {
  font-weight: 700;
  color: var(--c-brand-strong);
  font-size: 1.05rem;
}

.bulk-source { color: var(--c-text-muted); }
.bulk-source strong { color: var(--c-text); font-weight: 600; }

.bulk-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-bulk {
  padding: var(--space-2) var(--space-3);
  font-size: 0.88rem;
  border-radius: var(--radius-md);
}

.btn-bulk-danger {
  color: var(--c-danger);
  border-color: var(--c-border);
}

.btn-bulk-danger:hover {
  background: var(--c-danger-soft);
  border-color: #f4b6b6;
}

.bulk-move-wrap { position: relative; }

.bulk-move-dropdown {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: var(--space-1);
  animation: menu-pop var(--t-fast) var(--ease);
}

.bulk-move-empty {
  padding: var(--space-3);
  font-size: 0.88rem;
  color: var(--c-text-subtle);
  text-align: center;
  font-style: italic;
}

/* ----- Toast ----- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 2 * var(--space-4));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: #1f2230;
  color: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  min-width: 260px;
  max-width: 480px;
  pointer-events: auto;
  font-size: 0.92rem;
  animation: toast-rise var(--t-slow) var(--ease);
}

@keyframes toast-rise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-error { background: #5b1d1d; }

.toast-message { flex: 1 1 auto; }

.toast-undo {
  background: transparent;
  color: var(--c-accent);
  border: none;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.92rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
}

.toast-undo:hover { background: rgba(255, 255, 255, 0.08); color: white; }

.toast-error .toast-undo { color: #f4a8a8; }

.toast-dismiss {
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 var(--space-1);
  line-height: 1;
  transition: color var(--t-fast);
}

.toast-dismiss:hover { color: white; }

/* ============================================================================
   Responsive
   ============================================================================ */

/* Tablet */
@media (max-width: 1100px) {
  .page-container { padding: 0 var(--space-4); }
  .class-column { flex-basis: 300px; }
  .search-input { width: 220px; }
}

/* Mobile */
@media (max-width: 760px) {
  .page-container { padding: 0 var(--space-3); }

  .page-header {
    margin-bottom: var(--space-4);
  }

  .page-header-inner {
    padding: var(--space-5) var(--space-3) var(--space-4);
    align-items: stretch;
    gap: var(--space-3);
  }

  .page-title { font-size: 1.5rem; gap: var(--space-2); }
  .page-title::before { width: 3px; height: 1.3em; }
  .page-header-subtitle { padding-left: calc(3px + var(--space-2)); font-size: 0.82rem; }

  .page-actions { gap: var(--space-2); flex: 1 1 100%; }
  .page-actions .btn-primary { display: none; } /* moved to FAB */
  .search-input { width: 100%; flex: 1 1 100%; }

  .classes-board {
    flex-direction: column;
    overflow-x: visible;
    padding-bottom: 100px; /* leave room for FAB */
  }

  .class-column {
    flex: 1 0 auto;
    width: 100%;
    max-height: none;
  }

  .new-class-column {
    flex: 1 0 auto;
    width: 100%;
    min-height: 100px;
  }

  /* Class menu opens upward on mobile to avoid covering next class's content */
  .class-menu-dropdown {
    top: auto;
    bottom: calc(100% + 4px);
  }

  .fab { display: flex; align-items: center; justify-content: center; }

  /* Bigger touch targets */
  .student-remove-btn { opacity: 1; width: 32px; height: 32px; }
  .student-select { opacity: 1; width: 20px; height: 20px; } /* always visible on mobile */
  /* Slightly wider checkbox column for the larger mobile checkbox. */
  .student-card { grid-template-columns: 20px 36px minmax(0, 1fr) max-content; }

  .toast-container { bottom: calc(56px + var(--space-6) + var(--space-3)); }
  .toast { min-width: 0; }

  /* Bulk bar: when visible (selectedStudentIds > 0) the FAB is auto-hidden
     so there's no positional conflict. On narrow screens let the pill
     wrap to two rows if needed and keep generous touch targets. */
  .bulk-bar { bottom: var(--space-3); }
  .bulk-bar-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
  }
  .btn-bulk { padding: var(--space-2) var(--space-3); font-size: 0.92rem; min-height: 36px; }
  /* Move dropdown opens upward — on mobile we anchor to a different edge
     so it doesn't shoot off the top of the screen. */
  .bulk-move-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 2 * var(--space-3));
  }

  .modal { max-width: 100%; }
  .modal-header,
  .modal-body { padding-left: var(--space-4); padding-right: var(--space-4); }
  .modal-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
}

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop,
  .modal,
  .class-menu-dropdown,
  .toast {
    animation: none;
  }
  * { transition-duration: 0.001ms !important; }
}
