/* pages/calendar.css — /calendar/ (spec §5.5).
 *
 * PAGE-SCOPE RULE (§1.1, test_design check 9): every selector starts with a
 * class this file owns — `.cal*`, `.allday`, `.evblk*`, `.reach*`, `.cal-layout`,
 * `#event-detail` — or with [data-page="calendar"]. All eleven page files load
 * on every page.
 *
 * THE PAGE: a week grid filling the pane, and an event SHEET that is drawn only
 * while it holds a card. The grid's fixed top (`.cal__top`: the week head and
 * the day names) is the card's own colour, no wash and no lip (2026-10-02:
 * "seamless"); the
 * all-day row below it is pinned CONTENT on the plain ground (K48); the hours
 * scroll under a 40px fade (app.css lists `.cal__body`).
 *
 * ⚠️ THE WHOLE WEEK AT EVERY WIDTH. A phone three-day window was tried and
 * overturned — the columns narrow, there are still seven (K33).
 *
 * ⚠️ MONOCHROME (K22): blocks and all-day chips are grey with a 3px edge in
 * their CALENDAR's colour (`--cal-color`, set inline by the server); the today
 * disc is the grey selected step. No other accent, and no today-column tint.
 */

/* ── The page frame ───────────────────────────────────────────────────────
   The pane gives up its padding: the grid's top runs edge to edge. */
[data-page="calendar"].pane { padding: 0; }
[data-page="calendar"] .pane__body > .notices { margin: var(--app-viewpad) var(--app-viewpad) 0; }

