/* "Linen": warm cream, a serif for titles and day numbers, soft floating cards, terracotta accent.
   --display is a local serif stack: the CSP (server.js) is default-src 'self', so a hosted webfont would be
   blocked; to use one (Fraunces), drop the files in public/, add them to STATIC_FILES and @font-face it here. */
:root {
  --bg: #f4efe6;
  --card: #fffcf6;
  --fg: #2a2420;
  --muted: #7a6f66;
  --line: #e6ddd0;
  --accent: #b5522c;
  --accent-soft: #f3dfd4;
  --on-accent: #fff;
  --ok: #3f6b3a;
  --ok-bg: #e3ecd9;
  --err: #a33a2a;
  --maybe: #a4661c;
  --code-bg: #efe8dc;
  --ev-bg: #f2e6cf;
  --ev-fg: #6b4f1a;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 8px 24px -12px rgb(60 40 20 / .18);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --gap: 6px; /* between calendar cells; .ev-text and .ev.from count on it */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg) radial-gradient(1200px 500px at 50% -10%, #fff8ea, transparent 70%) no-repeat;
}
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1.2rem;
  padding: .9rem 1.4rem;
  max-width: 960px;
  margin: 0 auto;
}
header .brand { font: 700 1.5rem var(--display); letter-spacing: -.01em; text-decoration: none; color: var(--fg); margin-right: auto; }
/* nav has the popover attribute (the phone menu); the last six lines undo the browser's popover look
   on wide screens. */
nav {
  display: flex;
  gap: .3rem;
  align-items: center;
  flex-wrap: wrap;
  position: static;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  overflow: visible;
}
.menu-btn { display: none; font-size: 1.3rem; line-height: 1; padding: .2rem .5rem; }
@media (max-width: 600px) {
  .menu-btn { display: block; }
  nav:not(:popover-open) { display: none; }
  nav:popover-open {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(16rem, 80vw);
    height: 100%;
    box-sizing: border-box;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: .6rem;
    padding: 1.2rem;
    background: var(--card);
    border-right: 1px solid var(--line);
    box-shadow: 4px 0 16px rgb(0 0 0 / .15);
  }
  nav::backdrop { background: rgb(0 0 0 / .35); }
}
nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; padding: .3rem .6rem; border-radius: 999px; }
nav a:hover { color: var(--fg); }
nav a.active { color: var(--accent); background: var(--accent-soft); } /* app.js marks the current page */
nav button.link { color: var(--muted); font-weight: 500; }
/* The language menu (templates/language-menu.html): the icon at the end of the nav, or at the top right of a
   logged-out page's header, opening a small list under it. In the phone menu it reads "icon Language" and its
   list opens in place, under it. */
