/* Phone layout only: the desktop styles and content remain unchanged. */
@media (max-width: 760px) {
  .shell, .dc-shell, .edition-page .dc-shell { width: calc(100% - 32px); }
  .site-header .nav-main { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .site-header .nav-actions { gap: 16px; flex-wrap: wrap; font-size: 14px; }
  .site-header .nav-actions > a:not(.button) { display: inline-flex; color: #4f0058; min-height: 44px; }
  .site-header .brand .finatal-logo { width: 108px; }
  .brand span { white-space: normal; }
  .report-header h1, body[data-page="ocfo"] .dc-hero h1,
  body[data-page="ma"] .report-header h1, body[data-page="investment"] .report-header h1 { font-size: clamp(32px, 7.5vw, 44px); line-height: 1.12; }
  .report-header .lede, .dc-hero-lede { font-size: 17px; line-height: 1.5; }
  .benchmark-layout, .two-columns, .source-grid, .dc-context-grid,
  .edition-benchmark-grid, body[data-page="ocfo"] .dc-role-grid { grid-template-columns: minmax(0, 1fr); }
  .benchmark-layout > *, .two-columns > *, .dc-panel, .dc-chart, .history-chart,
  .table-scroll, .result-table, .edition-table-scroll { min-width: 0; max-width: 100%; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat, .stat:first-child { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stat strong { grid-column: 1; grid-row: auto; }
  .controls, .history-controls { gap: 16px; }
  .controls .field, .history-controls .field { flex-basis: 100%; min-width: 0; max-width: none; }
  input, select, textarea { font-size: 16px; }
  select { max-width: 100%; min-height: 48px; }
  .dc-measure-controls { flex-wrap: wrap; gap: 8px; }
  .dc-measure, body[data-page="ocfo"] .dc-measure, .edition-explorer .dc-measure { min-height: 44px; font-size: 14px; padding: 9px 12px; white-space: normal; }
  .dc-panel-head, body[data-page="ocfo"] .dc-panel-head { display: block; padding: 18px 16px; }
  .dc-measure-controls { margin-top: 14px; justify-content: flex-start; }
  .bar-row, #ip-comparison .bar-row, #carry-comparison .bar-row,
  .dc-chart-row, .edition-explorer .dc-chart-row, body[data-page="ocfo"] .dc-chart-row {
    grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 14px 4px; min-height: 66px;
  }
  .bar-row .bar-track, .dc-chart-row .dc-bar-track,
  .edition-explorer .dc-chart-row .dc-bar-track, body[data-page="ocfo"] .dc-chart-row .dc-bar-track {
    display: block; grid-column: 1 / -1; grid-row: 2; height: 10px;
  }
  .bar-row strong, .dc-chart-row .dc-row-value,
  .edition-explorer .dc-chart-row .dc-row-value { grid-column: 2; grid-row: 1; }
  .dc-chart-scale { grid-template-columns: minmax(0, 1fr) auto; }
  .dc-chart-scale span:nth-child(2) { display: none; }
  .dc-row-name, .dc-row-value, body[data-page="ocfo"] .dc-row-name,
  body[data-page="ocfo"] .dc-row-value { font-size: 14px; line-height: 1.45; }
  body[data-page="ocfo"] .dc-sector-row, body[data-page="ocfo"] .dc-benefit-row {
    grid-template-columns: minmax(0, 1fr) auto; min-height: 64px; gap: 8px 12px; padding: 12px 0;
  }
  body[data-page="ocfo"] .dc-sector-row .dc-change,
  body[data-page="ocfo"] .dc-benefit-row .dc-change { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  body[data-page="ocfo"] .dc-sector-name, body[data-page="ocfo"] .dc-benefit-name,
  body[data-page="ocfo"] .dc-sector-value, body[data-page="ocfo"] .dc-benefit-value,
  body[data-page="ocfo"] .dc-change { font-size: 14px; line-height: 1.4; }
  .history-card { padding: 18px 14px; }
  .history-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 0; }
  .history-track { grid-column: 1 / -1; grid-row: 2; }
  .history-value { grid-column: 2; grid-row: 1; }
  .table-scroll, .result-table, .edition-table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
  .edition-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 14px; }
  .edition-tabs .dc-tab { white-space: normal; }
  .quick-download { width: 100%; max-width: 100%; }
  .quick-download > summary { min-height: 48px; padding: 13px 16px; }
  .quick-name-row, .callback-name-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .quick-submit { width: 100%; min-height: 48px; }
  .callback-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); padding: 26px 20px; overscroll-behavior: contain; }
  .callback-dialog h2 { font-size: 25px; }
  .floating-callback, body[data-page="search"] .floating-callback { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); min-height: 44px; padding: 11px 16px; font-size: 14px; }
  .guide-hero { min-height: 0; padding-block: 38px; }
  .guide-card { padding: 22px 18px; }
  .report-access-card, .archive-form-card { padding: 24px 20px; }
  .site-legal-footer { text-align: center; }

  /* Keep the homepage within the phone viewport, with a dedicated footer area. */
  body[data-page="search"] { height: var(--mobile-viewport-height, 100dvh); max-height: var(--mobile-viewport-height, 100dvh); }
  body[data-page="search"] > .search-header { min-height: 60px; padding: 8px 12px; flex-wrap: wrap; gap: 0 10px; }
  .search-header .session-header-left { gap: 8px; }
  .search-header .session-icon-button { width: 36px; height: 44px; }
  .search-header .finatal-logo { width: 90px; }
  .search-header .header-actions { margin-left: auto; gap: 4px 12px; flex-wrap: wrap; font-size: 13px; }
  body[data-page="search"]:not(.has-results) #main {
    padding: 12px 14px calc(var(--mobile-footer-height, 164px) + 8px) !important; gap: 14px;
  }
  body[data-page="search"]:not(.has-results) .welcome-message h2 { font-size: 18px; line-height: 1.35; }
  body[data-page="search"]:not(.has-results) .search-stage { min-height: 0; gap: 14px; flex-shrink: 1; }
  body[data-page="search"] .search-composer { flex-shrink: 0; }
  body[data-page="search"]:not(.has-results) #search-form { display: grid; align-items: center; padding: 12px 14px; gap: 10px; grid-template-columns: minmax(0, 1fr) 44px; }
  body[data-page="search"]:not(.has-results) #question { font-size: 16px; line-height: 22px; height: 66px; min-height: 66px; max-height: 66px; padding: 0; overflow-y: auto; }
  body[data-page="search"] .search-submit { width: 44px; height: 44px; }
  body[data-page="search"]:not(.has-results) .home-below-prompt { min-height: 0; gap: 10px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
  body[data-page="search"]:not(.has-results) .example-prompts { grid-template-columns: minmax(0, 1fr); gap: 6px; flex: none; max-height: none; overflow: visible; }
  body[data-page="search"]:not(.has-results) .example-prompts > button { min-height: 44px; padding: 9px 12px; font-size: 14px; line-height: 1.35; }
  body[data-page="search"]:not(.has-results) .latest-reports { min-width: 0; max-width: 100%; margin-top: 4px; }
  body[data-page="search"]:not(.has-results) .latest-reports h2 { margin-bottom: 8px; }
  body[data-page="search"]:not(.has-results) .latest-report-links { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; max-height: none; padding: 2px 2px 6px; gap: 8px; }
  body[data-page="search"]:not(.has-results) .latest-report-links > a { flex: 0 0 auto; min-height: 44px; padding: 8px 12px; font-size: 13px; }
  body[data-page="search"]:not(.has-results) > .site-legal-footer, body[data-page="search"].has-results > .site-legal-footer { padding: 8px 14px calc(66px + env(safe-area-inset-bottom)) !important; gap: 7px; }
  body[data-page="search"] .site-legal-footer .site-legal-links { padding: 0; justify-content: center; gap: 4px 16px; }
  body[data-page="search"].has-results .search-stage { padding: 8px 12px calc(var(--mobile-footer-height, 164px) + 8px) !important; max-height: none; overflow: visible; }
  .has-results .conversation { padding: 20px 14px; }
  .has-results .answer-figure { padding: 12px; }
  .visual-toolbar { flex-wrap: wrap; gap: 12px; }
  .view-switch button, .pin-button, .followups button { min-height: 44px; }
  .answer-figure .visual-toolbar > .chat-report-access { flex-basis: 100%; max-width: none; }
  .answer-figure .visual-toolbar .report-access-link { min-height: 44px; }
  .session-sidebar { max-height: var(--mobile-viewport-height, 100dvh); }

  /* The on-screen keyboard gets priority while the visitor is typing. */
  body[data-page="search"].mobile-keyboard-open > .site-legal-footer,
  body[data-page="search"].mobile-keyboard-open .floating-callback,
  body[data-page="search"].mobile-keyboard-open:not(.has-results) .search-results,
  body[data-page="search"].mobile-keyboard-open .home-below-prompt { display: none !important; }
  body[data-page="search"].mobile-keyboard-open:not(.has-results) #main { padding-bottom: 16px !important; }
  body[data-page="search"].mobile-keyboard-open.has-results .search-stage { padding-bottom: 12px !important; }
}
@media (max-width: 760px) and (max-height: 740px) {
  body[data-page="search"]:not(.has-results) .welcome-fina-mark { width: 36px; height: 36px; margin-bottom: 12px; }
  body[data-page="search"]:not(.has-results) .welcome-message h2 { font-size: 17px; }
  body[data-page="search"]:not(.has-results) #main { gap: 10px; }
  body[data-page="search"]:not(.has-results) .example-prompts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body[data-page="search"]:not(.has-results) .example-prompts > button { min-height: 100px; padding: 8px; font-size: 13px; }
}
