/* Daisy School — Teacher Portal styles (moved out of index.html so browsers cache them). */
/* ── TOKENS ── */
:root {
  /* Blues */
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;

  /* Brand */
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-deeper: #1e3a8a;
  --brand-light:  #3b82f6;
  --brand-pale:   #eff6ff;
  --brand-mid:    #dbeafe;
  --accent:       #0ea5e9;   /* sky accent */
  --accent-warm:  #f59e0b;   /* amber for highlights */

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Surfaces */
  --bg:         #f0f4f8;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;

  /* Text */
  --text:       #0f172a;
  --text-mid:   #334155;
  --text-muted: #64748b;
  --text-hint:  #94a3b8;

  /* Borders */
  --border:     #e2e8f0;
  --border-mid: #cbd5e1;

  /* Layout */
  --topbar-h:    60px;
  --botnav-h:    68px;
  --botnav-safe: env(safe-area-inset-bottom, 0px);

  /* Radii */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  18px;
  --r-xl:  24px;
  --r-2xl: 32px;

  /* Shadows */
  --sh-xs: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --sh-sm: 0 2px 8px rgba(15,23,42,0.08), 0 1px 4px rgba(15,23,42,0.05);
  --sh-md: 0 4px 20px rgba(15,23,42,0.10), 0 2px 8px rgba(15,23,42,0.06);
  --sh-lg: 0 8px 40px rgba(15,23,42,0.14), 0 4px 16px rgba(15,23,42,0.08);
  --sh-blue: 0 4px 20px rgba(37,99,235,0.25);

  --ease: cubic-bezier(0.4,0,0.2,1);
}

/* ── DARK THEME ── (toggled via data-theme="dark" on <html>, see toggleTheme() in portal.js) */
html[data-theme="dark"] {
  --bg:         #0b1220;
  --surface:    #131b2e;
  --surface-2:  #0f1626;
  --text:       #e7ecf5;
  --text-mid:   #c2cbdb;
  --text-muted: #93a0b8;
  --text-hint:  #66748f;
  --border:     #22304a;
  --border-mid: #2c3c5c;
  --blue-50:    #16213a;
  --blue-100:   #1a2947;
  --blue-200:   #24365a;
  --gray-100:   #182238;
  --gray-200:   #22304a;
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] img.portal-gate-logo,
html[data-theme="dark"] .topbar-logo img { filter: brightness(0.95); }

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* ── LAYOUT SHELL ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── TOP HEADER ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--brand);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(37,99,235,0.35);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-logo {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.20);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.25);
}

.topbar-logo svg {
  width: 18px; height: 18px;
  fill: #fff;
}

.topbar-name {
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.65);
  font-weight: 400;
  margin-top: -2px;
  letter-spacing: 0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-year {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.90);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s var(--ease);
  color: #fff;
}

.notif-btn:hover { background: rgba(255,255,255,0.25); }

.notif-btn svg {
  width: 17px; height: 17px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
}

.notif-pip {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: #f59e0b;
  border-radius: 50%;
  border: 1.5px solid var(--brand);
  display: none;
}

.notif-pip.show { display: block; }

/* ── SCROLLABLE BODY ── */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: calc(var(--botnav-h) + var(--botnav-safe) + 12px);
}

/* ── PAGES ── */
.page { display: none; }
.page.active {
  display: block;
  animation: fadeUp 0.24s var(--ease);
}

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

/* ── BOTTOM NAVIGATION ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--botnav-h) + var(--botnav-safe));
  padding-bottom: var(--botnav-safe);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(15,23,42,0.10);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 2px 0;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-hint);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.18s var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

/* With 6 tabs, equal-flex squeezing gets illegible on narrow phones — scroll instead. */
@media (max-width: 420px) {
  .bottom-nav { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .bottom-nav::-webkit-scrollbar { display: none; }
  .nav-tab { flex: 0 0 auto; width: 70px; font-size: 0.62rem; }
}

.nav-tab .tab-icon {
  width: 44px; height: 30px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
  position: relative;
}

.nav-tab svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  transition: stroke 0.18s;
}

.nav-tab.active {
  color: var(--brand);
}

.nav-tab.active .tab-icon {
  background: var(--blue-50);
  transform: translateY(-1px);
}

.nav-tab.active svg {
  stroke: var(--brand);
  stroke-width: 2;
}

.nav-tab-label { line-height: 1; margin-bottom: 4px; }

.tab-notif-dot {
  position: absolute;
  top: 2px; right: 8px;
  width: 6px; height: 6px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
  display: none;
}

.tab-notif-dot.show { display: block; }

/* ── NOTIFICATION PANEL ── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h); right: -380px;
  width: min(380px, 100vw);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--sh-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: right 0.3s var(--ease);
}

.notif-panel.open { right: 0; }

.notif-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.40);
  z-index: 299;
  backdrop-filter: blur(2px);
}

.notif-overlay.show { display: block; }

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.notif-head-title {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.notif-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--gray-100); border-radius: 7px;
  cursor: pointer; transition: background 0.15s;
  color: var(--text-muted);
}

.notif-close:hover { background: var(--gray-200); }
.notif-close svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }

.notif-scroll {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}

.notif-item {
  padding: 12px 14px;
  background: var(--brand-pale);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}

.notif-item:hover { background: var(--blue-100); }
.notif-item-title { font-weight: 600; font-size: 0.85rem; color: var(--text); margin-bottom: 3px; }
.notif-item-msg { font-size: 0.79rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-time { font-size: 0.71rem; color: var(--brand); margin-top: 5px; font-weight: 600; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--blue-700) 60%, var(--blue-900) 100%);
  border-radius: var(--r-xl);
  padding: 22px 22px 20px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.dash-hero::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.dash-hero::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 40px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.dash-hero-inner { position: relative; z-index: 1; }

.dash-greeting {
  font-family: 'Sora', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.2;
}

.dash-sub { font-size: 0.82rem; color: rgba(255,255,255,0.65); margin-bottom: 16px; }

.dash-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hero-stat {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: var(--r-md);
  padding: 10px 8px;
  text-align: center;
}

.hero-stat-num {
  font-family: 'Sora', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  margin-bottom: 3px;
}

.hero-stat-label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.65);
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

/* Dash cards */
.dash-section-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.1px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-xs);
}

