/* v157 phones and small tablets: loaded last on app.html and admin.html. Desktop is never touched (every rule is
   inside a max-width query). Keeps the current look; fixes fit, overflow and touch targets. */

@media (max-width: 760px) {
  :root { --bar-h: 62px; --pill-gap: 12px; }

  /* ---------- floating glass pill bottom bar (workspace) ---------- */
  body.m-has-nav .m-nav {
    left: var(--pill-gap); right: var(--pill-gap); bottom: calc(var(--pill-gap) + var(--safe-b));
    height: var(--bar-h); padding: 0 6px; border-radius: 999px; align-items: center;
    background: rgb(255 255 255 / .66) !important;
    -webkit-backdrop-filter: saturate(190%) blur(22px); backdrop-filter: saturate(190%) blur(22px);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .95), inset 0 0 0 1px rgb(255 255 255 / .55), 0 0 0 1px rgb(1 21 55 / .07), 0 18px 40px -14px rgb(1 21 55 / .38) !important;
    animation: mPillIn .45s cubic-bezier(.2, .9, .3, 1.15) both;
  }
  @keyframes mPillIn { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
  .m-nav a, .m-nav button { position: relative; height: 50px; margin: 0 2px; border-radius: 999px; font-size: 11px; gap: 2px; color: #5d6880; transition: color .2s, background .25s; }
  .m-nav a.on { color: var(--brand); background: rgb(255 255 255 / .85); box-shadow: 0 4px 14px -6px rgb(1 21 55 / .3), inset 0 0 0 1px rgb(255 255 255 / .9); }
  .m-nav .m-new, .m-nav .m-new.on { background: none !important; box-shadow: none !important; }
  .m-nav .m-new svg { width: 48px; height: 48px; padding: 12px; margin-top: -26px; box-shadow: 0 0 0 4px rgb(255 255 255 / .9), 0 10px 22px rgb(0 85 236 / .45); }
  body.m-has-nav .main { padding-bottom: calc(var(--bar-h) + var(--pill-gap) * 2 + var(--safe-b) + 24px); }
  /* the help chat bubble and toasts sit above the pill */
  body.m-has-nav .toast-wrap { bottom: calc(var(--bar-h) + var(--pill-gap) * 2 + var(--safe-b)); }
  body.m-has-nav .lp-chat-btn, body.m-has-nav .chat-fab { bottom: calc(var(--bar-h) + var(--pill-gap) * 2 + var(--safe-b)) !important; }

  /* the listing editor's tool bar floats the same way */
  .m-bar {
    left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); height: var(--bar-h); padding: 0 6px; border-radius: 26px;
    background: rgb(255 255 255 / .72) !important; -webkit-backdrop-filter: saturate(190%) blur(22px); backdrop-filter: saturate(190%) blur(22px);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .95), 0 0 0 1px rgb(1 21 55 / .07), 0 18px 40px -14px rgb(1 21 55 / .38) !important;
  }
  .m-bar button { height: 52px; }
  body.m-editing .main { padding-bottom: calc(var(--bar-h) + 16px + var(--safe-b) + 24px); }

  /* ---------- generic fit fixes ---------- */
  html, body { overflow-x: clip; }
  .main { min-width: 0; }
  .main > * { max-width: 100%; }
  img, video, canvas, iframe { max-width: 100%; }
  pre, code { white-space: pre-wrap; overflow-wrap: anywhere; }
  table { max-width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  h1, h2, h3 { overflow-wrap: break-word; text-wrap: balance; }
  input, select, textarea { font-size: 16px !important; } /* no zoom-in on focus in iOS */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .row { flex-wrap: wrap; }
  .page-head { flex-wrap: wrap; }
  .page-head > div:first-child { flex: 1 1 100%; min-width: 0; }
  .grid-2, .grid-3, .two-col { grid-template-columns: minmax(0, 1fr) !important; }
  .modal-bg > .modal { max-width: 100%; }
  .crumb { display: inline-flex; align-items: center; min-height: 36px; }

  /* Settings: the grouped tab bar scrolls sideways inside its own box */
  .set-tabs, .settings-tabs, .set-nav { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; overflow-y: hidden !important; overscroll-behavior-x: contain; scrollbar-width: none; max-width: 100%; gap: 6px; scroll-snap-type: x proximity; }
  .set-tabs::-webkit-scrollbar, .settings-tabs::-webkit-scrollbar, .set-nav::-webkit-scrollbar { display: none; }
  .set-grp { flex: 0 0 auto; scroll-snap-align: start; }

  /* New listing: sections never wider than the screen */
  .cx-sec, .cx-get, .cx-recent, .home-listing, .tm-hero, .home-hero, .home-sec { min-width: 0; max-width: 100%; }
  .cx-get { overflow-x: auto; scrollbar-width: none; }
  .home-hero-main, .tm-meters, .tm-hero-side { min-width: 0; }
  .tm-meters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
}

