/* =====================================================================================================================
   reVolt "calm" redesign: Today (#screen-home). Owned by the Today screen; loaded after styles-calm.css.
   One big battery ring, three small score rings, one insight card, then quiet hairline rows (Autopilot, Electricity
   prices, Activity). Details open behind a tap; the containers tests look for always keep a box.
   Every rule is scoped to #screen-home so it cannot reach the other tabs.
   ===================================================================================================================== */

#screen-home {
  --today-gap: 24px;
}

#screen-home > .calm-home-heading {
  margin-bottom: 20px;
}

/* Car / Home energy switch: the shared segmented look, full width under the header. */
#screen-home .home-view-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 var(--today-gap);
  border: 0;
  border-radius: var(--calm-radius-control);
  padding: 4px;
  background: var(--calm-surface);
  box-shadow: none;
}

#screen-home .home-view-switch.hidden {
  display: none;
}

#screen-home .home-view-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  color: var(--calm-muted);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}

#screen-home .home-view-switch button[aria-selected="true"] {
  color: var(--calm-text);
  background: var(--calm-raised);
  font-weight: 500;
}

#screen-home .home-view-switch svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Storm Watch: a borderless notice with an amber accent. */
#screen-home .storm-watch-banner {
  margin: 0 0 var(--today-gap);
  border: 0 !important;
  border-radius: var(--calm-radius);
  background: var(--calm-surface) !important;
  box-shadow: none !important;
  color: var(--calm-text);
}

#screen-home .storm-watch-banner.hidden {
  display: none;
}

#screen-home .storm-watch-banner svg {
  color: var(--calm-amber);
  stroke: var(--calm-amber);
}

#screen-home .storm-watch-banner strong {
  color: var(--calm-text);
  font-weight: 500;
}

#screen-home .storm-watch-banner p,
#screen-home .storm-watch-banner span {
  color: var(--calm-muted);
}

/* ---------- Hero ---------- */
/* Without a ring (setup, plug control) the hero is a plain surface card; with one it opens up into the ring. */
#screen-home .simplified-home-hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 var(--today-gap);
  padding: 20px;
}

#screen-home .simplified-home-hero .hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

#screen-home .simplified-home-hero .hero-label {
  margin: 0 0 4px;
}

#screen-home .simplified-home-hero #heroStatus {
  margin: 0;
  color: var(--calm-text);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

#screen-home .simplified-home-hero .hero-badge {
  flex: none;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--calm-muted);
  background: var(--surface-soft);
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

#screen-home .simplified-home-hero .hero-badge::before {
  display: none;
}

#screen-home .simplified-home-hero .hero-badge[data-tone="ok"],
#screen-home .simplified-home-hero .hero-badge[data-tone="live"] {
  color: var(--calm-accent);
  background: var(--calm-accent-soft);
}

#screen-home .simplified-home-hero .hero-badge[data-tone="warn"] {
  color: var(--calm-amber);
  background: var(--calm-amber-soft);
}

#screen-home .simplified-home-hero .hero-plan-copy {
  margin: 0;
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

#screen-home .simplified-home-hero .battery-row strong {
  font-weight: 500;
}

#screen-home .simplified-home-hero .battery-row span {
  color: var(--calm-muted);
  font-weight: 400;
}

#screen-home .simplified-home-hero .progress-track {
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: var(--calm-track);
}

#screen-home .simplified-home-hero .progress-track span {
  border-radius: 2px;
  background: var(--calm-accent);
  box-shadow: none;
}

#screen-home .simplified-home-hero .progress-labels span {
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 400;
}

/* Ring mode: no card, everything centered: ring, "Ready by 7:00 AM", status, one sentence, Charge controls. */
#screen-home .simplified-home-hero[data-ring="true"] {
  align-items: center;
  gap: 0;
  padding: 4px 0 0;
  background: transparent !important;
  text-align: center;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-ring-row {
  order: 1;
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
}

#screen-home .simplified-home-hero[data-ring="true"] .battery-row,
#screen-home .simplified-home-hero[data-ring="true"] .progress-track,
#screen-home .simplified-home-hero[data-ring="true"] .progress-labels {
  display: none;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-ready-line {
  order: 2;
  margin: 0 0 8px;
  color: var(--calm-text);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

#screen-home .hero-ready-line.hidden {
  display: none;
}

/* The car's name sits inside the ring, so the eyebrow above the status steps aside (it stays for screen readers). */
#screen-home .simplified-home-hero[data-ring="true"] .hero-top {
  order: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 6px;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-top > div {
  display: flex;
  align-items: center;
}

#screen-home .simplified-home-hero[data-ring="true"] #heroLabel {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#screen-home .simplified-home-hero[data-ring="true"] #heroStatus,
#screen-home .simplified-home-hero[data-ring="true"] #heroStatus.compact {
  color: var(--calm-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
}

