/* Component styles. Colours come only from var(--…) tokens in tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: 15px/1.45 var(--font-sans);
}
.mono, .timelabel, .colhead, .tz-text, .debug code { font-family: var(--font-mono); }
/* The "·" between parts of a line, in a subtle colour. */
.sep { color: var(--color-sep); }
.timelabel, .colhead, .daynum, .dow, .picker-day, .tz-opt .off, .debug, .period-label { font-variant-numeric: tabular-nums; }
a { color: var(--color-link); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
h1, h2 { line-height: 1.2; }
code { font-family: var(--font-mono); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--space-2); top: -100px; z-index: 100; }
.skip-link:focus { top: var(--space-2); background: var(--color-bg); padding: var(--space-2); }

.icon { width: 16px; height: 16px; flex: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 2.25rem; padding: 0.3rem 0.6rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-bg); color: var(--color-text);
  font: inherit; font-size: 0.9rem; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--color-surface-2); }
.btn-icon { width: 2.25rem; padding: 0; font-size: 1.15rem; }
.btn-primary { background: var(--color-link); border-color: var(--color-link); color: var(--color-on-accent); }
.btn-primary:hover { background: var(--color-link); filter: brightness(1.08); }
.btn[aria-disabled="true"] { color: var(--color-text-muted); cursor: default; background: var(--color-surface); }

/* Pills: fully rounded, with more inline padding than the view tabs. */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 2.25rem; padding: 0.3rem 1rem;
  border: 1px solid var(--color-border); border-radius: 9999px;
  background: var(--color-bg); color: var(--color-text);
  font: inherit; font-size: 0.9rem; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.pill:hover { background: var(--color-surface-2); }
.pill.round { width: 2.25rem; padding: 0; font-size: 1.15rem; }
.pill-primary { background: var(--color-link); border-color: var(--color-link); color: var(--color-on-accent); }
.pill-primary:hover { background: var(--color-link); filter: brightness(1.08); }
.pill[aria-disabled="true"] { color: var(--color-text-muted); cursor: default; background: var(--color-surface); }

/* ---------------------------------------------------------------- page frame */
.page-calendar { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }

/* ---------------------------------------------------------------- top bar */
/*
 * Three groups: controls on the left, context (period, zone) centred, pages on
 * the right. The side columns share the free space equally, so the centre is
 * centred; they never shrink below their content.
 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: minmax(max-content, 1fr) minmax(0, max-content) minmax(max-content, 1fr);
  grid-template-areas: "left centre right"; align-items: center; gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg); border-bottom: 1px solid var(--color-divider);
}
.tb-left, .tb-centre, .tb-right { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.tb-left { grid-area: left; justify-self: start; }
.tb-centre { grid-area: centre; justify-self: stretch; justify-content: center; }
.tb-right { grid-area: right; justify-self: end; }
/* View tabs: a segmented control. The active tab is marked by fill and an underline only, so no tab changes width. */
.tb-tabs { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; flex: none; }
.tab {
  display: inline-flex; align-items: center; min-height: 2.15rem; padding: 0.3rem 0.7rem;
  color: var(--color-text); text-decoration: none; font-size: 0.9rem;
}
.tab + .tab { border-left: 1px solid var(--color-border); }
.tab:hover { background: var(--color-surface-2); }
.tab[aria-current="page"] { background: var(--color-surface-2); box-shadow: inset 0 -2px 0 var(--color-link); }
.period-label { margin: 0; font-size: 1rem; font-weight: 400; white-space: nowrap; }
.tz-button { gap: var(--space-1); padding: 0.2rem 0.6rem 0.2rem 0.85rem; min-height: 2rem; font-size: 0.85rem; color: var(--color-text-muted); max-width: 100%; min-width: 0; }
.tz-button:hover { color: var(--color-text); }
.tz-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.icon-step { width: 16px; height: 16px; }
.tb-menu { display: none; }
.tb-menu-items {
  /* Inline on wide screens: overrides the popover's hidden state. */
  display: flex; gap: var(--space-2); position: static; inset: auto; margin: 0; padding: 0;
  border: 0; background: none; color: inherit; overflow: visible; width: auto; height: auto;
}
.tb-indicator { color: var(--color-warning); border-color: var(--color-warning); }
.tb-indicator.sev-error { color: var(--color-error); border-color: var(--color-error); }

