/* ============================================================
   Winter 2026–27 Course Planner — styles
   ============================================================ */

:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #fbfbfe;
  --ink: #1e2233;
  --ink-soft: #5b6478;
  --ink-faint: #5d6577;
  --border: #e7e9f2;
  --border-strong: #d6d9e8;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --violet: #8b5cf6;
  --accent: #f59e0b;

  --theory: #4f46e5;
  --lab: #0f766e;
  --indigo: #4f46e5;
  --teal: #0d9488;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b45309;
  --danger-soft: #fffbeb;

  --shadow-sm: 0 1px 2px rgba(24, 28, 45, .06);
  --shadow: 0 6px 20px rgba(30, 35, 60, .09);
  --shadow-lg: 0 16px 40px rgba(30, 35, 60, .14);
  --radius: 16px;
  --radius-sm: 12px;
}

/* Stable classes let the timetable use dynamic subject colors without inline styles. */
.color-0 { --c: #4f46e5; }
.color-1 { --c: #0ea5e9; }
.color-2 { --c: #0d9488; }
.color-3 { --c: #f59e0b; }
.color-4 { --c: #2563eb; }
.color-5 { --c: #8b5cf6; }
.color-6 { --c: #7c3aed; }
.color-7 { --c: #14b8a6; }
.color-8 { --c: #6366f1; }
.color-9 { --c: #f97316; }
.color-10 { --c: #22c55e; }
.color-11 { --c: #06b6d4; }
.color-12 { --c: #a855f7; }
.color-13 { --c: #84cc16; }
.color-14 { --c: #0f766e; }
.color-15 { --c: #3b82f6; }

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-name {
  font-family: 'Outfit', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--ink-faint); }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--ink-faint); }

.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav-tab {
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-soft);
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .18s ease;
}
.nav-tab:hover { background: var(--surface-2); color: var(--ink); }
.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .15);
}

.header-right { margin-left: auto; }
.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: all .3s ease;
}
.credit-pill:not(.show) { display: none; }
.pill-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .4); }
  50% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0); }
}

/* ---------------- Views ---------------- */
.view { display: none; }
.view.active { display: block; }

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 45%, #7c3aed 100%);
  color: #fff;
  padding: 64px 0 76px;
}
.hero-glow {
  position: absolute;
  top: -160px; right: -120px;
  width: 460px; height: 460px;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 65%);
  pointer-events: none;
}
.hero-content { position: relative; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.hero-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .25);
  margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(30px, 4.2vw, 46px);
  font-weight: 800;
  line-height: 1.12;
  margin-bottom: 16px;
}
.hero h1 .h1-sub {
  display: block;
  margin-top: 8px;
  font-size: clamp(17px, 2.2vw, 24px);
  font-weight: 600;
  color: rgba(255, 255, 255, .9);
}
.hero p {
  max-width: 620px;
  font-size: 16px;
  color: rgba(255, 255, 255, .82);
}
.hero-stats { display: flex; gap: 14px; margin-top: 30px; flex-wrap: wrap; }
.hero-stat {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  padding: 14px 22px;
  min-width: 118px;
  backdrop-filter: blur(6px);
}
.hero-stat b { display: block; font-family: 'Outfit', sans-serif; font-size: 22px; font-weight: 700; }
.hero-stat span { font-size: 12.5px; color: rgba(255, 255, 255, .75); }

/* ---------------- Filter bar ---------------- */
.filter-bar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin: -38px 0 26px;
  position: relative;
  z-index: 5;
}
.search-box {
  flex: 1;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  color: var(--ink-faint);
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-faint); }

.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip-label { font-size: 12.5px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.cat-chip, .branch-chip, .type-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .16s ease;
  box-shadow: var(--shadow-sm);
}
.cat-chip:hover, .branch-chip:hover, .type-chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.cat-chip.active, .branch-chip.active, .type-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(79, 70, 229, .3);
}

/* ---------------- Course cards ---------------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  padding-bottom: 40px;
  align-items: start;
  min-height: 420px;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
  align-self: start;
  width: 100%;
  min-width: 0;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.code-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.code-chip {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: 8px;
  padding: 4px 10px;
  letter-spacing: .03em;
}
.cat-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cat-PE { background: #fef3c7; color: #b45309; }
.cat-PC { background: #e0e7ff; color: #3730a3; }
.cat-FE { background: #d1fae5; color: #047857; }
.cat-UC { background: #d1fae5; color: #047857; }
.cat-UE { background: #ede9fe; color: #6d28d9; }

.card-head h3 { font-size: 18px; font-weight: 700; line-height: 1.3; }
.credit-block {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.credit-block .ltp { font-size: 12px; color: var(--ink-faint); }
.credit-block b { font-size: 16px; color: var(--ink); }

.meta-row { margin: 10px 0 14px; }
.type-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
}

.branch-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 8px;
  padding: 4px 9px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.branch-MECH   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.branch-ECE    { background: #ccfbf1; color: #115e59; border-color: #99f6e4; }
.branch-CSE    { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.branch-MIS    { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.branch-MIC    { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.branch-Common { background: #e2e8f0; color: #334155; border-color: #cbd5e1; }
/* a course that sits on a second branch list shows that group as an outline
   chip, so the primary branch stays the one that colours the card */
.branch-badge.is-alt { background: rgba(255, 255, 255, .62); border-style: dashed; }