/* A quiet status dot in front: accent when plugged in or charging, amber when something needs a hand. */
#screen-home .simplified-home-hero[data-ring="true"] #heroStatus::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 2px 0;
  border-radius: 50%;
  background: var(--calm-faint);
  vertical-align: middle;
}

#screen-home .simplified-home-hero[data-ring="true"][data-state="scheduled"] #heroStatus::before,
#screen-home .simplified-home-hero[data-ring="true"][data-state="charging"] #heroStatus::before {
  background: var(--calm-accent);
}

#screen-home .simplified-home-hero[data-ring="true"][data-state="blocked"] #heroStatus::before {
  background: var(--calm-amber);
}

/* "Ready" repeats the line above; the badge only speaks up when it adds something (charging speed, plug in, view only). */
#screen-home .simplified-home-hero[data-ring="true"] .hero-badge[data-tone="ok"],
#screen-home .simplified-home-hero[data-ring="true"] .hero-badge[data-tone="neutral"] {
  display: none;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-badge {
  padding: 3px 9px;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-plan-copy {
  order: 4;
  max-width: 300px;
  margin: 0;
}

#screen-home .simplified-home-hero .hero-controls-button {
  order: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-height: 44px;
  margin: 8px 0 0;
  border: 0 !important;
  border-radius: 999px;
  padding: 0 20px;
  color: var(--calm-text);
  background: var(--calm-surface);
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
}

#screen-home .simplified-home-hero:not([data-ring="true"]) .hero-controls-button {
  background: var(--surface-soft);
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-controls-button {
  margin-top: 18px;
}

#screen-home .simplified-home-hero .hero-controls-button.hidden {
  display: none;
}

#screen-home .simplified-home-hero .hero-controls-button:hover,
#screen-home .simplified-home-hero .hero-controls-button:focus-visible {
  background: var(--calm-raised);
}

#screen-home .simplified-home-hero .hero-controls-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--calm-muted);
  stroke-width: 1.7;
  stroke-linecap: round;
}

/* The big ring: 236px, the goal as a faint arc, the level in solid accent. */
#screen-home .charge-ring {
  --ring-color: var(--calm-accent);
  width: 236px;
  height: 236px;
}

#screen-home .charge-ring.hidden {
  display: none;
}

#screen-home .charge-ring circle {
  stroke-width: 5;
}

#screen-home .charge-ring .ring-track {
  stroke: var(--calm-line);
}

#screen-home .charge-ring .ring-goal {
  stroke: #2A3445;
  stroke-linecap: round;
  stroke-dasharray: var(--target) 100;
}

#screen-home .charge-ring .ring-fill,
#screen-home .charge-ring[data-state="complete"] .ring-fill,
#screen-home .charge-ring[data-state="charging"] .ring-fill {
  stroke: var(--calm-accent);
  filter: none;
  animation: none;
}

#screen-home .charge-ring .ring-target {
  display: none;
}

#screen-home .charge-ring-center {
  gap: 4px;
}

/* Long names wrap to a second line instead of cutting off, since #heroLabel is visually hidden. */
#screen-home .charge-ring-name {
  display: -webkit-box;
  max-width: 156px; /* the ring's width up where the name sits, so a long line never reaches the arc */
  overflow: hidden;
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#screen-home .charge-ring-name:empty {
  display: none;
}

/* Long names (set by renderHomeChargeRing): smaller, tighter type, and more lines for the longest, so a
   name like "Maximilian's Midnight Silver Model Y Long Range" fits inside the ring whole. */
#screen-home .charge-ring-name[data-length="medium"] {
  font-size: 11px;
  letter-spacing: 0.06em;
}

#screen-home .charge-ring-name[data-length="long"] {
  font-size: 10px;
  letter-spacing: 0.04em;
  -webkit-line-clamp: 4;
}

#screen-home .charge-ring-center strong {
  color: var(--calm-text);
  font-family: var(--calm-font);
  font-size: 64px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

#screen-home .charge-ring-center #chargeRingLabel {
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
}

/* Charging: a slow breathe on the arc instead of the old orange glow. */
@keyframes today-ring-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

#screen-home .charge-ring[data-state="charging"] .ring-fill {
  animation: today-ring-breathe 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  #screen-home .charge-ring[data-state="charging"] .ring-fill {
    animation: none;
  }
}

/* ---------- Score rings ---------- */
#screen-home .home-scores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 var(--today-gap);
}

#screen-home .home-scores.hidden,
#screen-home[data-home-view="home"] .home-scores,
body[data-home-only="true"] #screen-home .home-scores {
  display: none !important;
}