/* Dark by default: the toggle shows the sun (switch to light), the moon in light mode. See "motion". */

/* ---------------------------------------------------------------- main regions */
.main {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cal bar";
  min-height: 0; overflow: hidden;
}
.cal-wrap { grid-area: cal; position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.cal-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; container-type: size; overscroll-behavior: contain; }

/* ---------------------------------------------------------------- columns (Day, Week, short Range) */
.cols {
  --row-h: 1.75rem;
  display: grid; grid-template-rows: var(--head-h) repeat(48, var(--row-h));
  min-width: min-content;
}
@supports (height: 1cqh) {
  .cols { --row-h: max(var(--row-min), calc((100cqh - var(--head-h)) / (var(--visible-hours) * 2))); }
}
.cols.n1 { grid-template-columns: var(--time-col-w) minmax(0, 40rem); }
/* Stacking, bottom to top: cells, greyed past, the now line, time labels, focus, column headers, corner. */
.corner, .colhead { position: sticky; top: 0; background: var(--color-bg); border-bottom: 1px solid var(--color-grid); }
.corner { left: 0; z-index: 7; }
.colhead {
  z-index: 6; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.colhead.is-today { color: var(--color-now); }
.cols { background: var(--color-bg); }
.timelabel {
  position: sticky; left: 0; z-index: 4; background: var(--color-bg);
  font-size: 0.75rem; color: var(--color-text-muted); text-align: right; padding: 0 var(--space-2) 0 0;
  line-height: 1; padding-top: 2px;
  scroll-margin-top: var(--head-h);
}
.slot {
  position: relative; border-right: 1px solid var(--color-grid); border-bottom: 1px solid var(--color-grid);
  background-repeat: repeat;
}
.slot:focus-visible, .daycell:focus-visible {
  outline: 3px solid var(--color-focus); outline-offset: -3px; z-index: 5;
  box-shadow: inset 0 0 0 5px var(--color-bg);
}
/*
 * Past time is dimmed: a veil in the page colour over a less saturated palette
 * colour (.past.pN in calendar.css). The dither still shows. Only the slot
 * holding now uses a backdrop filter, for its past part; one cell is cheap.
 */
.slot.past::after, .slot.split::after, .daycell.past::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: var(--color-veil);
}
.slot.split::after { bottom: auto; -webkit-backdrop-filter: saturate(0.5); backdrop-filter: saturate(0.5); }
.daycell.out::before {
  content: ""; position: absolute; inset: 0; z-index: 1; background: var(--color-veil); pointer-events: none;
}
.now-line {
  position: absolute; left: -1px; right: 0; height: 3px; margin-top: -1px; z-index: 2;
  background: var(--color-now); box-shadow: 0 0 0 1px var(--color-bg); pointer-events: none;
}

/* ---------------------------------------------------------------- day cells (Month, long Range) */
.cal-scroll[data-layout="cells"] { container-type: normal; }
.month {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto; grid-auto-rows: minmax(3.5rem, 1fr);
  gap: 1px; min-height: 100%; background: var(--color-grid);
}
.dow {
  position: sticky; top: 0; z-index: 2; background: var(--color-bg);
  text-align: center; font-size: 0.8rem; font-weight: 600; padding: var(--space-1) 0;
}
.daycell { position: relative; display: block; text-decoration: none; background-repeat: repeat; }
/*
 * Hover on a cell (Month and long Range days, Day/Week/Range slots): a thin
 * ring of grid colour grows in from the cell's edge, so it looks slightly shrunk. The ring is an inset
 * shadow painted over the background, so the cell and its dither pattern never
 * change size. Works over any cell colour, in both themes, and doesn't clash
 * with today's outline or the focus ring. Pointer devices only, so taps don't
 * leave a ring behind; not while drag-scrolling.
 */