@media (max-width: 380px) {
  :root { --pill-gap: 8px; }
  .m-nav a, .m-nav button { font-size: 10.5px; margin: 0 1px; }
  .main { padding-left: 12px; padding-right: 12px; }
  .page-head h1 { font-size: 21px; }
  .tm-meters { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (prefers-reduced-motion: reduce) { body.m-has-nav .m-nav { animation: none; } }

/* sideways tab rows fade at the right edge so it's clear they scroll */
@media (max-width: 760px) {
  .jumpbar, .set-nav, .ad-tabs, .st-tabs { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .jumpbar > :last-child, .set-nav > :last-child, .ad-tabs > :last-child, .st-tabs > :last-child { margin-right: 24px; }
}
@media (max-width: 760px) {
  .lp-gens { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .lp-gen b { font-size: 13.5px; }
  .lp-srcs { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 24px; }
  .lp-src { padding: 16px; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; }
  .lp-src .lp-src-ic { grid-row: 1 / 3; margin: 0; }
  .lab-meter { order: 3; }
}

/* Admin on phones: blog rows stack, tables scroll inside their card, cards never push past the screen */
@media (max-width: 760px) {
  .card, .stat, .two-col > *, .stats-grid > * { min-width: 0; }
  .table-wrap { max-width: 100%; }
  .table-wrap table { min-width: max-content; }
  .table-wrap td, .table-wrap th { white-space: nowrap; }
  .table-wrap td .muted, .table-wrap td div { white-space: normal; }
  .ab-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); grid-auto-flow: row; align-items: start; column-gap: 12px; row-gap: 6px; }
  .ab-thumb { width: 72px; height: 52px; grid-row: 1 / span 3; }
  .ab-main { grid-column: 2; }
  .ab-row > .badge { grid-column: 2; justify-self: start; }
  .ab-ex { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ab-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ab-two { grid-template-columns: minmax(0, 1fr); }
  .ai-bars { overflow-x: auto; scrollbar-width: none; }
  .stats-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
}
@media (max-width: 360px) { .stats-grid { grid-template-columns: minmax(0, 1fr) !important; } }
@media (max-width: 760px) {
  .funnel-card > .row select { flex: 1 1 100%; }
  .fn-row { row-gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .fn-row:last-child { border-bottom: 0; }
  .ab-tabs, .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .ab-tabs > *, .seg > * { flex: 0 0 auto; }
}
@media (max-width: 760px) {
  /* small summary tables (no header row) fit the card instead of scrolling */
  .table-wrap table:not(:has(thead)) { min-width: 0; width: 100%; }
  .table-wrap table:not(:has(thead)) td { white-space: normal; padding-left: 6px; padding-right: 6px; }
  .ai-strip { display: grid !important; gap: 4px; }
  .ai-strip .spacer { display: none; }
  .ai-strip > :last-child, .ai-strip { color: inherit; }
}
@media (max-width: 760px) { .hist-more { width: 100%; min-height: 48px; margin-top: 4px; } }
/* setup wizard header on phones: step badge + skip on one line, progress bar full width below */
@media (max-width: 760px) {
  .wizard-top { display: grid !important; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
  .wizard-top .badge { white-space: nowrap; }
  .wizard-top .wiz-bar { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .wizard-top > span.small { display: none; }
  .wizard-top #skipAll { white-space: nowrap; }
}
@media (max-width: 760px) { .tour-pop { width: calc(100vw - 24px) !important; max-height: 46vh; overflow-y: auto; border-radius: 20px; } }
