/* Phone layout fixes (loaded last).
   Found by crawling every page and dialog at 360–440px wide. Most issues came from a few shared patterns:
   - `.grow` is `flex: 1` (basis 0), so in a row with buttons the text column shrinks to a sliver instead of wrapping;
   - grid columns of `1fr` grow to the widest unbreakable child (a long select or URL) and push the card off-screen;
   - stat labels were cut off with an ellipsis; pill tabs and segmented buttons wrapped inside their labels. */

/* "Copied" feedback on copy buttons (all screen sizes): green check, same size as the button. */
.is-copied { color: var(--green) !important; border-color: color-mix(in srgb, var(--green) 45%, var(--line)) !important; }
.is-copied .i { color: var(--green) !important; }

/* Sign-out is a small POST form; it should look and sit exactly like the old link. */
.logout-form { display: contents; }
.tb-sheet .tb-signout { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 12px; border-radius: 12px; color: var(--ink-2); font-family: var(--font-ui); font-size: 15px; cursor: pointer; }
.tb-sheet .tb-signout .i { color: var(--muted); flex: none; }
.tb-sheet .tb-signout:hover, .tb-sheet .tb-signout:focus-visible { background: var(--surface-2); }

/* Carol timeline: the "🚗 10 min" drive label ran under the numbered circle (all screen sizes). */
.stop-time .drive { margin-right: 16px; }

/* Active pill tab: count and icon were white on the light-pink "on" background (all screen sizes). */
.pill-tab.on span, .pill-tab.on .i { color: var(--accent); }
.pill-tab.on .badge-count { color: #fff; }

@media (max-width: 760px) {
  /* ---- never let a form control or long word push a card wider than the screen ---- */
  select, .cb, input, textarea { max-width: 100%; }
  .meta-row > span, .meta-row > a, dd, dd a, .hint, .tl-txt { min-width: 0; overflow-wrap: anywhere; }

  /* ---- stat tiles: icon + number on top, full label underneath (no more "Awaiting re…") ---- */
  .stat { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; row-gap: 4px; padding: 12px 14px; }
  .stat > div { display: contents; }
  .stat .ic-badge { width: 36px; height: 36px; border-radius: 10px; grid-row: 1; }
  .stat .n { grid-row: 1; font-size: 24px; line-height: 1.1; }
  .stat .l { grid-column: 1 / -1; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; font-size: 12.5px; }

  /* ---- pill tabs (Care, Requests, Messages, Registrations…): wrap the row, never the label ---- */
  .pills, .log-bar .pills { flex-wrap: wrap; overflow: visible; padding-bottom: 0; }
  .pill-tab { white-space: nowrap; flex: none; padding: 8px 13px; font-size: 14px; }

  /* ---- segmented choices (Weekly/Monthly/Once, I'm new/I come regularly, email kinds…): wrap into rows ---- */
  .seg { display: flex; flex-wrap: wrap; overflow: visible; max-width: 100%; }
  .seg > label, .seg > a { flex: 1 1 auto; min-width: 0; }
  .seg > label > span, .seg > a > span, .seg > span { justify-content: center; white-space: nowrap; width: 100%; box-sizing: border-box; }
  .seg-sm .seg-btn { padding: 7px 12px; font-size: 13px; }

  /* ---- rows with a text column + action buttons: text keeps the first line, buttons drop below ---- */
  .list-row:has(> .acts) > .grow, .list-row:has(> form > .btn) > .grow, .list-row > .song-open { flex: 1 1 calc(100% - 64px) !important; min-width: 0; }
  .list-row > .acts { flex: 1 1 100%; justify-content: flex-end; flex-wrap: wrap; margin-left: 0; }
  .list-row > form:last-child:has(> .btn) { flex: 1 1 100%; display: flex; justify-content: flex-end; }
  .cel-row > .cel-main { flex: 1 1 calc(100% - 70px); }
  .cel-row > .btn, .cel-row > .pill, .cel-row > form { margin-left: auto; }
  .tip { flex-wrap: wrap; }
  .tip > .grow { flex: 1 1 calc(100% - 60px) !important; min-width: 0; }
  .tip > form { flex: 1 1 100%; display: flex; justify-content: flex-end; }
  .wrap > .grow, .wrap > .cb.grow { flex: 1 1 200px !important; min-width: 0; }

  /* ---- registrations: share links ---- */
  .share-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .share-card { flex-wrap: wrap; align-items: flex-start; padding: 14px; }
  .share-card > .grow { flex: 1 1 calc(100% - 60px) !important; }
  .share-acts { flex: 1 1 100%; flex-direction: row; justify-content: flex-end; }

  /* ---- people list: chips under the name wrap instead of running off the card ---- */
  .person-sub { flex-wrap: wrap; white-space: normal; }

  /* ---- event roles ---- */
  .rot-item button { min-width: 26px; min-height: 26px; padding: 0 4px; font-size: 16px; }
  .slot-top { flex-wrap: wrap; }
  .slot-top > .minw-0 { flex: 1 1 calc(100% - 60px); }
  .slot-top .actions { flex: 1 1 100%; justify-content: flex-end; }

  /* ---- carol night: homes in visiting order ---- */
  .stop-card, .prog { grid-template-columns: minmax(0, 1fr); }
  .stop-card, .stop-card > *, .prog, .prog-row, .prog-row > .grow, .pick-person { min-width: 0; }
  .pick-person { max-width: 100%; flex: 1 1 100%; }
  .pick-person .cb, .add-song .cb { min-width: 0; }
  .stop-head > .grow { flex: 1 1 100% !important; }
  .prog-who > .cb, .prog-who > select, .prog-who > form, .add-song, .add-song .cb { max-width: 100%; min-width: 0; }
  .prog-total { text-align: left; }
  .stop-acts { row-gap: 8px; }

  /* ---- carol programme items: title gets its own line ---- */
  .pi-head { flex-wrap: wrap; row-gap: 4px; }
  .pi-head strong { order: -1; flex: 1 1 100% !important; white-space: normal; }
  .pi-head .prog-min { margin-left: auto; }

  /* ---- add / edit role dialogs: "Arrive at" time box was squeezed into the 64px icon column ---- */
  .role-fields { grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); }
  .role-fields > .field:nth-child(2) { grid-column: 2 / 4; }
  .role-fields > .field:nth-child(3) { grid-column: 1 / 3; }
  .role-fields > .field:nth-child(4) { grid-column: 3; }

  /* ---- carol songbook rows ---- */
  .song-open strong { display: block; }
}

