:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --page: #f6f7fb;          /* Solid page background fixes the "column" */
  --card-bg: #ffffff;
  --radius: 16px;
  --transition: 0.25s ease;
}

/* Reset & base */
* { box-sizing: border-box; }
html { height: 100%; }
body {
  min-height: 100svh;
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--page);
  display: grid;
  place-items: center;       /* centers the card */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* When logged in, use normal flow (not centered grid) */
body.app-mode {
  display: block;
  padding: 20px;
}


/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 36px;
  background: var(--card-bg);       /* solid white, no frosted blur */
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
  text-align: center;
  animation: fade-in 0.45s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 24px;
}

/* ---------- Form ---------- */
.field { position: relative; margin-bottom: 14px; }

.field input {
  width: 100%;
  padding: 14px 44px 14px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.12);
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: #9ca3af;
  padding: 2px 6px;
  border-radius: 8px;
}

.toggle-password:hover { color: var(--primary); }

/* ---------- Button ---------- */
.btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.05s ease;
}

.btn:hover,
.btn:focus-visible { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

/* ---------- Messages ---------- */
#message {
  margin-top: 14px;
  font-size: 0.93rem;
  font-weight: 500;
  min-height: 1.2em;
}

.error { color: #d52731; }
.success { color: #269f53; }

/* ---------- Logout button ---------- */
/* Tiny logout icon (top-left of the page) */
.logout-icon {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 24, 40, 0.12);
  transition: background var(--transition), transform 0.05s ease;
  z-index: 1000;
}
.logout-icon i {
  font-size: 14px;   /* slightly larger than before */
  line-height: 1;
}

.logout-icon:hover { background: var(--primary-dark); }
.logout-icon:active { transform: translateY(1px); }



/* ---------- "+User" FAB (bottom-left) ---------- */
.user-fab {
  position: fixed;
  bottom: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.14);
  transition: background var(--transition), transform 0.05s ease, box-shadow var(--transition);
  z-index: 1000;
}
.user-fab i { font-size: 18px; line-height: 1; }
.user-fab:hover { background: var(--primary-dark); box-shadow: 0 8px 18px rgba(16,24,40,0.18); }
.user-fab:active { transform: translateY(1px); }


/* ---------- Calendar FAB (above +User) ---------- */
.calendar-fab {
  position: fixed;
  bottom: 64px;            /* sits above the +User fab */
  left: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.14);
  transition: background var(--transition), transform 0.05s ease, box-shadow var(--transition);
  z-index: 1000;
}
.calendar-fab i { font-size: 18px; line-height: 1; }
.calendar-fab:hover { background: var(--primary-dark); box-shadow: 0 8px 18px rgba(16,24,40,0.18); }
.calendar-fab:active { transform: translateY(1px); }


/* Teacher Calendar FAB (stacked above student FAB) */
.teacher-fab { bottom: 116px; }

/* Teacher page: pin the FAB to the true bottom-left and trim bottom spacing */
.page-teacher .teacher-fab {
  position: fixed;
  bottom: 12px;   /* was 116px on main page — this is the fix */
  left: 12px;
  z-index: 1200;
}

/* In case any containers add extra bottom gap, collapse it on this page */
.page-teacher .student-grid,
.page-teacher .day-grid,
.page-teacher #tBoardContent {
  margin-bottom: 0;
  padding-bottom: 0;
}


/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1100;
}


/* Respect the [hidden] attribute for the modal */
.modal-backdrop[hidden] {
  display: none !important;
}

