/* RA premium tools + phone app shell — loaded after ra.css and ra-extra.css */

/* Only shown on phones (see the phone section below) */
.ra-top, .ra-tabbar { display: none; }
.ra-side { overflow-y: auto; scrollbar-width: thin; }
.ra-side > * { flex-shrink: 0; }               /* tall menus scroll instead of squashing the account box */
.ra-mt0 { margin-top: 0; }
.ra-self-start { align-self: flex-start; }

/* ── Help box ─────────────────────────────────────────────────────────── */
.ra-help { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ra-help b { font-size: 13.5px; }
.ra-help small { color: var(--muted); font-size: 12px; }
.ra-help-btns { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.ra-help-btns .ra-btn { flex: 1 1 auto; }
.ra-btn--wa { background: #25d366; border-color: #25d366; color: #05210f; }
.ra-btn--wa:hover { background: #3fe07f; border-color: #3fe07f; }

/* ── Get started progress ─────────────────────────────────────────────── */
.ra-progress { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin: -4px 0 14px; }
.ra-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #e1306c); }
.ra-stat--link { color: inherit; text-decoration: none !important; transition: border-color .15s; }
.ra-stat--link:hover { border-color: var(--accent); }

/* ── Your results ─────────────────────────────────────────────────────── */
.ra-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.ra-kpis > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ra-kpis b { font-size: 24px; line-height: 1.15; }
.ra-kpis span { color: var(--muted); font-size: 12.5px; }
.ra-kpis em { font-style: normal; font-size: 12px; font-weight: 600; }
.ra-kpis em.up { color: var(--ok); }
.ra-kpis em.down { color: var(--err); }
.ra-kpis em.ra-kpi-note { color: var(--muted); font-weight: 400; }
.ra-kpi-split { display: flex; align-items: center; gap: 6px; font-size: 20px !important; }
.ra-kpi-split i { font-style: normal; width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.ra-kpi-split i.fb { background: var(--fb); }
.ra-kpi-split i.ig { background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af); margin-inline-start: 8px; }

.ra-chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; height: 160px; }
.ra-bar { height: 100%; display: grid; grid-template-rows: 16px minmax(0, 1fr) 16px; justify-items: center; min-width: 0; }
.ra-bar em { font-style: normal; font-size: 11px; color: var(--muted); line-height: 16px; }
.ra-bar-track { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.ra-bar i { display: block; width: 100%; max-width: 28px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--accent2), var(--accent)); }
.ra-bar i.zero { background: var(--panel2); }
.ra-bar.today i:not(.zero) { background: linear-gradient(180deg, #ff9a62, #e1306c); }
.ra-bar small { font-size: 10.5px; color: var(--muted); white-space: nowrap; line-height: 16px; }
.ra-bar.today small { color: var(--text); font-weight: 700; }

/* ── Story list: preview & edit ───────────────────────────────────────── */
.ra-thumb--edit { position: relative; display: block; transition: box-shadow .15s; }
.ra-thumb--edit:hover { box-shadow: 0 0 0 2px var(--accent); }
.ra-thumb--edit i { position: absolute; bottom: 4px; inset-inline-end: 4px; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-style: normal; background: rgba(10,12,16,.75); }
.ra-badge--edited { background: #1d1630; color: #c4b5fd; }

/* ── Story editor ─────────────────────────────────────────────────────── */
.ra-back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.ra-back:hover { color: var(--text); text-decoration: none; }
.ra-edit { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.ra-edit > .ra-card { margin: 0; }
.ra-edit-preview { position: sticky; top: 20px; }
.ra-live { position: relative; border-radius: 12px; overflow: hidden; background: var(--panel2); aspect-ratio: 4 / 5; }
.ra-live img { width: 100%; height: 100%; display: block; object-fit: cover; transition: opacity .2s; }
.ra-live.busy img { opacity: .3; }
.ra-live-busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-weight: 600; }
.ra-live-busy[hidden] { display: none; }
.ra-edit-preview .ra-small { margin-top: 10px; }
.ra-counter { direction: ltr; unicode-bidi: isolate; align-self: flex-end; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.ra-counter.warn { color: var(--warn); }
.ra-edit-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Accounts: self-service Facebook connection ───────────────────────── */
.ra-connect-btn { margin: 4px 0 2px; }
.ra-trust { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; color: #c9ced8; font-size: 14px; }
.ra-assist > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.ra-assist > summary::-webkit-details-marker { display: none; }
.ra-assist > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); transition: transform .2s; }
.ra-assist[open] > summary { margin-bottom: 14px; }
.ra-assist[open] > summary::after { transform: rotate(180deg); }
.ra-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.ra-pick form, .ra-conn-foot form { margin: 0; }
.ra-conn-foot { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ── metafy brand: logo (orange M with the pink "live" dot + wordmark) ── */
.mf-logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; direction: ltr; unicode-bidi: isolate; }
.mf-mark { width: 34px; height: 34px; flex: none; display: block; }
.mf-word { font: 700 26px/1 Poppins, system-ui, sans-serif; letter-spacing: -.9px; color: #fff; padding-bottom: 3px; }
.mf-logo:hover .mf-word { color: #fff; }
.ra-side .mf-logo { padding: 2px 4px; }
.lp-nav .mf-mark { width: 38px; height: 38px; }
.lp-nav .mf-word { font-size: 29px; letter-spacing: -1px; }
.ra-hero-top .mf-mark { width: 38px; height: 38px; }
.ra-hero-top .mf-word { font-size: 29px; }
.ra-legal .mf-logo { margin-bottom: 8px; }

/* ── Account screen (phone app "Account" tab; also works on computers) ── */
.mf-profile { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; }
.mf-avatar { width: 58px; height: 58px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 24px/1 Poppins, system-ui, sans-serif; color: #fff;
    background: linear-gradient(140deg, #FF7A3D, #FF5A1F 45%, #E1306C); box-shadow: 0 6px 18px rgba(255, 90, 31, .35); }
.mf-profile-txt { display: flex; flex-direction: column; min-width: 0; }
.mf-profile-txt b { font-size: 19px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-profile-txt small { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }

.mf-plan { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-radius: 18px; margin-bottom: 8px; color: #fff; text-decoration: none !important;
    background: radial-gradient(120% 140% at 100% 0%, rgba(225, 48, 108, .35), transparent 55%), linear-gradient(135deg, #2a1408, #1a0f16);
    border: 1px solid rgba(255, 90, 31, .35); transition: transform .12s; }
.mf-plan:active { transform: scale(.98); }
.mf-plan.off { border-color: rgba(239, 68, 68, .55); }
.mf-plan-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mf-plan-txt small { color: #f7b89c; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.mf-plan-txt b { font-size: 20px; }
.mf-plan-txt em { font-style: normal; color: #d9c9c2; font-size: 13px; }
.mf-plan.off .mf-plan-txt em { color: #fca5a5; }
.mf-plan-btn { flex: none; background: #FF5A1F; color: #fff; font-weight: 700; font-size: 14px; padding: 9px 14px; border-radius: 999px; }

.mf-group-h { font-size: 12.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; margin: 22px 4px 8px; }
.mf-group { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.mf-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 60px; color: var(--text); text-decoration: none !important; transition: background .12s; }
.mf-row + .mf-row { border-top: 1px solid var(--line); }
a.mf-row:active { background: var(--panel2); }
.mf-row > span:not(.mf-seg) { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.mf-row b { font-size: 15px; font-weight: 600; }
.mf-row small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-ico { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; }
.mf-ico svg, .mf-chev, .mf-logout-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mf-ico--blue   { background: rgba(59, 130, 246, .16); color: #7fb0ff; }
.mf-ico--orange { background: rgba(255, 90, 31, .16); color: #ff9a6a; }
.mf-ico--green  { background: rgba(34, 197, 94, .15); color: #6ee7a0; }
.mf-ico--purple { background: rgba(139, 92, 246, .17); color: #b9a1ff; }
.mf-ico--pink   { background: rgba(225, 48, 108, .17); color: #ff8fb6; }
.mf-ico--gray   { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
.mf-chev { color: var(--muted); flex: none; width: 18px; height: 18px; }
[dir="rtl"] .mf-chev { transform: scaleX(-1); }
.mf-seg { display: inline-flex; flex: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; direction: ltr; }
.mf-seg a { padding: 6px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none !important; }
.mf-seg a.on { background: #FF5A1F; color: #fff; }
.mf-group + .ra-help, .mf-group-h + .ra-help { margin-top: 0; }
.mf-logout { margin: 22px 0 0; }
.mf-logout-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 14px; border: 1px solid rgba(239, 68, 68, .35);
    background: rgba(239, 68, 68, .08); color: #fca5a5; font: 600 15px/1 inherit; font-family: inherit; cursor: pointer; }
.mf-logout-btn:active { background: rgba(239, 68, 68, .16); }
.mf-ver { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8; margin: 18px 0 6px; }
.mf-ver a { color: var(--muted); }

/* Page-change progress line (all screens) */
#mf-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0); opacity: 0;
    background: linear-gradient(90deg, #FF5A1F, #E1306C); }
#mf-progress.go { opacity: 1; transform: scaleX(.85); transition: transform 2.5s cubic-bezier(.1, .7, .2, 1), opacity .1s; }
[dir="rtl"] #mf-progress { transform-origin: 100% 50%; }

/* ── Phones: the app ──────────────────────────────────────────────────── */
@media (max-width: 860px) {
    @view-transition { navigation: auto; }

    .ra-shell--app { display: block; min-height: 100vh; }
    .ra-shell--app .ra-side { display: none; }
    .ra-shell--app .ra-main { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }

    /* App header: small mark · screen title · account bubble */
    .ra-top { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; min-height: 56px;
        padding: calc(8px + env(safe-area-inset-top)) 14px 8px; background: rgba(10, 12, 16, .88);
        -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid rgba(255, 255, 255, .06);
        view-transition-name: mf-top; }
    .mf-top-mark { width: 30px; height: 30px; flex: none; display: grid; place-items: center; }
    .mf-top-mark svg { width: 26px; height: 26px; }
    .mf-top-title { flex: 1; min-width: 0; font: 700 19px/1.2 Poppins, system-ui, sans-serif; letter-spacing: -.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    [dir="rtl"] .mf-top-title { font-family: Almarai, Poppins, system-ui, sans-serif; }
    .mf-top-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 15px/1 Poppins, system-ui, sans-serif;
        text-decoration: none !important; background: linear-gradient(140deg, #FF7A3D, #E1306C); box-shadow: 0 0 0 2px rgba(255, 255, 255, .08); }
    .mf-top-avatar:active { transform: scale(.92); }

    /* Bottom tab bar */
    .ra-tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        background: rgba(13, 16, 22, .94); -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
        border-top: 1px solid rgba(255, 255, 255, .07); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); view-transition-name: mf-tabbar; }
    .ra-tabbar > a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; color: #8a93a3;
        text-decoration: none !important; -webkit-tap-highlight-color: transparent; user-select: none; transition: color .15s, transform .12s; }
    .ra-tabbar > a:active { transform: scale(.9); }
    .ra-tabbar > a > i { position: relative; width: 58px; height: 30px; display: grid; place-items: center; border-radius: 999px; transition: background .2s; }
    .ra-tabbar > a > i svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
    .ra-tabbar > a > small { font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: .1px; }
    [dir="rtl"] .ra-tabbar > a > small { font-family: Almarai, system-ui, sans-serif; font-size: 11.5px; }
    .ra-tabbar > a.on { color: #fff; }
    .ra-tabbar > a.on > i { background: rgba(255, 90, 31, .18); color: #FF6A2B; }
    .ra-tabbar > a.on > i svg { stroke-width: 2.1; transform: translateY(-1px); }

    /* Page change: content slides in, header and tab bar stay put */
    ::view-transition-old(root) { animation: mf-fade-out .14s ease-in both; }
    ::view-transition-new(root) { animation: mf-slide-in .24s cubic-bezier(.2, .8, .2, 1) both; }
    ::view-transition-group(mf-top), ::view-transition-group(mf-tabbar) { animation: none; }

    /* Pull down to refresh (app only) */
    #mf-ptr { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 50%; z-index: 35; width: 40px; height: 40px; margin-left: -20px; border-radius: 50%;
        display: grid; place-items: center; background: #1a1e27; border: 1px solid var(--line); box-shadow: 0 8px 20px rgba(0, 0, 0, .45); opacity: 0;
        transform: translateY(-50px); pointer-events: none; }
    #mf-ptr svg { width: 22px; height: 22px; fill: none; stroke: #FF6A2B; stroke-width: 2.2; stroke-linecap: round; }
    #mf-ptr.spin svg { animation: mf-spin .7s linear infinite; }

    /* Touch-friendly controls */
    input, select, textarea { font-size: 16px; }           /* stops iPhone zooming into fields */
    .ra-btn { min-height: 44px; }
    .ra-btn--sm { min-height: 40px; padding: 8px 12px; }
    .ra-check input[type=checkbox] { width: 22px; height: 22px; }
    .ra-h1 { font-size: 22px; margin-bottom: 16px; }
    .ra-card { border-radius: 18px; }
    .ra-alert { border-radius: 14px; }

    .ra-stats { gap: 10px; }
    .ra-stat { padding: 14px; border-radius: 16px; }
    .ra-stat b { font-size: 24px; }
    .ra-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .ra-kpis b { font-size: 21px; }
    .ra-chart { gap: 3px; height: 140px; }
    .ra-bar small { font-size: 9.5px; }
    .ra-bar em { font-size: 10px; }

    /* Story list as touch cards */
    .ra-item { flex-wrap: wrap; gap: 12px; padding: 14px 0; }
    .ra-item .ra-thumb { width: 88px; height: 66px; border-radius: 10px; }
    .ra-item .ra-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: stretch; }
    .ra-item .ra-actions > * { flex: 1 1 0; min-width: 0; }
    .ra-item .ra-actions > a.ra-btn { flex-basis: 100%; }
    .ra-item .ra-actions form .ra-btn { width: 100%; }

    /* Story editor: preview first, buttons always in reach */
    .ra-edit { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .ra-edit-preview { position: static; }
    .ra-edit-actions { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; background: var(--panel); padding: 10px 0 4px; }
    .ra-edit-actions .ra-btn { flex: 1 1 auto; }
    .ra-edit-actions .ra-btn--primary { flex-basis: 100%; }

    .ra-connect-btn { width: 100%; }
    .ra-connect .ra-page { flex-wrap: wrap; }
    .ra-connect .ra-page .ra-btn { width: 100%; }

    .lp-nav .mf-mark { width: 32px; height: 32px; }
    .lp-nav .mf-word { font-size: 24px; }

    /* Log-in / sign-up inside the app: an app screen, not a web page */
    .ra-inapp .ra-auth, .ra-standalone .ra-auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: calc(24px + env(safe-area-inset-top)) 16px 24px; gap: 18px; }
    .ra-inapp .ra-hero, .ra-standalone .ra-hero { padding: 0; background: none; border: 0; min-height: 0; text-align: center; }
    .ra-inapp .ra-hero-top, .ra-standalone .ra-hero-top { justify-content: center; flex-direction: column; gap: 14px; }
    .ra-inapp .ra-hero-top .mf-mark, .ra-standalone .ra-hero-top .mf-mark { width: 64px; height: 64px; }
    .ra-inapp .ra-hero-top .mf-word, .ra-standalone .ra-hero-top .mf-word { font-size: 38px; }
    .ra-inapp .ra-hero-top .mf-logo, .ra-standalone .ra-hero-top .mf-logo { flex-direction: column; gap: 6px; }
    .ra-inapp .ra-hero h1, .ra-inapp .ra-hero > p, .ra-inapp .ra-points, .ra-inapp .ra-foot,
    .ra-standalone .ra-hero h1, .ra-standalone .ra-hero > p, .ra-standalone .ra-points, .ra-standalone .ra-foot { display: none; }
    .ra-inapp .ra-auth-card, .ra-standalone .ra-auth-card { border-radius: 22px; }
}
@media (max-width: 380px) {
    .ra-tabbar > a > small { font-size: 10px; }
    .ra-tabbar > a > i { width: 48px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
@keyframes mf-fade-out { to { opacity: 0; } }
@keyframes mf-slide-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes mf-spin { to { transform: rotate(360deg); } }

/* Installed app (iPhone/Android home screen): body already pads for the status bar */
.ra-standalone .ra-top { padding-top: 8px; }
.ra-inapp .ra-top { padding-top: 8px; }

/* ── "Continue with Facebook" (log-in / sign-up) ─────────────────────── */
.mf-fb-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 12px;
    background: #1877F2; color: #fff !important; font-weight: 600; font-size: 15px; text-decoration: none !important; transition: background .15s, transform .1s; }
.mf-fb-btn:hover { background: #2D88FF; }
.mf-fb-btn:active { transform: scale(.98); }
.mf-fb-btn svg { width: 22px; height: 22px; flex: none; }
.mf-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.mf-or::before, .mf-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