#screen-home .home-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  border: 0;
  border-radius: var(--calm-radius);
  padding: 16px 8px 14px;
  color: var(--calm-text);
  background: var(--calm-surface);
  box-shadow: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#screen-home .home-score:active {
  background: var(--surface-soft);
}

#screen-home .home-score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
}

#screen-home .home-score-ring .calm-ring {
  position: absolute;
  inset: 0;
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

#screen-home .home-score-ring circle {
  stroke-width: 5;
}

#screen-home .home-score-ring .calm-ring-fill.hidden {
  display: none;
}

#screen-home .home-score-value {
  position: relative;
  color: var(--calm-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#screen-home .home-score[data-tone="empty"] .home-score-value,
#screen-home .home-score[data-tone="locked"] .home-score-value {
  color: var(--calm-muted);
  font-size: 13px;
}

#screen-home .home-score-label {
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

/* ---------- Insight card: Your week and reVolt savings share one surface ---------- */
#screen-home .weekly-summary-card {
  margin: 0 0 var(--today-gap);
  padding: 20px;
}

#screen-home .weekly-summary-card.hidden {
  display: none;
}

#screen-home .weekly-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
}

#screen-home .weekly-summary-head .eyebrow {
  margin: 0;
  color: var(--calm-muted);
}

#screen-home #weeklySummaryDismiss {
  min-width: 44px;
  min-height: 44px;
  margin: -12px -8px -12px 0;
  border: 0;
  padding: 0 8px;
  color: var(--calm-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

#screen-home #weeklySummaryTitle {
  margin: 0 0 4px;
  color: var(--calm-text);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

#screen-home #weeklySummaryLines {
  margin: 0;
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

#screen-home .home-metric-grid {
  display: block;
  margin: 0 0 var(--today-gap);
}

#screen-home .home-metric-grid > .home-metric-card.hidden {
  display: none;
}

/* On the Car view, a visible week joins the savings card below it into one card. */
#screen-home:not([data-home-view="home"]) .weekly-summary-card:not(.hidden) {
  margin-bottom: 0;
  border-radius: var(--calm-radius) var(--calm-radius) 0 0;
  padding-bottom: 16px;
}

#screen-home:not([data-home-view="home"]) .weekly-summary-card:not(.hidden) + .home-metric-grid .home-savings-wide {
  border-top: 1px solid var(--calm-line) !important;
  border-radius: 0 0 var(--calm-radius) var(--calm-radius);
}

#screen-home .home-savings-wide {
  min-height: 0;
  padding: 18px 20px 20px !important;
}

#screen-home .home-savings-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 0;
  padding-right: 84px;
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#screen-home .home-savings-pill {
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--calm-amber);
  background: var(--calm-amber-soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

#screen-home .home-savings-pill.hidden {
  display: none;
}

#screen-home .home-savings-wide-copy strong {
  gap: 8px;
  margin: 6px 0 0;
}

#screen-home #homeSavingsMetric {
  color: var(--calm-text);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

#screen-home .home-savings-wide.has-savings #homeSavingsMetric {
  color: var(--calm-amber);
  font-family: var(--calm-font);
  font-size: 40px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: none;
  -webkit-text-fill-color: currentColor;
}

#screen-home #homeSavingsPeriod {
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
}

#screen-home #homeSavingsSubcopy {
  margin-top: 8px;
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

/* A 36px pill inside a 44px hit area: the transparent border is tappable but unpainted. */
#screen-home .home-savings-toggle {
  top: 12px;
  right: 10px;
  min-width: 44px;
  min-height: 44px;
  border: 4px solid transparent;
  padding: 0 12px;
  color: var(--calm-muted);
  background: var(--surface-soft);
  background-clip: padding-box;
  font-size: 13px;
  font-weight: 500;
}

#screen-home .home-savings-toggle.hidden {
  display: none;
}

#screen-home .home-savings-toggle::after {
  width: 5px;
  height: 5px;
  border-right-width: 1.5px;
  border-bottom-width: 1.5px;
}

#screen-home .home-savings-rows > div {
  min-height: 44px;
  padding: 12px 0;
  font-size: 14px;
}

#screen-home .home-savings-rows > div + div {
  border-top: 1px solid var(--calm-line);
}

#screen-home .home-savings-rows span {
  color: var(--calm-muted);
  font-weight: 400;
}

#screen-home .home-savings-rows strong {
  color: var(--calm-text);
  font-weight: 500;
}

#screen-home .home-savings-note {
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}

#screen-home .home-savings-link {
  min-height: 44px;
  margin: 4px 0 0;
  border: 0;
  padding: 0;
  color: var(--calm-accent);
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
}

/* Without Pro the card is a quiet invitation. */
#screen-home .home-savings-wide.locked #homeSavingsMetric {
  font-size: 17px;
}

