/* Phone layout (screens 768px wide or narrower).
   Loaded after each page's own styles with media="(max-width: 768px)", so laptops and desktops never use this file.
   Rule (HANDOFF.md): phone fixes go here; do not change desktop rules in style.css or page <style> blocks for a phone problem.
   Page-specific rules are scoped by a class on <body> (e.g. .page-attendees) so they cannot affect other pages. */

/* ---------- App shell: ☰ top bar, sidebar as drawer, bottom bar
   (design: docs/superpowers/specs/2026-10-12-mobile-ui-redesign-design.md, section 4) ---------- */
@media (max-width: 768px) {
    :root { --bnav-h: 72px; }

    /* Full width: no icon rail. Bottom padding keeps content clear of the bottom bar. */
    .main-content { margin-left: 0; padding: 16px 16px calc(var(--bnav-h) + 24px + env(safe-area-inset-bottom)); }
    .page-header { margin: -16px -16px 16px; padding: 0 10px 0 16px; height: 56px; z-index: 900; }
    .page-heading { display: flex; align-items: center; gap: 4px; min-width: 0; }
    .topbar-right { flex-shrink: 0; }   /* search + account keep their size; a long page title is what gets cut (it pushed the account button off-screen) */
    .page-title { font-size: 18px; }
    .topbar-back { width: 40px; height: 40px; margin-left: -8px; }
    .drawer-close:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

    /* "More" sheet: the sidebar rises from the bottom as a grid of tiles when More (bottom bar) is tapped
       (body.nav-open, set by mobile.js). Pages already in the bottom bar are left out (.in-bar). */
    /* It sits on top of the bottom bar, which stays above the dimmed page so More can close it again */
    .sidebar { top: auto; left: 0; right: 0; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); width: 100%; height: auto;
               max-height: calc(88vh - var(--bnav-h)); max-height: calc(88dvh - var(--bnav-h) - env(safe-area-inset-bottom));
               padding: 8px 16px 36px; border-radius: 24px 24px 0 0;   /* 36px: clear of the raised Check-in circle */
               z-index: 1001; overflow-y: auto; border-right: 0; overscroll-behavior: contain;
               transform: translateY(100%); visibility: hidden; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s; }
    body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -12px 40px rgba(46, 15, 38, .45); }
    .sidebar::before { content: ''; flex-shrink: 0; width: 40px; height: 4px; margin: 0 auto 4px; border-radius: 2px; background: rgba(255, 255, 255, .28); }   /* grab handle */
    body.nav-open { overflow: hidden; }
    body.nav-open .bnav { z-index: 1002; box-shadow: none; }
    .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(46, 15, 38, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
    body.nav-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
    .sidebar-logo { height: 52px; margin-bottom: 6px; flex-shrink: 0; }
    .sidebar-logo-img { max-height: 36px; }
    .drawer-close { display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .85); cursor: pointer; }
    .drawer-close .icon-svg { font-size: 20px; }
    .sidebar-menu { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .sidebar-section { grid-column: 1 / -1; padding: 10px 2px 0; }
    .sidebar-menu > .sidebar-section:first-child { padding-top: 0; }
    .sidebar-link { flex-direction: column; justify-content: center; gap: 8px; min-height: 86px; padding: 12px 6px; border-radius: 16px;
                    background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06); text-align: center; font-size: 12.5px; line-height: 1.25; }
    .sidebar-link .icon-svg { font-size: 24px; width: 24px; height: 24px; color: var(--pink-bright); }
    .sidebar-link:active { transform: scale(.97); }
    .sidebar-link.active { background: rgba(232, 87, 159, .18); border-color: rgba(232, 87, 159, .4); }
    .sidebar-link.active::before { display: none; }
    .sidebar-link.m-only { display: flex; }
    .sidebar-section.m-only { display: block; }
    .sidebar-link.in-bar, .sidebar-section.in-bar { display: none; }
    .sidebar-cta { flex-shrink: 0; margin-top: 14px; min-height: 56px; }
    .drawer-signout { display: flex; flex-direction: row; justify-content: center; flex-shrink: 0; min-height: 48px; margin-top: 10px; padding: 0;
                      border: 0; border-top: 1px solid rgba(255, 255, 255, .12); border-radius: 0; background: none; color: var(--white); font-size: 15px; }

    /* Bottom bar: 4 pages + More */
    .bnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
            height: calc(var(--bnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
            background: var(--color-surface); border-top: 1px solid var(--color-border); box-shadow: 0 -4px 16px rgba(46, 15, 38, .06); }
    .bnav a, .bnav-more { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px;
              font-size: 12px; font-weight: 600; color: var(--color-text-muted); text-decoration: none; }
    .bnav a .icon-svg, .bnav-more .icon-svg { font-size: 24px; }
    .bnav-more { border: 0; background: none; padding: 0; font-family: inherit; cursor: pointer; }
    .bnav-more:focus-visible { outline: 2px solid var(--magenta); outline-offset: -4px; border-radius: 12px; }
    body.nav-open .bnav-more { color: var(--wine-mid); }
    .bnav a[aria-current="page"] { color: var(--wine-mid); }
    .bnav a[aria-current="page"]::after { content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--magenta); }
    .bnav-circle { display: grid; place-items: center; width: 62px; height: 62px; margin-top: -26px; border-radius: 50%;
                   background: var(--magenta); color: var(--white); border: 4px solid var(--color-surface); box-shadow: 0 6px 16px rgba(194, 59, 142, .35); }
    .bnav a.bnav-main[aria-current="page"] .bnav-circle { background: var(--wine-mid); }

    /* Scan page: the camera gets the whole screen */
    .page-scan .bnav { display: none; }
    .page-scan .main-content { padding-bottom: 16px; }
}
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .sidebar, body.nav-open .sidebar, .drawer-backdrop { transition: none; }
}

