/* =========================================================================
   views/calendar.css — Calendar page + calendar responsive
   Split from the old monolithic styles/views.css. LOAD ORDER MATTERS:
   the <link> order in Magnet CRM.html / Client App.html reproduces the
   original file order, so the cascade is unchanged — add new rules to the
   matching feature file, not the end of the list.
   ========================================================================= */
/* ---- Calendar page -------------------------------------------------- */
/* the content scheduler's bar, mirrored: [seg · ‹ Today ›] — title — [actions] */
.main-toolbar[data-route="calendar"] { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.cal-bar-left { display: flex; align-items: center; gap: var(--space-3); justify-self: start; }
.cal-bar-right { display: flex; align-items: center; gap: var(--space-2); justify-self: end; }
/* centred title-with-nav: ‹ › flank the period and the period itself is a
   button (data-caltoday) that jumps back to today — replaces the old separate
   ‹ Today › group. Arrows are ghost chevrons (the dashboard mini-cal's .cal-nav
   treatment), so the title stays the visual anchor. */
.cal-title-nav { justify-self: center; display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.cal-title-arr { width: 28px; height: 28px; flex: none; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); border: none; background: none; padding: 0; transition: background var(--dur) var(--ease); }
.cal-title-arr svg { width: 18px; height: 18px; }
/* min-width:0 + hidden overflow: if the bar is ever squeezed below min-content
   anyway, the nowrap title clips with an ellipsis instead of painting over the
   arrows / action buttons beside it. */
.cal-page-title { font-size: var(--text-lg); font-weight: var(--fw-normal); color: var(--text); white-space: nowrap; text-align: center; font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; text-overflow: ellipsis; border: none; background: none; padding: 2px var(--space-2); border-radius: var(--radius-sm); transition: background var(--dur) var(--ease); }
.cal-page-title strong { font-weight: var(--fw-bold); color: var(--text-strong); }
@media (hover: hover) and (pointer: fine) {
  .cal-title-arr:hover, .cal-page-title:hover { background: var(--gray-100); }
}
.cal-viewseg button { min-width: 56px; }
/* month page: same internal-scroll model as week/day — the card fills the
   view and overflowing weeks scroll inside the grid, top padding stays put */
.cal-page { padding: 20px var(--space-6) var(--space-6); }
.cal-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
/* the grid scrolls, the head doesn't — reserve a matching scrollbar gutter on
   BOTH so their 7 columns stay pixel-aligned when a scrollbar is visible */
.cal-grid-month { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.cal-page > .cal-month-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-page > .cal-month-card > .cal-grid-month { flex: 1; min-height: 0; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 0 var(--space-2); }
.cal-weekdays span { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; padding-left: var(--space-3); }
/* 136px min: date number + three rail chips + the "+N more" link with real
   breathing room under it — tighter minimums left the more-link touching the
   cell's bottom border */
.cal-grid-month { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(136px, 1fr); }
.cal-month-card { border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.cal-month-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); overflow: hidden; scrollbar-gutter: stable; }
.cal-month-head span { height: 44px; display: flex; align-items: center; padding-left: var(--space-3); font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; border-left: 1px solid var(--border); }
.cal-month-head span:first-child { border-left: none; }
/* border-LEFT, matching .cal-month-head span — a border-right here sits on
   the opposite side of the same column boundary, 1px off the header's line */
.cal-cell { border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: var(--space-2); display: flex; flex-direction: column; gap: 5px; min-width: 0; transition: background var(--dur) var(--ease); }
.cal-cell:nth-child(7n + 1) { border-left: none; }
@media (hover: hover) and (pointer: fine) {
  .cal-cell:hover { background: var(--gray-25); }
}
.cal-cell.other { background: var(--surface-sunk); }
.cal-cell.other .cal-cell-num { color: var(--text-soft); opacity: 0.45; }
.cal-cell-num { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text); width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-cell.today .cal-cell-num { background: var(--primary-600); color: var(--on-primary); }
.cal-cell-num[data-cal-daycell] { cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cal-cell-num[data-cal-daycell]:hover { background: var(--gray-150); }
  .cal-cell.today .cal-cell-num[data-cal-daycell]:hover { background: var(--primary-700); }
}
.cal-cell-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
/* Month-grid entries are "rail" chips: no fill, a 2px colour rail on the left
   and a hairline between rows. The rail alone carries the calendar colour, so
   a busy day reads as a list instead of a stack of coloured bricks, and the
   title gets the full cell width (no right padding) before it truncates. */
.cal-chip { display: flex; align-items: center; gap: 5px; width: 100%; padding: 3px 7px 3px 9px; border-radius: 0 var(--radius-xs) var(--radius-xs) 0; font-size: var(--text-xs); line-height: 1.35; text-align: left; min-width: 0; transition: background var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cal-chip:hover { background: color-mix(in srgb, var(--ev, var(--primary-600)) 14%, var(--surface)); }
}
.cal-chip-time { font-weight: var(--fw-semibold); flex-shrink: 0; color: var(--text-muted); }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-medium); }
.cal-chip.cat-meeting  { background: var(--primary-50); color: var(--primary-700); }
.cal-chip.cat-demo     { background: var(--cat-demo-bg); color: var(--cat-demo-fg); }
.cal-chip.cat-call     { background: var(--info-bg); color: var(--info-600); }
.cal-chip.cat-review   { background: var(--cat-review-bg); color: var(--cat-review-fg); }
.cal-chip.cat-internal { background: var(--gray-100); color: var(--text-muted); }
/* "+N more" — clicking opens the day view (the click bubbles to the cell's
   [data-cal-daycell] handler); hover makes that affordance visible */
