/* MotoHQ theme consistency — shared appearance only, no layout or visibility rules.
   A named layer gives these appearance rules precedence over legacy unlayered
   !important declarations, including styles loaded later by feature scripts. */
@layer motohq-theme-consistency {
 @media screen {
  body[data-theme]:not(.landing-active) {
   --ui-surface:var(--surface,#fff);
   --ui-panel:var(--surface,#fff);
   --ui-card:#f2f2f2;
   --ui-input:#fff;
   --ui-text:var(--text,#14201f);
   --ui-muted:var(--muted,#506174);
   --ui-accent:var(--theme-primary,#00b7eb);
   --ui-ink:color-mix(in srgb,var(--theme-primary,#00b7eb) 68%,#122334);
   --ui-on-accent:#fff;
   --ui-edge:color-mix(in srgb,var(--theme-primary,#00b7eb) 28%,#c6d3df);
   --ui-field-edge:color-mix(in srgb,var(--theme-primary,#00b7eb) 28%,#9caebb);
   --ui-rim:#ffffffc9;
   --ui-button:var(--chrome-fill,linear-gradient(180deg,#fff,#edf3f8));
   --ui-shadow:inset 0 1px 0 var(--ui-rim),0 4px 12px #12233412;
   --ui-button-shadow:inset 0 1px 0 var(--ui-rim),0 3px 7px #00000020;
   --ui-danger:#ad2440;
   --ui-success:#196541;
   --ui-warning:#87520a;
   --ui-backdrop:#06101fb3;
   --ui-color-scheme:light;
  }
  /* Standard daytime themes need a white page canvas, not the legacy mobile
     black body. Keep html, the header and the status-area overlay unchanged. */
  body:is([data-theme="tm"],[data-theme="blue"],[data-theme="husqvarna"],[data-theme="pink"],[data-theme="purple"])[data-display-mode="day"]:not(.landing-active) {
   background:#fff!important;
   --ui-surface:#fff;
   --ui-panel:#fff;
  }
  body:is([data-theme="tm"],[data-theme="blue"],[data-theme="husqvarna"],[data-theme="pink"],[data-theme="purple"])[data-display-mode="day"]:not(.landing-active)>:is(main:not(.mh-main),footer.site-footer) {
   background:#fff!important;
  }
  /* Blue Glass 2: let the glass canvas show through the header gap on mobile. */
  @media (max-width:560px) {
   body[data-theme="glass-test"][data-display-mode="day"]:not(.landing-active)>main:not(.mh-main) {
    box-shadow:none!important;
   }
  }
  body[data-theme][data-display-mode="night"]:not(.landing-active) {
   --ui-card:#1d1f1f;
   --ui-input:#151719;
   --ui-text:var(--text,#eef3f8);
   --ui-muted:var(--muted,#acbacb);
   --ui-ink:color-mix(in srgb,var(--theme-primary,#00b7eb) 52%,#fff);
   --ui-edge:color-mix(in srgb,var(--theme-primary,#00b7eb) 30%,#465260);
   --ui-field-edge:color-mix(in srgb,var(--theme-primary,#00b7eb) 30%,#667786);
   --ui-rim:#ffffff40;
   --ui-danger:#ff9caa;
   --ui-success:#9ae3b2;
   --ui-warning:#ffd18a;
   --ui-backdrop:#030710c9;
   --ui-color-scheme:dark;
  }
  body[data-theme*="glass"][data-display-mode]:not(.landing-active) {
   --ui-panel:var(--bg-glass-panel);
   --ui-card:var(--bg-glass-field);
   --ui-input:var(--bg-glass-input);
   --ui-text:var(--bg-glass-text);
   --ui-muted:var(--bg-glass-muted);
   --ui-edge:var(--bg-glass-edge);
   --ui-field-edge:color-mix(in srgb,var(--theme-primary) 35%,var(--line,#b5c6d8));
   --ui-rim:var(--bg-glass-rim);
   --ui-button:linear-gradient(180deg,#ffffff25,#ffffff08 48%,#00000010 49%,#ffffff08),var(--bg-glass-field);
   --ui-shadow:inset 0 1px 1px var(--ui-rim),inset 0 -1px 0 #ffffff20,0 8px 14px #00000020;
  }
  /* Use a legible shade of the selected blue/pink for text on pale glass. */
  body[data-theme="black-blue-glass"][data-display-mode="day"]:not(.landing-active) {--ui-text:#006990;--ui-muted:#176b88;--ui-ink:#006990;--ui-on-accent:#08212b;}
  body[data-theme="black-pink-glass"][data-display-mode="day"]:not(.landing-active) {--ui-text:#a30b60;--ui-muted:#98416e;--ui-ink:#a30b60;--ui-on-accent:#260a19;}
  body:is([data-theme="tm"],[data-theme="blue"],[data-theme="pink"],[data-theme="neon-green"],[data-theme="snake"]) {--ui-on-accent:#10202c;}
  body[data-theme*="glass"][data-display-mode="night"] {--ui-on-accent:#101a27;}
  body[data-theme="snake"] {--ui-input:#0b0d0e;}
  /* Keep Neon Lights' cyan, pink and lime section accents, including their glow. */
  body[data-theme="neon-lights-glass"][data-display-mode]:not(.landing-active),
  body[data-theme="neon-lights-glass"] :where(main,dialog,button,.button,.metric,#garageWorkspace,#chat,#setupPanel,#partsOrderPanel,#bikeNotesPanel,#maintenancePanel,#upcomingEventsPanel) {
   --ui-ink:var(--nl-ink);
   --ui-edge:rgba(var(--nl-rgb),.5);
   --ui-field-edge:rgba(var(--nl-rgb),.5);
   --ui-shadow:inset 0 1px 0 var(--ui-rim),0 8px 14px var(--nl-shadow),0 0 18px rgba(var(--nl-rgb),.12);
   --ui-button-shadow:inset 0 1px 0 var(--ui-rim),0 3px 7px var(--nl-shadow),0 0 10px rgba(var(--nl-rgb),.1);
  }

  /* App pages and all native/dynamically mounted popups. */
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) {
   color:var(--ui-text)!important;
   scrollbar-color:var(--ui-field-edge) var(--ui-input);
  }
  body[data-theme]:not(.landing-active) :where(dialog,[role="dialog"]) {
   color-scheme:var(--ui-color-scheme);
   background:var(--ui-panel)!important;
   background-color:var(--ui-surface)!important;
   color:var(--ui-text)!important;
   border-color:var(--ui-edge)!important;
   box-shadow:inset 0 1px 0 var(--ui-rim),0 24px 72px #00000066!important;
  }
  body[data-theme]:not(.landing-active) dialog::backdrop {background:var(--ui-backdrop)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   h1,h2,h3,h4,h5,h6,dt,dd,label,legend,.panel-title,.card-title,.ride-explore-tool-copy
  ) {color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   p,small,.hint,.intro,.empty-state,.service-meta,.chat-context,.metric span,
   .lap-timer-stats span,.lap-timer-message,.ride-mode-message,.ride-mode-stats span,
   .setup-status-line,.ride-entry-details dt,.race-entry-details dt,.ride-path-stat span
  ) {color:var(--ui-muted)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   strong,b,.lap-timer-lap-time,#lapTimerClock,#rideModeClock,dd
  ) {color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   .accent,.due,.lap-timer-status,.lap-timer-lap b,.ride-mode-status,.eyebrow,.passport-kicker
  ) {color:var(--ui-ink)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"],footer.site-footer) a:not(.brand):not(.mhq-mobile-tab):not(.leaflet-control a):not(.leaflet-control-attribution a) {color:var(--ui-ink)!important;}

  /* Only real cards receive surfaces; page wrappers and card grids stay clear. */
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   article,.service-card,.garage-bike-tile,.garage-tray-card,.metric,.race-season-stat,
   .race-feature-card,.bike-setup-page-card,.ride-log-entry,.race-result-entry,
   .passport-section,.passport-stat,.passport-bike-summary,.membership-card,
   .onboarding-step,.install-guide-card,.dashboard-metric-option,.garage-module-option,
   .backup-sync-card,.backup-status-card,.rider-management-card,.rider-bike-mini,
   .rider-details-section,.family-bike-card,.ride-result-card,.placeholder-library-card,
   .maintenance-center-card,.maintenance-reminder-card,.cost-stat,.cost-summary-card,
   .setup-spec-field,.ride-lap-summary>span,.lap-timer-stats>div,.ride-mode-stats>div,
   .gps-stat,.gps-summary-card,.gps-performance-card,.gps-metric,.ride-path-stat,
   .ride-lap-details,.directory-results,.account-benefits,.account-status-card,
   .membership-status-card,.admin-access-card,.admin-page-card,.assistant-action-card,
   .assistant-video-card,.event-card,.filter-card,.maintenance-card,.machine-card,
   .metric-card,.module-card,.part-card,.part-order-card,.parts-order-card,
   .parts-order-page-card,.race-card,.race-result-card,.repair-outcome-card,
   .ride-card,.ride-log-card,.rider-card,.setup-card,.page-filter-card,.search-sort-card
  ) {
   background:var(--ui-card)!important;color:var(--ui-text)!important;
   border-color:var(--ui-edge)!important;box-shadow:var(--ui-shadow)!important;
  }
  body[data-theme]:not(.landing-active) :where(
   #dashboard,#garageWorkspace,#assistantWorkspace,#chat
  ) {background:var(--ui-panel)!important;color:var(--ui-text)!important;border-color:var(--ui-edge)!important;}
  body[data-theme]:not(.landing-active) :where(
   #rideLogTools,#raceResultsTools,#maintenanceTools,.bike-setups-toolbar,
   .parts-order-toolbar,.family-garage-tools,.history-toolbar,.ride-log-tools,
   .riders-toolbar,.ride-mode-map-toolbar,.gps-import-toolbar,.gps-performance-toolbar
  ) {background:var(--ui-card)!important;color:var(--ui-text)!important;border-color:var(--ui-edge)!important;}

  /* Card headers and stopwatch/ride-mode interiors share their parent's surface. */
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   .dialog-head,.dialog-body,.dialog-footer,.form-actions,.subhead,.section-head,
   .dashboard-head,.dashboard-bottom,.chat-top,.composer,.assistant-disclaimer,
   .lap-timer-shell,.lap-timer-head,.lap-timer-stage,.lap-timer-clock-panel,
   .lap-timer-setup,.lap-timer-footer,.lap-timer-tray-body,
   .ride-mode-shell,.ride-mode-head,.ride-mode-body,.ride-mode-panel,.ride-mode-footer,
   .ride-mode-clock,.ride-mode-stats,.ride-mode-actions,.ride-mode-message,
   .ride-mode-save-head,.ride-mode-save-body,.ride-mode-save-footer,
   .ride-path-head,.ride-path-body,.ride-path-footer,
   .passport-section h3,.bike-setup-page-card header
  ) {background:transparent!important;color:var(--ui-text)!important;border-color:var(--ui-edge)!important;}
  body[data-theme]:not(.landing-active) :where(.lap-timer-laps,.message.ai,.account-auth-panel,.ride-path-summary) {
   background:var(--ui-card)!important;color:var(--ui-text)!important;border-color:var(--ui-edge)!important;
  }
  body[data-theme]:not(.landing-active) :where(.message.ai,.message.ai *) {color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) .message.user {
   background:var(--ui-accent)!important;color:var(--ui-on-accent)!important;
  }
  body[data-theme]:not(.landing-active) .message.user * {color:var(--ui-on-accent)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   hr,fieldset,th,td,.setup-detail-row,.setup-spec-field,.ride-entry-details>div,
   .race-entry-details>div,.lap-timer-lap,.ride-lap-details li,.rider-details-grid>div,
   .passport-detail-list>div,.passport-record,.maintenance-center-details>div
  ) {border-color:var(--ui-edge)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(th,td) {background:transparent!important;color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) th {background:var(--ui-card)!important;}

  /* Text/date/time/file controls, dropdown options and autofill. */
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"]) :where(
   input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]),select,textarea
  ) {
   background:var(--ui-input)!important;color:var(--ui-text)!important;
   color-scheme:var(--ui-color-scheme);
   -webkit-text-fill-color:var(--ui-text)!important;caret-color:var(--ui-accent)!important;
   border-color:var(--ui-field-edge)!important;
   box-shadow:inset 0 2px 4px #0000000e!important;
  }
  body[data-theme]:not(.landing-active) :where(input,textarea)::placeholder {color:var(--ui-muted)!important;opacity:1!important;-webkit-text-fill-color:var(--ui-muted)!important;}
  body[data-theme]:not(.landing-active) :where(option,optgroup) {background:var(--ui-input)!important;color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) input:is(:-webkit-autofill,:autofill) {
   -webkit-text-fill-color:var(--ui-text)!important;box-shadow:0 0 0 1000px var(--ui-input) inset!important;caret-color:var(--ui-accent)!important;
  }
  body[data-theme]:not(.landing-active) :where(input[type="checkbox"],input[type="radio"],input[type="range"],progress) {accent-color:var(--ui-accent)!important;}
  body[data-theme]:not(.landing-active) :where(input[type="checkbox"],input[type="radio"]) {background-color:var(--ui-input)!important;border-color:var(--ui-field-edge)!important;}
  body[data-theme]:not(.landing-active) input::file-selector-button {
   background:var(--ui-button)!important;color:var(--ui-ink)!important;
   border:1px solid var(--ui-field-edge);border-radius:8px;font:inherit;
  }
  body[data-theme]:not(.landing-active) :where(input,select,textarea):is(:disabled,[readonly]) {color:var(--ui-muted)!important;-webkit-text-fill-color:var(--ui-muted)!important;}
  body[data-theme]:not(.landing-active) :where(input,select,textarea):focus {border-color:var(--ui-accent)!important;}
  /* Keep clicked controls free of the extra outline. Keyboard focus uses a soft
     accent halo instead of a hard text-colored ring. The nested layer wins over
     legacy per-component important focus rules without changing normal borders. */
  @layer focus-feedback {
   body[data-theme]:not(.landing-active) :where(button,a,input,select,textarea,summary,[tabindex]):focus {
    outline:none!important;
   }
   body[data-theme]:not(.landing-active) :where(button,a,input,select,textarea,summary,[tabindex]):focus-visible {
    box-shadow:0 0 10px 2px color-mix(in srgb,var(--ui-accent,var(--theme-primary,#00b7eb)) 45%,transparent)!important;
   }
   @media (forced-colors:active) {
    body[data-theme]:not(.landing-active) :where(button,a,input,select,textarea,summary,[tabindex]):focus-visible {
     outline:2px solid Highlight!important;outline-offset:3px!important;box-shadow:none!important;
    }
   }
  }

  /* Ordinary actions retain their sizes, hit areas and existing behavior. */
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"],body>header,footer.site-footer) :where(
   button,.button,input[type="submit"],input[type="button"]
  ):not(.bike-card):not(.rider-details-open):not(.mhq-mobile-tab):not(.leaflet-control button):not(:where(.make-bike-active,.rider-set-active)) {
   background:var(--ui-button)!important;color:var(--ui-ink)!important;
   border-color:var(--ui-field-edge)!important;box-shadow:var(--ui-button-shadow)!important;
  }
  body[data-theme]:not(.landing-active) :where(button,.button) :where(span,strong,b,small,svg) {color:inherit!important;}
  body[data-theme]:not(.landing-active) :where(main,dialog,[role="dialog"],body>header,footer.site-footer) :where(button,.button):not(:where(.make-bike-active,.rider-set-active)):enabled:hover {
   border-color:var(--ui-accent)!important;box-shadow:inset 0 1px 0 var(--ui-rim),0 0 0 1px var(--ui-accent),0 4px 10px #00000024!important;
  }
  body[data-theme]:not(.landing-active) :where(button,.button):is(:disabled,[aria-disabled="true"]) {
   color:var(--ui-muted)!important;opacity:.55!important;
  }
  body[data-theme]:not(.landing-active) :where(
   button[aria-pressed="true"],button.active,.make-bike-active.is-active,.rider-set-active.is-active,
   #lapTimerStartButton,#lapTimerLapButton,#rideModeStart,#rideModeMark
  ) {border-color:var(--ui-accent)!important;color:var(--ui-ink)!important;}
  body[data-theme]:not(.landing-active) :where(
   .icon-button,.remove-service,.remove-bike-card,.lap-timer-lap button,.rider-details-open,
   .lap-timer-tray-toggle,.lap-timer-setup-toggle,.rider-drag-handle,.family-bike-drag-handle
  ) {background:transparent!important;box-shadow:none!important;color:var(--ui-ink)!important;}
  body[data-theme]:not(.landing-active) :where(.rider-details-open):hover {box-shadow:none!important;}
  body[data-theme]:not(.landing-active) :where(
   .garage-bike-tile .bike-card,.family-bike-mirror .bike-card
  ) {background:transparent!important;color:var(--ui-text)!important;box-shadow:none!important;}
  body[data-theme]:not(.landing-active) :where(.danger,button[data-action="delete"],.rider-delete-button) {
   background:color-mix(in srgb,var(--ui-danger) 12%,var(--ui-input))!important;
   color:var(--ui-danger)!important;border-color:var(--ui-danger)!important;
  }
  body[data-theme]:not(.landing-active) :where(.error,.is-error,[data-status="error"]) {color:var(--ui-danger)!important;}
  body[data-theme]:not(.landing-active) :where(.success,[data-status="success"]) {color:var(--ui-success)!important;}
  body[data-theme]:not(.landing-active) :where(.warning,[data-status="warning"]) {color:var(--ui-warning)!important;}

  /* Map imagery is geographic content; its popups/controls use the app palette. */
  body[data-theme]:not(.landing-active) :where(.leaflet-container,#rideModeMap,#rideMap,#serviceMap) {background-color:var(--ui-input)!important;}
  body[data-theme]:not(.landing-active) :where(.leaflet-popup-content-wrapper,.leaflet-popup-tip,.leaflet-control-layers,.leaflet-bar a) {
   background:var(--ui-input)!important;color:var(--ui-text)!important;border-color:var(--ui-field-edge)!important;
  }
  body[data-theme]:not(.landing-active) .leaflet-popup-content :where(p,strong,span,a) {color:var(--ui-text)!important;}
  body[data-theme]:not(.landing-active) .leaflet-control-attribution {background:var(--ui-input)!important;color:var(--ui-muted)!important;}
  body[data-theme]:not(.landing-active) .leaflet-control-attribution a {color:var(--ui-ink)!important;}
  body[data-theme]:not(.landing-active) :where(.ride-mode-gps,.ride-mode-map-status,.ride-path-map-status) {
   background:var(--ui-input)!important;color:var(--ui-ink)!important;border-color:var(--ui-field-edge)!important;
  }
 }
}
