/*
 * styles-6-todays-brief.css
 *
 * Todays Brief grid, weather/commute/markets chips, IPL snapshot, viewport responsive.
 *
 * Phase 5 S3 pass-2: extracted from the monolithic styles.css
 * (8 286 LOC) to bring every CSS source file under the < 1 500
 * LOC bar. Load order in index.html preserves the original
 * cascade exactly: this file occupies lines 4842 - 6233 of the
 * pre-split styles.css.
 */

/* Today’s Brief — one chip height for Markets, Commute, Weather; IPL uses a taller token for score tables */
#today-brief-section {
  --today-brief-commute-h: min(15rem, 40svh);
  --today-brief-ipl-h: min(26rem, 64svh);
  /* Identical inset for Markets + Commute chips (pair in home grid) */
  --today-brief-chip-pad: 0.4rem 0.55rem 0.45rem;
}

/* Today’s Brief weather — single #weather-card (nested under #today-brief-section) */
.today-brief-weather.mobile-weather-brief {
  display: block;
  margin: 0.35rem 0 0.85rem;
  padding: 0;
}

.today-brief .today-brief-weather.mobile-weather-brief:first-of-type {
  margin-top: 0.25rem;
}

/* Match Commute chip box; align header with other brief chips (top-anchored, not vertically centered) */
#today-brief-section #brief-card-markets.today-brief__card--markets {
  display: flex;
  flex-direction: column;
  height: var(--today-brief-commute-h);
  min-height: var(--today-brief-commute-h);
  max-height: var(--today-brief-commute-h);
  overflow-x: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.28rem;
  padding: var(--today-brief-chip-pad);
  color: inherit;
  cursor: default;
}

#today-brief-section #brief-card-markets .today-brief__markets-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.15rem;
  margin: 0;
  line-height: 1.2;
  align-self: stretch;
  min-width: 0;
}

#today-brief-section #brief-card-markets .today-brief__eyebrow {
  margin: 0;
  line-height: 1.2;
  flex: 0 0 auto;
}

#today-brief-section #brief-card-markets .today-brief__markets-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Same header treatment as Markets chip */
#today-brief-section #commute-card .today-brief__eyebrow {
  margin: 0;
  line-height: 1.2;
  align-self: stretch;
  /* Keep “Commute” from running under the top-right refresh control */
  padding-inline-end: 2.65rem;
  box-sizing: border-box;
}

#today-brief-section #commute-card.today-brief__card.today-brief__card--commute {
  height: var(--today-brief-commute-h);
  min-height: var(--today-brief-commute-h);
  max-height: var(--today-brief-commute-h);
  box-sizing: border-box;
  padding: var(--today-brief-chip-pad);
  gap: 0.32rem;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* Weather in Today’s Brief — same footprint as commute chip; hourly scrolls inside */
#today-brief-section #weather-card.weather-card--brief {
  cursor: default;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 0.36rem 0.5rem 0.42rem;
  transition:
    border-color 0.18s ease,
    background 0.18s ease;
  height: var(--today-brief-commute-h);
  min-height: var(--today-brief-commute-h);
  max-height: var(--today-brief-commute-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Informational: subtle border highlight only (no “lift” — avoids looking tappable) */
#today-brief-section #weather-card.weather-card--brief:hover {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  box-shadow: none;
  transform: none;
}

#today-brief-section #weather-card.weather-card--brief.card:hover {
  box-shadow: none;
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
}

/* Current conditions: hourly lives in .weather-hourly-details (side-by-side on wide viewports). */
#today-brief-section #weather-card.weather-card--brief .weather-inline {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  overflow: hidden;
}

#today-brief-section #weather-card.weather-card--brief .weather-hourly-details {
  /* Size to heading + hourly strip only — flex-grow was leaving a dead band above the card bottom. */
  flex: 0 1 auto;
  min-height: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 88%, var(--border));
  padding: 0;
  margin: 0;
}

