/* RendezRoute styles (design decision D27). Mobile first; no inline styles anywhere (spec 3.8 CSP).
   Plan pages read --plan-* variables from the per-plan theme stylesheet (spec 3.1).

   Components, for pages added later (milestones B and C):
   - Buttons: <button> or a.button is the page's one primary action; .secondary for everything
     else; .danger for deleting. Groups of buttons go in .button-row: on phones they fill the row
     and stack evenly when wrapped, side by side from 600 px. The plan page's own actions row
     (.actions) follows the mock-up (D30).
   - Fields: .field (label, control, .hint, .error); .field-row puts two side by side; .choice is a
     radio or checkbox with its label; fieldset with legend groups related choices.
   - Messages: .notice (neutral), .warning (needs care), .error (a field's problem), .link-box (a
     link to copy, shown once).
   - Lists: ul.list for rows divided by hairlines; ul.items with li.item (.item-title, .item-meta,
     .item-actions) for plans, templates and the like.
   - Pages in parts: .sectioned on the page, each part a <section> divided by a hairline.
   - Notifications: .push (the browser switch), .email-switch, and .more-channels, a <details>
     fold "More ways to be notified" holding .ntfy-switch and .telegram-switch (D31, D33, D34).
   - States: section.status (with .status-joined, .status-loggedIn, …) for one's own state;
     section.message-page for a page that only says what happened.
   - Plan facts: dl.when-where (boxes, or .lines on the plan page), dl.metrics (inline, or .tiles
     on the plan page); people as li.person with the initial, .person-label and the host's .host-mark.
   - Radii: --r-sm for text inputs and small labels (.pill, .plan-activity), --r-md for buttons,
     fieldsets, message boxes, tiles, cards and maps, --r-lg for the plan's title block, --r-pill
     for badges and counts.
   - Icons: <span class="icon icon-NAME" aria-hidden="true">; each needs its SVG in public/icons/
     and a rule `.icon-NAME { --icon: url("icons/NAME.svg"); }` below.
   The design tokens below are checked for WCAG AA contrast by test/design/tokens.test.ts. */