.sections { display: flex; flex-direction: column; gap: 8px; }
.sections.expanded {
  max-height: 520px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.section-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 4px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: 10px;
  background: var(--surface-2);
  transition: all .18s ease;
  flex-wrap: nowrap;
}
.section-row:hover { border-color: color-mix(in srgb, var(--c) 40%, var(--border)); background: #fff; }
.section-row.selected {
  background: color-mix(in srgb, var(--c) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--c) 14%, transparent);
}
.slot-code {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--c);
  min-width: 76px;
  flex-shrink: 0;
  /* three-token slots such as A1+TA1+TAA1 must stay on one line */
  white-space: nowrap;
}
.slot-type {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.4;
  border-radius: 5px;
  padding: 2px 6px;
  color: #fff;
  background: var(--theory);
  flex-shrink: 0;
}
.slot-type.lab { background: var(--lab); }
.venue {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prof {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 500;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-days {
  font-size: 11px;
  color: var(--ink-faint);
  flex-shrink: 0;
  font-weight: 500;
  text-align: right;
}
.btn-select {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-select:hover { border-color: var(--primary); color: var(--primary); }
.btn-select.on {
  /* the accent palette is bright, so white label text on the raw colour lands
     around 2–4:1; deepening the fill keeps every hue above 4.5:1 */
  background: color-mix(in srgb, var(--c, var(--primary)) 57%, #0b1020);
  border-color: color-mix(in srgb, var(--c, var(--primary)) 57%, #0b1020);
  color: #fff;
  box-shadow: 0 5px 12px color-mix(in srgb, var(--c, var(--primary)) 30%, transparent);
}

.btn-more {
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--c);
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  min-height: 32px;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 2px;
  cursor: pointer;
}
.btn-more:hover { text-decoration: underline; }

.btn-register {
  margin-top: 10px;
  border: 1.5px dashed color-mix(in srgb, var(--c) 45%, var(--border-strong));
  background: transparent;
  color: var(--c);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px;
  border-radius: 11px;
  cursor: pointer;
  transition: all .16s ease;
}
.btn-register:hover { background: color-mix(in srgb, var(--c) 8%, transparent); }

.empty-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-faint);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* ---------------- Timetable ---------------- */
.tt-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin: 34px 0 18px;
}
.tt-header h2 { font-size: 26px; font-weight: 800; }
.tt-header p { font-size: 14px; margin-top: 4px; }
.tt-toolbar { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-ghost {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: all .16s ease;
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn-danger {
  border: 1px solid #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: all .16s ease;
}
.btn-danger:hover { background: #fee2e2; }
.btn-primary {
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
  transition: transform .16s ease;
}
.btn-primary:hover { transform: translateY(-2px); }

.tt-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tt-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 22px;
  box-shadow: var(--shadow-sm);
  min-width: 96px;
  text-align: center;
}
.tt-stat b { display: block; font-family: 'Outfit', sans-serif; font-size: 21px; font-weight: 700; color: var(--primary); }
.tt-stat span { font-size: 12px; color: var(--ink-faint); }

.tt-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.legend-title { font-size: 13px; font-weight: 600; color: var(--ink-faint); }
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px 5px 8px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.legend-swatch {
  width: 12px; height: 12px;
  border-radius: 4px;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
}
.legend-sec { color: var(--ink-faint); font-weight: 500; }

/* grid */
.tt-grid { margin-bottom: 48px; }
/* ---------------- Official slot-matrix timetable ---------------- */
#view-timetable .container { max-width: 1600px; }
.matrix-empty-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px 14px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
}
.matrix-empty-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}
.matrix-scroll-note {
  display: none;
  margin: 0 2px 8px;
  color: var(--ink-faint);
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
}
.schedule-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #cfd6e3;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd1df transparent;
}
.schedule-table {
  width: max-content;
  min-width: 1484px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: #253047;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px;
}
.schedule-table th,
.schedule-table td {
  border-right: 1px solid #a9c7d7;
  border-bottom: 1px solid #a9c7d7;
  text-align: center;
  vertical-align: middle;
}
.schedule-table tr:last-child > * { border-bottom: 0; }
.schedule-table tr > *:last-child { border-right: 0; }
.matrix-band,
.matrix-day {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 66px;
  min-width: 66px;
  max-width: 66px;
}
.matrix-label,
.matrix-kind {
  position: sticky;
  left: 66px;
  z-index: 3;
  width: 66px;
  min-width: 66px;
  max-width: 66px;
}
.matrix-band {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #354159;
}
.theory-band { background: #e5e2fb; }
.lab-band { background: #cde9f8; }
.matrix-label {
  height: 25px;
  padding: 4px 6px;
  background: #edf0f4;
  color: #556075;
  font-weight: 700;
}
.matrix-time {
  width: 64px;
  min-width: 64px;
  height: 25px;
  padding: 4px 2px;
  color: #43506a;
  font-size: 10.5px;
  font-weight: 600;
  background: #dcd9f5;
}
thead tr:nth-child(3) .matrix-time,
thead tr:nth-child(4) .matrix-time { background: #bfe0f4; }
.matrix-time.is-lunch { background: #e4e6ea !important; color: #4f5866; }
.matrix-day {
  padding: 8px 4px;
  background: #f0f2f5;
  color: #47526a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.matrix-kind {
  padding: 8px 4px;
  background: #f5f6f8;
  color: #47526a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
}
.matrix-cell {
  width: 64px;
  min-width: 64px;
  height: 52px;
  padding: 3px;
  background: #fffbd0;
  color: #566075;
  overflow: hidden;
}
.matrix-cell.is-gap {
  color: #a2a8b4;
  background: #fffde3;
}
.matrix-cell.is-lunch {
  color: #5c667a;
  background: #e7e9ed;
  font-size: 10px;
  font-weight: 700;
}
.matrix-slot {
  display: block;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
}
.matrix-cell.is-selected {
  position: relative;
  background: color-mix(in srgb, var(--c) 22%, #f4ffd6);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent);
  color: var(--ink);
}
.matrix-cell.is-selected .matrix-slot { color: var(--c); }
.matrix-course {
  display: block;
  min-width: 0;
  margin-top: 2px;
  line-height: 1.05;
}
.matrix-course b,
.matrix-course small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.matrix-course b { font-size: 9.5px; color: #172038; }
.matrix-course small { margin-top: 2px; font-size: 8.5px; color: #545e73; }
.matrix-cell.has-overlap {
  box-shadow: inset 0 0 0 2px var(--warn);
  background: var(--warn-soft);
}

/* ---------------- Footer ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 0;
  margin-top: 20px;
}
.site-footer p {
  font-size: 12.5px;
  color: var(--ink-faint);
  max-width: 900px;
}
.site-footer code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}

/* ---------------- Toasts ---------------- */
.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #10b981;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
}
.toast.show { transform: translateX(0); }
.toast-error { border-left-color: var(--warn); background: var(--warn-soft); }
.toast-info { border-left-color: var(--primary); }
.toast-icon { font-weight: 700; }
.toast-success .toast-icon { color: #10b981; }
.toast-error .toast-icon { color: var(--warn); }
.toast-info .toast-icon { color: var(--primary); }

/* ---------------- Header clear button ---------------- */
.header-right { display: flex; align-items: center; gap: 10px; }
.hdr-clear {
  display: none;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .16s ease;
}
.hdr-clear.show { display: inline-flex; }
.hdr-clear:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }

/* ---------------- My selections / Clear all panel ---------------- */
.sel-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.sel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.sel-title-wrap { display: flex; align-items: center; gap: 12px; }
.sel-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.sel-panel h3 { font-family: 'Outfit', sans-serif; font-size: 17px; font-weight: 700; }
.sel-panel .muted { font-size: 13px; margin-top: 2px; }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost.sm { padding: 8px 13px; font-size: 13px; }
.btn-ghost:disabled, .btn-clear-all:disabled {
  opacity: .45; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn-ghost:disabled:hover { border-color: var(--border-strong); color: var(--ink-soft); }
.btn-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, border-color .16s ease, color .16s ease;
}
.btn-clear-all:not(:disabled):hover { transform: translateY(-1px); border-color: var(--primary); color: var(--primary); }
.btn-clear-all:disabled { background: #f3f4f6; color: #9ca3af; }

.sel-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.sel-panel.empty .sel-list { display: none; }

/* clash banner */
.clash-banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: color-mix(in srgb, var(--warn) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-left: 4px solid var(--warn);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 4px;
}
.clash-banner-icon {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--warn);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.clash-banner-text { flex: 1; min-width: 0; }
.clash-banner-text b {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 4px;
}
.clash-detail {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .6);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
}
.sel-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--c);
  border-radius: 12px;
  padding: 10px 10px 10px 12px;
  background: color-mix(in srgb, var(--c) 5%, #fff);
  transition: box-shadow .16s ease;
}
.sel-item:hover { box-shadow: var(--shadow-sm); }
.sel-item.conflict { border-color: color-mix(in srgb, var(--warn) 30%, transparent); border-left-color: var(--warn); }
.sel-swatch { display: none; }
.sel-text { flex: 1; min-width: 0; }
.sel-line1 { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13.5px; }
.sel-line1 b { font-family: 'Outfit', sans-serif; font-weight: 700; color: var(--ink); }
.sel-slot { font-weight: 600; color: var(--c); font-size: 12.5px; }
.sel-warn { font-size: 11.5px; font-weight: 700; color: var(--warn); }
.sel-line2 {
  font-size: 12px; color: var(--ink-faint); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sel-remove {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-faint);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all .14s ease;
}
.sel-remove:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); background: var(--primary-soft); }

/* ---------------- Confirm modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 120;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(20, 22, 40, .45);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .2s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.show { opacity: 1; }
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 26px 22px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(.97);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1);
}
.modal-backdrop.show .modal { transform: none; }
.modal-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.modal h3 { font-family: 'Outfit', sans-serif; font-size: 20px; font-weight: 700; }
.modal p { font-size: 14px; line-height: 1.55; margin: 8px 0 22px; }
.modal p b { color: var(--ink); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; justify-content: center; }
.btn-solid-danger {
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .16s ease;
}
.btn-solid-danger:hover { background: var(--primary-600); }

/* toast action */
.toast-msg { flex: 1; }
.toast-action {
  border: none;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.toast-action:hover { background: #e0e3ff; }

@media (max-width: 560px) {
  .hdr-clear span { display: none; }
  .sel-actions { width: 100%; }
  .btn-clear-all { flex: 1; justify-content: center; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .nav-tab { flex: 1; text-align: center; padding: 9px 6px; }
  .hero { padding: 48px 0 60px; }
  .course-grid { grid-template-columns: 1fr; }
  .section-row { flex-wrap: wrap; gap: 6px; }
  .slot-days { margin-left: 0; width: 100%; text-align: left; padding-right: 0; }
  .prof { width: 100%; }
  .tt-header { align-items: flex-start; }
  .matrix-scroll-note { display: block; }
}
@media (max-width: 560px) {
  .container { padding: 0 16px; }
  .hero-stats { gap: 8px; }
  .hero-stat { min-width: 0; flex: 1; padding: 12px 10px; }
}

/* ============================================================
   MOTION + GLASS LAYER
   Frosted surfaces, soft ambient colour and one consistent
   easing vocabulary. Loaded after the base design so it can
   refine existing components without rewriting them.
   ============================================================ */

:root {
  /* motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .16s;
  --t-med: .28s;
  --t-slow: .55s;

  /* glass */
  --glass-blur: 18px;
  --glass-tint: linear-gradient(150deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .58));
  --glass-stroke: rgba(255, 255, 255, .78);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, .82);
  --glass-shadow: 0 18px 44px -28px rgba(30, 35, 60, .55);
}

/* ---- ambient colour, so frosted surfaces have something to blur ---- */
body {
  background-image:
    radial-gradient(58rem 34rem at 6% -10%, rgba(99, 102, 241, .18), transparent 62%),
    radial-gradient(52rem 32rem at 98% 0%, rgba(139, 92, 246, .16), transparent 60%),
    radial-gradient(46rem 30rem at 84% 86%, rgba(13, 148, 136, .12), transparent 64%),
    radial-gradient(40rem 28rem at 10% 98%, rgba(245, 158, 11, .10), transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* ---- view switching ---- */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view.active { animation: viewIn var(--t-slow) var(--ease-out) both; }

/* ---- header ---------------------------------------------------- */
.site-header {
  background: rgba(255, 255, 255, .64);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  border-bottom: 1px solid var(--glass-stroke);
  transition: background var(--t-med) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-soft),
              border-color var(--t-med) var(--ease-soft);
}
.site-header.is-scrolled {
  background: rgba(255, 255, 255, .82);
  border-bottom-color: rgba(30, 35, 60, .07);
  box-shadow: 0 14px 36px -24px rgba(30, 35, 60, .5);
}
.brand-logo {
  transition: transform var(--t-slow) var(--ease-out),
              box-shadow var(--t-med) var(--ease-soft);
}
.brand:hover .brand-logo {
  transform: rotate(-7deg) scale(1.06);
  box-shadow: 0 10px 24px rgba(99, 102, 241, .45);
}

.nav-tab {
  transition: background-color var(--t-fast) var(--ease-soft),
              color var(--t-fast) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}
.nav-tab:hover { background: rgba(255, 255, 255, .72); box-shadow: var(--glass-highlight); }
.nav-tab.active {
  background: linear-gradient(150deg, rgba(79, 70, 229, .16), rgba(139, 92, 246, .10));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9),
              inset 0 0 0 1px rgba(79, 70, 229, .16),
              0 8px 18px -14px rgba(79, 70, 229, .9);
}
.credit-pill {
  background: rgba(79, 70, 229, .10);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8),
              0 8px 18px -14px rgba(79, 70, 229, .8);
}
.hdr-clear {
  background: rgba(255, 255, 255, .6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* ---- hero ------------------------------------------------------ */
.hero::after {
  content: '';
  position: absolute;
  left: -150px;
  bottom: -230px;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, .55), transparent 68%);
  pointer-events: none;
}
@keyframes heroGlow {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: .85; }
  to   { transform: translate3d(-64px, 44px, 0) scale(1.16); opacity: 1; }
}
.hero-glow { animation: heroGlow 16s var(--ease-soft) infinite alternate; }

.hero-badge {
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform var(--t-med) var(--ease-out),
              background var(--t-med) var(--ease-soft);
}
.hero-badge:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .2); }

.hero-stat {
  background: linear-gradient(150deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, .08));
  border-color: rgba(255, 255, 255, .3);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4),
              0 16px 30px -22px rgba(0, 0, 0, .8);
  transition: transform var(--t-med) var(--ease-out),
              background var(--t-med) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out);
}
.hero-stat:hover {
  transform: translateY(-3px);
  background: linear-gradient(150deg, rgba(255, 255, 255, .32), rgba(255, 255, 255, .12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5),
              0 22px 34px -20px rgba(0, 0, 0, .75);
}

/* ---- floating filter toolbar ---------------------------------- */
.filter-bar {
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--glass-stroke);
  border-radius: 22px;
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  transition: box-shadow var(--t-med) var(--ease-out),
              background var(--t-med) var(--ease-soft);
}
.filter-bar:hover {
  box-shadow: var(--glass-highlight), 0 24px 52px -28px rgba(30, 35, 60, .6);
}

