/* Mobile (< 760px): the same pages, re-flowed. Sidebar → bottom nav + mobile header; rail → sheet; modals → sheets.
   Desktop rules above 760px are untouched; the mobile chrome is hidden there. */
.mtopbar, .mnavbar { display: none; }
body.embed .mock { display: none; }
body.embed .app { height: 100vh; }

/* Sheet variant of the modal (also used on desktop for "More" and the agent Info sheet if triggered) */
.modal.sheet { align-self: flex-end; width: 100%; max-width: 560px; border-radius: var(--r2) var(--r2) 0 0; border-bottom: 0; max-height: 86%; }
.modal.sheet::before { content: ''; display: block; width: 36px; height: 3px; border-radius: 2px; background: var(--line2); margin: 8px auto 0; }
.modal.sheet .mb.railbody { padding-top: 6px; }
.modal.sheet .railbody .rc { margin-bottom: 10px; }
.morelist { display: grid; }
.morerow { display: grid; grid-template-columns: 22px 1fr 16px; gap: 14px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); text-align: left; }
.morerow:first-child { border-top: 0; }
.morerow > svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.7; }
.morerow > svg:last-child { transform: rotate(-90deg); width: 14px; height: 14px; stroke: var(--quiet); }
.morerow b { display: block; font-size: 15px; font-weight: 500; }
.morerow small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.minfo { display: none; }

