:root {
  color-scheme: light;
  --paper: #f3f6fb;
  --surface: #fff;
  --ink: #192a41;
  --muted: #55667b;
  --line: #d9e2ee;
  --blue: #174779;
  --soft-blue: #e7effa;
  --accent: #2467bc;
  --radius: 12px;
  font: 100%/1.55 system-ui, "PingFang SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--paper); color: var(--ink); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }

.shell { width: min(1100px, calc(100% - 80px)); margin-inline: auto; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner, .sync, .week-header, .week-controls, .section-heading { display: flex; align-items: center; }
.topbar-inner { min-height: 68px; justify-content: space-between; gap: 12px; }
.wordmark { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-size: 1.125rem; font-weight: 700; line-height: 1; letter-spacing: -.055em; }
.brand-mark { display: grid; place-items: center; width: 25px; height: 25px; border-radius: var(--radius); background: var(--blue); }
.brand-mark span { width: 12px; height: 11px; border: 1.5px solid #fff; border-radius: 2px; position: relative; }
.brand-mark span::before { content: ''; position: absolute; top: 2px; inset-inline: 0; border-top: 1.5px solid #fff; }

.sync { gap: 9px; color: var(--muted); }
.sync-status { display: inline-flex; align-items: center; gap: 7px; font-size: .875rem; white-space: nowrap; }
.sync-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #8e9db2; }
.sync-status[data-state="ready"]::before { background: #3473ba; }
.sync-status:is([data-state="error"], [data-state="stale"])::before { background: #a74231; }
.icon-button, .today-button { min-width: 42px; min-height: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; }
.icon-button:hover:not(:disabled), .today-button:hover { background: var(--soft-blue); }
.refresh-button { min-width: 36px; min-height: 36px; border-color: transparent; }
.refresh-icon { font-size: 1.4rem; line-height: 1; margin-top: -2px; }
.refresh-button:disabled .refresh-icon { opacity: .45; }

main.shell { padding-block: 54px 65px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 32px; }
h1 { font-size: clamp(1.875rem, 3.5vw, 2.5rem); line-height: 1.12; letter-spacing: -.06em; font-weight: 750; }
.timezone { font-size: .875rem; color: var(--muted); white-space: nowrap; padding-bottom: 6px; }
.timezone span { margin-inline-start: 3px; font-variant-numeric: tabular-nums; }

.week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; }
.week-header { display: grid; grid-template-columns: 1fr auto 1fr; grid-template-areas: "range switch controls"; gap: 10px; margin-bottom: 13px; }
[data-view="week"] .week-header { margin-bottom: 0; }
.week-header h2 { grid-area: range; font-size: 1rem; padding-left: 3px; font-variant-numeric: tabular-nums; }
.week-controls { grid-area: controls; justify-self: end; gap: 5px; }
.view-switch { grid-area: switch; justify-self: start; display: flex; gap: 4px; }
.view-switch button { min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: .875rem; white-space: nowrap; }
.view-switch button[aria-pressed="true"] { background: var(--soft-blue); border-color: #b7cbe7; color: var(--blue); font-weight: 650; }
.view-switch button:hover { border-color: #9bb5d9; }
.today-button { padding-inline: 13px; font-size: .875rem; font-weight: 600; }
.chevron { width: 8px; height: 8px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: translateX(-2px) rotate(45deg); }
.chevron.previous { transform: translateX(2px) rotate(-135deg); }
.week-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.day { font-variant-numeric: tabular-nums; display: grid; place-items: center; align-content: center; gap: 1px; min-height: 87px; padding: 7px 3px; background: var(--paper); border: 1px solid transparent; border-radius: var(--radius); }
.day:hover { border-color: #9bb5d9; }
.day[aria-current="date"] { border-color: #769bc6; }
.day[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
.day-name { font-size: .875rem; color: var(--muted); }
.day[aria-pressed="true"] .day-name { color: #eff6ff; }
.day-number { font-size: 1.5rem; font-weight: 650; line-height: 1.13; }
.day-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; margin-top: 5px; }
.day.has-events .day-dot { background: #618abb; }
.day.has-events[aria-pressed="true"] .day-dot { background: #badbff; }
.content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, .44fr); gap: 26px; align-items: start; margin-top: 30px; }
.section-heading { justify-content: space-between; gap: 10px; min-height: 29px; margin: 0 0 11px; }
.section-heading h2, .upcoming h2 { font-size: 1.14rem; font-weight: 700; }
.event-count { font-size: .875rem; color: var(--muted); white-space: nowrap; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.event { display: grid; grid-template-columns: minmax(78px, auto) minmax(0, 1fr) auto; align-items: start; gap: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-height: 61px; }
.event-time { display: grid; align-content: start; gap: 0; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.45; }
.event-time strong { font-size: .97rem; color: var(--blue); }
.event-title { font-weight: 630; overflow-wrap: anywhere; }
.event-location { font-size: .875rem; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.ongoing { font-size: .8125rem; white-space: nowrap; padding: 2px 7px; border-radius: var(--radius); background: var(--soft-blue); color: var(--blue); }
.empty { border: 1px dashed #c6d5e7; color: var(--muted); border-radius: var(--radius); padding: 24px 16px; }

.upcoming { padding: 18px 19px 20px; border-radius: var(--radius); background: var(--soft-blue); border: 1px solid #d6e2f2; }
.upcoming h2 { margin-bottom: 13px; color: var(--blue); }
.upcoming p { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.upcoming .next-date { color: var(--blue); font-size: .875rem; font-variant-numeric: tabular-nums; }
.upcoming .next-title { color: var(--ink); font-size: 1.06rem; font-weight: 650; margin-block: 3px 6px; }
.next-location { margin-top: 5px; }

[data-view="week"] .content { grid-template-columns: minmax(0, 1fr); }
.week-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.week-board { display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr)); min-width: 765px; padding-bottom: 9px; }
.week-board[data-days="2"] { grid-template-columns: 42px repeat(2, minmax(0, 1fr)); min-width: 0; }
.week-board-label { color: var(--muted); font-size: .8125rem; display: grid; place-items: center; min-width: 0; }
.week-column-heading { margin: 0; border-inline-start: 1px solid var(--line); font-size: .875rem; min-width: 0; padding: 5px; }
.week-column-heading button { display: flex; justify-content: space-between; align-items: center; gap: 4px; width: 100%; min-height: 40px; padding: 5px 7px; border: 0; border-radius: var(--radius); background: var(--paper); color: var(--blue); font-size: .875rem; text-align: left; }
.week-column-heading button:hover, .week-column-heading.is-today button { background: var(--soft-blue); }
.week-column-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.week-allday-cell { min-width: 0; border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); padding: 3px 5px; display: grid; align-content: start; gap: 3px; }
.week-allday-label { border-top: 1px solid var(--line); }
.week-time-axis, .week-timeline { position: relative; height: var(--timeline-height); }
.week-time-axis { border-top: 1px solid var(--line); }
.week-hour { position: absolute; inset-inline-end: 5px; transform: translateY(-50%); color: var(--muted); font-size: .75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.week-hour:first-child { top: 3px !important; transform: none; }
.week-timeline { box-sizing: content-box; border-inline-start: 1px solid var(--line); border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour-height)); }
.week-timeline.is-today, .week-allday-cell.is-today { background-color: #f2f7fd; }
.week-block, .week-allday-event { border: 1px solid #b7cde8; border-radius: var(--radius); background: #e1edfb; color: #1b4778; text-align: left; min-width: 0; overflow: hidden; }
.week-block:hover, .week-allday-event:hover { background: #cfe2f8; border-color: #7ea3d0; }
.week-block:focus-visible { outline-offset: 0; z-index: 1; }
.week-block { position: absolute; padding: 2px 5px; display: grid; align-content: start; gap: 0; line-height: 1.15; }
.week-block.short { align-content: center; }
.week-block-time, .week-block-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.week-block-time { font-size: .75rem; font-variant-numeric: tabular-nums; font-weight: 550; }
.week-block-title, .week-allday-event { font-size: .875rem; font-weight: 600; }
.week-allday-event { white-space: nowrap; text-overflow: ellipsis; min-height: 29px; padding: 2px 6px; }
[data-view="week"] .upcoming { max-width: 360px; }

#event-dialog { width: min(420px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); padding: 18px; }
#event-dialog::backdrop { background: #16325466; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-header h2 { font-size: 1.12rem; overflow-wrap: anywhere; }
#event-dialog p { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
#event-dialog-location { margin-top: 5px; }

@media (max-width: 700px) {
  .shell { width: calc(100% - 36px); }
  .topbar-inner { min-height: 58px; }
  main.shell { padding-block: 36px 45px; }
  .intro { margin-bottom: 25px; }
  .content { grid-template-columns: 1fr; gap: 20px; margin-top: 23px; }
  .week { padding: 11px; }
  .week-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "range controls" "switch switch"; margin-bottom: 9px; }
  .week-days { gap: 4px; }
  .day { min-height: 66px; }
  .day-number { font-size: 1.25rem; }
  .event { padding-inline: 12px; gap: 9px; grid-template-columns: minmax(55px, auto) minmax(0, 1fr) auto; }
}

@media (max-width: 365px) {
  .shell { width: calc(100% - 24px); }
  .timezone span { display: none; }
  .week-header h2 { grid-area: range; font-size: .875rem; }
  .day-name { font-size: .8rem; }
}