.cal-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.cal {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── The fixed top: the week head and the day names, on the card ────────── */
.cal__top {
  flex: none;
  position: relative;
  z-index: 1;
  background: var(--md-sys-color-surface);
  padding: var(--app-viewpad) var(--md-sys-spacing-100) 0;
}

/* The head is SHOWN (K26): it carries the week's range, the calendar count
   and the week nav. app.css gives .head--shown its flex row. */
/* No wrap: the nav never drops onto a second row; on a narrow phone the TITLE
   wraps. (0,1,0) like app.css's `.head--shown`, and this file loads later. */
.cal__head {
  padding: 0 var(--md-sys-spacing-100) var(--md-sys-spacing-150);
  justify-content: space-between;
  flex-wrap: nowrap;
}
.cal__head > div:first-child { min-width: 0; }
.cal__title {
  margin: 0;
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-brand);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  font-weight: var(--md-sys-typescale-title-large-weight);
  font-variation-settings: "ROND" 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal__head .head__sub {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-weight: var(--md-sys-typescale-body-medium-weight);
}
/* The nav: the week group (‹ Today ›), then New event — outlined, so it reads
   as the one control here that MAKES something rather than moves the view. */
.cal__nav { flex: none; display: flex; align-items: center; gap: var(--md-sys-spacing-150); }

/* The count is the calendars menu's trigger: still the head's supporting
   line to look at, plus the chevron every menu trigger wears, turning over
   while the menu is open. Its 48px target height is a transparent border on
   the 20px line (§0, never a pseudo-element), given back by margins so
   the head's two lines do not move. An inline BLOCK, not a flex row: where
   the column is too narrow for one line (a 360px phone) the words wrap from
   the start edge and the chevron follows the last one. */
.cal__cals {
  display: inline-block;
  max-width: 100%;
  margin: -14px 0;
  text-align: start;
  padding: 0;
  border: solid transparent;
  border-width: 14px 0;
  border-radius: var(--md-sys-shape-corner-medium);
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cal__calsend { white-space: nowrap; }
.cal__calsend > .ico { --_icon: var(--app-icon-size-medium); --_opsz: 20; vertical-align: top; }
@media (hover: hover) {
  .cal__cals:hover { color: var(--md-sys-color-on-surface); }
}
/* The count of the calendar whose menu is open — the PANE's, by the menu's
   class: a split may hold two calendars, the second menu carries an id of its
   own (calgrid.js ownMenus), and `<main>` holds both. */
[data-page="calendar"].pane:has(.cal__menu:popover-open) .cal__cals { color: var(--md-sys-color-on-surface); }
[data-page="calendar"].pane:has(.cal__menu:popover-open) .cal__calsend > .ico { rotate: 180deg; }
@media (prefers-reduced-motion: no-preference) {
  .cal__cals { transition: color var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects); }
  .cal__calsend > .ico { transition: rotate var(--md-sys-motion-spring-fast-spatial-duration) var(--md-sys-motion-spring-fast-spatial); }
}

/* ── The calendars menu: #cal-menu.m3-menu.cal__menu (index.html) ─────────
   The M3 menu (m3.css §3.12) as a native popover, placed by calgrid.js under
   the count. Each row: the calendar's colour as a DOT — the one shape its
   colour may fill beside a name (K22) — the name, and a checkbox. */
.cal__menu {
  position: fixed;
  inset: auto;                             /* the UA's popover inset 0 + margin auto would centre it */
  margin: 0;
  border: 0;
  width: min(280px, 100vw - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
/* ⚠️ .m3-menu's `display: flex` is AUTHOR CSS, and any author rule beats the
   UA's `[popover]:not(:popover-open) { display: none }` — without this the
   closed menu would be drawn, unplaced, on every page load. */
.cal__menu:not(:popover-open) { display: none; }
.cal__menuitem { cursor: pointer; }
.cal__dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-inline: 4px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--cal-color, var(--md-sys-color-outline));
}
.cal__menuname {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cal__menuempty {
  padding: 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
@media (prefers-reduced-motion: no-preference) {
  /* Closing is instant: m3.css also transitions `display`, which would hold
     the closed menu on screen, out of the top layer, under the sheet. */
  .cal__menu { transition-property: scale, opacity; }
}

/* The day names. The same columns as the all-day row and the hours. */
.cal__days, .cal__allday, .cal__body {
  display: grid;
  grid-template-columns: 44px repeat(7, minmax(0, 1fr));
}
.cal__dayhead {
  display: grid;
  justify-items: center;
  gap: var(--md-sys-spacing-50);
  padding: var(--md-sys-spacing-100) 0;
  min-width: 0;
}
.cal__dow {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
}
.cal__dom {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-large-increased);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-brand);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  font-weight: var(--md-sys-typescale-title-large-weight);
  font-variant-numeric: tabular-nums;
}
/* Today: the grey selected step, emphasized. No accent (K22). */
.cal__dayhead.is-today .cal__dom {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: var(--md-sys-typescale-emphasized-title-large-weight);
  font-variation-settings: "ROND" var(--md-sys-typescale-emphasized-rond);
}
.cal__dayhead.is-today .cal__dow { color: var(--md-sys-color-on-surface); }

/* ── The all-day row: pinned CONTENT, not the fixed top (K48) ─────────────
   Between the fixed top and the hours, on the plain ground, so it stays put
   while the hours scroll; a 1px hairline under it separates the chips from the
   hours ("there needs to be a seperation line below the whole day tasks").
   An empty week draws it at its padding only. */
.cal__allday {
  flex: none;
  padding: var(--md-sys-spacing-50) var(--md-sys-spacing-100) var(--md-sys-spacing-100);
  background: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--app-color-hairline);
}
.cal__alldaycol {
  display: grid;
  gap: var(--md-sys-spacing-25);
  align-content: start;
  min-width: 0;
  padding: 0 var(--md-sys-spacing-25);
}
.allday {
  --_state-color: var(--md-sys-color-on-surface);
  --_container: var(--md-sys-color-surface-container-highest);   /* a resting fill, never the selected role (D2) */
  --_fill: 0;
  box-sizing: border-box;
  display: block;
  height: 24px;
  min-width: 0;
  margin: 0;
  padding: 0 var(--md-sys-spacing-100);
  border: 0;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state, 0%), var(--_container));
  box-shadow: inset 3px 0 0 var(--cal-color, transparent);
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: 24px;
  font-weight: var(--md-sys-typescale-label-medium-weight);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
@media (hover: hover) {
  .allday:hover { --_state: var(--md-sys-state-hover-state-layer-opacity); }
}
.allday:focus-visible { --_state: var(--md-sys-state-focus-state-layer-opacity); }
.allday:active { --_state: var(--md-sys-state-pressed-state-layer-opacity); }
@media (prefers-reduced-motion: no-preference) {
  .allday {
    transition: background-color var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects);
  }
}

/* ── The hours ────────────────────────────────────────────────────────────
   The body is the one vertical scroller (a 40px fade, listed in app.css). Its
   8px top padding keeps the "00" label from clipping; its end reserve clears
   the FAB. calgrid.js opens it at 07:00 and keeps the hour across swaps. */