#today-brief-section #weather-card.weather-card--brief .weather-hourly-details__heading {
  /* Keep hourly heading on same left vertical line as temperature row. */
  padding: var(--space-1) 0 0.15rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
}

@media (min-width: 821px) {
  #today-brief-section #weather-card.weather-card--brief {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    column-gap: var(--space-2);
    row-gap: 0;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-inline {
    grid-column: 1;
    grid-row: 1;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-hourly-details {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: none;
    background: transparent;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-hourly-details > .weather-hourly-details__heading {
    display: none;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-hourly-details #weather-hourly.hourly-forecast {
    flex: 0 1 auto;
    min-height: 0;
    min-width: 0;
  }
}

#today-brief-section #weather-card.weather-card--brief .weather-inline__summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  text-align: left;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: visible;
}

#today-brief-section #weather-card.weather-card--brief .weather-card__eyebrow {
  margin: 0;
}

#today-brief-section #weather-card.weather-card--brief .weather-card__top--standalone {
  margin-top: 0;
  margin-bottom: 0;
  width: 100%;
}

#today-brief-section #weather-card.weather-card--brief .card__top--tile > h2 {
  margin: 0;
  min-width: 0;
  font-size: var(--type-meta);
  font-weight: var(--font-weight-medium);
  line-height: 1.2;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#today-brief-section #weather-card.weather-card--brief .weather-card__top--standalone .status {
  font-size: var(--type-meta);
  max-width: min(52vw, 16rem);
}

#today-brief-section #weather-card.weather-card--brief .weather-current-row {
  margin: 0;
  gap: 0.2rem 0.45rem;
  flex-wrap: wrap;
  align-items: flex-start;
  min-width: 0;
}

#today-brief-section #weather-card.weather-card--brief .weather-current__main {
  font-size: clamp(0.95rem, 0.88rem + 0.25vw, 1.1rem);
  font-weight: var(--font-weight-semibold);
  line-height: var(--font-line-tight);
  color: var(--text);
  letter-spacing: -0.02em;
  min-width: 0;
  flex: 0 1 auto;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#today-brief-section #weather-card.weather-card--brief .weather-current__feels {
  font-size: var(--type-meta);
  font-weight: var(--font-weight-regular);
  color: var(--text-secondary);
  white-space: normal;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 7.5rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#today-brief-section #weather-card.weather-card--brief .weather-desc {
  margin: 0;
  font-size: var(--type-meta);
  line-height: var(--font-line-snug);
  color: var(--text-meta);
  font-weight: var(--font-weight-regular);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#today-brief-section #weather-card.weather-card--brief .hourly-forecast__caption {
  margin: 0.2rem 0 0;
  font-size: 0.58rem;
  flex: 0 0 auto;
}

#today-brief-section #weather-card.weather-card--brief.dashboard-tile.tile-type-horizontal-scroll {
  overflow: hidden;
}

#today-brief-section #weather-card.weather-card--brief #weather-hourly.hourly-forecast {
  min-width: 0;
  width: 100%;
  /* Override .dashboard-tile--weather #weather-hourly min-height so strip hugs chips + scrollbar. */
  min-height: 0;
  max-height: 100%;
  margin-top: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-gutter: auto;
  padding-left: 0;
  padding-bottom: 0;
  align-items: flex-start;
  align-self: stretch;
}

#today-brief-section #weather-card.weather-card--brief .hourly-forecast .hour-block {
  min-width: 3.95rem;
  padding: 0.07rem 0.18rem;
  color: var(--text);
  border-color: var(--hour-border);
}

#today-brief-section #weather-card.weather-card--brief .hour-block__time,
#today-brief-section #weather-card.weather-card--brief .hour-block__temp {
  color: var(--text);
}

#today-brief-section #weather-card.weather-card--brief .hour-block__feels-label,
#today-brief-section #weather-card.weather-card--brief .hour-block__meta {
  color: var(--muted);
}

#today-brief-section #weather-card.weather-card--brief .hour-block__time {
  font-size: 0.52rem;
  margin: 0;
}

