/* ===========================================================================
   Phone layout — app-shell, not a squeezed website.
   Loaded after app.css, and everything is inside the media query, so the
   desktop layout is untouched.

   Shell: three fixed rows (top bar / scrolling view / tab bar). The page
   itself never scrolls, only #view does, so the bars cannot move, cannot be
   dragged by iOS rubber-banding, and cannot jump when the URL bar collapses.
   =========================================================================== */
/* The app-shell layout is for touch devices only. A narrow desktop window keeps the
   original responsive layout (whole-page scroll) — see app.css. */
/* More sheet */
.more-sheet .dlg-foot{display:none;}
.more-sheet .dlg-body{padding:6px 10px calc(14px + env(safe-area-inset-bottom));}
.more-list{display:flex;flex-direction:column;}
.more-row{
  display:flex;align-items:center;gap:14px;width:100%;min-height:54px;padding:0 12px;
  background:none;border:none;border-radius:12px;font-size:16px;font-weight:600;color:var(--ink);text-align:left;cursor:pointer;
}
.more-row .ic{width:22px;height:22px;color:var(--ink-3);flex-shrink:0;}
.more-row:active{background:var(--surface-2);}
.more-row[aria-current="page"]{color:var(--accent);background:var(--accent-soft);}
.more-row[aria-current="page"] .ic{color:var(--accent);}
.more-row.is-danger,.more-row.is-danger .ic{color:var(--crit);}


