:root {
  color-scheme: light;
  --bg: #f6f5f2; --card: #ffffff; --field: #ffffff; --text: #1f2328; --muted: #646a73;
  --line: #dedbd4; --accent: #2f5d8a; --accent-text: #ffffff;
  --yes: #1f7a43; --yes-bg: #e3f3e8; --no: #b3261e; --no-bg: #fbe5e3;
  --pending: #8a5a00; --pending-bg: #fbf0d9; --info-bg: #e5eef7;
  --neutral-bg: #ececec; --prompt-line: #b9cfe8; --prompt-bg: #f3f8fd;
}
/* Dark mode (UC11b): chosen under Your details. <html data-theme="dark">, or
   data-theme="system" to follow the device. The two blocks are the same. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171a; --card: #1e2125; --field: #24282d; --text: #e6e8eb; --muted: #9aa1ab;
  --line: #353a41; --accent: #7fb0e0; --accent-text: #10161d;
  --yes: #6fcf97; --yes-bg: #183324; --no: #f2867c; --no-bg: #3a1d1b;
  --pending: #e6b85c; --pending-bg: #352a12; --info-bg: #1d2a38;
  --neutral-bg: #2c3036; --prompt-line: #34506e; --prompt-bg: #1a2530;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #15171a; --card: #1e2125; --field: #24282d; --text: #e6e8eb; --muted: #9aa1ab;
    --line: #353a41; --accent: #7fb0e0; --accent-text: #10161d;
    --yes: #6fcf97; --yes-bg: #183324; --no: #f2867c; --no-bg: #3a1d1b;
    --pending: #e6b85c; --pending-bg: #352a12; --info-bg: #1d2a38;
    --neutral-bg: #2c3036; --prompt-line: #34506e; --prompt-bg: #1a2530;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header.top { background: var(--card); border-bottom: 1px solid var(--line); }
header.top .inner, main { max-width: 52rem; margin: 0 auto; padding: 0.75rem 1rem; }
header.top .inner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
header.top .brand { font-weight: 700; text-decoration: none; color: var(--text); }
header.top nav { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
main { padding-bottom: 3rem; }
h1 { font-size: 1.6rem; margin: 1rem 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; margin: 0.75rem 0; }
.card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.tabs { display: flex; gap: 0.25rem 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--line);
  padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
.tabs a { text-decoration: none; }
.tabs a.current { font-weight: 700; color: var(--text); }
form.stack { display: grid; gap: 0.75rem; max-width: 32rem; }
form.inline { display: inline; margin: 0; }
label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.95rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
input, select, textarea { font: inherit; padding: 0.55rem 0.6rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--field); color: var(--text); width: 100%; }
textarea { min-height: 5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: end; }
@media (max-width: 30rem) { .grid2 { grid-template-columns: 1fr; } }
button, .button { font: inherit; font-weight: 600; padding: 0.5rem 0.9rem; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary, .button.secondary { background: var(--card); color: var(--accent); }
button.danger { background: var(--card); color: var(--no); border-color: var(--no); }
button.yes { background: var(--yes); border-color: var(--yes); }
button.no { background: var(--no); border-color: var(--no); }
button.small, .button.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 400;
  text-decoration: underline; }
.badge { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.8rem;
  font-weight: 600; background: var(--info-bg); color: var(--accent); }
.badge.confirmed, .badge.yes { background: var(--yes-bg); color: var(--yes); }
.badge.no { background: var(--no-bg); color: var(--no); }
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.cancelled, .badge.expired { background: var(--neutral-bg); color: var(--muted); }
.notice { padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 0; background: var(--info-bg); }
.notice.error { background: var(--no-bg); color: var(--no); }
.notice.warn { background: var(--pending-bg); color: var(--pending); }
.notice.ok { background: var(--yes-bg); color: var(--yes); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
td.nowrap { white-space: nowrap; }
details summary { cursor: pointer; color: var(--accent); }
.big-answer { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; }
.big-answer button { font-size: 1.1rem; padding: 0.75rem 1.25rem; }
.row select, .row input { width: auto; flex: 1 1 10rem; }
ol.log { list-style: none; padding: 0; margin: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; }
ol.log li { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); }
ol.log li:last-child { border-bottom: none; }
.row input[type=checkbox] { flex: none; width: auto; }

td.num, th.num { text-align: right; }
td.num.out { color: var(--no); }
.totals .row { padding: 0.15rem 0; }
.totals .result { border-top: 1px solid var(--line); margin-top: 0.35rem; padding-top: 0.5rem; }
.tabs.years { border: none; margin: 0; padding: 0; }

/* Date picker (datepicker.js): weeks start on Monday. */
label:has(input[data-datepicker]) { position: relative; }
.datepicker { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 0.25rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); padding: 0.5rem; font-weight: 400; width: max-content; }
.datepicker .dp-head { display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.25rem; }
.datepicker .dp-nav { background: none; color: var(--accent); border: none; font-size: 1.2rem;
  padding: 0.1rem 0.6rem; cursor: pointer; }
