/* ============================================================
   BP-MOBILE 2 - phone stylesheet, rewritten 2026-08-30
   Loaded after style.css. Everything lives inside one
   max-width:820px block, so the desktop layout is untouched.
   Design goals: content on the first screen, 44px tap targets,
   16px inputs (no iOS zoom), nothing wider than the screen.
   ============================================================ */

@media (max-width: 820px) {

  :root {
    --bp-bg: #080c12;
    --bp-surface: #111823;
    --bp-surface-2: #182131;
    --bp-line: rgba(148, 163, 184, .16);
    --bp-text: #e7eef8;
    --bp-muted: #8d99ad;
    --bp-accent: #00d09c;
    --bp-accent-ink: #04150f;
    --bp-red: #ff5f6d;
    --bp-radius: 14px;
    --bp-pad: 14px;
    --bp-bar: 64px;
  }

  html { -webkit-text-size-adjust: 100%; }

  body {
    background: var(--bp-bg);
    color: var(--bp-text);
    font-size: 15px;
    line-height: 1.45;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
  }

  /* the page content must never depend on an animation to become
     visible - a deferred animation used to leave a blank screen */
  main.wrap,
  .rise,
  .card {
    opacity: 1 !important;
    animation: none !important;
  }

  main.wrap {
    padding: 12px 12px calc(var(--bp-bar) + env(safe-area-inset-bottom, 0px) + 20px);
    max-width: 100%;
  }

  * { min-width: 0; }
  img, svg, canvas, table { max-width: 100%; }

  /* ---------- header ---------- */
  header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(8, 12, 18, .94);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--bp-line);
  }
  header .wrap {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    max-width: 100%;
  }
  header .brand { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }

  /* the bottom bar is the navigation on a phone */
  header nav,
  header .burger,
  header .navtog,
  header .navscrim,
  header .out { display: none !important; }

  header .tokchip {
    margin-left: auto;
    font-size: 11px;
    padding: 5px 9px;
    border-radius: 999px;
    white-space: nowrap;
  }

  /* ---------- the stat rail ---------- */
  /* nine stacked tiles used to fill the whole first screen, so the
     page itself began below the fold. One swipeable strip instead. */
  .rail {
    display: flex !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -12px 12px;
    padding: 0 12px 2px;
  }
  .rail::-webkit-scrollbar { display: none; }

  .rail .rc {
    flex: 0 0 auto;
    width: 136px;
    min-height: 58px;
    scroll-snap-align: start;
    background: var(--bp-surface);
    border: 1px solid var(--bp-line);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: inherit;
  }
  .rail .rc.wide { width: 190px; }
  .rail .rl {
    font-size: 9.5px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--bp-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rail .rv {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .rail .rv.good { color: var(--bp-accent); }

  /* ---------- cards ---------- */
  .card {
    background: var(--bp-surface);
    border: 1px solid var(--bp-line);
    border-radius: var(--bp-radius);
    padding: var(--bp-pad);
    margin: 0 0 12px;
    box-shadow: none;
  }
  .card > h2 {
    font-size: 13px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--bp-muted);
    margin: 0 0 10px;
    font-weight: 700;
  }
  .card > h3 { font-size: 15px; margin: 0 0 8px; }
  .card > p { margin: 0 0 10px; }
  .muted { color: var(--bp-muted); }
  .sm { font-size: 13px; }
  .tiny { font-size: 11.5px; }
  .pl-pos { color: var(--bp-accent); }
  .pl-neg { color: var(--bp-red); }

  /* ---------- tables ---------- */
  .tscroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--bp-pad) * -1);
    padding: 0 var(--bp-pad);
  }
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
  }
  th, td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--bp-line);
    text-align: left;
  }
  th {
    font-size: 10px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--bp-muted);
    font-weight: 600;
  }
  tr:last-child td { border-bottom: 0; }

  /* ---------- forms ---------- */
  form label,
  .pform label,
  .fld {
    display: block;
    margin: 0 0 14px;
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--bp-muted);
    font-weight: 600;
  }
  input, select, textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 46px;
    margin: 6px 0 0;
    padding: 11px 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--bp-text);
    background: var(--bp-surface-2);
    border: 1px solid var(--bp-line);
    border-radius: 11px;
    text-transform: none;
    letter-spacing: normal;
  }
  input[type=checkbox], input[type=radio] {
    display: inline-block;
    width: 20px;
    height: 20px;
    min-height: 0;
    margin: 0 8px 0 0;
    vertical-align: middle;
  }
  select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--bp-accent);
    box-shadow: 0 0 0 3px rgba(0, 208, 156, .16);
  }
  label em, label .muted, label span.muted {
    display: block;
    text-transform: none;
    font-weight: 400;
    margin-top: 5px;
  }

  /* ---------- buttons ---------- */
  .btn, button, input[type=submit] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 46px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border-radius: 11px;
    border: 1px solid var(--bp-line);
    background: var(--bp-surface-2);
    color: var(--bp-text);
    text-decoration: none;
    cursor: pointer;
  }
  .btn::after, .btn::before { display: none !important; }
  form > .btn, form > button[type=submit] { width: 100%; }
  .btn.primary, button.primary {
    background: var(--bp-accent);
    border-color: var(--bp-accent);
    color: var(--bp-accent-ink);
  }
  .btn.danger { background: rgba(255, 95, 109, .12); border-color: rgba(255, 95, 109, .4); color: var(--bp-red); }
  .btn.tiny { min-height: 38px; padding: 9px 13px; font-size: 13px; }
  .btn[disabled] { opacity: .5; }

  /* ---------- pills and badges ---------- */
  .bppill, .badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    border: 1px solid var(--bp-line);
    background: var(--bp-surface-2);
    color: var(--bp-muted);
  }
  .bppill.on { color: var(--bp-accent); border-color: rgba(0, 208, 156, .4); background: rgba(0, 208, 156, .1); }
  .bppill.pap { color: #8fb2ff; border-color: rgba(143, 178, 255, .35); background: rgba(143, 178, 255, .1); }

  /* ---------- bot cards on /blocks ---------- */
  .bplite { padding: 12px; margin-bottom: 10px; }
  .bplite h2 {
    font-size: 15px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--bp-text);
    margin: 0 0 8px;
  }
  .bplite h2 a { color: inherit; text-decoration: none; }
  .bplite-badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 9px; }
  .bplite-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    font-size: 12.5px;
    color: var(--bp-muted);
    margin: 0 0 10px;
  }
  .bpseg { display: flex; gap: 0; margin: 0 0 9px; width: 100%; }
  .bpseg-b {
    flex: 1 1 0;
    min-height: 42px;
    padding: 9px 4px;
    font-size: 12px;
    border-radius: 0;
    border-left-width: 0;
    background: var(--bp-surface-2);
  }
  .bpseg-b:first-child { border-left-width: 1px; border-radius: 10px 0 0 10px; }
  .bpseg-b:last-child { border-radius: 0 10px 10px 0; }
  .bpseg-b.is-on { background: var(--bp-accent); border-color: var(--bp-accent); color: var(--bp-accent-ink); }
  .bpseg-b.bpseg-real.is-on { background: var(--bp-red); border-color: var(--bp-red); color: #fff; }

  /* ---------- paper-test tiles ---------- */
  .ptiles, .statgrid, .bpgrid {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .ptile, .stat {
    background: var(--bp-surface-2);
    border: 1px solid var(--bp-line);
    border-radius: 12px;
    padding: 10px;
  }
  .ptile .ptl, .stat .k {
    display: block;
    font-size: 9.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--bp-muted);
    margin: 0 0 3px;
  }
  .ptile b, .stat .v { font-size: 16px; font-weight: 700; }

  /* ---------- bottom bar ---------- */
  .bpbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 80;
    display: flex;
    align-items: stretch;
    background: rgba(9, 13, 20, .96);
    backdrop-filter: saturate(140%) blur(12px);
    border-top: 1px solid var(--bp-line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bpbar a, .bpbar .bpmore {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--bp-bar);
    padding: 8px 2px;
    background: none;
    border: 0;
    border-radius: 0;
    color: var(--bp-muted);
    font-size: 10.5px;
    font-weight: 600;
    text-decoration: none;
  }
  .bpbar svg { width: 21px; height: 21px; }
  .bpbar a.on { color: var(--bp-accent); }
  .bpbar a:active, .bpbar .bpmore:active { background: rgba(255, 255, 255, .05); }

  /* ---------- the "All pages" sheet ---------- */
  .bpsheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  .bpsheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 95;
    max-height: 74vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bp-surface);
    border-top: 1px solid var(--bp-line);
    border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(102%);
    transition: transform .22s cubic-bezier(.2, .8, .3, 1);
  }
  body.bpsheet-open .bpsheet-scrim { opacity: 1; pointer-events: auto; }
  body.bpsheet-open .bpsheet { transform: translateY(0); }
  .bpsheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--bp-line); margin: 4px auto 12px; }
  .bpsheet-title {
    font-size: 10.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--bp-muted);
    margin: 0 4px 8px;
  }
  .bpsheet-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .bpsheet-list a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 10px 12px;
    background: var(--bp-surface-2);
    border: 1px solid var(--bp-line);
    border-radius: 11px;
    color: var(--bp-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
  }
  .bpsheet-list a.on { border-color: var(--bp-accent); color: var(--bp-accent); }

  /* ---------- sign-in page ---------- */
  body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
  body.auth form, body.auth .card { width: 100%; max-width: 380px; }

  /* ---------- long bot list: search + show-more ---------- */
  .bpfilter {
    position: sticky;
    top: 52px;
    z-index: 40;
    margin: 0 0 10px;
    padding: 8px 0;
    background: var(--bp-bg);
  }
  .bpfilter input { margin: 0; }
  .bpmoreblocks { width: 100%; margin: 4px 0 8px; }
  .bphidden { display: none !important; }

  /* ---------- misc trims ---------- */
  footer { font-size: 11.5px; color: var(--bp-muted); padding: 16px 0 0; line-height: 1.5; }
  .scrollprog { display: none; }
  pre { overflow-x: auto; font-size: 12px; }
  h1 { font-size: 20px; }
  a { color: var(--bp-accent); }
  .toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
  .toolbar > * { flex: 1 1 auto; }
}

