/* Planner: soft blue chrome, pastel category cards, one blue accent for today and actions. */

:root {
  /* Soft blue planner palette: navy ink, one blue accent, pastel category tints. */
  --bg: #F3F6FC;
  --surface: #FFFFFF;
  --ink: #1C2445;
  --muted: #5F6880; /* 5.2:1 on white (WCAG AA) */
  --line: #E5EAF3;
  --line-strong: #CFD7E6;
  --hover: #EDF2FB;
  --accent: #2B62C8; /* 5.7:1 with white text (WCAG AA) */
  --accent-soft: #E8F0FD;
  --on-accent: #FFFFFF;
  --focus: #2B62C8;
  --error: #C62B3C;
  --today-ink: #FFFFFF;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 20px;
  --tap: 44px;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1322;
    --surface: #161C2E;
    --ink: #E7ECF8;
    --muted: #95A0BA;
    --line: #252D43;
    --line-strong: #34405C;
    --hover: #1C2438;
    --accent: #6D9CF2;
    --accent-soft: #1E2C4D;
    --on-accent: #0E1322;
    --focus: #6D9CF2;
    --error: #F97066;
    --today-ink: #0E1322;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

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

/* ---------- loading bar ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 50;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: slide 1.1s ease-in-out infinite;
  opacity: .5;
}
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { .progress { animation: none; background: var(--ink); opacity: .25; } }

/* ---------- header ---------- */
.top {
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 10px;
  padding-right: max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex: none;
}

.top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
}
.top-row.second { margin-top: 6px; justify-content: space-between; flex-wrap: wrap; row-gap: 8px; }

.title {
  font-family: var(--font-round);
  font-weight: 700;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.15rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.nav { display: flex; align-items: center; gap: 4px; flex: none; }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* "Today" is a capsule; it turns solid when today is on screen. */
.today-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 17px;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin: 0 2px;
}
.today-btn.is-here { background: var(--accent); color: var(--on-accent); }

/* Segmented view switcher */
.views {
  display: inline-flex;
  background: var(--hover);
  border-radius: var(--radius-m);
  padding: 3px;
  gap: 2px;
}
.views button {
  border: 0;
  background: transparent;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.views button:hover { color: var(--ink); }
.views button[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 32, .12), 0 0 0 .5px rgba(16, 24, 32, .06);
}
.views .short { display: none; }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  color: var(--muted);
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend { flex: 1; justify-content: flex-end; }

/* Events panel toggle (3 Months only) */
.panel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.panel-btn[hidden] { display: none; }
.panel-btn:hover { color: var(--ink); background: var(--hover); }
.panel-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--line-strong); font-weight: 600; }
.panel-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.panel-btn[aria-pressed="true"] svg path { stroke-width: 2.4; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- main area ---------- */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  padding-right: max(16px, env(safe-area-inset-right));
  gap: 16px;
}
.cal-wrap { flex: 1; min-width: 0; min-height: 0; }
#calendar { height: 100%; }

/* Month grids grow to their natural height and the area scrolls. */
body[data-view="multiMonthYear"] .main,
body[data-view="threeMonths"] .main { overflow-y: auto; -webkit-overflow-scrolling: touch; }
body[data-view="multiMonthYear"] #calendar,
body[data-view="threeMonths"] #calendar { height: auto; }

body.not-connected .cal-wrap, body.not-connected .legend { display: none; }

.empty {
  margin: auto;
  max-width: 34ch;
  text-align: center;
}
.empty h2 { font-family: var(--font-round); font-size: 1.4rem; margin: 0 0 .4em; }
.empty p { color: var(--muted); margin: 0 0 1.2em; }

