/* =====================================================================================================================
   reVolt "calm" redesign: shared foundation.
   Loaded after styles.css (and before the per-screen styles-calm-*.css files), so everything here wins the cascade
   over the legacy passes without editing styles.css. One token block, a flat ground, borderless cards, quiet type,
   a plain tab bar, a small round Ask Rev button in the header corner, and shared building blocks the screens use:
   .calm-kicker, .calm-row, .calm-ring, .calm-segmented, .calm-num.
   ===================================================================================================================== */

:root {
  /* New tokens: screens should use these. */
  --calm-bg: #0A0E15;
  --calm-surface: #121824;
  --calm-raised: #243045;
  --calm-line: #1A212D;
  --calm-track: #1F2735;
  --calm-text: #E9EDF3;
  --calm-muted: #9AA4B2;
  --calm-faint: #6E7887;
  --calm-accent: #7DB8FF;
  --calm-accent-soft: rgba(125, 184, 255, 0.14);
  --calm-accent-deep: #1E3350;
  --calm-amber: #F2B36B;
  --calm-amber-soft: rgba(242, 179, 107, 0.14);
  --calm-radius: 20px;
  --calm-radius-control: 14px;
  --calm-gutter: 24px;
  --calm-tabbar: 76px;
  --calm-font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, system-ui, sans-serif;

  /* Legacy tokens mapped onto the calm palette, so the ~1,000 var() uses in styles.css follow along. */
  --bg: var(--calm-bg);
  --surface: var(--calm-surface);
  --surface-soft: #1A212D;
  --surface-tint: var(--calm-surface);
  --border: var(--calm-line);
  --border-strong: #232B38;
  --hairline: var(--calm-line);
  --text: var(--calm-text);
  --muted: var(--calm-muted);
  --soft: var(--calm-faint);
  --faint: var(--calm-faint);
  --accent: var(--calm-accent);
  --blue: var(--calm-accent);
  --blue-dark: #5E9FEA;
  --accent-blue: var(--calm-accent);
  --blue-soft: var(--calm-accent-soft);
  --accent-blue-soft: var(--calm-accent-soft);
  --accent-blue-line: rgba(125, 184, 255, 0.45);
  --amber: var(--calm-amber);
  --warning: var(--calm-amber);
  --warning-soft: var(--calm-amber-soft);
  --amber-soft: var(--calm-amber-soft);
  --orange: var(--calm-amber);
  --orange-2: var(--calm-amber);
  --radius-card: var(--calm-radius);
  --radius-sheet: var(--calm-radius);
  --radius-control: var(--calm-radius-control);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: none;
  --brand-gradient: linear-gradient(var(--calm-accent), var(--calm-accent));
  --action-gradient: linear-gradient(var(--calm-accent), var(--calm-accent));
  --font-ui: var(--calm-font);
  --font-num: var(--calm-font);
}

/* ---------- Ground and type ---------- */
html,
body,
.plug-stage,
body.native-app,
html.native-app {
  background: var(--calm-bg);
  background-attachment: initial;
}