.cal-more { font-size: var(--text-xs); color: var(--text-soft); font-weight: var(--fw-medium); padding: 1px var(--space-1); align-self: flex-start; border-radius: var(--radius-xs); cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cal-more:hover { background: var(--gray-100); color: var(--text-strong); }
}

/* week / day time grid — the PAGE never scrolls: the card fills the view and
   the hour grid scrolls inside .cal-time-body (day view's model, now shared by
   week). A page-scrolling sticky head let content show through its rounded
   corner notches and the top padding strip. */
.cal-time { padding: 20px var(--space-6) var(--space-6); display: flex; flex-direction: column; height: 100%; min-height: 0; }
.cal-time-grid { display: grid; grid-template-columns: 64px 1fr; }
.cal-time-head { flex-shrink: 0; z-index: 2; background: var(--surface); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow: hidden; scrollbar-gutter: stable; }
.cal-gutter-cell { border-right: 1px solid var(--border); }
.cal-dayheads { display: grid; }
.cal-dayhead { display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; border-left: 1px solid var(--border); }
.cal-dayhead:first-child { border-left: none; }
.cal-dh-dow { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-dh-num { font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text-strong); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-dayhead.today .cal-dh-num { background: var(--primary-600); color: var(--on-primary); }
.cal-dayhead.today .cal-dh-dow { color: var(--primary-600); }
/* scrollbar-gutter on body AND (hidden-overflow) head keeps the day columns
   aligned with the header columns when a scrollbar is visible */
.cal-time-body { flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 0 0 var(--radius-xl) var(--radius-xl); overflow-y: auto; overflow-x: hidden; background: var(--surface); box-shadow: var(--shadow-sm); scrollbar-gutter: stable; grid-template-rows: minmax(0, 1fr); }
/* with an all-day lane the body has TWO grid rows; pin the lane to content
   height and give the hour grid all the leftover — otherwise align-content's
   default stretch splits spare space between both auto rows and inflates the
   lane into a tall empty band (visible on week view, whose 13 hour rows can
   undershoot the fixed body height) */
.cal-time-body:has(.cal-allday-row) { grid-template-rows: auto minmax(0, 1fr); }
.cal-gutter { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
/* Hour rows GROW equally beyond their 48px base: .cal-time-body is flex:1, so
   on tall windows the day columns stretch past 13×48px — events are positioned
   in % OF THE COLUMN, so fixed-height rows made every chip drift downward and
   left a bordered void under the last row (bug: "1 PM" chip rendering at ~5 PM
   on tall screens). Uniform flex-grow keeps rows and percentages in agreement
   at any height. */
.cal-hour { flex: 1 0 48px; height: 48px; min-height: 0; position: relative; }
.cal-hour span { position: absolute; top: -7px; right: 8px; font-size: var(--text-xs); color: var(--text-soft); white-space: nowrap; }
.cal-hour:first-child span { top: 4px; }
.cal-cols { display: grid; }
.cal-day-col { position: relative; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.cal-day-col:first-child { border-left: none; }
/* today — the content scheduler's light accent wash, WEEK view only (on day
   view the single column is always today, so a wash would tint everything) */
/* mix from --primary-600, NOT --primary-50: the accent system pins the 50
   swatch to a LIGHT value inline on <html>, so a 50-mix over the dark surface
   rendered today's column as a grey slab in dark mode */
.cal-time:not(.cal-time-day) .cal-day-col.today,
.cal-time:not(.cal-time-day) .cal-dayhead.today,
.cal-time:not(.cal-time-day) .cal-allday-col.today { background: color-mix(in srgb, var(--primary-600) 6%, var(--surface)); }
.cal-hline { flex: 1 0 48px; height: 48px; min-height: 0; border-bottom: 1px solid var(--border); }
.cal-hline:last-child { border-bottom: none; }
/* Timed blocks keep a surface — the block IS the duration, so it has to read
   as a filled extent — but the surface is neutral and the calendar colour
   moves to the rail, matching .cal-ev-card on the dashboard widget. */
.cal-day-col .cal-event { position: absolute; left: calc(var(--cal-left, 0%) + 3px); right: auto; width: calc(var(--cal-width, 100%) - 6px); margin: 0; min-height: 24px; padding: 4px 8px; border-radius: 0 var(--radius-xs) var(--radius-xs) 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left; overflow: hidden; transition: background var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cal-day-col .cal-event:hover { background: color-mix(in srgb, var(--ev, var(--primary-600)) 14%, var(--surface)); }
}
.cal-event-time { font-size: 10px; font-weight: var(--fw-semibold); color: var(--text-muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* short (< 45min) blocks: time + title share one line instead of clipping */
.cal-day-col .cal-event--compact { flex-direction: row; align-items: center; gap: 5px; padding-top: 0; padding-bottom: 0; }
.cal-day-col .cal-event--compact .cal-event-time { flex-shrink: 0; }
.cal-day-col .cal-event--compact .cal-event-title { width: auto; min-width: 0; }
.cal-event-title { font-size: var(--text-xs); font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; max-width: 100%; }
.cal-day-col .cal-event.cat-meeting  { background: var(--primary-50); color: var(--primary-700); }
.cal-day-col .cal-event.cat-demo     { background: var(--cat-demo-bg); color: var(--cat-demo-fg); }
.cal-day-col .cal-event.cat-call     { background: var(--info-bg); color: var(--info-600); }
.cal-day-col .cal-event.cat-review   { background: var(--cat-review-bg); color: var(--cat-review-fg); }
.cal-day-col .cal-event.cat-internal { background: var(--gray-100); color: var(--text-muted); }

/* dynamic per-calendar colours — driven by inline --ev (each Google calendar,
   Consultations, Follow Ups). Tinted bg + readable text derived from --ev. */
.cal-chip.dyn { border-left: 2.5px solid var(--ev); color: var(--text-strong); background: color-mix(in srgb, var(--ev) 7%, var(--surface)); }
/* rail + the same light tint as the chips; the 2px rail runs the block's
   full height, so duration reads as the rail + tinted extent */
.cal-day-col .cal-event.dyn { background: color-mix(in srgb, var(--ev) 7%, var(--surface)); color: var(--text-strong); border-left: 2.5px solid var(--ev); }
/* all-day lane — a row of month-grid rail chips under the day headers
   (inside the sticky .cal-time-head), Google-style. Untimed entries no
   longer float over the first hour rows of the time grid. */
/* the lane lives at the TOP of the scrolling day content (not the sticky
   header): it renders at full height — no cap, no inner scroll — and slides
   away with the content, so it never restricts the hour grid mid-scroll */
.cal-allday-row { grid-column: 1 / -1; border-bottom: 1px solid var(--border); }
.cal-allday-cols { display: grid; }
.cal-allday-col { min-width: 0; border-left: 1px solid var(--border); padding: 3px 6px 4px; display: flex; flex-direction: column; gap: 2px; }
.cal-allday-col:first-child { border-left: none; }
/* the row's "All day" label lives in the gutter cell, aligned with the hour
   labels — the chips themselves carry only the rail + title */
.cal-allday-label { display: flex; align-items: center; justify-content: flex-end; padding-right: var(--space-2); font-size: 10px; font-weight: var(--fw-semibold); color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
/* Completed tasks (CRM to-dos + synced Google-Task instances) — struck-through
   + dimmed, like Google's grid. .etitle covers the dashboard widget's cards. */
.cal-chip--done { opacity: .55; }
.cal-chip--done .cal-chip-title,
.cal-chip--done .cal-event-title,
.cal-chip--done .etitle { text-decoration: line-through; }

/* Google entry detail sheet (gcalDetailDrawer) */
.gcal-brand { width: 14px; height: 14px; object-fit: contain; flex-shrink: 0; }
.gcal-title--done { text-decoration: line-through; opacity: .7; }
.ed-badge--done { color: var(--success-700, #15803d); }
.gcal-att { display: inline-flex; align-items: center; gap: 5px; }
.gcal-att--no { opacity: .6; text-decoration: line-through; }
.gcal-att-rsvp { display: inline-flex; }
.gcal-att-rsvp svg { width: 12px; height: 12px; }
.gcal-att-rsvp--accepted { color: var(--success-600, #16a34a); }
.gcal-att-rsvp--declined { color: var(--danger-600, #dc2626); }
.gcal-desc { white-space: pre-wrap; word-break: break-word; }
.gcal-src-link { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.gcal-src-link svg { width: 14px; height: 14px; flex-shrink: 0; }
.gcal-proj-note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; font-size: var(--fs-xs, 12px); color: var(--gray-500); }
.gcal-proj-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.gcal-updated { margin: 14px 0 0; font-size: var(--fs-xs, 12px); color: var(--gray-400); }

/* day view — taller hour rows for breathing room + internal scroll */
.cal-time-day { height: 100%; min-height: 0; }
.cal-time-day .cal-time-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.cal-time-day .cal-hour { flex: 1 0 64px; height: 64px; min-height: 0; }
.cal-time-day .cal-hline { flex: 0 0 auto; height: 64px; min-height: 0; }

/* ---- calendar responsive (tablet + mobile) ---- */
@media (max-width: 1024px) {
  .cal-page, .cal-time {
    padding-left: max(var(--space-4), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
  }
}
/* (the old ≤760px stacked-toolbar fallback is gone: the container tiers below
   + the responsive-tabs view seg keep the bar on one line at every width, and
   ≤640px the mobile shell hides this row and relocates its controls anyway) */
/* Squeeze tiers driven by the main COLUMN's width (container on .main): with
   the sidebar open the column is ~260px narrower than the viewport, so the
   grid bar ran out of room while the 760px media query above was still far
   away — the nowrap title then painted over the nav / Calendars buttons.
   Tier 1 (≤ 820px): the action buttons drop their labels and become square
   icon buttons (same treatment mobile already gives .cal-filter-btn), which
   buys the single-line bar ~170px. */
@container main-col (max-width: 820px) {
  /* :where() keeps specificity at 0,1,0 so the mobile shell's later
     .cal-filter-btn rules (44px touch target, responsive.css) still win */
  :where(.cal-bar-right) .btn { width: var(--btn-height); padding: 0; justify-content: center; }
  :where(.cal-bar-right) .btn > span { display: none; }
}
/* Below that, no stacking tier: the view seg is a .responsive-tabs, so as the
   column keeps shrinking Month/Week/Day fold into the "+N more" menu
   (scripts/responsive-tabs.js) and the bar holds a single line. */
@media (max-width: 640px) {
  .cal-page, .cal-time {
    padding: var(--space-4) max(var(--space-3), var(--safe-left)) 0
             max(var(--space-3), var(--safe-right));
  }
  /* week view: scroll horizontally so the 7 day columns stay usable */
  .cal-time { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-time-head, .cal-time-body { min-width: 680px; }
  .cal-time-grid { grid-template-columns: 48px 1fr; }
  /* fit the uppercased "ALL DAY" in the 48px gutter on one line */
  .cal-allday-label { font-size: 8px; letter-spacing: 0.02em; justify-content: center; padding-right: 0; }
  /* day view is a single column — no horizontal scroll */
  .cal-time-day { overflow-x: visible; }
  .cal-time-day .cal-time-head, .cal-time-day .cal-time-body { min-width: 0; }
  /* month view: shorter rows + tighter labels */
  .cal-grid-month { grid-auto-rows: minmax(76px, 1fr); }
  .cal-weekdays span { font-size: 10px; padding-left: var(--space-2); }
  /* only Month + Day view options on mobile */
  .cal-viewseg [data-calmode="week"] { display: none; }
  /* month cells: whole square opens day view; entries shown as colour dots */
  .cal-cell { cursor: pointer; }
  .cal-cell-events { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  /* dots take the calendar colour from --ev directly: the rail chip's text is
     --text-strong, so currentColor would render every dot the same dark grey. */
  .cal-cell .cal-chip {
    width: 7px; height: 7px; min-height: 0; padding: 0; gap: 0;
    border-radius: 50%; overflow: hidden; background: var(--ev);
    border: 0; pointer-events: none;
  }
  .cal-cell .cal-chip + .cal-chip { border-top: 0; }
  .cal-cell .cal-chip > * { display: none; }
  .cal-cell .cal-more { font-size: 10px; padding-left: 2px; pointer-events: none; }
}

/* calendar event info popover (on click) */
/* clicked entry while its popover is open — no held emphasis: the popover
   anchors beside the entry, and a persistent tint reads as a stuck hover
   (the old primary ring also read as stray blue lines on full-width rows) */
.cal-event.is-active, .cal-chip.is-active { box-shadow: none; }

/* current-time line — TODAY's column only, accent-coloured, with a dot on the
   column's left edge. pointer-events off so it never blocks event clicks. */
.cal-nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px dashed var(--primary-600); pointer-events: none; z-index: 4; }
/* the 1.5px stroke draws DOWNWARD from the element's y — centre the dot and
   pill on the stroke's middle (+0.75px), not the top edge */
.cal-nowline::before { content: ""; position: absolute; left: -4px; top: -4.25px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary-600); }
/* current-time pill — sits in the hour gutter at the line's left, covering
   whatever hour label it happens to pass (Google-style) */
.cal-nowline-chip { position: absolute; right: calc(100% + 7px); top: -0.75px; transform: translateY(-50%); display: inline-flex; align-items: center; background: var(--primary-600); color: var(--on-primary); font-size: 9px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; line-height: 1; padding: 3px 6px; border-radius: var(--radius-full); white-space: nowrap; }
.cal-evt-pop {
  position: fixed; z-index: var(--z-popover); width: 248px;
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: 8px;
}
.cal-evt-pop-head { display: flex; align-items: center; gap: 7px; }
.cal-evt-pop-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary-600); flex-shrink: 0; }
.cal-evt-pop.cat-demo     .cal-evt-pop-dot { background: var(--cat-demo-fg); }
.cal-evt-pop.cat-call     .cal-evt-pop-dot { background: var(--info-600); }
.cal-evt-pop.cat-review   .cal-evt-pop-dot { background: var(--cat-review-fg); }
.cal-evt-pop.cat-internal .cal-evt-pop-dot { background: var(--text-muted); }
.cal-evt-pop-cat { font-size: var(--text-2xs); font-weight: var(--fw-bold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); }
.cal-evt-pop-title { font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--text-strong); line-height: 1.3; text-wrap: pretty; }
.cal-evt-pop-row { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--text-muted); }
.cal-evt-pop-row > span { white-space: nowrap; }
.cal-evt-pop-row svg { width: 15px; height: 15px; color: var(--text-soft); flex-shrink: 0; }
.cal-evt-join { width: 100%; justify-content: center; margin-top: 4px; }
.cal-evt-join svg { width: 18px; height: 18px; }
.cal-evt-open-task { width: 100%; justify-content: center; gap: 6px; margin-top: 6px; }
.cal-evt-open-task svg { width: 16px; height: 16px; }

/* directional slide-in when paging the calendar (swipe + prev/next arrows) */
@keyframes calSlideNext { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes calSlidePrev { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: translateX(0); } }
.cal-page.cal-enter-next, .cal-time.cal-enter-next { animation: calSlideNext var(--dur-slow) var(--ease); }
.cal-page.cal-enter-prev, .cal-time.cal-enter-prev { animation: calSlidePrev var(--dur-slow) var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .cal-page.cal-enter-next, .cal-time.cal-enter-next,
  .cal-page.cal-enter-prev, .cal-time.cal-enter-prev { animation: none; }
}

/* mobile: event details as a full-screen page that slides in from the right,
   iOS-style — the calendar pushes left behind it and the bottom nav hides. */
@media (max-width: 640px) {
  .cal-evt-page {
    position: fixed; inset: 0; z-index: calc(var(--z-popover) + 3);
    background: var(--surface);
    display: flex; flex-direction: column;
    padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
    transform: translateX(100%);
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
  .cal-evt-page.show { transform: translateX(0); }
  .cal-evt-page.closing { transition-duration: 220ms; }
  /* calendar (and the rest of the app shell) eases left behind the detail */
  #main { transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1); }
  body.evt-page-open #main { transform: translateX(-32px); }
  body.evt-page-closing #main { transition-duration: 220ms; }
  /* bottom nav slides away while the detail page is open */
  .mobile-bottom { transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms cubic-bezier(0.22, 1, 0.36, 1); }
  body.evt-page-open .mobile-bottom { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .cal-evt-page-head {
    display: flex; align-items: center; gap: var(--space-2);
    height: var(--shell-header-height); flex-shrink: 0;
    padding: 0 var(--space-3); border-bottom: 1px solid var(--border);
  }
  .cal-evt-back {
    display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0;
    height: 44px; padding: 0 14px 0 8px;
  }
  .cal-evt-back svg { width: 22px; height: 22px; }
  .cal-evt-back span { font-size: var(--text-base); font-weight: var(--fw-medium); }
  .cal-evt-page-cat {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: var(--text-2xs); font-weight: var(--fw-bold);
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft);
  }
  .cal-evt-page.cat-demo     .cal-evt-pop-dot { background: var(--cat-demo-fg); }
  .cal-evt-page.cat-call     .cal-evt-pop-dot { background: var(--info-600); }
  .cal-evt-page.cat-review   .cal-evt-pop-dot { background: var(--cat-review-fg); }
  .cal-evt-page.cat-internal .cal-evt-pop-dot { background: var(--text-muted); }
  .cal-evt-page-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: var(--space-6) var(--space-5);
    display: flex; flex-direction: column; gap: var(--space-4);
  }
  .cal-evt-page-title {
    margin: 0; font-size: var(--text-2xl); font-weight: var(--fw-semibold);
    letter-spacing: -0.01em; color: var(--text-strong); text-wrap: pretty;
  }
  .cal-evt-page-body .cal-evt-pop-row { font-size: var(--text-base); }
  .cal-evt-page-body .cal-evt-pop-row svg { width: 18px; height: 18px; }
  .cal-evt-page-body .cal-evt-join { width: 100%; height: 52px; justify-content: center; font-size: var(--text-base); margin-top: var(--space-3); }
  .cal-evt-page-body .cal-evt-join svg { width: 22px; height: 22px; }
  @media (prefers-reduced-motion: reduce) {
    /* no slide — simple fade for the detail page; shell + nav don't translate */
    .cal-evt-page { transition: opacity 200ms linear; transform: none; opacity: 0; }
    .cal-evt-page.show { transform: none; opacity: 1; }
    #main, body.evt-page-open #main { transition: none; transform: none; }
    .mobile-bottom { transition: opacity 200ms linear; }
    body.evt-page-open .mobile-bottom { transform: none; opacity: 0; }
  }
}

/* "Calendars" filter button + popover */
.cal-filter-btn { position: relative; }
.cal-filter-btn.is-open { background: var(--seg-active); box-shadow: var(--seg-active-shadow); }
.cal-filt-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--primary-600); color: var(--on-primary); font-size: 10px; font-weight: var(--fw-bold); }
.cal-filt-pop {
  position: fixed; z-index: var(--z-popover); width: 232px;
  padding: var(--space-2);
}
.cal-filt-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; }
.cal-filt-head > span { font-size: var(--text-2xs); font-weight: var(--fw-bold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft); }
.cal-filt-all { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--primary-600); cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .cal-filt-all:hover { text-decoration: underline; }
}
.cal-filt-list { display: flex; flex-direction: column; gap: 1px; }
.cal-filt-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-md); cursor: pointer; transition: background var(--dur) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .cal-filt-row:hover { background: var(--gray-50); }
}
.cal-filt-box { flex-shrink: 0; }
.cal-filt-box:checked { background: var(--ev, var(--primary-600)); border-color: var(--ev, var(--primary-600)); }
.cal-filt-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cal-filt-name { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-strong); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-filt-count { font-size: 11px; font-weight: var(--fw-semibold); color: var(--text-soft); flex-shrink: 0; }
.cal-filt-row.is-off .cal-filt-dot { background: var(--gray-300) !important; }
.cal-filt-row.is-off .cal-filt-name { color: var(--text-muted); }
.cal-filt-foot { padding: 9px 8px 5px; margin-top: 4px; border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-soft); line-height: 1.4; }
.cal-filt-link { color: var(--primary-600); font-weight: var(--fw-semibold); cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .cal-filt-link:hover { text-decoration: underline; }
}

/* ---- Calendars popover: custom calendars (create + delete) ------------
   "Add calendar" is a quiet grey text link under the category list (owner
   call: minimal); clicking it reveals the inline composer (name + colour
   swatches). Custom rows carry a hover-delete. NOTE the explicit [hidden]
   guards — the display rules below would otherwise defeat the attribute. */
.cal-filt-del {
  display: none;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  flex: 0 0 auto;
}
.cal-filt-del svg { width: 13px; height: 13px; }
@media (hover: hover) and (pointer: fine) {
  .cal-filt-row:hover .cal-filt-del { display: inline-flex; }
  .cal-filt-del:hover { color: var(--danger-600); background: var(--nav-hover-bg); }
}
@media (max-width: 640px) { .cal-filt-del { display: inline-flex; } }   /* no hover on touch */
.cal-filt-newlink {
  display: inline-flex;
  padding: 7px 8px 3px;
  font-size: var(--text-xs); font-weight: var(--fw-medium);
  color: var(--text-soft);
  background: none;
}
@media (hover: hover) and (pointer: fine) {
  .cal-filt-newlink:hover { color: var(--text-strong); text-decoration: underline; }
}
.cal-filt-newlink[hidden] { display: none; }
/* The popover is a FIXED 232px box (padding --space-2 → ~216px content):
   everything here must fit that — 8 × 18px swatches + 7 × 6px gaps = 186px,
   and min-width:0 keeps the grid from growing past the container. */
.cal-new-form { padding: 6px 8px 8px; display: grid; gap: 9px; min-width: 0; }
.cal-new-form[hidden] { display: none; }
.cal-new-form .cal-new-name { width: 100%; min-width: 0; }
.cal-new-colors { display: flex; gap: 6px; }
.cal-new-swatch {
  width: 18px; height: 18px; border-radius: 999px;
  flex: 0 0 auto;
  border: 2px solid transparent;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur) var(--ease);
}
.cal-new-swatch.sel { border-color: var(--text-strong); transform: scale(1.12); }
.cal-new-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* ---- "Google Calendar" group in the Calendars popover ---- */
.cal-filt-group { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; padding-top: 3px; border-top: 1px solid var(--border-faint, var(--border)); }
.cal-filt-glogo { width: 14px; height: 14px; flex-shrink: 0; display: inline-flex; }
.cal-filt-glogo svg { width: 100%; height: 100%; }
.cal-filt-row.is-off .cal-filt-glogo { filter: grayscale(1); opacity: 0.55; }
.cal-filt-gcaret { width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-soft); cursor: pointer; transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.cal-filt-gcaret svg { width: 14px; height: 14px; transform: rotate(-90deg); transition: transform var(--dur-fast) var(--ease); }
.cal-filt-gcaret.open svg { transform: rotate(0deg); }
@media (hover: hover) and (pointer: fine) { .cal-filt-gcaret:hover { background: var(--gray-100); color: var(--text-strong); } }
.cal-filt-subs { display: flex; flex-direction: column; gap: 1px; }
.cal-filt-row--sub { margin-left: 24px; }
