/* The phone pass: density fixes that apply on a phone only.
 *
 * The question behind every rule here: how far down does the thing this screen is for start? On a
 * 390x844 phone the Guests screen used to spend its first screen on a title, a sentence, two rows of
 * buttons, a views label, four filters, two more buttons and a sort, and showed no guest at all.
 * Nothing is removed from the page (a hidden heading is still in the accessibility tree, and every
 * control is still there on a laptop); the phone just stops repeating itself and stops giving rarely
 * used controls a row each.
 *
 * Tokens only, no raw colours. Loaded after css/app.css and css/shell.css so it wins ties. */

@media (max-width: 640px) {
  /* The open tab is already named, in the row of chips under the header. Repeating it as a 36px
     heading cost about 60px of a first screen that has 700. The heading stays for screen readers
     (and for the page when it prints, via print.css), and the sentence beside it stays visible.
     Only where the chips are showing: Overview and Settings have none, so there the heading is
     the only title the screen has. */
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > h2 {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  #app:has(#subnav:not([hidden])) main { padding-top: var(--space-16); }
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child { margin-bottom: var(--space-16); gap: var(--space-8) var(--space-16); }

  /* People | Parties is a switch with two equal halves, sharing one row with Add guest (owner's request, 16 Nov:
     less before the first guest). The spacer that pushed it right on a laptop goes. */
  .guests-head .spacer { display: none; }
  /* The summary takes a line of its own above them. Sharing the row, a long summary ("1 guest on 0 parties. 0
     coming…") squeezed the switch until it was cut off at the right edge (owner's report, 17 Nov). The switch
     also has a floor, so nothing can squeeze it again. */
  .guests-head .section-byline { order: -1; flex-basis: 100%; }
  .guests-head .filter-group { flex: 1 1 0; min-width: 176px; }
  .guests-head .filter-group { flex-wrap: nowrap; }
  .guests-head .filter-group .filter-btn { padding-inline: var(--space-8); white-space: nowrap; }
  .guests-head .filter-group .filter-btn .material-symbols-rounded { display: none; }
  .guests-head .filter-group .filter-btn { flex: 1 1 0; justify-content: center; }

  /* A name that wraps to a narrow column (Music at 360px) was 40px wide: a link needs 44 each way. */
  .guest-link { min-width: 44px; }

  /* The Add guest menu opens under its button, from the button's left edge. It used to hang from the right edge
     (right: 0), which on a phone put most of it off the left of the screen, because the button is narrower than
     the menu. */
  .add-guest-menu .tab-more-pop { left: 0; right: auto; max-width: calc(100vw - 32px); }

  /* The filter popout is fixed above the bottom bar and used to grow upwards with however many options there
     were. With 156 guests (every menu choice, every table) it was taller than the screen: its top, and the first
     filters, were off the top with no way to scroll to them. It now stops short of the header, scrolls inside
     itself, and keeps Clear filters and Done pinned where a thumb is. */
  .filter-pop {
    max-height: calc(100vh - 76px - 130px - env(safe-area-inset-bottom)); max-height: calc(100dvh - 76px - 130px - env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain;
  }
  .filter-pop-foot { position: sticky; bottom: calc(var(--space-24) * -1); margin-bottom: calc(var(--space-24) * -1); padding-bottom: var(--space-24); background: var(--card); }

  /* Text size Larger at 360px: three things were wider than the screen and made the whole page scroll sideways.
     A row of segments (Everything, Helper, View only, Custom) now wraps instead of running on, a chip with a long
     supplier name wraps its words, and a group of filter buttons may take a second line. */
  .seg, .filter-group { flex-wrap: wrap; max-width: 100%; }
  .seg { border-radius: var(--radius-card); }
  .chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

}

/* No heading or tagline ends on a lone word ("Your wedding, where you left / it."). */
.auth-tagline, h1, h2, h3, .empty-state strong { text-wrap: balance; }

@media (min-width: 641px) {
  /* On a laptop the same menu hangs from the right edge, where the button sits. */
  .add-guest-menu .tab-more-pop { left: auto; right: 0; }
}

/* iOS Safari zooms the whole page when a field with text smaller than 16px is focused, and does not zoom back.
   Search boxes, selects and the record forms were 15px (one select 13px). Sixteen on anything touch or narrow.
   !important because the sizes are set by dozens of component rules of every specificity. */
@media (max-width: 640px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  select, textarea { font-size: 16px !important; }
}

/* A tablet, or a phone on its side (641 to 900px): Settings' row of section chips was given a -40px margin to
   reach the screen edges, but the page's own side padding at these widths is 20 to 27px, so the row stuck out
   by up to 20px and the whole page scrolled sideways. Take back exactly what the page gave. */
@media (min-width: 641px) and (max-width: 900px) {
  .section-nav {
    margin-inline: calc(-1 * clamp(var(--space-24), 3vw, var(--space-48))); padding-inline: clamp(var(--space-24), 3vw, var(--space-48));
    top: 109px; /* under the header, which has its names row below 1024px */
  }
  .settings-section, .settings-part, .settings-about { scroll-margin-top: 180px; }
}

/* A phone on its side is about 360px tall. Two rows of header (the names, then the tabs) are 150px of that and
   they are pinned, so a first screen showed a header and a heading and nothing else. Let the header scroll away
   there; the page is one swipe from its top. */
@media (max-height: 520px) and (orientation: landscape) {
  #topbar { position: static; }
  .section-nav { top: 0; }
  .settings-section, .settings-part, .settings-about { scroll-margin-top: 72px; }
}

/* ===== m-guests: "Filters and sort", and drawing the guest list a page at a time =====
 *
 * Select shown, Columns and Sort by used to take two rows and a menu of their own between the search box and the
 * first guest. On a phone they are rows inside the one popout, under the filters (js/tabs/guests-phone.js), so the
 * first guest card starts about 150px higher and there are three fewer things to tap above it.
 * The list itself is drawn 40 guests at a time with a "Show more" button (js/shared/paging.js). */

@media (max-width: 640px) {
  /* Sort by: a label with an icon, as the filters have, then the menu and the direction button. */
  .filter-pop-sort { display: flex; align-items: center; gap: var(--space-8); }
  .filter-pop-sort select {
    flex: 1; min-width: 0; min-height: 44px; padding: 0 var(--space-16); font: inherit; font-weight: 600;
    border: 1.5px solid var(--control); border-radius: var(--radius); background: var(--card); color: var(--text);
  }
  .filter-pop-label[for] { cursor: pointer; }

  /* A row that does something (choose columns, select shown): a name, a quiet note, and an arrow if it opens more. */
  .filter-pop-row {
    display: flex; align-items: center; gap: var(--space-8); width: 100%; min-height: 44px; padding: 0 var(--space-16);
    font: 600 14px var(--font-family); color: var(--text); text-align: left; cursor: pointer;
    background: transparent; border: 1.5px solid var(--control); border-radius: var(--radius);
  }
  .filter-pop-row:hover { background: var(--surface); }
  .filter-pop-row-note { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); }
  .filter-pop-row .material-symbols-rounded { flex: none; font-size: 20px; color: var(--muted); }
  .filter-pop-row-note + .material-symbols-rounded { margin-left: calc(var(--space-4) * -1); }

  /* The search box and the Filters and sort button share one row, so the box may shrink (its hint is short on a
     phone, see js/tabs/guests.js), and the toolbar needs less room under it and the views above it. */
  .guests-page .table-toolbar .search-bar { min-width: 0; }
  .guests-page .table-toolbar { margin-bottom: var(--space-8); }
  .guests-page .views { margin-bottom: var(--space-16); }
  .guests-page .table-toolbar .filter-menu-btn { padding-inline: var(--space-16); }
  table.data tr.group-row { padding-top: var(--space-16); }
}

/* "and sort" is read out but not drawn on the narrowest phones: the word Filters is still in the name, and the button
   shares its row with the search box. */
@media (max-width: 374px) {
  .filter-menu-more {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

/* The line and button under a list that is drawn a page at a time. The line is a polite live region. */
.show-more { display: grid; justify-items: stretch; gap: var(--space-8); padding: var(--space-16) 0 var(--space-8); }
.show-more-count { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.show-more-btn { justify-content: center; min-height: 48px; }
@media print {
  /* Paper has every guest (js/ui/table.js draws the rest just before printing), so no button. */
  .show-more { display: none; }
}

/* ===== m-tables: the Table plan on a phone, tables first =====
 *
 * "Not seated" used to be a card of 16 identical Seat buttons, 1,100px tall, with the first table at y 1,615
 * of a 6,100px page. On a phone it is now one row ("16 not seated" and a Seat someone button) and the
 * people are seated from a sheet (js/ui/seat-sheet.js). js/tabs/tables.js draws the row only on a phone
 * (it redraws when the window crosses 640px); a laptop's panel is untouched. The row is first (the rule in
 * app.css that puts Not seated above the tables stays) but it is one line, so the first table is a
 * screenful higher. */
@media (max-width: 640px) {
  .tableplan-layout { gap: var(--space-16); }
  .tableplan-unseated { padding: var(--space-8) var(--space-16) var(--space-8) var(--space-16); }
  .unseated-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); min-height: 48px; }
  .unseated-summary-text {
    display: inline-flex; align-items: center; gap: var(--space-8); margin: 0; min-width: 0;
    font-family: var(--font-family); font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--text);
  }
  .unseated-summary-text .material-symbols-rounded { font-size: 20px; color: var(--accent-dark); }
  .unseated-summary-btn { flex: none; min-height: 44px; padding: 0 var(--space-16); }
  /* Belt and braces: nothing but the row is ever shown here, whatever drew the panel. */
  .tableplan-unseated > :not(.unseated-summary) { display: none !important; }

  /* The sheet. A column that fits the screen, so the search stays put and only the list scrolls. */
  .seat-sheet-box { display: flex; flex-direction: column; overflow: hidden; }
  .seat-sheet { display: flex; flex-direction: column; gap: var(--space-8); flex: 1 1 auto; min-height: 0; }
  .seat-sheet [hidden] { display: none !important; }
  .seat-sheet-status { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
  .seat-sheet-order { display: flex; }
  .seat-sheet-order button { flex: 1 1 0; justify-content: center; min-height: 44px; }
  .seat-sheet .search-bar { max-width: none; flex: none; }
  .seat-sheet-list { display: flex; flex-direction: column; gap: var(--space-4); flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .seat-sheet .modal-foot { flex: none; }
  .seat-sheet-empty { display: flex; align-items: center; justify-content: center; gap: var(--space-8); border: none; padding: var(--space-24) 0; }
  .seat-sheet-empty .material-symbols-rounded { color: var(--accent-dark); }

  /* A whole row is the button: a name, a small arrow, nothing repeated. */
  .unseated-pick {
    display: flex; align-items: center; gap: var(--space-8); width: 100%; min-height: 52px; padding: var(--space-8) var(--space-8) var(--space-8) var(--space-16);
    border: none; border-radius: var(--radius); background: var(--surface); color: var(--text);
    font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; flex: none;
  }
  .unseated-pick:hover, .unseated-pick:active { background: var(--accent-soft); }
  .unseated-pick.nested { width: calc(100% - 14px); margin-left: var(--space-16); }
  /* Inside a party's box the people are already shown as belonging to it. */
  .party-box .unseated-pick.nested { width: 100%; margin-left: 0; background: none; }
  .unseated-pick-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .unseated-pick-go { color: var(--muted); flex: none; }
  .seat-sheet .unseated-group { gap: var(--space-4); }
  .unseated-party.in-sheet { cursor: default; }
}

/* ===== m-rest: the Overview first screen, Settings, tick circles ===================================
 *
 * Phones only (640px and under) unless a rule says otherwise: every rule that is not inside the media
 * query below only sets a thing that is invisible on a laptop (the short wording, the tick, the "Show
 * more" button), so the laptop layout is the layout it was.
 *
 * "Visually hidden" below always means the sr-only recipe (a 1px clipped box), never display: none, so a
 * screen reader still has the heading, the names and the full sentence.
 */

/* Things only a phone draws. */
.remind-short, .coming-tick, .dev-more { display: none; }
.remind-later > .material-symbols-rounded { display: none; }

/* The wrapper a to-do row gets when it carries a tick circle (js/tabs/overview-coming.js). It takes over the
   row's top rule and the row stretches to fill it, so a laptop draws exactly the row it drew before. */
.coming-item { display: flex; align-items: center; border-top: 1px solid var(--border); }
.coming-item > .coming-row { flex: 1 1 auto; width: auto; min-width: 0; border-top: 0; }
.coming-list > .coming-item:first-child { border-top: 0; }

@media (max-width: 640px) {
  /* S4. The Overview opened on a 240px card (a date, a number, the names, the venue) and a 130px banner, so
     the first thing due was at y 745 of 844, below the fold. The names are already in the header and the
     venue is one tap away in Settings, so the card is the date and the number only. */
  .ov { gap: var(--space-32); }
  .card.hero { padding: var(--space-16) var(--space-24); gap: 0; }
  .card.hero .countdown-where {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .card.hero .countdown-main { gap: var(--space-16); }
  .card.hero .date-tile { min-width: 84px; border-radius: 14px; }
  .card.hero .date-tile-month { padding: var(--space-4) var(--space-8); }
  .card.hero .date-tile-day { font-size: 36px; padding-top: var(--space-4); }
  .card.hero .date-tile-weekday { padding-bottom: var(--space-8); }
  .card.hero .countdown-number { font-size: clamp(28px, 9.4vw, 42px); line-height: 1.05; }

  /* The reminder banner is one line: how many are waiting, and the button. "Not yet" becomes a close
     button of the same 44px (its words are still its name for a screen reader), and "Remind them" is
     "Remind". The longer sentence, with the reply-by date, stays for a screen reader. */
  .remind-banner { flex-wrap: nowrap; gap: var(--space-4) var(--space-8); padding: var(--space-8) var(--space-8) var(--space-8) var(--space-16); margin-bottom: 0; }
  .remind-banner-text { flex: 1 1 auto; gap: 0; }
  .remind-banner-text > .material-symbols-rounded { display: none; }
  .remind-full, .remind-them, .remind-later-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .remind-short { display: inline; font-weight: 700; line-height: 1.3; }
  .remind-banner-actions { flex: none; flex-wrap: nowrap; gap: var(--space-4); }
  .remind-banner-actions .btn { min-height: 44px; }
  .remind-later { width: 44px; min-width: 44px; padding: 0; border-color: transparent; background: transparent; color: inherit; }
  .remind-later > .material-symbols-rounded { display: inline-block; font-size: 22px; }

  /* S5. A to-do in Coming up gets a circle at its right edge in place of the arrow: 44px to hit, a 24px
     circle to see, the same edge colour as every other control. Pressing it ticks the to-do off. */
  .coming-item.has-tick > .coming-row > .material-symbols-rounded { display: none; }
  .coming-tick {
    display: block; position: relative; flex: none; width: 44px; height: 44px; padding: 0; margin-left: var(--space-4);
    border: 0; border-radius: 10px; background: transparent; cursor: pointer; /* square-ish on purpose: a 50% radius would leave the corners of the 44px box untappable */
  }
  .coming-tick::before {
    content: ""; position: absolute; inset: 10px; border: 2px solid var(--control); border-radius: 50%; background: var(--card);
  }
  .coming-tick::after {
    content: ""; position: absolute; left: 19px; top: 14px; width: 4px; height: 9px; opacity: 0;
    border: solid var(--accent-dark); border-width: 0 2px 2px 0; transform: rotate(45deg);
  }
  .coming-tick:active::before { border-color: var(--accent); background: var(--accent-soft); }
  .coming-tick:active::after, .coming-tick:focus-visible::after { opacity: 1; }
  .coming-tick:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

  /* S7. Settings opened on a 120px title and a sentence, then a heading that said what the highlighted chip
     above it already says. The page is named by the header (the gear is lit) and each section by its chip. */
  #panel-settings .stack > .section-head:first-child > h2,
  #panel-settings .stack > .section-head:first-child > .section-byline,
  .settings-section h3.chip-echo,
  .settings-section .section-head:has(> h3.chip-echo:only-child) {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .settings-layout { margin-top: 0; gap: var(--space-16); }

  /* The opening screen is the mark, a title and a line, and the grey rows are added under them a moment later.
     Centred, that moved the mark and the title up as the rows arrived (a visible jump, and a layout shift in the
     page's own report). Held to the top, they stay where they were put. */
  #boot { justify-content: flex-start; padding-top: max(var(--space-24), 22vh); }

  /* The bottom bar is drawn empty and then filled, and it grew from 19px to 75px as the four areas arrived (it is
     pinned to the bottom, so its top edge moved up the screen: the other shift the page reports on load). Its
     height is reserved from the first frame. A minimum, so larger text can still make it taller. */
  #bottom-nav { box-sizing: border-box; min-height: calc(75px + env(safe-area-inset-bottom)); }

  /* S10. Devices: the newest three, and a button for the rest (js/settings/account.js decides which). */
  .devices-card:not(.show-all) .dev-extra { display: none; }
  .dev-more { display: inline-flex; margin-top: var(--space-16); min-height: 44px; }
}

@media (max-width: 640px) {
  /* Costs: the four money tiles stay four, but smaller, so the list of costs starts on the first screen
     (owner's request, 16 Nov). */
  .cost-tiles { gap: var(--space-8); }
  .cost-tile.card { padding: var(--space-card); }
  .cost-tile-value { font-size: 22px; }
  .cost-tile .cost-tile-hint { font-size: 12px !important; }
}


/* The narrowest phones (320px: the first iPhone SE, small Androids, big text). Found by tools/phone-check.mjs,
   17 Nov 2026. */
@media (max-width: 640px) {
  /* The reminder banner: the buttons drop under "1 party waiting" when the two do not fit side by side, rather
     than sitting on top of the words. */
  .remind-banner { flex-wrap: wrap; }
  .remind-banner-text { flex: 1 1 0; min-width: 5.5em; }

  /* A guest's song request: the Accept, Decline and Edit buttons go onto their own line when the row is narrow. */
  .music-row { flex-wrap: wrap; }
  .music-row .music-main { flex: 1 1 160px; min-width: 0; }
  .music-row .music-decide { margin-left: auto; }
}

/* The Email tab: its grid's single column may shrink to the screen, and a long word (a setting's name in the
   "Sending is not set up" note) breaks rather than pushing the page wider. */
.email-tab { grid-template-columns: minmax(0, 1fr); }
.email-tab > * { min-width: 0; }
.composer-banner > span:not(.material-symbols-rounded) { min-width: 0; overflow-wrap: anywhere; }
.composer-banner > .material-symbols-rounded { flex: none; }

/* ---- One floating button per tab on a phone (owner's choice, 17 Nov 2026, from /mockups/guests-phone) ----
   Each tab's main button (Add guest, Add cost, Add table and so on, marked `.fab` in the tab's code) leaves the top
   of the page and floats bottom right, just above the menu bar, where a thumb is. It keeps its words. A button that
   opens a menu opens it upwards. The page gets room at the bottom so the last row can be scrolled clear of it. */
@media (max-width: 640px) {
  .fab {
    position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 24; margin: 0;
  }
  .btn.fab, .fab > .btn {
    min-height: 56px; padding: 0 var(--space-24) 0 var(--space-16); gap: var(--space-8); font-size: 15px; font-weight: 700;
    background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lg);
  }
  .btn.fab .material-symbols-rounded, .fab > .btn .material-symbols-rounded { color: inherit; }
  /* A phone keeps "hover" on after a tap; the floating button stays in its own colours. */
  .btn.fab:hover, .fab > .btn:hover, .fab > .btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  /* Parties on a phone: the usual gaps between page blocks left a screenful of air above the first party. */
  .tab-panel.active > .stack:has(> .guests-head) { gap: var(--space-16); }
  .fab .tab-more-pop, .add-guest-menu.fab .tab-more-pop { top: auto; bottom: calc(100% + 10px); right: 0; left: auto; }
  .tab-panel.active:has(.fab) { padding-bottom: 88px; }
  .add-guest-menu.fab .add-more { display: inline; }
  /* While people are ticked, the bar along the bottom is the thing to use; the button would sit on top of it. */
  .guests-page.has-bulk .fab { display: none; }

  /* Filters is an icon on a phone, with its count on it (owner's choice, 17 Nov). Its words stay as its name. */
  .filter-pop-wrap:not(.cols-wrap) > .filter-menu-btn { position: relative; width: 48px; min-width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
  .filter-pop-wrap:not(.cols-wrap) > .filter-menu-btn .material-symbols-rounded { font-size: 22px; }
  .filter-pop-wrap:not(.cols-wrap) .filter-menu-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .filter-pop-wrap:not(.cols-wrap) > .filter-menu-btn .filter-count { position: absolute; top: -4px; right: -4px; }

  /* Guests: the summary sentence goes on a phone; the Overview's tiles say the same (owner's choice, 17 Nov). */
  .guests-head .section-byline { display: none; }
}

/* Guests on a phone (18 Nov): People | Parties, search and Filters on one line; searching, the box takes the line
   under the switch, beside Filters. */
@media (max-width: 640px) {
  .guests-head .guests-head-tools { flex: none; flex-wrap: nowrap; gap: var(--space-8); }
  .guests-head:has(.tab-search.open) .guests-head-tools { flex: 1 1 100%; }
  .guests-head .tab-search.open { flex: 1 1 auto; }
  .guests-head .filter-group { min-width: 176px; }
}

/* ===================================================================== the phone tidy (22 Nov 2026) ====
 * Owner's feedback: things did not line up and some screens looked messy on a phone. One set of rules, so
 * every tab follows the same order: what it is, a short summary, then its actions, then the list. */
.sched-break { display: none; }
.section-head .helper-count { background: var(--card); padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); font-size: 13px; font-weight: 700; }

@media (max-width: 640px) {
  /* -- The top of a tab: the summary on its own line, then the actions in an even two-column grid (Edit tables |
        Print, then Seating helper; Printables | Edit menu; Print). Plain text buttons become outlined like the
        rest, so no action looks like a stray link (the Print menu is a wrapper, so its button is named too). The floating Add button
        is not part of the grid. The order of the buttons is set in js/ui/head-actions.js. */
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child { flex-wrap: wrap; align-items: center; }
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > .section-byline { flex-basis: 100%; order: -1; margin: 0 0 var(--space-4); }
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > .spacer { display: none; }
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > .btn {
    flex: 0 1 calc(50% - var(--space-8)); justify-content: center; min-height: 44px; padding: 0 var(--space-16);
  }
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > .btn.ghost,
  #app:has(#subnav:not([hidden])) .tab-panel.active > div > .section-head:first-child > .print-menu > .btn.ghost { border: 1px solid var(--control); }

  /* -- A card's heading: its title, then its summary underneath (Menu's "17 of 19 chosen" no longer squeezes
        the course name). */
  .card > .section-head { flex-wrap: wrap; row-gap: var(--space-4); }
  .card > .section-head > .section-byline { flex-basis: 100%; order: 5; margin: 0; }

  /* -- List rows: the name, then the pills (status, reply, parts of the day) on one line, then the labelled
        values (amounts, dates, side) on the next. Clean dividers, no rounded smudge at the bottom of a row. */
  table.data tbody tr:not(.group-row) {
    display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-16); row-gap: var(--space-8); border-radius: 0;
  }
  table.data tbody tr:not(.group-row)::after { content: ""; order: 2; flex: 0 0 100%; height: 0; }
  table.data tbody tr:not(.group-row) > td.cell-primary { flex: 0 0 100%; order: 0; margin-bottom: 0; }
  table.data tbody tr:not(.group-row) > td:not([data-key="__select"]):not(.cell-primary):not(.actions) { order: 3; margin: 0; }
  table.data tbody tr:not(.group-row) > td:has(.badge, .chip, .tag, .g-tag, .ev-tag):not([data-key="__select"]):not(.cell-primary):not(.actions) { order: 1; }

  /* -- Ceremony: the move and edit buttons sit at the foot of each item, so the title and the people in it
        have the full width. */
  .cer-row { flex-wrap: wrap; }
  /* The arrows and pencil take a line of their own (three 44px targets leave too little width beside the words); pulled up and
     down into the card padding so that line does not add its full height again. */
  .cer-row > .row-actions { flex: 1 1 100% !important; justify-content: flex-end; margin: calc(var(--space-8) * -1) calc(var(--space-8) * -1) calc(var(--space-16) * -1) 0; }

  /* -- Coming up: the date on the left, the title and its "in 20 weeks" under it, the arrow centred on the right. */
  .coming-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; column-gap: var(--space-16); row-gap: var(--space-8); align-items: center; }
  .coming-row > .dchip { grid-row: 1 / span 2; align-self: start; }
  .coming-row > .coming-text { grid-column: 2; }
  .coming-row .badge { grid-column: 2; order: 0; margin-left: 0; justify-self: start; }
  .coming-row > .material-symbols-rounded { grid-column: 3; grid-row: 1 / span 2; margin-left: 0; }

  /* -- Schedule: a part of the day's name, then its when, how many coming and how many items on one line. */
  .sched-break { display: block; flex-basis: 100%; height: 0; }
  .sched-gap { display: none; }

  /* -- The helper panels (Need a room, Not seated) title like the cards beside them, not a size larger. */
  .room-helper > .section-head h3, .tableplan-unseated > .section-head h3 { font: 700 17px/1.3 var(--font-family); }

  /* -- Settings: on a phone the title row holds only the sync line, with less air before the section chips. */
  #panel-settings .stack > .section-head:first-child { margin-bottom: calc(var(--space-8) * -1); }
  #panel-settings .stack > .section-head:first-child > .spacer { display: none; }
}

/* Guests at 320px: the People | Parties switch gives a little, so search and filters stay on its row. */
@media (max-width: 359px) {
  .guests-head .filter-group { min-width: 150px; }
}

/* Compact header (mobile pass S6, js/ui/compact-header.js): scrolling down tucks the row of tabs away; scrolling up
   brings it back. No scroll anchoring here, so the page never nudges itself back and forth as the header changes. */
@media (max-width: 640px) {
  html { overflow-anchor: none; }
  #topbar.compact .subnav { display: none; }
}
