/* ---------- Phone browse pages ----------
 * Every browse page (sign in, nav, Home, Workouts, workout page, Plans, Exercises, dialogs, Settings, builder) at up to
 * 600 px wide (PHONE_PAGES_QUERY in core/nav.js). Every rule here is inside the one media query below, so the desktop
 * rules in style.css, home.css and plans.css are neither used differently nor changed above 600 px.
 * Design: docs/superpowers/specs/2026-11-06-mobile-browse-design.md. */
@media (max-width: 600px) {
  /* Sign-in screen: top-anchored, no card, so the Sign in button sits above the keyboard at 390 x 664. */
  .signin { width: auto; margin: 0; padding: 16px 16px 24px; background: transparent; box-shadow: none; border-radius: 0; gap: 10px; }
  .signin-form label { margin-top: 2px; }
  .signin-submit { margin-top: 10px; }
  .signin-alt { margin-top: 6px; }

  /* Top bar: one row, brand on the left, Account and Settings on the right. The page links live in the tab bar. */
  .topnav { flex-wrap: nowrap; min-height: 52px; padding: 4px 12px; gap: 8px; }
  .topnav nav[aria-label="Main"] { display: none; }
  .topnav .btn.sm { min-height: 44px; white-space: nowrap; }
  /* The Account button reads "Account" and shows a dot when sync wants attention (core/nav.js accountButton). */
  [data-account-button] .acct-label { display: none; }
  [data-account-button]::before { content: 'Account'; }
  [data-account-button][data-attention="true"]::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }

  /* Tab bar: fixed to the bottom edge, 56 px plus the home-indicator inset; icons and labels sit low. */
  .topnav nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; height: calc(56px + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
  .topnav nav.tabbar a { flex: 1; min-height: 0; border-bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; padding-bottom: 2px; font-size: 11px; font-weight: 700; color: var(--ink-2); text-decoration: none; }
  .topnav nav.tabbar a[aria-current="page"] { color: var(--orange); border-bottom: 0; }
  .topnav nav.tabbar a .ic { width: 22px; height: 22px; }
  /* Pages end above the bar; the notice sits above it too. */
  .page, .plan-page, #builder.builder { padding-bottom: calc(56px + env(safe-area-inset-bottom) + 24px); } /* #plans also carries .builder; its .plan-page pads itself */
  body:has(#topnav:not([hidden])) #notice { bottom: calc(56px + env(safe-area-inset-bottom) + 12px); max-width: calc(100vw - 24px); } /* not on the player, which has no bar */

  /* Home: the next plan day plays from the Continue card; workout rows get a 48 px Play and two-line titles. */
  .continue { flex-wrap: wrap; }
  .continue .acts { display: flex; gap: 8px; width: 100%; }
  .continue .continue-play { display: inline-flex; flex: 1; justify-content: center; min-height: 48px; }
  .continue .acts a.btn { flex: 0 0 auto; min-height: 48px; }
  .wk-card .wk-play { width: 48px; min-height: 48px; }
  .wk-card .tt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .plan-row .btn.sm { min-height: 44px; }
  /* "Browse all →" is 18 px of text; the padding and negative margin give it a 44 px thumb target without moving it. */
  .home-section .lbl a { padding: 13px 0; margin: -13px 0 -13px auto; }

  /* Workout page: back link, a shorter cover, then Play full width on the first screen; the rest in today's order. */
  .page.detail { display: flex; flex-direction: column; gap: 12px; }
  .page.detail > * { margin: 0; }
  .page.detail .back-link { order: -3; }
  .page.detail .detail-cover { order: -2; min-height: 130px; }
  .page.detail .detail-actions { display: contents; }
  .page.detail .detail-play { order: -1; display: block; }
  .page.detail .detail-play .btn { width: 100%; min-height: 56px; font-size: 17px; justify-content: center; }
  .page.detail .detail-actions > .btn { width: 100%; justify-content: center; }
  .page.detail .detail-section { margin-top: 10px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .detail-step .meta { text-align: left; }
  .detail-step .name.link { min-height: 44px; }
  .detail-step .btn.sm, .poster .acts .btn { min-height: 44px; }

  /* Plans: the primary action full width, the other buttons sharing rows at 44 px and wrapping. */
  .plan-actions .btn { min-height: 44px; flex: 1 1 40%; justify-content: center; white-space: nowrap; }
  .plan-actions .btn.primary { flex-basis: 100%; min-height: 56px; font-size: 17px; }
  .plan-page progress { width: 100%; }

  /* Exercises: touch sizes for the search field and the filter chips. */
  .ex-filters .search { min-height: 48px; }
  .ex-filters .chip { min-height: 44px; }

  /* Dialogs become sheets: anchored to the bottom edge, full width, scrolling inside, buttons stacked full width with
   * the primary on top. A tap on the backdrop closes them (ui/sheet.js). */
  .dlg, .exercise-detail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: none; max-height: 90dvh; margin: 0; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheet-in 200ms ease-out; overscroll-behavior: contain; }
  /* A drag down inside an open sheet scrolls the sheet, never the browser's pull-to-refresh behind it. */
  body:has(dialog[open]) { overscroll-behavior-y: none; }
  /* The X in the sheet header: a 44 px target at the top right, where a sheet is expected to close. */
  .dlg-close { display: inline-flex; position: absolute; top: -6px; right: -8px; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; }
  .dlg-close:active { background: var(--line-2); color: var(--ink); }
  .dlg-head h2 { padding-right: 44px; }
  .dlg::before, .exercise-detail::before { content: ''; display: block; width: 40px; height: 4px; margin: 10px auto 0; border-radius: 2px; background: var(--line); }
  .exercise-detail::before { position: sticky; top: 8px; z-index: 1; }
  .dlg-body { padding: 16px 20px 6px; }
  .dlg-actions { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 20px 20px; }
  .dlg-actions .primary { order: -1; } /* the primary action on top; Cancel or Close keeps its place at the end */
  .dlg-actions .btn, .dlg-actions .rbtn, .dlg-stack .btn { width: 100%; min-height: 48px; justify-content: center; }
  .dlg.settings, .plan-preview { width: 100%; }
  .exercise-detail header, .exercise-detail footer { padding: 12px 20px; }
  .exercise-detail header .btn.sm { min-height: 44px; }
  .detail-body { padding: 4px 20px 16px; }
  /* Settings: theme cards as rows with a small preview, so all five fit on one screen. */
  .theme-grid { grid-template-columns: 1fr; gap: 8px; }
  .theme-card { flex-direction: row; align-items: center; gap: 12px; padding: 6px 10px 6px 6px; min-height: 64px; }
  .theme-card .mini { width: 72px; height: 48px; flex: none; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
  .theme-card .mini .hero, .theme-card .mini .side { display: none; }
  .theme-card .mini::after { content: '0:42'; font-weight: 900; font-size: 16px; color: var(--accent-text); }
  .theme-card .name, .theme-card .blurb { padding: 0; }
  .theme-card .name { flex: none; }
  .theme-card .blurb { flex: 1; min-width: 0; }
  .sound-tests .btn { min-height: 44px; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }

  /* Builder and plan editor, last: one column, 44 px controls, the library as a sheet. Functional by touch, not pretty. */
  .b-header { padding: 10px 12px; gap: 8px; }
  .b-header .wname { flex-basis: 100%; min-height: 44px; }
  .b-header .btn { min-height: 44px; }
  .b-sub { padding: 8px 12px; }
  .b-sub select, .b-sub .btn { min-height: 44px; max-width: 100%; }
  .b-body { padding: 12px; gap: 12px; }
  .library { display: none; }
  .sections { flex-basis: 100%; }
  .s-head { flex-wrap: wrap; }
  .bk-head { padding: 8px 12px; }
  .bk-head select, .bk-head input, .bk-head .btn, .bk-head .btn.icon { min-height: 44px; }
  .bk-head .btn.icon { width: 44px; height: 44px; }
  .step { flex-wrap: wrap; padding: 8px 12px; row-gap: 6px; }
  .step .step-content { flex-basis: 100%; }
  .step .handle { display: none; }
  .step select, .step input, .step .btn, .step .btn.icon { min-height: 44px; }
  .step .btn.icon { width: 44px; height: 44px; }
  .bk-foot { flex-wrap: wrap; }
  .bk-foot .btn { min-height: 44px; }
  .bk-foot .add-exercise { display: inline-flex; }
  .builder .btn, .builder .dashed, .builder .addblock, .s-head .sname { min-height: 44px; }
  .builder .btn.icon { width: 44px; height: 44px; }
  .library-sheet .library { display: flex; position: static; max-width: none; }
  .library-sheet .cards { max-height: none; }
  .library-sheet .library-item .btn.sm { min-height: 44px; }
  .plan-add label { flex-basis: 100%; }
  .plan-add .btn { flex: 1 1 40%; min-height: 44px; }
  .plan-week-heading .plan-actions .btn { min-height: 44px; }
}
