/* Sized for older readers: 18px base text that the Text size buttons raise to 20 or 23px.
   Everything below is in rem so it all scales together. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --border: #c9ced6;
  --text: #111418;
  --muted: #434a55;
  --accent: #1a56c4;
  --today: #fff3c4;
  --shadow: 0 10px 30px rgba(15, 23, 42, .2);
  --banner-h: 2.6rem;   /* the sticky feedback banner; other sticky things sit below it */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --surface-2: #232931;
    --border: #3a414c;
    --text: #f1f3f6;
    --muted: #b8c0cc;
    --accent: #7aa7ff;
    --today: #2e2914;
    --shadow: 0 10px 30px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
html { font-size: 18px; scroll-padding-top: calc(var(--banner-h) + 12px); }
html[data-size="2"] { font-size: 20px; }
html[data-size="3"] { font-size: 23px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 1320px;
  padding: 0 16px 32px;
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 20; }
.skip:focus { left: 16px; }

/* ---------- Feedback banner, stuck to the top: the classic blue run hot ---------- */
html { overflow-x: clip; }   /* lets the banner run edge to edge without a sideways scrollbar */
.feedback-banner {
  position: sticky; top: 0; z-index: 8; min-height: var(--banner-h); display: flex; align-items: center; justify-content: center;
  width: 100vw; margin-left: calc(50% - 50vw); padding: 6px 16px; text-align: center; font-size: .9rem; font-weight: 600;
  background: linear-gradient(90deg, #1a56c4, #7c3aed 55%, #be185d); color: #fff;
  box-shadow: 0 2px 14px rgba(124, 58, 237, .45);
}
.feedback-banner p { margin: 0; }
.feedback-banner a {
  display: inline-block; margin-left: .6rem; padding: 3px 14px; border-radius: 999px;
  background: #d4ff3a; color: #111418; font-weight: 800; text-decoration: none;
  box-shadow: 0 0 0 2px #fff, 0 0 14px 2px rgba(212, 255, 58, .85);
  transition: transform .12s ease, box-shadow .12s ease;
}
.feedback-banner a:hover { transform: scale(1.06); box-shadow: 0 0 0 2px #fff, 0 0 22px 6px rgba(212, 255, 58, .95); }
.feedback-banner a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@media (max-width: 600px) { .feedback-banner .lead { display: none; } .feedback-banner a { margin-left: 0; } }

/* ---------- Header + toolbar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 0 8px; }
.top h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.top p { margin: 2px 0 0; font-size: .9rem; }
.text-size { display: flex; align-items: center; gap: 6px; }
.text-size .muted { font-size: .9rem; margin-right: 2px; }
.text-size button {
  min-width: 44px; min-height: 44px; border-radius: 8px; font-weight: 700;
  background: var(--surface); border: 2px solid var(--border);
}
.text-size button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.nav-group { display: flex; align-items: center; gap: 8px; }
.nav-group h2 { margin: 0 0 0 6px; font-size: 1.3rem; font-weight: 700; }
.toolbar button {
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px;
  padding: 6px 14px; min-height: 44px; font-weight: 600;
}
#prev, #next { font-size: 1.6rem; line-height: 1; padding: 2px 14px; min-width: 44px; }
.views { display: flex; border: 2px solid var(--border); border-radius: 12px; overflow: hidden; }
.views button { border: 0; border-radius: 0; border-right: 2px solid var(--border); }
.views button:last-child { border-right: 0; }
.views button.active { background: var(--accent); color: #fff; }

.dot { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Filters ---------- */
.filters { margin: 4px 0 16px; }
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-toggle, .filter-clear {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px; font-weight: 700;
}
.filter-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.filter-count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .85rem; min-width: 1.5rem; padding: 0 7px; text-align: center; }
.filter-clear { color: var(--accent); border-style: dashed; }
.search { flex: 1 1 220px; max-width: 360px; }
.search input {
  width: 100%; min-height: 44px; padding: 6px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px;
}
.filter-panel { margin-top: 10px; padding: 14px; background: var(--surface); border: 2px solid var(--border); border-radius: 14px; }
.filter-panel > p { margin: 0 0 12px; font-size: .9rem; }
.filter-list { display: flex; flex-wrap: wrap; gap: 8px; }
.filter {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 16px 6px 12px;
  border-radius: 999px; font-size: .95rem; font-weight: 600;
  background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 2px solid var(--c);
}
.filter .dot { width: .9rem; height: .9rem; }
.filter[aria-pressed="true"] { background: var(--c); color: #fff; }
.filter[aria-pressed="true"] .dot { background: #fff; }
.filter[aria-pressed="true"]::after { content: "\2713"; font-weight: 800; }
.free-only { display: inline-flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 600; min-height: 44px; cursor: pointer; }
.free-only input { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); }
.filter-status { margin: 10px 0 0; font-weight: 600; }
.filter-status:empty { display: none; }

/* ---------- Month ---------- */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; background: var(--border); border: 2px solid var(--border); border-radius: 14px; overflow: hidden; }
.month .dow { background: var(--surface-2); padding: 8px 4px; font-size: .85rem; font-weight: 700; text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.cell {
  background: var(--surface); border: 0; min-height: 6.2rem; padding: 8px; text-align: left;
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
.cell:hover { background: var(--surface-2); }
.cell.out { color: var(--muted); background: var(--bg); }
.cell.today { background: var(--today); }
.cell.today .num { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 9px; }
.cell.alert::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: #dc2626; }
.num { font-weight: 700; font-size: 1.05rem; align-self: flex-start; }
.dots { display: flex; flex-wrap: wrap; gap: 5px; }
.dots .dot { width: .95rem; height: .95rem; }
.count { position: absolute; top: 9px; right: 10px; font-size: .85rem; font-weight: 600; color: var(--muted); }

/* ---------- Week / weekend ---------- */
.cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 10px; }
.col { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.col.today { border-color: var(--accent); }
.col.alert { border-top: 5px solid #dc2626; }
.col-head { background: var(--surface-2); border: 0; border-bottom: 2px solid var(--border); padding: 8px 10px; text-align: left; }
.col-head b { display: block; font-size: 1.1rem; }
.col-head span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.chip {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  width: 100%; text-align: left; border: 0; border-left: 6px solid var(--c);
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); border-radius: 8px; padding: 6px 8px;
  font-size: .9rem; line-height: 1.35;
}
.chip time { font-weight: 700; font-variant-numeric: tabular-nums; }
.more { border: 0; background: none; color: var(--accent); font-weight: 700; text-align: left; padding: 4px 10px 10px; min-height: 44px; }
.none { margin: 4px; font-size: .9rem; color: var(--muted); }

/* ---------- Event list (day list + panel) ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.ev { background: var(--surface); border: 2px solid var(--border); border-left: 8px solid var(--c); border-radius: 12px; }
.ev summary {
  list-style: none; cursor: pointer; padding: 10px 14px; min-height: 44px;
  display: grid; grid-template-columns: 6.2rem 1fr auto; gap: 2px 12px; align-items: baseline;
}
.ev summary::-webkit-details-marker { display: none; }
.ev summary::after { content: "\203A"; grid-column: 3; grid-row: 1 / span 2; align-self: center; font-size: 1.6rem; color: var(--muted); transition: transform .15s; }
.ev[open] summary::after { transform: rotate(90deg); }
.ev .when { font-weight: 700; font-variant-numeric: tabular-nums; }
.ev .title { font-weight: 700; font-size: 1.05rem; line-height: 1.35; }
.ev .cat { grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.ev .flag, .ev .where, .agenda-day .stamp { display: none; } /* used by the field guide look only */
.ev .body { padding: 2px 14px 14px; border-top: 2px solid var(--border); }
.ev .body p { margin: 12px 0 0; white-space: pre-line; }
.ev .meta { color: var(--muted); }
.ev .tags { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal !important; }
.ev .tags span { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); }
.ev .links { display: flex; gap: 8px 20px; flex-wrap: wrap; margin-top: 12px; }
.ev .links a, .ev .links button { color: var(--accent); background: none; border: 0; padding: 8px 0; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.ev.city { background: color-mix(in srgb, #dc2626 8%, var(--surface)); }
.empty { color: var(--muted); padding: 20px; text-align: center; background: var(--surface); border: 2px dashed var(--border); border-radius: 12px; margin: 0; }

.day-view { max-width: 860px; padding-bottom: 88px; }
#cal:focus { outline: none; }
.agenda-day + .agenda-day { margin-top: 20px; }
.agenda-day h3 {
  position: sticky; top: var(--banner-h); z-index: 1; margin: 0 0 8px; padding: 10px 0 8px;
  background: var(--bg); font-size: 1.2rem; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.agenda-day h3 .day-name { display: inline-flex; align-items: baseline; gap: 10px; }
.agenda-day h3:focus { outline: none; }
.agenda-day h3:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.agenda-day h3 .muted { font-size: .9rem; font-weight: 600; }
.badge { background: var(--accent); color: #fff; font-size: .8rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.next-day {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; margin-top: 18px;
  padding: 14px 18px; min-height: 56px; border: 2px dashed var(--accent); border-radius: 12px; background: var(--surface);
  color: var(--accent); font-weight: 700; font-size: 1.05rem; text-align: left;
}
.next-day::before { content: "+"; font-size: 1.3rem; line-height: 1; }
.next-day .muted { margin-left: auto; font-weight: 600; font-size: .9rem; }
.next-day:hover { background: var(--surface-2); }

.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: .9rem; color: var(--muted); }
.summary span { display: flex; align-items: center; gap: 6px; }

/* ---------- Floating calendar / list toggle ---------- */
.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 9;
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: var(--shadow);
}
.fab:hover { filter: brightness(1.1); }
.fab:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }

/* ---------- Day panel ---------- */
#scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 10; }
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 11;
  background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform .2s ease, visibility 0s .2s; visibility: hidden;
}
#panel.open { transform: none; visibility: visible; transition: transform .2s ease; }
#panel > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px; border-bottom: 2px solid var(--border); background: var(--surface); }
#panel h2 { margin: 0; font-size: 1.3rem; }
#panel-close { background: var(--surface-2); border: 2px solid var(--border); border-radius: 10px; font-size: 1.8rem; line-height: 1; min-width: 48px; min-height: 48px; }
#panel-list { overflow-y: auto; padding: 12px 16px 24px; flex: 1; }

/* Wide screens: filters become a sticky sidebar beside the calendar, so they never push events down. */
@media (min-width: 1100px) {
  body { max-width: 1500px; }
  .layout { display: grid; grid-template-columns: 19rem minmax(0, 1fr); gap: 24px; align-items: start; }
  .filters { position: sticky; top: calc(var(--banner-h) + 12px); margin: 0; max-height: calc(100vh - var(--banner-h) - 24px); overflow-y: auto; }
  .filter-toggle { display: none; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; flex: none; }
  .filter-panel, .filter-panel[hidden] { display: block !important; }
  .filter-list { flex-direction: column; align-items: stretch; }
  .filter { border-radius: 12px; }
}

@media (max-width: 760px) {
  /* keep the header compact so the first events show without scrolling */
  .top { padding-top: 12px; }
  .top h1 { font-size: 1.3rem; }
  .text-size .muted { display: none; }
  .nav-group h2 { font-size: 1.1rem; }
  .cell { min-height: 4.6rem; padding: 5px; gap: 5px; }
  .num { font-size: .95rem; }
  .dots { gap: 3px; }
  .dots .dot { width: .7rem; height: .7rem; }
  .count { display: none; }
  .month .dow { font-size: .75rem; padding: 6px 2px; letter-spacing: 0; }
  .cols { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .views button { flex: 1; padding: 6px 4px; }
  .ev summary { grid-template-columns: 1fr auto; }
  .ev .when, .ev .title, .ev .cat { grid-column: 1; }
  .ev summary::after { grid-column: 2; grid-row: 1 / span 3; }
  .search { max-width: none; }
  #panel { top: auto; height: 88vh; width: 100%; border-radius: 16px 16px 0 0; transform: translateY(105%); }
}

/* ---------- Stars + "can't save" popup ---------- */
.ev-wrap { position: relative; }
.ev-wrap .ev summary { padding-right: 3.4rem; }
.star {
  position: absolute; top: 6px; right: 6px; z-index: 1; width: 48px; height: 48px;
  display: grid; place-items: center; border: 0; border-radius: 10px; background: none;
  font-size: 1.6rem; line-height: 1; color: var(--muted);
}
.star:hover { background: var(--surface-2); }
.star[aria-pressed="true"] { color: #e0a000; }
.free-only + .free-only { margin-left: 18px; }
.notice-dialog {
  max-width: min(30rem, calc(100vw - 32px)); padding: 1.4rem 1.5rem; border: 2px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.notice-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.notice-dialog h2 { margin: 0 0 .6rem; font-size: 1.3rem; }
.notice-dialog h2 span { color: #e0a000; }
.notice-dialog p { margin: 0 0 .7rem; }
.notice-dialog form { display: flex; justify-content: flex-end; margin-top: 1rem; }
.notice-dialog button { min-width: 7rem; min-height: 48px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; }