/* ---------- Hairline rows: Autopilot, Electricity prices ---------- */
#screen-home .autopilot-card {
  position: relative;
  margin: 0;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--calm-line) !important;
  padding: 0;
  background: transparent !important;
}

#screen-home .autopilot-card.hidden {
  display: none;
}

#screen-home .autopilot-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  margin: 0;
  border-bottom: 1px solid var(--calm-line);
  padding: 10px 0;
}

#screen-home .autopilot-head > div {
  flex: 1;
  min-width: 0;
}

#screen-home .autopilot-icon {
  display: none;
}

#screen-home .autopilot-head .eyebrow {
  margin: 0 0 2px;
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#screen-home #autopilotTitle {
  margin: 0;
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

#screen-home .autopilot-switch {
  display: flex;
  flex: none;
  align-items: center;
  min-height: 44px;
}

#screen-home .autopilot-details-toggle {
  min-height: 56px;
  border-bottom: 0;
}

#screen-home .autopilot-details-toggle::after {
  transition: transform 160ms ease;
}

#screen-home .autopilot-card.is-open .autopilot-details-toggle::after {
  transform: rotate(90deg);
}

#screen-home .autopilot-details-toggle .calm-row-value:empty {
  display: none;
}

#screen-home .autopilot-details-toggle .calm-row-value.warn {
  color: var(--calm-amber);
}

/* Closed: only the two rows. Open: the plan, Sun first, record, road trip and notes, in that order. */
#screen-home .autopilot-card:not(.is-open) > .autopilot-copy,
#screen-home .autopilot-card:not(.is-open) > .autopilot-plan,
#screen-home .autopilot-card:not(.is-open) > .autopilot-record,
#screen-home .autopilot-card:not(.is-open) > .autopilot-trip,
#screen-home .autopilot-card:not(.is-open) > #autopilotPreviewNote {
  /* Clipped rather than display:none so the text stays readable to the page; JS marks them inert while closed. */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

#screen-home .autopilot-card.is-open {
  padding-bottom: 16px;
}

#screen-home .autopilot-copy {
  margin: 0 0 12px;
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

#screen-home .autopilot-copy.hidden,
#screen-home .autopilot-plan.hidden,
#screen-home .autopilot-trip.hidden,
#screen-home #autopilotPreviewNote.hidden {
  display: none;
}

#screen-home .autopilot-plan {
  margin: 0 0 12px;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  background: var(--calm-surface);
}

#screen-home .autopilot-facts {
  border: 0;
  background: transparent;
}

#screen-home .autopilot-facts > div {
  border: 0;
  background: transparent;
}

#screen-home .autopilot-facts span {
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 400;
}

#screen-home .autopilot-facts strong {
  color: var(--calm-text);
  font-weight: 500;
}

#screen-home .autopilot-status {
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
}

#screen-home .autopilot-status.at-risk {
  color: var(--calm-amber);
}

#screen-home .autopilot-record {
  margin: 0 0 12px;
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
}

#screen-home .autopilot-record:empty {
  display: none;
}

#screen-home .autopilot-trip {
  width: 100%;
  min-height: 44px;
  border-radius: var(--calm-radius-control);
  font-size: 14px;
  font-weight: 500;
}

/* Electricity prices: one row; the tiles open beneath it as rows. */
#screen-home .rate-strip {
  display: block;
  margin: 0 0 var(--today-gap);
  border-bottom: 1px solid var(--calm-line);
}

#screen-home .rate-strip-toggle.hidden {
  display: none;
}

#screen-home .rate-strip-toggle {
  border-bottom: 0;
}

#screen-home .rate-strip-toggle::after {
  transition: transform 160ms ease;
}

#screen-home .rate-strip.is-open .rate-strip-toggle::after {
  transform: rotate(90deg);
}

#screen-home #rateStrip:not(.is-open) > article {
  display: none !important;
}

#screen-home #rateStrip > article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label value"
    "sub value";
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  min-height: 56px;
  margin: 0;
  border: 0 !important;
  border-top: 1px solid var(--calm-line) !important;
  border-radius: 0;
  padding: 10px 0;
  color: var(--calm-text);
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
}

#screen-home #rateStrip > article.hidden,
#screen-home #rateStrip[data-rate-layout="api-feeds"] > article:not(.api-rate-feed-tile) {
  display: none;
}

#screen-home #rateStrip > article > span {
  grid-area: label;
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#screen-home #rateStrip > article > strong {
  grid-area: value;
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 500;
  text-align: right;
}

#screen-home #rateStrip > article > small {
  grid-area: sub;
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

#screen-home #rateStrip > article > em {
  display: none;
}

#screen-home #rateStrip > article .rate-good {
  color: var(--calm-accent);
}

#screen-home #rateStrip > article .rate-bad {
  color: var(--calm-amber);
}

