/* TAN-1972 PWA landscape/portrait polish (folds TAN-1958 / 1881 / 1882).
   Phone-only. Desktop (≥769px portrait, height >500 landscape) is unchanged. */

.sentiment-chip { display: none; }

.pwa-rotate-hint {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(var(--pwa-nav-h, 52px) + env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%);
  z-index: 9500;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: var(--text-secondary, #94A3B8);
  font: 600 11px/1.2 var(--font-body, Inter, system-ui, sans-serif);
  letter-spacing: 0.04em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.settings-build-ver {
  display: none;
  margin: 16px 0 8px;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-faint, #64748B);
  letter-spacing: 0.04em;
}

.pt-kpi-compact { display: none; }

/* ── Phone portrait (max-width 768) ── */
@media (max-width: 768px) {
  :root {
    --topbar-h: 40px;
    --header-h: 40px;
    --sidebar-w: 56px;
  }

  /* Matt Oct 20: --topbar-h is 40px here but the fixed hamburger/search were
     40px tall at safe+8px, so they hung 8px past the header divider. Size to
     the 40px band: 34px boxes at safe+3px, centered on the same line as the
     sentiment strip and bell (topbar-center sits at safe + topbar-h/2). */
  .hamburger-btn,
  .hamburger-cmdk {
    top: calc(3px + env(safe-area-inset-top, 0px));
    width: 34px;
    height: 34px;
  }
  .hamburger-cmdk { left: 52px; }
  .hamburger-btn svg,
  .hamburger-cmdk svg { width: 18px; height: 18px; }
  /* Matt Oct 20: regime strip must sit on the true centre of the bar, not the
     centre of the grid cell left over after the 108px hamburger/search padding
     and the bell column. Pin it to the viewport centre line. */
  .topbar-center,
  .topbar .topbar-center {
    position: absolute !important;
    left: 50% !important;
    top: calc(env(safe-area-inset-top, 0px) + var(--topbar-h, 40px) / 2) !important;
    transform: translate(-50%, -50%) !important;
    justify-self: auto;
    margin: 0 !important;
    width: auto;
    max-width: calc(100% - 200px);
  }

  .topbar-title { font-size: 18px; }

  .topbar-cmdk-label,
  .topbar-cmdk-kbd,
  .cc-alerts-label,
  .tab-tour-replay-label,
  .terminal-tour-replay > span,
  .nav-sw-version,
  .cc-sw-version { display: none !important; }

  .sidebar-brand-word { display: none !important; }
  .sidebar-nav-item svg.nav-icon { width: 22px; height: 22px; }

  /* Matt Oct 15: alerts dropdown clipped off the left edge. Anchor to the
     full .topbar-right box (not the bell) and cap to the viewport. */
  .topbar-right .cc-alerts-wrap { position: static; }
  .topbar-right .cc-alerts-dropdown {
    right: 0;
    left: auto;
    width: min(420px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
  }

  /* Portrait rails: keep the prod 6-col grid (Matt Oct 15: 4-col never approved). */

  #view-c .vc-pta-panel,
  #view-c .cc-pta-rail-host,
  .cc-pta-rail-host {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* TAN-2191: 28px height clipped the stacked speed chips + play under
     .ff-section overflow:hidden (replay bar cut off by the canvas). */
  .ff-head {
    min-height: 28px;
    height: auto;
    padding: 6px max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px));
    gap: 8px;
    overflow: visible;
    flex-shrink: 0;
  }
  .ff-head-right {
    flex-wrap: wrap;
    row-gap: 6px;
    overflow: visible;
  }
  .ff-title,
  .ff-meta { font-size: 12px; }

  .pulse-v3-detail-panel .cloud-tf-toggle,
  .pulse-v3-detail-panel .cloud-legend-bar,
  #view-c .pulse-v3-detail-panel .cloud-tf-toggle,
  #view-c .cloud-legend-bar { display: none !important; }

  [id^="canon-v3-toolbar-pulse-"].canon-v3-toolbar,
  .canon-v3-toolbar-row-pulse-v3 .canon-v3-toolbar,
  #view-c .pulse-v3-detail-panel .canon-v3-toolbar,
  .pulse-v3-detail-panel .canon-v3-toolbar {
    display: none !important;
  }

  /* TAN-2007: one horizontally scrollable chip row (375/390). TAN-1882 wrap
     stacked MACD/Conf and N/F2H/LogH. Match landscape pulse + app.css nowrap. */
  #cloud-chart-modal .canon-v3-toolbar,
  #canon-v3-toolbar-modal.canon-v3-toolbar {
    flex-wrap: nowrap !important;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #cloud-chart-modal .canon-v3-toolbar::-webkit-scrollbar,
  #canon-v3-toolbar-modal.canon-v3-toolbar::-webkit-scrollbar { display: none; }
  #cloud-chart-modal .canon-v3-toolbar > .tb-group.tb-tfs,
  #canon-v3-toolbar-modal.canon-v3-toolbar > .tb-group.tb-tfs {
    flex-basis: auto !important;
    flex-shrink: 0;
    justify-content: flex-start;
  }

  .pwa-rotate-hint { display: inline-flex; }

  .settings-build-ver { display: block; }

  .portfolio-page .pt-kpi-strip { display: none !important; }
  .portfolio-page .pt-kpi-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 6px;
    max-height: 220px;
    overflow: hidden;
  }
  .portfolio-page .pt-kpi-compact .pt-kpi-hero {
    grid-column: 1 / -1;
  }
  .portfolio-page .pt-kpi-compact .pt-kpi-tile {
    min-height: 0;
    padding: 8px 10px;
  }
  .portfolio-page .pt-kpi-compact .pt-kpi-val { font-size: 16px; }
}

