:root {
  color-scheme: light;
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-soft: #eef2f7;
  --surface-overlay: rgba(255, 255, 255, 0.94);
  --text: #111827;
  --muted: #5f6b7a;
  --border: #d8dee8;
  --grid-line: rgba(216, 222, 232, 0.74);
  --brand: #1e3a5f;
  --brand-strong: #142940;
  --accent: #3b82f6;
  --accent-soft: #dbeafe;
  --session-bg: #f8fbff;
  --source-bg: #edf2f7;
  --eps: #10b981;
  --msi: #3b82f6;
  --empty-campus: #9ca3af;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --specialty: #6d28d9;
  --specialty-bg: #ede9fe;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  --radius: 8px;
  --header-height: 68px;
  --day-header-height: 58px;
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.28);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --surface: #1f2937;
  --surface-soft: #273244;
  --surface-overlay: rgba(31, 41, 55, 0.94);
  --text: #f9fafb;
  --muted: #cbd5e1;
  --border: #374151;
  --grid-line: rgba(55, 65, 81, 0.74);
  --brand: #8fb8e8;
  --brand-strong: #cfe5ff;
  --accent: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.2);
  --session-bg: #243247;
  --source-bg: #2d394b;
  --warning: #fbbf24;
  --warning-bg: rgba(180, 83, 9, 0.22);
  --specialty: #c4b5fd;
  --specialty-bg: rgba(109, 40, 217, 0.22);
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111827;
    --surface: #1f2937;
    --surface-soft: #273244;
    --surface-overlay: rgba(31, 41, 55, 0.94);
    --text: #f9fafb;
    --muted: #cbd5e1;
    --border: #374151;
    --grid-line: rgba(55, 65, 81, 0.74);
    --brand: #8fb8e8;
    --brand-strong: #cfe5ff;
    --accent: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.2);
    --session-bg: #243247;
    --source-bg: #2d394b;
    --warning: #fbbf24;
    --warning-bg: rgba(180, 83, 9, 0.22);
    --specialty: #c4b5fd;
    --specialty-bg: rgba(109, 40, 217, 0.22);
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

body,
button,
input,
select {
  font: inherit;
}

button,
a,
input,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: var(--surface-overlay);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-height);
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 10px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--brand-strong);
  font-size: 16px;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 13px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--shadow);
  cursor: pointer;
  flex: 0 0 auto;
}

.theme-toggle svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow);
}

.app-shell {
  width: min(1180px, 100%);
  min-height: calc(100vh - var(--header-height) - 56px);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px 24px;
  color: var(--muted);
  font-size: 13px;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 52vh;
  text-align: center;
}

.loader {
  width: 34px;
  height: 34px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.screen {
  display: grid;
  gap: 18px;
}

.screen-head {
  display: grid;
  gap: 8px;
}

.screen-title {
  margin: 0;
  color: var(--brand-strong);
  font-size: 28px;
  line-height: 1.15;
}

.screen-copy {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.selector-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.compact-mode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-weight: 800;
  cursor: pointer;
}

.compact-mode-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.degree-list,
.course-list,
.multi-degree-list {
  display: grid;
  gap: 8px;
}

.degree-button,
.course-choice,
.combo-option {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.degree-button,
.course-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.degree-button:hover,
.course-choice:hover,
.degree-button:focus-visible,
.course-choice:focus-visible,
.button:focus-visible,
.icon-button:focus-visible,
.combo-option:focus-within {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow);
}

.degree-name {
  display: block;
  font-weight: 750;
}

.degree-button .degree-name {
  line-height: 1.25;
}

.arrow {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--brand-strong);
  font-weight: 800;
  flex: 0 0 auto;
}

.selector-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.selector-toolbar .pill {
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-day-nav,
.multi-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 750;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button {
  padding: 10px 14px;
}

.button.primary {
  background: var(--brand);
  color: #ffffff;
}

.button.secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand-strong);
}

.button.ghost {
  background: transparent;
  color: var(--brand-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.multi-heading {
  margin: 0;
  color: var(--brand-strong);
  font-size: 17px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.course-choice {
  justify-content: center;
  min-height: 44px;
  padding: 8px 6px;
  font-weight: 850;
  text-align: center;
}

.multi-toolbar {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.multi-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.multi-degree {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.multi-degree:first-child {
  border-top: 0;
}

.combo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 8px;
}

.combo-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
}

.combo-option input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.combo-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.combo-option strong,
.combo-option small {
  display: block;
}

.combo-option small {
  color: var(--muted);
  font-size: 12px;
}

.schedule-head {
  display: grid;
  gap: 10px;
}

.schedule-title-row {
  min-width: 0;
}

.schedule-title {
  margin: 0;
  color: var(--brand-strong);
  font-size: 24px;
  line-height: 1.2;
}

.schedule-control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.schedule-control-row::-webkit-scrollbar {
  display: none;
}

.schedule-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.icon-control svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-control-primary {
  background: var(--brand);
  color: #ffffff;
}

.icon-control-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand-strong);
}

.icon-control:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.icon-control:active {
  transform: translateY(1px);
}

.icon-control:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.offline-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(180, 83, 9, 0.32);
  border-radius: var(--radius);
  background: var(--warning-bg);
  color: var(--warning);
  font-weight: 750;
}