.daycell, .slot { box-shadow: inset 0 0 0 0 var(--color-grid); transition: box-shadow var(--motion-hover); }
@media (hover: hover) {
  .daycell:hover, .slot:hover:not(:focus-visible) { box-shadow: inset 0 0 0 2px var(--color-grid); }
  .cal-scroll.is-dragging .daycell:hover, .cal-scroll.is-dragging .slot:hover { box-shadow: inset 0 0 0 0 var(--color-grid); }
}
.daynum {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  min-width: 1.6rem; padding: 0 0.3rem; border-radius: 2px; text-align: center;
  background: var(--color-bg); color: var(--color-text); font-size: 0.8rem; font-weight: 600;
}
.daycell.out .daynum { color: var(--color-text-muted); }
/* Today: the now line's red, with the same thin page-colour edge. */
.daycell.is-today { outline: 3px solid var(--color-now); outline-offset: -3px; z-index: 3; }
.daycell.is-today::before { content: ""; position: absolute; inset: 3px; z-index: 3; box-shadow: 0 0 0 1px var(--color-bg); pointer-events: none; }

/* ---------------------------------------------------------------- colour bar */
.colourbar {
  grid-area: bar; display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  padding: var(--space-2); border-left: 1px solid var(--color-divider); font-size: 0.75rem; color: var(--color-text-muted);
}
.cb-ramp { flex: 1; width: 1.25rem; display: flex; flex-direction: column-reverse; gap: 1px; border: 1px solid var(--color-grid); background: var(--color-grid); border-radius: 3px; overflow: hidden; }
.cb-band { flex: 1; background-repeat: repeat; }

/* ---------------------------------------------------------------- notices */
.notices {
  position: absolute; top: var(--space-2); right: var(--space-3); z-index: 20;
  display: flex; flex-direction: column; gap: var(--space-2);
  width: min(24rem, calc(100% - 2 * var(--space-3))); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-left: 4px solid var(--color-warning); border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--color-shadow);
}
.toast > .icon, .toast-icon .icon { margin-top: 0.15rem; color: var(--color-warning); }
.toast-error { border-left-color: var(--color-error); }
.toast-error > .icon, .toast-error .toast-icon .icon { color: var(--color-error); }
.toast-msg { margin: 0; flex: 1; font-size: 0.9rem; padding-top: 0.05rem; }
.toast-btn { width: 1.75rem; min-height: 1.75rem; font-size: 1rem; }

.inline-notice {
  display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) var(--space-3);
  padding: var(--space-1) var(--space-2); font-size: 0.9rem;
  border-left: 4px solid var(--color-warning); background: var(--color-surface);
}
.inline-notice > .icon { color: var(--color-warning); }
.js .inline-notice { display: none; }

/* ---------------------------------------------------------------- error panel */
.error-panel {
  margin: var(--space-6) auto; max-width: 36rem; width: calc(100% - 2 * var(--space-4));
  padding: var(--space-4) var(--space-6); background: var(--color-surface);
  border: 1px solid var(--color-error); border-left: 6px solid var(--color-error); border-radius: 2px;
}
.error-panel > .icon { display: block; width: 20px; height: 20px; margin: var(--space-3) 0 var(--space-2); color: var(--color-error); }
.error-panel h2 { margin: var(--space-2) 0; color: var(--color-error); font-size: 1.25rem; }
.error-panel .debug { margin-top: var(--space-4); color: var(--color-text-muted); font-size: 0.85rem; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- range form */
.range-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); position: relative;
}
.range-to { color: var(--color-text-muted); font-size: 0.9rem; }
.range-form input[type="date"], .tz-form select, .tz-pop input {
  font-variant-numeric: tabular-nums;
  font: inherit; font-size: 0.9rem; color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.3rem 0.5rem; min-height: 2.25rem;
}
.range-form .inline-notice { flex-basis: 100%; margin: 0; }