@media (max-width: 390px) {
  .portfolio-page .pt-kpi-compact { max-height: 220px; }
}

/* ── Phone landscape (iPhone ~844×390 skips max-width 768) ── */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --topbar-h: 40px;
    --header-h: 40px;
    --sidebar-w: 56px;
  }

  /* Matt Oct 20: --topbar-h is 40px here but the fixed hamburger/search were
     40px tall at safe+8px, so they hung 8px past the header divider. Size to
     the 40px band: 34px boxes at safe+3px, centered on the same line as the
     sentiment strip and bell (topbar-center sits at safe + topbar-h/2). */
  .hamburger-btn,
  .hamburger-cmdk {
    top: calc(3px + env(safe-area-inset-top, 0px));
    width: 34px;
    height: 34px;
  }
  .hamburger-cmdk { left: 52px; }
  .hamburger-btn svg,
  .hamburger-cmdk svg { width: 18px; height: 18px; }
  /* Matt Oct 20: regime strip must sit on the true centre of the bar, not the
     centre of the grid cell left over after the 108px hamburger/search padding
     and the bell column. Pin it to the viewport centre line. */
  .topbar-center,
  .topbar .topbar-center {
    position: absolute !important;
    left: 50% !important;
    top: calc(env(safe-area-inset-top, 0px) + var(--topbar-h, 40px) / 2) !important;
    transform: translate(-50%, -50%) !important;
    justify-self: auto;
    margin: 0 !important;
    width: auto;
    max-width: calc(100% - 200px);
  }

  .topbar-title { font-size: 18px; }

  .topbar-cmdk-label,
  .topbar-cmdk-kbd,
  .cc-alerts-label,
  .tab-tour-replay-label,
  .terminal-tour-replay > span,
  .nav-sw-version,
  .cc-sw-version { display: none !important; }

  .sentiment-label,
  .sentiment-bar,
  .sentiment-score-label { display: none !important; }
  .sentiment-chip {
    display: inline-flex !important;
    align-items: center;
    font: 700 12px/1 var(--font-mono, 'JetBrains Mono', monospace);
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  .sidebar-brand-word { display: none !important; }
  .sidebar-nav-item svg.nav-icon { width: 22px; height: 22px; }

  #view-c .triage-grid,
  .pulse-v3-active .triage-grid,
  .pulse-triage-stack .triage-grid,
  .triage-rail {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 4px;
  }
  .triage-rail .tr-tile,
  #view-c .triage-grid .tr-grid-cell,
  .pulse-v3-active .triage-grid .tr-grid-cell {
    min-height: 36px;
    max-width: 84px;
    width: auto;
    padding: 2px 6px;
    margin-bottom: 0;
  }

  #view-c .vc-pta-panel,
  #view-c .cc-pta-rail-host,
  .cc-pta-rail-host {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* TAN-2191: 28px height clipped the stacked speed chips + play under
     .ff-section overflow:hidden (replay bar cut off by the canvas). */
  .ff-head {
    min-height: 28px;
    height: auto;
    padding: 6px max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px));
    gap: 8px;
    overflow: visible;
    flex-shrink: 0;
  }
  .ff-head-right {
    flex-wrap: wrap;
    row-gap: 6px;
    overflow: visible;
  }
  .ff-title,
  .ff-meta { font-size: 12px; }

  .pulse-v3-detail-panel .cloud-tf-toggle,
  .pulse-v3-detail-panel .cloud-legend-bar,
  #view-c .pulse-v3-detail-panel .cloud-tf-toggle,
  #view-c .cloud-legend-bar { display: none !important; }

  [id^="canon-v3-toolbar-pulse-"].canon-v3-toolbar,
  .canon-v3-toolbar-row-pulse-v3 .canon-v3-toolbar,
  #view-c .pulse-v3-detail-panel .canon-v3-toolbar,
  .pulse-v3-detail-panel .canon-v3-toolbar {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  [id^="canon-v3-toolbar-pulse-"].canon-v3-toolbar::-webkit-scrollbar,
  .canon-v3-toolbar-row-pulse-v3 .canon-v3-toolbar::-webkit-scrollbar,
  #view-c .pulse-v3-detail-panel .canon-v3-toolbar::-webkit-scrollbar,
  .pulse-v3-detail-panel .canon-v3-toolbar::-webkit-scrollbar { display: none; }

  .pwa-rotate-hint { display: none !important; }

  .settings-build-ver { display: block; }

  .portfolio-page .pt-kpi-strip { display: none !important; }
  .portfolio-page .pt-kpi-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    max-height: 220px;
    overflow: hidden;
  }
  .portfolio-page .pt-kpi-compact .pt-kpi-hero { grid-column: 1 / -1; }
  .portfolio-page .pt-kpi-compact .pt-kpi-tile {
    min-height: 0;
    padding: 6px 8px;
  }
}
