/* Fit the existing phone UI to available Safari width, in either orientation. */
@media screen {
 html[data-surface="mobile"]{--mobile-width:100%;-webkit-text-size-adjust:100%;--up-safe-left:env(safe-area-inset-left,0px);--up-safe-right:env(safe-area-inset-right,0px);--up-safe-bottom:env(safe-area-inset-bottom,0px)}
 html[data-surface="mobile"] .mobile-desktop-note{display:none}
 html[data-surface="mobile"] body.mobile-app .mobile-device{box-sizing:border-box;width:100%;max-width:none;min-height:100vh;min-height:100dvh;margin:0;border:0;border-radius:0;padding-left:var(--up-safe-left);padding-right:var(--up-safe-right);padding-bottom:calc(90px + var(--up-safe-bottom))}
 html[data-surface="mobile"] body.mobile-app .mobile-topbar{padding-top:calc(13px + env(safe-area-inset-top,0px))}
 html[data-surface="mobile"] body.mobile-app .mobile-bottom-nav{box-sizing:border-box;left:0;bottom:0;transform:none;width:100%;max-width:none;border-radius:0;height:calc(69px + var(--up-safe-bottom));padding-left:max(6px,var(--up-safe-left));padding-right:max(6px,var(--up-safe-right));padding-bottom:max(6px,var(--up-safe-bottom))}
 html[data-surface="mobile"] body.mobile-app #main,html[data-surface="mobile"] body.mobile-app #main>*,html[data-surface="mobile"] body.mobile-app :is(.bw-ledger,.bw-account-list,.bw-account-card,.bw-copy-scroll){box-sizing:border-box;min-width:0;max-width:100%}
 html[data-surface="mobile"] body.mobile-app #follow-settings .pq-sheet{box-sizing:border-box;max-width:calc(100% - var(--up-safe-left) - var(--up-safe-right) - 12px);max-height:calc(100vh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 12px);max-height:calc(100dvh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 12px);padding-bottom:max(16px,var(--up-safe-bottom));overflow:auto;overscroll-behavior:contain}
 html[data-surface="mobile"] body.mobile-app .bw-copy-scroll{overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
 html[data-surface="mobile"] body.mobile-app .bw-account-card .bw-card-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}
/* Use the available page width even when the browser requests a desktop viewport.
   Empty grid tracks collapse, so a single account never leaves half a page blank. */
html[data-surface="mobile"] body.mobile-app #follow-settings.fs-inline:is(.bw-sources,.bw-followers) .bw-account-list{
 grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr));align-items:start
}
html[data-surface="mobile"] body.mobile-app #follow-settings.fs-inline .bw-account-list>:is(.bw-empty,.pq-empty){grid-column:1/-1}

/* The same six links become a right-hand rail in a wide landscape viewport.
   Compact portrait uses the same links as touch icons; tall phones keep the bottom row. */
@media (min-width:640px) and (orientation:landscape), (min-width:480px) and (max-height:479px) and (orientation:landscape), (min-width:300px) and (max-width:599px) and (min-aspect-ratio:9/16) and (max-aspect-ratio:4/5) and (orientation:portrait){
 html[data-surface="mobile"] body.mobile-app .mobile-device{
  --up-nav-rail:64px;--up-nav-reserve:0px;--mobile-nav-space:0px;
  padding-right:calc(var(--up-safe-right) + var(--up-nav-reserve));
  padding-bottom:var(--up-safe-bottom)
 }
 html[data-surface="mobile"] body.mobile-app .mobile-device:has(>.mobile-bottom-nav a){--up-nav-reserve:var(--up-nav-rail)}
 /* Match the original routes that deliberately hide the main navigation. */
 html[data-surface="mobile"] body.mobile-app:is([data-mobile-route=trader],[data-mobile-route=strategy]) .mobile-device:has(>.mobile-bottom-nav a),
 html[data-surface="mobile"] body.mobile-app .mobile-device:has(.mch-market,.mc-terminal,.mc-member:not(.mc-home):not(.pp-personal)){--up-nav-reserve:0px}
 html[data-surface="mobile"] body.mobile-app .mobile-bottom-nav{
  top:0;right:0;bottom:0;left:auto;transform:none;
  width:calc(var(--up-nav-rail) + var(--up-safe-right));max-width:none;
  height:100vh;height:100dvh;max-height:100dvh;
  flex-direction:column;align-items:stretch;justify-content:flex-start;gap:2px;
  padding:calc(4px + env(safe-area-inset-top,0px)) calc(10px + var(--up-safe-right)) calc(4px + var(--up-safe-bottom)) 4px;
  border-top:0;border-left:1px solid var(--border);border-radius:0;
  overflow-y:auto;overscroll-behavior:contain
 }
 html[data-surface="mobile"] body.mobile-app .mobile-bottom-nav a{
  position:relative;box-sizing:border-box;flex:1 0 44px;min-width:0;min-height:44px;max-height:64px;
  padding:4px 0;gap:3px;font-size:10px;line-height:14px
 }
 html[data-surface="mobile"] body.mobile-app .mobile-bottom-nav a .icon{width:20px;height:20px;flex:none}
 html[data-surface="mobile"] body.mobile-app .mobile-bottom-nav a.active:after{left:auto;right:2px;top:50%;bottom:auto;transform:translateY(-50%)}
 html[data-surface="mobile"] body.mobile-app .cd-action-dock {left:var(--up-safe-left);transform:none;margin:0 6px;width:calc(100% - var(--up-nav-reserve,0px) - var(--up-safe-left) - var(--up-safe-right) - 12px);bottom:var(--up-safe-bottom);}
 html[data-surface="mobile"] body.mobile-app .mobile-topbar{padding:calc(6px + env(safe-area-inset-top,0px)) 12px 6px}
 html[data-surface="mobile"] body.mobile-app #main{padding-left:12px;padding-right:12px}
}
@media (max-width:379px){
 .mobile-app #follow-settings.fs-inline .bw-account-follower .bw-card-funds{grid-template-columns:repeat(2,minmax(0,1fr))}
 .mobile-app #follow-settings.fs-inline .bw-account-follower .bw-card-funds>div:nth-child(n){grid-column:auto}
 .mobile-app .bw-account-card .bw-card-badges{gap:3px}.mobile-app .bw-account-card .bw-card-badges>span{font-size:10px;padding:2px 4px}
}