/* ---------- Site-wide (moved from style.css) ---------- */
@media (max-width: 768px) {
    .user-text { display: none; }
    .user-info { padding: 3px 8px 3px 3px; min-width: 0; height: 42px; }
    .user-avatar { width: 34px; height: 34px; }
    .auth-card { padding: 30px 20px; }
    .event-tabs { overflow-x: auto; }
}

@media (max-width: 768px) {
    .toolbar form { width: 100%; }
    .toolbar select, .toolbar input[type=text], .toolbar input[type=email], .toolbar input[type=password] { flex: 1 1 140px; }
    .toolbar .spacer { display: none; }
    .panel { padding: 16px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 26px; }
    .modal-actions { flex-direction: column; }
    .modal { padding: 20px; }
    .steps { flex-direction: column; }
    .page-intro { align-items: flex-start; }
    .hero { padding: 18px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn, .form-actions .btn-sm { width: 100%; }
}

@media (max-width: 768px) { .topbar-search, .topbar-add { display: none; } }   /* Attendees and Events have their own search / Add buttons */
/* Phones: a round search button opens the all-events search page */
@media (max-width: 768px) {
    .topbar-search-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--color-text-strong); }
    .topbar-search-btn .icon-svg { font-size: 22px; }
    .topbar-search-btn:active { background: var(--color-primary-soft); }
}

@media (max-width: 768px) { .dialog .modal-actions { flex-direction: column-reverse; } .dialog .modal-actions .btn { width: 100%; } }


@media (max-width: 768px) { .flash-stack { top: auto; bottom: calc(var(--bnav-h) + 12px + env(safe-area-inset-bottom)); left: 16px; right: 16px; width: auto; transform: none; } }

/* ---------- pages/attendees/index.php (body.page-attendees) ---------- */
@media (max-width: 768px) {
    .page-attendees .es-select, .page-attendees .es-select select { width: 100%; max-width: none; }
    .page-attendees .es-progress { margin-left: 0; width: 100%; }
    .page-attendees .es-progress .progress { flex: 1; }
}

@media (max-width: 768px) { .page-attendees .filter-bar select { flex: 1 1 140px; max-width: none; } .page-attendees .fb-search { flex: 1 1 100%; } .page-attendees .tc-showing { margin-left: 0; }
}