/* ---------------------------------------------------------------- popovers built by JS */
.picker, .tz-pop {
  position: absolute; z-index: 40; background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 8px 28px var(--color-shadow); padding: var(--space-3);
}
.picker { top: calc(100% + 4px); left: var(--space-3); width: 17.5rem; }
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); font-weight: 600; font-size: 0.9rem; }
.picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.picker-dow { text-align: center; font-size: 0.75rem; color: var(--color-text-muted); padding: var(--space-1) 0; }
.picker-day {
  height: 2.1rem; border: 0; border-radius: var(--radius); background: none; color: var(--color-text);
  font: inherit; font-size: 0.85rem; cursor: pointer;
}
.picker-day:hover { background: var(--color-surface-2); }
.picker-day.other { color: var(--color-text-muted); }
.picker-day.in-range { background: var(--color-surface-2); border-radius: 0; }
.picker-day.is-start, .picker-day.is-end { background: var(--color-link); color: var(--color-on-accent); border-radius: var(--radius); }
.picker-day.is-today { box-shadow: inset 0 0 0 1px var(--color-border); }

/* The zone dropdown: a shadcn-style command list. Hover and keyboard share one highlight (a lighter fill), no outline. */
.tz-pop { position: fixed; width: min(22rem, calc(100vw - 2 * var(--space-4))); padding: 0; border-radius: var(--radius); overflow: hidden; }
.tz-pop input {
  width: 100%; border: 0; border-bottom: 1px solid var(--color-divider); border-radius: 0;
  padding: 0.55rem var(--space-3); background: transparent;
}
.tz-pop input:focus-visible { outline: none; border-bottom-color: var(--color-focus); }
.tz-current { margin: 0; padding: var(--space-2) var(--space-3) var(--space-1); font-family: var(--font-mono); font-size: 0.8rem; color: var(--color-text-muted); }
.tz-list { list-style: none; margin: 0; padding: var(--space-1); max-height: min(50vh, 24rem); overflow: auto; }
.tz-group { padding: var(--space-2) var(--space-2) var(--space-1); font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted); }
.tz-opt {
  padding: 0.375rem var(--space-2); border-radius: 4px; font-size: 0.9rem; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
}
.tz-opt .name { display: inline-flex; align-items: center; gap: var(--space-2); }
.tz-opt .off { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.tz-opt:hover, .tz-opt[aria-selected="true"] { background: var(--color-surface-2); }
.tz-empty { padding: var(--space-2); color: var(--color-text-muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------- dialogs */
.dialog {
  border: 1px solid var(--color-divider); border-radius: calc(var(--radius) + 4px);
  background: var(--color-bg); color: var(--color-text); padding: 0;
  width: min(30rem, calc(100vw - 2 * var(--space-4))); max-height: min(85vh, 48rem);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog-wide { width: min(40rem, calc(100vw - 2 * var(--space-4))); }
.dialog::backdrop { background: var(--color-shadow); }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  /* Same inline padding as the body, so Close lines up with the content's right edge (Cancel, Copy). */
  padding: var(--space-3) var(--space-6); border-bottom: 1px solid var(--color-divider);
}
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: var(--space-4) var(--space-6) var(--space-6); overflow: auto; }
.dialog-body .help h3 { font-size: 1rem; margin: 0 0 var(--space-2); }
.actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); }
.page-sub .actions { justify-content: flex-start; }

/* ---------------------------------------------------------------- contact */
.lede { font-size: 1rem; }
.contact-list { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; gap: var(--space-2) var(--space-4); align-items: center; margin: 0; }
.contact-row { display: contents; }
.contact-list dt { color: var(--color-text-muted); display: flex; align-items: center; gap: var(--space-2); }
.icon-brand { width: 18px; height: 18px; flex: none; color: var(--color-text); }
.contact-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.contact-list .copy-cell { justify-self: end; }
.copy-btn { display: inline-grid; min-height: 2rem; padding: 0.2rem 0.55rem; }
.copy-state { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); visibility: hidden; }
.copy-btn:not([data-state]) .copy-idle,
.copy-btn[data-state="idle"] .copy-idle,
.copy-btn[data-state="done"] .copy-done,
.copy-btn[data-state="fail"] .copy-fail { visibility: visible; }
.copy-btn[data-state="fail"] { color: var(--color-error); border-color: var(--color-error); }

