/* Loaded only for screens up to 900px; desktop styles remain unchanged. */
@media screen and (max-width: 900px) {
  .app-sidebar-backdrop { z-index: 50; }

  .app-sidebar {
    z-index: 52;
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
  }

  html[data-app-sidebar-open="true"] .app-sidebar { visibility: visible; }
  html[data-app-sidebar-open="true"],
  html[data-app-sidebar-open="true"] body { overflow: hidden; }

  .app-sidebar-toggle,
  .app-toolbar-menu { width: 44px; height: 44px; flex-shrink: 0; }
  .app-nav-link, .app-nav-sublink { min-height: 44px; }
}

@media screen and (max-width: 900px) {
  /* Keep editable controls above iOS Safari's automatic zoom threshold. */
  body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  body select,
  body textarea { font-size: 16px !important; }

  button,
  .ghost-link,
  .marketing-menu-nav a,
  .marketing-topbar-signup,
  .watchers-mobile-sort-chip,
  .macro-tabs a,
  .macro-return-legend > button { min-height: 44px; }

  .ghost-link,
  .marketing-menu-nav a { display: inline-flex; align-items: center; }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  select { min-height: 44px; min-width: 0; max-width: 100%; }

  .marketing-menu-actions.is-open { gap: 12px; }
  .marketing-menu-nav { flex-wrap: wrap; }
  .watchers-mobile-sort { scrollbar-width: thin; padding-bottom: 6px; }
  .watchers-mobile-sort::-webkit-scrollbar { display: block; height: 4px; }
}

@media screen and (max-width: 900px) {
  .context-tooltip { width: 28px; height: 28px; }
  .context-tooltip > [role="tooltip"] { display: none !important; }

  .mobile-help-panel {
    position: fixed;
    z-index: 60;
    left: 16px;
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    max-height: 45vh;
    max-height: 45dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
}

@media screen and (max-width: 900px) {
  .pricing-card-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .pricing-plan-card { height: auto; min-height: 0; }
  .pricing-price-badge-slot:empty { display: none; }

  .opportunity-card-grid,
  .opportunity-candidate-grid { grid-template-columns: minmax(0, 1fr); }

  .macro-return-controls .macro-category-field,
  .macro-return-controls label,
  .macro-return-controls select { min-width: 0; max-width: 100%; }
  .macro-return-controls .macro-category-field { width: 100%; }
  .macro-return-controls .macro-category-options { left: 0; right: 0; min-width: 0; }
  .macro-return-controls .macro-category-options label { white-space: normal; overflow-wrap: anywhere; }
  .macro-return-controls .macro-category-options input { flex-shrink: 0; }
  .macro-return-overlay { max-height: 45vh; overflow-y: auto; }

  .macro-table-wrap,
  .distribution-table-wrap,
  .allocation-mekko-scroll { overscroll-behavior-x: contain; scrollbar-width: thin; }
}

@media screen and (max-width: 640px) {
  .panel { padding: 16px; }
  .page-head > *, .hero > *, .panel-head > *, .panel-head-spread > * { min-width: 0; }
  .panel-head, .panel-head-spread, .opportunity-section-head { flex-wrap: wrap; }
  h1 { font-size: clamp(1.75rem, 7vw, 2.1rem); line-height: 1.1; overflow-wrap: anywhere; }
  .page-head-actions { justify-content: flex-start; }
}

@media screen and (max-width: 900px) {
  .macro-dashboard .macro-summary-table { min-width: 760px; }
  .macro-dashboard .macro-summary-category { width: 160px; }
  .macro-dashboard .macro-summary-metric { width: 90px; }
  .macro-dashboard .macro-summary-updated { width: 150px; }
  .macro-dashboard .macro-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface-strong);
  }
}

@media screen and (max-width: 900px) {
  .thesis-editor-form { min-width: 0; }
  .thesis-editor-footer { flex-wrap: wrap; gap: 10px; }
  .thesis-editor-footer .thesis-recommendation-button { flex: 1 0 100%; }
  .thesis-editor-footer .thesis-action-button { flex: 1 1 0; min-width: 0; }
}

@media screen and (max-width: 900px) {
  /* Transparent sticky toolbars otherwise obscure headings beneath the banner. */
  .app-toolbar { position: static; }
  .app-page :is(section, article, div)[id] { scroll-margin-top: 56px; }
}