.dash-card-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--brand-pale);
}

.dash-card-icon {
  width: 30px; height: 30px;
  background: var(--brand-mid);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.dash-card-icon svg { width: 15px; height: 15px; stroke: var(--brand); fill: none; stroke-width: 1.9; }

.dash-card-title {
  font-size: 0.87rem; font-weight: 700; color: var(--text); letter-spacing: -0.1px;
}

.dash-card-body { padding: 14px 16px; }

/* ============================================================
   DASHBOARD INFOGRAPHICS
   ============================================================ */
.dash-section-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin: 18px 0 10px;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
}

.info-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.info-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  .info-grid-2 { grid-template-columns: 1fr; }
  .info-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .info-grid-3 { grid-template-columns: 1fr; }
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--sh-xs);
}

.info-card-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

/* ── DONUT / PIE SVG ── */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.donut-svg {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.pie-svg {
  width: 90px;
  height: 90px;
  display: block;
  margin: 0 auto 8px;
}

.pie-center-wrap {
  text-align: center;
}

.donut-legend, .pie-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-mid);
  line-height: 1.2;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.legend-val {
  font-weight: 700;
  color: var(--text);
  font-size: 0.77rem;
  flex-shrink: 0;
}

/* ── BAR CHARTS ── */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-mid);
  min-width: 68px;
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: var(--gray-100);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.bar-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
}

/* ── CLASS BAR CHART (horizontal scroll) ── */
.class-bar-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.class-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 100px;
  padding: 0 4px;
  min-width: max-content;
}

.class-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.class-bar {
  width: 28px;
  border-radius: 5px 5px 0 0;
  transition: height 0.5s cubic-bezier(0.4,0,0.2,1);
  min-height: 4px;
}

.class-bar-num {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.class-bar-lbl {
  font-size: 0.60rem;
  font-weight: 600;
  color: var(--text-hint);
  text-align: center;
  max-width: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  height: 40px;
  line-height: 28px;
}

/* ── EMPTY STATE ── */
.info-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-hint);
  font-size: 0.78rem;
}

/* Quick routine */
.dash-sel {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  transition: border-color 0.18s;
}

.dash-sel:focus { border-color: var(--brand); background-color: var(--surface); }

.mini-routine { margin-top: 10px; }

.mini-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.mini-row:last-child { border-bottom: none; }

.mini-day {
  background: var(--brand-pale);
  color: var(--brand);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.70rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

.mini-subj { flex: 1; font-weight: 600; color: var(--text); }
.mini-cls { font-size: 0.73rem; color: var(--text-muted); background: var(--gray-100); padding: 2px 7px; border-radius: 5px; }
.mini-time { font-size: 0.71rem; color: var(--brand); white-space: nowrap; font-weight: 600; flex-shrink: 0; }

/* Notif items in dash */
.dash-notif-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.dash-notif-row:last-child { border-bottom: none; }

.dash-notif-dot {
  width: 7px; height: 7px;
  background: var(--brand);
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.dash-notif-title { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.dash-notif-time { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  box-shadow: var(--sh-xs);
}

.seg-control {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.80rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  box-shadow: var(--sh-xs);
}

.f-sel, .f-inp {
  padding: 8px 12px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.83rem;
  color: var(--text);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.18s;
  flex: 1;
  min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.f-inp { background-image: none; padding-right: 12px; cursor: text; }

.f-sel:focus, .f-inp:focus { border-color: var(--brand); background-color: var(--surface); }

.term-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.term-chip {
  padding: 5px 13px;
  border: 1.5px solid var(--border-mid);
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.18s var(--ease);
}

.term-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ============================================================
   SECTION HEADER (page-level)
   ============================================================ */
.section-head {
  margin-bottom: 16px;
}

.section-head h1 {
    display: flex;
  font-family: 'Sora', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
  justify-content: center;
  align-items: center;
}

.section-head p { font-size: 0.82rem; color: var(--text-muted); justify-content: center; align-items: center; }

/* ============================================================
   ROUTINE TIMETABLE
   ============================================================ */
/* ── TIMETABLE — horizontally scrollable, sticky day column ── */
.timetable-wrap {
  /* Negative margin to break out of page-body padding on mobile */
  margin-left: -16px;
  margin-right: -16px;
  border-radius: 0;
  overflow: hidden;
}

@media (min-width: 600px) {
  .timetable-wrap {
    margin-left: 0;
    margin-right: 0;
    border-radius: var(--r-lg);
  }
}

.timetable {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--sh-xs);
  overflow-x: auto;           /* scroll lives HERE */
  -webkit-overflow-scrolling: touch;
  /* Hint that horizontal scrolling is available */
  scroll-snap-type: x proximity;
}

@media (min-width: 600px) {
  .timetable { border-radius: var(--r-lg); }
}

.timetable table {
  border-collapse: collapse;
  /* No width:100% — let table be as wide as content needs */
  width: max-content;
  min-width: 100%;
}

.timetable thead th {
  background: var(--brand);
  color: rgba(255,255,255,0.90);
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
}

/* Sticky day column header */
.timetable thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  color: rgba(255,255,255,0.70);
  background: var(--blue-900);
  min-width: 60px;
  border-right: 2px solid rgba(255,255,255,0.20);
}

.timetable tbody td {
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.80rem;
  text-align: center;
  vertical-align: top;
  min-width: 100px;
  max-width: 160px;
}

/* Sticky day column cells */
.timetable tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  font-weight: 700;
  font-size: 0.74rem;
  color: var(--brand);
  background: var(--blue-50);
  white-space: nowrap;
  min-width: 60px;
  max-width: 60px;
  border-right: 2px solid var(--blue-200);
  box-shadow: 2px 0 6px rgba(15,23,42,0.08);
}

.timetable tbody tr:last-child td { border-bottom: none; }
.timetable tbody tr:hover td { background: rgba(219,234,254,0.35); }
.timetable tbody tr:hover td:first-child { background: var(--blue-100); }

/* Scroll hint gradient on right edge — shows more content exists */
.timetable-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 28px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.7));
  pointer-events: none;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  display: none;
}