/* No utility yet: the one tile is the row, "Electricity prices   Add your utility ›". */
#screen-home .rate-strip[data-rate-count="1"] > #nowRateTile {
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "label value chev";
  border-top: 0 !important;
}

#screen-home .rate-strip[data-rate-count="1"] > #nowRateTile > small {
  display: none;
}

#screen-home .rate-strip[data-rate-count="1"] > #nowRateTile > strong {
  color: var(--calm-accent);
  font-size: 14px;
  font-weight: 400;
}

#screen-home .rate-strip[data-rate-count="1"] > #nowRateTile::after {
  content: "\203A";
  grid-area: chev;
  margin-left: -4px;
  color: var(--calm-faint);
  font-size: 18px;
  line-height: 1;
}

/* The live price feed opens as its own two rows. */
#screen-home #rateStrip > .api-rate-feed-tile {
  display: block;
  padding: 4px 0;
}

#screen-home .api-rate-feed-head {
  display: none;
}

#screen-home .api-rate-feed-grid {
  display: grid;
  gap: 0;
}

#screen-home .api-rate-feed-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label value"
    "sub value";
  align-items: center;
  column-gap: 12px;
  min-height: 52px;
  border: 0;
  border-radius: 0;
  padding: 8px 0;
  color: var(--calm-text);
  background: transparent;
  box-shadow: none;
  text-align: left;
}

#screen-home .api-rate-feed-item + .api-rate-feed-item {
  border-top: 1px solid var(--calm-line);
}

#screen-home .api-rate-feed-item span {
  grid-area: label;
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

#screen-home .api-rate-feed-item strong {
  grid-area: value;
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 500;
}

#screen-home .api-rate-feed-item small {
  grid-area: sub;
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 400;
}

/* Plug On/Off: a plain surface card with the shared segmented look. */
#screen-home .home-charge-source-grid {
  margin: 0 0 var(--today-gap);
}

#screen-home .home-charge-source-card {
  border: 0 !important;
  border-radius: var(--calm-radius);
  background: var(--calm-surface) !important;
  box-shadow: none !important;
}

#screen-home .home-charge-source-card .home-charge-source-head span {
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#screen-home .home-charge-source-card strong {
  font-weight: 500;
}

#screen-home .home-charge-toggle {
  border: 0;
  border-radius: var(--calm-radius-control);
  padding: 4px;
  background: var(--calm-bg);
}

#screen-home .home-charge-toggle .charge-state-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  color: var(--calm-muted);
  background: transparent;
  box-shadow: none;
}

#screen-home .home-charge-toggle .charge-state-button.active {
  color: var(--calm-text);
  background: var(--calm-raised);
}

/* ---------- Activity: a plain list with hairlines ---------- */
#screen-home .activity-card {
  margin: 0 0 var(--today-gap);
  border: 0 !important;
  border-radius: 0;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
}

#screen-home .activity-card.hidden {
  display: none;
}

#screen-home .activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
}

#screen-home .activity-head .eyebrow {
  margin: 0 0 2px;
}

#screen-home .activity-head h3 {
  margin: 0;
  color: var(--calm-text);
  font-size: 17px;
  font-weight: 500;
}

#screen-home #activitySeeAllButton {
  min-height: 44px;
  border: 0;
  padding: 0 0 0 12px;
  color: var(--calm-accent);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
}

#screen-home .activity-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

#screen-home .activity-row {
  border: 0;
  border-bottom: 1px solid var(--calm-line);
  border-radius: 0;
  padding: 14px 0;
  background: transparent;
}

#screen-home .activity-row:last-child {
  border-bottom: 0;
}

#screen-home .activity-icon {
  border: 0;
  color: var(--calm-muted);
  background: var(--calm-surface);
  box-shadow: none;
}

#screen-home .activity-row.tone-good .activity-icon {
  color: var(--calm-accent);
}

#screen-home .activity-row.tone-warn .activity-icon,
#screen-home .activity-row.tone-bad .activity-icon {
  color: var(--calm-amber);
}

#screen-home .activity-copy strong {
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 400;
}

#screen-home .activity-copy small,
#screen-home .activity-meta time {
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
}

#screen-home .activity-meta b,
#screen-home .activity-meta b.good {
  color: var(--calm-amber);
  font-weight: 500;
}

#screen-home .activity-empty {
  margin: 8px 0 0;
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

/* Legal line: faint and small at the bottom. */
#screen-home .home-legal {
  margin-top: 8px;
  color: var(--calm-faint);
  font-size: 12px;
  font-weight: 400;
}

#screen-home .home-legal summary,
#screen-home .home-legal a,
#screen-home .home-legal button {
  color: var(--calm-muted);
  font-weight: 400;
}