/* ---------- 3 Months agenda rail ---------- */
.rail {
  width: 320px;
  flex: none;
  align-self: flex-start;
  position: sticky;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 14px 6px 10px 14px;
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
}
.rail[hidden] { display: none; }
.rail-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.rail-empty { color: var(--muted); margin: 8px 0; }
.rail-day {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.rail-day .rd-num {
  font-family: var(--font-round);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
}
.rail-day.is-today .rd-num {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 0 .35em;
}
.rail-day.is-past { opacity: .55; }
.rail-group { list-style: none; margin: 0; padding: 0; }
.rail-item {
  display: grid;
  grid-template-columns: 4.2em 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--radius-s);
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  position: relative;
}
.rail-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--ev);
}
.rail-item:hover { background: var(--hover); }
.ri-time { grid-row: 1 / span 2; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ri-title { font-weight: 600; font-size: 14px; }
.ri-meta { font-size: 12.5px; color: var(--muted); }
.rail-item.status-cancelled .ri-title { text-decoration: line-through; color: var(--muted); }
.rail-item.status-done { opacity: .6; }

/* ---------- FullCalendar theme ---------- */
.fc {
  --fc-border-color: var(--line);
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--bg);
  --fc-list-event-hover-bg-color: var(--hover);
  --fc-today-bg-color: transparent;
  --fc-now-indicator-color: #E5484D;
  --fc-highlight-color: color-mix(in srgb, var(--focus) 14%, transparent);
  --fc-small-font-size: 12px;
  font-size: 13px;
}
.fc a { color: inherit; text-decoration: none; }
.fc .fc-scrollgrid { border-radius: var(--radius-l); overflow: hidden; background: var(--surface); }
.fc-theme-standard .fc-scrollgrid { border-color: var(--line); }
.fc .fc-col-header-cell-cushion { padding: 8px 4px; font-weight: 600; color: var(--muted); font-size: 12.5px; }