.timetable-wrap { position: relative; }

.tt-cell { font-weight: 600; color: var(--text); font-size: 0.82rem; }
.tt-cell small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.70rem; margin-top: 1px; }

/* Multi-entry timetable cells */
.tt-empty { color: var(--gray-300); text-align: center; font-size: 0.8rem; }

.tt-filled {
  padding: 6px 10px !important;
  vertical-align: top;
}

.tt-cell-entry {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--blue-50);
  border-left: 3px solid var(--brand);
  margin-bottom: 4px;
}

.tt-cell-entry:last-child { margin-bottom: 0; }

.tt-subj {
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.tt-info {
  font-size: 0.68rem;
  color: var(--brand);
  font-weight: 600;
  line-height: 1.2;
}

.day-chip {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.day-Sunday    { background: #fef9c3; color: #713f12; }
.day-Monday    { background: #dbeafe; color: #1e40af; }
.day-Tuesday   { background: #dcfce7; color: #14532d; }
.day-Wednesday { background: #f3e8ff; color: #581c87; }
.day-Thursday  { background: #e0f2fe; color: #0c4a6e; }
.day-Friday    { background: #ffe4e6; color: #881337; }

/* ============================================================
   COURSE PLAN
   ============================================================ */
.cp-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--sh-xs);
}

.cp-head {
  background: linear-gradient(90deg, var(--brand) 0%, var(--blue-700) 100%);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cp-head-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
}

.cp-term-tag {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.30);
  color: rgba(255,255,255,0.95);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.cp-table { width: 100%; border-collapse: collapse; }
.cp-table th { background: var(--gray-50); padding: 8px 14px; font-size: 0.70rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border); }
.cp-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: top; }
.cp-table tr:last-child td { border-bottom: none; }
.cp-table tr:hover td { background: var(--blue-50); }

.unit-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   ACTIVITIES
   ============================================================ */
.month-section { margin-bottom: 18px; }

.month-label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  font-family: 'Sora', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
}

.month-label-icon {
  width: 24px; height: 24px;
  background: rgba(255,255,255,0.20);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.month-label-icon svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 2; }

.act-cards {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  box-shadow: var(--sh-xs);
}

.act-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 14px;
  transition: all 0.18s var(--ease);
}

.act-card:hover {
  border-color: var(--blue-300);
  background: var(--blue-50);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

.act-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.act-name { font-weight: 700; font-size: 0.86rem; color: var(--text); line-height: 1.3; flex: 1; }
.act-sub-tag { background: var(--brand-mid); color: var(--brand-dark); padding: 2px 8px; border-radius: 5px; font-size: 0.70rem; font-weight: 700; white-space: nowrap; border: 1px solid var(--blue-200); }
.act-class-row { font-size: 0.77rem; color: var(--text-muted); margin-bottom: 5px; }
.act-detail { font-size: 0.80rem; color: var(--text-mid); line-height: 1.5; }

/* ============================================================
   STAFF CONTACTS
   ============================================================ */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.18s var(--ease);
  box-shadow: var(--sh-xs);
}

.contact-card:hover {
  border-color: var(--blue-300);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.contact-top { display: flex; align-items: center; gap: 12px; }

.contact-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: var(--brand);
}

.contact-name { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 4px; line-height: 1.2; }

.contact-dept {
  display: inline-block;
  background: var(--brand-pale);
  color: var(--brand-dark);
  padding: 2px 9px;
  border-radius: 5px;
  font-size: 0.70rem;
  font-weight: 700;
  border: 1px solid var(--blue-200);
}

.contact-info { display: flex; flex-direction: column; gap: 4px; }

.contact-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.81rem; color: var(--text-mid);
}

.contact-row svg { width: 13px; height: 13px; stroke: var(--text-muted); fill: none; stroke-width: 1.8; flex-shrink: 0; }

.contact-actions { display: flex; gap: 8px; padding-top: 4px; border-top: 1px solid var(--border); }

.btn-call {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s var(--ease);
  box-shadow: var(--sh-blue);
}

.btn-call:hover { background: var(--brand-dark); }
.btn-call svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.btn-mail {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-100);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--text-muted);
  transition: all 0.18s var(--ease);
  flex-shrink: 0;
}

.btn-mail:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-mail svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ============================================================
   BOOKS
   ============================================================ */
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.book-card {
  background:rgba(255,255,255,0.15);
  border:2px solid rgba(0,255,255,0.22);
  color:#fff;padding:5px 12px;font-family:inherit;font-size:.74rem;font-weight:600;text-decoration:none;white-space:nowrap;
  border-radius:8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  box-shadow: var(--sh-xs);
}
/* ============================================================
   NOTIFICATIONS PAGE
   ============================================================ */
.notifs-page { display: flex; flex-direction: column; gap: 10px; }

.notif-full-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--sh-xs);
  transition: box-shadow 0.18s;
}

.notif-full-card:hover { box-shadow: var(--sh-md); }

.notif-full-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 7px;
}