.search-box {
  background: rgba(255, 255, 255, .78);
  border-color: rgba(255, 255, 255, .85);
  box-shadow: inset 0 1px 0 #fff, 0 10px 22px -18px rgba(30, 35, 60, .9);
  transition: background var(--t-med) var(--ease-soft),
              border-color var(--t-med) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out);
}
.search-box:focus-within {
  background: rgba(255, 255, 255, .94);
  border-color: rgba(79, 70, 229, .45);
  box-shadow: inset 0 1px 0 #fff,
              0 0 0 4px rgba(79, 70, 229, .12),
              0 12px 26px -20px rgba(49, 46, 129, .9);
}
.search-box svg {
  transition: color var(--t-med) var(--ease-soft), transform var(--t-med) var(--ease-out);
}
.search-box:focus-within svg { color: var(--primary); transform: scale(1.08); }

.cat-chip, .branch-chip, .type-chip {
  background: rgba(255, 255, 255, .62);
  border-color: rgba(255, 255, 255, .8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85),
              0 4px 10px -8px rgba(30, 35, 60, .6);
}
.cat-chip:hover, .branch-chip:hover, .type-chip:hover { background: rgba(255, 255, 255, .92); }
.cat-chip.active, .branch-chip.active, .type-chip.active {
  background: linear-gradient(140deg, #6366f1, #8b5cf6);
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35),
              0 10px 22px -12px rgba(99, 102, 241, .9);
}