@media (max-width: 380px) {
  .bpsheet-list { grid-template-columns: 1fr; }
  .bplite-stats { grid-template-columns: 1fr; }
}

/* BP-MOB2 overrides: style.css wraps the rail into rows of two,
   which is what filled the whole first screen. Force one strip. */
@media (max-width: 820px) {
  .rail { flex-wrap: nowrap !important; align-items: stretch !important; }
  .rail .rc { width: 136px !important; min-width: 136px !important; flex: 0 0 136px !important; }
  .rail .rc.wide { width: 190px !important; min-width: 190px !important; flex: 0 0 190px !important; }
}

@media (max-width: 820px) { .bpcap { display: none !important; } }

/* An older fix turned the header nav into a page dropdown on phones.
   The bottom bar plus the All pages sheet replace it, and two menus
   on one screen is what made the navigation feel broken. */
@media (max-width: 820px) {
  header .navsel { display: none !important; }
  header .wrap { flex-wrap: nowrap !important; }
}

/* bpnav.js builds the phone bar and the All-pages sheet on EVERY screen
   size. Above the phone breakpoint they must not render at all - left
   unstyled on a desktop their icons blow up to full width. */
@media (min-width: 821px) {
  .bpbar, .bpsheet, .bpsheet-scrim { display: none !important; }
}