.notif-full-body { font-size: 0.86rem; color: var(--text-mid); line-height: 1.6; margin-bottom: 8px; }

.notif-full-meta {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.74rem; color: var(--text-muted);
}

.notif-full-meta svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ============================================================
   EMPTY / LOADING
   ============================================================ */
.empty-box {
  padding: 44px 20px;
  text-align: center;
}

.empty-icon {
  width: 52px; height: 52px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}

.empty-icon svg { width: 24px; height: 24px; stroke: var(--text-hint); fill: none; stroke-width: 1.6; }
.empty-box h3 { font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-box p { font-size: 0.82rem; color: var(--text-muted); }

.loading-box { padding: 44px; text-align: center; }
.spinner { width: 28px; height: 28px; border: 2.5px solid var(--gray-200); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.65s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 0.82rem; color: var(--text-muted); }

/* ============================================================
   DESKTOP OVERRIDE — wider screens
   ============================================================ */
@media (min-width: 900px) {
  .page-body { max-width: 860px; margin: 0 auto; }
  .act-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

  /* On desktop, bottom nav becomes slim left rail OR stays bottom — keep bottom */
  .bottom-nav { /* stays bottom on all screen sizes */ }
}

@media (min-width: 640px) {
  .dash-hero-stats { grid-template-columns: repeat(4,1fr); gap: 10px; }
  .contacts-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 400px) {
  .books-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-year { display: none; }
}

/* ============================================================
   v4 ADDITIONS
   ============================================================ */

/* Class label blocks for CP / Activities */
.cp-class-block, .act-class-block {
  margin-bottom: 20px;
}

.cp-class-label, .act-class-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--brand);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 14px 5px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: 0.2px;
}

.cp-class-block .cp-group { margin-bottom: 12px; }
.cp-class-block .cp-group:last-child { margin-bottom: 0; }

/* Book active state */
.book-card--active {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.20), var(--sh-md) !important;
}

/* ── TIMETABLE SCROLL HINT (mobile only) ── */
.tt-scroll-hint {
  display: none;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

@media (max-width: 700px) {
  .tt-scroll-hint { display: block; }
}

/* ============================================================
   ROUTINE — GRADE CATEGORY IMAGE VIEW
   ============================================================ */

/* View type toggle */
.routine-view-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.rvt-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  box-shadow: var(--sh-xs);
}

.rvt-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
  transition: stroke 0.2s;
}

.rvt-btn:hover {
  border-color: var(--blue-300);
  color: var(--brand);
  background: var(--blue-50);
}

.rvt-btn.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37,99,235,0.30);
}

.rvt-btn.active svg { stroke: #fff; }

/* Grade category grid */
.grade-cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

@media (min-width: 600px) {
  .grade-cat-grid { grid-template-columns: repeat(4, 1fr); }
}

.grade-cat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s var(--ease);
  box-shadow: var(--sh-xs);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.grade-cat-card:hover {
  border-color: var(--blue-300);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.grade-cat-card.active {
  border-color: var(--brand);
  background: var(--blue-50);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15), var(--sh-md);
}

.grade-cat-card.grade-cat-has-img::after {
  content: '';
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: #22c55e;
  border-radius: 50%;
  border: 1.5px solid white;
}

.grade-cat-icon {
  font-size: 2rem;
  line-height: 1;
}

.grade-cat-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.grade-cat-card.active .grade-cat-label { color: var(--brand); }

.grade-cat-sub {
  font-size: 0.70rem;
  color: var(--text-muted);
  font-weight: 500;
}

.grade-cat-badge {
  display: none; /* using ::after pseudo instead */
}

/* Routine image display area */
.routine-img-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--brand);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  gap: 12px;
}

.routine-img-label {
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  flex: 1;
  min-width: 0;
}

.routine-img-close {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.90);
  padding: 5px 12px;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.routine-img-close:hover { background: rgba(255,255,255,0.28); }

.routine-img-container {
  background: var(--surface);
  border: 1px solid var(--blue-200);
  border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.routine-img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.2s;
  max-height: 75vh;
  object-fit: contain;
  padding: 0;
}

.routine-img-tap-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.65);
  color: rgba(255,255,255,0.90);
  font-size: 0.71rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  animation: fadeHint 3s ease 1.5s forwards;
}

@keyframes fadeHint { to { opacity: 0; } }

.routine-img-container { position: relative; }

.routine-no-img {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}

.routine-no-img svg {
  width: 40px; height: 40px;
  opacity: 0.35;
}

.routine-no-img p {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-mid);
}

.routine-no-img span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── FULLSCREEN LIGHTBOX WITH ZOOM ── */
.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(3, 7, 18, 0.96);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.22s var(--ease);
  /* prevent body scroll */
  overflow: hidden;
}

.lb-overlay.open { opacity: 1; }

/* Top toolbar */
.lb-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  gap: 10px;
}

.lb-title {
  font-family: 'Sora', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.lb-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 8px;
  cursor: pointer;
  color: rgba(255,255,255,0.90);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.80rem;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

.lb-btn:hover  { background: rgba(255,255,255,0.22); }
.lb-btn:active { background: rgba(255,255,255,0.30); }

.lb-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  pointer-events: none;
}

.lb-zoom-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: rgba(255,255,255,0.70);
  min-width: 38px;
  text-align: center;
  letter-spacing: 0.3px;
}

.lb-divider {
  width: 1px; height: 20px;
  background: rgba(255,255,255,0.18);
  margin: 0 2px;
}

/* Image viewport — takes remaining height */
.lb-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;     /* handle all touch ourselves */
  -webkit-user-select: none;
  user-select: none;
}

.lb-viewport.grabbing { cursor: grabbing; }
.lb-viewport.zoomed   { cursor: move; }

.lb-img-wrap {
  position: absolute;
  top: 50%; left: 50%;
  transform-origin: center center;
  /* JS controls transform */
  will-change: transform;
  line-height: 0;
}