.datepicker table { width: auto; background: none; }
.datepicker th, .datepicker td { border: none; padding: 0.1rem; text-align: center; }
.datepicker .dp-week { color: var(--muted); font-size: 0.75rem; padding-right: 0.35rem; vertical-align: middle; }
.datepicker .dp-day { width: 2.2rem; height: 2.2rem; padding: 0; border-radius: 6px; cursor: pointer;
  background: none; color: var(--text); border: 1px solid transparent; font-size: 0.9rem; }
.datepicker .dp-day:hover { background: var(--info-bg); }
.datepicker .dp-other { color: var(--muted); opacity: 0.6; }
.datepicker .dp-today { border-color: var(--accent); }
.datepicker .dp-selected { background: var(--accent); color: var(--accent-text); }
[hidden] { display: none !important; }

/* --- Phones ---------------------------------------------------------------- */
/* Long words (email addresses, URLs) wrap instead of widening the page. */
main { overflow-wrap: break-word; }
pre { max-width: 100%; overflow-x: auto; }
pre.example { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.75rem; font-size: 0.85rem; }
ul.tight { margin: 0.25rem 0; padding-left: 1.25rem; }
ul.tight li { margin: 0.2rem 0; }
.import-problem { color: var(--no); }
table.import tr.invalid td { background: var(--no-bg); }
/* Selects take the width of their longest option: never wider than the screen. */
select { max-width: 100%; text-overflow: ellipsis; }
.row select, .row input { min-width: 0; }

/* Tables with class "cards" become one card per row on narrow screens: each
   cell shows its column name (data-label) on the left, the value on the right. */
@media (max-width: 36rem) {
  h1 { font-size: 1.4rem; }
  main { padding-left: 0.75rem; padding-right: 0.75rem; }
  .card { padding: 0.85rem; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr { display: block; width: 100%; }
  table.cards tr { border-bottom: 1px solid var(--line); padding: 0.5rem 0.75rem; }
  table.cards td { display: flex; justify-content: flex-end; align-items: baseline; flex-wrap: wrap;
    gap: 0.25rem 0.5rem; border: none; padding: 0.15rem 0; text-align: right; white-space: normal; }
  table.cards td::before { content: attr(data-label); flex: none; text-align: left; margin-right: auto;
    padding-right: 0.5rem; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
  table.cards td:not([data-label])::before { content: none; }
  table.cards td:empty { display: none; }
  table.cards td.actions { justify-content: flex-end; padding-top: 0.35rem; }
  table.cards td.num { text-align: right; }
  .datepicker .dp-day { width: 2.4rem; height: 2.4rem; } /* bigger touch targets */
}

/* Comments on a booking (UC12) */
ol.comments { list-style: none; padding: 0; margin: 0 0 1rem; }
li.comment { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; }
.comment-head { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.comment-text { white-space: pre-wrap; margin-top: 0.25rem; }

/* Asking for a missing detail (UC11) */
.card.prompt { border-color: var(--prompt-line); background: var(--prompt-bg); }

/* About page */
article.about { max-width: 42rem; }
article.about .lead { font-size: 1.1rem; }
header.top nav { flex-wrap: wrap; }

/* Cards on the Settings tab for sharing the band's gigs: the calendar feed
   (UC8) and the public gigs API (UC13). */
.card.share { margin-top: 1.5rem; }
.card.share h2 { margin-top: 0; font-size: 1.1rem; }
.card.share form { margin-top: 0.5rem; }
.card.share form p { margin-top: 0; }
pre.url { margin: 0.5rem 0; padding: 0.5rem 0.6rem; background: var(--bg); border-radius: 6px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
/* Inline code (URLs, query strings) may break anywhere rather than stick out. */
:not(pre) > code { overflow-wrap: anywhere; }

/* Dialogs (D48): centred on a wide screen, a sheet at the bottom of a
   phone's screen with full-width buttons that are easy to tap. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
dialog.modal { border: none; border-radius: 12px; padding: 0; color: var(--text);
  background: var(--card); width: min(30rem, calc(100vw - 2rem)); max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
/* A dialog inside a table cell mustn't take the cell's alignment. */
dialog.modal { text-align: left; white-space: normal; font-weight: 400; }
.nowrap { white-space: nowrap; }
dialog.modal::backdrop { background: rgba(20, 22, 26, 0.45); }
dialog.modal .dialog-body { padding: 1.25rem; }
dialog.modal h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }
dialog.modal p { margin: 0.5rem 0; }
body:has(dialog.modal[open]) { overflow: hidden; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end;
  margin-top: 1.25rem; }
.dialog-actions form, .dialog-choices form { display: contents; }
.dialog-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 1rem 0; }
.dialog-choices button { padding: 0.8rem 0.5rem; font-size: 1.05rem; }
button:disabled { opacity: 0.45; cursor: default; }
button.danger.solid { background: var(--no); color: var(--card); }
@media (max-width: 36rem) {
  dialog.modal { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 90dvh;
    border-radius: 14px 14px 0 0; }
  dialog.modal .dialog-body { padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; min-height: 2.9rem; }
  .dialog-choices { grid-template-columns: 1fr; }
  .dialog-choices button { min-height: 3.1rem; }
}

/* Shared secrets (UC14): a card whose content opens like an accordion. */
.card.share.secrets summary { list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.card.share.secrets summary::-webkit-details-marker { display: none; }
.card.share.secrets summary::before { content: "\25B8"; color: var(--accent); transition: transform 0.15s; }
.card.share.secrets details[open] > summary::before { transform: rotate(90deg); }
.card.share.secrets summary h2 { margin: 0; color: var(--text); }
.card.share.secrets details[open] > summary { margin-bottom: 0.5rem; }
textarea.secrets-text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem; min-height: 12rem; }
.secrets-saved pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.6rem; margin: 0; }

/* Reminder interval presets under the field (FR52). */
.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: -0.35rem; }
.presets button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
@media (max-width: 36rem) { .presets button { min-height: 2.5rem; } }

