@media (max-width: 768px) {
  #bar {
    display: none;
  }
  
  #companyCard {
    width: calc(100% - 16px);
    right: 8px;
    left: 8px;
    top: 80px !important;
    max-height: calc(100vh - 100px);
  }
  
  #searchWrap {
    top: 12px;
    right: 8px;
    width: calc(100% - 100px);
  }
  
  #subtitle {
    display: none;
  }
  
  .st {
    gap: 10px;
  }
  
  .st b {
    font-size: 14px;
  }
  
  .st span {
    font-size: 7px;
  }
  
  #lg {
    max-width: 80vw;
  }
  
  #mobileToggle {
    display: block;
    position: fixed;
    left: 8px;
    bottom: 8px;
    z-index: 130;
    background: linear-gradient(135deg, #1a1a1a, #222);
    border: 1px solid #333;
    color: #ddd;
    padding: 10px 14px;
    font-size: 9px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  
  #mobileSheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 140;
    background: linear-gradient(180deg, rgba(8,8,8,0.98) 0%, rgba(8,8,8,0.99) 100%);
    border-top: 1px solid #2a2a2a;
    padding: 12px;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  }
  
  #mobileSheet .mGrid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  
  #mobileSheet button {
    background: linear-gradient(135deg, #1a1a1a, #222);
    border: 1px solid #333;
    color: #aaa;
    padding: 10px 8px;
    font-size: 8px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border-radius: 6px;
    transition: all 0.15s;
  }
  
  #mobileSheet button:hover, #mobileSheet button:active {
    border-color: var(--acc);
    color: var(--acc);
    transform: translateY(-2px);
  }
  
  /* Improve touch targets */
  #bar button, #bar select, #companyCard button {
    min-height: 36px;
    min-width: 36px;
  }
  
  /* Larger tooltips on mobile */
  #tt {
    max-width: calc(100vw - 24px);
    padding: 14px;
  }

  /* New Phase 5-7 panels: full-width, bottom-anchored above the mobile toolbar,
     bounded height with scroll so they are usable and never clipped on a phone. */
  #chokepointsPanel, #scenarioPanel {
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 40vh;
  }
  #chokepointsPanel {
    bottom: calc(var(--space-6) + 56px);
  }
  #scenarioPanel {
    bottom: 56px;
  }

  /* Filter panel: usable mobile width instead of the desktop 280px column */
  #filterPanel {
    left: 8px;
    right: 8px;
    max-width: none;
    width: auto;
    top: 70px;
  }

  /* Hero tour overlay: span the viewport width with safe insets */
  #heroOverlay {
    left: 8px !important;
    right: 8px;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
    bottom: 64px;
  }

  /* Modals: give the dialog content a usable mobile width and inset */
  #helpModal .content, #methodologyModal .content {
    max-width: calc(100vw - 24px);
    width: calc(100vw - 24px);
    max-height: 85vh;
  }
  #compareModal .content {
    max-width: 100%;
    padding: 16px;
  }
  #compareModal .grid {
    grid-template-columns: 1fr;
  }
}
@media print {
  #top,#bar,#searchWrap,#companyCard,#hint,#lg,#ly,#filterPanel,#loading,#helpModal,#methodologyModal,#compareModal,#footer,#provenanceDrawer,#mobileToggle,#mobileSheet{display:none!important}
  #canvas{position:static;width:100%;height:600px}
  body{background:white;color:black;overflow:visible}
}
@keyframes fadeOut{0%{opacity:1}80%{opacity:1}100%{opacity:0}}

/* Smooth Transitions */
#companyCard,#tt,#filterPanel,#provenanceDrawer{transition:opacity var(--dur-base) ease,transform var(--dur-base) ease}
#bar button,#bar select{transition:all var(--dur-fast) var(--ease-standard)}
#bar button:hover{transform:translateY(-1px)}
#bar button:active{transform:translateY(0)}
.node{transition:filter var(--dur-base) ease,opacity var(--dur-base) ease}
.node:hover{filter:brightness(1.2) drop-shadow(0 0 8px currentColor)}
.link{transition:opacity var(--dur-base) ease}
@keyframes fadeIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
#companyCard.show,#tt.show,.modal.show{animation:fadeIn var(--dur-base) ease forwards}
.btn-press{transition:transform var(--dur-fastest) ease}
.btn-press:active{transform:scale(0.96)}

/* Update Status Indicator */
#footer{display:flex;align-items:center;gap:var(--space-4)}
#footer .updateStatus{display:inline-flex;align-items:center;gap:var(--space-2);font-size:var(--fs-xs);color:#666}
#footer .statusDot{width:var(--space-3);height:var(--space-3);border-radius:50%;animation:pulse 2s ease-in-out infinite}
#footer .statusDot.fresh{background:var(--color-success)}
#footer .statusDot.stale{background:var(--color-warning)}
#footer .statusDot.outdated{background:var(--color-danger)}

/* Top 10 Compact Sidebar */
#top10Sidebar{background:rgba(10,10,10,0.95);backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,0.08);border-radius:var(--radius-lg);padding:var(--space-5)}
#top10Sidebar::-webkit-scrollbar{width:4px}
#top10Sidebar::-webkit-scrollbar-track{background:transparent}
#top10Sidebar::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.1);border-radius:2px}
.top10-item{display:flex;align-items:center;gap:var(--space-4);padding:var(--space-4);background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:var(--radius-md);cursor:pointer;transition:all var(--dur-fast)}
.top10-item:hover{background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.12);transform:translateX(2px)}
.top10-item .rank{font-family:'JetBrains Mono',monospace;font-size:10px;font-weight:700;color:#666;min-width:20px}
.top10-item .logo{width:24px;height:24px;border-radius:4px;object-fit:contain;background:#0f0f0f;border:1px solid rgba(255,255,255,0.08)}
.top10-item .logoFallback{width:24px;height:24px;border-radius:4px;background:linear-gradient(135deg,#1a1a1a,#2a2a2a);border:1px solid rgba(255,255,255,0.08);display:flex;align-items:center;justify-content:center;font-family:'Bricolage Grotesque',sans-serif;font-size:10px;font-weight:700;color:#666}
.top10-item .info{flex:1;min-width:0}
.top10-item .symbol{font-family:'JetBrains Mono',monospace;font-size:9px;font-weight:700;color:#fff}
.top10-item .name{font-family:'Inter',sans-serif;font-size:8px;color:#888;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top10-item .marketCap{font-family:var(--font-mono);font-size:var(--fs-xs);color:var(--color-success);font-weight:var(--fw-semibold)}
@media(max-width:768px){#top10Sidebar{display:none!important}}

/* Reduced-motion: honor the OS-level prefers-reduced-motion setting (theme.css loads
   last, so these win the cascade). Source: MDN prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:0.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:0.01ms!important;
  }
  .node,.link,#companyCard,#tt,.modal{transition:none!important;animation:none!important}
}
