/* Phone navigation uses the same map and records as the desktop view. */
.mobile-only{display:none}
@media(any-pointer:coarse){
  .spatial #map-nodes,.spatial #map-nodes *{pointer-events:none!important}
  .edge .hit{stroke-width:22px}
  .variant-edge .hit{stroke-width:24px}
}
@media(max-width:700px){
  html,body{height:100%;overflow:hidden}
  body{display:flex;flex-direction:column;height:var(--visible-height,100dvh)}
  header{height:auto;flex:none;min-height:120px;padding:8px 10px; padding-top:max(8px,env(safe-area-inset-top));display:grid;grid-template-columns:minmax(0,1fr) auto auto;grid-template-rows:auto 44px;gap:6px;align-content:center}
  .brand-block{grid-column:1;min-width:0;margin:0;gap:0}
  .brand-block .brand{width:100%;font-size:clamp(15px,4.4vw,21px);line-height:27px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:0;min-height:27px}
  .brand-block .brand i{font-size:1em}
  .atlas-back{display:block;font-size:12px;line-height:20px;min-height:24px;padding:2px 0}
  header .view-switch{grid-column:2;order:0;align-self:center;gap:0;padding:0}
  .view-switch button{min-width:40px;min-height:44px;padding:8px;font-size:13px}
  header #help-button{grid-column:3;order:0;min-width:40px;width:40px;min-height:44px;margin:0;padding:8px}
  header .search-wrap{grid-row:2;grid-column:1/-1;order:0;width:100%;min-width:0;flex:none}
  #search{font-size:16px;height:44px;padding:10px 12px}
  #search-results{top:48px;left:0;right:0;width:auto;max-width:none;max-height:calc(var(--visible-height,100dvh) - 132px);overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  #search-results button{min-height:48px;white-space:normal;overflow-wrap:anywhere}
  #map-shell{flex:1 1 auto;height:auto;min-height:0;overflow:hidden}
  #map-tools{top:6px;left:10px;right:10px;display:flex;align-items:center;gap:6px;width:auto;pointer-events:none;z-index:18}
  #map-tools>button,#filters{pointer-events:auto}
  #map-tools>button{min-height:44px;margin:0;padding:8px 10px;font-size:13px}
  #history-back{max-width:86px;order:0}
  #map-tools #filter-button{order:1}
  #map-tools #mobile-list{order:2}
  .mobile-only{display:block}
  #mobile-list{margin-left:auto!important;border:1px solid #3c4c5f;background:#16212e;color:#dce6ef}
  #hint,#map-tools:has(#history-back:not([hidden]))~#hint{top:55px;left:12px;right:12px;max-height:38px;height:38px;gap:18px;font-size:12px;white-space:nowrap;overscroll-behavior-x:contain}
  #hint button{font-size:12px;min-height:36px;padding:6px 0}
  #viewport{inset:98px 0 112px}
  .map-footer{left:10px;right:10px;bottom:64px;min-height:44px;gap:8px;align-items:center}
  .legend{font-size:10px;line-height:1.3;gap:3px 8px;max-width:none;flex:1}
  .legend span{gap:5px}
  .legend b{width:16px}
  .camera{gap:0;flex:none;background:#14202c;border:1px solid #3c4c5f;border-radius:6px}
  .camera button{min-width:40px;min-height:44px;padding:8px;color:#dce6ef;font-size:14px}
  .map-meta{left:12px;right:12px;bottom:max(5px,env(safe-area-inset-bottom));gap:8px;align-items:flex-end;font-size:11px;line-height:1.35;min-height:48px}
  .coverage-line{display:flex;flex-direction:column;align-items:flex-start;gap:1px;min-width:0;max-width:54%}
  .coverage-line #coverage{white-space:normal;overflow:visible;font-size:10px}
  #suggest-addition{white-space:normal;padding:5px 0;min-height:28px}
  .map-meta>span:last-child{max-width:46%;flex-shrink:1;text-align:right}
  #gesture-hint{font-size:10px;display:block;line-height:1.3}
  #reference-link{min-height:28px;padding:4px 0;font-size:11px}
  #filters{position:absolute;left:0;top:50px;right:0;width:auto;max-width:none;max-height:calc(var(--visible-height,100dvh) - 184px);padding:10px 16px 0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;box-shadow:0 12px 35px #0009}
  #filters fieldset{margin-bottom:8px;padding-bottom:8px}
  #filters legend{font-size:15px;margin-bottom:2px}
  #filters label{min-height:44px;padding:9px 0;font-size:14px;gap:12px}
  #filters input[type=checkbox]{width:20px;height:20px;flex-basis:20px}
  .filter-actions{position:sticky;bottom:0;background:#141f2e;gap:6px;margin:0 -8px;padding:8px;border-top:1px solid #3c5065;flex-wrap:wrap}
  .filter-actions button{min-height:44px;padding:7px 10px}
  #filters .filter-note{font-size:12px}
  #detail{left:0;right:0;top:auto;bottom:0;width:auto;max-height:min(55dvh,calc(var(--visible-height,100dvh) - 128px));min-height:0;padding:0 16px max(20px,env(safe-area-inset-bottom));border-radius:12px 12px 0 0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;z-index:16}
  .detail-controls{gap:2px;padding:5px 0;margin:0 -6px 6px;min-height:54px}
  .detail-controls button,.detail-controls #back,.detail-controls #focus-selection{min-height:44px;font-size:12px;padding:8px}
  .detail-controls #expand-family{min-height:44px;font-size:12px;padding:6px 8px;white-space:normal}
  .detail-controls #close-detail{min-width:44px;min-height:44px;padding:8px;font-size:26px;flex:none}
  #detail h1{font-size:25px}
  #detail-content{overflow-wrap:anywhere}
  #detail p{font-size:14px}
  #detail select{font-size:16px;min-height:44px;width:100%}
  #detail summary{min-height:44px;padding:9px 0}
  #detail .source-card a{display:inline-block;padding:5px 0}
  #map-shell.listing #map-tools{display:flex;left:auto;width:auto;right:10px;z-index:14}
  #map-shell.listing #history-back,#map-shell.listing #mobile-list{display:none}
  #map-shell.listing #filters{position:fixed;left:10px;right:10px;top:calc(var(--header-height,120px) + 56px)}
  #map-return{top:6px;left:10px;right:10px;min-height:44px}
  #return-map{min-height:44px;padding:8px 10px;font-size:13px}
  #map-context{top:50px;width:100%;font-size:17px;line-height:1.2}
  #map-shell.listing #map-context{top:53px}
  #map-shell.listing #list{top:92px;left:10px;right:10px;bottom:8px;columns:1;padding:4px 12px;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
  #map-shell.listing .map-footer,#map-shell.listing .map-meta{display:none}
  #list button{min-height:60px;overflow-wrap:anywhere}
  #map-shell.expanded #mode-note{top:12px;left:auto;right:12px;width:calc(100% - 130px);font-size:11px;text-align:right}
  #map-shell.expanded #variant-surface{top:80px;bottom:54px}
  #map-shell.expanded .map-meta{display:none}
  #map-shell.expanded .map-footer{bottom:4px}
  #guide{max-height:calc(var(--visible-height,100dvh) - 20px);width:calc(100% - 20px);padding:14px 18px;overflow:auto;overscroll-behavior:contain;overflow-wrap:anywhere}
  #close-guide{position:sticky;top:0;min-width:44px;min-height:44px;z-index:1;background:#192630}
  #guide th,#guide td{padding:8px 5px}
  #status{bottom:118px;left:10px;right:10px;max-width:none}
}
@media(max-width:700px) and (max-height:480px) and (orientation:landscape){
  header{min-height:66px;grid-template-columns:minmax(0,1fr) minmax(150px,1fr) auto auto;grid-template-rows:50px;padding:5px 10px}
  header .search-wrap{grid-column:2;grid-row:1}
  header .view-switch{grid-column:3}
  header #help-button{grid-column:4}
  #viewport{top:54px;bottom:63px}
  #hint{display:none}
  .map-footer{bottom:7px;left:auto}
  .map-footer .legend{display:none}
  .map-meta{right:150px;min-height:44px}
  #filters{max-height:calc(var(--visible-height,100dvh) - 128px)}
  #detail{max-height:calc(var(--visible-height,100dvh) - 72px);left:30%;border-radius:10px 0 0 0}
  #map-shell.expanded #variant-surface{top:85px;bottom:63px}
  #search-results{max-height:calc(var(--visible-height,100dvh) - 72px)}
}