#today-brief-section #weather-card.weather-card--brief .hour-block__feels-label {
  font-size: 0.48rem;
  margin: 0.03rem 0 0;
}

#today-brief-section #weather-card.weather-card--brief .hour-block__temp {
  font-size: 0.58rem;
  margin: 0.03rem 0 0;
  line-height: 1.12;
}

#today-brief-section #weather-card.weather-card--brief .hour-block__meta {
  font-size: 0.5rem;
  margin: 0.02rem 0 0;
  line-height: 1.12;
}

#today-brief-section #weather-card.weather-card--brief .weather-hourly-toggle__icon {
  width: 18px;
  height: 18px;
}

/* Commute chip in Today’s Brief grid — stretch to grid row so height matches Markets */
.today-brief__grid-commute {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 0;
  height: 100%;
}

#commute-card.today-brief__card.today-brief__card--commute {
  cursor: default;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  text-align: left;
  align-items: flex-start;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

#commute-card.today-brief__card.today-brief__card--commute:hover {
  transform: none;
  box-shadow: var(--card-elev-subtle);
  border-color: var(--border);
}

#commute-card.today-brief__card .today-brief__commute-status {
  font-size: var(--type-meta);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  max-width: min(52vw, 16rem);
}

#commute-card.today-brief__card .today-brief__text {
  margin: 0;
  width: 100%;
}

#commute-card.today-brief__card .today-brief__text--commute-duration {
  font-size: clamp(1rem, 0.92rem + 0.28vw, 1.15rem);
  font-weight: var(--font-weight-semibold);
  line-height: var(--font-line-tight);
  color: var(--text);
  letter-spacing: -0.02em;
}

#commute-card.today-brief__card .commute-inline__detail {
  color: var(--text-secondary);
  font-size: var(--type-meta);
}

#commute-card.today-brief__card .tile-refresh-corner--top-end {
  top: max(0.28rem, env(safe-area-inset-top, 0px));
  right: max(0.28rem, env(safe-area-inset-right, 0px));
}

#commute-card.today-brief__card .tile-refresh-btn {
  border-radius: 10px;
  opacity: 0.92;
}

/* IPL snapshot in Today’s Brief — same chip height as Commute; body scrolls */
#brief-card-ipl.today-brief__card--ipl-brief {
  cursor: default;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: var(--today-brief-ipl-h);
  min-height: var(--today-brief-ipl-h);
  max-height: var(--today-brief-ipl-h);
  overflow: hidden;
  padding: 0.36rem 0.48rem 0.42rem;
  gap: 0.15rem;
}

#brief-card-ipl.today-brief__card--ipl-brief:hover {
  transform: none;
  box-shadow: var(--card-elev-subtle);
  border-color: var(--border);
}

#brief-card-ipl .today-brief__eyebrow {
  margin: 0;
  flex: 0 0 auto;
  line-height: 1.2;
}

#brief-card-ipl .brief-ipl-scroll {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  overscroll-behavior: none;
  font-size: clamp(0.52rem, 0.48rem + 0.18vw, 0.62rem);
  line-height: 1.25;
}

#brief-card-ipl .brief-ipl-scroll .ipl-match-title {
  font-size: 0.58rem;
  margin: 0 0 0.12rem;
  line-height: 1.2;
}

#brief-card-ipl .brief-ipl-scroll .ipl-section-title {
  font-size: 0.54rem;
  margin: 0.18rem 0 0.06rem;
}

#brief-card-ipl .brief-ipl-scroll .ipl-table {
  font-size: 0.52rem;
}

#brief-card-ipl .brief-ipl-scroll .ipl-table th,
#brief-card-ipl .brief-ipl-scroll .ipl-table td {
  padding: 0.06rem 0.14rem;
}

#brief-card-ipl .today-brief__ipl-status {
  font-size: 0.56rem;
  max-width: min(70vw, 18rem);
  flex: 0 0 auto;
}

