#mobileMenuToggle,#mobileModeBar,#mobileFooter,#mobileWalkDock,#mobileZoom,#mobilePanelHead,#mobileToolDock,#mobileViewOptions,#mobileTourInfo,#mobileNavigationInfo,#mobileTouchHelp { display:none; }
.mobile-backdrop { position:fixed; inset:0; border:0; padding:0; background:#13263866; z-index:45; }
#mobileMenu { position:fixed; inset:0; z-index:70; }
#mobileMenu .mobile-backdrop { z-index:0; }
.mobile-menu-sheet { position:absolute; left:0; right:0; bottom:0; max-height:85dvh; overflow:auto; background:#fff; border-radius:18px 18px 0 0; padding:16px 16px max(16px,env(safe-area-inset-bottom)); }
.mobile-menu-sheet header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
#mobileMenuClose,#mobilePanelClose { border:0; background:var(--chip); border-radius:10px; min-width:44px; min-height:44px; }
#mobileSaveDock,#mobileActionDock .top-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; margin-bottom:9px; }
#mobileSaveDock>.btn,#mobileActionDock .btn { min-height:44px; font-size:14px; }
#mobileSaveDock .menu-wrap { grid-column:1/-1; }
#mobileSaveDock #btnConceptMenu { width:100%; font-size:14px; min-height:44px; }
#mobileSaveDock #conceptMenu { position:static; width:100%; box-shadow:none; margin-top:6px; }
#mobileSaveDock #conceptMenu button { min-height:44px; }
#mobileMenu #btnCheat,#mobileMenu #btnShot { display:block; }
#tourAccess { margin-top:10px; padding:10px; border-radius:8px; background:#fff2df; color:#65401d; font-size:12px; line-height:1.5; }
#tourAccess .btn { display:block; margin-top:7px; }
#tourDots .inaccessible { border-color:#bf6a23; background:#fff0de; }
@media(max-width:760px), (max-height:500px) and (pointer:coarse) {
  html,body { height:100%; overscroll-behavior:none; }
  #app,#app.fp-view { height:100dvh; grid-template-columns:minmax(0,1fr); grid-template-rows:56px 48px minmax(0,1fr) auto; }
  #topbar { grid-row:1; min-width:0; flex-wrap:nowrap; gap:8px; padding:6px 10px; min-height:56px; }
  #topbar .brand,#topbar .save-state { display:none; }
  #topbar .concept-box { display:contents; }
  #topbar #designName { min-width:0; max-width:none; flex:1; padding:4px 0; overflow:hidden; }
  #designName span,#designName small { width:100%; }
  #btnNav { min-width:44px; height:44px; padding:0!important; }
  #btnNav .shortcut-key { display:none; }
  #mobileMenuToggle { display:block; height:44px; padding:6px 10px!important; font-size:13px; flex-shrink:0; }
  #mobileModeBar { display:block; grid-row:2; padding:2px 8px 4px; background:#fff; border-bottom:1px solid var(--line); }
  #mobileModeBar #viewSeg { display:grid; grid-template-columns:repeat(4,1fr); width:100%; box-shadow:none; background:#edf2f7; padding:2px; }
  #mobileModeBar button { min-height:40px; padding:4px; font-size:13px; }
  #stage { grid-row:3; min-width:0; min-height:0; }
  #viewbar,#navTab,#compass,#hint { display:none!important; }
  #overlay .lbl { font-size:9px; max-width:130px; overflow:hidden; text-overflow:ellipsis; }
  #mobileFooter { display:block; grid-row:4; background:#fff; border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); }
  .mobile-utilities { display:grid; grid-template-columns:repeat(3,1fr); padding:3px 8px; gap:5px; }
  .mobile-utilities button { min-height:44px; font-size:12px; font-weight:600; border:0; background:#edf2f7; border-radius:9px; }
  #mobileFooter #tourCard { position:static; transform:none; max-width:none; width:100%; padding:8px 12px; margin:0; border:0; border-bottom:1px solid var(--line); border-radius:0; background:white; box-shadow:none; }
  #tourCard .tour-top { flex-wrap:nowrap; gap:8px; }
  #tourCard .tour-top .x { min-height:30px; padding:0; }
  #tourCard h3 { margin:2px 0 6px; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  #tourCard .tour-ctrl { gap:6px; }
  #tourCard .tour-ctrl .btn { min-height:40px; font-size:13px; }
  #tourCard .shortcut-key { display:none; }
  #tourAccess { margin:6px 0 0; padding:6px 8px; font-size:11px; display:flex; align-items:center; gap:8px; }
  #tourAccess .btn { margin:0; flex-shrink:0; min-height:36px; }
  #mobileWalkDock { display:block; position:absolute; left:12px; right:12px; bottom:12px; z-index:5; pointer-events:none; }
  #mobileWalkDock #walkHud { position:static; display:flex; flex-direction:row; align-items:flex-end; justify-content:space-between; padding:0; background:none; border:0; gap:8px; }
  #mobileWalkDock .dpad,#mobileWalkDock .walk-turns { pointer-events:auto; }
  .dpad { grid-template-columns:repeat(3,44px); grid-template-rows:repeat(2,44px); gap:4px; }
  .dpad button { width:44px; height:44px; font-size:20px; background:#fffffff2; border-color:#b6c6d7; touch-action:none; }
  .dpad .shortcut-key { display:none; }
  #mobileWalkDock .walk-turns { width:92px; grid-template-columns:44px 44px; gap:4px; }
  #mobileWalkDock .walk-turns button { width:44px; height:44px; font-size:0; padding:0; touch-action:none; background:#fffffff2; border-color:#b6c6d7; }
  .walk-turns kbd { display:none; }
  .walk-turns button::before { font-size:22px; }
  [data-look="turnL"]::before { content:'↶'; } [data-look="turnR"]::before { content:'↷'; }
  [data-look="lookU"]::before { content:'↑'; } [data-look="lookD"]::before { content:'↓'; }
  #app:not(.mobile-object-drag) .lbl.room { pointer-events:none; }
  #mobileZoom { display:flex; gap:4px; position:absolute; top:10px; right:10px; z-index:5; }
  #mobileZoom button { width:44px; height:44px; border:1px solid #becddd; background:#fffffff0; border-radius:9px; font-size:22px; box-shadow:0 2px 6px #13263818; }
  #panel { position:fixed; grid-row:auto; bottom:0; left:0; right:0; width:100%; height:min(68dvh,600px); min-height:0; border-radius:18px 18px 0 0; border:0; box-shadow:0 -8px 40px #13263833; padding-bottom:max(16px,env(safe-area-inset-bottom)); z-index:50; transform:translateY(110%); visibility:hidden; pointer-events:none; overscroll-behavior:contain; }
  #app.mobile-panel-open #panel { transform:none; visibility:visible; pointer-events:auto; }
  #mobilePanelHead { display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; background:white; padding:10px 14px; border-bottom:1px solid var(--line); z-index:2; }
  #panel>section,#mobileToolDock { display:none; }
  #app[data-mobile-panel="comments"] #commentPanel { display:block; }
  #app[data-mobile-panel="view"] #mobileViewOptions { display:block; }
  #app[data-mobile-panel="tour"] #mobileTourInfo { display:block; }
  #app[data-mobile-panel="tools"] #mobileToolDock,#app[data-mobile-panel="tools"] #mobileTouchHelp { display:block; }
  #app[data-mobile-panel="tools"] #props,#app[data-mobile-panel="tools"] #toolOptions,#app[data-mobile-panel="tools"] #palette { display:block; }
  #app.fp-view[data-mobile-panel="tools"] #mobileNavigationInfo { display:block; }
  #app.fp-view #mobileToolDock,#app.fp-view #mobileTouchHelp { display:none; }
  #mobileToolDock #tools { display:flex; width:100%; flex-wrap:wrap; height:auto; padding:6px 10px; gap:5px; opacity:1!important; border:0; }
  #tools .tool { width:calc(20% - 5px); min-width:44px; min-height:60px; }
  #mobileViewOptions .seg { display:grid; grid-template-columns:repeat(2,1fr); box-shadow:none; width:100%; margin:8px 0 20px; }
  #mobileViewOptions .seg button { min-height:44px; border:1px solid var(--line); padding:8px; }
  #mobileViewOptions #cameraControls { position:static; max-width:none; }
  #panel p { font-size:13px; line-height:1.6; }
  #mobileTourInfo #tourDots { display:flex; flex-wrap:wrap; gap:8px; }
  #mobileTourInfo #tourDots button { min-width:36px; min-height:36px; }
  #mobileNavigationInfo .walk-help { font-size:13px; margin-bottom:14px; }
  #mobileNavigationInfo #minimap { display:block; margin:10px auto; }
  #mobileNavigationInfo #btnAddStop { min-height:44px; }
  #panel input:not([type=checkbox]):not([type=range]),#panel select,#panel textarea { font-size:16px; min-height:44px; }
  #commentPanel .comment-scroll { max-height:none; overflow:visible; }
  #commentPanel .actions { display:flex; flex-wrap:wrap; gap:7px; }
  #commentPanel .actions .btn { min-height:44px; }
  #commentPanel .actions .shortcut-key { display:none; }
  .comment-actions .btn { min-height:44px; }
  #sidenav { position:fixed; top:0; bottom:0; left:0; width:min(340px,100vw); height:100dvh; z-index:65; padding-top:env(safe-area-inset-top); }
  #sidenav button,#sidenav input { min-height:44px; }
  #sidenav .nav-head { padding:10px; gap:6px; }
  #sidenav .nav-item { min-height:65px; }
  #mobileNavBackdrop { z-index:60; }
  #modalBack { align-items:flex-end; padding:0; top:var(--visual-top,0px); bottom:auto; height:var(--visual-height,100dvh); }
  #modal { width:100%; max-width:none; max-height:calc(var(--visual-height,100dvh) - 24px); border-radius:18px 18px 0 0; padding:20px 18px max(20px,env(safe-area-inset-bottom)); overscroll-behavior:contain; }
  #modal input:not([type=checkbox]),#modal select,#modal textarea { font-size:16px!important; min-height:44px; }
  #modal .mrow { flex-wrap:wrap; gap:6px; }
  #modal .mrow label { flex-basis:100%; }
  #modal .mfoot { position:sticky; bottom:-20px; background:#fff; padding:12px 0; gap:8px; }
  #modal .mfoot .btn { min-height:44px; }
  #commentMode { left:10px; right:10px; max-width:none; flex-wrap:wrap; }
  #toast { max-width:calc(100vw - 28px); width:max-content; font-size:12px; pointer-events:none; }
  #dashboard { top:0; padding-top:max(16px,env(safe-area-inset-top)); }
  .dashboard-head { align-items:flex-start; gap:10px; }
  .dashboard-head h1 { font-size:21px; }
  .dashboard-head p { font-size:12px; }
  .dashboard-head>.btn { min-height:44px; white-space:normal; max-width:110px; }
  .dashboard-stats div { padding:10px; }
  .dashboard-stats span { font-size:11px; }
  .dashboard-grid { grid-template-columns:1fr; }
  .dashboard-grid .card img,.dashboard-grid .card .noimg { max-height:170px; }
  .dashboard-grid .card .foot .btn { min-height:44px; }
  .dashboard-filters input,.dashboard-filters select { font-size:16px; width:100%; min-height:44px; }
}
@media(max-height:500px) and (pointer:coarse) {
  #app,#app.fp-view { grid-template-rows:48px 42px minmax(0,1fr) auto; }
  #topbar { min-height:48px; padding:2px 10px; }
  #mobileModeBar button { min-height:34px; }
  #mobileFooter #tourCard { display:grid; grid-template-columns:minmax(0,1fr) 230px; column-gap:10px; padding:5px 12px; }
  #tourCard .tour-top { grid-column:1; } #tourCard h3 { grid-column:1; } #tourCard .tour-ctrl { grid-column:2; grid-row:1/3; align-self:center; }
  #tourAccess { grid-column:1/-1; }
  .mobile-utilities { padding:2px 8px; } .mobile-utilities button { min-height:36px; }
  #mobileWalkDock { bottom:8px; }
}