/* The carol-night timeline switches to one column at 640px (app.css); keep that column from growing past the screen. */
@media (max-width: 640px) {
  .stop { grid-template-columns: minmax(0, 1fr); }
}

/* Grid columns written as plain `1fr` grow to fit the longest option or URL inside them and push the content past
   the edge (e.g. "Short message by" in the Add-home dialog). Same breakpoints as app.css/mobile.css, with minmax(0, …). */
.v-segment, .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .carol-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .acct-grid, .share-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .settings, .reg-body { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .how, .req-quick { grid-template-columns: minmax(0, 1fr); } .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .set-row { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .msg-box, .time-fixed, .team-checks, .start-pick { grid-template-columns: minmax(0, 1fr); } .msg-box > .field { min-width: 0; } }
@media (max-width: 560px) { .kind-pick { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .vr-row3, .vr-row2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .vr-actions, .theme-grid, .design-grid { grid-template-columns: minmax(0, 1fr); } }


/* Schedule on phones: lighter cards, compact role rows (name · time on one line, small quiet buttons). */
@media (max-width: 760px) {
  .event-head .progress { justify-content: flex-start; gap: 6px; }
  .event-head .progress > span:first-child { margin-right: auto; }
  .event-head .progress .icon-btn { width: 34px; height: 34px; }
  .roles.role-panels { padding: 0; gap: 0; background: none; border-top: 0; }
  .roles.role-panels > .role-group { border: 0; border-radius: 0; border-top: 1px solid var(--line); margin: 0; }
  .role-group-h { padding: 10px 14px 6px; border-bottom: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .role-group-h small { text-transform: none; letter-spacing: 0; }
  .role-group .role { padding: 8px 14px; gap: 6px 8px; border-top: 0; min-height: 0; }
  .role-group .role + .role { border-top: 1px solid var(--line-2); }
  .role-group .role-name > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .role-group .role-name > div small { display: inline; margin: 0; }
  .role-group .role-tools .icon-btn, .role-group .role-tools .role-add { width: 30px; height: 30px; min-width: 30px; border-color: transparent; background: none; box-shadow: none; }
  .roles.role-panels > .role-new-row { padding: 10px 14px 4px; border-top: 1px solid var(--line); }
  .role .chips .chip { padding-top: 4px; padding-bottom: 4px; }
}
@media (max-width: 760px) {
  .role-group .role-name > div small { margin-left: 0 !important; color: var(--muted); font-weight: 600; }
  .role-group .role-name > div small::before { content: "· "; }
}
@media (max-width: 760px) { .role-group .role-name > div { justify-content: flex-start !important; } }