#brief-card-ai-news.today-brief__card--ai-news {
  cursor: default;
  width: 100%;
  max-width: 100%;
  grid-column: 1 / -1;
  align-self: stretch;
  gap: 0.5rem;
  padding: 0.58rem 0.65rem 0.62rem;
  box-sizing: border-box;
}

#brief-card-ai-news.today-brief__card--ai-news:hover {
  transform: none;
  box-shadow: var(--card-elev-subtle);
  border-color: var(--border);
}

#brief-card-ai-news.today-brief__card--ai-news > .today-brief__eyebrow {
  letter-spacing: 0.06em;
}

#brief-card-ai-news .brief-ai-news__block + .brief-ai-news__block {
  margin-top: 0.35rem;
  padding-top: 0.48rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
}

.brief-ai-news__block {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.brief-ai-news__lead {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.28;
  font-weight: 600;
  color: var(--muted);
}

.brief-ai-news__lead--with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.brief-ai-news__lead strong {
  font-weight: 700;
  color: var(--accent);
}

/* Align with Markets label rhythm: one row of controls per summary line */
.brief-ai-news__minutes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.28rem;
  width: 100%;
  align-items: stretch;
}

.brief-ai-news__audio-btn.news-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  width: 100%;
  height: auto;
  min-width: 0;
  padding: 0.26rem 0.35rem;
  min-height: 2.05rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  background: color-mix(in srgb, var(--surface) 70%, var(--surface-alt));
}

.brief-ai-news__lead--with-action .brief-ai-news__audio-btn.news-audio-btn {
  width: auto;
  /* Phase 4 S4 a11y: was 1.65rem (~26px) — fails WCAG 2.5.5. Bumped to
     the global var so it inherits the same min as every other touch
     target on the page. Visual padding stays slim. */
  min-width: max(4.2rem, var(--touch-target-min, 48px));
  min-height: var(--touch-target-min, 48px);
  padding: 0.18rem 0.42rem;
  margin-left: auto;
}

.brief-ai-news__audio-btn.news-audio-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface-alt));
}

.brief-ai-news__btn-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
}

.brief-ai-news__min-label {
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}

.today-brief__browse-news-btn {
  margin-top: 0.25rem;
  align-self: stretch;
  padding: 0.4rem 0.65rem;
  min-height: 2.25rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 38%, var(--surface-alt));
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.today-brief__browse-news-btn:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 52%, var(--surface-alt));
}

.today-brief__browse-news-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  #brief-card-ai-news.today-brief__card--ai-news {
    padding: 0.38rem 0.5rem 0.45rem;
    gap: 0.3rem;
  }

  #brief-card-ai-news .brief-ai-news__block + .brief-ai-news__block {
    margin-top: 0.22rem;
    padding-top: 0.32rem;
  }

  .brief-ai-news__block {
    gap: 0.2rem;
  }

  .brief-ai-news__lead {
    font-size: 0.6rem;
    line-height: 1.22;
  }

  .brief-ai-news__lead--with-action {
    gap: 0.3rem;
  }

  .brief-ai-news__minutes {
    gap: 0.2rem;
  }

  .brief-ai-news__audio-btn.news-audio-btn {
    /* Dense layout; stay close to 44×44 ideal via wider tap targets horizontally */
    min-height: 2.05rem;
    padding: 0.22rem 0.32rem;
  }

  .brief-ai-news__lead--with-action .brief-ai-news__audio-btn.news-audio-btn {
    min-height: 1.55rem;
    min-width: 3.95rem;
    padding: 0.14rem 0.36rem;
  }

  .brief-ai-news__min-label {
    font-size: 0.58rem;
  }

  .today-brief__browse-news-btn {
    min-height: 1.85rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.64rem;
    margin-top: 0.12rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .today-brief__card,
  #today-brief-section #weather-card.weather-card--brief {
    transition: none;
  }

  .today-brief__card.card-interactive::before,
  a.today-brief__panel.surface-interactive::before {
    transition: none;
    opacity: 0 !important;
  }

  .today-brief__card.card-interactive:active,
  a.today-brief__panel.surface-interactive:active {
    transform: none;
  }
}