.cal__body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: var(--md-sys-spacing-100) var(--md-sys-spacing-100) var(--fabreach);
}
.cal__hours { position: relative; min-width: 0; }
.cal__hour {
  display: block;
  height: var(--hour-px);
  padding-inline-end: var(--md-sys-spacing-100);
  text-align: end;
  translate: 0 -8px;                      /* the label sits ON its hour line */
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line-height);
  font-weight: var(--md-sys-typescale-label-small-weight);
  font-variant-numeric: tabular-nums;
}

/* ⚠️ THE COLUMN IS EXACTLY 24 × --hour-px TALL. calgrid.js turns pixels into
   minutes as column height / 1440, so no vertical padding or border here; the
   slot's own line stays inside its border-box. The lines are the hairline
   (they were the fixed top's tone, DM L6882, and kept it when the top took the
   card's colour). The "today" tint is gone (K22). */
.cal__col {
  position: relative;
  min-width: 0;
  border-left: 1px solid var(--app-color-hairline);
  touch-action: none;                    /* a mouse or pen draws a new event here */
}
.cal__slot {
  box-sizing: border-box;
  height: var(--hour-px);
  border-bottom: 1px solid var(--app-color-hairline);
}
/* ⚠️ A FINGER SCROLLS, ON A BLOCK TOO. On touch a vertical swipe over the
   week pans the hours; drag-to-create is a mouse and pen gesture (calgrid.js
   ignores touch on empty space, or the pan would cancel the pointer and leave
   a ghost behind). A block is pan-y as well: at 360-412 the blocks cover much
   of each column, and a block that took every touch made an ordinary scroll
   MOVE an event (a POST to Google). A finger drags a block only after a hold
   (calgrid.js's HOLD_MS), which then stops the pan itself. The block's
   selector is (0,2,0) because .evblk's own touch-action: none comes later. */
@media (pointer: coarse) {
  .cal__col, .cal__col > .evblk { touch-action: pan-y; }
  .cal__col > .evblk { -webkit-touch-callout: none; user-select: none; }
}

/* ── Event blocks ─────────────────────────────────────────────────────────
   Grey (#333537) with a 3px edge in the calendar's colour; the outline grey
   when the calendar has none. left/width come from pack(), already including
   any nesting indent; top/height from the server's geometry. */
.evblk {
  --_state-color: var(--md-sys-color-on-surface);
  --_fill: 0;
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  display: grid;
  align-content: start;
  min-width: 0;
  margin: 0;
  padding: var(--md-sys-spacing-25) var(--md-sys-spacing-75) var(--md-sys-spacing-25) 9px;
  border: 0;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state, 0%), var(--md-sys-color-surface-container-highest));
  box-shadow: inset 3px 0 0 var(--cal-color, var(--md-sys-color-outline));
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
  text-align: start;
  cursor: pointer;
  touch-action: none;                    /* pointer drags (calgrid.js); pan-y on touch, below */
  /* Its own width decides whether the time fits (the rule after .evblk--slim):
     pack() gives every block an explicit width, so the size query is safe. */
  container: evblk / inline-size;
}
.evblk[data-event-id] { cursor: grab; }
/* A nested block sits ON TOP of its host — containment is not a clash. A
   1px line of the ground separates the two. */
.evblk.is-nested { outline: 1px solid var(--md-sys-color-surface); outline-offset: 0; }
/* THE OPEN ONE: the event the sheet is showing (calgrid.js sets .is-open and
   keeps it across grid repaints). An inner 2px ink line, no accent (K22); the
   keyboard ring takes its place while the block has focus. */
:is(.evblk, .allday).is-open:not(:focus-visible) {
  --_state: var(--md-sys-state-hover-state-layer-opacity);
  outline: 2px solid var(--md-sys-color-on-surface);
  outline-offset: -2px;
}
@media (hover: hover) {
  .evblk:hover { --_state: var(--md-sys-state-hover-state-layer-opacity); }
}
.evblk:active { --_state: var(--md-sys-state-pressed-state-layer-opacity); }
.evblk:focus-visible {
  --_state: var(--md-sys-state-focus-state-layer-opacity);
  outline: var(--app-focus-ring);
  outline-offset: -3px;                  /* inner: the body scroller would clip an outer ring */
}
.evblk__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--md-sys-typescale-label-medium-weight);
}
.evblk__time {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-small-size);
  line-height: var(--md-sys-typescale-label-small-line-height);
  font-weight: var(--md-sys-typescale-label-small-weight);
  font-variant-numeric: tabular-nums;
}
/* Too short for the stacked form: title and time go side by side, or the time
   is clipped off the bottom. */