/* ---------------------------------------------------------------- sub-pages */
.subheader {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider);
}
.subheader h1 { margin: 0; font-size: 1.1rem; flex: 1; }
.sub-main { max-width: 44rem; margin: 0 auto; padding: var(--space-4); }
.help section + section { margin-top: var(--space-6); }
.help h2, .help h3 { font-size: 1.1rem; margin: 0 0 var(--space-2); }
.help dt { font-weight: 600; margin-top: var(--space-2); }
.help dd { margin-left: 0; }
.tz-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.tz-form select { max-width: 100%; }
.note { color: var(--color-text-muted); }

/* ---------------------------------------------------------------- top bar: two rows */
/*
 * When the three groups don't fit in one row: row 1 is the context (left) and
 * the pages (right); row 2 the controls. Achieved with CSS only; the HTML order
 * is the same at every width.
 */
@media (max-width: 1160px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "centre right" "left left";
    gap: var(--space-2) var(--space-2); padding: var(--space-2);
  }
  .tb-centre { justify-self: stretch; justify-content: flex-start; }
  /* The zone selector takes what row 1 has left and truncates, so nothing wraps. */
  .tz-button { flex: 0 1 auto; min-width: 0; justify-content: space-between; }
  .tb-right { gap: var(--space-1); }
}

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 640px) {
  body { font-size: 14px; }
  /* Row 2 fills the width with bigger tap targets: the tabs share the free space. */
  .tb-left { justify-self: stretch; }
  .tb-tabs { flex: 1 1 auto; }
  .tab { flex: 1 1 auto; justify-content: center; padding: 0.25rem 0.3rem; font-size: 0.85rem; min-height: 2.75rem; }
  .tb-today { padding: 0.25rem 0.6rem; min-height: 2.75rem; margin-left: var(--space-1); }
  .pill.round.tb-prev, .pill.round.tb-next { width: 2.5rem; min-height: 2.75rem; }
  .period-label { padding-inline: var(--space-2) var(--space-1); font-size: 0.9rem; }
  .tz-button { font-size: 0.8rem; padding: 0.2rem 0.4rem 0.2rem 0.6rem; }
  .tb-menu { display: inline-flex; }
  .tb-menu-items {
    position: fixed; inset: auto; top: 3.25rem; right: var(--space-2); margin: 0;
    flex-direction: column; align-items: stretch; padding: var(--space-2);
    background: var(--color-bg); border: 1px solid var(--color-divider); border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 8px 28px var(--color-shadow);
  }
  .tb-menu-items:not(:popover-open) { display: none; }
  /* Grows from the menu button. Its exit is instant: popovers close natively. */
  .tb-menu-items:popover-open { transform-origin: top right; --grow-from: var(--grow-nudge) calc(-1 * var(--grow-nudge)); animation: grow-in var(--motion-in); }

  .main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "bar" "cal"; }
  .colourbar { flex-direction: row-reverse; border-left: 0; border-bottom: 1px solid var(--color-divider); padding: 2px var(--space-2); }
  .cb-ramp { flex-direction: row; width: auto; height: 0.6rem; }
  .notices { left: var(--space-2); right: var(--space-2); width: auto; }
  .range-form { padding: var(--space-2); }
  .month { grid-auto-rows: minmax(3rem, 1fr); }
  .dialog-head { padding-inline: var(--space-4); }
  .dialog-body { padding: var(--space-3) var(--space-4) var(--space-4); }
}

/* ================================================================ motion */
/*
 * "Grow from the source": everything that appears grows out of the control
 * that opened it (transform-origin plus a small nudge from that side), and
 * shrinks back into it when it goes. Exits are quicker than entrances.
 * JS adds .is-closing / .anim-* classes for exits; see public/js/app.js.
 */