@media (max-width: 820px) {
  #brief-card-ipl.today-brief__card--ipl-brief {
    padding: 0.32rem 0.45rem 0.38rem;
    gap: 0.14rem;
  }
}

/* Very short viewports (e.g. phone landscape): hide quote, tighten chips so home stays usable */
@media (max-width: 820px) and (max-height: 520px) {
  .dashboard__quote-column {
    display: none;
  }

  .dashboard__header {
    margin-bottom: 0.35rem;
    gap: 0.35rem;
  }

  #today-brief-section {
    --today-brief-commute-h: clamp(5.75rem, 18svh, 9rem);
    --today-brief-ipl-h: clamp(9.5rem, 26svh, 15rem);
  }

  .today-brief {
    margin-bottom: 0.35rem;
  }

  .today-brief__intro {
    margin-bottom: 0.25rem;
  }

  .today-brief-weather.mobile-weather-brief {
    margin: 0.08rem 0 0.28rem;
  }

  .today-brief__grid {
    gap: 0.3rem;
  }
}

.weather-card__top--standalone {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

/* Keep the hourly chevron tappable and visible beside long status text */
#weather-card .weather-card__top--standalone .status {
  min-width: 0;
  max-width: min(46vw, 14rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-self: end;
}

#weather-card .tile-header-actions {
  flex-shrink: 0;
  position: relative;
  z-index: 6;
}

#weather-card .weather-hourly-toggle {
  position: relative;
  z-index: 6;
}

#commute-card,
#tile-ipl,
#weather-card,
#currency-tile {
  position: relative;
}

#tile-ipl {
  padding-bottom: 2.35rem;
}

.tile-refresh-corner--bottom-end {
  position: absolute;
  right: max(0.35rem, env(safe-area-inset-right, 0px));
  bottom: max(0.4rem, env(safe-area-inset-bottom, 0px));
  z-index: 4;
}

.tile-refresh-corner--top-end {
  position: absolute;
  right: max(0.35rem, env(safe-area-inset-right, 0px));
  top: max(0.35rem, env(safe-area-inset-top, 0px));
  z-index: 4;
}

#weather-card {
  padding-bottom: 2.35rem;
}

#currency-tile {
  padding-bottom: 2.35rem;
}

.ghost-btn {
  border: 1px solid var(--ghost-border);
  border-radius: 10px;
  background: var(--ghost-bg);
  color: var(--ghost-text);
  font-weight: 600;
  padding: 0.65rem 0.95rem;
}

