:root {
  color-scheme: light dark;
  --bg: #f4f5f1;
  --surface: #ffffff;
  --text: #171a16;
  --muted: #5f665d;
  --line: #d5d9d1;
  --line-strong: #aeb5aa;
  --accent: #135ed6;
  --accent-hover: #0a4cb8;
  --accent-soft: #e7eefb;
  --today: #0b6b4f;
  --warning: #9a5b00;
  --focus: #f0b323;
  --max: 74rem;
  --header-height: 4.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111411;
    --surface: #191d19;
    --text: #f4f6f1;
    --muted: #abb3a8;
    --line: #353b35;
    --line-strong: #5d675d;
    --accent: #78aaff;
    --accent-hover: #a2c5ff;
    --accent-soft: #1d2d47;
    --today: #73d2ae;
    --warning: #ffc46b;
    --focus: #ffd166;
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }
button, input, select { font: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.7rem;
  left: 0.7rem;
  padding: 0.7rem 1rem;
  transform: translateY(-180%);
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: relative;
  z-index: 20;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.header-inner {
  display: flex;
  width: min(100% - 2rem, var(--max));
  min-height: var(--header-height);
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 1.9rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 0.74rem;
}

.global-nav {
  display: flex;
  min-width: 0;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.global-nav::-webkit-scrollbar { display: none; }
.global-nav a {
  flex: 0 0 auto;
  padding: 0.65rem 0.7rem;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}
.global-nav a:hover, .global-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.container { width: min(100% - 2rem, var(--max)); margin-inline: auto; }
.narrow { max-width: 48rem; }
.section { padding: clamp(3.5rem, 8vw, 6.5rem) 0; }
.section + .section { border-top: 1px solid var(--line); }
.section.surface { background: var(--surface); }

.hero {
  display: grid;
  min-height: calc(100svh - var(--header-height));
  align-content: center;
  padding: clamp(2rem, 5vw, 4rem) 0 2rem;
}

.hero-grid {
  display: grid;
  gap: clamp(1.75rem, 5vw, 4rem);
  align-items: center;
}

.eyebrow, .section-label {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, h3 { text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2.25rem, 8vw, 4.8rem); line-height: 1; }
h2 { margin: 0; font-size: clamp(1.75rem, 5vw, 3rem); line-height: 1.12; }
h3 { margin: 0; font-size: 1.2rem; line-height: 1.25; }

.week-display {
  display: flex;
  align-items: baseline;
  gap: clamp(0.65rem, 2vw, 1.25rem);
  margin-top: 1.1rem;
}

.week-number {
  color: var(--accent);
  font-size: clamp(7rem, 30vw, 15rem);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 0.76;
}

.week-side { display: grid; gap: 0.3rem; }
.week-year { font-size: clamp(1.35rem, 4vw, 2.2rem); font-weight: 800; }
.iso-code { color: var(--muted); font-size: 1rem; font-variant-numeric: tabular-nums; }

.hero-details {
  display: grid;
  gap: 0.6rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}
.hero-details strong { font-weight: 800; }
.timezone-line { color: var(--muted); font-size: 0.88rem; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.5rem;
}
.year-links { margin: 0 0 1.5rem; }

.button {
  display: inline-flex;
  min-height: 2.85rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.button:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: #fff; transform: translateY(-1px); }
.button.secondary { background: transparent; color: var(--accent); }
.button.secondary:hover { background: var(--accent-soft); color: var(--accent-hover); }
.button.icon-button { width: 2.85rem; padding: 0; }
.button svg { width: 1.05rem; height: 1.05rem; }

.week-nav {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.week-nav a { font-weight: 700; text-decoration: none; }

.quick-tools {
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--line);
}
.quick-tools h2 { font-size: 1rem; }
.quick-links { display: grid; gap: 0; margin-top: 0.75rem; }
.quick-links a {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 720;
  text-decoration: none;
}
.quick-links a::after { color: var(--accent); content: "→"; }
.quick-links a:hover { color: var(--accent); }

.section-head { display: grid; gap: 1rem; margin-bottom: 2rem; }
.section-intro { max-width: 44rem; margin: 0.9rem 0 0; color: var(--muted); font-size: 1.05rem; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.week-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.week-table th, .week-table td { padding: 0.72rem 0.8rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.week-table th { background: var(--bg); color: var(--muted); font-size: 0.74rem; text-transform: uppercase; }
.week-table tbody tr:last-child td { border-bottom: 0; }
.week-table tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.week-table tr.current-week td { background: var(--accent-soft); font-weight: 750; }
.week-table tr.current-week td:first-child { box-shadow: inset 4px 0 var(--accent); }
.week-table a { font-weight: 750; text-decoration: none; }

.two-col, .three-col { display: grid; gap: 2.5rem; }
.plain-block { padding-block: 1.5rem; border-top: 1px solid var(--line); }
.plain-block:last-child { border-bottom: 1px solid var(--line); }
.plain-block p:last-child { margin-bottom: 0; }
.definition-list { margin: 1.25rem 0 0; }
.definition-list dt { margin-top: 1rem; font-weight: 800; }
.definition-list dd { margin: 0.2rem 0 0; color: var(--muted); }

.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { padding: 1.15rem 0; cursor: pointer; font-weight: 780; }
.faq details div { max-width: 45rem; padding: 0 0 1.25rem; color: var(--muted); }

.breadcrumb { padding: 1rem 0; color: var(--muted); font-size: 0.84rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { margin-right: 0.35rem; content: "/"; }
.breadcrumb a { color: inherit; }

.page-hero { padding: clamp(2.75rem, 7vw, 5rem) 0 2.5rem; }
.page-hero h1 { max-width: 16ch; font-size: clamp(2.3rem, 7vw, 4.6rem); line-height: 1.02; }
.page-lead { max-width: 43rem; margin: 1.15rem 0 0; color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.2rem); }

.tool-layout { display: grid; gap: 2.5rem; align-items: start; }
.tool-form { display: grid; gap: 1.15rem; }
.field { display: grid; gap: 0.38rem; }
.field label, .field legend { font-weight: 780; }
.field-hint { margin: 0; color: var(--muted); font-size: 0.84rem; }
input, select {
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
input:invalid:not(:placeholder-shown) { border-color: var(--warning); }
.form-grid { display: grid; gap: 1rem; }
.error { min-height: 1.4em; margin: 0; color: var(--warning); font-size: 0.88rem; font-weight: 700; }

.result {
  min-height: 14rem;
  padding: 1.5rem 0;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
}
.result-label { margin: 0; color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.result-value { margin: 0.25rem 0 0; color: var(--accent); font-size: clamp(2.8rem, 10vw, 5.5rem); font-variant-numeric: tabular-nums; font-weight: 850; line-height: 1; }
.result-meta { display: grid; gap: 0.35rem; margin-top: 1.15rem; }
.result-meta p { margin: 0; }
.result[hidden] { display: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 1.2rem; }

.year-switcher { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between; margin: 2rem 0; }
.year-switcher a { font-weight: 750; text-decoration: none; }

.months-grid { display: grid; gap: 2rem 1.25rem; }
.month h2, .month h3 { margin-bottom: 0.65rem; font-size: 1.05rem; }
.month-table { width: 100%; border: 1px solid var(--line); border-collapse: separate; border-spacing: 0; border-radius: 5px; background: var(--surface); font-size: 0.76rem; table-layout: fixed; }
.month-table th, .month-table td { height: 2rem; padding: 0; text-align: center; }
.month-table thead th { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.65rem; }
.month-table th:first-child, .month-table td:first-child { width: 2.35rem; border-right: 1px solid var(--line); color: var(--muted); font-weight: 800; }
.month-table tbody tr + tr td { border-top: 1px solid var(--line); }
.month-table .outside { color: color-mix(in srgb, var(--muted) 40%, transparent); }
.month-table .today { background: var(--accent); color: #fff; font-weight: 800; }
.month-table tr.current-week td { background: var(--accent-soft); }
.month-table tr.current-week td.today { background: var(--accent); }

.code-block {
  position: relative;
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  white-space: nowrap;
}

.steps { padding-left: 1.25rem; }
.steps li { margin-block: 0.75rem; padding-left: 0.35rem; }
.note { padding: 1rem 1.1rem; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.source-list { padding-left: 1.2rem; }
.source-list li { margin-block: 0.55rem; }

.download-list { border-top: 1px solid var(--line); }
.download-item {
  display: grid;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.download-item p { margin: 0.25rem 0 0; color: var(--muted); }
.download-item .button { align-self: center; }

.related { padding: 3.5rem 0; border-top: 1px solid var(--line); }
.related h2 { font-size: 1.4rem; }
.related-links { display: grid; gap: 0; margin-top: 1rem; border-top: 1px solid var(--line); }
.related-links a { padding: 0.9rem 0; border-bottom: 1px solid var(--line); font-weight: 720; text-decoration: none; }

.site-footer { padding: 2.5rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
.footer-inner { display: grid; gap: 1.5rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.7rem 1.25rem; }
.footer-links a { color: inherit; }
.site-footer p { margin: 0; }

.status-message {
  position: fixed;
  z-index: 50;
  right: 1rem;
  bottom: 1rem;
  max-width: min(22rem, calc(100% - 2rem));
  padding: 0.75rem 1rem;
  border-radius: 5px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
}
.status-message[hidden] { display: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (min-width: 44rem) {
  .hero-grid { grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr); }
  .section-head { grid-template-columns: minmax(0, 0.8fr) minmax(18rem, 0.55fr); align-items: end; }
  .section-head .section-intro { margin: 0; }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool-layout { grid-template-columns: minmax(17rem, 0.65fr) minmax(20rem, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .months-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .download-item { grid-template-columns: minmax(0, 1fr) auto; }
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
}

@media (min-width: 70rem) {
  .months-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 55rem) {
  .header-inner { display: grid; padding: 0.8rem 0; }
  .global-nav { width: 100%; }
  :root { --header-height: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

@media print {
  .site-header, .breadcrumb, .action-row, .week-nav, .related, .site-footer, .button { display: none !important; }
  body { background: #fff; color: #000; font-size: 9pt; }
  .section, .page-hero { padding: 1rem 0; }
  .container { width: 100%; }
  .table-wrap { overflow: visible; border-color: #777; }
  .week-table th, .week-table td { padding: 0.25rem 0.4rem; }
  a { color: #000; text-decoration: none; }
}