.evblk--slim {
  grid-auto-flow: column;
  justify-content: start;
  align-items: baseline;
  column-gap: var(--md-sys-spacing-50);
}
/* ⚠️ THE BLOCK'S WIDTH, NOT THE WINDOW'S, DROPS THE TIME. At 721-839 (and in
   a split, or beside a clash) a block is ~80px: side by side, the time ate the
   title ("Lu… 11:4"). A slim block whose CONTENT box is under 112px (about
   127px drawn: 721-1199, a docked sheet, a split) keeps only its title, which
   matters more, since the grid already places the time; a tall one keeps its
   time on its own line until it cannot hold "00:00". */
@container evblk (max-width: 112px) {
  .evblk--slim .evblk__time { display: none; }
}
@container evblk (max-width: 48px) {
  .evblk__time { display: none; }
}

/* ⚠️ THE BOTTOM 8px RESIZES rather than moves (calgrid.js's HANDLE_PX = 8).
   The cursor is the only thing that says so, so it has to. */
.evblk::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  cursor: ns-resize;
}
.evblk:not([data-event-id])::after { display: none; }
.evblk.is-moving, .evblk.is-resizing {
  --_state: var(--md-sys-state-dragged-state-layer-opacity);
  z-index: 5;
  cursor: grabbing;
  box-shadow: inset 3px 0 0 var(--cal-color, var(--md-sys-color-outline)), var(--md-sys-elevation-level3);
}
/* What a new event looks like while it is being drawn: a solid block, the one
   it becomes (DM L2770). No dash and no blue. */
.evblk--ghost {
  left: 0;
  width: 100%;
  padding: 0;
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: inset 3px 0 0 var(--md-sys-color-outline), var(--md-sys-elevation-level3);
  pointer-events: none;
  z-index: 5;
}
@media (prefers-reduced-motion: no-preference) {
  .evblk {
    transition-property: background-color, box-shadow;
    transition-duration: var(--md-sys-motion-spring-fast-effects-duration), var(--md-sys-motion-spring-fast-effects-duration);
    transition-timing-function: var(--md-sys-motion-spring-fast-effects), var(--md-sys-motion-spring-fast-effects);
  }
}

/* ── Phone (≤720) ──────────────────────────────────────────────────────────
   A 32px gutter, a 32px date disc, and the M3 floor of 11px for the hours and
   the blocks (the tier's 9 and 9.5 are gone). The block hides its time. */
@media (max-width: 720px) {
  .cal__days, .cal__allday, .cal__body { grid-template-columns: 32px repeat(7, minmax(0, 1fr)); }
  .cal__hour { padding-inline-end: var(--md-sys-spacing-50); }
  .cal__dom {
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-large);
    font-size: var(--md-sys-typescale-title-medium-size);
    line-height: var(--md-sys-typescale-title-medium-line-height);
    font-weight: var(--md-sys-typescale-title-medium-weight);
  }
  .cal__dayhead.is-today .cal__dom { font-weight: var(--md-sys-typescale-emphasized-title-medium-weight); }
  .cal__alldaycol { padding: 0 1px; }
  .allday {
    padding: 0 var(--md-sys-spacing-50) 0 6px;
    font-size: var(--md-sys-typescale-label-small-size);
    font-weight: var(--md-sys-typescale-label-small-weight);
  }
  .evblk {
    padding: 1px var(--md-sys-spacing-25) 1px 6px;
    font-size: var(--md-sys-typescale-label-small-size);
    line-height: var(--md-sys-typescale-label-small-line-height);
    font-weight: var(--md-sys-typescale-label-small-weight);
  }
  .evblk__title { font-weight: var(--md-sys-typescale-label-small-weight); }
  .evblk__time { display: none; }
}
/* The week's range would push the nav onto a second line on a phone; the
   title steps down one role there instead, so the head stays one row, and on
   the narrowest phones the range itself wraps (balanced) beside the nav.
   New event made the nav 52px wider, so here its gaps step to 8 (M3's own
   group gap for the larger sizes; the 48px targets still meet, never
   overlap) and the head's to 8: the range's "4 Oct 2026" stays whole at 360
   and "10 of 11 calendars" stays one line at 412. */