/* Landscape phones: often wider than narrow-width breakpoints but very short — stack header for readable quote + title. */
@media (orientation: landscape) and (max-height: 520px) {
  .dashboard__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
  }

  .dashboard__header-lead {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    column-gap: 0;
    row-gap: 0.55rem;
    align-items: start;
    justify-items: stretch;
  }

  .dashboard__title-row {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
  }

  .dashboard__title-stack {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .dashboard__quote-column {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
  }

  .quote-of-day {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .top-actions {
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 1100px) {
  .tile-type-square {
    grid-column: span 6;
  }

  .tile-type-horizontal,
  .tile-type-horizontal-scroll,
  .tile-type-vertical {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
    padding-bottom: calc(4.2rem + max(0.5rem, env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
  }

  /* Bottom-nav tabs own News / Stocks / TODOs / Favorites — omit from the scrollable home rail */
  body:not(.mobile-news-screen):not(.mobile-stocks-screen):not(.mobile-todos-screen):not(.mobile-favorites-screen)
    #dashboard-tiles
    > :is(#stocks-tile, #tile-news, #todo-card, #favorites-card) {
    display: none !important;
  }

  /* Mobile home: single-screen density (portrait). Chip height uses svh with a rem floor so
     brief rows stay aligned in landscape without collapsing below readable minima.
     Floor must clear Today’s Brief weather (summary + hourly strip) without vertical clipping. */
  #today-brief-section {
    --today-brief-commute-h: clamp(7.75rem, 24svh, 11.5rem);
    --today-brief-ipl-h: clamp(12.5rem, 32svh, 17rem);
  }

  .today-brief {
    margin: 0 0 0.55rem;
  }

  .today-brief__intro {
    margin-bottom: 0.35rem;
  }

  .today-brief__hero-title {
    font-size: clamp(0.86rem, 0.8rem + 0.22vw, 1.02rem);
    line-height: 1.25;
  }

  .today-brief-weather.mobile-weather-brief {
    margin: 0.12rem 0 0.42rem;
  }

  .today-brief__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-items: stretch;
    gap: 0.4rem;
  }

  .today-brief__grid-commute {
    grid-column: auto;
    min-width: 0;
  }

  /* Full-width rows under Markets + Commute keep brief chips aligned and readable */
  #brief-card-ipl.today-brief__card--ipl-brief,
  #brief-card-ai-news.today-brief__card--ai-news {
    grid-column: 1 / -1;
  }

  body:not(.mobile-news-screen):not(.mobile-stocks-screen):not(.mobile-todos-screen):not(.mobile-favorites-screen) {
    min-height: 100dvh;
    min-height: 100svh;
  }

  .dashboard {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: clamp(0.5rem, 2.4vw, 0.75rem);
    border-radius: clamp(14px, 3.5vw, 20px);
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .dashboard__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
  }

  .dashboard__header-lead {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 0.45rem;
    align-items: start;
    justify-items: stretch;
  }

  .dashboard__title-row {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
    gap: 0.35rem 0.5rem;
  }

  .dashboard__title-stack {
    width: 100%;
    max-width: 100%;
  }

  h1 {
    font-size: clamp(1.18rem, 1rem + 1vw, 1.375rem);
    font-weight: var(--font-weight-semibold);
    margin: 0.08rem 0 0.2rem;
    line-height: var(--font-line-tight);
  }

  .dashboard__quote-column {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: 100%;
  }

  .quote-of-day {
    width: 100%;
    max-width: 100%;
    height: fit-content;
    min-height: 0;
    padding: 0.3rem 0.5rem 0.35rem;
    border-radius: 10px;
  }

  .quote-of-day__text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .top-actions {
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.32rem 0.42rem;
  }

  #prefs-toggle {
    display: none !important;
  }

  /* Resize handles are hidden on full-screen tab tiles; hint is desktop-only. */
  .prefs-field--tile-resize-hint {
    display: none !important;
  }

  .theme-icon-btn {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    width: 2.5rem;
    height: 2.5rem;
  }

  /*
   * Full-screen preferences when opened from bottom nav (header toggle hidden on narrow viewports).
   * Match News/Stocks/Todos tile height so the bottom tab bar stays visible (same nav clearance as app-shell padding-bottom).
   */
  .prefs-panel {
    position: fixed;
    z-index: 300;
    left: max(0.5rem, env(safe-area-inset-left, 0px));
    right: max(0.5rem, env(safe-area-inset-right, 0px));
    top: max(0.35rem, env(safe-area-inset-top, 0px));
    bottom: auto;
    width: auto;
    max-width: none;
    height: calc(
        100dvh - max(0.35rem, env(safe-area-inset-top, 0px)) -
          (4.2rem + max(0.5rem, env(safe-area-inset-bottom, 0px)))
      );
    max-height: none;
    border-radius: 0;
    padding: max(0.65rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
      max(0.75rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    overflow: hidden;
    overscroll-behavior: contain;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .prefs-panel__scroll {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .cards {
    gap: clamp(0.4rem, 1.8vw, 0.65rem);
  }

  .dashboard-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(0.4rem, 1.8vw, 0.65rem);
    /* Bottom-nav home hides every tile in this rail; keep a non-zero box so layout/tests stay stable */
    min-height: 1px;
  }

  .tile-type-square {
    grid-column: span 1;
    min-height: 11.5rem;
    max-height: 11.5rem;
    overflow: hidden;
  }

  .tile-type-horizontal,
  .tile-type-horizontal-scroll,
  .tile-type-vertical {
    grid-column: 1 / -1;
  }

  .tile-type-horizontal,
  .tile-type-horizontal-scroll {
    min-height: 8.8rem;
    max-height: 8.8rem;
  }

  /* Full dashboard weather (not Today’s Brief chip): taller flexible tile */
  #weather-card.tile-type-horizontal-scroll:not(.weather-card--brief) {
    min-width: 0;
    max-width: 100%;
    min-height: min(15rem, 36svh);
    max-height: min(24rem, 48svh);
    overflow-x: hidden;
    overflow-y: hidden;
  }

  #today-brief-section #weather-card.weather-card--brief.tile-type-horizontal-scroll {
    height: var(--today-brief-commute-h);
    min-height: var(--today-brief-commute-h);
    max-height: var(--today-brief-commute-h);
    overflow: hidden;
  }

  body:not(.mobile-news-screen):not(.mobile-stocks-screen):not(.mobile-todos-screen):not(.mobile-favorites-screen)
    #tile-ipl {
    display: none !important;
  }

  .tile-type-vertical {
    max-height: min(40svh, 40vh);
    overflow: hidden;
  }

  /* To-do grows with content; do not inherit the short vertical cap used for stocks/news. */
  #todo-card.tile-type-vertical,
  #todo-card.tile-type-vertical.todo-card--composer-open,
  #favorites-card.tile-type-vertical {
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
  }

  .dashboard-tile {
    height: auto;
    min-height: 0;
    padding: 0.82rem 0.85rem 0.88rem;
    overflow: hidden;
  }

  #todo-card.dashboard-tile {
    height: auto;
    align-self: start;
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .card__top--tile {
    --drag-handle-size: 2.25rem;
  }

  .news-summary__head.news-summary__head--tile {
    --drag-handle-size: 2.25rem;
  }

  .tile-collapse-btn {
    max-width: min(4.6rem, 22vw);
    min-width: 2.2rem;
    padding: 0.12rem 0.26rem;
    font-size: clamp(0.48rem, 0.38rem + 0.32vw, 0.62rem);
  }

  .tile-drag-handle {
    width: var(--drag-handle-size);
    height: var(--drag-handle-size);
  }

  .dashboard-tile.todo-card {
    padding: 0.85rem 0.88rem 0.9rem;
  }

  #currency-tile.card--currency {
    min-height: 0;
    padding: 0.72rem 0.78rem 0.82rem;
  }

  #currency-tile.tile-type-horizontal {
    min-height: min(10.5rem, 26svh);
    max-height: min(13.5rem, 30svh);
  }

  #stocks-tile.card--stocks {
    min-height: 0;
    padding: 0.72rem 0.78rem 0.82rem;
    --stock-row-h: 5.2rem;
    --stock-gap: 0.32rem;
  }

  #stocks-tile .stocks-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  #stocks-tile .stocks-scroll {
    flex: 1 1 auto;
    min-height: 0;
  }

  .card__top {
    gap: 0.5rem;
    margin-bottom: 0.4rem;
  }

  .dashboard h2 {
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .dashboard-tile--weather .weather-inline {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: visible;
    overflow-y: hidden;
  }

  .dashboard-tile--weather .hourly-forecast,
  .dashboard-tile--weather #weather-hourly.hourly-forecast {
    flex: 1 1 auto;
    min-height: min(5.25rem, 15svh);
    margin-top: 0.55rem;
    max-height: none;
  }

  /* Today’s Brief: right-column hourly scroller; grid layout from base rules */
  #today-brief-section #weather-card.weather-card--brief #weather-hourly.hourly-forecast {
    min-height: 0 !important;
    margin-top: 0 !important;
    max-height: 100%;
    padding-bottom: 0 !important;
    scrollbar-gutter: auto !important;
  }

  #today-brief-section #weather-card.weather-card--brief .hourly-forecast__caption {
    display: none !important;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-inline__summary {
    gap: 0.06rem;
  }

  #today-brief-section #weather-card.weather-card--brief .weather-card__top--standalone {
    margin-bottom: 0 !important;
  }

  #current-time.metric {
    font-size: clamp(1.28rem, 1rem + 4.2vw, 1.95rem);
  }

  #stocks-tile .stocks-grid {
    grid-template-columns: 1fr;
  }

  #stocks-tile.dashboard-tile--resizable-v .stocks-scroll {
    max-height: none;
  }

  #tile-news.dashboard-tile--resizable-v .news-tiles {
    max-height: none;
  }

  .news-summary--toolbar {
    min-height: min(20rem, 54svh);
    min-height: min(20rem, 54vh);
    padding: 0.65rem 0.72rem 0.78rem;
  }

  .news-summary__head {
    gap: 0.5rem;
  }

  .news-summary__row {
    flex-wrap: wrap;
    gap: 0.4rem 0.65rem;
  }

  .news-source-select {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .news-tiles {
    margin-top: 0.65rem;
    max-height: min(50vh, 52svh);
    max-height: min(50dvh, 52svh);
  }

}