body {
  color: var(--calm-text);
  font-family: var(--calm-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.phone-frame {
  border-color: #151B26;
  background: var(--calm-bg);
}

@media (min-width: 431px) {
  .phone-frame {
    border: 10px solid #151B26;
  }
}

body.native-app .phone-frame {
  border: 0;
}

.screen-view,
.auth-strip,
.bottom-tabs {
  background: var(--calm-bg);
}

a {
  color: var(--calm-accent);
}

:focus-visible {
  outline: 2px solid var(--calm-accent);
  outline-offset: 3px;
}

/* Large numerals: light, tight, tabular. Screens add .calm-num to their headline figures. */
.calm-num {
  font-family: var(--calm-font);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Screens: 24px gutters, no room needed for the old floating mascot ---------- */
.screen-view:not(.charge-sheet) {
  padding: 20px var(--calm-gutter) 32px;
}

body.native-app .screen-view:not(.charge-sheet) {
  padding-top: max(20px, calc(env(safe-area-inset-top, 0px) + 8px));
}

/* Page header: a small muted line (.calm-kicker) over the page title, Ask Rev in the top-right corner. */
.screen-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin: 0 0 24px;
}

/* Leave the top-right corner to the Ask Rev button on the four main tabs. */
.screen-view[data-screen="home"] > .screen-heading,
.screen-view[data-screen="device"] > .screen-heading,
.screen-view[data-screen="energy"] > .screen-heading,
.screen-view[data-screen="settings"] > .screen-heading {
  padding-right: 56px;
}

.screen-heading > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.screen-heading h2 {
  margin: 0;
  color: var(--calm-text);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.calm-kicker {
  margin: 0;
  color: var(--calm-muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-transform: none;
}

.calm-kicker:empty {
  display: none;
}

/* ---------- Section labels ---------- */
.eyebrow,
.hero-label,
.setting-head,
.calm-eyebrow {
  margin: 0 0 6px;
  color: var(--calm-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calm-eyebrow.amber {
  color: var(--calm-amber);
}

/* ---------- Cards: borderless surface, radius 20, no shadow, no glow ---------- */
.hero-card,
.ai-card,
.tesla-card,
.charge-empty-card,
.simulator-card,
.schedule-context-card,
.settings-card,
.log-card,
.hint-card,
.raw-api-card,
.garage-hero,
.vehicle-data-card,
.devices-hub-card,
.plan-rate-context-card,
.savings-period-card,
.charge-summary-list-card,
.settings-account-card,
.billing-summary-card,
.home-metric-card,
.settings-landing-list,
.settings-setup-tile,
.savings-hero,
.live-session-card,
.weekly-charging-card,
.rate-strip article,
.api-rate-feed-tile,
.weekly-summary-card,
.autopilot-card,
.charging-plan-card,
.plan-tonight-card,
.savings-pro-teaser,
.calm-card {
  border: 0 !important;
  border-radius: var(--calm-radius);
  box-shadow: none !important;
}

.hero-card,
.hero-card[data-state],
.home-metric-card,
.home-savings-wide,
.weekly-summary-card,
.autopilot-card,
.charging-plan-card,
.plan-tonight-card,
.settings-account-card,
.settings-profile-hero,
.savings-hero,
.account-page-hero,
.utility-rate-hero,
.setup-step-card,
.charge-empty-card,
.calm-card {
  background: var(--calm-surface) !important;
}

.calm-card {
  padding: 20px;
}

.hero-card,
.savings-hero,
.home-savings-wide,
.live-session-card.is-charging {
  border-left: 0 !important;
}

.plan-card.plan-pro,
.savings-pro-teaser {
  background: var(--calm-surface);
}

.savings-hero h2,
.signin-title b {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: var(--calm-text);
}

/* Legacy light hairlines become the calm divider color. */
.settings-route-row,
.settings-route-row + .settings-route-row,
.settings-detail-body {
  border-color: var(--calm-line);
}

/* Chips and tags: flat, quiet. */
.chip,
.badge,
.updated {
  border-color: transparent;
  color: var(--calm-muted);
  background: var(--surface-soft);
}

/* ---------- Bottom tabs: plain bar, faint inactive, bright active, no pill ---------- */
.bottom-tabs {
  height: var(--calm-tabbar);
  padding: 4px 12px 0;
  border-top: 1px solid #151B26;
  background: var(--calm-bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.bottom-tabs button,
.bottom-tabs button.active,
.bottom-tabs button:hover,
.bottom-tabs button:focus-visible {
  min-height: 0;
  align-content: center;
  gap: 4px;
  border-radius: 12px;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.bottom-tabs button {
  color: var(--calm-faint);
}

.bottom-tabs button.active,
.bottom-tabs button:hover {
  color: var(--calm-text);
}

.bottom-tabs button svg,
.bottom-tabs button.active svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.bottom-tabs button:focus-visible {
  outline: 2px solid var(--calm-accent);
  outline-offset: -2px;
}

/* ---------- Ask Rev: one small round button in the header's top-right corner ---------- */
.rev-button,
.rev-button.intro {
  position: absolute;
  top: 20px;
  right: var(--calm-gutter);
  bottom: auto;
  left: auto;
  z-index: 9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 22px;
  color: #C9D3E0;
  background: #161C27;
  box-shadow: none;
  transition: opacity 180ms ease, transform 180ms ease, background-color 160ms ease;
}

body.native-app .rev-button {
  top: max(20px, calc(env(safe-area-inset-top, 0px) + 8px));
}

/* While viewing a shared account the banner pushes the screens down; Rev follows, by the banner's measured height
   (--shared-banner-space: from the top of the app to the banner's bottom edge). */
.shared-account-banner:not(.hidden) ~ .rev-button {
  top: calc(20px + var(--shared-banner-space, 72px));
}

body.native-app .shared-account-banner:not(.hidden) ~ .rev-button {
  top: calc(max(20px, calc(env(safe-area-inset-top, 0px) + 8px)) + var(--shared-banner-space, 72px));
}

.rev-button::after {
  display: none;
}

.rev-button:hover {
  background: #1C2433;
}

.rev-button:active {
  transform: scale(0.94);
}

.rev-button:focus-visible {
  outline: 2px solid var(--calm-accent);
  outline-offset: 2px;
  border-radius: 22px;
}

.rev-button .rev-button-mark,
.rev-button.intro .rev-button-mark {
  position: static;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  overflow: visible;
  border-radius: 22px;
  background: transparent;
  animation: none;
}

.rev-button:active .rev-button-mark {
  transform: none;
}

.rev-button .rev-button-mark svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* "Ask Rev" is a small bubble to the left on the first visit only; otherwise it stays as the accessible name. */
.rev-button .rev-button-label {
  position: absolute;
  top: 50%;
  right: calc(100% + 8px);
  max-width: none;
  padding: 7px 12px;
  border-radius: 14px;
  color: var(--calm-text);
  background: var(--calm-raised);
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translate(6px, -50%);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.rev-button.intro .rev-button-label {
  opacity: 1;
  transform: translate(0, -50%);
}

/* Scrolling down a screen fades it out; scrolling up or reaching the top brings it back. */
.rev-button.tucked {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

/* The mascot no longer floats over the content, so screens don't need the 96px of room it used to take. */
.screen-view:not(.charge-sheet) {
  padding-bottom: 32px;
}

@media (prefers-reduced-motion: reduce) {
  .rev-button,
  .rev-button-label {
    transition: none;
  }
}

/* ---------- Toast ---------- */
.toast {
  top: max(16px, calc(env(safe-area-inset-top, 0px) + 10px));
  border-radius: 16px;
  padding: 12px 18px;
  color: var(--calm-text);
  background: var(--calm-raised);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  font-weight: 500;
  /* It only shows text; taps go through to whatever is under it. */
  pointer-events: none;
}

body.rev-open .toast {
  top: auto;
}

/* ---------- Overlays and sheets ---------- */
.app-sheet-overlay,
.setup-overlay,
.schedule-editor-overlay,
.tesla-auth-overlay,
.billing-gate {
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-sheet,
.setup-sheet,
.schedule-editor-sheet,
.tesla-auth-sheet,
.command-sheet,
.target-picker-sheet {
  border: 0;
  border-radius: var(--calm-radius) var(--calm-radius) 0 0;
  color: var(--calm-text);
  background: var(--calm-surface);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
}

.app-sheet {
  padding: 24px;
}

.setup-sheet.onboarding-screen {
  background: var(--calm-bg);
}

.billing-gate-card {
  border: 0;
  border-radius: var(--calm-radius);
  background: var(--calm-surface);
}

.sheet-top h2,
.app-sheet .sheet-top h2 {
  color: var(--calm-text);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Charge controls sheet uses the same sheet look. */
#screen-garage.charge-sheet.active {
  border-top: 0;
  border-radius: var(--calm-radius) var(--calm-radius) 0 0;
  padding-left: var(--calm-gutter);
  padding-right: var(--calm-gutter);
  background: var(--calm-surface);
}

.charge-sheet-backdrop {
  background: rgba(5, 7, 11, 0.72);
}

#screen-garage .charge-sheet-head h2 {
  font-size: 20px;
  font-weight: 500;
}

.charge-sheet-grabber {
  background: #2A3445;
}

/* Round icon buttons: no outline, quiet. */
.icon-button,
.auth-strip button {
  border: 0;
  color: var(--calm-muted);
  background: var(--surface-soft);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: transparent;
  color: var(--calm-text);
  background: var(--calm-raised);
}

.rev-overlay .rev-sheet {
  border-radius: var(--calm-radius) var(--calm-radius) 0 0;
}

/* ---------- Buttons ---------- */
.primary-action,
.secondary-action,
.settings-row.button-row,
.auth-primary-button {
  border-radius: var(--calm-radius-control);
  font-weight: 600;
}

.primary-action:not(:disabled):not(.charge-start-button),
.auth-primary-button:not(:disabled) {
  border-color: transparent;
  color: var(--calm-bg);
  background: var(--calm-accent);
  box-shadow: none;
}

.primary-action:not(.charge-start-button),
.auth-primary-button {
  box-shadow: none;
}

.secondary-action {
  border: 0;
  border-color: transparent;
  color: var(--calm-text);
  background: var(--surface-soft);
}

.primary-action:disabled,
.secondary-action:disabled {
  border-color: transparent;
  color: var(--calm-faint);
  background: var(--calm-surface);
}

/* ---------- Segmented controls (D / W / M, three-way choices) ---------- */
.period-tabs,
.segmented-control,
.calm-segmented {
  gap: 4px;
  border: 0;
  border-radius: var(--calm-radius-control);
  padding: 4px;
  background: var(--calm-surface);
}

.period-tabs button,
.segmented-control button,
.calm-segmented button,
.calm-segmented label {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  color: var(--calm-muted);
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 400;
}

.period-tabs button.active,
.segmented-control button.active,
.calm-segmented button.active,
.calm-segmented button[aria-selected="true"],
.calm-segmented label:has(input:checked) {
  color: var(--calm-text);
  background: var(--calm-raised);
  box-shadow: none;
  font-weight: 500;
}

.boost-duration-grid button.active,
.limit-option-grid button.active,
.rate-card-option.active,
.setup-choice.active,
.period-tile.active {
  border-color: transparent;
  color: var(--calm-text);
  background: var(--calm-raised);
  box-shadow: none;
}

.period-tile.active strong {
  color: var(--calm-text);
}

/* ---------- Shared list row: label left, value right, chevron, hairline dividers ---------- */
.calm-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.calm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--calm-line);
  border-radius: 0;
  color: var(--calm-text);
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
}

.calm-row:last-child {
  border-bottom: 0;
}

.calm-row-label {
  min-width: 0;
  color: var(--calm-text);
}

.calm-row-value {
  flex: none;
  max-width: 60%;
  overflow: hidden;
  color: var(--calm-muted);
  font-size: 14px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calm-row-value.accent {
  color: var(--calm-accent);
}

button.calm-row::after,
a.calm-row::after,
.calm-row.chevron::after {
  content: "\203A";
  flex: none;
  margin-left: -4px;
  color: var(--calm-faint);
  font-size: 18px;
  line-height: 1;
}

button.calm-row:active,
a.calm-row:active {
  opacity: 0.7;
}

/* ---------- Rings ---------- */
/* .calm-ring: an SVG ring with a track circle (.calm-ring-track) and a value arc (.calm-ring-fill, set with
   stroke-dasharray on pathLength="100"). .amber switches the arc color. */
.calm-ring {
  display: block;
  flex: none;
}

.calm-ring circle {
  fill: none;
  stroke-linecap: round;
}

.calm-ring-track {
  stroke: var(--calm-track);
}

.calm-ring-goal {
  stroke: #2A3445;
}

.calm-ring-fill {
  stroke: var(--calm-accent);
  transition: stroke-dasharray 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.calm-ring.amber .calm-ring-fill {
  stroke: var(--calm-amber);
}

/* Home battery ring: solid accent, no gradient or glow. */
.charge-ring:not([data-state="complete"]) .ring-fill {
  stroke: var(--calm-accent);
  filter: none;
}

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

.charge-level-slider-fill {
  background: var(--calm-accent);
}

/* ---------- Banners ---------- */
.shared-account-banner {
  margin: 8px var(--calm-gutter) 0;
  border-radius: 16px;
  padding: 10px 14px;
  background: var(--calm-surface);
  color: var(--calm-text);
}

.shared-account-banner small {
  color: var(--calm-muted);
}

.shared-account-banner button {
  border-color: transparent;
  color: var(--calm-bg);
  background: var(--calm-accent);
  font-weight: 500;
}

.offline-banner {
  border: 0;
  background: var(--calm-raised);
}

/* Screen-reader-only helper. */
.calm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Ask Rev shows Rev himself, as before the calm redesign, sized to sit inside the 44px button. */
.rev-button .rev-button-mark img {
  position: static;
  display: block;
  width: auto;
  height: 34px;
  max-width: none;
  margin: 0;
  transform: none;
  filter: none;
  pointer-events: none;
}

/* ---------- Text fit: shared shell (every string stays inside its button, sheet and the screen) ---------- */

/* Toast: legacy left:50% + translate shrink-wraps it to half the screen, so a long message became a tall narrow
   column over the header. Size it to its text, up to the screen less a 16px gutter each side. */
.toast {
  width: max-content;
  max-width: min(calc(100vw - 32px), 360px);
  overflow-wrap: anywhere;
  text-align: center;
  line-height: 1.4;
}

/* Rev: a long word, URL or name in a message pushed the bubble past the sheet's edge, where it was cut off. */
.rev-message,
.rev-bubble,
.rev-text,
.rev-message.you p,
.rev-suggest,
.rev-suggest .rev-do,
.rev-suggest .rev-do > span:not(.rev-do-icon) {
  min-width: 0;
}

.rev-message p,
.rev-text,
.rev-text li,
.rev-welcome h3,
.rev-welcome > p,
.rev-suggest .rev-do > span:not(.rev-do-icon),
.rev-done,
.rev-stats dd {
  overflow-wrap: anywhere;
}

.rev-actions button {
  max-width: 100%;
  text-align: left;
}

/* Sign-in / create account: a long email in "We sent a code to ..." (or any unbroken word) set the column's minimum
   width, so the whole screen grew to 420px and ran off a 320-390px phone. Let every block shrink to the screen and
   break long words instead. */
.auth-gate .signin > *,
.auth-gate .signin-panel > *,
.auth-gate .signin-form > *,
.auth-gate .signin-hero > * {
  min-width: 0;
}

.auth-gate .signin-title,
.auth-gate .signin-subcopy,
.auth-gate .signin-message,
.auth-gate .signin-error,
.auth-gate .signin-hint,
.auth-gate .signin-zip-status,
.auth-gate .signin-footer,
.auth-gate .signin-legal,
.auth-gate .signin-alt-button span {
  overflow-wrap: anywhere;
}

.auth-gate .signin-preview-head {
  flex-wrap: wrap;
  row-gap: 4px;
}

.auth-gate .signin-preview-head em {
  min-width: 0;
  text-align: right;
}

.auth-gate .signin-alt-button {
  padding-left: 12px;
  padding-right: 12px;
  text-align: center;
}

.auth-gate .signin-footer svg {
  align-self: flex-start;
  margin-top: 1px;
}

/* Page kickers (Plan shows the car's name): a long name wraps under the title's line instead of being cut to "...". */
#screen-device > .screen-heading #planVehicleKicker,
.screen-heading .calm-kicker {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Confirm sheet (Start / Stop charging): the buttons' minimum widths (96px + 150px) were wider than a 320px sheet's
   content, so the rows and buttons ran into the sheet's right padding. Let the columns shrink; labels may wrap. */
.command-actions {
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
}

.command-actions .primary-action,
.command-actions .secondary-action {
  min-width: 0;
  padding: 0 12px;
  white-space: normal;
  line-height: 1.2;
}

/* Shared-account banner. styles.css never applies its own banner and Shared access rules: the
   ".tesla-cars-save:disabled {" rule just before them is missing its closing brace, so the parser drops everything
   after it. Without them the name, role and "Back to mine" ran together as one paragraph and the banner grew under
   Ask Rev. Restated here: the account's name in full, its role under it, and "Back to mine" on the right. A name too
   long to share the line with the button gets the banner's whole width and the button moves to a line of its own;
   the screens and Ask Rev move down by however tall the banner is (--shared-banner-space, set by 12c-shared-access.js). */
.tesla-cars-save:disabled {
  opacity: 0.5;
}

.shared-account-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 64px;
  box-sizing: border-box;
}

.shared-account-banner.hidden {
  display: none;
}

.shared-account-banner > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.shared-account-banner strong {
  color: var(--calm-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.shared-account-banner small {
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.shared-account-banner button {
  flex: none;
  min-height: 44px;
  margin-left: auto;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.shared-account-banner:not(.hidden) ~ .screen-stack {
  height: calc(100% - var(--calm-tabbar) - var(--shared-banner-space, 72px));
}

.shared-access-btn {
  flex: none;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--calm-text);
  background: var(--calm-raised);
  font: inherit;
  font-weight: 500;
}

.shared-access-btn:disabled {
  opacity: 0.55;
}

.shared-access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.shared-access-row > span:first-child {
  display: grid;
  min-width: 0;
  flex: 1 1 160px;
}

.shared-access-row strong,
.shared-access-row small {
  overflow-wrap: anywhere;
}

.shared-access-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.shared-access-role {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 0 8px;
  color: var(--calm-text);
  background: var(--calm-raised);
  font: inherit;
}

.shared-access-invite {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.shared-access-note {
  margin: 6px 0 10px;
  color: var(--calm-muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.shared-access-note.error {
  color: var(--calm-amber);
}

/* Offline notice: pinned to the top it sat over the page kicker ("Tue, Nov 17") and Ask Rev. It now floats just
   above the tab bar, and wraps instead of running past a narrow screen. */
.offline-banner {
  top: auto;
  bottom: calc(var(--calm-tabbar) + 12px + env(safe-area-inset-bottom, 0px));
  max-width: min(calc(100vw - 32px), 360px);
  border: 0;
  border-radius: 16px;
  color: var(--calm-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Recovery sheet: two facts in a three-column grid left each tile ~70px wide at 320px, cutting "Complete" off.
   The tiles now share the full width and long values wrap; where two tiles would be under 140px each (a car's name
   ran to seven lines) they stack. */
.failure-recovery-sheet .assumption-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.failure-recovery-sheet .assumption-grid > div {
  min-width: 0;
}

.failure-recovery-sheet .assumption-grid strong {
  overflow-wrap: anywhere;
}

/* Offline notice: it floats above the tab bar, so while it shows each screen ends with room for it and the last
   line can still be scrolled clear of it. */
body:has(#offlineBanner:not(.hidden)) .screen-view:not(.charge-sheet) {
  padding-bottom: 104px;
}

/* "Ask Rev" bubble: on Savings, D / W / M sits right beside Ask Rev (on a 390px or wider phone) and the bubble would
   cover it. As on Plan (styles-calm-plan.css), the button alone is enough there; the bubble shows on Today and Me. */
body:has(#screen-energy.active) .rev-button.intro .rev-button-label {
  opacity: 0;
}

/* Rev: a suggested action that wraps to several lines kept no room above and below its label. */
.rev-suggest .rev-do {
  padding-top: 10px;
  padding-bottom: 10px;
  line-height: 1.3;
}

/* Rev's first screen: the goal ("100% by 12:45 PM") and price were cut to "100% ..." in their third of the row.
   Values wrap instead, and each row of labels and of values lines up across the three tiles. */
.rev-stats {
  grid-template-columns: none;
  grid-template-rows: auto auto;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
}

.rev-stats div {
  grid-row: span 2;
  grid-template-rows: subgrid;
  align-content: start;
}

.rev-stats dt,
.rev-stats dd {
  overflow-wrap: anywhere;
}

.rev-stats dd {
  overflow: visible;
  line-height: 1.25;
  white-space: normal;
  text-overflow: clip;
}

/* A "Done" note longer than a line was drawn inside a 999px radius, which made it a green blob. */
.rev-done {
  border-radius: 16px;
}

/* Sign-in: "Send a new code" and "Back to log in" sat 4px apart and read as one phrase. */
.auth-gate .signin-back-row {
  flex-wrap: wrap;
  column-gap: 24px;
}

/* Vehicle picker: Cancel and Save Target had minimum widths (96px + 150px) wider than a 320px sheet, so Save Target
   ran into the sheet's edge; and "Connect Vehicle" was squeezed into half the row on two lines. */
.target-picker-actions {
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
}

.target-picker-actions .primary-action,
.target-picker-actions .secondary-action {
  min-width: 0;
  padding: 0 12px;
  white-space: normal;
  line-height: 1.2;
}

.target-picker-setup-actions {
  display: flex;
  flex-wrap: wrap;
}

.target-picker-setup-actions > button {
  flex: 0 1 auto;
  min-width: 0;
  white-space: normal;
}

.target-picker-setup-actions.is-primary-path > button {
  flex: 1 1 100%;
}

/* Setup: beside "Step 1 of 2" and the close button the heading had a third of a narrow phone's width, so the eyebrow
   (a car's name: "... is connected") ran to six lines. Under 390px the step and close button take the first line
   and the eyebrow and title get the full width under them. */
@media (max-width: 389px) {
  #setupOverlay .setup-top.onboarding-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "step close"
      "text text";
    align-items: center;
    gap: 12px;
  }

  #setupOverlay .setup-top.onboarding-top > div:first-child {
    grid-area: text;
    min-width: 0;
  }

  #setupOverlay .setup-top.onboarding-top > .setup-step-pill {
    grid-area: step;
    justify-self: start;
  }

  #setupOverlay .setup-top.onboarding-top > #setupCloseButton {
    grid-area: close;
  }
}

/* Choose your cars: "Loading your cars…" and "There are no cars on this Tesla account." sat on the list's rounded
   surface with no padding, so the first letters ran into its corner. They get the rows' padding. */
#teslaCarsOverlay .tesla-cars-list > .tesla-cars-intro {
  padding: 14px 18px;
}

/* A car name with a long unbroken word set the list's width, so every row scrolled sideways and names and notes were
   cut at the sheet's edge. Rows keep to the sheet and long words break. */
#teslaCarsOverlay .tesla-cars-list {
  grid-template-columns: minmax(0, 1fr);
}

#teslaCarsOverlay .tesla-car-row > span {
  min-width: 0;
}

#teslaCarsOverlay .tesla-car-row strong,
#teslaCarsOverlay .tesla-car-row small,
#teslaCarsOverlay .tesla-cars-status {
  overflow-wrap: anywhere;
}

/* Utility setup: "Select Provider" and "Take Questionnaire" are wider together than a 320px sheet, and the second ran
   past its edge. On a narrow phone each takes its own line. */
#utilitySettingsOverlay .utility-actions {
  flex-wrap: wrap;
  row-gap: 10px;
}

#utilitySettingsOverlay .utility-actions > button {
  flex: 1 1 auto;
}

/* ---------- Take control sheet ---------- */
/* Two big choices (Charge now / Stop charging, and Use my Tesla schedule) with what each does, then a way to tell us. */
.take-control-overlay .take-control-sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: rev-sheet-in 280ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.take-control-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
}

.take-control-head > div {
  min-width: 0;
}

.take-control-head h2 {
  margin: 0;
  color: var(--calm-text);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.take-control-head h2:focus {
  outline: none;
}

.take-control-head p {
  margin: 6px 0 0;
  color: var(--calm-muted);
  font-size: 14px;
  line-height: 1.45;
}

.take-control-head .icon-button {
  flex: none;
}

.take-control-notice {
  margin: 0;
  border-radius: var(--calm-radius-control);
  padding: 12px 14px;
  color: var(--calm-amber);
  background: var(--calm-amber-soft);
  font-size: 14px;
  line-height: 1.45;
}

/* View-only access is how sharing works, not a problem, so it reads quietly; being offline gets the amber. */
.take-control-notice[data-kind="view-only"] {
  color: var(--calm-text);
  background: var(--surface-soft);
}

.take-control-notice.hidden {
  display: none;
}

.take-control-choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.take-control-option,
.take-control-current {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  column-gap: 14px;
  row-gap: 12px;
  width: 100%;
  min-height: 76px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--calm-radius);
  padding: 16px;
  color: var(--calm-text);
  background: var(--surface-soft);
  box-shadow: none;
  font: inherit;
  text-align: left;
}

.take-control-option {
  cursor: pointer;
}

.take-control-option.hidden,
.take-control-current.hidden {
  display: none;
}

.take-control-option:not(:disabled):hover,
.take-control-option:focus-visible {
  background: var(--calm-raised);
}

.take-control-current {
  border-color: var(--accent-blue-line);
}

.take-control-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--calm-accent);
  background: var(--calm-accent-soft);
}

.take-control-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Stopping and the Tesla app's schedule are quieter than charging now. */
.take-control-option.is-stop .take-control-icon,
#takeControlTeslaSchedule .take-control-icon {
  color: var(--calm-text);
  background: var(--calm-raised);
}

.take-control-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-top: 1px;
}

.take-control-text strong {
  color: var(--calm-text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
}

.take-control-text small {
  color: var(--calm-muted);
  font-size: 14px;
  line-height: 1.45;
}

.take-control-text small.hidden {
  display: none;
}

.take-control-text .take-control-detail {
  color: var(--calm-text);
}

/* Can't be used right now: the reason is in the description, so it stays at full contrast and reads as information,
   not a broken button. Only the title and icon step back. */
.take-control-option:disabled {
  cursor: default;
  opacity: 1;
}

.take-control-option:disabled:not(.is-busy) strong {
  color: var(--calm-muted);
}

.take-control-option:disabled:not(.is-busy) .take-control-icon {
  opacity: 0.45;
}

/* Sending: a spinner in place of the icon while the car wakes and answers. */
.take-control-option.is-busy .take-control-icon svg {
  opacity: 0;
}

.take-control-option.is-busy .take-control-icon::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: take-control-spin 0.9s linear infinite;
}

@keyframes take-control-spin {
  to { transform: rotate(360deg); }
}

.take-control-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 0 0 0 4px;
}

.take-control-feedback.hidden,
.take-control-feedback p.hidden {
  display: none;
}

.take-control-feedback p {
  flex: 1 1 220px;
  margin: 0;
  color: var(--calm-amber);
  font-size: 14px;
  line-height: 1.45;
}

.take-control-retry,
.take-control-switch-back {
  min-height: 44px;
  max-width: 100%;
  margin: 0;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.take-control-retry {
  color: var(--calm-text);
  background: var(--calm-raised);
}

.take-control-retry.hidden {
  display: none;
}

.take-control-switch-back {
  grid-column: 2;
  justify-self: start;
  color: var(--calm-accent);
  background: var(--calm-accent-soft);
}

.take-control-retry:disabled,
.take-control-switch-back:disabled {
  cursor: default;
  opacity: 0.5;
}

.take-control-help {
  align-self: center;
  min-height: 44px;
  margin: 2px 0 0;
  border: 0;
  padding: 0 12px;
  color: var(--calm-muted);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

.take-control-help span {
  color: var(--calm-accent);
  font-weight: 500;
}

.take-control-help:hover span,
.take-control-help:focus-visible span {
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .take-control-overlay .take-control-sheet { animation: none; }
  .take-control-option.is-busy .take-control-icon::after { animation: none; border-right-color: currentColor; opacity: 0.6; }
}

/* reVolt plans: a locked control's small tag names the plan that adds it, set as --plan-tag. */
.pro-locked::after {
  content: var(--plan-tag, "Drive");
}