.mobile-app #follow-settings.fs-inline .bw-compact-card .bw-card-funds{grid-template-columns:repeat(3,minmax(0,1fr))}
.mobile-app #follow-settings.fs-inline .bw-compact-card .bw-card-funds>div:nth-child(n){grid-column:auto}

/* Copy settings use the same compact purple surface and type as account cards. */
html[data-surface="mobile"] body.mobile-app #follow-settings.fs-inline .bw-copy-sheet{
 --settings-bg:#eee3ff;--settings-line:#ceb5eb;--settings-text:#39254f;--settings-field:#f6efff;
 --pq-bg:var(--settings-bg);--pq-card:var(--settings-bg);--pq-line:var(--settings-line);--pq-text:var(--settings-text);
 padding:8px 9px max(9px,env(safe-area-inset-bottom,0px));border:1px solid var(--settings-line);border-radius:12px;
 background:var(--settings-bg);color:var(--settings-text);font-family:inherit;font-size:11px;line-height:16px;box-shadow:0 4px 18px #0002
}
html[data-theme="dark"][data-surface="mobile"] body.mobile-app #follow-settings.fs-inline .bw-copy-sheet{
 --settings-bg:#332442;--settings-line:#684b80;--settings-text:#f1e4ff;--settings-field:#291d36
}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet-head{justify-content:flex-start;gap:6px;min-height:32px;padding-bottom:5px;border-bottom:1px solid var(--settings-line)}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet-head h3{margin:0;font-size:12px;font-weight:600;line-height:17px;text-align:left}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet h4{font-size:11px;font-weight:500;line-height:16px;margin:7px 0 4px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet p{font-size:10px;line-height:16px;margin:4px 0}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet fieldset{margin:6px 0;padding:6px 7px;border-color:var(--settings-line);border-radius:7px;background:transparent}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet legend{max-width:100%;padding:0 3px;font-size:11px;line-height:16px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet legend label{display:flex;align-items:center;gap:5px;margin:0;min-height:30px;font-size:11px;line-height:16px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet legend input{width:16px;height:16px;margin:0;accent-color:var(--purple)}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-parameters{gap:5px 7px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-parameters label{display:grid;gap:2px;margin:0;font-size:10px;line-height:15px;color:var(--muted)}
/* Keep native focus sizing while matching the 11px card values visually. */
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-field-control{display:block;min-width:0;height:32px;position:relative;overflow:hidden;border-radius:5px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-field-control :is(input,select){
 position:absolute;top:0;left:0;box-sizing:border-box;width:145.454545%;max-width:none;min-width:0;height:46.545455px;min-height:46.545455px;margin:0;
 padding:5.818182px 8.727273px;border:1.454545px solid var(--settings-line);border-radius:7.272727px;background:var(--settings-field);color:var(--settings-text);
 font-family:inherit;font-size:16px;font-weight:400;line-height:24px;transform:scale(.6875);transform-origin:top left;font-variant-numeric:tabular-nums
}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-field-control :is(input,select):focus-visible{outline:2px solid var(--purple);outline-offset:-2px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-recovery{padding:3px 0 6px;border-color:var(--settings-line)}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-recovery-grid{gap:4px 10px;margin:4px 0}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-recovery-grid>div{gap:5px;font-size:10px;line-height:16px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-recovery-grid dd{font-size:11px;font-variant-numeric:tabular-nums}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet :is(button,a){display:inline-flex;align-items:center;justify-content:center;min-height:32px;margin:0;padding:3px 7px;border:1px solid var(--settings-line);border-radius:5px;background:transparent;color:var(--purple);font-family:inherit;font-size:10px;font-weight:400;line-height:16px;text-decoration:none}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet-head [data-mpc-close]{flex:none;width:30px;min-height:30px;padding:0;border:0;font-size:18px;color:var(--settings-text)}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-connection-actions{gap:6px;margin-top:5px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons{gap:5px;margin:6px 0 0}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet [data-mpc-error]:empty{display:none}

/* One compact type scale; save/start/pause first, stop on its own second row. */
.mobile-app #follow-settings.fs-inline .bw-copy-sheet :is(label,legend,p,dt,h4,.bw-copy-source-connection){font-size:10px;line-height:15px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet :is(dd,.bw-copy-assigned-name){font-size:11px;line-height:16px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-field-control option{font-size:11px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-parameters label>:is(input,select){font-size:11px;min-height:32px;padding:4px 6px}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:8px 0 0}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>button{box-sizing:border-box;width:100%;min-width:0;min-height:34px;padding:5px 3px;border-radius:6px;font-size:10px;font-weight:500;line-height:15px;overflow-wrap:anywhere;text-align:center;white-space:normal}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>.bw-copy-save{background:#7654a2;border-color:#8d6bb7;color:#fff}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>[data-mpc-control="start"]{background:#8b68b214;border-color:#9a7cbb}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>[data-mpc-control="stop"]{grid-column:1/-1;background:#f7e7ec;border-color:#d0a1b2;color:#963f5c}
html[data-theme="dark"] .mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>[data-mpc-control="stop"]{background:#402a3b;border-color:#80536c;color:#ecb4c9}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>button:not(:disabled):active{filter:brightness(.9)}
.mobile-app #follow-settings.fs-inline .bw-copy-sheet .bw-copy-control-buttons>button:focus-visible{outline:2px solid var(--purple);outline-offset:2px}

/* One compact navigation strip inside the viewport; the header keeps its own tools. */
@media (min-width:300px) and (max-width:599px) and (min-aspect-ratio:9/16) and (max-aspect-ratio:4/5) and (orientation:portrait) {
 html[data-surface="mobile"] body.mobile-app .mobile-device { --up-nav-rail:58px; }
 html[data-surface="mobile"] body.mobile-app #main {padding-inline:6px;}
 html[data-surface="mobile"] body.mobile-app #nav.mobile-bottom-nav {
  top:auto;bottom:calc(12px + var(--up-safe-bottom));right:calc(10px + var(--up-safe-right));
  width:46px;height:auto;
  max-height:calc(100vh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 24px);
  max-height:calc(100dvh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 24px);
  padding:2px 0;gap:0;border:1px solid var(--border);border-radius:24px;
 }
 html[data-surface="mobile"] body.mobile-app #nav.mobile-bottom-nav a {flex:0 0 44px;height:44px;width:44px;padding:0;gap:0;border-radius:50%;}
 html[data-surface="mobile"] body.mobile-app #nav.mobile-bottom-nav a>span {display:none;}
 html[data-surface="mobile"] body.mobile-app #nav.mobile-bottom-nav svg {width:20px;height:20px;}
 html[data-surface="mobile"] body.mobile-app #nav.mobile-bottom-nav a.active:after {right:2px;}
 html[data-surface="mobile"] body.mobile-app #follow-settings.fs-inline .bw-compact-card>header {align-items:start;flex-wrap:wrap;}
 html[data-surface="mobile"] body.mobile-app .bw-compact-card .bw-source-tools {flex-wrap:wrap;max-width:100%;margin-left:auto;}
 html[data-surface="mobile"] body.mobile-app .bw-compact-card .bw-source-identity {min-width:0;}
 html[data-surface="mobile"] body.mobile-app #follow-settings .bw-copy-orders {width:100%;min-width:0;}
}

/* Center the native settings sheet between the safe edges even when only one side has an inset. */
html[data-surface="mobile"] body.mobile-app #follow-settings.fs-inline dialog.bw-copy-sheet[open] {
 left:var(--up-safe-left);right:var(--up-safe-right);bottom:calc(6px + var(--up-safe-bottom));margin-inline:auto;
 max-height:calc(100vh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 12px);
 max-height:calc(100dvh - env(safe-area-inset-top,0px) - var(--up-safe-bottom) - 12px);
 padding-bottom:9px;
}
html[data-surface="mobile"] body.mobile-app:has(dialog[data-mpc-dialog][open]) #nav.mobile-bottom-nav {
 visibility:hidden;
}