@media (max-width: 480px) {
  .app-shell {
    padding-left: max(0.4rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.4rem, env(safe-area-inset-right, 0px));
  }

  .dashboard {
    padding: clamp(0.5rem, 2.8vw, 0.75rem);
    border-radius: 12px;
  }

  .cards {
    gap: 0.5rem;
  }

  .dashboard-tiles {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .dashboard-tiles > .dashboard-tile,
  .dashboard-tiles > .tile-type-square,
  .dashboard-tiles > .tile-type-horizontal,
  .dashboard-tiles > .tile-type-horizontal-scroll,
  .dashboard-tiles > .tile-type-vertical {
    grid-column: 1 / -1;
  }

  .card {
    padding: 0.8rem;
  }

  .dashboard-tile {
    padding: 0.75rem 0.78rem 0.82rem;
  }

  .dashboard-tile.todo-card {
    padding: 0.72rem 0.75rem 0.78rem;
  }

  .prefs-toggle {
    min-height: var(--touch-target-min);
    padding: 0.42rem 0.8rem;
  }

  .news-summary--toolbar {
    min-height: min(17rem, 48svh);
    min-height: min(17rem, 48vh);
    padding: 0.58rem 0.65rem 0.72rem;
  }

  .news-summary__row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .news-summary__label {
    flex: 0 0 auto;
  }

  .news-source-select {
    width: 100%;
  }

  #tile-news #news-status {
    text-align: end;
    line-height: 1.25;
  }
}

