:root {
  color-scheme: light;
  font-family: system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page-background);
  font-synthesis: none;
  --text: #192c24;
  --page-background: #eef3ef;
  --muted: #52645b;
  --line: #dce6df;
  --surface: #fff;
  --control-background: #f8faf8;
  --control-hover: #eaf1eb;
  --selected-background: #193d31;
  --selected-text: #fff;
  --focus: #206c51;
  --red: #9a3239;
  --day-text: #24352c;
  --day-background: #f0f5f1;
  --nonworking-background: #f9eeed;
  --nonworking-absence-text: #832029;
  --overlap-background: #e6eee8;
  --absence-tint: 43%;
  --detail-background: #18362b;
  --detail-line: #496759;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #edf5ee;
  --page-background: #111915;
  --muted: #b5c7bb;
  --line: #37483e;
  --surface: #1b2721;
  --control-background: #24342a;
  --control-hover: #304738;
  --selected-background: #b8dec2;
  --selected-text: #143122;
  --focus: #92d3ac;
  --red: #ffabb2;
  --day-text: #edf5ee;
  --day-background: #26382e;
  --nonworking-background: #3a292d;
  --nonworking-absence-text: #ffb8be;
  --overlap-background: #2e4237;
  --absence-tint: 27%;
  --detail-background: #24342a;
  --detail-line: #698575;
}

.person-accent { --person-color: var(--person-light); }
[data-theme="dark"] .person-accent {
  --person-color: var(--person-dark, color-mix(in srgb, var(--person-light) 65%, white));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button { font: inherit; cursor: pointer; }
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page {
  width: min(100%, 84rem);
  margin-inline: auto;
  padding: clamp(.75rem, 2vw, 1.75rem) clamp(.75rem, 1.8vw, 2rem) 2rem;
}

.schedule {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .75rem;
}

.load-state {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--surface);
}

.load-error { color: var(--red); }
noscript .load-state { margin-top: .5rem; }

.people-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: .35rem;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--surface);
}

.people { display: flex; flex-wrap: wrap; gap: .35rem; }

.person-button, .theme-toggle {
  min-height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  color: var(--text);
  background: var(--control-background);
}

.person-button:hover, .theme-toggle:hover { background: var(--control-hover); }

.person-button {
  display: flex;
  flex: 1 1 7rem;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .35rem .55rem;
  font-size: .875rem;
  font-weight: 550;
  text-align: center;
  overflow-wrap: anywhere;
}

.person-button[aria-pressed="true"] {
  border-color: var(--selected-background);
  color: var(--selected-text);
  background: var(--selected-background);
}

.person-color {
  flex: 0 0 .72rem;
  height: .72rem;
  border: 1px solid #172c2130;
  border-radius: .2rem;
  background: var(--person-color);
}
.person-button[aria-pressed="true"] .person-color { border-color: #ffffff6b; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  padding: 0;
  font-family: "Segoe UI Symbol", system-ui, sans-serif;
  font-size: 1.25rem;
  line-height: 1;
}

.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

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

.month-card {
  min-width: 0;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--surface);
  scroll-margin-block: .75rem;
}

.month-card:target { border-color: var(--focus); }
.month-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .15rem .3rem;
  padding: .2rem .15rem .45rem;
  border-bottom: 1px solid var(--line);
}

.month-header h2 { font-size: 1.125rem; font-weight: 720; letter-spacing: -.025em; }
.month-hours { color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.month-table { width: 100%; table-layout: fixed; margin-top: .4rem; border-spacing: .125rem .17rem; }
.month-table th { width: 1.75rem; text-align: start; }
.month-table td { padding: 0; text-align: center; }
.weekday { color: var(--muted); font-size: .8125rem; font-weight: 550; }
.week-number, .month-table tfoot td { padding-top: .25rem; color: var(--muted); font-size: .75rem; font-weight: 550; }

.day {
  position: relative;
  display: block;
  width: 100%;
  height: 2.125rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: .28rem;
  color: var(--day-text);
  background: var(--day-background);
  font-size: .9375rem;
  font-weight: 530;
  font-variant-numeric: tabular-nums;
}

.day.is-nonworking { color: var(--red); background: var(--nonworking-background); }
.day.has-absence { font-weight: 680; }
.day.has-absence:not(.has-overlap) {
  background: color-mix(in srgb, var(--person-color) var(--absence-tint), var(--surface));
  box-shadow: inset 0 -2px var(--person-color);
}
.day.is-nonworking.has-absence { color: var(--nonworking-absence-text); }
.day.has-overlap { padding-bottom: .45rem; background: var(--overlap-background); }
.overlap-colors {
  display: none;
  position: absolute;
  inset: auto 1px 1px;
  gap: 1px;
  height: .55rem;
  overflow: hidden;
  border-radius: 2px;
  pointer-events: none;
}
.day.has-overlap .overlap-colors { display: flex; }
.overlap-colors > span { flex: 1; background: var(--person-color); }

.day:hover, .day[aria-describedby] { border-color: var(--focus); }
.day:focus-visible { z-index: 1; outline-offset: 1px; }
.short-mark { position: absolute; top: 0; right: 1px; color: inherit; font-size: .65rem; }

.day-details {
  position: fixed;
  z-index: 5;
  width: min(21rem, calc(100% - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: .9rem 1rem;
  border: 1px solid var(--detail-line);
  border-radius: .85rem;
  color: #fff;
  background: var(--detail-background);
  box-shadow: 0 .6rem 1.75rem #10251e39;
  overflow: auto;
  pointer-events: none;
}

.day-details[data-pinned] { pointer-events: auto; overscroll-behavior: contain; }
.detail-title { display: block; font-size: .9375rem; font-weight: 700; }
.detail-status, .detail-empty { margin-top: .3rem; color: #d4e5da; font-size: .875rem; }
.detail-list { margin: .65rem 0 0; padding: 0; list-style: none; }
.detail-person { display: grid; gap: .15rem; padding-left: .55rem; border-left: 3px solid var(--person-color); }
.detail-person + .detail-person { margin-top: .7rem; }
.detail-person strong { overflow-wrap: anywhere; font-size: .875rem; }
.detail-role, .detail-period { overflow-wrap: anywhere; font-size: .8125rem; color: #d4e5da; }
.detail-period { color: #e1f2c9; }

@media (width < 66rem) {
  .people { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 39rem) {
  .people { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .person-button, .theme-toggle { min-height: 2.55rem; }
  .theme-toggle { width: 2.55rem; }
  .year-grid { grid-template-columns: minmax(0, 1fr); gap: .7rem; }
  .month-card { padding: .85rem; }
  .month-table { border-spacing: .18rem; }
  .month-table th { width: 1.95rem; }
  .day { height: 2.65rem; font-size: 1rem; }
  .short-mark { top: .23rem; right: .18rem; }
}