.install-tip {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 80;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100% - 24px));
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-overlay);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(14px);
  animation: installTipIn 180ms ease-out;
}

.install-tip-no-action {
  grid-template-columns: 38px minmax(0, 1fr) 44px;
}

.install-tip-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--brand-strong);
}

.install-tip-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.install-tip-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.install-tip-copy strong {
  color: var(--brand-strong);
  font-size: 14px;
  line-height: 1.2;
}

.install-tip-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-tip-action,
.install-tip-close {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 850;
  cursor: pointer;
}

.install-tip-action {
  padding: 8px 10px;
  background: var(--brand);
  color: #ffffff;
}

.install-tip-close {
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.install-tip-action:focus-visible,
.install-tip-close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

@keyframes installTipIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.campus-legend {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 2px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.legend-swatch {
  width: 8px;
  height: 20px;
  border-radius: 999px;
}

.legend-swatch.eps {
  background: var(--eps);
}

.legend-swatch.msi {
  background: var(--msi);
}

.legend-swatch.empty {
  background: var(--empty-campus);
}

.term-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.term-button {
  min-width: 34px;
  min-height: 34px;
  padding: 6px 7px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  cursor: pointer;
}

.term-button.is-active {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: var(--shadow);
}

.mobile-day-nav {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 8px;
}

.mention-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mention-button {
  min-height: 38px;
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.mention-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--brand-strong);
  box-shadow: var(--shadow);
}

.mention-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

.mention-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow);
}

.icon-button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand-strong);
}

.schedule-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-snap-type: x mandatory;
  scroll-padding-left: 58px;
}

.schedule-grid {
  --timeline-height: 900px;
  display: grid;
  grid-template-columns: 58px repeat(5, minmax(254px, 1fr));
  min-width: calc(58px + (5 * 254px));
}

.time-rail {
  position: sticky;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-rows: var(--day-header-height) auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.time-rail-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.time-rail-body {
  position: relative;
  height: var(--timeline-height);
}

.time-tick {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.day-column {
  display: grid;
  grid-template-rows: var(--day-header-height) auto;
  min-width: 0;
  border-right: 1px solid var(--border);
  scroll-snap-align: start;
}

.day-column:last-child {
  border-right: 0;
}

.day-header {
  position: relative;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.day-header strong {
  color: var(--brand-strong);
  font-size: 15px;
}

.day-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.day-column.is-today .day-header {
  background: var(--accent-soft);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.day-timeline {
  position: relative;
  height: var(--timeline-height);
  background:
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px) 0 0 / 100% 60px,
    var(--surface);
}

.grid-line {
  position: absolute;
  right: 0;
  left: 0;
  border-top: 1px solid var(--grid-line);
  pointer-events: none;
}

.session-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 34px;
  overflow: hidden;
  padding: 8px 9px 8px 10px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--empty-campus);
  border-radius: var(--radius);
  background: var(--session-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.25;
}

.session-card.campus-eps {
  border-left-color: var(--eps);
}

.session-card.campus-msi {
  border-left-color: var(--msi);
}

.session-card.campus-empty {
  border-left-color: var(--empty-campus);
}

.session-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.session-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--brand-strong);
  font-weight: 800;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.session-detail {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.session-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
}

.badge-en {
  background: var(--accent-soft);
  color: var(--brand-strong);
}

.badge-specialty,
.badge-mention {
  background: var(--specialty-bg);
  color: var(--specialty);
}

.badge-source {
  background: var(--source-bg);
  color: var(--muted);
}

.day-empty {
  position: absolute;
  top: 18px;
  right: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  min-height: 76px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 640px) {
  .selector-panel {
    padding: 18px;
  }

  .degree-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding: 24px 22px 34px;
  }

  .screen-title {
    font-size: 34px;
  }

  .mobile-day-nav {
    display: none;
  }

  .schedule-grid {
    grid-template-columns: 66px repeat(5, minmax(174px, 1fr));
    min-width: 980px;
  }

  .schedule-scroll {
    scroll-padding-left: 66px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .screen-title {
    font-size: 25px;
  }

  .button {
    width: 100%;
  }

  .schedule-actions .button,
  .multi-actions .button,
  .mobile-day-nav .button,
  .selector-toolbar .button {
    width: auto;
  }

  .schedule-grid {
    grid-template-columns: 54px repeat(5, minmax(242px, 1fr));
    min-width: calc(54px + (5 * 242px));
  }
}