@media (max-width: 480px) {
  .cal__title {
    font-size: var(--md-sys-typescale-title-medium-size);
    line-height: var(--md-sys-typescale-title-medium-line-height);
    font-weight: var(--md-sys-typescale-title-medium-weight);
    white-space: normal;
    text-wrap: balance;
  }
  .cal__head { column-gap: var(--md-sys-spacing-100); }
  .cal__nav, .cal__week { gap: var(--md-sys-spacing-100); }
}

/* ── The event sheet: #event-detail.cal__detail.m3-sheet ──────────────────
   NOT a .split__detail: reading mode hid that at ≤839px and no calendar
   fragment enters it, so the event could not be seen on a phone or at
   721–839. It is a NON-MODAL sheet (no scrim, K3): docked beside the grid in
   a pane ≥1080px, floating over it in a narrower one, rising from the bottom
   on a phone (≤720). With
   no card in it, it is not drawn at all — the grid is the page. A scroller
   with no mask: it paints its own ground (app.css hides its bar). */
#event-detail:not(:has(> .card-detail)) { display: none; }
#event-detail {
  --_padb: var(--md-sys-spacing-300);    /* the bottom padding, which the pinned actions cover */
  padding: var(--md-sys-spacing-300);
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--md-sys-color-surface-container-low);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#event-detail > .card-detail { flex: none; }

/* ⚠️ THE PANE'S WIDTH DECIDES, NOT THE WINDOW'S. In a split the calendar may
   have 480–900px of a wide screen: a viewport rule docked a 360px sheet in a
   648px pane (seven 28px columns, the date discs colliding) and, at 721–1199,
   floated a viewport-fixed sheet over the OTHER pane. So above the phone the
   pane body is a size container and the dock and the float ask it. 1080px is
   the unsplit pane at a 1200px window (§5.5's breakpoint). The phone's bottom
   sheet stays a viewport rule: there is no split there. */
@media (min-width: 721px) {
  [data-page="calendar"].pane > .pane__body { container: cal / inline-size; }
}

/* A pane ≥1080: docked side sheet, a second column of the layout. */
@container cal (min-width: 1080px) {
  .cal-layout:has(#event-detail > .card-detail) {
    grid-template-columns: minmax(0, 1fr) 360px;
    column-gap: var(--md-sys-spacing-200);
    padding-right: var(--md-sys-spacing-200);
  }
  /* ⚠️ THE SHEET ENDS ABOVE THE FAB, it does not scroll under it. With the
     reserve as padding, a form taller than the sheet (the drop's notice plus
     the reach radios, at 1440×900) rested with Save under the 80px FAB, and
     a click on Save hit the FAB. As a margin, nothing in the sheet can sit
     in the FAB's corner. */
  #event-detail {
    width: auto;
    min-height: 0;
    margin: var(--app-viewpad) 0 calc(var(--app-viewpad) + var(--fabreach));
    box-shadow: none;
  }
}
/* A narrower pane: floating (M3's detached side sheet, without its scrim),
   INSIDE the calendar's own box, so in a split it never covers the other
   pane. It starts below the week head (16 + the nav's 48px row + 16), so ‹
   Today › stay usable while an event is open, and it stops above the FAB's
   corner when this pane has the FAB (--fabreach), 16px short otherwise. */
@container cal (max-width: 1079.98px) {
  .cal-layout { position: relative; }
  #event-detail {
    position: absolute;
    right: var(--md-sys-spacing-200);
    top: calc(var(--app-viewpad) + 48px + var(--md-sys-spacing-200));
    bottom: max(var(--md-sys-spacing-200), var(--fabreach));
    z-index: var(--app-z-float);
    width: min(400px, 100% - 32px);
    box-sizing: border-box;
    box-shadow: var(--md-sys-elevation-level3);
  }
}
/* ≤720: the bottom sheet, over the nav bar's top edge, up to 70% of the
   screen. It closes by its button, by the system back (calgrid.js pushes one
   history marker) and by pulling the handle strip down past 64px. */