/* BP-MOB3 2026-08-30
   1. body::before is a fixed, 120%-tall, animated, blur(6px) aura and
      body::after a masked grid overlay. On a phone that is a full-screen
      composited layer being repainted forever - the most likely reason a
      loaded page still showed as an empty card. Phones do not need it.
   2. Belt and braces for the sign-in page: nothing there may depend on an
      animation, a gradient text clip or a script to become visible. */
@media (max-width: 820px) {
  body::before, body::after { display: none !important; }

  body.auth { min-height: 100svh; }
  body.auth h1, body.auth h1 * {
    -webkit-text-fill-color: currentColor !important;
    opacity: 1 !important;
    animation: none !important;
  }
  body.auth h1 { color: #fff !important; background: none !important; }
  body.auth h1 span { color: var(--bp-accent) !important; }
  body.auth .card, body.auth form, body.auth label, body.auth .btn {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }
}

/* BP-MOB3b: the "N shown" counter sat inline against the first checkbox */
@media (max-width: 820px) {
  #bpfindn { display: block; margin: 8px 0 6px; }
  label.bpronly {
    display: flex !important;
    align-items: center;
    gap: 9px;
    margin: 0 0 10px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--bp-text);
  }
  label.bpronly input[type=checkbox] { margin: 0; flex: 0 0 auto; }
}

/* BP-MOB3c: the bot list on a phone.
   style.css:1239 hides every card child except the first two and the last,
   which is what removed the Off/Test/Real switch and the per-bot numbers on
   a phone, and the 2-up grid squeezed each card to 183px. One bot per row,
   controls back, and Minimise really does collapse to a line again. */
@media (max-width: 820px) {
  .bpgrid { grid-template-columns: 1fr !important; }
  .bpgrid > .card.bplite { min-height: 0 !important; max-height: none !important; }
  .bpgrid > .card.bplite > .bplite-stats { display: grid !important; }
  .bpgrid > .card.bplite > .bpseg { display: flex !important; }
  .bpgrid > .card.bplite > .muted.sm { display: block !important; }

  body.bpminion .bpgrid > .card.bplite { padding: 8px 10px !important; margin-bottom: 6px !important; }
  body.bpminion .bpgrid > .card.bplite > h2 { margin: 0 0 6px !important; font-size: 13.5px !important; }
  body.bpminion .bpgrid > .card.bplite > .bplite-badges,
  body.bpminion .bpgrid > .card.bplite > .bplite-stats,
  body.bpminion .bpgrid > .card.bplite > .muted.sm,
  body.bpminion .bpgrid > .card.bplite > .btn { display: none !important; }
}