/* ---- course + faculty cards ----------------------------------- */
.course-card {
  background-color: rgba(255, 255, 255, .55);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .58));
  border-color: rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: var(--glass-highlight),
              0 2px 4px rgba(24, 28, 45, .04),
              0 20px 40px -32px rgba(30, 35, 60, .9);
  transition: transform var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              border-color var(--t-med) var(--ease-soft),
              background-color var(--t-med) var(--ease-soft);
}
.course-card:hover {
  transform: translateY(-4px);
  background-color: rgba(255, 255, 255, .8);
  border-color: #fff;
  box-shadow: var(--glass-highlight),
              0 0 0 1px color-mix(in srgb, var(--c, var(--primary)) 20%, transparent),
              0 2px 4px rgba(24, 28, 45, .05),
              0 30px 58px -30px rgba(49, 46, 129, .55);
}


.section-row {
  background: rgba(255, 255, 255, .55);
  transition: transform var(--t-fast) var(--ease-out),
              background-color var(--t-fast) var(--ease-soft),
              border-color var(--t-fast) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out);
}
.section-row:hover { background: rgba(255, 255, 255, .92); transform: translateX(2px); }
.section-row.selected:hover { transform: translateX(0); }

.sel-item {
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .6));
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out);
}
.sel-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm), 0 10px 20px -16px color-mix(in srgb, var(--c) 70%, transparent);
}

/* ---- panels, stats, notes ------------------------------------- */
.sel-panel,
.tt-stat,
.legend-item,
.matrix-empty-note,
.empty-card {
  background-color: rgba(255, 255, 255, .46);
  background-image: var(--glass-tint);
  border-color: var(--glass-stroke);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: var(--glass-highlight), 0 18px 38px -30px rgba(30, 35, 60, .9);
}
.tt-stat {
  transition: transform var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out);
}
.tt-stat:hover { transform: translateY(-2px); box-shadow: var(--glass-highlight), var(--glass-shadow); }

/* ---- timetable surfaces --------------------------------------- */
.schedule-wrap {
  background: rgba(255, 255, 255, .82);
  border-color: var(--glass-stroke);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: var(--glass-highlight), 0 22px 48px -32px rgba(30, 35, 60, .8);
}
.matrix-cell {
  transition: background-color var(--t-fast) var(--ease-soft),
              box-shadow var(--t-fast) var(--ease-soft),
              color var(--t-fast) var(--ease-soft);
}

/* ---- toasts + modal ------------------------------------------- */
.toast {
  background: rgba(255, 255, 255, .84);
  border-color: rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  opacity: 0;
  transform: translateX(120%) scale(.98);
  transition: transform var(--t-med) var(--ease-out),
              opacity var(--t-med) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out);
}
.toast.show { transform: translateX(0) scale(1); opacity: 1; }
.toast-error { background: rgba(255, 251, 235, .86); }
.toast-success, .toast-info { background: rgba(255, 255, 255, .86); }