:root {
  /* Colour */
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5c636e;
  --line: #e4e7eb;
  --control-line: #c5cad1;
  --field-border: #858c97;
  --surface: #f3f4f6;
  --accent: #2c67a8;
  --on-accent: #ffffff;
  --focus: #2c67a8;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --warning-bg: #fff4e5;
  --warning-line: #f3d19c;
  --ok: #1a6e3e;
  --ok-bg: #ebf8f0;
  --ok-line: #b9e4c9;
  /* Name colours for initials: background and text */
  --avatar-0-bg: #fde2e4;
  --avatar-0-fg: #8a1c2b;
  --avatar-1-bg: #dbe8ff;
  --avatar-1-fg: #1d3f8f;
  --avatar-2-bg: #d8f3e1;
  --avatar-2-fg: #17613a;
  --avatar-3-bg: #ecdfff;
  --avatar-3-fg: #5b2a99;
  --avatar-4-bg: #ffe8cc;
  --avatar-4-fg: #8a4b00;
  --avatar-5-bg: #d5f2f4;
  --avatar-5-fg: #0e5c63;
  --avatar-6-bg: #f7dcef;
  --avatar-6-fg: #84205f;
  --avatar-7-bg: #e5e9d0;
  --avatar-7-fg: #4d5a12;
  /* The secondary plan colour where a page has no plan theme (spec 3.1 default) */
  --plan-secondary-default: #ff7a45;
  --plan-on-secondary-default: #111111;
  /* Type: 16 px base; headings tight and heavy */
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-2xl: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
  /* Space: a 4 px scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  /* Smallest touch target (WCAG 2.5.8 asks 24 px; 44 px for thumbs) */
  --target: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --fg: #e8eaed;
    --muted: #a3a9b2;
    --line: #2c2f35;
    --control-line: #464b53;
    --field-border: #737a85;
    --surface: #1d2024;
    --accent: #8bb8ea;
    --on-accent: #111111;
    --focus: #8bb8ea;
    --danger: #f2b8b5;
    --on-danger: #111111;
    --warning-bg: #3a2c12;
    --warning-line: #6b5120;
    --ok: #8fd9a8;
    --ok-bg: #15271c;
    --ok-line: #2b5a3c;
    --avatar-0-bg: #5a1d26;
    --avatar-0-fg: #ffd6db;
    --avatar-1-bg: #1f3463;
    --avatar-1-fg: #d5e3ff;
    --avatar-2-bg: #174a2c;
    --avatar-2-fg: #c9f0d7;
    --avatar-3-bg: #3f2566;
    --avatar-3-fg: #e7d9ff;
    --avatar-4-bg: #5a3608;
    --avatar-4-fg: #ffe2bf;
    --avatar-5-bg: #124549;
    --avatar-5-fg: #c8f1f4;
    --avatar-6-bg: #57203f;
    --avatar-6-fg: #ffd6ef;
    --avatar-7-bg: #3b4214;
    --avatar-7-fg: #e9eec8;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Elements the map script reveals; author display rules must not show them early. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    var(--text-md) / 1.5 Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: var(--s5) 0 var(--s4);
  overflow-wrap: break-word;
  hyphens: auto;
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  margin: var(--s6) 0 var(--s3);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h3 {
  margin: var(--s5) 0 var(--s2);
  font-size: var(--text-md);
  font-weight: 700;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Page frame */

main,
.site-header,
.site-footer {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 var(--s4);
}

.site-header {
  padding-top: var(--s3);
  padding-bottom: var(--s3);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-header a {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  /* The name in the logo's colour (decision D28). */
  color: var(--accent);
  text-decoration: none;
}

/* The mark before the site's name (decision D28), as a mask like the icons below. */
.logo {
  flex: none;
  width: 1.05em;
  height: 1.6em;
  background: currentColor;
  -webkit-mask: url("icons/logo.svg") center / contain no-repeat;
  mask: url("icons/logo.svg") center / contain no-repeat;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: var(--s7);
  padding-top: var(--s4);
  padding-bottom: var(--s5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-sm);
}

.powered-by,
.legal-links {
  margin: 0;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
}

.footer-menu {
  margin-left: auto;
}

.footer-menu summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--target);
  padding: 0 var(--s4);
  border: 1px solid var(--control-line);
  border-radius: var(--r-pill);
  color: var(--fg);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.footer-menu summary::-webkit-details-marker {
  display: none;
}

.footer-menu[open] {
  flex-basis: 100%;
}

.footer-menu[open] summary {
  float: right;
}

.footer-menu-body {
  clear: both;
  margin-top: var(--s3);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

/* One line per setting: label, the select taking what is left, the button as wide as its text.
   Below 340 px the label sits above the select and button instead. */
.preference {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s3);
}

.preference label {
  flex: 0 0 5.5rem;
}

.preference select {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  font-size: inherit;
}

.preference button {
  flex: none;
  min-width: 0;
  padding: var(--s2) var(--s4);
  font-size: inherit;
  white-space: nowrap;
}

@media (max-width: 339.98px) {
  .preference label {
    flex: 1 0 100%;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin: var(--s4) 0 0;
}

.dev-banner {
  margin: 0;
  padding: var(--s2) var(--s4);
  background: var(--danger);
  color: var(--on-danger);
  text-align: center;
  font-weight: 600;
}

/* Icons: SVG files from public/icons/ as masks, so they take the text colour. */

.icon {
  display: inline-block;
  flex: none;
  width: 1.15em;
  height: 1.15em;
  background: currentColor;
  vertical-align: -0.2em;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

/* High-contrast modes replace backgrounds; keep icons in the text colour. */
@media (forced-colors: active) {
  .icon,
  .logo {
    background: CanvasText;
    forced-color-adjust: none;
  }

  /* The mark beside the site's name, which becomes a system link colour. */
  .logo {
    background: LinkText;
  }
}

.icon-back {
  --icon: url("icons/back.svg");
}

.icon-calendar {
  --icon: url("icons/calendar.svg");
}

.icon-check {
  --icon: url("icons/check.svg");
}

.icon-flag {
  --icon: url("icons/flag.svg");
}

.icon-lock {
  --icon: url("icons/lock.svg");
}

.icon-menu {
  --icon: url("icons/menu.svg");
}

.icon-pin {
  --icon: url("icons/pin.svg");
}

.icon-globe {
  --icon: url("icons/globe.svg");
}

.icon-users {
  --icon: url("icons/users.svg");
}

/* Buttons: one primary per page, quiet secondaries, red for deleting. */

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--target);
  padding: var(--s2) var(--s5);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary,
button.secondary {
  border-color: var(--control-line);
  background: var(--surface);
  color: var(--fg);
}

.button.danger,
button.danger {
  background: var(--danger);
  color: var(--on-danger);
}

/* Main buttons on plan pages use the plan's primary color (spec 3.1). */
.plan .button:not(.secondary, .danger),
.plan button:not(.secondary, .danger) {
  background: var(--plan-primary, var(--accent));
  color: var(--plan-on-primary, var(--on-accent));
}

/* Forms */

fieldset {
  margin: var(--s4) 0;
  padding: var(--s3) var(--s4) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.field {
  margin: var(--s4) 0;
}

.field label,
legend {
  display: block;
  margin-bottom: var(--s1);
  font-weight: 600;
}

legend {
  padding: 0 var(--s1);
}

.field-row {
  display: grid;
  /* minmax(0, 1fr), not 1fr: native date and time inputs are wide on iOS and would stop the columns
     from shrinking. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}

.field-row > * {
  min-width: 0;
}

input:not([type="radio"], [type="checkbox"], [type="color"]),
select,
textarea {
  width: 100%;
  min-height: var(--target);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--field-border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}

textarea {
  min-height: 6rem;
}

input[type="date"],
input[type="time"] {
  min-width: 0;
  max-width: 100%;
  text-align: start;
}

input::-webkit-date-and-time-value {
  min-width: 0;
  text-align: start;
}

input[type="file"] {
  padding: var(--s1);
}

input[type="file"]::file-selector-button {
  min-height: calc(var(--target) - 2 * var(--s1) - 2px);
  margin-right: var(--s3);
  padding: 0 var(--s4);
  border: 1px solid var(--control-line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input[type="color"] {
  width: 100%;
  height: var(--target);
  padding: 2px;
  border: 1px solid var(--field-border);
  border-radius: var(--r-sm);
  background: var(--bg);
}

input[type="radio"],
input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

/* A radio or checkbox with its label; the whole row is the touch target. */
.choice {
  display: flex;
  gap: var(--s3);
  align-items: center;
  min-height: var(--target);
  padding-block: var(--s1);
  font-weight: 400;
}

/* A choice that cannot be made reads as unavailable, not only its radio. */
.choice:has(input:disabled) {
  color: var(--muted);
}

.hint {
  margin: var(--s1) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.error {
  margin: var(--s1) 0 0;
  color: var(--danger);
  font-weight: 600;
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger);
  border-width: 2px;
}

/* Messages */

.warning {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--warning-line);
  border-radius: var(--r-md);
  background: var(--warning-bg);
}

.notice {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--surface);
}

.link-box {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow-wrap: anywhere;
}

/* Lists divided by hairlines */

.list,
.items,
.rating-notes,
.report-attached,
.contributions,
.people-actions {
  padding: 0;
  list-style: none;
}

.list > li,
.item,
.rating-notes > li,
.report-attached > li,
.admin-report,
.contribution {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}

/* Pages about a plan: the way back comes first (decision D27). */

.back-link {
  margin: var(--s4) 0 0;
}

.back-link a {
  display: inline-flex;
  gap: var(--s1);
  align-items: center;
  min-height: var(--target);
  font-weight: 600;
  text-decoration: none;
}

.back-link a:hover {
  text-decoration: underline;
}

/* The plan a form page manages; forms stay neutral (decision D11). */
.plan-context {
  margin: var(--s2) 0 0;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: break-word;
}

.host h1 {
  margin-top: var(--s2);
}

/* Pages in parts (host, template, My data, account, calendar, admin, privacy): each part divided
   by a hairline (D27). */
.sectioned > section:not(.status) {
  margin-top: var(--s6);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}

/* A part that starts with a form, not a heading, gets room below its line (text and button rows
   bring their own margin). */
.sectioned > section:not(.status) > form:first-child {
  margin-top: var(--s4);
}

/* A plan or template in a list: title, a muted line saying when, then its actions (D27). */
.item-title {
  margin: 0;
  font-weight: 600;
  overflow-wrap: break-word;
}

.item-meta {
  margin: var(--s1) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  align-items: baseline;
  margin-top: var(--s2);
}

/* An opened fold takes the whole row. */
.item-actions details[open] {
  flex-basis: 100%;
}

/* The section's own hairline follows the last item. */
.items > .item:last-child,
.admin-report:last-of-type {
  border-bottom: 0;
}

/* Time and place after a hint, e.g. on the admin's plan page. */
.hint + .when-where {
  margin-top: var(--s3);
}

/* Buttons side by side, wrapping on narrow screens. */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  margin: var(--s4) 0;
}

.button-row form {
  margin: 0;
}

/* On phones the buttons of a row fill it, so wrapped ones stack evenly; side by side from 600 px. */
.button-row > * {
  flex: 1 1 auto;
}

.button-row form > button {
  width: 100%;
}

@media (min-width: 600px) {
  .button-row > * {
    flex: none;
  }
}

.person-name {
  display: inline-flex;
  gap: var(--s2);
  align-items: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Plan page (decisions D27, D30): the title in a block tinted in the plan's primary colour, the
   rest without boxes around sections. One column on phones; from 960 px the plan on the left, you
   and the group on the right. */

/* The title in a block tinted in the plan's primary colour, as in the phone mock-up (D30). */
.plan-header {
  margin: var(--s4) 0;
  padding: var(--s5);
  border-radius: var(--r-lg);
  background: var(--plan-primary-tint, var(--surface));
}

.plan-header h1 {
  margin: 0 0 var(--s2);
}

.plan-byline {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Name and host badge wrap together; a long name still breaks inside the block. */
.plan-poster {
  display: inline-block;
}

/* App text only: names keep their case. */
.plan-activity {
  display: inline-block;
  margin-right: var(--s2);
  padding: 2px var(--s2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Who can find the plan (step 8): a small label with an icon on the byline, like the activity. */
.plan-visibility {
  display: inline-flex;
  gap: var(--s1);
  align-items: center;
  margin-right: var(--s2);
  padding: 2px var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-xs);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0 var(--s2);
  border-radius: var(--r-pill);
  background: var(--plan-secondary, var(--plan-secondary-default));
  color: var(--plan-on-secondary, var(--plan-on-secondary-default));
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.when-where {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: 0 0 var(--s4);
}

/* Date and place as plain lines on the plan page (D30). */
.when-where.lines {
  display: block;
  padding: 0 var(--s2);
  font-size: var(--text-lg);
}

.when-where.lines dd {
  margin: 0;
}

.when-where.lines div + div {
  margin-top: var(--s1);
  color: var(--muted);
  font-size: var(--text-md);
}

.pill {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-weight: 600;
}

.pill {
  min-width: 0;
  max-width: 100%;
}

.pill dd {
  display: flex;
  gap: var(--s2);
  align-items: baseline;
  margin: 0;
}

.pill dd > span:last-child {
  min-width: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Neutral, so any plan colour stays visible (spec 3.1: the primary marks the header and buttons). */
.pill .icon {
  color: var(--muted);
}

.time-zone {
  color: var(--muted);
  font-weight: 400;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin: 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

.metric {
  display: flex;
  gap: var(--s1);
  align-items: baseline;
}

.metric dt {
  color: var(--muted);
}

.metric dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* The measures and the drop policy as equal tiles, value above label (D30). */
/* Two per row, so values read on one line (user feedback on D30). */
.metrics.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2);
  padding-top: 0;
  border-top: 0;
}

.tiles .metric {
  flex-direction: column-reverse;
  gap: 2px;
  align-items: center;
  justify-content: center;
  padding: var(--s3) var(--s2);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: center;
  overflow-wrap: break-word;
}

.tiles .metric dt {
  font-size: var(--text-xs);
}

.note {
  margin: var(--s4) 0;
  font-size: var(--text-lg);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.map.plan-map {
  height: 300px;
  margin-top: var(--s5);
}

/* Filled with the plan's secondary tint, no border (D30). All text in --fg, the hint and links
   too: muted grey and the accent blue fall below 4.5:1 on dark secondaries' tints. */
.exact-start {
  --muted: var(--fg);
  --accent: var(--fg);
  margin: var(--s4) 0;
  padding: var(--s4);
  border-radius: var(--r-md);
  background: var(--plan-secondary-tint, var(--surface));
}

.exact-start h2 {
  display: flex;
  gap: var(--s2);
  align-items: center;
  margin-top: 0;
}

.exact-start .hint {
  font-style: italic;
}

.plan .share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: var(--s4) 0;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

.plan .share h2 {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.plan .share .hint {
  flex-basis: 100%;
  margin: 0;
}

.plan .share .hint:empty {
  display: none;
}

/* You and the group */

.plan-side {
  margin-top: var(--s5);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}

.plan .plan-side > *,
.plan .plan-after > * {
  margin: var(--s5) 0;
}

.plan-after {
  margin-top: var(--s5);
  border-top: 1px solid var(--line);
}

.plan-side h2 {
  margin-top: 0;
}

.status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s1) var(--s3);
  align-items: center;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.status-joined,
.status-loggedIn {
  border-color: var(--ok-line);
  background: var(--ok-bg);
}

.status-text {
  grid-column: span 2;
}

.status-icon + .status-text {
  grid-column: auto;
}

.status-text h2 {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.status-joined .status-text h2,
.status-loggedIn .status-text h2 {
  color: var(--ok);
}

.status-text p {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--ok-bg);
}

.status-action {
  grid-column: 1 / -1;
  margin: var(--s1) 0 0;
}

.status-action a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

/* Counters are a secondary-color fill (spec 3.1); text keeps the normal color. */
.counts {
  display: inline-block;
  padding: 2px var(--s3);
  border-radius: var(--r-pill);
  background: var(--plan-secondary-tint, var(--surface));
  font-size: var(--text-sm);
  font-weight: 600;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  margin-bottom: var(--s3);
}

.section-head h2,
.section-head .counts {
  margin: 0;
}

.people-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  gap: var(--s4) var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A round initial with the name below, the host's badge on the initial (D30). */
.person {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  align-items: center;
  min-width: 0;
  text-align: center;
}

.person .avatar {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  font-weight: 600;
}

/* The host's mark: a flag on the initial's top right, in the plan's secondary colour like the
   host's initial, with a ring in the page colour to set it off. */
.host-mark {
  position: absolute;
  top: -4px;
  left: calc(50% + 14px);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--plan-secondary, var(--plan-secondary-default));
  color: var(--plan-on-secondary, var(--plan-on-secondary-default));
}

.host-mark .icon {
  width: 14px;
  height: 14px;
  vertical-align: 0;
}

.person-label {
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Initials coloured from the name (never from an account); the host's in the plan's secondary
   colour (spec 3.1). */
.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: 700;
}

.avatar-0 {
  background: var(--avatar-0-bg);
  color: var(--avatar-0-fg);
}
.avatar-1 {
  background: var(--avatar-1-bg);
  color: var(--avatar-1-fg);
}
.avatar-2 {
  background: var(--avatar-2-bg);
  color: var(--avatar-2-fg);
}
.avatar-3 {
  background: var(--avatar-3-bg);
  color: var(--avatar-3-fg);
}
.avatar-4 {
  background: var(--avatar-4-bg);
  color: var(--avatar-4-fg);
}
.avatar-5 {
  background: var(--avatar-5-bg);
  color: var(--avatar-5-fg);
}
.avatar-6 {
  background: var(--avatar-6-bg);
  color: var(--avatar-6-fg);
}
.avatar-7 {
  background: var(--avatar-7-bg);
  color: var(--avatar-7-fg);
}

.avatar-host {
  background: var(--plan-secondary, var(--plan-secondary-default));
  color: var(--plan-on-secondary, var(--plan-on-secondary-default));
}

.deletion {
  color: var(--muted);
  font-size: var(--text-sm);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.actions .button {
  flex: 1 1 14rem;
}

@media (min-width: 960px) {
  .wide {
    max-width: 72rem;
  }

  /* The recap sits under the plan, beside you and the group. */
  .plan {
    display: grid;
    grid-template-areas:
      "main side"
      "after side";
    grid-template-rows: auto 1fr;
    grid-template-columns: minmax(0, 1.6fr) minmax(20rem, 1fr);
    gap: 0 var(--s6);
    align-items: start;
  }

  .plan-main {
    grid-area: main;
  }

  .plan-after {
    grid-area: after;
  }

  .plan-side {
    grid-area: side;
    margin-top: var(--s4);
    padding: 0 0 0 var(--s6);
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .plan-side > :first-child {
    margin-top: var(--s4);
  }

  .plan-side .actions {
    flex-direction: column;
  }

  .plan-side .actions .button {
    flex: none;
  }

  .map.plan-map {
    height: 360px;
  }
}

/* Responding and managing */

.respond,
.manage form {
  margin: var(--s4) 0;
}

.withdraw {
  margin: var(--s5) 0;
}

.withdraw summary {
  color: var(--danger);
}

/* Recap (spec 6 feature 5) */

.contribution p {
  margin: var(--s1) 0;
}

.contribution-author {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.contribution-body {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.contribution-link a {
  overflow-wrap: anywhere;
}

.service {
  display: inline-block;
  padding: 0 var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
}

.hidden-contribution {
  opacity: 0.6;
}

.contribution-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
}

.contribution-actions form {
  margin: 0;
}

/* Host page */

.people-actions li {
  display: flex;
  gap: var(--s3);
  align-items: center;
  justify-content: space-between;
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--line);
}

.people-actions form {
  margin: 0;
}

/* Pending requests on the host page (spec 6 feature 1): name, note, then the two buttons. */
.people-actions.requests li {
  flex-wrap: wrap;
}

.request-note {
  flex-basis: 100%;
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
}

.danger-zone {
  margin: var(--s5) 0;
}

.danger-zone summary,
.danger-zone a {
  color: var(--danger);
}

details > summary {
  min-height: var(--target);
  cursor: pointer;
}

/* Maps (spec 3.9, decision D12) */

.map {
  height: 280px;
  margin: var(--s3) 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

/* Dark mode: the tiles darkened in the browser, so it works with any tile server; only the tiles,
   so the area circle, pins and route keep their colours. Controls in the page's dark colours. */
@media (prefers-color-scheme: dark) {
  .map.leaflet-container {
    background: var(--surface);
  }

  .map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9);
  }

  .map .leaflet-bar a {
    border-color: var(--line);
    background: var(--surface);
    color: var(--fg);
  }

  .map .leaflet-bar a:hover,
  .map .leaflet-bar a:focus {
    background: var(--line);
  }

  /* As specific as Leaflet's own rule, which comes later. */
  .map.leaflet-container .leaflet-control-attribution {
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    color: var(--muted);
  }

  .map.leaflet-container .leaflet-control-attribution a {
    color: var(--accent);
  }
}

.map-tools {
  margin: var(--s3) 0;
}

.map-tools > button {
  margin: var(--s1) 0;
}

.inline-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}

.inline-input .handle-host {
  overflow-wrap: anywhere;
}

.inline-input input {
  flex: 1;
  min-width: 10rem;
}

.place-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.place-results button {
  width: 100%;
  margin: var(--s1) 0;
  text-align: left;
}

.plan-form .map-mode {
  margin: var(--s2) 0;
  padding: 0;
  border: 0;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

/* Notification switch (spec 6 feature 3), shown only where push works. */
.push,
.email-switch {
  margin: var(--s5) 0;
}

/* The email setting under the push switch (decision D31), and ntfy in the fold (D33): their notice
   and buttons close together; the row's forms keep no margin of their own, also where a page gives
   its forms one (.manage). */
.email-switch .notice,
.ntfy-switch .notice,
.telegram-switch .notice {
  margin-bottom: var(--s3);
}

.email-switch .button-row form {
  margin: 0;
}

/* "More ways to be notified" (decision D33): ntfy and later Telegram in one fold under email. */
.more-channels {
  margin: var(--s5) 0;
}

.more-channels h3 {
  margin: var(--s4) 0 var(--s2);
  font-size: var(--text-md);
}

.more-channels .button-row {
  margin-top: var(--s3);
}

/* Each channel its own part: room above the next one's heading. */
:is(.ntfy-switch, .telegram-switch) + :is(.telegram-switch, .fediverse-messages-switch) {
  margin-top: var(--s6);
}

/* As in the email block: the row's forms keep no margin of their own, also on .manage pages. */
.more-channels .button-row form {
  margin: 0;
}

/* "Email me my links" under "Get a new link" (decision D31): its hint over its own button, with
   room above it and before the fold below. */
.link-tools form + form {
  margin: var(--s4) 0;
}

.link-tools form + form .hint {
  margin: 0 0 var(--s2);
}

/* Ratings (spec 6a): the own note keeps its line breaks. */
.rating-note {
  white-space: pre-line;
}

/* Reports (spec 7 Moderation): a quiet link at the foot of the plan page; on the admin pages the
   reporter's details keep their line breaks, and attached copies are listed like ratings. */
.report-link {
  font-size: var(--text-sm);
}

.report-details,
.report-attached > li {
  white-space: pre-line;
}
