/* CycleWright Calendar and contacts (round 21): calendar.js, calevent.js, contacts.js.
   The Calendar page (calendar.js): the toolbar, the drawer (your calendars, CycleWright dates, colleagues), Day / Week
   (the time grid), Month, List, the reminders' notice; light and dark from ui.css's tokens; a phone gets one column, the
   drawer as a sheet and a round New event button; print is black on white with no menus. */

:root { --cal-off: rgba(148, 163, 184, .055); --cal-line: rgba(148, 163, 184, .13); --cal-half: rgba(148, 163, 184, .06); --cal-now: #ef4444; }
:root[data-theme="light"] { --cal-off: #f4f6fa; --cal-line: #e6e9ef; --cal-half: #f1f3f7; --cal-now: #dc2626; }

/* ---------------------------------------------------------------- the page */
body.cal-on main#view { max-width: none; padding-top: 14px; padding-bottom: 12px; }
.cal { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.cal-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-top .spacer { flex: 1; }
.cal-range { margin: 0 6px 0 2px; font-size: 18px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-arrows { display: inline-flex; gap: 2px; }
.cal-search { flex: 1 1 150px; max-width: 300px; min-width: 130px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  background: var(--input-bg); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text-3); cursor: text; }
.cal-search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.cal .cal-search input { flex: 1; min-width: 0; height: 34px; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 14px; }
.cal .cal-search input:focus { box-shadow: none; }
.cal-views > button { min-width: 58px; }
.cal-drawer-btn, .cal-sbtn { display: none; }
.cal-banner:empty { display: none; }
.cal-banner { display: flex; flex-direction: column; gap: 6px; }
.cal-banner .callout { margin: 0; }
.cal-hint { display: flex; align-items: center; gap: 8px; padding: 0 4px 6px; color: var(--text-3); font-size: 13px; }
.cal-hint[hidden] { display: none; }
.cal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 244px minmax(0, 1fr); gap: 14px; }
.cal-center { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cal-main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.cal-main.busy::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 50% 100%; background-repeat: no-repeat; animation: cal-busy 1s linear infinite; }
@keyframes cal-busy { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.cal-view { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); }
.cal-scrim, .cal-fab { display: none; }

/* ---------------------------------------------------------------- the drawer */
.cal-drawer { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 2px 4px 14px 0; }
.cal-drawer-h { display: none; }
.cal-dsec h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cal-chk { display: flex; align-items: center; gap: 9px; min-height: 30px; padding: 2px 6px; border-radius: 8px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.cal-chk:hover { background: var(--hover); }
.cal-chk input { width: 16px; height: 16px; margin: 0; flex: none; }
.cal-chk-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-src { flex: none; font-size: 11px; color: var(--text-3); }
.cal-n { flex: none; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); font-size: 11.5px; text-align: center; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal-warn svg { color: var(--warn); }
.cal-colleague { display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 2px 2px 2px 6px; font-size: 13.5px; }
.cal-ini { --bc: #64748b; flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 99px; font-style: normal; font-size: 10.5px; font-weight: 700;
  color: #fff; background: var(--bc); }
.cal-addcol { width: 100%; margin-top: 6px; height: 34px; font-size: 13px; }
.cal-note { margin: 8px 6px 0; line-height: 1.45; }
.cal-mbox { display: flex; align-items: center; gap: 7px; margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.cal-mbox svg { color: var(--text-3); flex: none; }
/* the small month */
.cal-mini { padding: 10px 10px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.cal-mini-h { display: flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.cal-mini-h b { flex: 1; font-size: 13.5px; padding-left: 4px; }
.cal-mini-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-mini-w { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 2px 0 4px; }
.cal-mini-d { height: 28px; min-height: 0; padding: 0; border: 0; border-radius: 99px; background: none; box-shadow: none; font-size: 12.5px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.cal-mini-d:hover { background: var(--hover); }
.cal-mini-d.other { color: var(--text-3); }
.cal-mini-d.in { background: var(--accent-soft); border-radius: 0; }
.cal-mini-d.sel { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 99px; }
.cal-mini-d.today { background: var(--accent); color: #fff; font-weight: 700; border-radius: 99px; }

/* ---------------------------------------------------------------- events, chips and CycleWright dates */
.cal-ev, .cal-chip { --ec: var(--accent); color: var(--text); }
.cal-ev { position: absolute; z-index: 2; overflow: hidden; padding: 3px 6px 2px 7px; border-radius: 6px; border-left: 3px solid var(--ec);
  background: color-mix(in srgb, var(--ec) 22%, var(--surface)); box-shadow: 0 0 0 1px var(--surface); font-size: 12px; line-height: 1.3; cursor: pointer; user-select: none; }
.cal-ev:hover { background: color-mix(in srgb, var(--ec) 30%, var(--surface)); z-index: 3; }
.cal-ev:focus-visible, .cal-chip:focus-visible, .cal-lrow:focus-visible { outline: none; box-shadow: var(--ring); z-index: 4; }
.cal-ev.can-move { cursor: grab; }
.cal-ev.dragging { cursor: grabbing; z-index: 6; opacity: .92; box-shadow: var(--shadow-lg); }
.cal-ev.dragging::after { content: attr(data-when); position: absolute; right: 4px; bottom: 2px; padding: 1px 6px; border-radius: 6px; background: var(--ec); color: #fff; font-size: 11px; font-weight: 650; }
.ce-t { display: flex; align-items: center; gap: 4px; font-weight: 650; min-width: 0; }
.ce-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev:not(.short) .ce-n { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ce-tm { flex: none; font-weight: 500; color: var(--text-2); }
.ce-w { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.cal-ev.short { padding-top: 1px; padding-bottom: 0; }
.ce-rs { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.ce-rs::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 2px; margin-left: -9px; border-radius: 2px; background: var(--ec); opacity: 0; }
.cal-ev:hover .ce-rs::after { opacity: .8; }
.cal-ev.cont-t { border-top-left-radius: 0; border-top-right-radius: 0; }
.cal-ev.cont-b { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cal-ics { display: inline-flex; gap: 2px; flex: none; color: var(--text-2); }
.cal-ics svg { width: 11px; height: 11px; }
.cal-ev, .cal-chip { container-type: inline-size; }
@container (max-width: 96px) { .cal-ics { display: none; } }          /* a narrow event keeps its title, not its marks */
@container (max-width: 64px) { .ce-tm, .ce-w { display: none; } }
/* not answered / tentative: striped and outlined; declined: struck through and light; past: a little quieter */
.cal-ev.tent, .cal-chip.filled.tent { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ec) 18%, var(--surface)) 0 6px, var(--surface) 6px 12px);
  outline: 1px dashed color-mix(in srgb, var(--ec) 80%, transparent); outline-offset: -1px; }
.cal-ev.declined, .cal-chip.declined, .cal-lrow.declined { opacity: .55; }
.cal-ev.declined .ce-n, .cal-chip.declined .cal-chip-n, .cal-lrow.declined .cal-ln { text-decoration: line-through; }
.cal-ev.declined { background: var(--surface-2); }
.cal-ev.cancelled, .cal-chip.cancelled, .cal-lrow.cancelled { opacity: .5; }
.cal-ev.cancelled { border-left-style: dashed; outline: 1px dashed var(--text-3); outline-offset: -1px; }     /* the whole block reads as one, though faint */
.cal-ev.free { background: color-mix(in srgb, var(--ec) 10%, var(--surface)); }
.cal-ev.past:not(:hover) { filter: saturate(.7); }
.cal-ev.past .ce-n, .cal-chip.past .cal-chip-n { color: var(--text-2); }

.cal-chip { display: flex; align-items: center; gap: 5px; min-width: 0; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 12px; line-height: 1; cursor: pointer;
  user-select: none; white-space: nowrap; overflow: hidden; }
.cal-chip.filled { background: color-mix(in srgb, var(--ec) 24%, var(--surface)); border-left: 3px solid var(--ec); font-weight: 600; }
.cal-chip.timed:hover, .cal-chip.filled:hover { background: color-mix(in srgb, var(--ec) 32%, var(--surface)); }
.cal-chip.timed:hover { background: var(--hover); }
.cal-chip.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-chip.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-chip-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cal-month .cal-chip .cal-ics { display: none; }                      /* a month's day has room for the title only */
.cal-chip-t { flex: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal-dot { flex: none; width: 8px; height: 8px; border-radius: 99px; background: var(--ec); }
.cal-chip.timed.tent .cal-dot { background: none; box-shadow: inset 0 0 0 2px var(--ec); }

/* a CycleWright date: a diamond in its kind's colour, an outline - never filled like an event; late = red */
.cal-mark { --lc: #64748b; display: flex; align-items: center; gap: 6px; min-width: 0; height: 22px; padding: 0 8px 0 6px; border-radius: 99px;
  border: 1px solid color-mix(in srgb, var(--lc) 45%, transparent); background: color-mix(in srgb, var(--lc) 7%, transparent);
  color: var(--text); font-size: 11.5px; font-weight: 550; line-height: 1; text-decoration: none; white-space: nowrap; overflow: hidden; cursor: pointer; }
button.cal-mark { min-height: 0; box-shadow: none; justify-content: flex-start; font: inherit; font-size: 11.5px; font-weight: 600; }
.cal-mark:hover { background: color-mix(in srgb, var(--lc) 16%, transparent); color: var(--text); }
.cal-mark.late { --lc: var(--bad) !important; color: var(--bad); }
.cal-mark-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cal-dia { --lc: #64748b; flex: none; width: 8px; height: 8px; transform: rotate(45deg); border-radius: 1.5px; background: var(--lc); }
.cal-mark .cal-dia { background: var(--lc); }
.cal-mark.wide { height: auto; min-height: 40px; padding: 6px 10px; border-radius: 10px; flex-wrap: wrap; white-space: normal; }
.cal-mark.wide .cal-mark-n { flex: 1; font-size: 13px; }
.cal-mark.wide small { width: 100%; padding-left: 14px; color: var(--text-2); font-weight: 400; }

/* ---------------------------------------------------------------- Day and Week */
.cal-tg { --gut: 58px; }
.cal-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.cal-top-sticky { position: sticky; top: 0; z-index: 8; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 4px 10px -8px rgba(0, 0, 0, .35); }
.cal-gut { flex: none; width: var(--gut); }
.cal-whead { display: flex; }
.cal-dhs { flex: 1; display: grid; min-width: 0; }
.cal-dh { height: auto; min-height: 52px; flex-direction: column; gap: 2px; padding: 6px 4px; border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--text-2); font-weight: 500; }
.cal-dh:hover { background: var(--hover); }
.cal-dh-w { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.cal-dh-n { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 99px; font-size: 18px; font-weight: 650; color: var(--text); }
.cal-dh.today .cal-dh-w { color: var(--accent); }
.cal-dh.today .cal-dh-n { background: var(--accent); color: #fff; }
.cal-dh.off .cal-dh-n { color: var(--text-2); }
.cal-day .cal-dh { flex-direction: row; justify-content: flex-start; gap: 10px; padding-left: 12px; cursor: default; }
.cal-strip { display: flex; border-top: 1px solid var(--border); }
.cal-strip-l { display: flex; align-items: flex-start; justify-content: flex-end; padding: 6px 8px 0 0; font-size: 11px; color: var(--text-3); }
.cal-strip-grid { flex: 1; min-width: 0; display: grid; gap: 2px 0; padding: 3px 0 4px; max-height: 32vh; overflow-y: auto; cursor: cell;
  background-image: linear-gradient(90deg, var(--cal-line) 1px, transparent 1px); background-size: calc(100% / var(--n, 7)) 100%; }
.cal-week .cal-strip-grid { --n: 7; }
.cal-day .cal-strip-grid { --n: 1; }
.cal-strip-grid > * { margin: 0 3px; cursor: pointer; }
.cal-grid { display: flex; position: relative; }
.cal-hours { position: relative; }
.cal-hours span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cal-cols { flex: 1; display: grid; min-width: 0; position: relative; }
.cal-col { position: relative; height: 100%; background: var(--cal-off); border-left: 1px solid var(--cal-line); cursor: cell; }
.cal-col.off { background: color-mix(in srgb, var(--cal-off) 100%, var(--bg) 35%); }
.cal-work { position: absolute; left: 0; right: 0; background: var(--surface); pointer-events: none; }
.cal-lines { position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image: linear-gradient(var(--cal-line) 1px, transparent 1px), linear-gradient(var(--cal-half) 1px, transparent 1px);
  background-size: 100% 48px, 100% 48px; background-position: 0 0, 0 24px; }
.cal-col.today .cal-work { background: color-mix(in srgb, var(--accent) 3%, var(--surface)); }
.cal-now { position: absolute; left: -1px; right: 0; z-index: 5; height: 2px; margin-top: -1px; background: var(--cal-now); pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 99px; background: var(--cal-now); }
.cal-sel { position: absolute; left: 2px; right: 2px; z-index: 4; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); border: 1.5px solid var(--accent);
  color: var(--accent); font-size: 11.5px; font-weight: 650; pointer-events: none; }
/* colleagues' busy times: soft grey hatched blocks at the right of the day */
.cal-busy { --bc: #64748b; position: absolute; z-index: 1; overflow: hidden; border-radius: 4px; pointer-events: none;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bc) 30%, transparent) 0 4px, color-mix(in srgb, var(--bc) 14%, transparent) 4px 8px);
  border: 1px solid color-mix(in srgb, var(--bc) 45%, transparent); }
.cal-busy.tent { opacity: .6; }
.cal-busy span { display: block; padding: 2px 3px; font-size: 10px; font-weight: 700; color: var(--text-2); writing-mode: vertical-rl; white-space: nowrap; }
.cal-day .cal-busy span { writing-mode: horizontal-tb; overflow: hidden; text-overflow: ellipsis; }
.cal-busy-key { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 7px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.cal-busy-key span { --bc: #64748b; display: inline-flex; align-items: center; gap: 6px; }
.cal-busy-key i { display: inline-grid; place-items: center; min-width: 22px; height: 18px; padding: 0 4px; border-radius: 4px; font-style: normal; font-size: 10px; font-weight: 700;
  color: var(--text); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bc) 30%, transparent) 0 4px, color-mix(in srgb, var(--bc) 14%, transparent) 4px 8px);
  border: 1px solid color-mix(in srgb, var(--bc) 45%, transparent); }

/* ---------------------------------------------------------------- Month */
.cal-mhead { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-mhead > div { padding: 8px 10px; font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.cal-mgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow-y: auto; }
.cal-mday { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 6px; border-right: 1px solid var(--cal-line); border-bottom: 1px solid var(--cal-line); cursor: cell; }
.cal-mday:nth-child(7n) { border-right: 0; }
.cal-mday.off { background: var(--cal-off); }
.cal-mday.other { background: var(--cal-off); }
.cal-mday.other .cal-mnum { color: var(--text-3); }
.cal-mnum { align-self: flex-start; height: 26px; min-height: 0; min-width: 26px; padding: 0 7px; border: 0; border-radius: 99px; background: none; box-shadow: none;
  font-size: 12.5px; font-weight: 650; color: var(--text); }
.cal-mnum:hover { background: var(--hover); }
.cal-mday.today .cal-mnum { background: var(--accent); color: #fff; }
.cal-mitems { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-more { align-self: flex-start; height: 22px; min-height: 0; padding: 0 7px; border: 0; background: none; box-shadow: none; font-size: 12px; font-weight: 650; color: var(--text-2); }
.cal-more:hover { color: var(--accent); background: var(--hover); }

/* the phone's month: a small grid with dots, the day picked under it */
.cal-month.phone { background: none; border: 0; box-shadow: none; overflow: visible; }
.cal-month.phone .cal-mhead { border: 0; }
.cal-month.phone .cal-mhead > div { text-align: center; padding: 4px 0; }
.cal-pgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.cal-pday { height: 48px; min-height: 44px; padding: 4px 0; flex-direction: column; gap: 3px; border: 0; border-radius: 10px; background: none; box-shadow: none; font-size: 15px; font-weight: 600; color: var(--text); }
.cal-pday.other { color: var(--text-3); }
.cal-pday.today > span:first-child { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 99px; background: var(--accent); color: #fff; }
.cal-pday.sel { background: var(--accent-soft); }
.cal-dots { display: flex; gap: 3px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 99px; }
.cal-dots i.mk { border-radius: 1px; transform: rotate(45deg) scale(.85); }
.cal-month.phone .cal-lday { margin-top: 14px; }

/* ---------------------------------------------------------------- List (and search results) */
.cal-list { overflow-y: auto; padding: 4px 16px 16px; }
.cal-lday { padding: 6px 0; }
.cal-lday + .cal-lday { border-top: 1px solid var(--border); }
.cal-lday-h { margin: 8px 0 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.cal-lday.today .cal-lday-h { color: var(--accent); }
.cal-lrow { --ec: var(--accent); --lc: #64748b; display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 7px 10px; border-radius: 10px; color: var(--text);
  text-decoration: none; cursor: pointer; }
.cal-lrow:hover { background: var(--hover); color: var(--text); }
.cal-lt { flex: none; width: 96px; display: flex; flex-direction: column; gap: 2px; padding-top: 1px; font-size: 12.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal-lt small { font-weight: 400; color: var(--text-3); }
.cal-ldot { flex: none; width: 10px; height: 10px; margin-top: 4px; border-radius: 99px; background: var(--ec); }
.cal-lrow.tent .cal-ldot { background: none; box-shadow: inset 0 0 0 2px var(--ec); }
.cal-lrow.mark .cal-dia { margin: 5px 1px 0; }
.cal-lrow.mark .cal-lt { font-weight: 500; font-size: 12px; }
.cal-lrow.mark.late .cal-dia { background: var(--bad); }
.cal-lrow.mark.late b { color: var(--bad); }
.cal-lmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* many dates of one kind on a day: one row that lists them */
button.cal-lrow { width: 100%; height: auto; justify-content: flex-start; border: 0; background: none; box-shadow: none; font: inherit; text-align: left; white-space: normal; }
button.cal-lrow:hover { background: var(--hover); }
.cal-lrow.group .cal-lmain b { color: var(--text); }
.cal-late-n { color: var(--bad); font-weight: 650; }
.cal-lmain b { display: flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; min-width: 0; }
.cal-ln { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-lmain small { font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.cal-lnone { margin: 6px 4px; }
.cal-loadmore { align-self: center; margin: 14px auto 4px; }
.cal-empty { margin: 18px auto; max-width: 640px; box-shadow: none; }
.cal-found-h { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; padding: 8px 0 4px; color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------- the popover, the summary card, choices */
.cal-pop { position: fixed; z-index: 160; width: 340px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; padding: 14px 16px 14px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow-lg); }
.cal-pop.wide { width: 380px; }
.cal-pop.rem { width: 230px; padding: 6px; }
.cal-pop.rem .cal-pop-x { display: none; }
.cal-pop-x { position: absolute; top: 8px; right: 8px; }
.cal-pop.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto; max-width: none; max-height: 78vh; border-radius: 18px 18px 0 0;
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.cal-card { display: flex; flex-direction: column; gap: 8px; padding-right: 22px; }
.cal-card-h { display: flex; align-items: flex-start; gap: 10px; font-size: 16px; }
.cal-sw { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 4px; }
.cal-card-l { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); }
.cal-card-l svg { flex: none; margin-top: 2px; color: var(--text-3); }
.cal-card-d { margin: 4px 0 0; white-space: pre-wrap; font-size: 13px; overflow-wrap: anywhere; }
.cal-group h3 { margin: 0 28px 10px 0; font-size: 15px; }
.cal-group-l { display: flex; flex-direction: column; gap: 6px; }
.cal-menu { display: flex; flex-direction: column; }
.cal-menu-h { padding: 6px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cal-menu button { justify-content: flex-start; height: 36px; border: 0; background: none; box-shadow: none; font-weight: 500; }
.cal-menu button:hover, .cal-menu button:focus-visible { background: var(--hover); }
.cal-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.cal-choices button { justify-content: flex-start; height: 42px; }
.cal-keytable { border-collapse: collapse; }
.cal-keytable td { padding: 5px 18px 5px 0; vertical-align: top; }

/* ---------------------------------------------------------------- reminders (every page) */
.cal-rem { position: fixed; z-index: 140; right: 18px; bottom: 18px; width: 360px; max-width: calc(100vw - 24px); padding: 10px 12px 12px;
  background: var(--surface); border: 1px solid var(--border-2); border-left: 4px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow-lg); }
.cal-rem-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text); }
.cal-rem-h svg { color: var(--accent); }
.cal-rem-h .spacer { flex: 1; }
.cal-rem-l { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.cal-rem-i + .cal-rem-i { padding-top: 10px; border-top: 1px solid var(--border); }
.cal-rem-t { display: block; font-size: 14.5px; overflow-wrap: anywhere; }
.cal-rem-w { margin-top: 2px; font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.cal-rem-w.now { color: var(--accent); font-weight: 650; }
.cal-rem-w span { font-weight: 400; color: var(--text-2); }
.cal-rem-a { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.cal-rem-more { margin-top: 8px; }

/* ---------------------------------------------------------------- narrower: the drawer pulls out */
.cal[data-mode="mid"] .cal-body, .cal[data-mode="phone"] .cal-body { grid-template-columns: minmax(0, 1fr); }
.cal[data-mode="mid"] .cal-drawer-btn, .cal[data-mode="phone"] .cal-drawer-btn { display: inline-flex; }
.cal[data-mode="mid"] .cal-drawer { position: fixed; z-index: 150; top: 0; bottom: 0; left: 0; width: 300px; max-width: 86vw; padding: 14px 14px 20px;
  background: var(--bg-elev); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: translateX(-104%); transition: transform .18s ease; }
.cal[data-mode="mid"].drawer-open .cal-drawer { transform: none; }
.cal[data-mode="mid"] .cal-drawer-h, .cal[data-mode="phone"] .cal-drawer-h { display: flex; align-items: center; justify-content: space-between; }
.cal.drawer-open .cal-scrim { display: block; position: fixed; inset: 0; z-index: 145; background: var(--scrim); }
.cal[data-mode="mid"] .cal-print { display: none; }

/* ---------------------------------------------------------------- a phone */
.cal[data-mode="phone"] { gap: 8px; }
.cal[data-mode="phone"] .cal-top { gap: 4px; }
.cal[data-mode="phone"] .cal-drawer-btn .cal-l, .cal[data-mode="phone"] .cal-new, .cal[data-mode="phone"] .cal-print, .cal[data-mode="phone"] .cal-keys { display: none; }
.cal[data-mode="phone"] .cal-top button, .cal[data-mode="phone"] .cal-top .btn { min-height: 44px; height: 44px; }
.cal[data-mode="phone"] .cal-drawer-btn, .cal[data-mode="phone"] .cal-arrows button, .cal[data-mode="phone"] .cal-gear { width: 44px; padding: 0; }
/* a phone's toolbar: [calendars] [Today] [< >] ... [search] [settings] / the range + Day Month List / the search box */
.cal[data-mode="phone"] .cal-drawer-btn { order: 1; }
.cal[data-mode="phone"] .cal-today { order: 2; padding: 0 12px; }
.cal[data-mode="phone"] .cal-arrows { order: 3; }
.cal[data-mode="phone"] .cal-top .spacer { order: 4; display: block; }
.cal[data-mode="phone"] .cal-sbtn { order: 5; display: inline-flex; width: 44px; padding: 0; }
.cal[data-mode="phone"] .cal-gear { order: 6; }
.cal[data-mode="phone"] .cal-range { order: 10; flex: 1 1 45%; margin: 0 2px; font-size: 17px; }      /* its own row with the views */
.cal[data-mode="phone"] .cal-views { order: 11; flex: none; }
.cal[data-mode="phone"] .cal-views > button { min-width: 0; height: 38px; min-height: 38px; padding: 0 11px; }
.cal[data-mode="phone"] .cal-search { order: 20; flex: 1 1 100%; max-width: none; height: 44px; display: none; }
.cal[data-mode="phone"].searching .cal-search, .cal[data-mode="phone"] .cal-search:focus-within { display: flex; }
.cal[data-mode="phone"] .cal-search input { font-size: 16px; }
.cal[data-mode="phone"] .cal-drawer { position: fixed; z-index: 150; left: 0; right: 0; bottom: 0; max-height: 82vh; padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg-elev); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); transform: translateY(105%); transition: transform .2s ease; }
.cal[data-mode="phone"].drawer-open .cal-drawer { transform: none; }
.cal[data-mode="phone"] .cal-chk, .cal[data-mode="phone"] .cal-colleague { min-height: 44px; font-size: 15px; }
.cal[data-mode="phone"] .cal-chk input { width: 20px; height: 20px; }
.cal[data-mode="phone"] .cal-addcol { height: 44px; font-size: 16px; }
.cal[data-mode="phone"] .cal-mini-d { height: 40px; font-size: 14px; }
.cal[data-mode="phone"] .cal-view:not(.cal-month) { flex: none; }
.cal[data-mode="phone"] .cal-tg .cal-scroll { flex: none; height: calc(100dvh - 250px - var(--tabs-h)); min-height: 380px; }
.cal[data-mode="phone"] .cal-tg { --gut: 46px; }
.cal[data-mode="phone"] .cal-list { background: none; border: 0; box-shadow: none; padding: 0 0 80px; overflow: visible; }
.cal[data-mode="phone"] .cal-lrow { min-height: 56px; padding: 10px 12px; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--border); }
.cal[data-mode="phone"] .cal-lday + .cal-lday { border-top: 0; }
.cal[data-mode="phone"] .cal-lt { width: 74px; }
.cal[data-mode="phone"] .cal-lmain b { font-size: 15px; }
.cal[data-mode="phone"] .cal-loadmore { min-height: 44px; }
.cal[data-mode="phone"] .cal-month.phone .cal-lrow { margin-bottom: 6px; }
.cal[data-mode="phone"] .cal-fab { display: inline-flex; position: fixed; right: 16px; bottom: calc(16px + var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 30;
  height: 56px; min-width: 56px; padding: 0 20px; gap: 8px; border-radius: 99px; font-size: 15px; box-shadow: var(--shadow-lg); }
.cal[data-mode="phone"].drawer-open .cal-fab, body:has(#cal-rem) .cal[data-mode="phone"] .cal-fab { display: none; }   /* a reminder waits for its answer first */
@media (max-width: 699px) {
  body.cal-on main#view { padding-bottom: calc(28px + var(--tabs-h)); }
  .cal-rem { left: 10px; right: 10px; width: auto; bottom: calc(10px + var(--tabs-h) + env(safe-area-inset-bottom)); }
  .cal-rem-a button { min-height: 44px; }
  .cal-pop.rem { width: auto; }
  .cal-pop .cal-menu button { min-height: 48px; }
}
/* nightly 2026-11-16 admin2#8: a reminder never covers an open compose window (its Send button is bottom right):
   next to the window when there is room, else at the top and under the window (the window's buttons stay on top) */
body:has(.mcw) .cal-rem { right: 652px; }
@media (max-width: 1099px) {
  body:has(.mcw) .cal-rem { right: 18px; left: auto; top: 64px; bottom: auto; z-index: 79; }
}
body:has(.mcw.max) .cal-rem { right: 18px; left: auto; top: 64px; bottom: auto; z-index: 79; }
@media (max-width: 699px) {
  body:has(.mcw) .cal-rem { left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); }
}

/* ---------------------------------------------------------------- print: the view on screen, black on white */
@media print {
  body.cal-on main#view { padding: 0; }
  .cal { --text: #000; --text-2: #222; --text-3: #555; --surface: #fff; --surface-2: #fff; --bg: #fff; --border: #999; --cal-line: #bbb; --cal-half: #e5e5e5;
    --cal-off: #f2f2f2; --accent: #000; --accent-soft: transparent; height: auto !important; color: #000; }
  .cal-top > :not(.cal-range), .cal-drawer, .cal-scrim, .cal-fab, .cal-banner, .cal-hint, .cal-loadmore, .cal-busy-key, .cal-rem, .cal-pop, #cal-rem { display: none !important; }
  .cal-range { font-size: 16pt; }
  .cal-body { display: block; }
  .cal-view { border: 1px solid #999; box-shadow: none; overflow: visible; }
  .cal-scroll, .cal-mgrid, .cal-list { overflow: visible !important; height: auto !important; }
  .cal-top-sticky { position: static; box-shadow: none; }
  .cal-strip-grid { max-height: none; }
  .cal-ev, .cal-chip.filled { background: #fff !important; border: 1px solid #000; border-left-width: 3px; outline: none; filter: none; }
  .cal-ev.tent { border-style: dashed; }
  .cal-mark { background: #fff; border-color: #555; }
  .cal-mark.late { color: #000; border-width: 2px; }
  .cal-now, .cal-sel { display: none; }
  .cal-dh.today .cal-dh-n, .cal-mday.today .cal-mnum { background: none; color: #000; text-decoration: underline; }
  .cal-mday { break-inside: avoid; }
}