/* ---------- pages/checkin/scan.php (body.page-scan) ---------- */
@media (max-width: 560px) { .page-scan .manual-row { flex-direction: column; }
}

/* ---------- pages/events/view.php (body.page-event-view) ---------- */
@media (max-width: 600px) {
    .page-event-view .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .page-event-view .stats-grid { grid-template-columns: 1fr; }
    .page-event-view .event-hero { padding: 20px; }
    .page-event-view .event-hero-meta { flex-direction: column; gap: 8px; }
}

/* ---------- pages/reports/index.php (body.page-reports) ---------- */
@media (max-width: 768px) { .page-reports .kpi-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Export and Print as an even pair across the width (they hugged the right edge at different widths) */
    .page-reports .toolbar .spacer { display: none; }
    .page-reports .toolbar > .btn-sm { flex: 1 1 0; min-width: 0; min-height: 44px; justify-content: center; }
}

/* ---------- pages/events/view.php: long venue/date lines wrap; card padding fits a phone ---------- */
@media (max-width: 768px) {
    .page-event-view .event-hero-meta span { white-space: normal; }
    .page-event-view .info-card { padding: 16px; }
}

/* ---------- pages/events/index.php (body.page-events): cards need 320px, a phone has ~262px ---------- */
@media (max-width: 768px) {
    .page-events .events-grid { grid-template-columns: 1fr; }
    /* New event button (the top bar's Add Event is hidden on phones) */
    .page-events .events-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-events .events-add { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; }
}

/* ---------- pages/attendees/view_qr.php (body.page-qr-view): the 280px QR in 40px padding was wider than the screen ---------- */
@media (max-width: 768px) {
    .page-qr-view .qr-container { padding: 24px 16px; }
    .page-qr-view .qr-image { width: 100%; max-width: 240px; height: auto; aspect-ratio: 1; }
}

/* ---------- pages/dashboard/index.php (body.page-dashboard) ---------- */
/* The page's own 1100px rule uses "1fr", which cannot shrink below its widest content: on a 390px phone
   the column stayed 422px wide and the whole page (and the bottom bar) got wider than the screen. */