/* Who has read a comment (UC12b). */
.comment-reads { margin-top: 0.5rem; padding-top: 0.4rem; border-top: 1px dashed var(--line); }
.comment-reads p { margin: 0 0 0.25rem; }
.comment-reads form { margin: 0.25rem 0 0; }
@media (max-width: 36rem) { .comment-reads button { min-height: 2.5rem; width: 100%; } }

/* Documentation page (/docs). */
.docs nav.toc { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 1rem; }
.docs nav.toc h2 { margin-top: 0; font-size: 1.1rem; }
.docs nav.toc ol { columns: 2; margin: 0; padding-left: 1.25rem; }
.docs section { scroll-margin-top: 1rem; }
.docs section h3 { margin-bottom: 0.25rem; }
@media (max-width: 36rem) { .docs nav.toc ol { columns: 1; } }

/* A helper text on hover, tap or keyboard focus, e.g. for a disabled button
   (UC5b). Disabled buttons get no mouse events, so the wrapper carries it;
   the page also says it in text. It's placed above the whole row
   (.has-tooltips), so it never sticks out of a phone's screen. */
.has-tooltips { position: relative; }
.tooltip { display: inline-block; }
.tooltip button[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.tooltip::after {
  content: attr(data-tooltip); position: absolute; left: 0; bottom: calc(100% + 0.4rem); z-index: 10;
  width: max-content; max-width: min(22rem, 100%); padding: 0.4rem 0.6rem; border-radius: 6px;
  background: var(--text, #222); color: var(--bg, #fff); font-size: 0.85rem; line-height: 1.3;
  display: none; pointer-events: none;   /* not laid out until shown: no sideways scrolling */
}
.tooltip:hover::after, .tooltip:focus::after, .tooltip:focus-within::after { display: block; }
.tooltip:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Booking page (D55): tabs like the band's, your own answer as two big
   buttons, and the comment form as wide as the comments. */
.tabs[aria-label="Booking"] { margin: 0.75rem 0 1rem; }
.my-answer { margin: 0.5rem 0; }
.my-answer button { flex: 1 1 12rem; min-height: 3.25rem; font-size: 1.15rem; font-weight: 700; }
.my-answer button.yes-outline { color: var(--yes); border: 2px solid var(--yes); background: var(--card); }
.my-answer button.no-outline { color: var(--no); border: 2px solid var(--no); background: var(--card); }
.my-answer button[aria-pressed="true"]::before { content: "✓ "; }
#comment-form { max-width: none; }

/* Booking page (D55): tabs like the band's, your own answer as two big
   buttons, and the comment form as wide as the comments. */
.tabs[aria-label="Booking"] { margin: 0.75rem 0 1rem; }
.my-answer { margin: 0.5rem 0; }
.my-answer button { flex: 1 1 12rem; min-height: 3.25rem; font-size: 1.15rem; font-weight: 700; }
.my-answer button.yes-outline { color: var(--yes); border: 2px solid var(--yes); background: var(--card); }
.my-answer button.no-outline { color: var(--no); border: 2px solid var(--no); background: var(--card); }
.my-answer button[aria-pressed="true"]::before { content: "✓ "; }
#comment-form { max-width: none; }

/* Appearance choice on Your details (UC11b) */
fieldset.choices { border: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
fieldset.choices legend { font-weight: 600; font-size: 0.95rem; padding: 0; margin-bottom: 0.25rem; }
fieldset.choices label { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
fieldset.choices input[type="radio"] { width: auto; margin: 0; }

/* Breadcrumbs: Home › The Core › Members */
nav.breadcrumbs { font-size: 0.875rem; margin: 0.5rem 0 0; }
nav.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.1rem 0; }
nav.breadcrumbs li { display: inline; overflow-wrap: anywhere; }
nav.breadcrumbs li + li::before { content: "\203A"; color: var(--muted); padding: 0 0.45rem; }
nav.breadcrumbs [aria-current="page"] { color: var(--muted); }

/* The member's bands on the start page: one per row, as wide as the
   upcoming bookings' cards below them */
.band-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; margin: 0.75rem 0; }
.band-cards .card { margin: 0; display: grid; gap: 0.4rem; align-content: start; }
.band-card h3 { overflow-wrap: anywhere; }
.band-card.needs-answer { border-left: 4px solid var(--pending); }
.band-card .awaiting { margin: 0; padding: 0.5rem 0.75rem; }
.band-card .awaiting ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.band-card .awaiting a { color: inherit; }
.band-card nav.band-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; border-top: 1px solid var(--line);
  padding-top: 0.4rem; }

/* Upcoming bookings on the start page: the first three, then "Show N more" */
details.more-bookings > summary { margin: 0.25rem 0 0.5rem; font-weight: 600; }
details.more-bookings .when-open, details.more-bookings[open] .when-closed { display: none; }
details.more-bookings[open] .when-open { display: inline; }
details.more-bookings[open] > summary { margin-bottom: 0; }

/* A link straight to a comment (UC12c): under each comment, and the
   comment a link leads to is marked */
.comment-link { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; margin-top: 0.35rem; }
.comment-link .copied { overflow-wrap: anywhere; }
li.comment { scroll-margin-top: 1rem; }
li.comment:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Changing a comment, and its versions (UC12d). */
.comment-head .edited a { margin-left: 0.15rem; }
details.comment-edit { margin-top: 0.35rem; }
details.comment-edit > summary { display: inline-block; }
details.comment-edit form { margin-top: 0.4rem; max-width: none; }
.version-nav { align-items: center; gap: 0.75rem; }
.button.disabled { opacity: 0.45; pointer-events: none; }
ol.versions { padding-left: 1.2rem; }
ol.versions li { margin: 0.2rem 0; }

/* Notes (UC15) and their files (UC15b). */
ul.notes { list-style: none; padding: 0; margin: 1rem 0; }
.card.note-card { margin-bottom: 0.6rem; }
.note-card .note-title { font-weight: 600; font-size: 1.05rem; }
details.new-note, details.edit-note { margin: 1rem 0; }
details.new-note form, details.edit-note form { margin-top: 0.5rem; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 0.5rem; }
textarea.note-text { min-height: 10rem; }
.note-saved pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem; }
ul.attachments { list-style: none; padding: 0; margin: 0 0 1rem; }
li.attachment { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
li.attachment > a { font-weight: 600; overflow-wrap: anywhere; }
button.link.danger { color: var(--no); border: none; background: none; }
form.upload input[type="file"] { padding: 0.4rem 0; }
section.remove-note { margin-top: 2rem; }

/* UC15c: tags on notes, and the Notes tab's filter */
.tags { list-style: none; padding: 0; margin: 0.25rem 0 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
a.tag { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.6rem;
  border-radius: 999px; font-size: 0.85rem; background: var(--info-bg); color: var(--accent);
  text-decoration: none; border: 1px solid transparent; overflow-wrap: anywhere; }
a.tag:hover { border-color: var(--accent); }
a.tag.chosen { background: var(--accent); color: var(--accent-text); }
a.tag .count { font-size: 0.75rem; opacity: 0.75; }
.tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.75rem 0; }
.tag-filter a.tag { min-height: 2rem; }
.filter-summary { margin: 0 0 0.5rem; }

/* UC8b: the calendar feed hint on a band card, and the old shared address */
.calendar-hint { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem;
  margin: 0.5rem 0; padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--info-bg); }
.calendar-hint form { margin: 0; }
.shared-feed { margin-top: 1rem; }
.shared-feed summary { cursor: pointer; color: var(--muted); }