/* ---------- Autocomplete for "New student name" ---------- */
.autocomplete {
  position: relative;
}
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.12);
  max-height: 240px;
  overflow: auto;
  z-index: 1200; /* above modal content */
}
.autocomplete-list .suggestion {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}
.autocomplete-list .suggestion:hover { background: #f8fafc; }
.autocomplete-list .empty { padding: 10px 12px; color: #64748b; }

.modal {
  width: min(980px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(16, 24, 40, 0.28);
  animation: fade-in 0.25s ease both;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #eef2f7;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  gap: 10px;
  align-items: center;
  color: #0f172a;
}
.modal-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #475569;
}
.modal-body {
  padding: 18px 20px 6px;
  display: grid;
  gap: 16px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px 20px;
  border-top: 1px solid #eef2f7;
}

/* Buttons (match your style) */
.btn-primary, .btn-secondary, .btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; border-radius: 12px; cursor: pointer;
  padding: 12px 16px; border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform 0.05s ease;
}
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background:#f1f5f9; color:#0f172a; border-color:#e2e8f0; }
.btn-secondary:hover { background:#e2e8f0; }
.btn-outline { background:#fff; color:#0f172a; border-color:#e2e8f0; }
.btn-outline:hover { background:#f8fafc; }

.section-title {
  margin-top: 6px;
  font-weight: 700;
  color: #0f172a;
}

.grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.form-group label { display:block; margin: 0 0 6px; font-weight:600; color:#334155; }
.form-group input, .form-group select {
  width: 100%; padding: 12px 12px; border-radius: 12px; border: 1px solid #e5e7eb;
  background:#f9fafb; outline: none; font-size: 0.95rem;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(13,110,253,0.12);
}

/* Schedule rows */
#scheduleRows { display: grid; gap: 10px; margin-bottom: 8px; }
.schedule-row {
  display: grid; grid-template-columns: 180px 160px 140px auto;
  gap: 10px; align-items: center;
}


/* Teacher: day + start + end + remove */
#teacherScheduleRows { display: grid; gap: 10px; margin-bottom: 8px; }
.range-row{
  display: grid;
  grid-template-columns: 180px 140px 140px auto;
  gap: 10px;
  align-items: center;
}
.range-row .day, .range-row .start, .range-row .end{
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 12px; background:#f9fafb;
}
.range-row .remove{
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; padding:0; border-radius:12px;
  border:1px solid #fecaca; background:#fff; color:#ef4444; cursor:pointer;
}
.range-row .remove:hover{ background:#fff1f2; }
@media (max-width:720px){
  .range-row{ grid-template-columns: 1fr 1fr 1fr auto; }
}


@media (max-width: 720px) {
  .schedule-row { grid-template-columns: 1fr 1fr 1fr auto; }
}

.schedule-row .day, .schedule-row .time {
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 12px; background:#f9fafb;
}
.schedule-row .remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff;
  color: #ef4444;
  cursor: pointer;
  justify-self: start; /* don't stretch across the row */
}
.schedule-row .remove i { pointer-events: none; }

.schedule-row .remove:hover { background:#fff1f2; }

.tip { color:#64748b; font-size: 0.9rem; }
.hidden { display: none !important; }



.schedule-row .bp-toggle{
  display:inline-flex; align-items:center; gap:8px;
  padding: 10px 12px; border:1px solid #e5e7eb; border-radius:12px; background:#f9fafb;
  font-weight:600; color:#334155;
}
.schedule-row .bp-toggle input{ transform: translateY(1px); }

/* ---------- Calendar Board ---------- */
.board {
  /* Wider container with a responsive cap */
  width: min(92vw, 1600px);
  max-width: 1600px;
  margin: 24px auto;
}


.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.board-header h1 {
  display: flex; gap: 10px; align-items: center;
  margin: 0; font-size: 1.25rem; color: #0f172a;
}

.view-toggle { display: inline-flex; gap: 8px; align-items: center; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid #e5e7eb; background: #fff; font-weight: 700;
}
.toggle.active { background: #eff6ff; border-color: #bfdbfe; }
.toggle:hover { background: #f8fafc; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid #e5e7eb; background: #fff; cursor: pointer;
}
.icon-btn:hover { background: #f8fafc; }

/* ----- By-student grid (modern cards) ----- */
.student-grid {
  display: grid;
  /* Always a single, full-width card per row */
  grid-template-columns: 1fr;
  gap: 16px;
}


.student-card {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(16,24,40,.06);
  padding: 12px 14px;
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(16,24,40,.1);
  border-color: #e4e7ee;
}

/* Row = name column + 7 equal day columns */
.student-week{
  display: grid;
  grid-template-columns: minmax(180px, 260px) repeat(7, 1fr);
  align-items: center;
  gap: 8px 12px;
}

/* name column on the left */
.student-name{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
}

/* small rounded badge for status number */
.status-badge{
  display:inline-grid;
  place-items:center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 800;
  color:#0f172a;
  background:#eef2f7;
  border:1px solid #e2e8f0;
  border-radius: 9999px;
  line-height: 1;
}


/* hide the faint day badge when a pill exists in this cell */
.day-cell.has-pill::before { display: none; }

/* Connected "day + time" pill */
.duo-chip{
  --bg: #eef2ff;
  --bd: #e0e7ff;
  --fg: #3730a3;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--bd);
  background: var(--bg);
  color: var(--fg);
  border-radius: 9999px;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(16,24,40,0.03);
  cursor: pointer;
  white-space: nowrap;            /* NEW: never wrap inside the chip */
}



/* left segment = weekday */
.duo-chip .day{
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  background: rgba(255,255,255,.6);
  border-right: 1px solid var(--bd);
  border-top-left-radius: 9999px;
  border-bottom-left-radius: 9999px;
}

/* right segment = time (slightly smaller than before) */
.duo-chip .time{
  font-size: 14px;
  font-weight: 800;
  padding: 6px 10px;
  letter-spacing: .2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;           /* NEW: keep “03:00 PM” on one line */
}


/* small hairline between start and end, follows current text color */
.t-sep {
  display: inline-block;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: .35;
}

/* when a day has multiple shifts, give pills a bit of breathing room */
.day-cell .duo-chip { margin: 3px 0; }


/* subtle highlight for the next upcoming session */
.duo-chip.next{
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
  border-color: #bfdbfe;
}

/* per-day color tokens (same hues you already use) */
.duo-chip.sun { --bg:#fff7ed; --bd:#ffedd5; --fg:#9a3412; }
.duo-chip.mon { --bg:#eef2ff; --bd:#e0e7ff; --fg:#3730a3; }
.duo-chip.tue { --bg:#ecfeff; --bd:#cffafe; --fg:#155e75; }
.duo-chip.wed { --bg:#ecfdf5; --bd:#bbf7d0; --fg:#065f46; }
.duo-chip.thu { --bg:#fdf2f8; --bd:#fbcfe8; --fg:#9d174d; }
.duo-chip.fri { --bg:#fef9c3; --bd:#fde68a; --fg:#854d0e; }
.duo-chip.sat { --bg:#f1f5f9; --bd:#e2e8f0; --fg:#334155; }

/* === Extra session (buổi phụ) look === */
.duo-chip.extra{
  --bg:#fff1f2;
  --bd:#fecaca;
  --fg:#b91c1c;
  border-style: dashed;
  position: relative;

  /* make the chip feel longer & flatter */
  padding-right: 6px;            /* adds a tiny bit of length */
}

/* slim the vertical padding on segments only for extra chips */
.duo-chip.extra .day{ padding: 2px 8px; }

.duo-chip.extra .time{
  padding: 3px 12px;   /* was 4px 12px */
  line-height: 1;
}


/* compact PHỤ badge so it doesn't increase height */
.duo-chip.extra .time::after{
  content: ' PHỤ';
  margin-left: 8px;
  font-size: 11px;
  font-weight: 900;
  padding: 1px 6px;              /* was 2px 6px -> shorter badge */
  line-height: 1;                /* prevents chip from growing taller */
  border-radius: 8px;
  border: 1px solid var(--bd);
  background: #fff;
}




.chip.sun { background:#fff7ed; border-color:#ffedd5; color:#9a3412; }
.chip.mon { background:#eef2ff; border-color:#e0e7ff; color:#3730a3; }
.chip.tue { background:#ecfeff; border-color:#cffafe; color:#155e75; }
.chip.wed { background:#ecfdf5; border-color:#bbf7d0; color:#065f46; }
.chip.thu { background:#fdf2f8; border-color:#fbcfe8; color:#9d174d; }
.chip.fri { background:#fef9c3; border-color:#fde68a; color:#854d0e; }
.chip.sat { background:#f1f5f9; border-color:#e2e8f0; color:#334155; }

.chip.next {
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
  border-color: #bfdbfe !important;
}

/* Responsive: on narrow screens stack the week grid */
@media (max-width: 900px){
  .student-week{
    grid-template-columns: 1fr; /* name on its own row */
  }
  .day-cell{
    padding-left: 38px;
  }
  .student-card{
    padding: 14px;
  }
}


/* pill chips + day colors */
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 10px; border-radius: 9999px; font-weight: 700;
  background: #eef2ff; border: 1px solid #e0e7ff; color: #3730a3;
}

/* day-specific hues */
.chip.sun { background:#fff7ed; border-color:#ffedd5; color:#9a3412; }
.chip.mon { background:#eef2ff; border-color:#e0e7ff; color:#3730a3; }
.chip.tue { background:#ecfeff; border-color:#cffafe; color:#155e75; }
.chip.wed { background:#ecfdf5; border-color:#bbf7d0; color:#065f46; }
.chip.thu { background:#fdf2f8; border-color:#fbcfe8; color:#9d174d; }
.chip.fri { background:#fef9c3; border-color:#fde68a; color:#854d0e; }
.chip.sat { background:#f1f5f9; border-color:#e2e8f0; color:#334155; }

/* highlight the next session on the card */
.chip.next {
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
  border-color: #bfdbfe !important;
}


/* ----- By-day grid ----- */
.day-grid .day-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 8px 10px; margin-bottom: 8px;
}
.day-grid .day-item .who { font-weight: 700; color: #0f172a; }
.day-grid .day-item .when {
  color: #475569;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.day-grid .day-item:last-child { margin-bottom: 0; }


/* Nicer “teacher name” tag */
/* Compact teacher name pill */
.assigned-teacher{
  display: inline-flex;
  align-items: center;
  gap: 6px;                  /* tighter gap */
  margin-top: 4px;           /* smaller top margin */
  padding: 4px 8px;          /* smaller padding */
  line-height: 1;            /* keeps height tight */
  font-size: 11px;           /* slightly smaller text */
  font-weight: 700;
  color: #1f2937;
  background: #eef2ff;
  border: 1px solid #dbeafe;
  border-radius: 9999px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: box-shadow .16s ease, border-color .16s ease;
}

.assigned-teacher::before{
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: currentColor; /* dot follows text color */
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 30%, transparent);
  flex: 0 0 auto;
}

/* Teacher pill colors follow the day */
.assigned-teacher.sun { background:#fff7ed; border-color:#ffedd5; color:#9a3412; }
.assigned-teacher.mon { background:#eef2ff; border-color:#e0e7ff; color:#3730a3; }
.assigned-teacher.tue { background:#ecfeff; border-color:#cffafe; color:#155e75; }
.assigned-teacher.wed { background:#ecfdf5; border-color:#bbf7d0; color:#065f46; }
.assigned-teacher.thu { background:#fdf2f8; border-color:#fbcfe8; color:#9d174d; }
.assigned-teacher.fri { background:#fef9c3; border-color:#fde68a; color:#854d0e; }
.assigned-teacher.sat { background:#f1f5f9; border-color:#e2e8f0; color:#334155; }


.assigned-teacher::before{
  content: '';
  width: 6px;                /* smaller dot */
  height: 6px;
  border-radius: 9999px;
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,.18); /* thinner ring */
  flex: 0 0 auto;
}

.assigned-teacher:hover{
  border-color: #bfdbfe;
  box-shadow: 0 2px 10px rgba(59,130,246,.12);
}



/* Usage bar under assigned pills */
.usage { margin-top: 6px; }
.usage-bar {
  height: 6px;
  background: #e5e7eb;       /* light gray track */
  border-radius: 9999px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  width: 0;                  /* set inline via style attribute */
  background: #3b82f6;       /* blue fill */
}
.usage-label {
  margin-top: 4px;
  font-size: 11px;
  color: #334155;
}

/* Small teacher picker popover (used on main board) */
.pick-popover {
  position: fixed;        /* independent of the parent layout */
  right: auto !important; /* cancel the .autocomplete-list { right:0 } */
  width: auto;
  min-width: 220px;
  max-width: 320px;
}
.pick-popover .suggestion {
  white-space: normal;    /* allow long names to wrap instead of forcing width */
}


/* Mini popover editor for a single availability range */
.avail-editor{
  position: fixed;
  z-index: 1300;
  width: 300px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 18px 36px rgba(16,24,40,.14);
}
.avail-editor .ae-row{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.avail-editor label{
  width: 48px;
  font-size: 12px;
  color: #334155;
}
.avail-editor input[type="time"]{
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 0.95rem;
}
.avail-editor .ae-actions{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.avail-editor .ae-actions .spacer{ flex: 1; }

/* small buttons */
.btn-sm{
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.btn-sm.primary{
  color: #fff;
  background: var(--primary);
  border-color: transparent;
}
.btn-sm.danger{
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}
.btn-sm:hover{ filter: brightness(0.98); }


/* ---------- Teacher Calendar chip button (bottom-right) ---------- */
.teacher-calendar-chip {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: #ffffff;
  color: #111;
  border: 1px solid rgba(17, 24, 39, 0.12);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  transition: transform 0.05s ease, box-shadow 160ms ease,
              background 160ms ease, color 160ms ease, border-color 160ms ease;
  z-index: 1100;
}
.teacher-calendar-chip .icon {
  line-height: 1;
  font-size: 16px; /* emoji size */
}
.teacher-calendar-chip:hover {
  border-color: var(--primary, #2563eb);
  background: var(--primary, #2563eb);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}
.teacher-calendar-chip:active {
  transform: translateY(1px);
}

/* Focus-visible for keyboard users */
.teacher-calendar-chip:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary, #2563eb) 50%, transparent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px color-mix(in srgb, var(--primary, #2563eb) 35%, transparent);
}

/* Only on Teacher page: pin the FAB to the real bottom-left */
.page-teacher .teacher-fab { bottom: 12px; left: 12px; }


/* ---------- Back to main (teacher page) ---------- */
.back-home-chip {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(17, 24, 39, 0.12);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  transition: transform 0.05s ease, box-shadow 160ms ease,
              background 160ms ease, color 160ms ease, border-color 160ms ease;
  z-index: 1150; /* above cards & modals backdrop */
}
.back-home-chip i {
  font-size: 14px;
  line-height: 1;
}
.back-home-chip:hover {
  border-color: var(--primary, #2563eb);
  background: var(--primary, #2563eb);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}
.back-home-chip:active {
  transform: translateY(1px);
}
.back-home-chip:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary, #2563eb) 50%, transparent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px color-mix(in srgb, var(--primary, #2563eb) 35%, transparent);
}


/* ===== Teacher Planner ===== */
.planner-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}
@media (max-width: 920px){ .planner-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px){ .planner-grid { grid-template-columns: 1fr; } }

.planner-day {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(16,24,40,.06);
  padding: 12px;
}
.planner-day h4 {
  display:flex; align-items:center; justify-content:space-between;
  margin:0 0 10px; color:#0f172a;
}
.range-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:6px 8px; margin:8px 0 6px;
  background:#f8fafc; border:1px solid #e5e7eb; border-radius:10px;
  font-weight:700; color:#334155;
  font-variant-numeric: tabular-nums;
}
.range-time { display:inline-flex; align-items:center; gap:8px; }
.range-len  { color:#64748b; font-weight:600; }

.block {
  display:inline-flex; align-items:center; gap:8px;
  margin:4px 6px 0 0; padding:6px 10px;
  border-radius:9999px; border:1px solid #e2e8f0; background:#ffffff;
  font-weight:700; font-size:12px; color:#0f172a;
  box-shadow: 0 1px 0 rgba(16,24,40,0.04);
}
.block .when { color:#475569; font-variant-numeric: tabular-nums; font-weight:600; }
.block .del  { border:none; background:none; color:#ef4444; cursor:pointer; }

.add-link {
  display:inline-flex; align-items:center; gap:6px;
  padding:6px 8px; border-radius:10px; border:1px dashed #cbd5e1;
  background:#f8fafc; color:#334155; font-weight:600; cursor:pointer;
}
.add-link:hover { background:#eef2f7; }

.add-pop {
  position: fixed; z-index: 1300; width: 320px;
  padding: 12px; background:#fff; border:1px solid #e5e7eb; border-radius:12px;
  box-shadow: 0 18px 36px rgba(16,24,40,.14);
}
.add-pop .row { display:flex; gap:10px; align-items:center; margin-bottom:8px; }
.add-pop label { width:76px; font-size:12px; color:#334155; }
.add-pop input[type="time"], .add-pop select, .add-pop input[type="number"] {
  flex:1; padding:8px 10px; border:1px solid #e5e7eb; border-radius:10px; background:#f9fafb;
}
.add-pop .actions { display:flex; gap:8px; justify-content:flex-end; }
.add-pop .btn-sm { padding:8px 12px; }


/* ===================== Teacher Planner: vertical timelines ===================== */

/* grid of day cards (keeps your existing look) */
.planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.planner-day {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(16,24,40,.06);
}
.planner-day h4 { margin: 4px 8px 12px; color:#0f172a; }

/* range header (08:00 — 12:00 • 240 min) */
.range-head {
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin-bottom: 8px;
}
.range-head .range-time { display:inline-flex; gap:8px; font-variant-numeric: tabular-nums; }
.range-head .range-len  { font-weight: 800; color:#475569; }
.range-head .t-sep {
  display:inline-block; width:12px; height:2px; border-radius:2px;
  background: currentColor; opacity:.35;
}

/* vertical timeline column */
/* ===== Teacher Planner: vertical timeline ===== */
.timeline{
  position: relative;
  --px-per-min: 3px;
  --pad-top: 20px;   /* was 14px */
  --pad-bottom: 12px;
  height: calc(var(--len-min) * var(--px-per-min) + var(--pad-top) + var(--pad-bottom));
  padding-top: var(--pad-top);
  padding-bottom: var(--pad-bottom);
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}


/* ticks layer stays absolutely positioned */
.timeline .ticks{
  position: absolute;
  inset: 0;
}

/* 5-minute line */
.timeline .tick{
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: #e5e7eb;
}

/* 30-minute line a bit darker */
.timeline .tick.half{ background: #dfe5ee; }

/* Hour line slightly thicker */
.timeline .tick.hour{ height: 2px; background: #ccd5e3; }

/* time label next to hour / half-hour */
.timeline .tick .tlabel{
  position: absolute;
  left: 8px;
  top: -8px;                 /* centered on the line */
  font-size: 12px;
  color: #64748b;
  background: #fff;
  padding: 0 4px;
  border-radius: 6px;
}

/* Make the very first tick label (range start, e.g., 08:00) visible */
.timeline .ticks .tick:first-child .tlabel {
  top: 2px;   /* put it fully inside the box instead of above the line */
}


/* blocks layer */
.timeline .blocks-v{
  position: absolute;
  inset: 0;
  padding: 0 10px;
}

@media (max-width: 640px){
  .timeline { height: calc(var(--len-min) * 1.6px); } /* slightly shorter on phones */
}

/* 5-minute grid lines; stronger for hours/half-hours */
.tick { position:absolute; left:0; right:0; height:1px; background: rgba(100,116,139,0.18); }
.tick.half { background: rgba(100,116,139,0.26); }
.tick.hour { background: rgba(100,116,139,0.34); }
.tick .tlabel {
  position:absolute; left:6px; top:-7px; font-size:10px; color:#64748b;
  padding:0 4px; border-radius:4px; background: rgba(255,255,255,.7);
}

/* layer that holds the blocks */
.blocks-v { position:absolute; inset:0; padding: 0 8px; }

/* a scheduled block rectangle */
.blk {
  position:absolute; left:8px; right:8px;
  display:flex; align-items:center; gap:8px;
  padding:4px 8px;
  border-radius:10px;

  /* use per-card tokens with day-color fallbacks */
  background: var(--cardbg, var(--bg));
  color: var(--cardfg, var(--fg));
  border: 1px solid var(--cardbd, var(--bd));

  box-shadow: 0 6px 12px rgba(16,24,40,.06);
  font-size:12px; line-height:1.2;
}

/* make inner text follow the card color */
.blk .b-name,
.blk .b-time { color: inherit; }



/* Rotate a clean palette per card inside each timeline column */
/* Rotate harmonious bg/fg/border for blocks (8-color loop) */
.blocks-v .blk:nth-child(8n+1) { --cardbg:#eef2ff; --cardbd:#e0e7ff; --cardfg:#1e3a8a; } /* indigo */
.blocks-v .blk:nth-child(8n+2) { --cardbg:#ecfeff; --cardbd:#cffafe; --cardfg:#155e75; } /* cyan/teal */
.blocks-v .blk:nth-child(8n+3) { --cardbg:#fefce8; --cardbd:#fde68a; --cardfg:#854d0e; } /* amber */
.blocks-v .blk:nth-child(8n+4) { --cardbg:#fdf2f8; --cardbd:#fbcfe8; --cardfg:#9d174d; } /* rose */
.blocks-v .blk:nth-child(8n+5) { --cardbg:#ecfdf5; --cardbd:#bbf7d0; --cardfg:#065f46; } /* emerald */
.blocks-v .blk:nth-child(8n+6) { --cardbg:#fff7ed; --cardbd:#ffedd5; --cardfg:#9a3412; } /* orange */
.blocks-v .blk:nth-child(8n+7) { --cardbg:#f1f5f9; --cardbd:#e2e8f0; --cardfg:#334155; } /* slate */
.blocks-v .blk:nth-child(8n+8) { --cardbg:#e0f2fe; --cardbd:#bae6fd; --cardfg:#075985; } /* sky */

/* small lift on hover */
.blocks-v .blk:hover { box-shadow: 0 10px 18px rgba(16,24,40,.10); }


.blk .b-time { font-variant-numeric: tabular-nums; font-weight:800; }
.blk .b-name { font-weight:700; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.blk .del {
  margin-left:auto; border:0; background:transparent; color:#e11d48;
  cursor:pointer; font-size:14px;
}

/* day color tokens reused from your chips */
.blk.sun { --bg:#fff7ed; --bd:#ffedd5; --fg:#9a3412; }
.blk.mon { --bg:#eef2ff; --bd:#e0e7ff; --fg:#3730a3; }
.blk.tue { --bg:#ecfeff; --bd:#cffafe; --fg:#155e75; }
.blk.wed { --bg:#ecfdf5; --bd:#bbf7d0; --fg:#065f46; }
.blk.thu { --bg:#fdf2f8; --bd:#fbcfe8; --fg:#9d174d; }
.blk.fri { --bg:#fef9c3; --bd:#fde68a; --fg:#854d0e; }
.blk.sat { --bg:#f1f5f9; --bd:#e2e8f0; --fg:#334155; }


/* ===== Teacher Planner: centered "Add block" modal ===== */
.add-pop-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.45);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 2000; /* above everything */
}

.add-pop{
  width: min(380px, 92vw);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(16,24,40,.28);
  padding: 14px;
}

.add-pop .row{
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.add-pop label{ color:#334155; font-size: 13px; font-weight: 600; }
.add-pop select,
.add-pop input{
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  font-size: 0.95rem;
}

.add-pop .actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}


/* --- Planner blocks: full name, neat header --- */
.timeline .blocks-v .blk{
  display:flex;
  flex-direction:column;
  padding:8px 10px 10px 10px; /* no reserved space for the X */
}


/* header row (time + delete button) */
.timeline .blocks-v .blk .b-top{
  display:flex;
  align-items:center;
  justify-content:flex-start; /* don't push content to make space for X */
  gap:8px;
}


/* time stays on one line */
.timeline .blocks-v .blk .b-time{
  font-weight:700;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

/* name can wrap to as many lines as needed */
.timeline .blocks-v .blk .b-name{
  margin-top:4px;
  font-weight:600;
  white-space:normal;        /* allow wrapping */
  overflow:visible;          /* no clipping */
  text-overflow:clip;        /* no ellipsis */
  word-break:break-word;     /* break long words if needed */
}

/* put the X in the header area without shrinking text */
/* put the trash icon at the bottom-right without shifting text */
.timeline .blocks-v .blk .del{
  position:absolute;       /* float over the card */
  bottom:6px;              /* ⬅️ was top:6px */
  right:8px;
  margin:0;
  z-index:2;
  opacity:0;               /* hidden by default */
  pointer-events:none;     /* not clickable until hover */
  transition: opacity .15s ease-in-out;
}


/* reveal on hover */
.timeline .blocks-v .blk:hover .del{
  opacity:1;
  pointer-events:auto;
}


/* slim trash icon button */
.timeline .blocks-v .blk .del{
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #ef4444;               /* same red you used */
  background: transparent;
}

.timeline .blocks-v .blk .del i{
  font-size: 14px;              /* slender icon size */
  line-height: 1;
}

.timeline .blocks-v .blk .del:hover{
  background: rgba(239, 68, 68, 0.10);  /* soft red hover */
}

.impacts {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.impacts-label {
  font-weight: 700;
  color: #334155;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background: #f8fafc;
  font-size: 12px;
  color: #0f172a;

}


/* === Teacher card actions (hover-only) === */
.student-card {
  position: relative; /* anchor for absolute actions */
}

.card-actions {
  position: absolute;
  top: 10px;
  right: 10px;              /* sticks to the far right */
  display: flex;
  gap: 8px;
  opacity: 0;               /* hidden by default */
  pointer-events: none;     /* ignore clicks while hidden */
  transition: opacity .12s ease-in-out;
}

.student-card:hover .card-actions {
  opacity: 1;               /* show on hover */
  pointer-events: auto;
}

.card-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}

.card-action:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}


/* --- Teacher chip: smaller + distinct from time pill --- */
.assigned-teacher { 
  margin-top: 6px;           /* small gap under the time pill */
}

.assigned-teacher .duo-chip.small {
  /* compact size */
  padding: 2px 8px;
  min-height: 18px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;

  /* make it look different from the big pill */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;       /* light gray-blue */
  border: 1px solid #cbd5e1; /* subtle outline */
  color: #334155;            /* slate text */
  box-shadow: none;          /* no shadow like the pill */
}

/* Compact teacher name chip (small + dotted rectangle) */
.teacher-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;        /* compact */
  font-size: 12px;         /* smaller text */
  line-height: 1;
  font-weight: 600;
  color: #334155;
  background: #f8fafc;
  border: 1px dotted #94a3b8;   /* dotted rectangle */
  border-radius: 10px;
  margin-top: 6px;         /* small gap under the time pill */
}

.teacher-chip::before{
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #3b82f6;     /* tiny blue dot */
  flex: 0 0 auto;
}