@media (max-width: 768px) {
    .page-dashboard .dash { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Card lists (design section 5): wide .tbl tables become "Label: value" cards ---------- */
@media (max-width: 768px) {
    .m-cards, .m-cards tbody, .m-cards tr, .m-cards td { display: block; width: 100%; }
    .m-cards thead, .m-cards tr:has(> th) { display: none; }
    .m-cards tr { padding: 12px 14px; margin-bottom: 10px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
    .m-cards tr:hover td { background: none; }
    .m-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
    .m-cards td[data-label]::before { content: attr(data-label); flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--color-text-muted); text-align: left; }
    .m-cards td:first-child { display: block; padding-bottom: 6px; font-size: 15px; font-weight: 700; color: var(--color-text-strong); text-align: left; }
    .m-cards td:first-child::before { content: none; }
    .m-cards td[colspan] { display: block; text-align: center; }
    .m-cards td.m-actions-cell { display: flex; flex-wrap: wrap; justify-content: stretch; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--color-border-faint); }
    .m-cards td.m-actions-cell form { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; }
    .m-cards td.m-actions-cell :is(button, .btn-sm, input, select) { min-height: 44px; }
    .m-cards td.m-actions-cell :is(input, select) { flex: 1 1 140px; font-size: 16px; }
    .m-cards td.m-actions-cell:not(:has(*)) { display: none; }   /* nothing to do on this row */
    .table-wrap:has(> .m-cards) { overflow: visible; }
}

/* ---------- Attendees as cards with a "⋯" action sheet (body.page-attendees) ---------- */
@media (max-width: 768px) {
    .page-attendees .table-scroll { overflow: visible; }
    .page-attendees #attendees-table, .page-attendees #attendees-table tbody { display: block; width: 100%; }
    .page-attendees #attendees-table thead { display: none; }
    .page-attendees #attendees-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "person more" "company more" "status time";
        column-gap: 10px; row-gap: 4px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
    .page-attendees #attendees-table td { display: block; padding: 0; border: 0; max-width: none; position: static; box-shadow: none; }
    .page-attendees #attendees-table td:nth-child(1), .page-attendees #attendees-table td:nth-child(4), .page-attendees #attendees-table td:nth-child(7) { display: none; }
    .page-attendees #attendees-table td.cell-person { grid-area: person; }
    .page-attendees #attendees-table .cell-person .cell-main { max-width: none; font-size: 16px; font-weight: 600; white-space: normal; }
    .page-attendees #attendees-table .cell-person .cell-sub { display: none; }
    .page-attendees #attendees-table td.cell-company { grid-area: company; font-size: 13px; color: var(--color-text-muted); }
    .page-attendees #attendees-table .cell-company :is(.cell-main, .cell-sub) { display: inline; font-size: 13px; font-weight: 400; color: var(--color-text-muted); }
    .page-attendees #attendees-table .cell-company .cell-sub::before { content: " · "; }
    .page-attendees #attendees-table td:nth-child(5) { grid-area: status; }
    .page-attendees #attendees-table td:nth-child(6) { grid-area: time; text-align: right; font-size: 12px; }
    .page-attendees #attendees-table td.row-more-cell { display: block; grid-area: more; align-self: center; justify-self: end; }   /* same spot on every card */
    /* Checked in + Walk-in side by side on a card (the desktop table stacks them) */
    .page-attendees #attendees-table td[id^="status-"] .status-pill { display: inline-block; }
    .page-attendees #attendees-table td[id^="status-"] .status-pill + .status-pill { margin: 0 0 0 4px; }
    .page-attendees .tc-filters .fb-select { flex: 1 1 100%; }   /* full width like the search above it */
    .page-attendees #attendees-table td[colspan] { display: block; grid-column: 1 / -1; }
    .page-attendees #attendees-table tbody tr:has(td[colspan]) { display: block; }
    .row-more { width: 44px; height: 44px; border: 1px solid var(--color-border); border-radius: 50%; background: var(--color-surface); color: var(--color-text-strong); font-size: 20px; line-height: 1; cursor: pointer; }
    .row-more:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }
}

/* ---------- "⋯" action sheet (built by mobile.js) ---------- */
@media (max-width: 768px) {
    .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 1100; background: rgba(46, 15, 38, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
    .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1101; max-height: 85vh; overflow-y: auto; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
             background: var(--color-surface); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(46, 15, 38, .25); transform: translateY(100%); visibility: hidden;
             transition: transform .22s ease, visibility 0s linear .22s; }
    body.sheet-open .sheet { transform: none; visibility: visible; transition: transform .22s ease; }
    body.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
    body.sheet-open { overflow: hidden; }
    .sheet::before { content: ''; display: block; width: 40px; height: 4px; margin: 0 auto 10px; border-radius: 4px; background: var(--color-border); }
    .sheet-head { padding: 4px 4px 12px; border-bottom: 1px solid var(--color-border-faint); margin-bottom: 6px; }
    .sheet-head b { display: block; font-size: 16px; color: var(--color-text-strong); }
    .sheet-head small { font-size: 13px; color: var(--color-text-muted); }
    .sheet-actions { display: flex; flex-direction: column; }
    .sheet-form { display: contents; }
    .sheet-action { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 8px; border: 0; border-radius: 10px; background: none;
                    font: inherit; font-size: 15px; font-weight: 600; color: var(--color-text-strong); text-align: left; text-decoration: none; cursor: pointer; }
    .sheet-action:active, .sheet-action:hover { background: var(--color-surface-alt); }
    .sheet-action svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--wine-mid); }
    .sheet-action.is-danger, .sheet-action.is-danger svg { color: var(--danger-text); }
    .sheet-action.is-disabled { opacity: .5; cursor: default; }
    .sheet-cancel { width: 100%; min-height: 48px; margin-top: 8px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); font: inherit; font-weight: 600; color: var(--color-text-strong); cursor: pointer; }
}
@media (max-width: 768px) and (prefers-reduced-motion: reduce) { .sheet, body.sheet-open .sheet, .sheet-backdrop { transition: none; } }