.modal-backdrop {
  background: rgba(20, 22, 40, .38);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
  transition: opacity var(--t-med) var(--ease-soft);
}
.modal {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(255, 255, 255, .75);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  box-shadow: var(--glass-highlight), 0 44px 84px -42px rgba(20, 22, 40, .75);
  transform: translateY(16px) scale(.96);
  transition: transform var(--t-med) var(--ease-out);
}
.modal-backdrop.show .modal { transform: none; }

/* ---- shared button motion ------------------------------------- */
.btn-select,
.btn-more,
.btn-register,
.btn-ghost,
.btn-danger,
.btn-primary,
.btn-clear-all,
.btn-solid-danger,
.hdr-clear,
.sel-remove,
.toast-action,
.cat-chip,
.branch-chip,
.type-chip,
.nav-tab {
  transition: background-color var(--t-fast) var(--ease-soft),
              color var(--t-fast) var(--ease-soft),
              border-color var(--t-fast) var(--ease-soft),
              box-shadow var(--t-med) var(--ease-out),
              transform var(--t-fast) var(--ease-out),
              opacity var(--t-fast) var(--ease-soft);
}
.btn-select:active,
.btn-register:active,
.btn-ghost:active,
.btn-danger:active,
.btn-primary:active,
.btn-clear-all:active,
.btn-solid-danger:active,
.hdr-clear:active,
.sel-remove:active,
.toast-action:active,
.cat-chip:active,
.branch-chip:active,
.type-chip:active,
.nav-tab:active {
  transform: translateY(0) scale(.97);
}

:where(button, input, a, [tabindex]):focus-visible {
  outline: 2px solid rgba(79, 70, 229, .6);
  outline-offset: 2px;
}

/* ---- graceful fallback when backdrop-filter is unavailable ---- */
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: rgba(255, 255, 255, .97); }
  .filter-bar,
  .course-card,
  .sel-panel,
  .tt-stat,
  .legend-item,
  .matrix-empty-note,
  .empty-card,
  .toast,
  .modal,
  .schedule-wrap {
    background: #fff;
    background-image: none;
  }
}

/* ---- respect reduced-motion preferences ----------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  body { background-image: none !important; }
  .site-header,
  .filter-bar,
  .course-card,
  .sel-panel,
  .modal,
  .toast {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

/* ---------------- Pick limits: 1 theory + 1 lab per course ---------------- */
.pick-rule {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--primary);
  background: rgba(79, 70, 229, .09);
  border: 1px solid rgba(79, 70, 229, .16);
  transition: background var(--t-fast) var(--ease-soft), color var(--t-fast) var(--ease-soft);
}
.btn-select.swap {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--c, var(--primary)) 45%, var(--border-strong));
  color: var(--c, var(--primary));
  background: rgba(255, 255, 255, .7);
}
.btn-select.swap:hover {
  background: color-mix(in srgb, var(--c, var(--primary)) 10%, #fff);
  border-color: var(--c, var(--primary));
}

/* ---------------- Utilities: skip link + screen-reader only ---------------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transition: top var(--t-med) var(--ease-out);
}
.skip-link:focus { top: 12px; }
/* dark mode lightens --primary for text use, so the skip link needs its own
   solid brand fill to keep white label text at 7.9:1 */
[data-theme="dark"] .skip-link { background: #4338ca; color: #fff; }

.noscript-note {
  padding: 14px 18px;
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* keep the search field visually identical across browsers */
.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* ---------------- Footer ---------------- */
/* ---------------- About + FAQ (static, indexable copy) ---------------- */
.about-block { padding-top: 46px; padding-bottom: 14px; }
.about-block h2 {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--ink);
}
.about-block p {
  max-width: 78ch;
  margin-bottom: 12px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}
.about-sub {
  margin: 26px 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.course-index {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 9px 26px;
}
.course-index li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.course-index code {
  flex: none;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}
.faq { display: grid; gap: 15px; max-width: 82ch; }
.faq-item dt { font-size: 14px; font-weight: 700; color: var(--ink); }
.faq-item dd { margin: 5px 0 0; font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); }

.site-footer {
  background-color: rgba(255, 255, 255, .62);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .94));
  border-top: 1px solid var(--glass-stroke);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  padding: 34px 0 0;
  margin-top: 28px;
}
.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 34px;
  padding-bottom: 26px;
}
.footer-brand .brand { margin-bottom: 12px; }
.footer-brand p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 46ch;
}
.footer-col h4 {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.footer-col li {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
/* ---- GitHub block (replaces the old Data column) ---- */
.footer-github { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.footer-gh-star {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease-soft), color var(--t-fast) var(--ease-soft), transform var(--t-fast) var(--ease-soft);
}
.footer-gh-star svg { color: #b45309; }
.footer-gh-star:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.footer-gh-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
.footer-gh-link svg { flex: none; opacity: .85; }
.footer-gh-link:hover { color: var(--primary); text-decoration: underline; }

.footer-col li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 55%, transparent);
}
.footer-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 16px;
  padding-bottom: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-faint);
}
.footer-dot { opacity: .5; }
.footer-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}
.footer-link:hover { text-decoration: underline; }

.footer-top {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 2px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--t-fast) var(--ease-soft);
}
.footer-top:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 26px; }
  .footer-top { margin-left: 0; }
}
@media (max-width: 560px) {
  .footer-inner { grid-template-columns: 1fr; gap: 22px; }
}