@media (max-width: 720px) {
  #event-detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--app-navbar-offset);
    z-index: var(--app-z-float);
    max-height: 70dvh;
    --_padb: var(--md-sys-spacing-200);
    padding: var(--md-sys-spacing-600) var(--md-sys-spacing-200) var(--_padb);
    border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
    box-shadow: var(--md-sys-elevation-level1);
  }
  #event-detail::before {
    content: "";
    position: absolute;
    top: 22px;
    left: 50%;
    width: 32px;
    height: 4px;
    translate: -50% 0;
    border-radius: var(--app-shape-corner-mark);
    background: var(--md-sys-color-on-surface-variant);
  }
}
@media (prefers-reduced-motion: no-preference) {
  /* Enters rising 16px and fading in. ⚠️ `display` is NOT in the list: the
     sheet closes by losing its card, which changes no opacity, so a delayed
     display only left the emptied sheet standing for 150ms (at ≥1200 as a
     stray grid row under the week). Closing is instant. */
  #event-detail {
    transition-property: translate, opacity;
    transition-duration: var(--md-sys-motion-spring-default-spatial-duration), var(--md-sys-motion-spring-fast-effects-duration);
    transition-timing-function: var(--md-sys-motion-spring-default-spatial), var(--md-sys-motion-spring-fast-effects);
  }
  @starting-style {
    #event-detail { translate: 0 16px; opacity: 0; }
  }
}

/* The head of every sheet fragment: the close button sits beside the title
   block, top-right, rather than on a row of its own. */
#event-detail .card-detail__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--md-sys-spacing-100);
  row-gap: var(--md-sys-spacing-50);
  align-items: start;
}
#event-detail .card-detail__head > * { grid-column: 1; }
#event-detail .card-detail__head > .cal__close {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  margin-block: -8px;
  margin-inline-end: -12px;
}
.cal__close { margin-inline-start: auto; }
/* calgrid.js parks focus on the title after a tap or click opens the sheet
   (so Escape closes it); a heading is not a control and draws no ring. */
#event-detail .card-detail__head h2[tabindex="-1"]:focus { outline: none; }

/* ── What the sheet holds ──────────────────────────────────────────────── */
/* The calendar, "repeats", "cancelled": label chips (m3.css .field__tag). The
   calendar's chip carries its colour as the same 3px edge as its blocks. */
.cal__tags { display: flex; flex-wrap: wrap; gap: var(--md-sys-spacing-100); }
.cal__tags:not(:has(*)) { display: none; }
.cal__tag { box-shadow: inset 3px 0 0 var(--cal-color, transparent); padding-inline-start: 11px; }
.cal__tag:not([style]) { padding-inline-start: var(--md-sys-spacing-100); }

/* The forms in the sheet: two columns — Title (and Calendar) across, Day
   across, From and To side by side. */
#event-detail .fieldgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#event-detail .fieldgrid__row:has(> [name="day"]) { grid-column: 1 / -1; }

/* The actions: the one filled action at the END, Cancel before it; Remove on
   the far LEFT, away from the FAB's corner. ⚠️ Only the drawn order moves:
   Save/Create stays the first submit button in the markup, because Enter in a
   field "clicks" the first one, and Remove is a submit with its own hx-post. */
.cal__actions { justify-content: flex-end; }
.cal__actions > .m3-btn--filled { order: 1; }
.cal__actions > .cal__remove { order: -1; margin-inline-end: auto; }

/* ⚠️ THE FORM'S ACTIONS ARE PINNED TO THE SHEET'S BOTTOM EDGE (M3's side
   sheet action bar). A drop answers with a notice plus the reach radios, taller
   than the sheet at 1440×900, and Save rested below the fold with nothing to
   say so. The bar is the last child of both forms (edit, new); it sticks over
   the sheet's own bottom padding (--_padb) and its top 20px is a fade, the
   short of the two fade lengths, so what scrolls under it reads as more. */
#event-detail > .card-detail > .cal__actions:last-child {
  position: sticky;
  bottom: calc(-1 * var(--_padb));
  z-index: 1;
  margin: calc(-1 * var(--md-sys-spacing-200)) 0 calc(-1 * var(--_padb));
  padding: 20px 0 var(--_padb);
  background: linear-gradient(transparent, var(--md-sys-color-surface-container-low) 20px);
}

/* Removed: the statement in body-large, the event under it. */
.cal__removed .card-detail__head h2 {
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
  font-variation-settings: "ROND" 0;
}

