/* ════════════════════════════════════════════════════════════
   四模块 · 手机 / 窄屏适配（≤768px，情报台 ≤900px）
════════════════════════════════════════════════════════════ */

/* ── 详情页：模块视图可滚动、占满主区 ── */
@media (max-width: 768px) {
  body.in-detail .main-area {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
  }

  body.in-detail #macro-view.view,
  body.in-detail #intel-view.view,
  body.in-detail #health-view.view,
  body.in-detail #review-view.view {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: stretch;
    justify-content: flex-start;
    padding:
      var(--main-content-pad-y)
      var(--main-content-pad-x)
      max(16px, env(safe-area-inset-bottom, 0px));
  }

  #macro-view > .m-page,
  #health-view > .m-page,
  #review-view > .m-page {
    padding-top: clamp(8px, 2vh, 14px);
    padding-left: 0;
    padding-right: 0;
    max-width: none;
  }

  .m-header--compact {
    flex-wrap: wrap;
    gap: 10px;
  }

  .m-header--compact .m-title {
    font-size: clamp(17px, 4.5vw, 20px);
  }

  .m-filter-bar--compact {
    flex-wrap: wrap;
  }

  .m-filter-bar--compact .m-chips {
    flex-wrap: wrap;
    max-width: 100%;
  }
}

/* ── Module 03 健康度（mh-）── */
@media (max-width: 768px) {
  #health-view .mh-mast {
    flex-direction: column;
    align-items: stretch;
  }

  #health-view .mh-periods {
    width: 100%;
    justify-content: stretch;
  }

  #health-view .mh-period {
    flex: 1 1 0;
    text-align: center;
    padding: 8px 6px;
    font-size: 11px;
  }

  #health-view .mh-canvas {
    grid-template-columns: 1fr;
  }

  #health-view .mh-radar-panel {
    min-height: min(72vw, 300px);
  }

  #health-view .mh-stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #health-view .mh-timeline {
    padding-left: 0;
  }
}

@media (max-width: 480px) {
  #health-view .mh-stat-strip {
    grid-template-columns: 1fr;
  }
}

/* ── Module 04 复盘（mr-）── */
@media (max-width: 768px) {
  #review-view .mr-tagline {
    font-size: 11.5px;
  }

  #review-view .mr-tabs {
    gap: 4px 10px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #review-view .mr-tabs::-webkit-scrollbar {
    display: none;
  }

  #review-view .mr-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  #review-view .mr-journal {
    padding-left: 2px;
    padding-right: 2px;
  }

  #review-view .mr-j-card {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ── Module 02 情报台（it2-）≤900px：顶栏菜单 + 全宽内容 ── */
@media (max-width: 900px) {
  #intel-view {
    overflow-x: hidden;
    overflow-y: visible;
    min-height: min-content;
  }

  #intel-view .it2-layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
    gap: 0;
  }

  .it2-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid rgba(20, 18, 40, 0.08);
    padding: 0 clamp(10px, 3vw, 14px) 10px;
    overflow: visible;
  }

  body.dark-mode .it2-sidebar {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .it2-sidebar-header {
    padding: 10px 0 8px;
  }

  .it2-home-btn {
    min-height: 40px;
  }

  .it2-nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 4px 0 8px;
    margin: 0 -4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .it2-nav-list::-webkit-scrollbar {
    display: none;
  }

  .it2-nav-item {
    flex: 0 0 auto;
    width: auto;
    justify-content: flex-start;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .it2-nav-label,
  .it2-nav-badge {
    display: inline !important;
  }

  .it2-sidebar-alert-zone {
    display: none;
  }

  .it2-sidebar-night {
    padding: 0 0 8px;
  }

  .it2-night-digest-btn {
    width: 100%;
    text-align: center;
    font-size: 12px;
    padding: 10px 12px;
  }

  .it2-sidebar-search {
    padding: 0 0 10px;
  }

  .it2-search-box {
    width: 100%;
    padding: 10px 12px;
    justify-content: flex-start;
  }

  .it2-search-input {
    width: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px !important;
  }

  .it2-search-input::placeholder {
    color: var(--it2-muted-color, #6868a0) !important;
  }

  .it2-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: visible;
  }

  .it2-panel {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .it2-platforms-body {
    min-height: 0;
  }

  .it2-platforms-body .it2-src-bar {
    flex-wrap: wrap;
    align-items: flex-start;
    min-height: 0;
    padding-bottom: 8px;
  }

  .it2-platforms-body .it2-src-bar-side {
    width: 100%;
    align-items: stretch;
  }

  .it2-platforms-body .it2-src-bar-actions {
    width: 100%;
    justify-content: flex-end;
    border-left: none;
    padding-left: 0;
    margin-top: 4px;
  }

  .it2-platforms-body .it2-src-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .it2-platforms-body .it2-feed-section {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .it2-platforms-body .it2-feed-viewport-wrap.is-ema-radar-mode,
  .it2-platforms-body .it2-feed-section.is-ema-radar-mode {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .it2-feed-viewport.is-ema-radar-mode {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .it2-platforms-body .it2-feed-grid.it2-feed-grid--ema-radar:not(.is-empty) {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .it2-feed-grid--ema-radar .er-dashboard--multi,
  .it2-feed-grid--ema-radar .er-dashboard.er-dashboard--multi:not(.er-dashboard--loading) {
    flex: 0 1 auto !important;
    height: auto !important;
  }

  .it2-feed-grid--ema-radar .er-tab-panel {
    flex: 0 0 auto !important;
    margin-top: clamp(8px, 2vw, 14px) !important;
  }

  .it2-feed-grid--ema-radar .er-overlap-body,
  .it2-feed-grid--ema-radar .er-table-wrap {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
  }

  .it2-feed-grid--ema-radar .er-masthead {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .it2-feed-grid--ema-radar .er-masthead-brand {
    align-self: flex-start;
  }

  .it2-feed-grid--ema-radar .er-masthead-tabs {
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
    margin-top: 0;
  }

  .it2-feed-grid--ema-radar .er-tf-nav--periods {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .it2-feed-grid--ema-radar .er-dashboard--multi {
    gap: clamp(16px, 4vw, 28px);
  }

  .it2-feed-viewport-wrap.is-ema-radar-mode {
    padding-top: 8px;
  }

  .it2-platforms-body .it2-feed-grid {
    padding-bottom: 8px;
  }

  .it2-feed-grid:not(.it2-feed-grid--ema-radar) {
    grid-template-columns: 1fr !important;
  }

  .it2-feed-detail-drawer,
  .it2-feed-detail-backdrop {
    max-width: 100%;
  }

  .it2-panel-anomaly .it2-anomaly-body,
  .it2-placeholder-body {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 768px) {
  .it2-feed-grid--ema-radar .er-masthead-name {
    font-size: clamp(16px, 4.2vw, 19px);
  }

  .it2-feed-grid--ema-radar .er-overlap-group {
    margin-bottom: 12px;
  }

  .gh-dashboard .gh-hero {
    flex-direction: column;
    align-items: flex-start;
  }
}