/* BP-MOB3d: the bot cards carry content-visibility:auto with
   contain-intrinsic-size: auto 700px. The real card on a phone is ~260px
   (~105px minimised), so every off-screen bot was reserving 440px of empty
   scroll - the whole list measured 219,000px instead of 82,000px and the
   scrollbar was meaningless. Give the placeholder the real number. */
@media (max-width: 820px) {
  .bpgrid > .card.bplite { contain-intrinsic-size: auto 288px !important; }
  body.bpminion .bpgrid > .card.bplite { contain-intrinsic-size: auto 130px !important; }
}

/* BP-HISTMOB: trade history on phones */
@media (max-width:820px){
  h3.bphead{font-size:13.5px;line-height:2;overflow-wrap:anywhere}
  .bpdet .tscroll{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -14px;padding:0 14px}
  .bpdet table.logs{min-width:860px;font-size:12px}
  .bpstat{font-size:11.5px !important}
  .bpstat span{padding:2px 8px !important}
}
/* BP-HISTMOB2: style.css's phone transform for table.logs was built for the
   3-column logs table; the 13-column trade tables inside .bpdet lost their
   headers and every value stacked unlabeled. Restore real table + side scroll. */
@media (max-width:900px){
  .bpdet{overflow:visible}
  .bpdet .tscroll{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .bpdet table.logs{display:table;width:auto;min-width:900px;font-size:12px}
  .bpdet table.logs tbody{display:table-row-group}
  .bpdet table.logs tr{display:table-row;border-bottom:0;padding:0}
  .bpdet table.logs tr:first-child th{display:table-cell;font-size:10px;padding:7px 8px}
  .bpdet table.logs td{display:table-cell;border-bottom:1px solid var(--line);padding:7px 8px;white-space:nowrap;font-size:12px;margin:0}
  .bpdet table.logs td:nth-child(3):not(:last-child){display:table-cell}
}
/* BP-MVNROW: Mirror-vs-normal card table as a single scrolling row per bot (like the order book), not stacked */
@media (max-width:900px){
  .bpmvn{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -14px;padding:0 14px}
  .bpmvn table.logs{display:table;width:auto;min-width:720px;font-size:12px}
  .bpmvn table.logs tbody{display:table-row-group}
  .bpmvn table.logs tr{display:table-row;border-bottom:0;padding:0}
  .bpmvn table.logs tr:first-child th{display:table-cell;font-size:10px;padding:7px 8px;white-space:nowrap}
  .bpmvn table.logs td{display:table-cell;border-bottom:1px solid var(--line);padding:7px 8px;white-space:nowrap;font-size:12px;margin:0}
  .bpmvn table.logs td:nth-child(3):not(:last-child){display:table-cell}
}
/* BP-PTUI: paper-test stats as one-liners on phones (label left, value right) */
@media (max-width:820px){
  .ptiles,.statgrid{grid-template-columns:1fr !important;gap:6px !important}
  .ptile,.stat{display:flex !important;flex-direction:row !important;justify-content:space-between !important;align-items:baseline !important;padding:8px 12px !important;border-radius:8px !important;gap:10px !important}
  .ptile .ptl,.stat .k{display:inline !important;margin:0 !important;font-size:11px !important;flex:1 1 auto}
  .ptile b,.stat .v{font-size:14px !important;text-align:right;white-space:nowrap}
}

/* BP-PTBL: "Trades taken that day" / opposite-way / at-the-same-time tables on the
   paper-test result page use class="logs ptbl" inside .ptblwrap. style.css's phone
   transform for table.logs stacks them into tall blocks. .ptblwrap already scrolls
   sideways on desktop (min-width:960px), so restore display:table on phones and let it
   swipe horizontally the same way the mirror-vs-normal table does (BP-MVNROW). */
@media (max-width:900px){
  .ptblwrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .ptblwrap table.logs{display:table;width:auto}
  .ptblwrap table.logs tbody{display:table-row-group}
  .ptblwrap table.logs tr{display:table-row;border-bottom:0;padding:0}
  .ptblwrap table.logs tr:first-child th{display:table-cell;font-size:10px;padding:7px 8px;white-space:nowrap}
  .ptblwrap table.logs td{display:table-cell;border-bottom:1px solid var(--line);padding:7px 8px;white-space:nowrap;font-size:12px;margin:0}
  .ptblwrap table.logs td:nth-child(3):not(:last-child){display:table-cell}
}
