:root {
  --bg: #ffffff;
  --fg: #1b1f24;
  --muted: #5a6470;
  --brand: #0b5cad;
  --brand-fg: #ffffff;
  --border: #d3d9e0;
  --surface: #f4f6f9;
  --weekend-bg: #e9edf2;
  --weekend-fg: #4a5561;
  --holiday-bg: #fde7e4;
  --holiday-fg: #8a1c10;
  --today: #0b5cad;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --fg: #e8ecf1;
    --muted: #a3adb9;
    --brand: #6cb2f5;
    --brand-fg: #0a1a2b;
    --border: #2d3640;
    --surface: #1a2028;
    --weekend-bg: #232b34;
    --weekend-fg: #b4bec9;
    --holiday-bg: #4a1f1a;
    --holiday-fg: #ffc9c1;
    --today: #6cb2f5;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--brand); }
a:focus-visible, .btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 0.5rem; top: -4rem; padding: 0.5rem 1rem;
  background: var(--brand); color: var(--brand-fg); z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

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

.site-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-weight: 700; text-decoration: none; color: var(--fg);
}

.container { max-width: 52rem; margin: 0 auto; padding: 1rem; }

h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.2; margin: 0.5rem 0; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.75rem; }
.lead { font-size: 1.15rem; margin: 0 0 1rem; }
.count { color: var(--brand); font-size: 1.3em; }
.muted { color: var(--muted); font-size: 0.9rem; }

.month-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  margin: 1rem 0;
}
.month-nav .btn--ghost { grid-column: 1 / -1; order: 3; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.75rem; padding: 0.4rem 1rem;
  background: var(--brand); color: var(--brand-fg);
  border: 2px solid var(--brand); border-radius: 0.5rem;
  font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn--ghost { background: transparent; color: var(--brand); }
.btn--disabled { background: var(--surface); border-color: var(--border); color: var(--muted); cursor: not-allowed; }

.table-wrap { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; }
caption { text-align: left; color: var(--muted); font-size: 0.9rem; padding-bottom: 0.5rem; }

.calendar { table-layout: fixed; }
.calendar th {
  padding: 0.4rem 0; font-size: 0.85rem; text-transform: uppercase;
  color: var(--muted); border-bottom: 2px solid var(--border);
}
.calendar abbr { text-decoration: none; }
.cell {
  height: 4.2rem; padding: 0.3rem; vertical-align: top;
  border: 1px solid var(--border);
}
.cell time { display: block; font-weight: 700; font-size: 1.05rem; }
.cell--weekend {
  background-color: var(--weekend-bg); color: var(--weekend-fg);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgb(128 128 128 / 0.12) 6px 8px);
}
.cell--weekend time { font-weight: 500; font-style: italic; }
.cell--holiday { background: var(--holiday-bg); color: var(--holiday-fg); }
.cell--empty { background: transparent; border-color: transparent; }
.cell--today { outline: 3px solid var(--today); outline-offset: -3px; }
.cell-tag {
  display: inline-block; margin-top: 0.1rem; padding: 0 0.3rem;
  border: 1px solid currentColor; border-radius: 0.3rem;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
}
.cell-name { display: none; font-size: 0.72rem; line-height: 1.2; margin-top: 0.15rem; }

.legend {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  list-style: none; padding: 0; margin: 1rem 0;
}
.swatch {
  display: inline-block; width: 1rem; height: 1rem; vertical-align: -0.15rem;
  border: 1px solid var(--border); border-radius: 0.2rem;
}
.swatch--working { background: var(--bg); }
.swatch--weekend {
  background-color: var(--weekend-bg);
  background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgb(128 128 128 / 0.3) 3px 4px);
}
.swatch--holiday { background: var(--holiday-bg); border-color: var(--holiday-fg); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin: 0 0 1rem; }
.stats > div { background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.75rem; }
.stats dt { color: var(--muted); font-size: 0.9rem; }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 700; }
.stats-total { border-color: var(--brand) !important; }
.stats-total dd { color: var(--brand); }

.month-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.5rem;
  list-style: none; padding: 0; margin: 0;
}
.month-grid li { background: var(--surface); border-radius: 0.5rem; }
.month-grid a, .month-grid strong {
  display: block; padding: 0.7rem 0.5rem; text-align: center; text-transform: capitalize;
}
.month-grid strong { background: var(--brand); color: var(--brand-fg); border-radius: 0.5rem; }

.holidays th, .holidays td { padding: 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.holidays thead th { color: var(--muted); font-size: 0.9rem; }

.prose { max-width: 44rem; }

.site-footer {
  margin-top: 3rem; padding: 1.5rem 1rem; text-align: center;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem;
}
.site-footer p { margin: 0.3rem 0; }

@media (min-width: 40rem) {
  .month-nav { display: flex; justify-content: space-between; }
  .month-nav .btn--ghost { order: 0; }
  .cell { height: 5.5rem; padding: 0.5rem; }
  .cell-name { display: block; }
  .cell-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