.lb-image {
  display: block;
  max-width: 94vw;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Hint bar at bottom */
.lb-hint {
  text-align: center;
  padding: 6px 14px;
  font-size: 0.70rem;
  color: rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.40);
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

/* Double-tap ripple (visual feedback) */
.lb-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
  transform: scale(0);
  animation: lbRipple 0.4s ease-out forwards;
}

@keyframes lbRipple {
  to { transform: scale(3); opacity: 0; }
}

/* Keep old class name aliases so existing callers still work */
.routine-lightbox         { display: none !important; }
.routine-lb-backdrop      { display: none !important; }
.routine-lb-content       { display: none !important; }
.routine-lb-img           { display: none !important; }
.routine-lb-close         { display: none !important; }

/* ── SUBJECT CARD GRID (Course Plan & Activities) ── */
.subj-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 500px) {
  .subj-card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

.subj-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 18px 10px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s var(--ease);
  box-shadow: var(--sh-xs);
  -webkit-tap-highlight-color: transparent;
}

.subj-card:hover {
  border-color: var(--subj-color, var(--brand));
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.subj-card--active {
  border-color: var(--subj-color, var(--brand));
  background: color-mix(in srgb, var(--subj-color, var(--brand)) 8%, white);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--subj-color, var(--brand)) 20%, transparent), var(--sh-md);
}

/* Green dot for cards that have an image */
.subj-card--has::after {
  content: '';
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  background: #22c55e;
  border-radius: 50%;
  border: 1.5px solid white;
}

.subj-card-icon {
  font-size: 1.7rem;
  line-height: 1;
}

.subj-card-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.25;
}

.subj-card--active .subj-card-label {
  color: var(--subj-color, var(--brand));
}

.subj-card-dot { display: none; } /* using ::after instead */

/* Image display section */
.subj-img-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--brand);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  gap: 12px;
}

.subj-img-label {
  font-family: 'Sora', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  flex: 1;
  min-width: 0;
}

.subj-img-close {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.90);
  padding: 5px 12px;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.subj-img-close:hover { background: rgba(255,255,255,0.28); }

.subj-img-container {
  background: var(--surface);
  border: 1px solid var(--blue-200);
  border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* ── STAFF DIRECTORY — DEPT FILTER BUTTONS ── */
.dept-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.dept-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--sh-xs);
}

.dept-btn svg {
  width: 15px; height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  flex-shrink: 0;
  transition: stroke 0.18s;
}

.dept-btn:hover {
  border-color: var(--blue-300);
  color: var(--brand);
  background: var(--blue-50);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}

.dept-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,0.30);
}

.dept-btn.active svg { stroke: #fff; }

/* Count badge on active dept button */
.dept-btn-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.dept-btn:not(.active) .dept-btn-count {
  background: var(--blue-50);
  color: var(--brand);
}

.contacts-search-wrap {
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  .dept-btn { padding: 7px 12px; font-size: 0.78rem; gap: 5px; }
  .dept-btn svg { width: 13px; height: 13px; }
}

/* ── STUDENT PASSWORD GATE ── */
.student-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 20px;
}

.student-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--sh-md);
}

.student-gate-icon {
  width: 56px; height: 56px;
  background: var(--blue-50);
  border: 2px solid var(--blue-200);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.student-gate-icon svg {
  width: 26px; height: 26px;
  stroke: var(--brand);
  fill: none;
  stroke-width: 1.8;
}

.student-gate-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.student-gate-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.5;
}

.student-gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.student-gate-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.18s;
}

.student-gate-input:focus { border-color: var(--brand); background: var(--surface); }

.student-gate-error {
  font-size: 0.80rem;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--r-sm);
  padding: 7px 12px;
}

.student-gate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s;
  box-shadow: 0 4px 14px rgba(37,99,235,0.30);
}

.student-gate-btn:hover { background: var(--brand-dark); }

/* ── STUDENT CARDS ── */
.student-card {
  border-top: 3px solid var(--brand) !important;
}

.student-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.student-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