/* ---------------- Long-data guards (venue / faculty / title overflow) ---------------- */
.card-head > div:first-child { min-width: 0; }
.card-head h3 { overflow-wrap: anywhere; }
.credit-block { white-space: nowrap; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.meta-row .pick-rule { margin-left: 0; }
.sections.expanded { overflow-x: hidden; }
.section-row .venue,
.section-row .prof,
.sel-line2,
.matrix-course b,
.matrix-course small { overflow-wrap: anywhere; }
.course-card { min-width: 0; }
.sel-list { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }


/* ============================================================
   Dark theme
   Toggled from the header button, remembered in localStorage,
   defaulting to the OS preference. Everything below overrides a
   hard-coded light surface; the token block does the rest.
   ============================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1020;
  --surface: #141a2e;
  --surface-2: #1a2137;
  --ink: #e9edfb;
  --ink-soft: #b7c0d6;
  --ink-faint: #a4adc2;
  --border: #263049;
  --border-strong: #36425f;

  --primary: #a5b4fc;
  --primary-600: #c7d2fe;
  --primary-soft: #1e2547;
  --violet: #a78bfa;
  --accent: #fbbf24;

  --theory: #4338ca;
  --lab: #0f766e;
  --warn: #fbbf24;
  --warn-soft: #2c2210;
  --danger: #fca5a5;
  --danger-soft: #331b1b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);

  --glass-tint: linear-gradient(150deg, rgba(30, 38, 62, .95), rgba(18, 24, 42, .82));
  --glass-stroke: rgba(255, 255, 255, .09);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, .07);
  --glass-shadow: 0 18px 44px -28px rgba(0, 0, 0, .9);
}

/* ---- header, search, chips ---- */
[data-theme="dark"] .site-header { background: rgba(11, 16, 32, .86); border-bottom-color: var(--border); }
[data-theme="dark"] .site-header.is-scrolled { background: rgba(11, 16, 32, .95); }
[data-theme="dark"] .nav-tab:hover { background: rgba(255, 255, 255, .07); }
[data-theme="dark"] .nav-tab.active {
  background: var(--primary-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), inset 0 0 0 1px rgba(129, 140, 248, .35);
}
[data-theme="dark"] .hdr-clear,
[data-theme="dark"] .theme-toggle { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .12); }
[data-theme="dark"] .hdr-clear:hover,
[data-theme="dark"] .theme-toggle:hover { background: rgba(255, 255, 255, .12); color: var(--ink); }
[data-theme="dark"] .credit-pill { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 18px -14px rgba(0, 0, 0, .9); }
[data-theme="dark"] .search-box {
  background: rgba(20, 26, 46, .92);
  border-color: rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
[data-theme="dark"] .search-box:focus-within {
  background: rgba(26, 33, 55, .98);
  border-color: rgba(165, 180, 252, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 4px rgba(99, 102, 241, .3);
}
[data-theme="dark"] .cat-chip,
[data-theme="dark"] .branch-chip,
[data-theme="dark"] .type-chip {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  color: var(--ink-soft);
}
[data-theme="dark"] .cat-chip:hover,
[data-theme="dark"] .branch-chip:hover,
[data-theme="dark"] .type-chip:hover { background: rgba(255, 255, 255, .12); color: var(--ink); }
[data-theme="dark"] .cat-chip.active,
[data-theme="dark"] .branch-chip.active,
[data-theme="dark"] .type-chip.active { background: #4338ca; border-color: #4338ca; color: #fff; }

/* ---- cards, rows, panels ---- */
[data-theme="dark"] .course-card {
  background-color: rgba(20, 26, 46, .78);
  background-image: linear-gradient(160deg, rgba(32, 40, 66, .95), rgba(18, 24, 42, .85));
  border-color: rgba(255, 255, 255, .08);
}
[data-theme="dark"] .course-card:hover { background-color: rgba(26, 33, 55, .92); border-color: rgba(255, 255, 255, .16); }
[data-theme="dark"] .section-row { background: rgba(255, 255, 255, .045); border-color: rgba(255, 255, 255, .1); }
[data-theme="dark"] .section-row:hover { background: rgba(255, 255, 255, .085); border-color: rgba(255, 255, 255, .16); }
[data-theme="dark"] .sel-panel,
[data-theme="dark"] .tt-stat,
[data-theme="dark"] .legend-item,
[data-theme="dark"] .matrix-empty-note,
[data-theme="dark"] .empty-card { background-color: rgba(20, 26, 46, .72); border-color: rgba(255, 255, 255, .09); }
[data-theme="dark"] .sel-item { background: color-mix(in srgb, var(--c) 16%, #141a2e); }
[data-theme="dark"] .clash-detail { background: rgba(255, 255, 255, .06); }
[data-theme="dark"] .btn-clear-all:disabled { background: #1c2334; color: #7b8499; }
[data-theme="dark"] .btn-danger { border-color: #5b2a2a; }
[data-theme="dark"] .btn-danger:hover { background: #3a1d1d; }
[data-theme="dark"] .toast,
[data-theme="dark"] .toast-success,
[data-theme="dark"] .toast-info { background: rgba(20, 26, 46, .97); border-color: rgba(255, 255, 255, .1); }
[data-theme="dark"] .modal { background: rgba(18, 24, 42, .98); border-color: rgba(255, 255, 255, .12); }
[data-theme="dark"] .toast-action:hover { background: rgba(129, 140, 248, .18); }
[data-theme="dark"] .sections.expanded { scrollbar-color: #3a4564 transparent; }

/* the per-card accent colour is mid-tone; lift it for dark surfaces */
[data-theme="dark"] .code-chip,
[data-theme="dark"] .slot-code,
[data-theme="dark"] .btn-more,
[data-theme="dark"] .btn-register,
[data-theme="dark"] .matrix-cell.is-selected .matrix-slot,
[data-theme="dark"] .fac-course { color: color-mix(in srgb, var(--c) 45%, #ffffff); }

/* ---- category + branch badges ---- */
[data-theme="dark"] .cat-PE { background: #3a2c12; color: #fcd34d; }
[data-theme="dark"] .cat-PC { background: #232a55; color: #c7d2fe; }
[data-theme="dark"] .cat-UC,
[data-theme="dark"] .cat-FE { background: #10322a; color: #6ee7b7; }
[data-theme="dark"] .cat-UE { background: #2b2150; color: #d8b4fe; }
[data-theme="dark"] .branch-MECH { background: #3a2c12; color: #fcd34d; border-color: #5a4318; }
[data-theme="dark"] .branch-ECE { background: #0e3330; color: #5eead4; border-color: #14504a; }
[data-theme="dark"] .branch-CSE { background: #2b2150; color: #d8b4fe; border-color: #3f3270; }
[data-theme="dark"] .branch-MIS { background: #232a55; color: #c7d2fe; border-color: #35407a; }
[data-theme="dark"] .branch-MIC { background: #0b2d40; color: #7dd3fc; border-color: #12506b; }
[data-theme="dark"] .branch-badge.is-alt { background: rgba(255, 255, 255, .04); }

/* ---- footer ---- */
[data-theme="dark"] .site-footer {
  background-color: rgba(17, 23, 41, .85);
  background-image: linear-gradient(180deg, rgba(23, 30, 52, .92), rgba(13, 18, 34, .98));
  border-top-color: #263049;
}
[data-theme="dark"] .footer-gh-star {
  border-color: #2f3a56;
  background: #161d33;
  color: #e9edfb;
}
[data-theme="dark"] .footer-gh-star svg { color: #fbbf24; }
[data-theme="dark"] .footer-gh-star:hover { border-color: #7c8bd6; color: #c7d2fe; }
[data-theme="dark"] .footer-gh-link { color: #a9b3cc; }
[data-theme="dark"] .footer-gh-link:hover { color: #c7d2fe; }
[data-theme="dark"] .branch-Common { background: #232a3b; color: #cbd5e1; border-color: #333d55; }

/* ---- timetable matrix ---- */
[data-theme="dark"] .schedule-wrap { background: #0f1526; border-color: #263049; }
[data-theme="dark"] .schedule-table th,
[data-theme="dark"] .schedule-table td { border-color: #2c3651; }
[data-theme="dark"] .matrix-band { color: #dfe5f7; }
[data-theme="dark"] .theory-band { background: #241f45; }
[data-theme="dark"] .lab-band { background: #10303c; }
[data-theme="dark"] .matrix-label { background: #1a2137; color: #b7c0d6; }
[data-theme="dark"] .matrix-time { background: #232a4a; color: #cbd3e8; }
[data-theme="dark"] thead tr:nth-child(3) .matrix-time,
[data-theme="dark"] thead tr:nth-child(4) .matrix-time { background: #16323f; color: #dbe6f5; }
[data-theme="dark"] .matrix-time.is-lunch { background: #202636 !important; color: #9aa3b8; }
[data-theme="dark"] .matrix-day { background: #1a2137; color: #cbd3e8; }
[data-theme="dark"] .matrix-kind { background: #171d31; color: #cbd3e8; }
[data-theme="dark"] .matrix-cell { background: #1b2333; color: #c9d2e6; }
[data-theme="dark"] .matrix-cell.is-gap { background: #151b2b; color: #7b8499; }
[data-theme="dark"] .matrix-cell.is-lunch { background: #1c2334; color: #9aa3b8; }
[data-theme="dark"] .matrix-cell.is-selected { background: color-mix(in srgb, var(--c) 26%, #16203a); }
[data-theme="dark"] .matrix-course b { color: #e9edfb; }
[data-theme="dark"] .matrix-course small { color: #a4adc2; }
[data-theme="dark"] .matrix-scroll-note,
[data-theme="dark"] .matrix-empty-note { color: var(--ink-soft); }

/* ---- fallback when backdrop-filter is unavailable ---- */
@supports not (backdrop-filter: blur(1px)) {
  [data-theme="dark"] .filter-bar,
  [data-theme="dark"] .course-card,
  [data-theme="dark"] .sel-panel,
  [data-theme="dark"] .tt-stat,
  [data-theme="dark"] .legend-item,
  [data-theme="dark"] .matrix-empty-note,
  [data-theme="dark"] .empty-card,
  [data-theme="dark"] .toast,
  [data-theme="dark"] .modal,
  [data-theme="dark"] .schedule-wrap { background: #141a2e; }
}


/* ---- the toggle button ---- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------------- PNG export ----------------
   html2canvas reads the screen stylesheet only, so the download used to keep the
   on-screen 64 px cells with ellipsised captions. While a capture is running the
   grid wears .is-exporting, which re-lays the table exactly like paper: one wide
   sheet, wrapped text, a border on every cell. */
.tt-grid.is-exporting {
  width: max-content;
  min-width: 0;
  max-width: none;
  padding: 16px;
  background: #fff;
}
.tt-grid.is-exporting .matrix-empty-note,
.tt-grid.is-exporting .matrix-scroll-note { display: none !important; }
.tt-grid.is-exporting .schedule-wrap {
  overflow: visible !important;
  max-height: none !important;
  border: 0 !important;
  box-shadow: none !important;
  background: #fff !important;
}
.tt-grid.is-exporting .schedule-table {
  width: 1240px !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  background: #fff !important;
}
.tt-grid.is-exporting .schedule-table th,
.tt-grid.is-exporting .schedule-table td {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  position: static !important;
  box-shadow: none !important;
  border: 1px solid #98a2b3 !important;
  padding: 5px 3px !important;
  vertical-align: top !important;
  white-space: normal !important;
  overflow: visible !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  background-color: #fff !important;
  background-image: none !important;
  color: #111 !important;
}
.tt-grid.is-exporting .schedule-table th:first-child { width: 10% !important; }
.tt-grid.is-exporting .schedule-table th:nth-child(2) { width: 9% !important; }
.tt-grid.is-exporting .matrix-band,
.tt-grid.is-exporting .matrix-day,
.tt-grid.is-exporting .matrix-kind,
.tt-grid.is-exporting .matrix-label,
.tt-grid.is-exporting .matrix-time {
  background: #eef1f6 !important;
  color: #1a2233 !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
}
.tt-grid.is-exporting .theory-band { background: #e7e5fb !important; }
.tt-grid.is-exporting .lab-band { background: #dcecfb !important; }
.tt-grid.is-exporting .matrix-day { font-size: 13px !important; letter-spacing: .04em !important; }
.tt-grid.is-exporting .matrix-cell {
  height: auto !important;
  min-height: 46px;
  background: #fff !important;
  color: #111 !important;
  font-size: 11px !important;
}
.tt-grid.is-exporting .matrix-cell.is-gap { background: #fafbfc !important; color: #9aa2b1 !important; }
.tt-grid.is-exporting .matrix-cell.is-lunch { background: #eef0f3 !important; color: #3d4760 !important; }
.tt-grid.is-exporting .matrix-cell.is-selected {
  background: #e9efff !important;
  border: 2px solid #46536b !important;
}
.tt-grid.is-exporting .matrix-cell.has-overlap {
  background: #fff4d6 !important;
  border: 2px solid #8a5a00 !important;
}
.tt-grid.is-exporting .matrix-slot { font-size: 11px !important; font-weight: 700 !important; color: #1a2233 !important; }
.tt-grid.is-exporting .matrix-cell.is-selected .matrix-slot { color: #1a2233 !important; }
.tt-grid.is-exporting .matrix-course b,
.tt-grid.is-exporting .matrix-course small {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
.tt-grid.is-exporting .matrix-course b { font-size: 11.5px !important; color: #172038 !important; }
.tt-grid.is-exporting .matrix-course small { font-size: 10px !important; color: #545e73 !important; }

/* ==================== PRINT STYLES ==================== */
/* One sheet of paper: a title line, the sections that were picked, then the
   matrix. Portrait A4 on purpose — print dialogs disagree about landscape and
   some rotate the page instead of resizing it, which is how a timetable ends up
   sideways with clipped cells. Everything here beats the theme rules, so a
   print from dark mode gives the same white sheet. */
.print-head { display: none; }

@page { size: A4 portrait; margin: 10mm 8mm; }

@media print {
  html, body { background: #fff !important; color: #111 !important; }
  body { margin: 0 !important; }

  /* only the timetable sheet goes on paper, whichever tab is open */
  .site-header, .hero, .nav, .filter-bar, .sel-panel, .site-footer, .about-block,
  .skip-link, .noscript-note, .toasts, .modal-backdrop, .theme-toggle,
  .tt-header, .tt-stats, .matrix-empty-note, .matrix-scroll-note { display: none !important; }
  #view-courses { display: none !important; }
  #view-timetable { display: block !important; }
  .container { max-width: none !important; margin: 0 !important; padding: 0 !important; }

  /* the sheet header the screen never shows */
  .print-head { display: block !important; margin: 0 0 7px; }
  .print-head h2 { margin: 0; font-size: 13pt; font-weight: 800; color: #111 !important; }
  .print-head p { margin: 2px 0 0; font-size: 8pt; color: #555 !important; }

  /* the picked sections, as one compact line */
  .tt-legend {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px 12px;
    margin: 8px 0;
    font-size: 7.5pt;
    color: #111 !important;
  }
  .legend-title { font-weight: 700; color: #111 !important; }
  .legend-item { display: inline-flex; align-items: center; gap: 4px; }
  .legend-swatch {
    width: 7px; height: 7px;
    border-radius: 2px;
    border: .5pt solid #444 !important;
    background: var(--c, #cfd6e4) !important;
  }
  .legend-sec { color: #444 !important; }

  .schedule-wrap {
    overflow: visible !important;
    max-height: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .schedule-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .schedule-table thead { display: table-header-group; }
  .schedule-table tr { break-inside: avoid; page-break-inside: avoid; }

  /* cells: every one bounded, wrapped, hairline-free borders */
  .schedule-table th,
  .schedule-table td {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    border: .5pt solid #98a2b3 !important;
    padding: 1.5px 1px !important;
    vertical-align: top !important;
    position: static !important;
    box-shadow: none !important;
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    color: #111 !important;
    background-color: #fff !important;
    background-image: none !important;
  }
  /* the label columns stay narrow, the periods share the rest of the width */
  .schedule-table th:first-child { width: 9% !important; }
  .schedule-table th:nth-child(2) { width: 8% !important; }

  .matrix-band, .matrix-day, .matrix-kind, .matrix-label, .matrix-time {
    background: #eef1f6 !important;
    color: #1a2233 !important;
    font-size: 6.5pt !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
  }
  .matrix-day { font-size: 7.5pt !important; letter-spacing: .04em !important; }
  .theory-band { background: #e7e5fb !important; }
  .lab-band { background: #dcecfb !important; }

  .matrix-cell {
    height: auto !important;
    min-height: 0 !important;
    font-size: 6.5pt !important;
    line-height: 1.15 !important;
    background: #fff !important;
  }
  .matrix-cell.is-gap { background: #fafbfc !important; color: #9aa2b1 !important; }
  .matrix-cell.is-lunch {
    background: #eef0f3 !important;
    color: #3d4760 !important;
    font-size: 6.5pt !important;
  }
  .matrix-cell.is-selected {
    background: #e9efff !important;
    border: 1pt solid #46536b !important;
  }
  .matrix-cell.is-selected .matrix-slot { color: #1a2233 !important; }
  .matrix-cell.has-overlap {
    background: #fff4d6 !important;
    border: 1pt solid #8a5a00 !important;
  }

  .matrix-slot {
    font-size: 6.5pt !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    color: #1a2233 !important;
  }
  .matrix-course { margin-top: 1px !important; line-height: 1.1 !important; }
  .matrix-course b,
  .matrix-course small {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  .matrix-course b { font-size: 6.5pt !important; color: #172038 !important; }
  .matrix-course small { font-size: 6pt !important; color: #545e73 !important; }

  /* The dark palette lives in plain class rules, so it still matches while
     printing — an id prefix outranks it and keeps the paper white. */
  #view-timetable .schedule-table th,
  #view-timetable .schedule-table td {
    background-color: #fff !important;
    color: #111 !important;
    border-color: #98a2b3 !important;
  }
  #view-timetable .matrix-band,
  #view-timetable .matrix-day,
  #view-timetable .matrix-kind,
  #view-timetable .matrix-label,
  #view-timetable .matrix-time { background: #eef1f6 !important; color: #1a2233 !important; }
  #view-timetable .theory-band { background: #e7e5fb !important; }
  #view-timetable .lab-band { background: #dcecfb !important; }
  #view-timetable .matrix-cell { background: #fff !important; }
  #view-timetable .matrix-cell.is-gap { background: #fafbfc !important; color: #9aa2b1 !important; }
  #view-timetable .matrix-cell.is-lunch { background: #eef0f3 !important; color: #3d4760 !important; }
  #view-timetable .matrix-cell.is-selected {
    background: #e9efff !important;
    border: 1pt solid #46536b !important;
  }
  #view-timetable .matrix-cell.has-overlap {
    background: #fff4d6 !important;
    border: 1pt solid #8a5a00 !important;
  }
  #view-timetable .matrix-slot { color: #1a2233 !important; }
  #view-timetable .matrix-course b { color: #172038 !important; }
  #view-timetable .matrix-course small { color: #545e73 !important; }
  #view-timetable .print-head h2,
  #view-timetable .print-head p { color: #111 !important; }
  #view-timetable .print-head p { color: #555 !important; }
  #view-timetable .legend-title,
  #view-timetable .legend-item { color: #111 !important; }
  #view-timetable .legend-sec { color: #444 !important; }
}