.lang-menu { position: relative; margin: 0; }
.lang-menu summary {
  display: flex; align-items: center; gap: .4rem; list-style: none; cursor: pointer;
  color: var(--muted); font-weight: 500; font-size: .95rem; padding: .3rem .6rem; border-radius: 999px;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { color: var(--fg); }
.lang-menu svg { width: 1.25rem; height: 1.25rem; fill: currentColor; }
.lang-label { display: none; }
.lang-menu form {
  position: absolute; right: 0; top: calc(100% + .3rem); z-index: 10;
  display: flex; flex-direction: column; min-width: 9rem; padding: .3rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.lang-menu form button.link { text-align: left; padding: .35rem .7rem; border-radius: 8px; color: var(--fg); text-decoration: none; }
.lang-menu form button.link:hover { background: var(--accent-soft); }
.lang-menu button[aria-current]::after { content: " ✓"; color: var(--accent); }
@media (max-width: 600px) {
  nav .lang-label { display: inline; }
  nav .lang-menu form { position: static; min-width: 0; padding: .2rem 0 0 1.6rem; background: none; border: 0; box-shadow: none; }
}
main { max-width: 900px; margin: 0 auto; padding: 1rem; }
h1 { font: 700 2.2rem/1.1 var(--display); letter-spacing: -.02em; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 1.2rem 0 .8rem; }
/* the month arrows: round buttons */
h1 a {
  color: var(--accent);
  text-decoration: none;
  font-size: 1.8rem;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
}
/* Today, after the arrows while another month is on screen: a pill at body size (wraps under them on a phone) */
h1 a.today-link { width: auto; height: auto; padding: .3rem .9rem; border-radius: 999px; font: 600 .9rem system-ui, sans-serif; letter-spacing: 0; }
h2 { font: 700 1.3rem var(--display); letter-spacing: -.01em; margin: 2rem 0 .6rem; }
.hint { color: var(--muted); font-size: .9rem; }
/* a subtitle right under a page title, like the version on Settings */
h1 + .hint { margin-top: -.6rem; }
.err { color: var(--err); }
/* A form error sits right under its field: tight above, a little room below. */
p.err { margin: .3rem 0 .6rem; }
.stack > p.err { margin: -.5rem 0 0; }
.ok { color: var(--ok); }
input, select, button {
  font: inherit;
  padding: .45rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
}
button { background: var(--accent); color: var(--on-accent); border-color: var(--accent); cursor: pointer; font-weight: 600; box-shadow: var(--shadow); }
button.link { background: none; color: var(--accent); border: none; padding: 0; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; font-weight: 500; }
button.danger, .danger { color: var(--err); }
button.danger:not(.link) { background: var(--card); border-color: var(--line); color: var(--err); }
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: .5rem .9rem;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.stack { display: grid; gap: .8rem; max-width: 360px; }
.stack label { display: grid; grid-template-columns: minmax(0, 1fr); gap: .2rem; }
.stack label.check { display: flex; align-items: center; gap: .4rem; }
/* Event form: an all-day event has no times, so its time inputs are hidden. */
form:has(#all-day:checked) input[type=time] { display: none; }
/* Repeat: one that does not repeat has no end; only "Custom…" shows its fields, and its unit which of them (the
   weekdays for weeks, which day for months). "This event" of a repeating one hides what is the whole event's. */
form:has(#repeats option[value=""]:checked) .repeat-ends,
form:not(:has(#repeats option[value=custom]:checked)) .repeat-custom,
.repeat-custom:not(:has(option[value=WEEKLY]:checked)) .repeat-weekdays,
.repeat-custom:not(:has(option[value=MONTHLY]:checked)) .repeat-monthly,
form:has(input[name=scope][value=one]:checked) :is(.repeat, .visibility) { display: none; }
/* minmax(0, 1fr): a select as wide as its longest option (French ones are long) shrinks to the phone, not the reverse. */
.repeat, .repeat-custom, .repeat-ends, .scope { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.repeat-ends, .scope { border: none; padding: 0; margin: 0; gap: .3rem; }
.repeat-ends legend, .scope legend { padding: 0; margin-bottom: .3rem; }
.repeat input[type=number] { width: 4.5rem; }
/* Custom's weekdays: a round letter each, like Google Calendar's, the checkbox over it unseen but still there */
.repeat-weekdays { display: flex; gap: .35rem; }
.stack .repeat-weekdays label { position: relative; display: block; }
.repeat-weekdays input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.repeat-weekdays span {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--code-bg); color: var(--muted); font-size: .8rem; font-weight: 600;
}
.repeat-weekdays input:checked + span { background: var(--accent); color: var(--on-accent); }
.repeat-weekdays input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The location box looks like a map search: a pin on the left, the clear button (app.js) on the right. */
.place-picker { display: grid; gap: .2rem; }
.place-box { position: relative; }
.place-box input { width: 100%; padding-left: 2.2rem; padding-right: 2.6rem; }
.place-pin {
  position: absolute; left: .6rem; top: 50%; translate: 0 -50%; width: 1.25rem; height: 1.25rem;
  fill: var(--muted); pointer-events: none;
}
.place-clear {
  position: absolute; right: .3rem; top: 50%; translate: 0 -50%; display: grid; place-items: center;
  width: 2rem; height: 2rem; padding: 0; background: none; border: none; border-radius: 50%; box-shadow: none;
  color: var(--muted);
}
.place-clear[hidden], .place-box input:placeholder-shown ~ .place-clear { display: none; }
.place-clear:hover { background: var(--accent-soft); }
.place-clear svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
/* Who sees it (share-with.html): the group list only matters, and only shows, for a private event or poll. */
form:not(:has(#visibility-private:checked)) .share-groups { display: none; }
.visibility, .share-groups { display: grid; gap: .3rem; }
/* a plain list under its legend, like .colors */
.visibility { border: none; padding: 0; margin: 0; }
.visibility legend { padding: 0; margin-bottom: .3rem; }
.share-groups { padding-left: 1.6rem; }
/* The calendar's Custom view: the people to tick, side by side, wrapping onto as many lines as it takes. */
.custom-pick fieldset { display: flex; flex-wrap: wrap; gap: .3rem 1rem; border: none; padding: 0; margin: .5rem 0 0; }
.custom-pick legend { padding: 0; margin-bottom: .3rem; }
.custom-pick label.check { display: flex; align-items: center; gap: .3rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
form { margin: 0; }
code { word-break: break-all; font-size: .85rem; background: var(--code-bg); padding: .1rem .3rem; border-radius: 4px; }

/* settings / admin panels: one card per topic, so the page reads as groups, not one long list.
   No two panels on the same page share a color.
   Each .panel-* only sets --panel (fill) and --panel-edge (top stripe + heading); dark mode reuses the names. */
.panel {
  background: var(--panel);
  border-top: 4px solid var(--panel-edge);
  border-radius: 14px;
  padding: .6rem 1.4rem 1.4rem;
  margin: 1.4rem 0;
  box-shadow: var(--shadow);
  /* the tint costs .hint about .2 of contrast ratio; one step darker keeps it over 4.5:1 */
  --muted: #5e544b;
}
/* The default ::marker collides with the block-level h2, so the summary lays itself out as a
   flex row and draws its own triangle. list-style + the -webkit rule kill the native one. */
.panel > summary { cursor: pointer; display: flex; align-items: center; gap: .5rem; list-style: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before {
  content: "▶";
  font-size: .7rem;
  color: var(--panel-edge);
  transition: transform .15s ease;
}
.panel[open] > summary::before { transform: rotate(90deg); }
/* Only the section title is enlarged. Subtitles stay at body size and lean on weight, not size. */
.panel h2 { font-size: 1.3rem; color: var(--panel-edge); margin: .6rem 0; }
/* section headings inside a panel (Members, Next event, Name…): small spaced capitals in the panel's color,
   so they read as labels and stand apart from the text under them. */
.panel > h3, .panel > form > h3, .integration h3 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  margin: 2.2rem 0 .45rem; /* room above, so each section starts clearly apart from the one before it */
  color: var(--panel-edge);
}
/* the first section sits right under the panel title (or Owned by): no extra room needed there */
.panel > h3:first-of-type, .panel > form > h3:first-of-type { margin-top: 1.3rem; }
/* collapsed: drop the bottom padding so the closed panel is a tidy title bar.
   Scoped to details so the admin page's plain <section class=panel> keeps its padding. */
details.panel:not([open]) { padding-bottom: .6rem; }
/* Admin connection log: the panel's full width. It scrolls both ways inside itself (long actions on
   a phone); the header row stays pinned while scrolling down. */
/* Tall enough for the header + 20 rows, then it scrolls. --log-row is one row: text (.8rem at
   line-height 1.4), padding (2 × .25rem) and the 1px bottom border, the same numbers table.log uses below. */
.log-wrap {
  --log-row: calc(.8rem * 1.4 + .5rem + 1px);
  max-height: calc(21 * var(--log-row));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
table.log { border-collapse: collapse; width: 100%; font-size: .8rem; line-height: 1.4; }
table.log th, table.log td {
  padding: .25rem .6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.log th { position: sticky; top: 0; background: var(--card); }
/* one entry per row: no wrapping, except the action, which takes whatever width is left */
table.log td:not(:last-child), table.log th { white-space: nowrap; }
/* width: 1% shrinks #, time, IP and user to their content, so Action gets all the space left over */
table.log th:not(:last-child) { width: 1%; }
table.log td.n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
table.log td:nth-child(2) { font-variant-numeric: tabular-nums; }
/* Earth tones, one per panel: each only sets its stripe + heading color, the fill is a faint tint of it
   over the card (so the set stays coherent, and dark mode only swaps the edges). */
.panel          { --panel: color-mix(in srgb, var(--panel-edge) 6%, var(--card)); }
.panel-feeds    { --panel-edge: #5b7a9a; } /* dusty blue */
.panel-custom   { --panel-edge: #8a5a8c; } /* plum */
.panel-profile  { --panel-edge: #b0566a; } /* rose */
.panel-security { --panel-edge: #b5522c; } /* terracotta, the accent */
.panel-admin    { --panel-edge: #9c3a2e; } /* brick */
.panel-invites  { --panel-edge: #b8862b; } /* ochre */
.panel-integration { --panel-edge: #3f7a6e; } /* sage */
/* Calendar Integration (settings.html): my calendars, Rules, Add a calendar, one under the other on a phone, each a
   card like the Calendar feeds' (.feed-card). On a wider screen, once a calendar is connected (so there are Rules),
   two columns: my calendars with Add a calendar under them, and the Rules beside both. 1fr on the second row soaks
   up the height the Rules have over my calendars; the cards stretch, so both columns end level. */
.integration { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
.integration > * { padding: 1rem 1.2rem 1.2rem; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
/* each card opens with its heading: the card's padding is the room above it */
.integration h3 { margin-top: 0; }
/* nor room under the last thing in a card: the padding again */
.integration > * > :last-child, .integration > * > form:last-child > :last-child { margin-bottom: 0; }
@media (min-width: 760px) {
  .integration:has(> .integration-rules) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto 1fr;
    grid-template-areas: "calendars rules" "add rules";
  }
  .integration:has(> .integration-rules) > .integration-calendars { grid-area: calendars; }
  .integration:has(> .integration-rules) > .integration-rules { grid-area: rules; }
  .integration:has(> .integration-rules) > .integration-add { grid-area: add; }
}
/* my connected calendars, inside their card: a tinted row each, name and last sync on top, its options under */
.calendar-list { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .5rem; }
.calendar-list li {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem;
  padding: .6rem .8rem; background: var(--panel); border-radius: 10px;
}
.calendar-list .calendar-name, .calendar-list .err { flex-basis: 100%; }
.calendar-list .calendar-name .hint { margin-left: .3rem; }
/* Remove at the far right of its card */
.calendar-list form:last-child { margin-left: auto; }
/* Calendar Integration rules: always-busy days × slots */
.busy-grid th, .busy-grid td { padding: .1rem .6rem; text-align: center; font-weight: normal; }
.busy-grid tr > th:first-child { text-align: left; }
/* Settings → Customisation, Profile → About me and Security: an option per row in its card, a faint line between rows
   (~: an error between two rows keeps it): an icon in the panel's color on a tinted circle (it tilts on hover), its
   words, then its control at the right end, under the words when there is no room. A note (.pref-note) goes under it
   all, lined up with the words. */
.pref { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .65rem 0; }
label.pref { cursor: pointer; }
.pref ~ .pref { border-top: 1px solid color-mix(in srgb, var(--panel-edge) 18%, transparent); }
.pref > .pref-icon + span { flex: 1; min-width: 9rem; }
.pref > input:not([type=checkbox]) { margin-left: auto; width: min(100%, 16rem); }
.pref-color { display: flex; align-items: center; gap: .5rem; margin-left: auto; max-width: 100%; }
.pref-color .hue { width: min(240px, 100%); min-width: 0; }
.pref-note { flex-basis: 100%; margin: 0; padding-left: 2.9rem; font-size: .85rem; }
/* rows as a list (Profile → my passkeys): no bullets; a row's own form (Remove) at its right end */
.pref-list { list-style: none; padding: 0; margin: .5rem 0; }
.pref { margin: 0; }
.pref > form:last-child, .pref-actions { margin-left: auto; }
/* a row's buttons side by side (Groups → Accept / Decline), the plain one a little smaller than a form's */
.pref-actions { display: flex; align-items: center; gap: .8rem; }
.pref-actions button:not(.link) { padding: .3rem .9rem; }
/* a form in a row (Groups → Invite, Rename, Delete, New group): an icon, its field taking what is left, its buttons.
   A faint line above, like between .pref rows, except right under a heading or first in its card. */
.action-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem;
  margin-top: .4rem; padding-top: .8rem; border-top: 1px solid color-mix(in srgb, var(--panel-edge) 18%, transparent);
}
.action-row:first-child, h3 + .action-row { margin-top: 0; padding-top: 0; border-top: none; }
.action-row > input:not([type=hidden]), .action-row > select { flex: 1; min-width: 8rem; }
/* a date needs no more room than this (Polls → Add a date, Deadline) */
.action-row > input[type=date] { flex: 0 1 12rem; }
/* a card's later headings (Groups → Invited under Members): room above, as .integration h3 has none */
.integration > * > h3:not(:first-child) { margin-top: 1.4rem; }
/* Groups: one group's cards. On a wider screen Members on the left, Next event and its Calendar feed on the right,
   Manage under both. The feed card (feed-card.html) sits flat in its card. */
@media (min-width: 760px) {
  .group-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto 1fr;
    grid-template-areas: "members event" "members feed";
  }
  .group-members { grid-area: members; }
  .group-event { grid-area: event; }
  .group-feed { grid-area: feed; }
  .group-manage { grid-column: 1 / -1; }
}
.group-cards .feeds { grid-template-columns: minmax(0, 1fr); margin: .6rem 0 0; }
.group-cards .feed-card { padding: 0; background: none; box-shadow: none; }
.group-event .pill { margin-left: 2.9rem; }
.pref-icon {
  display: grid; place-items: center; flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  font-size: 1.05rem; background: color-mix(in srgb, var(--panel-edge) 14%, var(--card)); transition: transform .2s ease;
}
.pref:hover .pref-icon { transform: rotate(-10deg) scale(1.08); }
.pref-icon svg { width: 1.3rem; height: 1.3rem; fill: var(--panel-edge); }
/* a person (Groups → Members): their initials on their color, in place of an icon (after .pref-icon, so it wins).
   Invited, not in yet: dashed. */
.avatar { background: var(--c); color: #fff; font-size: .78rem; font-weight: 700; }
.avatar svg { fill: currentColor; }
.avatar.pending { background: none; color: var(--muted); border: 2px dashed color-mix(in srgb, var(--panel-edge) 45%, transparent); }
/* on / off: a switch in the panel's color, the checkbox itself redrawn (so it still posts, and Space toggles it) */
.pref input[type=checkbox] {
  appearance: none; flex: none; position: relative; width: 2.6rem; height: 1.5rem; margin: 0 0 0 auto; padding: 0;
  border: none; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--panel-edge) 22%, var(--card)); transition: background .2s ease;
}
.pref input[type=checkbox]::before {
  content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: translate .2s ease;
}
.pref input[type=checkbox]:checked { background: var(--panel-edge); }
.pref input[type=checkbox]:checked::before { translate: 1.1rem 0; }
/* one of a few: rounded chips, the picked one filled; the radio over each, unseen but still there (.repeat-weekdays) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.chips label { position: relative; }
.chips input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.chips span {
  display: block; padding: .35rem .85rem; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: color-mix(in srgb, var(--panel-edge) 70%, var(--fg));
  background: color-mix(in srgb, var(--panel-edge) 12%, var(--card)); transition: background .15s ease;
}
.chips label:hover span { background: color-mix(in srgb, var(--panel-edge) 22%, var(--card)); }
.chips input:checked + span { background: var(--panel-edge); color: var(--card); }
.pref input:focus-visible, .chips input:focus-visible + span { outline: 2px solid var(--panel-edge); outline-offset: 2px; }
.panel-options  { --panel-edge: #6b8a3f; } /* olive */
.panel-log      { --panel-edge: #6f5e8f; } /* heather */
/* one group on the groups page: stripe and title in the group's own color (member_groups.color) */
.panel-group    { --panel-edge: var(--c); }

/* calendar */
/* minmax(0, …): a plain 1fr won't shrink below its content, so one long title would widen its column */
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--gap); }
.dow { text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: .4rem 0; }
.day {
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .2rem;
  font-size: .75rem;
  box-shadow: var(--shadow);
}
.day.pad { background: none; border: none; box-shadow: none; }
/* continuous calendar: the days of the months before and after, still usable but stepped back */
.day.outside { background: none; box-shadow: none; }
.day.outside .num { color: var(--muted); font-weight: 400; }
/* the button is the whole cell: grid on every wrapper stretches it edge to edge, no fixed heights.
   Each day spans two rows of .grid (head, events, see calendar.html) and passes them down as a
   subgrid, so the head row is as tall as the tallest one in the week: bars start level under
   initials of any height. row-gap 0 inside the cell; --gap stays between weeks. */
.day, .day form, .day button {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  row-gap: 0;
  /* minmax(0, …): a label stretched over the next days (.ev-text) must not widen the cell's own column,
     or the day's other events would stretch with it and spill into the next day */
  grid-template-columns: minmax(0, 1fr);
}
.day button { text-align: left; background: none; border: none; color: var(--fg); padding: .1rem .2rem; font-weight: 400; box-shadow: none; }
.day .head { display: block; }
/* the cell's minimum height lives in the events row, so the head stays packed at the top */
.day .day-events { display: flex; flex-direction: column; min-height: 3rem; }
.day .num { font: 600 .95rem var(--display); display: inline-block; min-width: 1.4rem; }
.day.today .num { background: var(--accent); color: var(--on-accent); border-radius: 50%; width: 1.4rem; height: 1.4rem; line-height: 1.4rem; text-align: center; }
/* Holding a day opens the morning/afternoon menu (public/app.js), so the phone's own long-press
   reactions must not fire: no text selection, no iOS callout. manipulation also drops the
   double-tap zoom, so taps land at once. */
.day button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* "am" / "pm" after the initials of a half-day member. A second free time stacks right under the first:
   inline-grid puts each <i> on its own row, and its baseline is the first row's, so one slot looks as before. */
.who sup { display: inline-grid; font-size: .7em; font-weight: 600; margin-left: 1px; line-height: 1; }
.who sup i { font-style: normal; }

/* the morning / afternoon / all day menu */
#day-part {
  border: none;
  border-radius: 14px;
  padding: 1rem 1.2rem;
  background: var(--card);
  color: var(--fg);
  min-width: 240px;
  box-shadow: var(--shadow);
}
#day-part::backdrop { background: rgb(40 25 15 / .4); }
#day-part h2 { margin: 0 0 .8rem; }
#day-part .stack button { width: 100%; }
/* what the day is set to now */
#day-part .stack button.current { outline: 3px solid var(--fg); outline-offset: 2px; }
/* already free twice that day: a third time cannot be picked until one is taken off */
#day-part .stack button:disabled { opacity: .4; }
#day-part .day-add { margin: .8rem 0 0; text-align: center; }
#day-part form[method=dialog] { margin-top: .8rem; text-align: center; }
/* day states: one class per DAY_STATES key in src/lib.js */
/* my free days, ringed in my own color: the grid carries my .cN class */
.day.mine { box-shadow: var(--shadow), inset 0 0 0 2px var(--c, var(--accent)); }
/* Settings → Customisation → "Disable border of free days" */
.grid.no-free-border .day.mine { box-shadow: var(--shadow); }
.day.all { background: var(--ok-bg); }
.day.all .num::after { content: " ✓"; color: var(--ok); font-size: .7rem; }
.who { display: flex; flex-wrap: wrap; gap: 2px; }
/* user colors: 13 distinct colors, index stored in users.color. --c is for light mode, --cd for dark.
   To add one: a .cN line here, a stop in the .hue gradient below, and bump COLORS in src/lib.js. */
.c0  { --c: #dc2626; --cd: #f87171; }
.c1  { --c: #ea580c; --cd: #fb923c; }
.c2  { --c: #ca8a04; --cd: #facc15; }
.c3  { --c: #65a30d; --cd: #a3e635; }
.c4  { --c: #16a34a; --cd: #4ade80; }
.c5  { --c: #0d9488; --cd: #2dd4bf; }
.c6  { --c: #0284c7; --cd: #38bdf8; }
.c7  { --c: #2563eb; --cd: #60a5fa; }
.c8  { --c: #4f46e5; --cd: #818cf8; }
.c9  { --c: #9333ea; --cd: #c084fc; }
.c10 { --c: #db2777; --cd: #f472b6; }
.c11 { --c: #7c4a1d; --cd: #c9915a; }
.c12 { --c: #475569; --cd: #94a3b8; }
.who span, .swatch { color: var(--c, var(--accent)); padding: 0 .15rem; font-weight: 700; }
.swatch { font-size: 1.3rem; min-width: 2.2rem; text-align: center; }
.hue::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--fg);
}
.hue::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--fg);
}
.hue {
  appearance: none;
  width: 240px;
  height: 10px;
  border: none;
  border-radius: 5px;
  padding: 0;
  /* one equal band per color, .c0 to .c12 */
  background: linear-gradient(to right,
    #dc2626 0.00% 7.69%, #ea580c 7.69% 15.38%, #ca8a04 15.38% 23.08%, #65a30d 23.08% 30.77%,
    #16a34a 30.77% 38.46%, #0d9488 38.46% 46.15%, #0284c7 46.15% 53.85%, #2563eb 53.85% 61.54%,
    #4f46e5 61.54% 69.23%, #9333ea 69.23% 76.92%, #db2777 76.92% 84.62%, #7c4a1d 84.62% 92.31%,
    #475569 92.31% 100.00%);
}
.ev { background: var(--ev-bg); color: var(--ev-fg); border-radius: 6px; padding: 0 .25rem; margin-top: 2px; font-weight: 500; }
/* An event with a color (events.color): a tint of its .cN palette color, text in a darkened shade of it. */
.ev.colored { background: color-mix(in srgb, var(--c) 16%, var(--card)); color: color-mix(in srgb, var(--c) 80%, #000); }
/* the color picker on the event page: one round chip per palette color, the radio inside it hidden */
.colors { display: flex; flex-wrap: wrap; gap: .4rem; border: none; padding: 0; margin: 0; }
.colors legend { padding: 0; margin-bottom: .3rem; }
/* "Default" has no .cN, so it falls back to the default event look */
.swatch-pick {
  position: relative;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  cursor: pointer;
  background: var(--c, var(--ev-bg));
  border: 2px solid var(--c, var(--ev-fg));
}
.swatch-pick input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-pick:has(:checked) { outline: 3px solid var(--fg); outline-offset: 2px; }
.swatch-pick:has(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
/* the event page's Delete: a .stack like the form above, so it is as wide as Save, set apart from it */
.delete-event { margin-top: 1.5rem; }
/* Multi-day bars: one line each so every piece of a bar is the same height; the tooltip has the full title. */
.ev.bar { white-space: nowrap; }
/* The label runs across the bar's next cells in the week (run-N = N cells, set in views.js).
   One cell step is a column plus the gap: (100cqw + gap) / 7, cqw being 1% of .grid's width.
   Minus the gap, the cell's inset on both sides (.4rem padding + 1px border) and the bar's padding.
   z-index lifts it over the later cells, which paint after this one; pointer-events: none lets a
   click on the text still reach the day under it. */
.grid { container-type: inline-size; }
.ev-text {
  display: block;
  position: relative;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  width: calc(var(--run) * (100cqw + var(--gap)) / 7 - var(--gap) - .8rem - 2px - .5rem);
}
.run-1 { --run: 1; }
.run-2 { --run: 2; }
.run-3 { --run: 3; }
.run-4 { --run: 4; }
.run-5 { --run: 5; }
.run-6 { --run: 6; }
.run-7 { --run: 7; }
.ev.gap { visibility: hidden; }
/* A piece that carries on stretches over the cell's padding (.2rem + .2rem on the button) and 1px border,
   and the one continuing it also over the grid gap, so the two meet edge to edge.
   Not across a week break: the first column (7 weekday headers, then 7n+1) keeps its padding. */
.day button { overflow: visible; }
.ev.to { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: calc(-.4rem - 1px); }
.ev.from { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: calc(-.4rem - 1px - var(--gap)); }
.day:nth-child(7n+1) .ev.from { margin-left: 0; }
/* too much text makes the cell taller, not wider: wrap, and break words that are longer than the cell */
.day button { overflow-wrap: anywhere; }
/* one card per event, like the days above */
.events { list-style: none; padding: 0; }
/* > li: the rows only, not the items of their Add to calendar menu, which stays as in Settings (.add-menu) */
.events > li { margin: .4rem 0; padding: .6rem .9rem; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); }
.events > li.past { opacity: .6; } /* its last day is before today */
.events > li > span a { color: var(--accent); }
/* its Add to calendar pill (.add-menu) at the right end, in the accent; under the text on a phone */
.events { --panel-edge: var(--accent); }
.events > li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; }

/* polls: their panels, like Settings' (the open ones / the answers, the closed ones, the result, Manage) */
.panel-poll     { --panel-edge: #5b7a9a; } /* dusty blue */
.panel-closed   { --panel-edge: #7a6f66; } /* stone */
.panel-result   { --panel-edge: #3f6b3a; } /* moss, the yes green */
.panel-manage   { --panel-edge: #b8862b; } /* ochre */
/* the list (poll-row.html): title over its kind and status, "to answer" at the right end */
.poll-name { display: grid; line-height: 1.35; }
.poll-name a { color: var(--fg); font-weight: 600; text-decoration: none; }
.poll-name a:hover { color: var(--accent); }
.poll-name small { font-size: .82rem; }
.pref > .pill { margin-left: auto; }
/* New poll: the kind chips show its choices only, dates or activities. A fieldset each, its legend like a card's h3. */
.poll-form:has(input[name=kind][value=activity]:checked) .dates,
.poll-form:not(:has(input[name=kind][value=activity]:checked)) .activities { display: none; }
/* the rows side by side, as many as fit, wrapping */
.choices {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem;
  border: none; padding: 0; margin: 0 0 .4rem; min-width: 0;
}
.choices.activities { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.choices legend {
  padding: 0; margin-bottom: .45rem; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--panel-edge);
}
/* Who sees it (share-with.html) in a .pref row: beside its icon, its error under both */
.pref > .visibility { flex: 1; min-width: 12rem; }
.pref > .err { flex-basis: 100%; margin: 0; }
.panel-result .row { margin-top: .8rem; }
/* The card is the wrapper, so a table wider than a phone scrolls sideways inside it, and the names column stays put. */
.poll-wrap { overflow-x: auto; margin: .8rem 0; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
table.poll { border-collapse: collapse; width: 100%; }
table.poll tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; }
table.poll th, table.poll td { border-bottom: 1px solid var(--line); padding: .55rem .6rem; text-align: center; font-size: .9rem; }
table.poll thead th { font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; vertical-align: bottom; }
/* a date's weekday over it */
table.poll thead th small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; }
/* an activity's name wraps instead of widening its column */
table.poll thead th.activity { white-space: normal; min-width: 6.5rem; max-width: 11rem; }
/* the winner's column, once the result is out */
table.poll tr > .best { background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
table.poll thead th.best { color: var(--ok); }
/* my row, tinted in the panel's color (its sticky name cell too) */
table.poll tr.me > * { background: color-mix(in srgb, var(--panel-edge) 7%, var(--card)); }
table.poll tbody th { font-weight: 500; }
.poll-who { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
table.poll .avatar { width: 1.8rem; height: 1.8rem; font-size: .68rem; }
table.poll tr.tot > * { color: var(--muted); font-size: .78rem; border: 0; }
/* an answer: a round icon in its color, yes green, maybe amber, no red; none yet a faint dash */
.a { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; color: var(--muted); }
.a svg, .vote svg { width: 1.05rem; height: 1.05rem; fill: currentColor; }
.a.yes { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, var(--card)); }
.a.maybe { color: var(--maybe); background: color-mix(in srgb, var(--maybe) 16%, var(--card)); }
.a.no { color: var(--err); background: color-mix(in srgb, var(--err) 13%, var(--card)); }
/* my answers: three round buttons, the picked one filled; the radio over each, unseen but still there (.chips) */
.vote { display: inline-flex; gap: .25rem; }
.vote label { position: relative; }
.vote input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.vote span {
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  color: var(--muted); background: var(--code-bg); transition: background .15s ease, color .15s ease;
}
.vote label:hover span { background: var(--line); }
.vote .yes input:checked + span { background: var(--ok); color: var(--card); }
.vote .maybe input:checked + span { background: var(--maybe); color: var(--card); }
.vote .no input:checked + span { background: var(--err); color: var(--card); }
.vote input:focus-visible + span { outline: 2px solid var(--panel-edge); outline-offset: 2px; }
/* filled in from my free days, not saved yet (poll.suggested): paler, ringed with dashes */
.vote.suggested input:checked + span { opacity: .6; outline: 2px dashed var(--fg); outline-offset: 2px; }
.tally { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tally .yes { color: var(--ok); }
.tally .maybe { color: var(--maybe); }
.tally .no { color: var(--err); }
/* Settings → Calendar feeds (feed-card.html): a card per feed, its address hidden behind Add to calendar.
   Two columns on a wider screen, like Calendar Integration; the no-group hint takes the whole width. */
.feeds { list-style: none; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
@media (min-width: 760px) {
  .feeds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feeds > .hint { grid-column: 1 / -1; }
}
.feed-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem;
  padding: .7rem .9rem; background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
}
/* a round badge: an emoji on a tint of the panel, or a group's initial on its own color (.cN) */
.feed-badge {
  display: grid; place-items: center; flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  font: 700 1.15rem var(--display); background: color-mix(in srgb, var(--panel-edge) 16%, var(--card));
}
.feed-badge.group { background: var(--c); color: #fff; }
.feed-name { flex: 1; min-width: 8rem; display: grid; line-height: 1.3; }
.feed-name .hint { font-size: .8rem; }
/* a soft rounded button in the panel's color. Its text is the panel color pulled toward --fg: the plain
   color is under 4.5:1 on the tint, in light mode. */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .8rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .85rem;
  white-space: nowrap; cursor: pointer;
  color: color-mix(in srgb, var(--panel-edge) 70%, var(--fg));
  background: color-mix(in srgb, var(--panel-edge) 14%, var(--card));
  transition: background .15s ease;
}
.pill:hover, details[open] > .pill { background: color-mix(in srgb, var(--panel-edge) 24%, var(--card)); }
.pill svg { width: 1rem; height: 1rem; fill: currentColor; }
/* Add to calendar: the pill opens a small list under it, against its right edge, like the language menu.
   On a phone it wraps under the name, against the card's right edge. */
.add-menu { position: relative; margin: 0 0 0 auto; }
.add-menu > summary { list-style: none; }
.add-menu > summary::-webkit-details-marker { display: none; }
/* the panels' own triangle (some fonts lack ▾), turned to point down, and up while open */
.add-menu > summary::after { content: "▶"; font-size: .55rem; transform: rotate(90deg); transition: transform .15s ease; }
.add-menu[open] > summary::after { transform: rotate(-90deg); }
.add-menu ul {
  position: absolute; right: 0; top: calc(100% + .3rem); z-index: 10;
  list-style: none; margin: 0; padding: .3rem; min-width: 12rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.add-menu a {
  display: flex; align-items: center; gap: .45rem;
  padding: .4rem .7rem; border-radius: 8px; color: var(--fg); text-decoration: none; white-space: nowrap;
}
.add-menu a:hover, .add-menu a:focus-visible { background: var(--accent-soft); }
.add-menu a svg { width: 1rem; height: 1rem; fill: currentColor; }
/* Apple Calendar copies the link: a faint copy icon at its right end says so */
.add-menu a svg.copies { margin-left: auto; opacity: .55; }
/* Copy link, for any other app: set apart under the three calendars, green for a moment once copied */
.add-menu .sep { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .3rem; }
.add-menu .sep a { color: var(--muted); }
.add-menu a.copied { color: var(--ok); }
details { margin: .8rem 0; }
a { color: var(--accent); }
@media (max-width: 600px) {
  :root { --gap: 4px; }
  /* half the side margin: every pixel goes to the 7 calendar columns (about 2px more each) */
  main { padding: 1rem .5rem; }
  .day { font-size: .65rem; border-radius: 8px; }
  .day .num { font-size: .8rem; min-width: 1.2rem; }
  .day.today .num { width: 1.2rem; height: 1.2rem; line-height: 1.2rem; }
  .day .day-events { min-height: 1.8rem; }
  .day .ev:not(.bar) { white-space: nowrap; overflow: hidden; padding: 0 .15rem; }
  .ev-time { display: none; }
  /* .pref rows: a field or chips that do not fit beside the words go under them, lined up with them, full width
     (switches stay beside) */
  .pref > input:not([type=checkbox]), .pref > .chips, .pref-color { margin-left: 2.9rem; width: calc(100% - 2.9rem); }
  .pref-color .hue { flex: 1; width: auto; }
  /* an event's Add to calendar: just the icon, beside its text instead of under it */
  .events .add-label, .events .add-menu > summary::after { display: none; }
  .events .add-menu > summary { padding: .4rem; }
  .events > li { flex-wrap: nowrap; }
  .events > li > span { flex: 1; min-width: 0; }
  /* initials and their am / pm wrap as one */
  .who span { padding: 0 .15rem; white-space: nowrap; }
  h1 { font-size: 1.8rem; }
}

/* dark mode: follows the OS setting. Same warmth, pulled down to deep brown. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1a1613;
    --card: #241f1b;
    --fg: #efe7dc;
    --muted: #a1958a;
    --line: #3a322c;
    --accent: #e2825a;
    --accent-soft: #3a271d;
    --on-accent: #1a1613;
    --ok: #9bcf8a;
    --ok-bg: #273523;
    --err: #f08a7a;
    --maybe: #e6b35a;
    --code-bg: #2e2822;
    --ev-bg: #3a3020;
    --ev-fg: #ecd3a1;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -12px rgb(0 0 0 / .6);
  }
  body { background: var(--bg); }
  .who span, .swatch { color: var(--cd, var(--accent)); }
  .day.mine { box-shadow: var(--shadow), inset 0 0 0 2px var(--cd, var(--accent)); }
  .ev.colored { background: color-mix(in srgb, var(--cd) 20%, var(--card)); color: var(--cd); }
  .swatch-pick { background: var(--cd, var(--ev-bg)); border-color: var(--cd, var(--ev-fg)); }
  .feed-badge.group, .avatar { background: var(--cd); color: var(--bg); }
  /* the same earth tones, lifted so they read on the dark card; the fill tints a little stronger.
     Dark needs no --muted bump: #a1958a clears 4.5:1 on all of them. */
  .panel { --muted: #a1958a; --panel: color-mix(in srgb, var(--panel-edge) 10%, var(--card)); }
  .panel-feeds    { --panel-edge: #9ab6d3; }
  .panel-custom   { --panel-edge: #c9a0cb; }
  .panel-profile  { --panel-edge: #e59aa9; }
  .panel-security { --panel-edge: #e2825a; }
  .panel-admin    { --panel-edge: #e8927f; }
  .panel-invites  { --panel-edge: #e0b35a; }
  .panel-integration { --panel-edge: #8ccbbb; }
  .panel-options  { --panel-edge: #b0c97e; }
  .panel-log      { --panel-edge: #b5a7d8; }
  .panel-group    { --panel-edge: var(--cd); }
  .panel-poll     { --panel-edge: #9ab6d3; }
  .panel-closed   { --panel-edge: #b3a79c; }
  .panel-result   { --panel-edge: #9bcf8a; }
  .panel-manage   { --panel-edge: #e0b35a; }
}
