/* Phone navigation (UI build U5a, web/phone-nav.js): a bottom bar, a short header and the More sheet at 600 px and
 * narrower. Wider screens keep the tab rows; nothing below shows there. Touch targets are at least 44 px. */
#phone-nav, #pn-title, #pn-search, #pn-profile { display: none; }

@media (max-width: 600px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

  /* The tab rows stop scrolling sideways: the bottom bar and More replace them. */
  .tabs, .subtabs { display: none !important; }

  /* Header: logo, the market as the page title, search, Ask FRAME, profile. */
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 6px 10px; min-height: 52px; }
  .brand { flex: 0 0 auto; }
  .brand .divider, .brand .product { display: none; }
  #pn-title { display: block; flex: 1 1 auto; min-width: 0; color: #fff; font-weight: 700; font-size: 16px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { gap: 6px; flex: 0 0 auto; }
  .topbar-right .who-chip, .topbar-right .market-picker, #signout-btn { display: none !important; }
  #agent-open { padding: 0 10px; min-height: 40px; font-size: 13px; }
  .pn-icon { display: inline-flex !important; align-items: center; justify-content: center; width: 40px; height: 40px;
    border-radius: 10px; border: 1px solid #3a3a3a; background: #1a1a1a; color: #fff; cursor: pointer; padding: 0; }
  .pn-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .pn-profile::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor;
    box-shadow: 0 9px 0 -3px currentColor; transform: translateY(-3px); }
  .pn-icon:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  /* Search opens as its own row under the header. */
  .gs-wrap { display: none !important; }
  body.pn-search-open .gs-wrap { display: block !important; position: fixed; left: 8px; right: 8px; top: 58px; z-index: 40; margin: 0; max-width: none; }

  /* The bottom bar */
  #phone-nav { display: grid; grid-template-columns: repeat(var(--pn-cols, 5), minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 1500; background: var(--black); border-top: 1px solid #2a2a2a;
    padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
  .pn-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px;
    background: none; border: 0; color: #b8bcc2; font: 600 11px/1.1 inherit; cursor: pointer; border-radius: 10px; }
  .pn-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
  .pn-btn[data-pn="more"] svg { fill: currentColor; stroke: none; }
  .pn-btn.on { color: var(--gold); }
  .pn-btn { position: relative; }
  .pn-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--no); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
  .pn-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
  /* A drawer or sheet that rises from the bottom takes the bar's place while it is open, so nothing of it is covered:
     the site drawer (web/v2.css), the parcel sheet (web/parcel-sheet.css) and the rule drawer when it floats
     (web/markets.css). Closing it brings the bar back. */
  body.v2-drawer-open #phone-nav, body.ps-open #phone-nav, body:has(#mk-drawer:not([hidden]):not(.mk-inline)) #phone-nav { display: none; }
  body.v2-drawer-open, body.ps-open { padding-bottom: 0; }
  /* Things pinned to the bottom of the page sit above the bar. */
  .df-open-note { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

/* More: a sheet from the bottom */
.pn-sheet { width: 100vw; max-width: 100vw; max-height: 85vh; margin: auto 0 0; border: 0; border-radius: 16px 16px 0 0; padding: 0 0 calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--panel); color: var(--ink); overflow: auto; box-shadow: 0 -10px 40px rgba(0,0,0,.3); }
.pn-sheet::backdrop { background: rgba(13,13,13,.6); }
.pn-sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.pn-sheet-head h2 { font-size: 18px; margin: 0; }
.pn-x { border: 0; background: none; font-size: 28px; line-height: 1; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--ink); }
.pn-market { display: grid; gap: 6px; padding: 12px 16px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.pn-market select { min-height: 44px; font: inherit; font-size: 15px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel); }
.pn-group { padding: 8px 16px 0; }
.pn-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 4px; }
.pn-item { display: block; width: 100%; min-height: 44px; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); font: inherit; font-size: 15px; color: var(--ink); cursor: pointer; padding: 8px 2px; }
.pn-item:focus-visible, .pn-x:focus-visible { outline: 2px solid var(--gold-dk); outline-offset: 2px; }

/* Profile menu */
.pn-menu { position: fixed; top: 54px; right: 8px; z-index: 1600; min-width: 200px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 6px; }
.pn-menu-who { padding: 10px 12px; font-weight: 700; color: var(--gold-dk); }
.pn-menu-item { display: block; width: 100%; min-height: 44px; text-align: left; border: 0; background: none; font: inherit; font-size: 15px; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.pn-menu-item:hover, .pn-menu-item:focus-visible { background: var(--muted-bg); }