/* Today's date number: a solid ink circle, the one strong mark on the page. */
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  min-width: 1.9em;
  text-align: center;
  font-weight: 700;
}
.fc .fc-timegrid-col.fc-day-today { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion { color: var(--accent); }
.fc .fc-daygrid-day-number { padding: 4px 6px; font-variant-numeric: tabular-nums; }
.fc .fc-day-sat, .fc .fc-day-sun { background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.fc .fc-day-past .fc-daygrid-day-number { color: var(--muted); }

/* Events: a soft tint of the category colour with a solid edge. */
.fc .fc-event.pc-ev {
  background: color-mix(in srgb, var(--ev) 16%, var(--surface));
  border: 0;
  border-left: 3px solid var(--ev);
  border-radius: 5px;
  color: var(--ink);
  cursor: pointer;
}
.fc .fc-event.pc-ev .fc-event-main,
.fc .fc-event.pc-ev .fc-event-time,
.fc .fc-event.pc-ev .fc-event-title { color: var(--ink); }
.fc .fc-event.pc-ev:hover { background: color-mix(in srgb, var(--ev) 26%, var(--surface)); }
.fc .fc-daygrid-event.pc-ev { padding: 1px 4px; margin-top: 2px; }
.fc .fc-daygrid-dot-event.pc-ev .fc-daygrid-event-dot { border-color: var(--ev); }
.fc .fc-timegrid-event.pc-ev .fc-event-main { padding: 3px 5px; }
.fc .fc-timegrid-event.pc-ev .fc-event-time { font-weight: 600; }
.fc .fc-event.status-cancelled .fc-event-title,
.fc .fc-list-event.status-cancelled .fc-list-event-title { text-decoration: line-through; opacity: .7; }
.fc .fc-event.status-done { opacity: .55; }
.fc .fc-daygrid-more-link { font-weight: 600; color: var(--muted); }

/* Time grid */
.fc .fc-timegrid-slot { height: 2.6em; }
.fc .fc-timegrid-slot-label-cushion { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.fc .fc-timegrid-slot-minor { border-top-style: none; }
.fc-theme-standard .fc-timegrid { background: var(--surface); }

/* Multi-month (Year and 3 Months) */
.fc .fc-multimonth { border: 0; background: transparent; }
.fc .fc-multimonth-month { padding: 0 8px 12px; }
.fc .fc-multimonth-title {
  font-family: var(--font-round);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  padding: 10px 6px 8px;
}
.fc .fc-multimonth-daygrid { background: var(--surface); border-radius: var(--radius-m); overflow: hidden; }
.fc .fc-multimonth-header { background: transparent; }
.fc .fc-multimonth-header-table .fc-col-header-cell-cushion { font-size: 11px; padding: 4px 0; }
.fc-theme-standard .fc-multimonth { border-color: transparent; }

/* Year: compact days with colour dots */
.fc-multiMonthYear-view .fc-multimonth-daygrid-table { height: auto !important; }
.fc-multiMonthYear-view .fc-daygrid-day-frame { min-height: 0 !important; display: flex; flex-direction: column; align-items: center; padding: 2px 0 3px; }
.fc-multiMonthYear-view .fc-daygrid-day-top { justify-content: center; }
.fc-multiMonthYear-view .fc-daygrid-day-number { font-size: 12px; padding: 2px 4px; }
.fc-multiMonthYear-view .fc-daygrid-day-events,
.fc-multiMonthYear-view .fc-daygrid-day-bg { display: none; }
.fc-multiMonthYear-view .fc-daygrid-day { cursor: pointer; }
.fc-multiMonthYear-view .fc-daygrid-day:hover { background: var(--hover); }
.fc-multiMonthYear-view .fc-daygrid-day.has-events .fc-daygrid-day-number { font-weight: 700; color: var(--ink); }
.dots { display: flex; gap: 2px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }

/* 3 Months: months stacked full width, room for three events per day */
.fc-threeMonths-view .fc-multimonth-month { padding-bottom: 18px; }
.fc-threeMonths-view .fc-multimonth-title { font-size: 1.25rem; padding-top: 6px; }
.fc-threeMonths-view .fc-multimonth-daygrid-table { height: auto !important; }
.fc-threeMonths-view .fc-daygrid-day-frame { min-height: 6.4em; }
.fc-threeMonths-view .fc-daygrid-day { cursor: pointer; }
.fc-threeMonths-view .fc-daygrid-event { font-size: 12px; }
.fc-threeMonths-view .fc-daygrid-event .fc-event-time { font-weight: 600; margin-right: 4px; flex-shrink: 0; overflow: visible; }
.fc-threeMonths-view .fc-daygrid-event .fc-event-title { overflow: hidden; text-overflow: ellipsis; }

/* Agenda list */
.fc .fc-list { border-radius: var(--radius-l); overflow: hidden; background: var(--surface); }
.fc-theme-standard .fc-list { border-color: var(--line); }
.fc .fc-list-day-cushion { background: var(--bg); padding: 10px 14px; }
.fc .fc-list-day-text { font-family: var(--font-round); font-weight: 700; font-size: 15px; }
.fc .fc-list-day.fc-day-today .fc-list-day-text::after {
  content: "Today";
  margin-left: 8px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  vertical-align: 2px;
}
.fc .fc-list-event td { padding: 12px 14px; }
.fc .fc-list-event-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 7em; }
.fc .fc-list-event-dot { border-color: var(--ev, currentColor); }
.fc .fc-list-event-title { font-weight: 600; }
.fc .fc-list-event.pc-ev { background: transparent; border: 0; }
.fc .fc-list-event.pc-ev:hover td { background: var(--hover); }
.fc .fc-list-empty { background: var(--surface); color: var(--muted); }


/* ---------- Week planner ---------- */
/* The time grid stays loaded underneath (it drives dates and loading) but the planner replaces it. */
body[data-view="timeGridWeek"] .cal-wrap { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
body[data-view="timeGridWeek"] .main { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.week { flex: 1; min-width: 0; }
.week[hidden] { display: none; }

.wk-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600;
}
.chip.done { background: color-mix(in srgb, #16A34A 14%, var(--surface)); color: #15803D; }

/* Wide: seven day columns */
.wk-cols { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }
.wk-col {
  background: var(--surface);
  border-radius: var(--radius-l);
  padding: 12px 10px 14px;
  min-height: calc(100dvh - 230px);
  border: 1.5px solid transparent;
}
.wk-col.is-today { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.wk-col-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 12px; }
.wk-dow { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.wk-num {
  font-family: var(--font-round); font-size: 19px; font-weight: 700;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.wk-col.is-today .wk-num { background: var(--accent); color: var(--on-accent); }
.wk-col.is-past .wk-col-head { opacity: .55; }
.wk-list, .wk-tasks { display: grid; gap: 8px; }
.wk-free { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0; opacity: .7; }
.wk-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 16px 2px 8px; }

/* Event card: pastel tint of the category colour, icon tile, time in the category colour */
.wk-card {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; cursor: pointer;
  border: 0; border-radius: 16px; padding: 10px;
  background: color-mix(in srgb, var(--ev) 12%, var(--surface));
}
.wk-card:hover { background: color-mix(in srgb, var(--ev) 18%, var(--surface)); }
.wk-ico {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--ev) 22%, var(--surface)); color: var(--ev);
}
.wk-ico svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wk-text { min-width: 0; display: grid; gap: 2px; }
.wk-title { font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.25; overflow-wrap: break-word; hyphens: auto; }
.wk-time {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px;
  font-size: 12.5px; font-weight: 500;
  color: color-mix(in srgb, var(--ev) 78%, var(--ink));
  font-variant-numeric: tabular-nums;
}
.wk-time .clk { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.wk-loc { color: var(--muted); font-size: 12.5px; }
.wk-time.overdue { color: var(--error); font-weight: 600; }
.wk-card.status-cancelled .wk-title { text-decoration: line-through; color: var(--muted); }
.wk-card.status-done { opacity: .6; }
.wk-col .wk-ico { width: 32px; height: 32px; border-radius: 10px; }
.wk-col .wk-ico svg { width: 18px; height: 18px; }
.wk-col .wk-loc { display: none; }

/* Task: round checkbox in the category colour */
.wk-task {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 6px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.wk-check {
  flex: none; width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; border-radius: 50%;
}
.wk-check svg {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--ev); padding: 2px;
  fill: none; stroke: transparent; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  transition: background .15s, stroke .15s;
}
.wk-check:hover svg { background: color-mix(in srgb, var(--ev) 14%, transparent); }
.wk-check[aria-checked="true"] svg { background: var(--ev); stroke: #fff; }
.wk-task-body {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; cursor: pointer;
  display: grid; gap: 1px; padding: 4px 0;
}
.wk-task-body .wk-time { color: var(--muted); }
.wk-task.is-done .wk-title { text-decoration: line-through; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .wk-check svg { transition: none; } }

/* Narrow: day strip + the chosen day's timeline */
.wk-strip {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--surface); border-radius: var(--radius-l); padding: 10px 6px 8px;
  margin-bottom: 12px;
}
.wk-pick {
  border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px 0;
}
.wk-pick .wk-num { width: 42px; height: 42px; font-size: 17px; background: var(--bg); }
.wk-pick.is-today .wk-num { color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.wk-pick.is-sel .wk-num { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.wk-pick.is-sel .wk-dow { color: var(--ink); font-weight: 700; }
.wk-pick i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.wk-pick i.has { background: var(--accent); }

.wk-day { background: var(--surface); border-radius: var(--radius-l); padding: 16px 14px 18px; }
.wk-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.wk-day-head h2 { margin: 0; font-family: var(--font-round); font-size: 1.35rem; display: grid; line-height: 1.15; }
.wk-day-head h2 span { font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--muted); }
.wk-day-head p { margin: 0; font-size: 13px; color: var(--muted); text-align: right; }
.wk-empty { color: var(--muted); margin: 18px 0 6px; }

.tl { display: grid; }
.tl-row {
  display: grid; grid-template-columns: 58px 1fr; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.tl-time { display: grid; align-content: start; font-variant-numeric: tabular-nums; padding-top: 4px; }
.tl-time b { font-size: 15px; }
.tl-time span { font-size: 12.5px; color: var(--muted); }
.tl-cards { display: grid; gap: 8px; min-width: 0; }
.wk-card.pill {
  border-radius: 28px; padding: 8px 14px 8px 8px;
  border: 1px solid color-mix(in srgb, var(--ev) 32%, transparent);
}
.wk-card.pill .wk-ico { width: 44px; height: 44px; border-radius: 50%; }
.wk-card.pill .wk-title { font-size: 15px; }

/* Tasks shown in the other views */
.fc .pc-ev.is-task .fc-event-title::before,
.fc .pc-ev.is-task .fc-list-event-title a::before { content: "\25CB\00a0"; font-weight: 700; color: var(--ev); }
.fc .pc-ev.is-task.status-done .fc-event-title::before,
.fc .pc-ev.is-task.status-done .fc-list-event-title a::before { content: "\2713\00a0"; }


/* ---------- Year planner (Mac, iPad landscape) ---------- */
body.year-linear .cal-wrap { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.year { flex: 1; min-width: 0; }
.year[hidden] { display: none; }
.yr-grid {
  --label: 108px;
  background: var(--surface);
  border-radius: var(--radius-l);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.yr-row {
  display: grid;
  grid-template-columns: var(--label) repeat(37, minmax(26px, 1fr));
  min-width: calc(var(--label) + 37 * 26px);
  position: relative;
}
.yr-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.yr-dow { grid-row: 1; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 0 8px; }
.yr-dow.we { color: var(--accent); }
.yr-month { border-bottom: 1px solid var(--line); }
.yr-label {
  grid-column: 1; grid-row: 1 / -1;
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  padding: 5px 10px 0 14px;
  font-family: var(--font-round); font-weight: 700; font-size: 14px;
  border-right: 1px solid var(--line);
}
.yr-month.is-now .yr-label { color: var(--accent); }

/* Day cells fill the whole month row; bars sit on top of them. */
.yr-cell {
  grid-row: 1 / -1;
  border: 0; border-left: 1px solid var(--line);
  background: transparent;
  padding: 4px 0 0; margin: 0;
  display: flex; justify-content: center; align-items: flex-start;
  font: 500 12px/1 var(--font); color: var(--ink);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.yr-cell span { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 999px; }
.yr-cell.we { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.yr-cell.out { background: color-mix(in srgb, var(--ink) 5%, var(--surface)); cursor: default; }
.yr-cell.past span { color: var(--muted); }
.yr-cell:hover:not(.out) { background: var(--accent-soft); }
.yr-cell.is-today { background: var(--accent-soft); }
.yr-cell.is-today span { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.yr-bar {
  z-index: 1;
  margin: 2px 1px;
  min-width: 0;
  height: 18px;
  border: 0; border-radius: 9px;
  padding: 0 6px;
  font: 600 11px/18px var(--font);
  text-align: left; white-space: nowrap; overflow: hidden;
  cursor: pointer;
}
.yr-bar span { display: block; overflow: hidden; text-overflow: ellipsis; }
/* Multi-day: solid category colour, as in a wall planner */
.yr-bar.multi { background: var(--ev); color: #fff; }
.yr-bar.multi.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.yr-bar.multi.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
/* One day: a soft chip */
.yr-bar.single {
  background: color-mix(in srgb, var(--ev) 20%, var(--surface));
  color: color-mix(in srgb, var(--ev) 70%, var(--ink));
  padding: 0 3px;
  border-radius: 6px;
  text-overflow: clip;
}
.yr-bar.single span { text-overflow: clip; }
.yr-bar:hover { filter: brightness(.95); }
.yr-bar.status-cancelled span { text-decoration: line-through; opacity: .75; }
.yr-bar.status-done { opacity: .55; }


/* ---------- hover card ---------- */
.hovercard {
  position: fixed; z-index: 70; pointer-events: none;
  width: max-content; min-width: 220px; max-width: 360px;
  background: var(--surface); color: var(--ink);
  border-radius: 16px; padding: 12px 14px 12px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--ev);
  box-shadow: 0 14px 36px rgba(20, 30, 60, .18);
  font-size: 13px; line-height: 1.35;
  display: grid; gap: 6px;
}
.hovercard[hidden] { display: none; }
.hc-kind { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: color-mix(in srgb, var(--ev) 75%, var(--ink)); }
.hc-kind i { width: 8px; height: 8px; border-radius: 50%; background: var(--ev); flex: none; }
.hc-flag { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: 11px; }
.hc-title { font-size: 15px; font-family: var(--font-round); line-height: 1.25; }
.hc-line { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start; color: var(--muted); }
.hc-line span { color: var(--ink); }
.hc-line svg { width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- dialogs ---------- */
dialog.sheet {
  border: 0;
  padding: 18px 20px 22px;
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  width: min(440px, calc(100vw - 32px));
  max-height: min(80dvh, 720px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(10, 16, 24, .28);
}
dialog.sheet::backdrop { background: rgba(10, 16, 24, .35); }
dialog.sheet.narrow { width: min(420px, calc(100vw - 32px)); }

/* Wide screens: event details slide in as a side panel. */
@media (min-width: 900px) {
  dialog#detail {
    margin: 0 0 0 auto;
    height: 100dvh;
    max-height: 100dvh;
    width: 400px;
    border-radius: 0;
    padding-top: max(18px, env(safe-area-inset-top));
    box-shadow: -12px 0 40px rgba(10, 16, 24, .18);
  }
  dialog#detail::backdrop { background: rgba(10, 16, 24, .12); }
}

/* Phones: dialogs are bottom sheets. */
@media (max-width: 600px) {
  dialog.sheet, dialog.sheet.narrow {
    margin: auto 0 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    max-height: 88dvh;
  }
}

.sheet-head { display: flex; align-items: flex-start; gap: 10px; }
.sheet-head h2 {
  flex: 1;
  margin: 8px 0 0;
  font-family: var(--font-round);
  font-size: 1.35rem;
  line-height: 1.2;
}
.sheet-head .icon-btn { margin: -4px -8px 0 0; flex: none; }
.swatch { width: 14px; height: 14px; border-radius: 4px; margin-top: 13px; flex: none; }
.d-when { margin: 8px 0 16px; font-weight: 500; }

.facts { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px 12px; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 13.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { color: var(--focus); text-decoration: none; }
.facts a:hover { text-decoration: underline; }
.facts .notes { white-space: pre-wrap; }
.facts .links { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }

.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0 16px; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
input[type="url"], input[type="password"], input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: 16px var(--font); /* 16px stops iOS zooming in */
}
.form-msg { min-height: 1.4em; font-size: 13.5px; color: var(--muted); margin: 0 0 10px; }
.form-msg.error { color: var(--error); }
.actions { display: flex; justify-content: flex-end; }

.primary {
  min-height: var(--tap);
  padding: 0 22px;
  border-radius: 22px;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
}
.primary:disabled { opacity: .5; cursor: progress; }

/* ---------- toast ---------- */
.toast {
  --accent: var(--ink); --on-accent: var(--surface);
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: min(520px, calc(100vw - 32px));
  z-index: 60;
  box-shadow: 0 10px 30px rgba(10, 16, 24, .25);
}

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .rail { width: 280px; }
}

@media (max-width: 860px) {
  /* 3 Months: agenda goes below the months */
  body[data-view="threeMonths"] .main { flex-direction: column; }
  body[data-view="threeMonths"] .cal-wrap { flex: none; }
  .rail { width: auto; position: static; max-height: none; align-self: stretch; }
}

@media (max-width: 600px) {
  .top-row.second { margin-top: 4px; }
  .views { width: 100%; }
  .views button { flex: 1; padding: 0 4px; font-size: 13.5px; }
  .views .long { display: none; }
  .views .short { display: inline; }
  .legend { display: none; }
  .panel-btn { margin-left: auto; min-height: 34px; font-size: 13.5px; }
  .fc-threeMonths-view .fc-daygrid-event .fc-event-time { display: none; }
  .fc-threeMonths-view .fc-daygrid-event { font-size: 11px; padding: 1px 2px; }
  .fc-threeMonths-view .fc-daygrid-day-frame { min-height: 5em; }
  .main { padding-top: 8px; padding-left: 8px; padding-right: 8px; }
  .nav { gap: 0; }
  .today-btn { padding: 0 11px; }
  .title { font-size: 1.4rem; }
  .icon-btn { width: 36px; }
  .today-btn { height: 32px; font-size: 13.5px; }
  .fc .fc-list-event td { padding: 12px 10px; }
  .fc-multiMonthYear-view .fc-multimonth-month { padding: 0 4px 10px; }
  .fc-multiMonthYear-view .fc-multimonth-header-table .fc-col-header-cell-cushion { font-size: 9.5px; }
  .fc-multiMonthYear-view .fc-daygrid-day-number { font-size: 11px; padding: 1px 2px; }
  .fc .fc-list-event-time { width: 5.5em; }
}

/* Headings that receive focus when a sheet opens don't need a ring. */
h2[tabindex="-1"]:focus { outline: none; }

/* ---------- add, edit and delete (Phase 3b) ---------- */
.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.add-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.add-btn:hover { filter: brightness(1.06); }
@media (max-width: 600px) { .add-btn span { display: none; } .add-btn { padding: 0; width: 36px; justify-content: center; } }

.ghost {
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.ghost:hover { background: var(--hover); }
.danger-link {
  min-height: var(--tap);
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--error);
  font-weight: 600;
  cursor: pointer;
}
.spacer { flex: 1; }
.detail-actions { gap: 6px; margin-top: 18px; align-items: center; }

dialog.editor form { display: block; }
dialog.editor .sheet-head h2 { margin-bottom: 14px; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.seg button {
  min-height: 36px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(10, 16, 24, .12); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row2 label select, .row2 label input { min-width: 0; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
label select, label textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: 16px var(--font);
}
label textarea { min-height: 0; resize: vertical; }
input[type="date"], input[type="time"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: var(--tap);
  padding: 0 8px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: 16px var(--font);
  -webkit-appearance: none;
  appearance: none;
}
label.switch { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; cursor: pointer; }
label.switch input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
label[hidden] { display: none; }
.time input { max-width: 100%; }

fieldset.chips {
  border: 0;
  padding: 0;
  margin: 0 0 14px;
  min-width: 0;
}
fieldset.chips legend { font-weight: 600; font-size: 13.5px; padding: 0; margin-bottom: 6px; }
.chip-opt {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0 6px 6px 0;
  padding: 0 12px;
  border-radius: 17px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
}
.chip-opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.choice .choice-actions { display: grid; gap: 8px; margin-top: 14px; }
.choice-btn {
  min-height: var(--tap);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.choice-btn.is-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.choice-btn.danger { color: var(--error); }
.choice-btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.choice h2 { font-family: var(--font-round); margin: 4px 0 6px; font-size: 1.25rem; }

.toast { display: flex; align-items: center; gap: 14px; }
.toast-action {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 2px;
}

/* The hidden attribute must win over layout rules such as display: grid. */
[hidden] { display: none !important; }
.hint.small { font-size: 12px; margin: 4px 0 0; display: block; }

/* ---------- custom repeat builder ---------- */
fieldset.rule {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 10px 12px 12px;
  margin: 0 0 16px;
  min-width: 0;
  background: var(--bg);
}
fieldset.rule legend { font-weight: 600; font-size: 13.5px; padding: 0 4px; }
.rule-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 10px; font-size: 14.5px; }
.rule-part { margin: 2px 0 10px; }
.rule-label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.rule select, .rule input[type="number"], .rule input[type="date"] {
  height: 38px;
  padding: 0 8px;
  border-radius: var(--radius-s, 8px);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: 16px var(--font);
  min-width: 0;
}
.rule input[type="number"] { width: 4.5em; }
.rule input[type="date"] { margin: 0; }
.rule .rule-count input { width: 4.5em; }
.rule-count { display: inline-flex; align-items: center; gap: 6px; }
.dow-row { display: flex; gap: 6px; flex-wrap: wrap; }
.dow {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.dow[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.rule label.radio {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0 0 10px;
  font-size: 14.5px;
}
.rule label.radio input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.rule-summary { margin: 2px 0 0; font-weight: 600; color: var(--accent); font-size: 14px; }

/* ---------- Year view: move between years ---------- */
.yr-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 12px; }
.yr-year { margin: 0; font-family: var(--font-round); font-size: 1.5rem; min-width: 4em; text-align: center; }
.yr-step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.yr-step:hover { background: var(--hover); }

/* ---------- public holidays: light red days ---------- */
:root { --holiday-bg: #FDE9E8; --holiday-ink: #B42318; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --holiday-bg: #3B2024; --holiday-ink: #FCA5A5; }
}
:root[data-theme="dark"] { --holiday-bg: #3B2024; --holiday-ink: #FCA5A5; }

.fc-daygrid-day.is-holiday,
.fc-col-header-cell.is-holiday,
.fc-timegrid-col.is-holiday .fc-timegrid-col-bg,
.wk-col.is-holiday,
.wk-pick.is-holiday,
.yr-cell.is-holiday { background-color: var(--holiday-bg) !important; }
.fc-daygrid-day.is-holiday .fc-daygrid-day-number,
.wk-col.is-holiday .wk-num,
.wk-pick.is-holiday .wk-num,
.yr-cell.is-holiday span { color: var(--holiday-ink); font-weight: 700; }

/* 3 Months events list: a thin line between days. */
#rail-list > .rail-day:not(:first-child) { border-top: 1px solid var(--line-strong); margin-top: 12px; padding-top: 12px; }

/* ---------- Phase 3c: filters, search, shortcuts, offline, year counts, accessibility ---------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Colour key: categories are buttons that show or hide their events */
.key-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 8px;
  margin: 0 -4px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.key-btn:hover { background: var(--hover); }
.key-btn i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.key-btn[aria-pressed="false"] { color: var(--muted); }
.key-btn[aria-pressed="false"] i { opacity: .3; }
.key-btn[aria-pressed="false"] span { text-decoration: line-through; text-decoration-thickness: 1px; }

#legend { flex: 1; justify-content: flex-end; }


/* Header buttons: search and filters */
.filter-btn { position: relative; }
.filter-btn.is-filtered { color: var(--accent); }
.filter-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* Offline banner */
.offline {
  margin: 0;
  padding: 7px var(--gutter);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}

/* Search and filter sheets */
.search-field { display: block; margin-top: 4px; }
.search-field input[type="search"] {
  display: block;
  width: 100%;
  min-height: var(--tap);
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 58vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.result {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 6px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.result:first-child { border-top: 0; }
.result:hover, .result:focus-visible { background: var(--hover); }
.r-title { font-weight: 600; font-size: 15px; }
.r-when { color: var(--muted); font-size: 13.5px; }
.r-meta { color: var(--muted); font-size: 12.5px; }

fieldset.checks {
  border: 0;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 0;
  min-width: 0;
}
fieldset.checks legend { font-weight: 600; font-size: 13.5px; padding: 0; margin-bottom: 4px; }
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  font-size: 15px;
  cursor: pointer;
}
.check input[type="checkbox"] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }

/* Keyboard shortcut list */
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 12px 18px; margin: 14px 0 0; align-items: baseline; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; font-size: 15px; }
kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 600 13px var(--font);
  text-align: center;
}

/* Keyboard focus is always visible, including on dark backgrounds */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.result:focus-visible, .key-btn:focus-visible { outline-offset: -2px; }

/* Small screens: a bit more room for tap targets in the sheets */
@media (max-width: 600px) {
  .key-btn { min-height: var(--tap); }
  .keys { grid-template-columns: 1fr; gap: 4px 0; }
  .keys dt { margin-top: 10px; }
  .keys dt:first-child { margin-top: 0; }
  .keys dd { padding-bottom: 2px; border-bottom: 1px solid var(--line); }
}

/* Header buttons meet the 44px tap target */
.today-btn, .add-btn { min-height: var(--tap); }
@media (max-width: 600px) {
  .add-btn { width: var(--tap); }
}

/* Phone: New becomes a round button in the corner, so the header keeps room for the title */
@media (max-width: 600px) {
  .add-btn {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 20;
    width: 56px;
    height: 56px;
    min-height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(20, 30, 60, .22);
  }
  .add-btn svg { width: 24px; height: 24px; }
}

/* Phone: the title gets its own line so it is never cut short */
@media (max-width: 600px) {
  .top-row:not(.second) { flex-wrap: wrap; row-gap: 2px; }
  .top-row:not(.second) .title { flex: 1 0 100%; }
  .top-row:not(.second) .nav { margin-left: auto; }
}

/* Year line: < 2026 > on the left, All day and Timed tick boxes justified right (both Year layouts) */
.year-bar { display: none; }
body[data-view="multiMonthYear"] .year-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px var(--gutter) 0;
}
.year-checks { display: flex; gap: 16px; margin-left: auto; }
.tick { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tick input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