/* ---------- Home energy view and home-only mode: same tokens, savings in amber, no heavy weights ---------- */
#screen-home .home-energy-card,
#screen-home .solar-worth,
#screen-home .day-plan,
#screen-home .home-energy-week,
#screen-home .weather-plan {
  margin-bottom: var(--today-gap);
  border: 0 !important;
  border-radius: var(--calm-radius);
  background: var(--calm-surface) !important;
  box-shadow: none !important;
}

#screen-home .home-energy-card h3,
#screen-home .solar-worth h3,
#screen-home .day-plan h3,
#screen-home .home-energy-week h3,
#screen-home .weather-plan h3 {
  font-weight: 500;
}

#screen-home .hes-worth strong,
#screen-home .solar-worth strong {
  color: var(--calm-amber);
  font-weight: 300;
  letter-spacing: -0.02em;
}

/* Without Pro, Autopilot's switch carries a quiet PRO tag. */
#screen-home .autopilot-card.pro-locked::after {
  top: 23px;
  right: 64px;
  padding: 3px 8px;
  color: var(--calm-amber);
  background: var(--calm-amber-soft);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

#screen-home #rateStrip {
  padding: 0;
  gap: 0;
}

#screen-home #rateStripToggle .calm-row-label {
  color: var(--calm-text);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#screen-home #rateStripToggle .calm-row-value {
  color: var(--calm-muted);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#screen-home #rateStrip > article > strong,
#screen-home #rateStrip .api-rate-feed-item strong {
  color: var(--calm-text) !important;
}

#screen-home #rateStrip > article[data-tone="good"] > strong {
  color: var(--calm-accent) !important;
}

#screen-home #rateStrip > article[data-tone="bad"] > strong {
  color: var(--calm-amber) !important;
}

#screen-home #rateStrip[data-rate-count="1"] > #nowRateTile > strong {
  color: var(--calm-accent) !important;
}

/* Home energy view: lighter type, no green chips. */
#screen-home :is(.home-energy-summary, .weather-plan, .home-energy-card, .day-plan, .home-energy-week, .solar-worth) :is(p, small, label) {
  font-weight: 400;
}

#screen-home :is(.home-energy-summary, .weather-plan, .home-energy-card, .day-plan, .home-energy-week, .solar-worth) :is(strong, b, h3, h4) {
  font-weight: 500;
}

#screen-home .home-energy-summary small {
  color: var(--calm-muted);
}

#screen-home .hes-mode em,
#screen-home .hes-mode em.on {
  border: 0;
  color: var(--calm-accent);
  background: var(--calm-accent-soft);
  font-style: normal;
  font-weight: 500;
}

/* Setup and plug heroes: the two facts read as values, not headlines. */
#screen-home .simplified-home-hero:not([data-ring="true"]) .battery-row strong {
  font-size: 16px;
  line-height: 1.3;
}

/* ---------- Home energy view: quiet the callout, chips and flow colours ---------- */
#screen-home .he-tip {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--calm-raised);
}

#screen-home .he-tip p {
  color: var(--calm-text);
  font-size: 14px;
  font-weight: 400;
}

/* Status chips (Exporting, Off, On · reVolt runs it) read as muted text, not filled pills. */
#screen-home .he-pill,
#screen-home .wp-status,
#screen-home .home-savings-pill {
  border: 0;
  padding: 0;
  color: var(--calm-muted) !important;
  background: transparent !important;
  font-size: 13px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#screen-home .wp-status.error {
  color: var(--calm-amber) !important;
}

#screen-home .weather-plan h3 {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

#screen-home .he-foot,
#screen-home .he-foot > span:first-child:not(.stale),
#screen-home .hes-go {
  color: var(--calm-muted);
  font-weight: 400;
}

/* Flow diagram: calm amber for solar, a soft green for Powerwall, no glow. */
#screen-home .home-energy-card {
  --he-solar: var(--calm-amber);
  --he-battery: #8FD3A8;
}

#screen-home .he-flow {
  filter: none;
}

#screen-home .he-node.is-active.he-solar .he-node-bg {
  fill: rgba(242, 179, 107, 0.1);
}

#screen-home .he-node.is-active.he-battery .he-node-bg {
  fill: rgba(143, 211, 168, 0.1);
}

/* Compact actions on Home still get a 44px tap height. */
#screen-home :is(.primary-action, .secondary-action).compact {
  min-height: 44px;
}

/* Live prices (ComEd and other hourly feeds): the older tile rules (two columns, a colour bar, a 40px label box and
   overflow hidden) still matched under the calm rows and clipped "Right now" / "This hour" when the row opened. */
#screen-home #rateStrip .api-rate-feed-grid {
  grid-template-columns: minmax(0, 1fr);
}