.cards::-webkit-scrollbar,
.news-tiles::-webkit-scrollbar,
.hourly-forecast::-webkit-scrollbar,
.news-tile::-webkit-scrollbar,
#stocks-tile .stocks-scroll::-webkit-scrollbar,
.todo-scroll.todo-scroll--limited::-webkit-scrollbar,
#todo-scroll-region::-webkit-scrollbar,
.todo-input::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.cards::-webkit-scrollbar-thumb,
.news-tiles::-webkit-scrollbar-thumb,
.hourly-forecast::-webkit-scrollbar-thumb,
.news-tile::-webkit-scrollbar-thumb,
#stocks-tile .stocks-scroll::-webkit-scrollbar-thumb,
.todo-scroll.todo-scroll--limited::-webkit-scrollbar-thumb,
#todo-scroll-region::-webkit-scrollbar-thumb,
.todo-input::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.cards::-webkit-scrollbar-track,
.news-tiles::-webkit-scrollbar-track,
.hourly-forecast::-webkit-scrollbar-track,
.news-tile::-webkit-scrollbar-track,
#stocks-tile .stocks-scroll::-webkit-scrollbar-track,
.todo-scroll.todo-scroll--limited::-webkit-scrollbar-track,
#todo-scroll-region::-webkit-scrollbar-track,
.todo-input::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
