/* Phone-only shell. Tablet and desktop styles remain authoritative. */
.mobile-score-tabs,.mobile-score-types,.mobile-manual-list-heading,.mobile-new-song,.mobile-device-note,.mobile-reader-header,.mobile-reader-scroll,.mobile-bottom-nav{display:none}

@media (max-width:600px){
  :root{--mobile-safe-bottom:max(12px,env(safe-area-inset-bottom));--mobile-nav-height:64px}
  html,body{max-width:100%;overflow-x:hidden}
  body:not(.private-image-workbench):not(.score-creation-app){padding-bottom:calc(var(--mobile-nav-height) + var(--mobile-safe-bottom))}
  a,button,input,select,summary{touch-action:manipulation}
  button,a,.mobile-keypad-disclosure summary{min-height:44px}

  .mobile-bottom-nav{display:grid;grid-template-columns:1fr 1fr 64px;position:fixed;z-index:90;right:0;bottom:0;left:0;height:calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));padding:0 12px var(--mobile-safe-bottom);box-sizing:border-box;border-top:1px solid #d8c8ae;background:#fffaf1f2;backdrop-filter:blur(12px)}
  .mobile-bottom-nav.has-install{grid-template-columns:1fr 1fr 88px 64px}
  .mobile-bottom-nav a,.mobile-bottom-nav button{display:grid;place-items:center;border:0;color:#59645e;background:none;text-decoration:none;font-size:14px;font-weight:700}
  .mobile-bottom-nav [hidden]{display:none!important}
  .mobile-nav-install{padding:0 4px;font-size:12px!important}
  .mobile-bottom-nav a[aria-current="page"]{color:#a94e34}
  .mobile-nav-account{grid-column:3;justify-items:end!important}.mobile-bottom-nav.has-install .mobile-nav-account{grid-column:4}
  .mobile-nav-avatar{display:grid;width:36px;height:36px;place-items:center;border-radius:50%;color:#f4f0e8;background:#62776f;font:700 14px/1 Georgia,"Songti SC",serif;opacity:.62}
  .mobile-nav-account[aria-current="page"] .mobile-nav-avatar{background:#526b62;opacity:.82}
  .site-bug-trigger,.site-install-notice{display:none!important}

  .site-header{min-height:58px;padding:env(safe-area-inset-top) 16px 0;box-sizing:content-box;display:flex;align-items:center}
  .site-header .brand{min-width:0}.site-header .brand-mark{width:38px;height:38px}.site-header .brand-copy{display:none}
  .site-header>nav{display:none}.site-header .account-link{display:none}.site-header .account-name{display:none}
  .account-badge{width:44px;height:44px}

  /* Home: search first, then one full-width list. */
  body.home-page{height:auto;min-height:100dvh;overflow:auto;background:#f5eddf}
  .home-shell{position:static;display:flex;flex-direction:column;min-height:calc(100dvh - var(--mobile-nav-height));background:#f5eddf}
  .home-control-rail{display:flex;flex-direction:column;padding:calc(12px + env(safe-area-inset-top)) 16px 8px;color:#214b40;background:#173c33}
  .home-brand{display:none}.home-control-rail .rail-divider,.home-control-rail .rail-actions{display:none}
  .home-search{order:-2;min-height:52px;border-color:#d7c39e;background:#fffaf3}
  .home-search input{height:50px;color:#213d35;font-size:16px}.home-search input::placeholder{color:#817666}
  .home-search .search-symbol{border-color:#36584e}.home-search-clear{color:#36584e}
  .keypad-sequence{color:#f0c27a}
  .mobile-keypad-disclosure{display:none}
  .home-keypad{margin:6px 0 8px;gap:8px}.home-keypad button{min-height:48px}
  .home-results{height:auto;overflow:visible}.home-topbar{height:54px;padding:0 16px}.home-topbar nav{display:none}
  .home-topbar .account-link{display:none}.home-topbar .account-name{display:none}
  .recommendation-paper{position:static;display:block;padding:10px 16px 12px;overflow:visible}
  .recommendation-paper .paper-clip-asset{display:none}.candidate-header{align-items:center}.candidate-header h1{font-size:23px}.recent-entry{display:none}
  .candidate-list{display:block;overflow:visible;border-top:1px solid rgba(130,109,78,.24)}
  .candidate-row{min-height:66px;display:grid;grid-template-columns:minmax(0,1fr) auto;padding:0;border-bottom:1px solid rgba(130,109,78,.24)}
  .song-entry{grid-column:1;grid-row:1;display:flex;gap:10px;padding:8px 0}.song-entry>span{width:38px;height:38px}.song-entry strong{font-size:17px;white-space:normal}
  .artist-entry{grid-column:1;grid-row:1;align-self:end;margin:0 0 5px 48px;min-height:22px;font-size:12px;pointer-events:none}
  .score-info-trigger{grid-column:2;grid-row:1;width:48px;padding:0}.score-info-trigger .score-tags,.score-info-trigger .score-detail-label{display:none}

  /* Search: the retired browse catalogue stays out of the phone journey. */
  .search-results-page .browse-page{width:auto;margin:0;padding:14px 16px 20px}
  .search-results-page .browse-routes,.search-results-page .breadcrumbs,.search-results-page .browse-heading{display:none}
  .browse-search{display:grid;grid-template-columns:auto minmax(0,1fr) 64px;margin:0 0 18px}.browse-search input{min-width:0;padding-inline:12px;font-size:16px}.browse-search button{min-width:64px}
  .song-results{display:grid;gap:0}.song-results>a{min-height:70px;padding:8px 0;border:0;border-bottom:1px solid #ded1bc;border-radius:0;background:transparent;box-shadow:none}
  .song-results .song-glyph,.song-results .result-reason{display:none}.song-results h2{font-size:18px}.song-results>a>span:last-child{font-size:12px}
  .version-drawer,.paper-info-drawer{width:100%;max-width:none;height:min(78dvh,720px);inset:auto 0 0;padding:48px 20px calc(24px + env(safe-area-inset-bottom));box-sizing:border-box;border-radius:18px 18px 0 0;overflow:auto}
  .version-drawer .drawer-close,.paper-info-drawer .drawer-close{top:8px;right:12px}
  .version-list article{grid-template-columns:18px minmax(0,1fr);gap:8px}.version-list .tags{display:none}.version-list .workbench-link,.version-list .favorite-form{grid-column:2}

  /* My Scores: two short rows of choices, then compact readable items. */
  body.my-scores-app{height:auto;min-height:100dvh;overflow:auto;background:#f5eddf}
  .my-scores-shell{position:static;display:block;height:auto;min-height:100dvh;background:#f5eddf}
  .my-scores-rail{display:none}.my-scores-stage{height:auto;overflow:visible}.my-scores-topbar{display:none!important}
  .my-scores-paper{position:static;display:flex;flex-direction:column;padding:env(safe-area-inset-top) 16px 18px}.my-scores-paper .paper-clip-asset{display:none}
  .mobile-score-tabs{display:grid;grid-template-columns:repeat(3,1fr);padding:3px;border-radius:10px;background:#e9dfcd}
  .mobile-score-tabs a{display:grid;place-items:center;color:#5d625d;text-decoration:none;border-radius:8px}.mobile-score-tabs a.active{color:#fff;background:#315f50}
  .mobile-score-types{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:7px;margin:10px 0 14px}.mobile-score-types span{font-size:12px;color:#7b7061}.mobile-score-types a{display:grid;place-items:center;border:1px solid #c8b899;border-radius:999px;color:#315f50;text-decoration:none;font-size:13px}.mobile-score-types a.active{border-color:#315f50;background:#e3eee8}
  .my-scores-heading{min-height:42px}.my-scores-heading h1{font-size:23px}.my-scores-heading p{display:none}
  .mobile-manual-list-heading{display:flex;justify-content:flex-end;margin:-2px 0 4px}
  .mobile-new-song{min-width:108px;min-height:44px;display:grid;place-items:center;padding:0 10px;border-radius:9px;color:#fff;background:#a94e34;text-decoration:none;font-size:13px;font-weight:800}.my-scores-heading>.my-scores-summary{display:none}
  .my-score-list{display:block;overflow:visible}.my-score-row{min-height:66px;grid-template-columns:44px minmax(0,1fr);padding:2px 0}
  .my-score-open{grid-template-columns:1fr;gap:3px}.my-score-main{display:grid;gap:3px}.my-score-main strong{font-size:17px}.my-score-open>.relation-badge{justify-self:start;padding:0;background:none;color:#7a6e5f}
  .my-score-detail{display:none}.my-scores-pagination{justify-content:space-between;margin-top:10px}.my-scores-pagination a{border:1px solid #cbb99b;background:#fffaf1}

  /* Account and login remain usable above the on-screen keyboard. */
  .account-page{min-height:100dvh}.account-shell,.login-shell{width:auto;min-height:calc(100dvh - var(--mobile-nav-height));padding-left:16px;padding-right:16px;box-sizing:border-box}
  .account-heading h1,.login-hero h1{font-size:28px}.account-card{width:100%;box-sizing:border-box}.user-panel{grid-template-columns:1fr}.capability-grid,.roadmap-note{grid-template-columns:1fr}
  .auth-dialog{width:calc(100% - 24px);max-height:calc(100dvh - 24px);padding:48px 18px 18px;box-sizing:border-box;overflow:auto}
  .auth-flow input{font-size:16px}.guest-account-page{padding-bottom:0}

  /* Song creation reuses the formal editor; image/PDF import stays on larger screens. */
  .score-creation-app[data-creation-mode=private_image]>.paper-shell{display:none}.score-creation-app[data-creation-mode=private_image]{padding-bottom:calc(var(--mobile-nav-height) + var(--mobile-safe-bottom))}
  .score-creation-app[data-creation-mode=new_song]{height:100dvh;min-height:0;padding:0;overflow:hidden}.score-creation-app[data-creation-mode=new_song] .mobile-bottom-nav{display:none!important}
  .score-creation-app[data-creation-mode=new_song]>.paper-shell{height:100dvh;min-height:0;display:block;background:#fbf5ea}.score-creation-app[data-creation-mode=new_song] .my-scores-stage{height:100dvh;min-height:0;overflow:hidden}.score-creation-app[data-creation-mode=new_song] .score-creation-paper{position:static;width:100%;height:100dvh;min-height:0;padding:0;overflow:hidden;border:0;border-radius:0}.score-creation-app[data-creation-mode=new_song] .score-creation-paper>.paper-clip-asset{display:none}.score-creation-app[data-creation-mode=new_song] .new-song-entry-frame{height:100%}
  .mobile-device-note{display:flex;min-height:calc(100dvh - var(--mobile-nav-height) - var(--mobile-safe-bottom));box-sizing:border-box;padding:calc(18px + env(safe-area-inset-top)) 24px 24px;flex-direction:column;align-items:flex-start;justify-content:center;color:#f9f1e4;background:#183d34}
  .mobile-device-note>a:first-child{position:absolute;top:calc(12px + env(safe-area-inset-top));left:18px;color:#fff;text-decoration:none;font-size:36px}
  .mobile-device-note h1{margin:6px 0 12px;font:600 30px/1.2 Georgia,"Songti SC",serif}.mobile-device-note p{max-width:320px;line-height:1.7;color:#ddd0bb}
  .mobile-device-note-action{display:grid;place-items:center;margin-top:18px;padding:0 22px;border-radius:10px;color:#173d34!important;background:#f4e5ca;text-decoration:none}

  /* GTP, self-built and image/PDF all share the same lightweight reader shell. */
  body:has(.top-shell){padding:0;min-height:100dvh;overflow:hidden;background:#f8f2e7}
  body:has(.top-shell) .mobile-bottom-nav{display:none!important}
  body:has(.top-shell) .app-shell{height:100dvh;padding:0}
  body:has(.top-shell) .top-shell{display:block;min-height:0}.global-bar{min-height:48px;padding:env(safe-area-inset-top) 8px 0}.global-bar .product-brand,.global-bar .site-nav,.global-bar .account-control{display:none}
  .global-bar .site-nav:has([data-workbench-return]){display:flex;margin-left:0}.global-bar .site-nav>:not([data-workbench-return]){display:none}.global-bar [data-workbench-return]{font-size:12px}
  .global-bar .song-identity{width:100%;display:grid;grid-template-columns:minmax(0,1fr) max-content 44px 64px;align-items:center;column-gap:4px;padding:0}.global-bar .song-identity select{grid-column:1;width:100%;max-width:none;padding-right:2px;overflow:hidden;text-overflow:ellipsis;font-size:15px;pointer-events:none;background:none}.global-bar .song-identity span{display:block;grid-column:2;grid-row:1;max-width:82px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:#decdb3}.song-favorite{grid-column:3;grid-row:1;justify-self:end;width:44px;height:44px}
  .content-edit-actions,.private-image-tools{display:none!important}
  .info-bar{display:block!important;min-height:52px;padding:4px 12px;border-bottom:1px solid #d7c9b3;background:#f4ede1}
  html.new-song-boot .info-bar,body.new-song-entry-loading .info-bar,body.new-song-creation-view .info-bar{display:none!important}
  .info-bar>:not(.action-row),.action-row>:not(.mode-rail){display:none!important}
  .info-bar .action-row,.info-bar .mode-rail{display:block;width:100%;margin:0}
  .info-bar .bookmark-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;width:100%}
  .info-bar .bookmark-tabs button{width:auto;min-width:0;min-height:44px;padding:0 4px;border:1px solid #c8b899;border-radius:8px;transform:none;font-size:13px}
  .info-bar .bookmark-tabs button.active{color:#fff;background:#315f50;transform:none}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .info-bar .bookmark-tabs{box-sizing:border-box;padding-right:66px}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .content-edit-actions{display:flex!important;position:fixed;z-index:95;top:calc(env(safe-area-inset-top) + 52px);right:8px;bottom:auto;left:8px;width:auto;max-width:none}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .content-edit-session{width:100%;display:grid;grid-template-columns:minmax(0,1fr) 58px;gap:4px}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) #mobile-score-return{display:flex;min-width:0;height:44px;align-items:center;gap:2px}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) #mobile-score-return a{display:grid;min-width:0;height:44px;place-items:center;padding:0 10px;border-radius:8px;color:#315f50;background:#fffaf1;text-decoration:none;font-size:13px;font-weight:800}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) #score-edit-entry{display:grid;width:58px;height:44px;min-height:44px;place-items:center;padding:0;border-radius:8px;background:#fffaf1;font-size:13px}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .score-edit-menu{top:calc(env(safe-area-inset-top) + 100px);right:8px!important;bottom:auto!important;max-height:calc(100dvh - env(safe-area-inset-top) - 108px);overflow:auto}
  body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .cancel-content-button,body.new-song-score-view.new-song-complete:not(.new-song-creation-view) .undo-content-button{display:none!important}
  .score-area,.private-image-stage{height:auto;min-height:0;overflow:auto;scrollbar-width:none}.score-area::-webkit-scrollbar,.private-image-stage::-webkit-scrollbar{display:none}.score-stage{height:auto;min-height:100%;padding:0}.paper-frame{width:100%;max-width:100%;min-width:0;height:max-content;min-height:100%;overflow:visible;border:0;border-radius:0;box-shadow:none}.paper-frame iframe{margin:0}
  .private-image-stage{padding:0;background:#f8f2e7}.image-workbench-layout{max-width:none}.image-score-pages{display:block}.image-score-page{margin:0 0 10px;border:0;border-radius:0;box-shadow:none}.image-page-controls{display:none}
  body.fallback-fullscreen,body.fallback-fullscreen .score-area,body.fallback-fullscreen .score-stage,body.fallback-fullscreen .paper-frame,body.fallback-fullscreen .private-image-stage{touch-action:pan-y pinch-zoom!important;overscroll-behavior-x:none;overflow-x:hidden!important}
  body.fallback-fullscreen.private-image-workbench .private-image-stage{overflow-y:auto;padding:0;-webkit-overflow-scrolling:touch}
  .mobile-reader-scroll{display:grid;grid-column:4;grid-row:1;width:64px;height:44px;place-items:center;align-self:center;min-width:0;padding:0;border:0;border-radius:0;color:#f3dfbb;background:transparent;font-size:14px;font-weight:800;box-shadow:none}
  body.fallback-fullscreen .mobile-reader-scroll{display:none}
  body.fallback-fullscreen .mobile-bottom-nav{display:none}
  body.fallback-fullscreen:has(.top-shell) .app-shell{height:100dvh}
  body.fallback-fullscreen .fullscreen-exit-overlay,body.fallback-fullscreen .exit-image-fullscreen{left:max(8px,env(safe-area-inset-left));right:auto;top:max(8px,env(safe-area-inset-top));height:44px;min-height:44px;padding:0 12px;border-radius:10px}
  body.fallback-fullscreen .adjust-image-fullscreen{display:none!important}
  body.fallback-fullscreen .follow-actions{flex-direction:row}
  body.fallback-fullscreen .follow-reading-line{left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right))}
  body.new-song-creation-view .top-shell{display:none}body.new-song-creation-view .app-shell{grid-template-rows:minmax(0,1fr);height:100dvh;padding:0}body.new-song-creation-view .score-area,body.new-song-creation-view .score-stage{height:100%;min-height:0}body.new-song-creation-view .paper-frame{height:calc(100dvh - 20px);min-height:calc(100dvh - 20px);max-height:calc(100dvh - 20px)}body.new-song-creation-view .mobile-bottom-nav{display:none!important}
}

@media (min-width:601px) and (max-height:600px){
  body.new-song-creation-view .top-shell{display:none}body.new-song-creation-view .app-shell{grid-template-rows:minmax(0,1fr);height:100dvh;padding:0}body.new-song-creation-view .score-area,body.new-song-creation-view .score-stage{height:100%;min-height:0}body.new-song-creation-view .paper-frame{height:calc(100dvh - 20px);min-height:calc(100dvh - 20px);max-height:calc(100dvh - 20px)}
  body.fallback-fullscreen,body.fallback-fullscreen .score-area,body.fallback-fullscreen .score-stage,body.fallback-fullscreen .paper-frame,body.fallback-fullscreen .private-image-stage{touch-action:pan-y pinch-zoom!important;overscroll-behavior-x:none;overflow-x:hidden!important}
  body.fallback-fullscreen.private-image-workbench .private-image-stage{overflow-y:auto;-webkit-overflow-scrolling:touch}
  body.fallback-fullscreen .fullscreen-exit-overlay,body.fallback-fullscreen .exit-image-fullscreen{left:max(8px,env(safe-area-inset-left));right:auto;top:max(8px,env(safe-area-inset-top));height:44px;min-height:44px;padding:0 12px;border-radius:10px}
  body.fallback-fullscreen .adjust-image-fullscreen{display:none!important}
  body.fallback-fullscreen .follow-actions{flex-direction:row}
  body.fallback-fullscreen .follow-reading-line{left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right))}
}

@media (min-width:601px){.mobile-keypad-disclosure{display:contents}.mobile-keypad-disclosure>.home-keypad{display:grid!important}}
