/* ==========================================================================
   WhatsMan mobile UI (≤768px): a 1:1 port of the whatsweb-app (Expo) design.
   Every class mirrors a component in whatsweb-app/src/components/ui.tsx; values come from
   whatsweb-app/src/theme.ts (light palette, radii, spacing, type scale, shadow).

   Usage in templates:
     .m-only  → shown only ≤768px     .d-only → hidden ≤768px (desktop markup)
     Icons:   <svg class="m-icon"><use href="#i-calendar"/></svg>   (sprite in layout.html)
     JS:      mIcon('calendar', 'm-icon--sm')  → same markup as a string (layout.html)
   ========================================================================== */

:root {
    --m-bg: #F0F7F7;
    --m-surface: #FFFFFF;
    --m-surface-muted: #E3EEEB;
    --m-ink: #0F172A;
    --m-ink-muted: #64748B;
    --m-ink-subtle: #A3B1B8;
    --m-border: #E2E8F0;
    --m-primary: #00B289;
    --m-primary-deep: #009975;
    --m-primary-soft: #D7F5EC;
    --m-disabled: #B9D6CE;
    --m-danger: #E5484D;
    --m-danger-soft: #FDE8E8;
    --m-warning: #92600A;
    --m-warning-soft: #FEF3C7;
    --m-info: #2563EB;
    --m-info-soft: #E0EAFF;
    --m-backdrop: rgba(8, 20, 18, 0.55);
    --m-shadow: 0 8px 18px rgba(15, 61, 51, 0.08);
    --m-grad-primary: linear-gradient(90deg, #00C497, #009975);
    --m-grad-night: linear-gradient(160deg, #101C2C, #1A4D4A);
    --m-gutter: 20px;
    --m-tabbar-space: 96px;
}

/* Dark palette = whatsweb-app src/theme.ts `dark` (toggled by html[data-theme], see layout.html). */
html[data-theme="dark"] body:not(:has(.landing-page)) {
    --m-bg: #0B1416;
    --m-surface: #142023;
    --m-surface-muted: #1D2C2F;
    --m-ink: #E8F3F0;
    --m-ink-muted: #94A8A4;
    --m-ink-subtle: #56686A;
    --m-border: #22343A;
    --m-primary: #00B289; /* app uses #13C99A; kept at the light value so white text on green stays readable */
    --m-primary-deep: #00B289;
    --m-primary-soft: #123A31;
    --m-disabled: #2C4A43;
    --m-danger: #FF6B6F;
    --m-danger-soft: #3A1C1E;
    --m-warning: #F6C453;
    --m-warning-soft: #3A2F12;
    --m-info: #7AA2FF;
    --m-info-soft: #1C2A4A;
    --m-backdrop: rgba(0, 0, 0, 0.7);
    --m-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

/* m- components set display (flex etc.), which would otherwise beat the `hidden` attribute.
   Scoped to m- classes so desktop scripts that toggle style.display on [hidden] elements are unaffected. */
[class^="m-"][hidden],
[class*=" m-"][hidden],
.m-only [hidden] {
    display: none !important;
}

@media (min-width: 769px) {
    .m-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .d-only {
        display: none !important;
    }

    /* App shell: no web header or drawer; each screen draws its own header. The draggable help button stays
       (positioned above the tab bar / pinned footers by layout.css). */
    body {
        background: var(--m-bg);
    }

    .header,
    .sidebar,
    .sidebar-overlay,
    .low-tokens-banner,
    .two-fa-activation-banner {
        display: none !important;
    }

    /* Top: clear the phone's status bar/notch (viewport-fit=cover lets the page draw under it),
       then 20px like the app (insets.top + header 8px + content 12px). */
    .dashboard-container .content-body {
        padding: calc(20px + env(safe-area-inset-top, 0px)) var(--m-gutter) calc(40px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Full-bleed pages (landing, sign-in) keep their own spacing; just keep them out from under the status bar. */
    /* Auth/error screens (.m-auth/.m-err) already add the inset themselves. */
    .auth-container:not(:has(.m-auth, .m-err)) {
        padding-top: env(safe-area-inset-top, 0px);
    }

    /* Help button above the tab bar / pinned wizard footers (layout.css's base rule comes later, so set it here).
       A dragged position is inline (top/left) and still wins. */
    .help-fab-wrap {
        bottom: calc(max(12px, env(safe-area-inset-bottom, 0px)) + 84px);
    }

    body.m-tabroot .content-body {
        padding-bottom: calc(var(--m-tabbar-space) + 40px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ---------- Icons (24px grid, 1.8 stroke, like icons.tsx) ---------- */
.m-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.m-icon--sm { width: 18px; height: 18px; }
.m-icon--xs { width: 16px; height: 16px; }
.m-icon--lg { width: 28px; height: 28px; }

/* ---------- Type (theme.ts `type`) ---------- */
.m-display { font-size: 30px; line-height: 36px; font-weight: 800; letter-spacing: -0.6px; color: var(--m-ink); margin: 0; }
.m-title { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.3px; color: var(--m-ink); margin: 0; }
.m-heading { font-size: 17px; line-height: 23px; font-weight: 500; color: var(--m-ink); margin: 0; }
.m-body { font-size: 16px; line-height: 23px; color: var(--m-ink); margin: 0; }
.m-subtitle { font-size: 16px; line-height: 23px; color: var(--m-ink-muted); margin: 0; }
.m-label { font-size: 15px; line-height: 20px; font-weight: 500; color: var(--m-ink); margin: 0; }
.m-caption { font-size: 13px; line-height: 18px; color: var(--m-ink-muted); margin: 0; }
.m-overline { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.9px; text-transform: uppercase; color: var(--m-ink); margin: 0; }
.m-link { color: var(--m-primary); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.m-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m-clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Layout ---------- */
/* Screen: column with 16px between blocks (layout.block); children fade in like FadeInUp. */
.m-screen { display: flex; flex-direction: column; gap: 16px; }
.m-screen > * { animation: m-fade-up 0.32s ease both; }
.m-screen > :nth-child(2) { animation-delay: 60ms; }
.m-screen > :nth-child(3) { animation-delay: 120ms; }
.m-screen > :nth-child(4) { animation-delay: 180ms; }
.m-screen > :nth-child(5) { animation-delay: 240ms; }
.m-screen > :nth-child(6) { animation-delay: 300ms; }
.m-screen > :nth-child(7) { animation-delay: 360ms; }
.m-screen > :nth-child(n+8) { animation-delay: 420ms; }

@keyframes m-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .m-screen > * { animation: none; }
}

.m-stack { display: flex; flex-direction: column; gap: 12px; }
.m-stack--sm { gap: 8px; }
.m-list { display: flex; flex-direction: column; gap: 12px; }
.m-row-flex { display: flex; align-items: center; gap: 8px; }
.m-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.m-grid2 { display: flex; flex-wrap: wrap; gap: 12px; }
.m-grid2 > * { flex: 1 1 47%; min-width: 0; }
.m-divider { border-top: 1px solid var(--m-border); }
.m-center { text-align: center; align-items: center; }

/* ---------- Header (ui.tsx Header) ---------- */
.m-header { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.m-header__titles { flex: 1; min-width: 0; }
.m-header__titles .m-title,
.m-header__titles .m-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* SectionTitle */
.m-section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

/* ---------- IconButton (44px round; surface has shadow) ---------- */
.m-iconbtn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--m-surface);
    color: var(--m-ink);
    box-shadow: var(--m-shadow);
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease;
}

.m-iconbtn .m-icon { width: 20px; height: 20px; }
.m-iconbtn:active { transform: scale(0.96); }
.m-iconbtn--primary { background: var(--m-primary); color: #fff; box-shadow: none; }
.m-iconbtn--danger { background: var(--m-danger-soft); color: var(--m-danger); box-shadow: none; }
.m-iconbtn--sm { width: 36px; height: 36px; }
.m-iconbtn--sm .m-icon { width: 17px; height: 17px; }

/* ---------- Card ---------- */
.m-card {
    background: var(--m-surface);
    border-radius: 22px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--m-shadow);
    color: var(--m-ink);
    text-decoration: none;
}

a.m-card:active,
button.m-card:active { transform: scale(0.98); }

/* Balance hero (Home): night gradient */
.m-hero {
    border-radius: 22px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--m-grad-night);
    color: #fff;
    box-shadow: var(--m-shadow);
}

.m-hero .m-caption { color: #B8D4CF; }
.m-hero__value { font-size: 38px; line-height: 48px; font-weight: 800; color: #fff; margin: 0; }

/* ---------- Row (rowCard) ---------- */
.m-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--m-surface);
    border-radius: 15px;
    border: 1.5px solid transparent;
    padding: 12px 16px;
    min-height: 64px;
    color: var(--m-ink);
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.m-row:active { transform: scale(0.98); }
div.m-row { cursor: default; }
div.m-row:active { transform: none; }
.m-row.is-selected { border-color: var(--m-primary); background: var(--m-primary-soft); }
.m-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-row__title { font-size: 15px; line-height: 20px; font-weight: 500; color: var(--m-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row__sub { font-size: 13px; line-height: 18px; color: var(--m-ink-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.m-row__end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.m-chevron { color: var(--m-ink-muted); width: 20px; height: 20px; }

/* ---------- Avatar / IconTile ---------- */
.m-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--m-primary-soft);
    color: var(--m-primary-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
}

.m-avatar img { width: 100%; height: 100%; object-fit: cover; }
.m-avatar .m-icon { width: 22px; height: 22px; }
.m-avatar--lg { width: 72px; height: 72px; font-size: 26px; }
.m-avatar--lg .m-icon { width: 36px; height: 36px; }
.m-avatar--sm { width: 38px; height: 38px; font-size: 14px; }

.m-icontile {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--m-surface-muted);
    color: var(--m-primary-deep);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.m-icontile .m-icon { width: 21px; height: 21px; }
.m-icontile--lg { width: 64px; height: 64px; }
.m-icontile--lg .m-icon { width: 31px; height: 31px; }
.m-icontile--md { width: 42px; height: 42px; }
.m-icontile--sm { width: 36px; height: 36px; }
.m-icontile--sm .m-icon { width: 17px; height: 17px; }
.m-icontile--active { background: var(--m-primary); color: #fff; }
.m-icontile--danger { background: var(--m-danger-soft); color: var(--m-danger); }
.m-icontile--warning { background: var(--m-warning-soft); color: var(--m-warning); }
.m-icontile--info { background: var(--m-info-soft); color: var(--m-info); }

/* ---------- Badge ---------- */
.m-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    background: var(--m-surface-muted);
    color: var(--m-ink-muted);
    white-space: nowrap;
}

.m-badge--success { background: var(--m-primary-soft); color: var(--m-primary-deep); }
.m-badge--warning { background: var(--m-warning-soft); color: var(--m-warning); }
.m-badge--danger { background: var(--m-danger-soft); color: var(--m-danger); }
.m-badge--info { background: var(--m-info-soft); color: var(--m-info); }

/* ---------- Button ---------- */
.m-btn {
    position: relative;
    min-height: 56px;
    border-radius: 999px;
    border: 0;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: var(--m-grad-primary);
    color: #fff;
    box-shadow: var(--m-shadow);
    width: 100%;
    box-sizing: border-box;
    transition: transform 0.12s ease;
}

.m-btn .m-icon { width: 20px; height: 20px; }
.m-btn:active { transform: scale(0.98); }
.m-btn:disabled,
.m-btn[aria-disabled="true"] { background: var(--m-disabled); box-shadow: none; cursor: default; }
.m-btn--secondary { background: var(--m-surface); color: var(--m-ink); border: 1px solid var(--m-border); box-shadow: none; }
.m-btn--danger { background: var(--m-danger-soft); color: var(--m-danger); box-shadow: none; }
.m-btn--ghost { background: transparent; color: var(--m-primary); box-shadow: none; }
.m-btn--secondary:disabled,
.m-btn--danger:disabled { background: var(--m-surface); color: var(--m-ink-subtle); }
.m-btn--small { min-height: 42px; padding: 0 16px; font-size: 15px; width: auto; }
.m-btn--small .m-icon { width: 18px; height: 18px; }
.m-btn--inline { width: auto; }

/* ---------- Fields ---------- */
.m-field { display: flex; flex-direction: column; gap: 6px; }

.m-input,
.m-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.m-field select,
.m-field textarea {
    font: inherit;
    font-size: 17px;
    line-height: 23px;
    color: var(--m-ink);
    background: var(--m-surface);
    border: 1.5px solid var(--m-border);
    border-radius: 15px;
    padding: 12px 16px;
    min-height: 54px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.m-field textarea,
textarea.m-input { min-height: 130px; resize: vertical; }
.m-input:focus,
.m-field input:focus,
.m-field select:focus,
.m-field textarea:focus { outline: none; border-color: var(--m-primary); }
.m-field.is-error input,
.m-field.is-error textarea { border-color: var(--m-danger); }
.m-field__error { font-size: 13px; line-height: 18px; color: var(--m-danger); }
.m-input::placeholder,
.m-field ::placeholder { color: var(--m-ink-subtle); }

/* SearchBar */
.m-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--m-surface);
    border-radius: 999px;
    border: 1px solid var(--m-border);
    padding: 0 16px;
    min-height: 50px;
    color: var(--m-ink-muted);
}

.m-search input {
    flex: 1;
    min-width: 0;
    border: 0 !important;
    background: transparent !important;
    padding: 10px 0 !important;
    min-height: 0 !important;
    font: inherit;
    font-size: 16px;
    line-height: 23px;
    color: var(--m-ink);
    box-shadow: none !important;
    outline: none;
    border-radius: 0 !important;
}

.m-search input::placeholder { color: var(--m-ink-subtle); }

/* layout.css styles every label (8px margin, 600 weight, navy) and input (18px checkboxes);
   undo that where m- components are built from <label>/<input>. */
label.m-search,
label.m-switch,
label.m-row,
label.m-chip,
label.m-check {
    margin: 0;
    font-weight: inherit;
    color: inherit;
}

label.m-search { display: flex; font-weight: 400; color: var(--m-ink-muted); }
label.m-switch { display: block; }
.m-search input { font-weight: 400 !important; }
.m-switch input { width: 100% !important; height: 100% !important; }
.m-search__clear { border: 0; background: none; padding: 4px; color: var(--m-ink-muted); cursor: pointer; display: inline-flex; }

/* Chips (horizontal scroll pills) */
.m-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 0 2px; }
.m-chips::-webkit-scrollbar { display: none; }

.m-chip {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--m-border);
    background: var(--m-surface);
    color: var(--m-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.m-chip.is-active,
.m-chip[aria-pressed="true"] { background: var(--m-primary); border-color: var(--m-primary); color: #fff; }
/* "All 1961": flex drops a leading space inside the count span, so space it with a gap instead. */
.m-chip { gap: 0.3em; }
.m-chip > span:empty { display: none; }

/* Segmented */
.m-seg { display: flex; background: var(--m-surface-muted); border-radius: 12px; padding: 4px; }

.m-seg__item {
    flex: 1;
    min-height: 42px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--m-ink-muted);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-seg__item.is-active,
.m-seg__item[aria-selected="true"] { background: var(--m-surface); color: var(--m-ink); box-shadow: var(--m-shadow); }

/* Check (round) / CheckSquare */
.m-check {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 1.5px solid var(--m-ink-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 0;
    color: #fff;
    cursor: pointer;
}

.m-check .m-icon { width: 14px; height: 14px; stroke-width: 2.6; visibility: hidden; }
.m-check--square { border-radius: 7px; }
.m-check.is-checked,
.m-check[aria-checked="true"] { border-color: var(--m-primary); background: var(--m-primary); }
.m-check.is-checked .m-icon,
.m-check[aria-checked="true"] .m-icon { visibility: visible; }

/* Switch (ToggleRow) */
.m-switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.m-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.m-switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--m-surface-muted); transition: background 0.2s; }
.m-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.m-switch input:checked + span { background: var(--m-primary); }
.m-switch input:checked + span::after { transform: translateX(20px); }
.m-switch input:focus-visible + span { outline: 2px solid var(--m-primary); outline-offset: 2px; }
.m-switch input:disabled + span { opacity: 0.5; }

/* ---------- Notice ---------- */
.m-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    padding: 12px;
    background: var(--m-danger-soft);
    color: var(--m-danger);
    font-size: 13px;
    line-height: 18px;
}

.m-notice .m-icon { width: 18px; height: 18px; }
.m-notice__text { flex: 1; min-width: 0; }
.m-notice a,
.m-notice button { color: inherit; font-weight: 600; }
.m-notice--warning { background: var(--m-warning-soft); color: var(--m-warning); }
.m-notice--info { background: var(--m-info-soft); color: var(--m-info); }
.m-notice--success { background: var(--m-primary-soft); color: var(--m-primary-deep); }

/* ---------- Empty / Loading ---------- */
.m-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 0; text-align: center; }
.m-empty .m-caption { max-width: 300px; }

.m-loading { display: flex; justify-content: center; padding: 40px 0; }
.m-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--m-primary-soft); border-top-color: var(--m-primary); animation: m-spin 0.8s linear infinite; }
.m-btn .m-spinner { width: 20px; height: 20px; border-width: 2.5px; border-color: rgba(255, 255, 255, 0.4); border-top-color: #fff; }

@keyframes m-spin { to { transform: rotate(360deg); } }

/* ---------- KeyValue / Stat ---------- */
.m-kv { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.m-kv > :first-child { flex: 0 0 auto; }
.m-kv__value { font-size: 15px; line-height: 20px; font-weight: 500; color: var(--m-ink); text-align: right; min-width: 0; overflow-wrap: anywhere; }

.m-stat { background: var(--m-surface); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--m-shadow); flex: 1; min-width: 0; }
.m-stat__value { font-size: 22px; line-height: 28px; font-weight: 800; color: var(--m-ink); }

/* ---------- Steps (wizard dots) ---------- */
.m-steps { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.m-steps__dots { display: flex; align-items: center; }
.m-steps__line { width: 40px; height: 2.5px; border-radius: 2px; background: var(--m-border); }
.m-steps__dot { width: 14px; height: 14px; border-radius: 50%; background: var(--m-border); display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.m-steps__dot .m-icon { width: 10px; height: 10px; stroke-width: 2.6; }
.m-steps__dot.is-done,
.m-steps__line.is-done { background: var(--m-primary); }
.m-steps__dot.is-current { width: 16px; height: 16px; background: var(--m-primary); }

/* Pinned footer (Wizard / forms): stays above the keyboard edge, page bg */
.m-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--m-bg);
    z-index: 5;
}

/* ---------- Sheet / Dialog / Toast ---------- */
.m-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: var(--m-backdrop);
    display: flex;
    align-items: flex-end;
    animation: m-fade 0.2s ease both;
}

.m-backdrop[hidden] { display: none; }
.m-backdrop--center { align-items: center; justify-content: center; padding: 24px; }

.m-sheet {
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--m-bg);
    border-radius: 22px 22px 0 0;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: m-slide-up 0.25s ease both;
}

.m-dialog { width: 100%; max-width: 420px; background: var(--m-surface); border-radius: 22px; padding: 24px; display: flex; flex-direction: column; gap: 8px; }

@keyframes m-fade { from { opacity: 0; } }
@keyframes m-slide-up { from { transform: translateY(100%); } }

.m-toast {
    position: fixed;
    left: 24px;
    right: 24px;
    bottom: calc(var(--m-tabbar-space) + 16px + env(safe-area-inset-bottom, 0px));
    z-index: 2100;
    border-radius: 15px;
    padding: 16px;
    background: var(--m-ink);
    color: #fff;
    font-size: 15px;
    box-shadow: var(--m-shadow);
    animation: m-fade 0.2s ease both;
}

.m-toast--danger { background: var(--m-danger); }

/* Floating selection bar (Directory) */
.m-selbar {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    z-index: 940;
    background: var(--m-surface);
    border: 1px solid var(--m-border);
    border-radius: 22px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--m-shadow);
}

.m-selbar[hidden] { display: none; }
.m-selbar__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Tab bar (tabs/_layout.tsx FloatingTabBar) ---------- */
.m-tabbar { display: none; }

@media (max-width: 768px) {
    body.m-tabroot .m-tabbar {
        position: fixed;
        left: 28px;
        right: 28px;
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        z-index: 950;
        display: flex;
        padding: 6px;
        background: var(--m-surface);
        border: 1px solid var(--m-border);
        border-radius: 999px;
        box-shadow: var(--m-shadow);
    }
}

.m-tab {
    position: relative;
    isolation: isolate;
    flex: 1 1 0;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--m-ink-muted);
    font-size: 10.5px;
    line-height: 13px;
    font-weight: 500;
    text-decoration: none;
}

.m-tab .m-icon { width: 22px; height: 22px; }
.m-tab.is-active { color: #fff; }
.m-tab.is-active::before { content: ""; position: absolute; z-index: -1; width: 56px; height: 56px; border-radius: 50%; background: var(--m-primary); }
.m-tab.is-active span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.m-tab:focus-visible { outline: 2px solid var(--m-primary); outline-offset: 2px; border-radius: 999px; }

/* Home feature tile */
.m-tile {
    flex: 1 1 47%;
    min-width: 0;
    min-height: 128px;
    box-sizing: border-box;
    background: var(--m-surface);
    border-radius: 22px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--m-shadow);
    color: var(--m-ink);
    text-decoration: none;
    transition: transform 0.12s ease;
}

.m-tile:active { transform: scale(0.97); }
