/* Narrow workspaces get a real device-width canvas without shrinking charts. */
@media (max-width: 1279px) {
  body { min-width: 0; }

  .shell {
    width: min(1280px, calc(100% - clamp(24px, 4vw, 48px)));
  }

  .dashboard-detail {
    min-width: 0;
  }
}

/* Keep research charts' existing readable scale; contain their horizontal
   overflow inside the research panel rather than the document and nav. */
@media (max-width: 1000px) {
  .dashboard-detail:has(> .tab-surface:not(.tab-surface--launch, .fof-overview-surface)) {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  .dashboard-detail > .tab-surface:not(.tab-surface--launch, .fof-overview-surface) {
    min-inline-size: 950px;
  }

  .topbar {
    display: grid;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    padding: 12px 14px;
  }

  .topbar-brand { display: contents; }

  .topbar-brand > :first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .topbar h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .eyebrow { margin-bottom: 3px; }

  .topbar .topbar-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 4px;
    scrollbar-width: thin;
  }

  .topbar .tab-button { flex: 0 0 auto; white-space: nowrap; }
  .topbar .top-actions { grid-column: 2; grid-row: 1; justify-self: end; }
}

@media (max-width: 820px) {
  .auth-view {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    border-radius: 20px;
  }

  .brand-panel, .auth-card {
    grid-column: 1;
    padding: clamp(20px, 5vw, 38px);
  }

  .brand-panel {
    grid-template-rows: auto auto;
    gap: 10px;
  }

  .brand-copy h1 {
    font-size: clamp(34px, 7vw, 51px);
    line-height: .98;
  }

  .brand-copy > p { margin-top: 8px; }
  .brand-modules { display: none; }
  .brand-foot { justify-self: start; margin: 0; }
  .hero-logo { margin-block-end: 12px; }

  .auth-card {
    border-top: 1px solid var(--line);
    border-left: 0;
    box-shadow: none;
    transform: none;
  }

  .auth-card input:not([type="checkbox"]) { font-size: 16px; }
}

@media (max-width: 530px) {
  .shell { padding-top: 12px; }
  .app-view { gap: 12px; }

  .topbar {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .topbar h1 { font-size: 20px; }

  .topbar .top-actions {
    grid-column: 1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-start;
    overflow-x: auto;
    border-radius: 10px;
  }

  .topbar .topbar-tabs { grid-row: 3; }
  .topbar .tab-button,
  .topbar .secondary-button { min-height: 38px; padding-inline: 12px; }
}

/* Reducing animation must also remove entrance delays on form controls. */
@media (prefers-reduced-motion: reduce) {
  .brand-copy, .brand-foot, .brand-modules li, .auth-card { animation: none; }
}
