:root {
  --bg: #e9edf1;
  --surface: #f8fafc;
  --ink: #121820;
  --muted: #3d4855;
  --line: #b4bec9;
  --accent: #a3241a;
  --accent-ink: #ffffff;
  --focus: #1d5fa8;
  --moon-dark: #303a46;
  --moon-lit: #f6f2e4;
  --moon-edge: #121820;
  --r: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151c25;
    --ink: #e7ebf0;
    --muted: #b0bbc7;
    --line: #34404d;
    --accent: #ff8b7d;
    --accent-ink: #1b0705;
    --focus: #8cc4ff;
    --moon-dark: #262e38;
    --moon-lit: #efe9d4;
    --moon-edge: #8794a3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, textarea:focus-visible,
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
[hidden] { display: none !important; }

.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.brand-mark { width: 24px; height: 24px; }
.mk-dark { fill: var(--moon-dark); stroke: var(--moon-edge); stroke-width: 1; }
.mk-lit { fill: var(--moon-lit); }

h1 { font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.45rem); line-height: 1.15; margin: 22px 0 8px; letter-spacing: -0.015em; max-width: 24ch; font-weight: 800; }
.lede { margin: 0 0 18px; max-width: 62ch; color: var(--muted); }
h2 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 1.08rem; margin: 22px 0 4px; }