.student-tag-class  { background: var(--blue-50);  color: var(--blue-800);  border: 1px solid var(--blue-200); }
.student-tag-bus    { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.student-tag-shift  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.student-tag-house  { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }

.student-parents {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.student-parent {
  font-size: 0.80rem;
  color: var(--text-mid);
  line-height: 1.4;
}

.parent-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Lock button */
.student-lock-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 18px auto 4px;
  padding: 9px 20px;
  background: var(--gray-100);
  color: var(--text-muted);
  border: 1.5px solid var(--border-mid);
  border-radius: 24px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}

.student-lock-btn:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

.contacts-search-wrap {
  margin-bottom: 12px;
}

.student-tag-stop {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* ════════════════════════════════════════════════════════════
   PORTAL LOGIN GATE (whole-app gate — shown until teacher signs in)
   ════════════════════════════════════════════════════════════ */
.portal-gate {
  position: fixed; inset: 0; z-index: 5000;
  background: linear-gradient(160deg, var(--brand-deeper) 0%, var(--brand) 55%, var(--accent) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(24px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.portal-gate-inner { width: 100%; max-width: 400px; }
.portal-gate-brand { text-align: center; margin-bottom: 22px; }
.portal-gate-logo { width: 56px; height: 56px; border-radius: 16px; background: #fff; padding: 6px; box-shadow: var(--sh-md); }
.portal-gate-name { font-family: 'Sora', sans-serif; font-size: 1.3rem; font-weight: 800; color: #fff; margin-top: 12px; }
.portal-gate-sub { font-size: .85rem; color: rgba(255,255,255,0.85); margin-top: 2px; }
.portal-gate-alt-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; padding: 12px 16px; min-height: 44px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.30);
  border-radius: 12px; color: #fff; text-decoration: none;
  font-size: .85rem; font-weight: 600;
}
.portal-gate-alt-link svg { width: 16px; height: 16px; stroke: #fff; }
.portal-gate-alt-link:hover { background: rgba(255,255,255,0.22); }

/* ── PERSISTENT PROFILE STRIP (visible on every tab once signed in) ── */
.portal-profile-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.pp-av {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand); color: #fff; font-weight: 800; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.pp-info { flex: 1; min-width: 0; }
.pp-name { font-family: 'Sora', sans-serif; font-size: .88rem; font-weight: 700; color: var(--text); }
.pp-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.pp-logout-btn {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: #fff; border: 1px solid var(--border-mid); color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pp-logout-btn:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

/* ── MY TIMETABLE TABLE ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.my-routine-table { width: 100%; border-collapse: collapse; font-size: .78rem; min-width: 420px; }
.my-routine-table th, .my-routine-table td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.my-routine-table th { color: var(--text-muted); font-weight: 700; font-size: .70rem; text-transform: uppercase; letter-spacing: .03em; }
.my-routine-empty { text-align: center; padding: 22px 10px; color: var(--text-muted); font-size: .83rem; }

/* ── MY PROFILE PAGE ── */
.profile-view-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.pv-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.pv-val { font-size: .85rem; color: var(--text); font-weight: 600; text-align: right; }

.mp-doc-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 9px; flex-wrap: wrap; }
.mp-doc-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.mp-doc-icon svg { width: 18px; height: 18px; stroke-width: 1.8; fill: none; stroke: currentColor; }
.mp-doc-icon.has { background: var(--blue-50); color: var(--brand); }
.mp-doc-icon.missing { background: var(--gray-100); color: var(--text-hint); }
.mp-doc-info { flex: 1; min-width: 0; }
.mp-doc-name { font-size: .84rem; font-weight: 700; color: var(--text); }
.mp-doc-status { font-size: .70rem; margin-top: 1px; }
.mp-doc-status.has { color: var(--brand); }
.mp-doc-status.missing { color: var(--text-hint); }
.mp-doc-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mp-doc-view { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; background: var(--blue-50); color: var(--brand); border: 1px solid var(--blue-200); text-decoration: none; }
button.mp-doc-view { cursor: pointer; padding: 0; font: inherit; }
.mp-doc-view svg { width: 14px; height: 14px; stroke: currentColor; fill: none; }
.mp-doc-upload-btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 9px; background: var(--brand); color: #fff; border: none; font-size: .74rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.mp-doc-upload-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }
.mp-doc-upload-btn.uploading { opacity: .6; pointer-events: none; }

/* ════════════════════════════════════════════════════════════
   EMBEDDED TEACHER PORTAL
   ════════════════════════════════════════════════════════════ */

/* Login card */
.tp-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 26px 22px;
  max-width: 380px;
  margin: 0 auto;
  box-shadow: var(--sh-sm);
}

.tp-login-icon {
  width: 52px; height: 52px;
  background: var(--blue-50);
  border: 2px solid var(--blue-200);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.tp-login-icon svg { width: 24px; height: 24px; stroke: var(--brand); fill: none; stroke-width: 1.8; }

.tp-login-sub {
  font-size: .82rem; color: var(--text-muted); text-align: center;
  margin-bottom: 18px; line-height: 1.5;
}

.tp-login-err {
  font-size: .80rem; color: #dc2626; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: var(--r-sm);
  padding: 8px 12px; margin-bottom: 12px; display: none;
}
.tp-login-err.show { display: block; }

.tp-f-label {
  font-size: .76rem; font-weight: 700; color: var(--text-muted);
  margin-bottom: 4px; display: block; text-transform: uppercase; letter-spacing: .5px;
}

.tp-f-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md); font-family: inherit; font-size: .9rem; color: var(--text);
  background: var(--bg); outline: none; transition: border-color .18s; margin-bottom: 12px;
  -webkit-appearance: none; appearance: none;
}
.tp-f-input:focus { border-color: var(--brand); background: #fff; }

.tp-btn-sign {
  width: 100%; padding: 12px; background: var(--brand); color: #fff; border: none;
  border-radius: var(--r-md); font-family: inherit; font-size: .92rem; font-weight: 700;
  cursor: pointer; transition: background .18s; display: flex; align-items: center;
  justify-content: center; gap: 8px; margin-top: 4px;
}
.tp-btn-sign:hover { background: var(--brand-dark); }

/* Profile banner */
.tp-role-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 20px; font-size: .68rem; font-weight: 700;
  background: var(--blue-50); color: var(--brand);
}
.tp-class-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tp-class-chip {
  background: var(--gray-100); border: 1px solid var(--border);
  color: var(--text-mid); padding: 2px 8px; border-radius: 5px;
  font-size: .68rem; font-weight: 600;
}

/* Stats */
.tp-stats-row { display: flex; gap: 8px; margin-bottom: 12px; }
.tp-stat-pill {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px; text-align: center; box-shadow: var(--sh-xs);
}
.tp-stat-num { font-family: 'Sora', sans-serif; font-size: 1.25rem; font-weight: 700; color: var(--brand); }
.tp-stat-lbl { font-size: .64rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-top: 1px; }

/* Student cards grid */
.tp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .tp-grid { grid-template-columns: 1fr; } }

.tp-card {
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--border);
  box-shadow: var(--sh-xs); overflow: hidden; display: flex; flex-direction: column;
}
.tp-card-top {
  padding: 11px 12px 8px; display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--border);
}
.tp-av {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-family: 'Sora', sans-serif; font-size: .80rem;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.tp-nm { font-size: .83rem; font-weight: 700; color: var(--text); line-height: 1.2; margin-bottom: 1px; }
.tp-cls { font-size: .68rem; color: var(--text-muted); }

.tp-body { padding: 8px 12px 6px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.tp-row { display: flex; align-items: flex-start; gap: 5px; font-size: .74rem; color: var(--text-mid); line-height: 1.4; }
.tp-row svg { width: 11px; height: 11px; stroke: var(--text-hint); fill: none; stroke-width: 2; flex-shrink: 0; margin-top: 2px; }
.tp-rv { flex: 1; min-width: 0; word-break: break-word; }

.tp-phones { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tp-call {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px;
  background: var(--blue-50); border: 1px solid var(--blue-200); border-radius: 6px;
  color: var(--brand); font-size: .70rem; font-weight: 700; text-decoration: none;
  transition: background .15s;
}
.tp-call:active { background: var(--blue-100); }
.tp-call svg { width: 10px; height: 10px; stroke: var(--brand); fill: none; stroke-width: 2.5; flex-shrink: 0; }

.tp-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.tp-tag { font-size: .63rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.tp-tag-bus   { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.tp-tag-shift { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.tp-tag-house { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.tp-tag-stop  { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tp-edit-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin: 6px 10px 10px; padding: 7px; background: var(--blue-50);
  border: 1.5px solid var(--blue-200); border-radius: var(--r-sm); color: var(--brand);
  font-family: inherit; font-size: .74rem; font-weight: 700; cursor: pointer; transition: all .15s;
}
.tp-edit-btn:hover { background: var(--blue-100); border-color: var(--brand); }
.tp-edit-btn svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2.2; }

/* ── EDIT MODAL ── */
.tp-modal-bg {
  position: fixed; inset: 0; z-index: 9000; background: rgba(15,23,42,.65);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.tp-modal-bg.open { opacity: 1; pointer-events: all; }
.tp-modal-sheet {
  background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 600px;
  max-height: 92vh; overflow-y: auto; transform: translateY(30px); transition: transform .22s;
}
.tp-modal-bg.open .tp-modal-sheet { transform: translateY(0); }
.tp-modal-head {
  background: var(--brand); padding: 14px 16px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 1;
}
.tp-modal-title { font-family: 'Sora', sans-serif; font-size: .93rem; font-weight: 700; color: #fff; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-modal-close {
  width: 30px; height: 30px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25);
  border-radius: 7px; color: #fff; cursor: pointer; font-size: .95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tp-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.tp-r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tp-r3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .tp-r2 { grid-template-columns: 1fr; } .tp-r3 { grid-template-columns: 1fr 1fr; } }
.tp-fg label { font-size: .70rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 3px; }
.tp-fg input, .tp-fg select {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border-mid); border-radius: var(--r-sm);
  font-family: inherit; font-size: .83rem; color: var(--text); background: var(--bg); outline: none;
  appearance: none; transition: border-color .15s;
}
.tp-fg select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; padding-right: 22px; cursor: pointer;
}
.tp-fg input:focus, .tp-fg select:focus { border-color: var(--brand); background: #fff; }
.tp-modal-footer {
  display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--surface);
}
.tp-btn-save {
  flex: 1; padding: 11px; background: var(--brand); color: #fff; border: none;
  border-radius: var(--r-md); font-family: inherit; font-size: .87rem; font-weight: 700;
  cursor: pointer; transition: background .15s; display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.tp-btn-save:hover { background: var(--brand-dark); }
.tp-btn-cancel {
  padding: 11px 16px; background: var(--surface); color: var(--text-muted);
  border: 1.5px solid var(--border-mid); border-radius: var(--r-md);
  font-family: inherit; font-size: .83rem; font-weight: 600; cursor: pointer;
}

/* ── GLOBAL TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--botnav-h, 64px) + var(--botnav-safe, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: .82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc2626; }

/* The window that hides the images outside the frame */
.slider-container {
  max-width: 380px;
  margin: 5px auto;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* The long conveyor belt holding all images */
.slider-track {
  display: flex;
  width: 400%; /* 4 slides * 100% = 400% */
  animation: continuousLoop 12s infinite ease-in-out;
}

/* Each individual slide takes up exactly 1/4th of the track */
.slide {
  width: 25%; 
}

.slide img {
  width: 100%;
  display: block;
}

/* ANIMATION TIMING BREAKDOWN (Total 12 seconds):
  0% to 25%    = Show Image 1
  30% to 55%   = Slide to and Show Image 2
  60% to 85%   = Slide to and Show Image 3
  90% to 99.9% = Slide to Image 1 Clone
  100%         = Jump instantly back to 0% (invisible to user)
*/
@keyframes continuousLoop {
  0%, 25% {
    transform: translateX(0);
  }
  30%, 55% {
    transform: translateX(-25%); /* Move to slide 2 */
  }
  60%, 85% {
    transform: translateX(-50%); /* Move to slide 3 */
  }
  90%, 99.9% {
    transform: translateX(-75%); /* Move to clone slide */
  }
  100% {
    transform: translateX(0);    /* Instant snap back to start */
  }
}

/* Optional: Pause the slider when a user hovers over it */
.slider-container:hover .slider-track {
  animation-play-state: paused;
}

/* ── QUESTION PAPERS ── */
.qp-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 13px 16px; margin-bottom: 16px; min-height: 44px;
  background: var(--brand); color: #fff; border: none; border-radius: var(--r-lg);
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: .88rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,.28);
}
.qp-new-btn svg { width: 17px; height: 17px; }

.qp-list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; margin-bottom: 9px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-xs); cursor: pointer;
}
.qp-list-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--blue-50); color: var(--brand); }
.qp-list-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.qp-list-info { flex: 1; min-width: 0; }
.qp-list-title { font-size: .87rem; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qp-list-meta { font-size: .74rem; color: var(--text-muted); margin-top: 1px; }
.qp-status-pill { font-size: .66rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; flex-shrink: 0; white-space: nowrap; }
.qp-status-pill.draft { background: var(--gray-100); color: var(--text-muted); }
.qp-status-pill.locked { background: #fef3c7; color: #b45309; }
html[data-theme="dark"] .qp-status-pill.locked { background: #3a2c0f; color: #f5b854; }
.qp-status-pill.unlocked { background: #dbeafe; color: #1d4ed8; }
html[data-theme="dark"] .qp-status-pill.unlocked { background: #172554; color: #93c5fd; }
.tp-remember { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-muted); margin: 10px 0 4px; cursor: pointer; }
.tp-remember input { width: 16px; height: 16px; accent-color: var(--brand); }
.pw-banner { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fef3c7; color: #92400e; font-size: .76rem; border-bottom: 1px solid #fde68a; }
.pw-banner span { flex: 1; }
.pw-banner button { border: 0; background: #b45309; color: #fff; border-radius: 6px; padding: 4px 10px; font-size: .74rem; font-weight: 600; cursor: pointer; }
.pw-banner .pw-banner-x { background: transparent; color: #92400e; font-size: 1.1rem; padding: 0 4px; }
html[data-theme="dark"] .pw-banner { background: #3a2c0f; color: #f5b854; border-color: #5b4513; }
.pw-msg { display: none; font-size: .78rem; margin: 8px 0 2px; padding: 8px 10px; border-radius: 8px; }
.pw-msg.err { display: block; background: #fef2f2; color: #dc2626; }
.pw-msg.ok  { display: block; background: #ecfdf5; color: #047857; }

.qp-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.qp-back-btn {
  display: flex; align-items: center; gap: 5px; padding: 9px 13px; min-height: 40px;
  background: var(--surface); border: 1px solid var(--border-mid); border-radius: var(--r-md);
  color: var(--text-mid); font-family: 'Plus Jakarta Sans', sans-serif; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.qp-back-btn svg { width: 15px; height: 15px; }
.qp-editor-title { font-family: 'Sora', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--text); }

.qp-field-row { display: flex; gap: 10px; }
.qp-field-row .qp-field { flex: 1; min-width: 0; }
.qp-field { margin-bottom: 13px; }
.qp-field label { display: block; font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.qp-field .f-sel, .qp-field .f-inp { width: 100%; min-height: 44px; font-size: .9rem; }

.qp-quill { background: var(--surface); border-radius: var(--r-md); }
.qp-quill .ql-toolbar { border-radius: var(--r-md) var(--r-md) 0 0; border-color: var(--border-mid); flex-wrap: wrap; }
.qp-quill .ql-container { border-radius: 0 0 var(--r-md) var(--r-md); border-color: var(--border-mid); min-height: 220px; font-size: .95rem; }
.qp-quill .ql-editor { min-height: 220px; }
html[data-theme="dark"] .qp-quill .ql-toolbar { background: var(--surface); }
html[data-theme="dark"] .qp-quill .ql-toolbar .ql-stroke { stroke: var(--text-mid); }
html[data-theme="dark"] .qp-quill .ql-toolbar .ql-fill { fill: var(--text-mid); }
html[data-theme="dark"] .qp-quill .ql-toolbar .ql-picker { color: var(--text-mid); }
html[data-theme="dark"] .qp-quill .ql-container { color: var(--text); }

.qp-editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.qp-editor-actions button { min-height: 44px; }
.qp-btn-secondary {
  display: flex; align-items: center; gap: 7px; padding: 11px 18px;
  background: var(--surface); border: 1px solid var(--border-mid); border-radius: var(--r-md);
  color: var(--text-mid); font-family: 'Plus Jakarta Sans', sans-serif; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.qp-btn-secondary svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.qp-btn-lock {
  display: flex; align-items: center; gap: 7px; padding: 11px 18px;
  background: #fef3c7; border: 1px solid #fde68a; border-radius: var(--r-md);
  color: #92400e; font-family: 'Plus Jakarta Sans', sans-serif; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.qp-btn-lock svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.qp-btn-danger {
  display: flex; align-items: center; gap: 7px; padding: 11px 18px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--r-md);
  color: #dc2626; font-family: 'Plus Jakarta Sans', sans-serif; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.qp-btn-danger svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }

.qp-lock-banner {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px; margin-bottom: 14px;
  background: #fef3c7; border: 1px solid #fde68a; border-radius: var(--r-md);
  color: #92400e; font-size: .82rem; font-weight: 600;
}
.qp-lock-banner svg { width: 16px; height: 16px; stroke: currentColor; fill: none; flex-shrink: 0; }
html[data-theme="dark"] .qp-lock-banner { background: #3a2c0f; color: #f5b854; border-color: #4a3717; }

.qp-paper-card { background: #fff; border-radius: var(--r-lg); padding: 18px 16px; box-shadow: var(--sh-md); overflow-x: auto; }

@media print {
  body * { visibility: hidden; }
  #qpPreviewWrap, #qpPreviewWrap * { visibility: visible; }
  #qpPreviewWrap { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
}

/* ── GLOBAL MOBILE POLISH ──────────────────────────────────────
   16px input font-size stops iOS Safari from auto-zooming on focus;
   min-height keeps every tappable control at (or near) the 44px
   touch-target guideline on phones. */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px !important; }
  .f-sel, .f-inp, .tp-f-input, .tp-fg input, .tp-fg select { min-height: 42px; }
  .tp-btn-sign, .tp-btn-save, .nav-tab { min-height: 44px; }
  .mp-doc-upload-btn, .mp-doc-view { min-height: 36px; }
}

/* ── Routine / Course Plan dropdowns ── */
.rc-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.rc-field label { font-size: .70rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.rc-field .f-sel { width: 100%; flex: none; min-height: 44px; font-size: .9rem; }