/* Agents list page (desktop + mobile) */
.aglist { display: grid; }
.agcard { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.agcard:first-child { border-top: 0; }
.agcard.needsyou { background: linear-gradient(90deg, var(--rbg), transparent 55%); margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--r1); }
.agc1 { display: flex; align-items: center; gap: 10px; }
.agc1 b { font-size: 15px; font-weight: 600; }
.agc small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.agc p { margin-top: 6px; font-size: 13.5px; color: var(--body); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agr { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.agr > b { font-size: 15px; font-weight: 600; }

@media (max-width: 760px) {
  :root { --topbar-h: 52px; --mnav-h: 60px; }
  .app { grid-template-columns: 1fr !important; }
  .side, .top, .rail, .railgrip { display: none !important; }
  .mtopbar { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); flex: none; }
  .mtopbar .mmark svg { width: 22px; height: 22px; display: block; }
  .mtopbar .mtitle { flex: 1; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mback { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r1); color: var(--body); margin-left: -6px; }
  .mback svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; transform: rotate(90deg); }
  .mnavbar { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--mnav-h); border-top: 1px solid var(--line); background: var(--side); flex: none; padding-bottom: env(safe-area-inset-bottom); }
  .mnavbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--quiet); font-size: 10.5px; position: relative; }
  .mnavbar button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .mnavbar button.on { color: var(--text); }
  .mnavbar button.on svg { stroke: var(--violet); }
  .mnavbar .mdot { position: absolute; top: 9px; right: calc(50% - 14px); width: 6px; height: 6px; border-radius: 50%; background: var(--violet); }
  .sysbar { padding: 8px 14px; font-size: 12.5px; flex-wrap: wrap; }
  .sysbar .btn { margin-left: 0; }

  /* Content */
  .wrap { padding: 18px 16px 28px; }
  .sh { margin: 28px 0 12px; flex-wrap: wrap; }
  .sh h3 { font-size: 16px; }
  .sh .r { margin-left: 0; width: 100%; justify-content: flex-start; }
  .strip { grid-template-columns: 1fr 1fr; gap: 18px 16px; padding-bottom: 18px; }
  .strip > div { padding: 0 !important; border-left: 0 !important; }
  .strip > div:first-child { grid-column: 1 / -1; }
  .strip .v { font-size: 26px; }
  .strip .v.disp { font-size: 48px; }
  .strip .acts { flex-wrap: wrap; }
  .dotfield { width: 80%; }
  .spark { max-width: none; }

  /* Home */
  .pulse { margin-top: 12px; }
  .askhead h2 { font-size: 20px; }
  .askhead span { display: none; }
  .who { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .starters { display: none; }
  .now { grid-template-columns: 1fr; gap: 6px; }
  .nowc { padding: 12px 14px 12px 16px !important; border-left-width: 3px; background: var(--panel); border-radius: 0 var(--r2) var(--r2) 0; }
  .nowc p { margin-top: 10px; }
  .cardspark { margin-top: 8px; }
  .rewardstrip { grid-template-columns: 1fr; gap: 14px; }
  .rw { border-left: 0 !important; padding: 0 !important; }
  .ev { grid-template-columns: 28px 1fr; }
  .evr { grid-column: 2; display: flex; gap: 12px; text-align: left; }
  .evr .amt { margin-top: 0; }

  /* Agent page */
  .ws { grid-template-columns: 1fr !important; }
  .aghead { padding: 8px 12px !important; flex-wrap: wrap !important; border-bottom: 0 !important; gap: 8px !important; }
  .aghead .av.lg { width: 34px; height: 34px; }
  .aghead h2 { font-size: 15px; }
  .aghead .meta { display: none; }
  .aghead > div:nth-child(2) { min-height: 40px; }
  .minfo { display: inline-flex; margin-left: auto; }
  .aghead .runonce { margin-left: 0 !important; }
  .aghead .runonce span, .aghead .runonce svg + text { display: none; }
  .aghead .auto { margin-left: 0 !important; padding-left: 0 !important; border-left: 0 !important; font-size: 0; }
  .aghead .auto .sw { margin-left: 0; }
  .aghead .tabs { order: 10 !important; flex-basis: calc(100% + 24px) !important; margin: 4px -12px 0 !important; padding: 0 12px !important; border-top: 1px solid var(--line) !important; border-bottom: 1px solid var(--line) !important; overflow-x: auto; white-space: nowrap; }
  .aghead .tabs button { height: 40px; padding: 0 12px; }
  .aghead .meta i, .aghead .meta .rank { display: none !important; }
  .chatpane { padding: 16px 14px 6px !important; }
  .msg { margin-bottom: 16px; }
  .msg.me { max-width: 88%; }
  .compwrap { padding: 4px 10px 10px !important; }
  .comp.tall { padding: 8px 8px 6px 12px; }
  .comptools .hint { display: none; }
  .ctool.model small { display: none; }
  .runs, .strat { padding: 14px 14px 30px; }
  .runstrip { grid-template-columns: 1fr 1fr; }
  .runacts { grid-column: 1 / -1; justify-content: space-between; }
  .runbody { padding-left: 0; }
  .stratbody { grid-template-columns: 1fr; margin-top: 0; }
  .stratnav { display: none; }
  .ss.editing { margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
  .riskgrid { grid-template-columns: 1fr 1fr; }
  .voicegrid, .trackgrid, .pv, .costgrid { grid-template-columns: 1fr; }
  .trigrow { grid-template-columns: 28px 1fr; }
  .trigacts { grid-column: 2; justify-content: flex-start; }
  .trigform { margin-left: 0; }

  /* Funds / Costs / Rewards / Activity */
  .alloc .row { grid-template-columns: 1fr auto; row-gap: 8px; }
  .alloc .row .bar, .alloc .row.head { display: none; }
  .alloc .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .ways { grid-template-columns: 1fr; }
  .way + .way { border-left: 0; border-top: 1px solid var(--line); }
  .crow { grid-template-columns: 30px 1fr auto; }
  .cbar, .cusd { display: none; }
  .earnhead { display: none; }
  .earnrow { grid-template-columns: 1fr auto; row-gap: 8px; }
  .earnrow .who { grid-column: 1 / -1; }
  .lbrow { grid-template-columns: 40px 22px 1fr auto; }
  .lbdelta { display: none; }
  .filters { overflow-x: auto; white-space: nowrap; }
  .filters .r { margin-left: 0; }
  .lrow { grid-template-columns: 44px 1fr auto; }
  .tabs.inline { flex-wrap: wrap; }

  /* Settings */
  .settings { grid-template-columns: 1fr; gap: 12px; }
  .setnav { display: flex; gap: 2px; overflow-x: auto; position: static; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
  .setnav button { white-space: nowrap; }
  .setrow { flex-wrap: wrap; }
  .setrow .txt { flex-basis: 100%; }
  .provider { grid-template-columns: 1fr; }

  /* Create / onboarding */
  .meet { grid-template-columns: 1fr; gap: 24px; justify-items: center; }
  .portrait, .pframe { width: min(300px, 100%); }
  .mside { width: 100%; }
  .gacts { flex-wrap: wrap; }
  .stakes { grid-template-columns: repeat(3, 1fr); }
  .recruit { padding: 18px 16px; }
  .rfoot { flex-direction: column-reverse; gap: 10px; }
  .rfoot .btn { width: 100%; }
  .gacts .btn { flex: 1; }
  .style + .style { border-left: 0; border-top: 1px solid var(--line); }
  .style p { min-height: 0; }
  .namerow { grid-template-columns: 56px 1fr; }
  .gate { grid-template-columns: 1fr; }
  .gate .art { display: none; }
  .gate .pane { padding: 28px 20px; align-items: flex-start; }
  .firstrun h2 { font-size: 26px; }
  .ck { grid-template-columns: 28px 1fr; }
  .ck > :last-child:not(small) { grid-column: 2; }

  /* Modals → sheets */
  .overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: none; border-radius: var(--r2) var(--r2) 0 0; border-bottom: 0; max-height: 92%; animation: slideUp var(--med) var(--ease) both; }
  .modal .mh, .modal .mb, .modal .mf { padding-left: 18px; padding-right: 18px; }
  .modal .mf { flex-wrap: wrap; }
  .modal .mf .btn { flex: 1; justify-content: center; }
  .palette { margin-top: 8vh; }
  .toast { left: 12px; right: 12px; transform: none; bottom: calc(var(--mnav-h) + 12px); }
  .dd.sm .ddmenu { left: 0; right: auto; }

  /* Mobile preview page itself, viewed on mobile */
  .mobrow { flex-direction: column; align-items: center; }
  .notes { grid-template-columns: 1fr !important; }
}

/* The Mobile route on desktop: live iframes in phone frames */
.phone iframe.scr { border: 0; width: 100%; height: 100%; display: block; background: var(--bg); }
.phone { width: 390px; height: 780px; }
@media (max-width: 760px) {
  .vp { overflow-x: hidden; }
  .strip > div, .wrap, .stage, .chatcol { min-width: 0; }
  .strip .v.disp { font-size: 42px; }
  .strip .lbl, .strip .d { overflow-wrap: anywhere; }
  .aghead .runonce { padding: 0 10px; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr) !important; overflow: hidden; }
  .stage { max-width: 100vw; overflow: hidden; }
  .mnavbar { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .strip > div:first-child { grid-column: auto; }
  .strip > .dotfield + div, .strip > div:first-child:not(.dotfield) { grid-column: 1 / -1; }
  .strip .v.disp { font-size: clamp(32px, 10.5vw, 44px); white-space: nowrap; }
  .strip .v.disp small { font-size: 16px; }
}
@media (max-width: 760px) { .chip { white-space: nowrap; flex: none; } }
@media (max-width: 760px) {
  .summary { display: none; }
  .aghead .runonce span { display: none; }
  .aghead .runonce { width: 34px; padding: 0; justify-content: center; }
  .strat, .stratsecs, .ss, .strathead, .strathead > div { min-width: 0; }
  .strathead { flex-direction: column; align-items: flex-start; gap: 8px; }
  .strathead .r { margin-left: 0; }
  .strathead h3 { font-size: 17px; }
  .goaltext { font-size: 16px; max-width: 100%; overflow-wrap: anywhere; }
  .ssh { flex-wrap: wrap; }
  .ssh .r { margin-left: 0; }
  .ssh h4 { font-size: 15px; }
  .rulelist li { flex-wrap: wrap; }
  .rulelist .rt { flex-basis: 100%; }
}