/* ----- form ----- */
.setup { display: grid; gap: 14px; align-content: start; }
.f { display: grid; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.f > span, .f > label, legend { font-weight: 650; font-size: 1rem; padding: 0; }
input[type=text], input[type=search], input[type=number], input[type=time], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; min-height: 46px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select { padding-right: 30px; }
.combo { position: relative; }
.city-list {
  list-style: none; margin: 4px 0 0; padding: 4px 0; position: absolute; left: 0; right: 0; top: 100%; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  max-height: 320px; overflow-y: auto;
}
.city-list li { padding: 10px 12px; cursor: pointer; min-height: 44px; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.city-list li .reg { color: var(--muted); }
.city-list li[aria-selected=true] { background: var(--accent); color: var(--accent-ink); }
.city-list li[aria-selected=true] .reg { color: inherit; }
.city-list li.none { cursor: default; color: var(--muted); }
.place-now { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.place-now .co { font-weight: 400; color: var(--muted); }
.place-more { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.coords-box { flex: 1 1 220px; }
.coords-box summary, .more summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; padding-top: 4px; }
.coords label { display: grid; gap: 4px; }
.coords label span { font-weight: 600; }
.coords .btn { grid-column: 1 / -1; justify-self: start; }
.when { display: grid; grid-template-columns: 1fr 7.5em; gap: 10px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg label { flex: 1 1 0; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 46px; padding: 6px 8px; line-height: 1.2; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--ink); color: var(--bg); font-weight: 600; }
.student-opts { display: grid; gap: 2px; margin-top: 6px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }

.btn {
  font: inherit; font-weight: 600; font-size: 1rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 18px; min-height: 46px; cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 8px 14px; min-height: 44px; }
.btn.icon { width: 46px; padding: 0; display: inline-grid; place-items: center; }
.btn.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn.primary { min-width: 8em; }
.msg { margin: 0; color: var(--muted); }
.msg:empty { display: none; }
.msg.warn { color: var(--accent); font-weight: 600; }
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 6px; }
.more-grid .tz-f { grid-column: 1 / -1; }

/* ----- result ----- */
.result { margin-top: 26px; }
.printset { margin-top: 30px; display: grid; gap: 14px; align-content: start; }
.printset h2 { margin: 0; }
.place-now .co { display: block; }
.place-now:focus { outline: none; }
.tz-here .f { margin-top: 4px; }
.shared-bar { display: grid; gap: 8px; justify-items: start; }
.shared-bar p { margin: 0; }
.res-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.res-head h2 { flex: 1; margin: 0; text-align: center; font-size: 1.25rem; }
.mv + .mv { margin-top: 18px; }
.mv h3 { margin: 0 0 6px; font-size: 1.05rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal .wd { text-align: center; font-size: 0.95rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.day {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid transparent; border-radius: 4px;
  padding: 3px 2px 5px; min-height: 64px; display: grid; justify-items: center; align-content: start; gap: 2px; cursor: pointer; position: relative;
}
.day.gone { cursor: default; background: transparent; border: 1px dashed var(--line); }
.day.gone .dn { text-decoration: line-through; color: var(--muted); }
.day .dn { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.day svg { width: min(36px, 80%); height: auto; }
.day[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.day.today .dn { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.day.noted::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.disc .dk { fill: var(--moon-dark); }
.disc .lt { fill: var(--moon-lit); }
.disc .rim { fill: none; stroke: var(--moon-edge); stroke-width: 1.2; }

.night { margin-top: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.night-top { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start; }
.night-top svg { width: 96px; height: 96px; }
.night h3 { margin: 0 0 4px; font-size: 1.15rem; }
.night dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.night dt { color: var(--muted); }
.night dd { margin: 0; font-weight: 600; }
.night .ph { font-size: 1.05rem; font-weight: 700; margin: 0 0 6px; }
.night .note-f { margin-top: 14px; }
.computed { margin: 14px 0 0; color: var(--muted); max-width: 70ch; }
.clear-row { margin: 10px 0 0; }

.about { margin-top: 40px; padding-bottom: 32px; }
.about section { max-width: 72ch; margin-bottom: 30px; }
.about p { margin: 0 0 12px; }
.faq h3 { margin-top: 18px; }

.foot { border-top: 1px solid var(--line); padding: 22px 0 30px; color: var(--muted); }
.sb-footer p { margin: 0 0 10px; overflow-wrap: anywhere; }
.sb-more a, .sb-privacy a, .sb-credit a { color: var(--accent); }

@media (min-width: 900px) {
  main > .wrap:first-child { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; grid-template-rows: auto auto auto 1fr; column-gap: 48px; }
  main > .wrap:first-child > h1, main > .wrap:first-child > .lede { grid-column: 1 / -1; }
  .setup { grid-column: 1; grid-row: 3; }
  .printset { grid-column: 1; grid-row: 4; margin-top: 26px; }
  .result { grid-column: 2; grid-row: 3 / span 2; margin-top: 0; }
  .day { min-height: 76px; }
  .day svg { width: 40px; }
}
@media (max-width: 400px) {
  .seg span { font-size: 0.95rem; padding: 6px 4px; }
  .night-top { grid-template-columns: 72px 1fr; gap: 12px; }
  .night-top svg { width: 72px; height: 72px; }
  .more-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ----- the printed sheet ----- */
.sheet { display: none; }
/* No page margin: Chrome then has no room for its own header (the address, which can hold the month) and footer. */
@page { margin: 0; }
@media print {
  html, body { background: #fff !important; color: #000; font-size: 10pt; }
  body > *:not(main), main > *:not(.sheet) { display: none !important; }
  .sheet { display: block; color: #000; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
  .pg { break-after: page; page-break-after: always; height: 100vh; box-sizing: border-box; padding: 0.45in 0.5in; display: flex; flex-direction: column; overflow: hidden; }
  .pg:last-child { break-after: auto; page-break-after: auto; }
  .pg-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12pt; border-bottom: 1.5pt solid #000; padding-bottom: 4pt; margin-bottom: 6pt; }
  .pg-title { font-size: 17pt; font-weight: 800; margin: 0; line-height: 1.1; }
  .pg-head .who { font-size: 10.5pt; white-space: nowrap; }
  .pg-sub { font-size: 9.5pt; margin: 0 0 6pt; display: flex; justify-content: space-between; gap: 10pt; }
  .pg-foot { margin-top: auto; padding-top: 4pt; border-top: 0.75pt solid #777; font-size: 8pt; line-height: 1.3; color: #222; }
  .sheet svg .dk { fill: #8a9099; }
  .sheet svg .lt { fill: #fff; }
  .sheet svg .rim { fill: none; stroke: #000; stroke-width: 1; }
  .sheet svg .sk { fill: none; stroke: #555; stroke-width: 0.9; }
  .sheet svg { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  /* month grid */
  .mgrid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; border-top: 0.75pt solid #000; border-left: 0.75pt solid #000; min-height: 0; }
  .mgrid .wdh { font-size: 8.5pt; font-weight: 700; text-align: center; padding: 2pt 0; border-right: 0.75pt solid #000; border-bottom: 0.75pt solid #000; }
  .mgrid.has-wd { grid-template-rows: auto; }
  .mc { border-right: 0.75pt solid #000; border-bottom: 0.75pt solid #000; padding: 3pt 3pt 3pt; display: grid; grid-template-rows: 0.32in var(--ph) var(--ev) minmax(0, 1fr); min-height: 0; overflow: hidden; }
  .mc.empty, .mc.skipd { display: block; }
  .mc .mt { display: flex; align-items: flex-start; gap: 2pt; min-width: 0; }
  .mc .dn { font-size: 12pt; font-weight: 700; line-height: 1; }
  .mc .pc { font-size: 8.5pt; flex: 1; text-align: right; padding-top: 1pt; white-space: nowrap; }
  .mc .dl { font-size: 8pt; color: #333; border-bottom: 0.5pt solid #777; flex: 1; margin-left: 3pt; height: 10pt; }
  .mc .ph-slot { display: flex; overflow: hidden; }
  .mc .ph-slot .dl { margin-left: 0; }
  .mc .mt svg { width: 0.28in; height: 0.28in; flex: none; }
  .mc .pn { font-size: 8.5pt; font-weight: 700; line-height: 1.2; }
  .mc.skipd .pn { font-weight: 400; margin-top: 4pt; }
  .mc .ev-slot { overflow: hidden; }
  .mc .tx { font-size: 8.5pt; line-height: 10.5pt; white-space: nowrap; }
  .mc .skw { display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
  .mc .skw svg { height: 100%; max-height: 0.85in; width: auto; aspect-ratio: 1; display: block; }

  /* week pages */
  .wrows { flex: 1; display: flex; flex-direction: column; border-top: 0.75pt solid #000; }
  .wr { flex: 1 1 0; min-height: 0; max-height: 1.45in; display: grid; grid-template-columns: 1.95in 1in 1fr; gap: 8pt; border-bottom: 0.75pt solid #000; padding: 5pt 0; break-inside: avoid; }
  .wr .info { display: grid; grid-template-columns: 0.5in 1fr; gap: 6pt; align-content: start; }
  .wr .info svg { width: 0.5in; height: 0.5in; }
  .wr .dn { font-size: 11pt; font-weight: 700; line-height: 1.15; }
  .wr .pn { font-size: 9.5pt; font-weight: 600; line-height: 1.2; }
  .wr .tx { font-size: 9.5pt; line-height: 1.25; }
  .wr .blank { font-size: 9.5pt; color: #333; border-bottom: 0.5pt solid #777; height: 14pt; }
  .wr .sk { display: flex; align-items: center; justify-content: center; }
  .wr .sk svg { width: 0.98in; height: 0.98in; }
  .wr .lines { display: grid; grid-template-rows: repeat(4, 1fr); font-size: 9pt; color: #333; }
  .wr .lines div:last-child { border-bottom: 0; }
  .wr .lines div { border-bottom: 0.5pt solid #999; display: flex; align-items: flex-end; padding-bottom: 1pt; overflow: hidden; }
  .wr .lines .typed { color: #000; font-size: 9.5pt; white-space: pre-wrap; align-items: flex-start; grid-row: span 3; border-bottom: 0.5pt solid #999; overflow: hidden; line-height: 1.25; }
}
