:root {
  --surface: #ffffff;
  --neutral: #f7f7f8;
  --ink: #111111;
  --muted: #626262;
  --rule: #d9d9dc;
  --blue: #002fa7;
  --red: #e4002b;
  --yellow: #ffd400;
  --pink: #ff8fbe;
  --hour-height: 48px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--neutral);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, sans-serif;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

button, input { font: inherit; }

button {
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  min-height: 34px;
  padding: 0 11px;
  cursor: pointer;
}

button:hover, button:focus-visible {
  background: var(--ink);
  color: var(--surface);
  outline: none;
}

.widget-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 17px;
  border-bottom: 4px solid var(--blue);
}

.program, .reminder-label, #dayKicker {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mobile-label {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: .95;
  letter-spacing: -.04em;
}

.live-clock {
  display: grid;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.live-clock strong {
  color: var(--red);
  font-size: 22px;
  line-height: 1;
}

.live-clock span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.date-controls {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  border-bottom: 1px solid var(--rule);
}

.date-controls > * {
  border-width: 0 1px 0 0;
  border-color: var(--rule);
}

.date-controls > *:last-child { border-right: 0; }

#datePicker {
  width: 100%;
  min-width: 0;
  border-radius: 0;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
}

.day-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--rule);
}

.day-heading h2 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -.035em;
}

#eventCount {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.reminder-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--neutral);
}

.reminder-panel.urgent {
  color: var(--surface);
  background: var(--red);
}

.reminder-panel.urgent .reminder-label { color: var(--surface); }
.reminder-panel.urgent button { border-color: var(--surface); }

#reminderText {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

#notificationButton { flex: 0 0 auto; }

.mobile-access-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 4px solid var(--blue);
  background: var(--surface);
}

#installStatus {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mobile-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.calendar-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--blue);
  color: var(--surface);
  background: var(--blue);
  font-size: 13px;
  text-decoration: none;
}

.calendar-link:hover, .calendar-link:focus-visible {
  color: var(--blue);
  background: var(--surface);
  outline: none;
}

.all-day-section {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule);
}

.all-day-section > p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.all-day-card {
  padding: 9px 11px;
  border: 1px solid var(--ink);
  background: var(--pink);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  padding: 13px 20px;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
}

.timeline-viewport {
  height: min(64vh, 670px);
  min-height: 430px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--blue) var(--neutral);
}

.timeline {
  position: relative;
  height: calc(var(--hour-height) * 24);
  margin-left: 20px;
  background: var(--surface);
}

.grid-layer, .event-layer {
  position: absolute;
  inset: 0;
}

.time-tick {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
}

.time-tick::after {
  content: attr(data-time);
  position: absolute;
  right: 10px;
  top: -8px;
  width: 42px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  line-height: 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.event-card {
  position: absolute;
  left: 0;
  right: 66px;
  overflow: hidden;
  padding: 9px 11px;
  border: 1px solid var(--ink);
  color: var(--surface);
  background: var(--blue);
}

.event-card.exam { background: var(--red); }
.event-card.activity { color: var(--ink); background: var(--yellow); }

.event-card .event-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.event-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
  line-height: 1.12;
  letter-spacing: -.015em;
}

.event-card p {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.25;
}

.event-card.compact {
  padding-top: 6px;
  padding-bottom: 6px;
}

.event-card.compact h3 {
  margin-bottom: 3px;
  font-size: 13px;
}

.now-line {
  position: absolute;
  left: 0;
  right: 56px;
  z-index: 10;
  height: 2px;
  background: var(--red);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.7);
}

.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
}

#nowLabel {
  position: absolute;
  right: -54px;
  top: -9px;
  width: 48px;
  color: var(--surface);
  background: var(--red);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

footer {
  padding: 14px 20px 17px;
  border-top: 1px solid var(--rule);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 11px;
  font-weight: 700;
}

.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border: 1px solid var(--ink); }
.course-dot { background: var(--blue); }
.exam-dot { background: var(--red); }
.activity-dot { background: var(--yellow); }
.holiday-dot { background: var(--pink); }

.source-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.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;
}

@media (max-width: 470px) {
  .masthead { align-items: start; }
  h1 { font-size: 26px; }
  .date-controls { grid-template-columns: 1fr 1fr 1fr; }
  #datePicker { grid-column: 1 / -1; grid-row: 1; min-height: 38px; border-bottom: 1px solid var(--rule); }
  .date-controls button { grid-row: 2; }
  .reminder-panel { align-items: flex-start; }
  .mobile-access-panel { align-items: flex-start; flex-direction: column; }
  .mobile-actions { width: 100%; justify-content: stretch; }
  .mobile-actions > * { flex: 1 1 auto; justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