/* ── The reach picker ─────────────────────────────────────────────────────
   ⚠️ NOTHING IS PRESELECTED, and that is the feature: a default reach is
   either a silent no-op on a hundred future occurrences or an edit to a
   hundred he did not mean. The warning on "this and following" sits inside
   the choice rather than in a dialog — this app does not use those.
   A segmented list (§3.10): each choice a 72px two-line tile, 2px apart, on
   #1E1F20 over the sheet's #1B1B1B; the chosen one the grey selected step. */
.reach {
  display: flex;
  flex-direction: column;
  gap: var(--md-sys-spacing-25);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.reach > legend {
  padding: 0 0 var(--md-sys-spacing-100);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
}
.reach__row {
  --_state-color: var(--md-sys-color-on-surface);
  --_container: var(--md-sys-color-surface-container);
  --_r: var(--md-sys-shape-corner-extra-small);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--md-sys-spacing-200);
  min-height: var(--app-list-h-2);
  padding: var(--md-sys-spacing-100) var(--md-sys-spacing-200) var(--md-sys-spacing-100) 26px;
  border-radius: var(--_r);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state, 0%), var(--_container));
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}
.reach__row:first-of-type { border-start-start-radius: var(--md-sys-shape-corner-large); border-start-end-radius: var(--md-sys-shape-corner-large); }
.reach__row:last-of-type { border-end-start-radius: var(--md-sys-shape-corner-large); border-end-end-radius: var(--md-sys-shape-corner-large); }
@media (hover: hover) {
  .reach__row:hover { --_state: var(--md-sys-state-hover-state-layer-opacity); border-radius: var(--md-sys-shape-corner-medium); }
}
.reach__row:has(> input:checked) {
  --_container: var(--md-sys-color-secondary-container);
  border-radius: var(--md-sys-shape-corner-large);
}
.reach__row:has(> input:focus-visible) { outline: var(--app-focus-ring); outline-offset: -3px; }
.reach__row > input:focus-visible { outline: none; }
.reach__text { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.reach__row b {
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-weight);
}
/* (The chosen row's words are found FROM its radio — `input:checked ~ …` — not
   through the row's :has(): a parent's :has() in front of a subject named only
   by its tag is asked again for every such element written anywhere in the app
   (test_design check 13). `:where()` keeps the weight the :has() spelling had.) */
.reach__row > input:checked ~ :where(.reach__text) b {
  font-weight: var(--md-sys-typescale-emphasized-body-large-weight);
  font-variation-settings: "ROND" var(--md-sys-typescale-emphasized-rond);
}
.reach__row em {
  color: var(--md-sys-color-on-surface-variant);
  font-style: normal;
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-weight: var(--md-sys-typescale-body-medium-weight);
}
/* The chosen row's note brightens, except the warning: it stays red, and it
   matters most exactly when "this and following" is the choice. */
.reach__row > input:checked ~ :where(.reach__text) em:not(.reach__warn) { color: var(--md-sys-color-on-surface); }
/* "Splits the series and cannot be undone": red TEXT with a warning glyph. */
.reach__row em.reach__warn {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--md-sys-spacing-50);
  color: var(--md-sys-color-error);
}
.reach__warn > .ico { --_icon: var(--app-icon-size-medium); --_opsz: 20; color: inherit; }
@media (prefers-reduced-motion: no-preference) {
  .reach__row {
    transition-property: background-color, border-radius;
    transition-duration: var(--md-sys-motion-spring-fast-effects-duration), var(--md-sys-motion-spring-fast-spatial-duration);
    transition-timing-function: var(--md-sys-motion-spring-fast-effects), var(--md-sys-motion-spring-fast-spatial);
  }
}

/* A week step in flight: m3.css puts the loading shape 160px down a tall
   host, which on this grid is the day names and the today disc. Here it
   sits in the hours, where the wait is. */
.cal.m3-loading-host.htmx-request::after { top: 50%; }

/* K42: everything above that is given a display keeps [hidden] honest. */
:is(.cal-layout, .cal, .cal__days, .cal__dayhead, .cal__dom, .cal__allday, .cal__alldaycol, .cal__body,
    .cal__hour, .allday, .evblk, .reach, .reach__row, .reach__text, .reach__warn, .cal__tags)[hidden] { display: none; }