#screen-home #rateStrip .api-rate-feed-item {
  grid-template-rows: auto;
  gap: 2px 12px;
  min-width: 0;
  min-height: 56px;
  overflow: visible;
}

#screen-home #rateStrip .api-rate-feed-item::before {
  display: none;
}

#screen-home #rateStrip .api-rate-feed-item span {
  display: block;
  min-height: 0;
}

#screen-home #rateStrip .api-rate-feed-item strong {
  align-self: center;
  line-height: 1.3;
  white-space: nowrap;
}

#screen-home #rateStrip > .api-rate-feed-tile {
  min-height: 0 !important;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-top: 1px solid var(--calm-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#screen-home #rateStrip .api-rate-feed-item {
  padding: 8px 0;
}

/* ---------- Fit: every label and value stays inside its card, chip and button, down to a 320px phone ---------- */
/* Card heads ("Your solar's worth  At your hourly prices", "Week ahead  Chicago, IL · NWS forecast"): the source
   drops under the eyebrow when both don't fit, instead of squeezing the eyebrow onto two lines. */
#screen-home .hew-head {
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 12px;
  row-gap: 2px;
}

#screen-home .hew-head > .eyebrow {
  flex: 0 0 auto;
  white-space: nowrap;
}

#screen-home .hew-head > .hew-source {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Home energy head: the status ("Self-powered") reads as a line under the title, so a long car name gets the full
   width instead of three cramped lines and a cut-off eyebrow. */
#screen-home .home-energy-card .he-head {
  grid-template-columns: 40px minmax(0, 1fr);
  row-gap: 2px;
}

#screen-home .home-energy-card .he-head .eyebrow {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#screen-home .home-energy-card .he-head h3 {
  overflow-wrap: anywhere;
}

#screen-home .home-energy-card .he-head > .he-pill {
  grid-column: 2;
  justify-self: start;
  white-space: normal;
  line-height: 1.3;
}

#screen-home .home-energy-card .he-head > .he-badge {
  grid-row: 1 / span 2;
  align-self: start;
}

/* Today's three facts: labels and values wrap inside their tile rather than ellipsizing or running out. */
#screen-home .he-facts > div {
  align-content: start;
  padding: 8px;
}

#screen-home .he-facts span,
#screen-home .he-facts strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  line-height: 1.25;
}

#screen-home .he-facts strong {
  overflow-wrap: anywhere;
}

/* Footer: "Updated 4 min ago", "Details and ways to save" and the site picker wrap onto lines of their own. */
#screen-home .he-foot {
  flex-wrap: wrap;
  row-gap: 8px;
}

#screen-home .he-foot > span:first-child {
  white-space: nowrap;
}

#screen-home .he-foot .he-site {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  text-overflow: ellipsis;
}

/* Solar's worth: three short sums sit side by side; four-figure ones turn the tiles into rows so nothing is cut. */
#screen-home .sw-tile {
  min-width: 0;
  padding: 10px 4px;
}

#screen-home .sw-tile b {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#screen-home .sw-tiles.long {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

#screen-home .sw-tiles.long .sw-tile {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 12px;
  padding: 10px 12px;
  text-align: left;
}

#screen-home .sw-tiles.long .sw-tile b {
  grid-column: 2;
  grid-row: 1;
}

#screen-home .sw-tiles.long .sw-tile small {
  grid-column: 1;
  grid-row: 1;
}

#screen-home .sw-tiles.long .sw-tile .sw-days {
  grid-column: 1 / -1;
}

/* Week ahead > a day's facts: the wind ("25 mph NNW, gusts 40 mph") gets a full row and wraps; no value runs off. */
#screen-home .hew-facts {
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
}

#screen-home .hew-facts > div {
  min-width: 0;
}

#screen-home .hew-facts > div.long {
  grid-column: 1 / -1;
}

#screen-home .hew-facts dt,
#screen-home .hew-facts dd {
  white-space: normal;
  overflow-wrap: anywhere;
}

#screen-home .hew-facts dd {
  line-height: 1.3;
}

/* The day's head: the name sits beside the temperatures and the forecast words ("Partly Sunny then Chance Showers
   And Thunderstorms") run the full width under both, instead of a one-word column squeezed between them. */
#screen-home .hew-detail-head {
  grid-template-columns: auto minmax(min-content, 1fr) auto;
  column-gap: 10px;
  row-gap: 2px;
}

#screen-home .hew-detail-head > div {
  display: contents;
}

#screen-home .hew-detail-head > .hew-detail-icon {
  grid-row: 1 / span 2;
  align-self: start;
}

#screen-home .hew-detail-head strong {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  white-space: nowrap;
}

#screen-home .hew-detail-head small {
  display: block;
  grid-column: 2 / -1;
  grid-row: 2;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Two temperatures that don't fit beside the name stack, high over low, rather than breaking the name. */