@keyframes grow-in { from { opacity: 0; scale: var(--grow-scale); translate: var(--grow-from, 0 0); } }
@keyframes grow-out { to { opacity: 0; scale: var(--grow-scale); translate: var(--grow-from, 0 0); } }
/* A sticky toast shrinking into the notice indicator, and coming back out of it. */
@keyframes shrink-to-point { to { opacity: 0; scale: 0.2; translate: var(--point, 0 0); } }
@keyframes grow-from-point { from { opacity: 0; scale: 0.2; translate: var(--point, 0 0); } }
@keyframes pop-in { from { opacity: 0; scale: 0.6; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* Dialogs open from the top right, where Download, Contact and Help are. */
.dialog { transform-origin: top right; --grow-from: var(--grow-nudge) calc(-1 * var(--grow-nudge)); }
.dialog[open] { animation: grow-in var(--motion-in); }
.dialog[open]::backdrop { animation: fade-in var(--motion-in); }
.dialog.is-closing { animation: grow-out var(--motion-out) forwards; }
.dialog.is-closing::backdrop { animation: fade-out var(--motion-out) forwards; }

/* Toasts sit at the top right and grow from there. */
.toast { transform-origin: top right; --grow-from: var(--grow-nudge) calc(-1 * var(--grow-nudge)); }
.toast.anim-in { animation: grow-in var(--motion-in); }
.toast.anim-out { animation: grow-out var(--motion-out) forwards; }
.toast.anim-to-point { transform-origin: center; animation: shrink-to-point var(--motion-in) forwards; }
.toast.anim-from-point { transform-origin: center; animation: grow-from-point var(--motion-in); }
.tb-indicator.anim-in { animation: pop-in var(--motion-in); }

/* Popovers built by JS: JS sets transform-origin under the control that opened them. */
.tz-pop, .picker { --grow-from: 0 calc(-1 * var(--grow-nudge)); }
.tz-pop.anim-in, .picker.anim-in { animation: grow-in var(--motion-in); }
.tz-pop.anim-out, .picker.anim-out { animation: grow-out var(--motion-out) forwards; }

/* Copy: the label cross-fades in place; the button's width never changes. */
.copy-state { opacity: 0; transition: opacity var(--motion-ui), visibility 0s linear 100ms; }
.copy-btn:not([data-state]) .copy-idle,
.copy-btn[data-state="idle"] .copy-idle,
.copy-btn[data-state="done"] .copy-done,
.copy-btn[data-state="fail"] .copy-fail { opacity: 1; transition: opacity var(--motion-ui), visibility 0s; }

/* Theme icons swap with a quarter turn. Page colours switch instantly. */
.theme-toggle { display: inline-grid; place-items: center; }
.theme-toggle .icon { grid-area: 1 / 1; display: inline; transition: opacity var(--motion-in), rotate var(--motion-in); }
.theme-toggle .icon-moon, :root[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; rotate: -90deg; }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; rotate: 0deg; }

/* The now line and the split slot glide to their new place each minute. */
.now-line { transition: top var(--motion-glide); }
.slot.split::after { transition: height var(--motion-glide); }

/* Hover and press, the same on every control. */
.pill, .btn, .tab, .picker-day, .tz-opt { transition: background-color var(--motion-ui), color var(--motion-ui), scale var(--motion-ui); }
.pill:active, .btn:active, .tab:active, .picker-day:active { scale: 0.97; }

/* Drag to scroll with a mouse (JS): a grab cursor, and no text selection mid-drag. */
.js .cal-scroll { cursor: grab; }
.js .cal-scroll .daycell { cursor: pointer; -webkit-user-drag: none; }
.cal-scroll.is-dragging, .cal-scroll.is-dragging * { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* No motion at all when the viewer asks for less. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop {
    animation-duration: 0s !important; animation-delay: 0s !important;
    transition-duration: 0s !important; transition-delay: 0s !important;
  }
  .pill:active, .btn:active, .tab:active, .picker-day:active { scale: none; }
}