/* ---------- Form fields: 16px text on phones, or iPhones zoom in when a field is tapped ---------- */
@media (max-width: 768px) {
    /* .dashboard-body prefix: stronger than page rules like .filter-bar select, so every field gets it */
    .dashboard-body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea) { font-size: 16px; }
}

/* ---------- Event-day screens (design section 6) ---------- */
@media (max-width: 768px) {
    /* Shell tap targets: back arrow and account button reach 44px; form fields 44px tall */
    .topbar-back { width: 44px; height: 44px; }
    .topbar-back .icon-svg { font-size: 22px; }
    .user-info { height: 44px; }
    .dashboard-body .form-input, .dashboard-body .input { min-height: 44px; }

    /* Check-in hub: live numbers first, then one big Scan button and two compact rows, recent check-ins before companies */
    .page-checkin .main-content { display: flex; flex-direction: column; }
    .page-checkin .checkin-actions { order: 2; grid-template-columns: 1fr; gap: 10px; margin: 6px 0 20px; }
    .page-checkin .panel-grid { order: 3; display: flex; flex-direction: column; }
    .page-checkin .panel-grid > .panel:last-child { order: -1; }
    .page-checkin .stats-grid { gap: 8px; margin-bottom: 4px; }
    .page-checkin .stat-card { padding: 12px 14px; }
    .page-checkin .stat-value { font-size: 22px; }
    .page-checkin .action-card { display: grid; grid-template-columns: 44px 1fr; column-gap: 14px; align-items: center; min-height: 64px; padding: 12px 16px; text-align: left; }
    .page-checkin .action-card .icon-circle { grid-row: span 2; width: 44px; height: 44px; margin: 0; }
    .page-checkin .action-card:first-child { min-height: 76px; background: var(--wine-mid); border-color: var(--wine-mid); }
    .page-checkin .action-card:first-child :is(.action-label, .action-desc) { color: var(--white); }
    .page-checkin .action-card:first-child .icon-circle { background: rgba(255, 255, 255, .16); color: var(--white); }
    .page-checkin .action-card:first-child .action-label { font-size: 17px; }

    /* Scanner: camera edge to edge; the result slides up from the bottom; manual entry stacked */
    .page-scan .scan-wrap { max-width: none; margin: -16px -16px 0; }
    .page-scan .scanner-card { padding: 0; margin: 0; border-radius: 0; border: 0; box-shadow: none; }
    .page-scan .scan-stage { min-height: calc(100dvh - 56px - 170px); }
    .page-scan #qr-reader__scan_region { min-height: calc(100dvh - 56px - 170px); }
    .page-scan .result-area { position: fixed; left: 0; right: 0; bottom: 0; z-index: 960; }
    .page-scan .result-card { border-left: 0; border-top: 5px solid; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
    .page-scan .result-ok   { border-top-color: var(--success); }
    .page-scan .result-warn { border-top-color: var(--warning); }
    .page-scan .result-bad  { border-top-color: var(--danger); }
    .page-scan .action-buttons .btn-sm { min-height: 48px; }
    .page-scan .undo-link { min-height: 44px; }
    .page-scan .manual { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
    .page-scan .manual-row { flex-direction: column; }
    .page-scan .manual-row .btn-sm { min-height: 48px; justify-content: center; }

    /* Pinned buttons stick to the screen, not inside the panel: the phone .panel scrolls by itself (overflow: auto) */
    .page-walkin .panel, .page-badge .panel { overflow: visible; }

    /* Walk-in: big tappable copy choices; Register pinned above the bottom bar (← in the top bar replaces Cancel) */
    .page-walkin .send-copy .check { flex: 1 1 140px; min-height: 48px; padding: 0 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text-strong); }
    .page-walkin .send-copy .check:has(input:checked) { border-color: var(--magenta); background: var(--color-primary-soft); }
    .page-walkin .dupe-box .btn-sm { min-height: 44px; }
    .page-walkin .form-actions { position: sticky; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); z-index: 5; margin: 8px -16px -16px; padding: 12px 16px;
                                 background: var(--color-surface); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    /* Cancel (left, small) and Register (right, big) side by side in the pinned bar */
    .page-walkin .form-actions { flex-direction: row; gap: 10px; }
    .page-walkin .form-actions .btn-secondary { flex: 0 0 auto; width: auto; min-height: 50px; padding: 0 18px; }
    .page-walkin .form-actions .btn-primary { flex: 1; width: auto; }
    .page-walkin .btn-long { display: none; }   /* "Register" fits beside Cancel; the form intro says the badge opens next */
    .page-walkin .form-actions .btn-primary { min-height: 50px; }

    /* Badge preview: heading text hidden (the top bar says it); Print / Next pinned at the bottom */
    .page-badge .page-intro h2, .page-badge .page-intro p { display: none; }
    .page-badge .page-intro { justify-content: flex-end; margin-bottom: 8px; }
    .page-badge .badge-stage { overflow: hidden; }
    .page-badge .badge-actions { position: sticky; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); z-index: 5; margin: 12px -16px -16px; padding: 12px 16px;
                                 background: var(--color-surface); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    .page-badge .badge-actions > * { min-height: 50px; }
    .page-badge .badge-fix-toggle .btn-sm { min-height: 44px; }
}
/* Screen only, so a printed badge keeps its real size */
@media screen and (max-width: 768px) {
    .page-badge .badge-stage > #defaultBadge, .page-badge .badge-stage > #customBadge { zoom: var(--fit, 1); }
}

/* ---------- Other pages and pop-ups (design section 7) ---------- */
@media (max-width: 768px) {
    /* Small buttons, dropdowns and text links reach a 44px tap area */
    .dashboard-body .btn-sm, .dashboard-body select { min-height: 44px; }
    .dashboard-body .btn-sm { justify-content: center; }
    .cap-link { display: inline-flex; align-items: center; min-height: 44px; }
    .bt-fav { width: 44px; height: 44px; }

    /* Events list: the status filter is one row you can swipe */
    .page-events .events-tabs { display: flex; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .page-events .events-tab { flex: none; display: inline-flex; align-items: center; min-height: 44px; }

    /* Event page: quick actions as compact rows, two per line */
    .page-event-view .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .page-event-view .action-btn { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 12px; text-align: left; }
    .page-event-view .action-btn .action-icon { margin: 0; flex-shrink: 0; }
    .page-event-view .status-btn { min-height: 44px; }

    /* Create Event: badge designs two per row; Create pinned above the bottom bar (← replaces Cancel) */
    .page-create-event .panel { overflow: visible; }
    .bp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .bp-card { padding: 8px; }
    .bp-thumb { overflow: hidden; }
    .bp-thumb > * { zoom: .85; }
    .page-create-event .form-actions { position: sticky; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); z-index: 5; margin: 8px -16px -16px; padding: 12px 16px;
                                       background: var(--color-surface); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
    .page-create-event .form-actions .btn-secondary { display: none; }
    .page-create-event .form-actions .btn-primary { min-height: 50px; }

    /* Pop-up windows open as bottom sheets; their buttons stay visible while the sheet scrolls */
    .modal-overlay, .edit-overlay { align-items: flex-end; padding: 0; }
    .modal, .edit-modal { max-width: none; width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; }
    .modal .modal-actions, .edit-modal .modal-actions { position: sticky; bottom: 0; z-index: 2; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
                                                        background: var(--color-surface); border-top: 1px solid var(--color-border-faint); }
    .modal-actions .btn { min-height: 48px; }
    .edit-modal .modal-actions { padding-left: 20px; padding-right: 20px; }   /* this window's actions sit outside its padded body */

    /* Badge Designer: a note instead of the drag-and-drop editor */
    .page-badge-editor .bd-toolbar, .page-badge-editor .bd-wrap, .page-badge-editor .flash-stack { display: none; }
    .page-badge-editor .bd-phone-note { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 20px; text-align: center;
                                        background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
    .page-badge-editor .bd-phone-note .icon-svg { font-size: 24px; color: var(--magenta); }   /* icon() caps icons at 24px */
    .page-badge-editor .bd-phone-note strong { font-size: 17px; color: var(--color-text-strong); }
    .page-badge-editor .bd-phone-note p { font-size: 14px; color: var(--color-text-muted); max-width: 32ch; }
    .page-badge-editor .bd-phone-note .btn { min-height: 48px; margin-top: 6px; }
}

/* ---------- Attendees: header actions and filters on phones (body.page-attendees) ---------- */
@media (max-width: 768px) {
    /* Same 16px side padding as the attendee cards below, so every left edge lines up */
    .page-attendees .table-actions { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
    .page-attendees .tc-filters { padding: 12px 16px; }
    /* Buttons in an even 2-column grid; Send Invite (the main action) gets its own full-width row */
    .page-attendees .table-actions .btn-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
    .page-attendees .table-actions .btn-group > .btn-sm, .page-attendees .invite-wrap > .btn-sm { width: 100%; min-height: 44px; padding: 0 12px; justify-content: center; white-space: nowrap; }
    .page-attendees .invite-wrap { grid-column: 1 / -1; display: block; }
    /* An odd button left before Send Invite (admins: Scan, End, Export) fills its row instead of leaving a gap */
    .page-attendees .table-actions .btn-group > :nth-last-child(2):nth-child(odd) { grid-column: 1 / -1; }
    .page-attendees .invite-menu { left: 0; right: 0; min-width: 0; }
    .page-attendees .invite-menu a { min-height: 48px; }
    /* Smaller placeholder so the full hint fits; typed text stays 16px (no iPhone zoom) */
    .page-attendees #searchInput::placeholder { font-size: 14px; }
}

.main-content .tm-intro { font-size: 13px; margin-bottom: 12px; }
.main-content .tm-create { margin-bottom: 14px; flex-wrap: nowrap; }
.main-content .tm-create .form-input { flex: 1 1 0; width: auto; min-width: 0; height: 44px; font-size: 16px; }
.main-content .tm-create .btn-sm { height: 44px; flex-shrink: 0; padding: 0 14px; }
.main-content .tm-grid { gap: 10px; }
.main-content .tm-card { padding: 14px; }
.main-content .tm-actions .btn-sm { height: 36px; padding: 0 12px; }
.main-content .tm-rename .form-input { flex: 0 0 100%; height: 44px; font-size: 16px; }
.main-content .tm-rename .btn-sm { flex: 1 1 0; height: 40px; justify-content: center; }
.main-content .tm-member { padding: 10px 0; }
.main-content .tm-member .btn-sm { height: 36px; padding: 0 12px; }
.main-content .tm-add select { height: 44px; font-size: 16px; }
.main-content .tm-add .btn-sm { height: 44px; padding: 0 18px; }
.main-content .team-picks { grid-template-columns: 1fr; gap: 8px; }
.main-content .team-pick { padding: 12px; }
.main-content .team-add { gap: 8px; }
.main-content .team-add-row { display: flex; width: 100%; }
.main-content .team-add-row .form-input { flex: 1 1 100%; width: auto; min-width: 0; height: 44px; font-size: 16px; }
.main-content .team-add-row .btn-sm { flex: 1 1 0; height: 40px; justify-content: center; }
.main-content .team-manage { margin-left: 0; }
.limit-note { font-size: 12px; }

.main-content .pager { justify-content: center; padding: 12px 4px; text-align: center; }
.main-content .pager-info { flex-basis: 100%; }
.main-content .pager-btn { min-width: 38px; height: 38px; }
.main-content .list-tools { gap: 8px; }
.main-content .list-tools select { flex: 1 1 auto; min-width: 0; }
.main-content .log-search { flex: 1 1 100%; min-width: 0; }