#screen-home .hew-temps {
  grid-column: 3;
  grid-row: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 6px;
  row-gap: 0;
}

#screen-home .hew-temps b,
#screen-home .hew-temps i {
  white-space: nowrap;
}

/* Seven-day strips (Week ahead, Weather plan's likely week): tighter gaps and lighter type keep "Today", "117" and
   "100%" inside their day on a 320px phone. */
#screen-home .hew-days,
#screen-home .wp-week {
  gap: 2px;
}

#screen-home .hew-day,
#screen-home .wp-day {
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
}

#screen-home .hew-name,
#screen-home .wp-day b {
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}

#screen-home .hew-kwh,
#screen-home .wp-day i {
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

@media (max-width: 380px) {
  #screen-home .hew-name,
  #screen-home .wp-day,
  #screen-home .wp-day b,
  #screen-home .wp-day i {
    font-size: 11px;
  }

  #screen-home .hew-kwh {
    font-size: 12px;
  }
}

/* Weather plan buttons ("Pause for today", "Change limits") keep one line where they can and wrap inside if not. */
#screen-home .wp-buttons {
  flex-wrap: wrap;
}

#screen-home .wp-buttons button {
  flex: 1 1 130px;
  min-width: 0;
  padding-left: 12px;
  padding-right: 12px;
  white-space: normal;
  line-height: 1.25;
}

/* ---------- Take control (Today) ---------- */
/* Charge controls and Take control sit side by side under the car, and wrap onto two lines on a narrow phone. */
#screen-home .simplified-home-hero .hero-actions {
  order: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 8px 0 0;
}

#screen-home .simplified-home-hero[data-ring="true"] .hero-actions {
  margin-top: 18px;
}

#screen-home .simplified-home-hero .hero-actions.hidden {
  display: none;
}

#screen-home .simplified-home-hero .hero-actions .hero-controls-button {
  flex: 0 1 auto;
  max-width: 100%;
  margin: 0;
  padding: 0 16px;
  text-align: center;
}

/* Without the ring the hero is a card, and its buttons share the full width. */
#screen-home .simplified-home-hero:not([data-ring="true"]) .hero-actions .hero-controls-button {
  flex: 1 1 auto;
}

/* Following the Tesla app's schedule: a quiet card in place of the plan sentence, with the way back. */
#screen-home .tesla-schedule-status {
  order: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 12px 0 0;
  border-radius: var(--calm-radius);
  padding: 18px 18px 16px;
  background: var(--calm-surface);
  text-align: center;
}

#screen-home .simplified-home-hero:not([data-ring="true"]) .tesla-schedule-status {
  align-items: flex-start;
  margin: 0;
  background: var(--surface-soft);
  text-align: left;
}

#screen-home .tesla-schedule-status.hidden {
  display: none;
}

#screen-home .tesla-schedule-status h3 {
  margin: 0;
  color: var(--calm-text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
}

#screen-home .tesla-schedule-status p {
  max-width: 320px;
}

/* reVolt plans on Today: one calm card about reVolt Home (the grace period, its end, or the offer) where the Weather
   plan, forecasts and solar's worth sit for a home with the plan. */
#screen-home .home-plan-notice {
  display: grid;
  gap: 14px;
  border-radius: var(--calm-radius);
  padding: 18px;
  background: var(--calm-surface);
}

#screen-home .home-plan-notice .eyebrow {
  margin: 0 0 6px;
  color: var(--calm-amber);
}

#screen-home .home-plan-notice h3 {
  margin: 0 0 6px;
  color: var(--calm-text);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

#screen-home .home-plan-notice p:not(.eyebrow) {
  margin: 0;
  color: var(--calm-muted);
  font-size: 14px;
  line-height: 1.45;
}

#screen-home .tesla-schedule-switch-back {
  min-height: 44px;
  max-width: 100%;
  margin: 8px 0 0;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  color: var(--calm-accent);
  background: var(--calm-accent-soft);
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#screen-home .tesla-schedule-switch-back:hover,
#screen-home .tesla-schedule-switch-back:focus-visible {
  background: rgba(125, 184, 255, 0.22);
}

#screen-home .tesla-schedule-switch-back.hidden {
  display: none;
}

#screen-home .home-plan-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#screen-home .home-plan-notice-actions button {
  flex: 1 1 120px;
  min-height: 44px;
}

/* Without reVolt Home the switches read off and say which plan adds them; the worth row offers the plan. */
#screen-home .hes-solar.locked small,
#screen-home .hes-storm.locked small {
  color: var(--calm-amber);
}

#screen-home .hes-worth.locked strong {
  color: var(--calm-accent);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: normal;
}

#screen-home .autopilot-card.pro-locked::after {
  content: var(--plan-tag, "Drive");
}