@media (max-width:900px) and (pointer:coarse){
  html,body{height:100%;overflow:hidden;overscroll-behavior:none;}
  body{
    -webkit-tap-highlight-color:transparent;
    -webkit-touch-callout:none;
    -webkit-text-size-adjust:100%;
  }
  a,button,summary,select,[role="button"],label{touch-action:manipulation;}
  .topbar,.tabbar,.rail,.btn,.pg,.lrow,.tabbar a{-webkit-user-select:none;user-select:none;}

  /* sign-in: the page no longer scrolls, so the card must (small phones + keyboard) */
  .login-wrap{position:fixed;inset:0;overflow-y:auto;-webkit-overflow-scrolling:touch;place-items:start center;padding:max(24px,env(safe-area-inset-top)) 16px 40px;}
  .login-card{margin:auto 0;}

  /* ── shell ── */
  .app.is-on{display:flex;flex-direction:column;height:100dvh;min-height:0;}
  .main{flex:1;min-height:0;display:flex;flex-direction:column;padding-bottom:0;}
  .view{
    flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
    -webkit-overflow-scrolling:touch;overscroll-behavior-y:contain;
    scroll-padding-bottom:24px;
    padding:14px 14px calc(96px + env(safe-area-inset-bottom));
  }

  /* ── top bar ── */
  .topbar{
    position:relative;flex-shrink:0;height:auto;min-height:calc(48px + env(safe-area-inset-top));
    padding:env(safe-area-inset-top) 10px 0 16px;gap:2px;
    background:color-mix(in srgb,var(--surface) 88%,transparent);
    -webkit-backdrop-filter:saturate(1.4) blur(14px);backdrop-filter:saturate(1.4) blur(14px);
    border-bottom:1px solid var(--line);
  }
  .crumb{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
  .crumb b{font-size:19px;font-weight:800;letter-spacing:-.01em;}
  #theme-btn,#appearance-btn{display:none;}   /* still in Settings -> Appearance */
  .topbar .btn-icon,.cmdk-trigger{width:44px;height:44px;min-width:44px;border-radius:50%;border:none;background:transparent;padding:0;justify-content:center;}
  .topbar .btn-icon .ic,.cmdk-trigger .ic{width:21px;height:21px;}
  .cmdk-trigger kbd{display:none;}
  .topbar .btn:active,.cmdk-trigger:active{background:var(--surface-2);}
  #refresh-btn.is-spinning .ic{animation:aa-spin .7s linear infinite;}
  @keyframes aa-spin{to{transform:rotate(360deg);}}

  /* ── bottom tab bar: always there, never scrolls ── */
  .tabbar{
    position:fixed;left:0;right:0;bottom:0;z-index:60;display:flex;
    padding:6px 6px calc(6px + env(safe-area-inset-bottom));
    background:color-mix(in srgb,var(--surface) 90%,transparent);
    -webkit-backdrop-filter:saturate(1.5) blur(18px);backdrop-filter:saturate(1.5) blur(18px);
    border-top:1px solid var(--line);
    transform:translateZ(0);will-change:transform;
  }
  .tabbar a{
    position:relative;flex:1;min-width:0;min-height:52px;gap:3px;justify-content:center;
    font-size:10.5px;font-weight:600;letter-spacing:.01em;border-radius:14px;background:none !important;
    transition:color .15s;
  }
  .tabbar a .ic{width:24px;height:24px;transition:transform .18s cubic-bezier(.3,1.4,.5,1);}
  .tabbar a:active .ic{transform:scale(.86);}
  .tabbar a[aria-current="page"]{color:var(--accent);}
  .tabbar a[aria-current="page"] .ic{transform:translateY(-1px) scale(1.06);}
  .tabbar a[aria-current="page"]::before{
    content:"";position:absolute;top:-7px;left:50%;width:26px;height:3px;margin-left:-13px;
    border-radius:0 0 3px 3px;background:var(--accent);
  }
  .toasts{bottom:calc(76px + env(safe-area-inset-bottom));}

  /* ── touch targets & forms (16px stops iOS zooming into a field) ── */
  .btn{min-height:44px;padding:10px 16px;font-size:14px;border-radius:12px;}
  .btn-sm{min-height:38px;padding:8px 13px;}
  .btn:active:not(:disabled){transform:scale(.97);}
  .field input,.field select,.field textarea,select.f,input[type="search"],input[type="text"],input[type="email"],input[type="password"],input[type="tel"],input[type="number"],textarea{font-size:16px;min-height:44px;}
  select.f{padding:9px 14px;}
  .perm{min-height:44px;}
  .pager .pg{min-width:40px;height:40px;font-size:13px;border-radius:10px;}

  /* ── lists: tappable cards with instant press feedback ── */
  a.lrow{padding:14px 16px;transition:background .06s;}
  a.lrow:hover{background:transparent;}
  a.lrow:active{background:var(--surface-2);}
  .lrow .nm{font-size:15px;}
  .lrow .r2{font-size:13px;}
  .lead-list{border-bottom:none;}

  /* ── detail screens: back stays reachable ── */
  .dhead{position:sticky;top:0;z-index:15;padding:12px 14px;}
  .dback{min-height:44px;padding:0 6px 0 0;font-size:14px;}
  .detail{overscroll-behavior-y:contain;}

  /* ── dialogs become bottom sheets ── */
  dialog:not(.mv){
    position:fixed;inset:auto 0 0 0;margin:0;width:100%;max-width:none;
    max-height:min(92dvh,100% - env(safe-area-inset-top));
    border-radius:20px 20px 0 0;border-bottom:none;
    padding-bottom:env(safe-area-inset-bottom);
    animation:aa-sheet .26s cubic-bezier(.2,.9,.3,1);
  }
  dialog:not(.mv)[open]{display:flex;flex-direction:column;}
  dialog:not(.mv)::before{
    content:"";display:block;width:38px;height:4px;border-radius:2px;background:var(--line-2);margin:8px auto 0;flex-shrink:0;
  }
  dialog:not(.mv) .dlg-body{flex:1;min-height:0;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;}
  dialog:not(.mv) .dlg-foot{position:sticky;bottom:0;background:var(--surface);border-top:1px solid var(--line);}
  dialog:not(.mv) .dlg-foot .btn{flex:1;}
  dialog::backdrop{animation:aa-fade .2s ease;}
  dialog.mv{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0;border:none;}
  @keyframes aa-sheet{from{transform:translateY(100%);}to{transform:none;}}
  @keyframes aa-fade{from{opacity:0;}to{opacity:1;}}

  /* search palette = full-height sheet */
  .overlay{padding:0;place-items:end stretch;}
  .cmdk{width:100%;max-height:88dvh;border-radius:20px 20px 0 0;padding-bottom:env(safe-area-inset-bottom);animation:aa-sheet .26s cubic-bezier(.2,.9,.3,1);}
  .cmdk-in input{font-size:16px;}
  .cmdk-opt{min-height:48px;}
  .cmdk-foot{display:none;}

  /* ── screen change + pull-to-refresh ── */
  .view.is-entering{animation:aa-enter .22s cubic-bezier(.2,.8,.3,1);}
  @keyframes aa-enter{from{opacity:.0;transform:translateY(8px);}to{opacity:1;transform:none;}}
  .ptr{
    position:absolute;left:50%;top:calc(env(safe-area-inset-top) + 52px);z-index:40;
    width:36px;height:36px;margin-left:-18px;border-radius:50%;
    background:var(--surface);border:1px solid var(--line);box-shadow:var(--sh-2);
    display:grid;place-items:center;color:var(--accent);
    transform:translateY(-70px);opacity:0;pointer-events:none;
  }
  .ptr .ic{width:18px;height:18px;}
  .ptr.is-loading .ic{animation:aa-spin .7s linear infinite;}
  .skip{display:none;}
}

/* installed to the home screen: the status bar is translucent, so keep clear of it */
@media (display-mode: standalone) and (max-width:900px) and (pointer:coarse){
  .login-wrap{padding-top:calc(24px + env(safe-area-inset-top));}
}
@media (prefers-reduced-motion: reduce){
  .view.is-entering,dialog,.cmdk,dialog::backdrop{animation:none !important;}
  .tabbar a .ic{transition:none;}
}
