/* DRIFTS branding: maroon accent + logo. Loaded just before preflight.css. */
.header-title { display: flex; align-items: center; gap: 8px; color: var(--ios-blue); }
.header-logo { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.phone.dark-mode .header-logo { background: #F4E9EA; border-radius: 50%; padding: 3px; }

/* The camera card is always dark: use the light maroon there so icons stay readable. */
.vision-topbar svg { stroke: #E06777 !important; }
.vision-standby-overlay button { background: #B13447 !important; }

/* Pi mode: the Raspberry Pi camera stream in the camera card */

/* Raw sensor data card */
.raw-head { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 8px; }
.raw-head b { font-size: 13px; color: var(--ios-text); }
.raw-src { font-size: 10.5px; color: var(--ios-subtext); font-weight: 600; }
.raw-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.raw-grid .tele-box { padding: 8px 4px; }
.raw-grid .tele-val { font-size: 13.5px; }
.raw-grid .tele-val.raw-warn { color: var(--ios-red); }
.raw-link { width: 100%; margin: -4px 0 12px; }

/* Safety notice */
.safety-notice { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(20, 6, 9, 0.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.safety-card { max-width: 380px; width: 100%; background: #fff; border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3); color: #1A1A1A; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.safety-logo { width: 56px; height: 56px; display: block; margin: 0 auto 6px; }
.safety-card h2 { text-align: center; font-size: 21px; color: #86252D; margin-bottom: 12px; }
.safety-card ul { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.safety-card li { font-size: 13.5px; line-height: 1.4; padding-left: 14px; position: relative; color: #3A3A3A; }
.safety-card li::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: #86252D; }
.safety-card li b { color: #1A1A1A; }
.safety-ok { width: 100%; padding: 13px; border: none; border-radius: 14px; background: #86252D; color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer; }

/* Rig mode / Car mode switch (raw sensor card) */
.rig-mode { margin: -2px 0 12px; }
.rig-seg { display: flex; border: 1px solid var(--ios-separator, #d8d0c8); border-radius: 10px; overflow: hidden; }
.rig-seg button { flex: 1; padding: 8px 0; border: 0; background: transparent; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--ios-subtext); cursor: pointer; }
.rig-seg button.on { background: var(--ios-blue); color: #fff; }
.rig-note { font-size: 11px; color: var(--ios-subtext); margin-top: 6px; }

/* Outputs card (Sensors tab): one Test Signal button per output */
.out-card { padding: 4px 14px; }
.out-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.out-row + .out-row { border-top: 1px solid rgba(60, 60, 67, 0.12); }
.out-btn { flex: 0 0 128px; width: 128px; margin: 0; padding: 9px 0; }
.out-btn.running { opacity: 0.6; pointer-events: none; }

/* Welcome greeting on Home: "Morning, Kendra." (Profile -> Profile Name) */
.home-greeting { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 4px 2px; }
.home-greeting-text { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; color: var(--ios-text); }
.home-greeting-set { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ios-blue); cursor: pointer; }
.profile-name-input { width: 46%; max-width: 180px; padding: 8px 10px; border: 1px solid rgba(60, 60, 67, 0.2);
  border-radius: 10px; font: inherit; font-size: 15px; text-align: right; color: var(--ios-text);
  background: var(--ios-card, #fff); }
.profile-name-input:focus { outline: 2px solid var(--ios-blue); outline-offset: 1px; }

/* Pi camera calibration card (Sensors): a brief look at the driver with a red / green oval */
.camcal-preview { position: relative; margin: 10px 0 6px; border-radius: 14px; overflow: hidden; background: #000;
  aspect-ratio: 4 / 3; }
.camcal-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camcal-preview img.mirrored { transform: scaleX(-1); }
.camcal-oval { position: absolute; left: 50%; top: 50%; width: 42%; height: 72%; transform: translate(-50%, -50%);
  border: 3px solid #FF3B30; border-radius: 50%; box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.28);
  transition: border-color 0.25s ease; }
.camcal-oval.ok { border-color: #34C759; }
.camcal-done { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35); }
.camcal-status { margin: 4px 2px 10px; }
.camcal-hint { font-size: 14px; font-weight: 700; color: var(--ios-text); text-align: center; margin-bottom: 8px; }
.camcal-hint.ok { color: #34C759; }
.camcal-hint.bad { color: #FF3B30; }
.camcal-track { height: 6px; border-radius: 3px; background: rgba(60, 60, 67, 0.14); overflow: hidden; }
.camcal-fill { height: 100%; width: 0; background: var(--ios-blue); transition: width 0.25s ease; }
.camcal-action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 4px; }
.camcal-action .btn-sensor-overlay { position: static; }

/* One-line camera status on Home (the camera picture only shows in Sensors) */
.cam-line { font-size: 11px; font-weight: 600; color: var(--ios-subtext); margin: -2px 0 6px; }
.cam-line.warn { color: #FF9500; }

/* Sensors: Driving Mode and Phone Camera cards */
.drive-mode-seg { margin: 12px 0 6px; }
.drive-mode-seg button { padding: 10px 0; font-size: 14px; }
.phonecam-row { margin: 10px 0 0; padding: 0; background: none; border: 0; box-shadow: none; }
.phonecam-preview canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.phonecam-err { margin: 6px 2px 0; font-size: 12px; font-weight: 600; color: #FF3B30; text-align: center; }
#btn-phonecam-preview:disabled { opacity: 0.45; cursor: default; }

/* Installed web app (https / GitHub Pages): phone only, the Pi has its own page */
.hosted-only { display: none; }
body.hosted .hosted-only { display: block; }
body.hosted .section-label.hosted-only { display: flex; }
body.hosted .pi-only { display: none !important; }
.hosted-note { font-size: 13px; line-height: 1.45; color: var(--ios-subtext); margin: 10px 2px 4px; }
.hosted-note b { color: var(--ios-text); font-weight: 700; }

/* Install DRIFTS (js/install.js): Profile row, one-time iPhone tip, steps sheet */
.install-btn { width: auto; min-width: 118px; margin: 0; padding: 8px 12px; flex-shrink: 0; }
.install-btn:disabled { opacity: 0.6; }
.inst-share { display: inline-block !important; width: 17px; height: 17px; vertical-align: -3px; color: #007AFF; margin: 0 1px; }
.inst-tip { position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 9000;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 16px;
  background: var(--ios-card, #fff); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18); max-width: 420px; margin: 0 auto; }
.inst-tip img { width: 36px; height: 36px; border-radius: 9px; }
.inst-tip-text { flex: 1; display: flex; flex-direction: column; font-size: 12.5px; color: var(--ios-subtext); line-height: 1.35; }
.inst-tip-text b { color: var(--ios-text); }
.inst-tip-text > b { font-size: 14px; }
.inst-tip-how { border: 0; border-radius: 999px; padding: 7px 13px; background: var(--ios-blue); color: #fff;
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.inst-tip-x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--ios-subtext); cursor: pointer; padding: 0 2px; }
.inst-sheet { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.45); padding: 12px; }
.inst-card { width: 100%; max-width: 420px; background: var(--ios-card, #fff); border-radius: 22px; padding: 22px 20px 16px;
  margin-bottom: env(safe-area-inset-bottom); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
.inst-logo { width: 56px; height: 56px; border-radius: 14px; display: block; margin: 0 auto 8px; }
.inst-card h2 { text-align: center; font-size: 19px; margin: 0 0 8px; color: var(--ios-text); }
.inst-lead { font-size: 14px; color: var(--ios-subtext); text-align: center; margin: 0 0 12px; line-height: 1.4; }
.inst-steps { margin: 0 0 10px; padding-left: 22px; font-size: 14.5px; line-height: 1.55; color: var(--ios-text); }
.inst-steps li { margin-bottom: 8px; }
.inst-note { font-size: 12px; color: var(--ios-subtext); margin: 0 0 12px; text-align: center; }
.inst-btn, .inst-close { width: 100%; border: 0; border-radius: 14px; padding: 13px; font: inherit; font-size: 15px;
  font-weight: 700; cursor: pointer; }
.inst-btn { background: var(--ios-blue); color: #fff; margin-bottom: 8px; }
.inst-close { background: rgba(120, 120, 128, 0.14); color: var(--ios-text); }

/* Home: Driver Camera Feed card (ToShare design); the picture only while calibrating */
.vision-viewport > [hidden] { display: none !important; }
#home-cal-img { width: 100%; max-height: 360px; object-fit: contain; display: block; background: #000; }
#home-cal-img.mirrored { transform: scaleX(-1); }
.home-cal-oval { box-shadow: none; }
.vision-card.calibrating { border-color: var(--ios-blue); box-shadow: 0 0 22px rgba(134, 37, 45, 0.28); }
.vision-state-pill.watching { background: rgba(52, 199, 89, 0.22); color: #7CE29A; }
.cam-timer-bar-fill.cal-fill { background: #34C759; transition: width 0.25s ease; }
.vision-card.calibrating .cam-timer-bar-wrap { display: block; }
#home-cal-hint { font-weight: 700; }
#home-cal-hint.ok { color: #7CE29A; }
#home-cal-hint.bad { color: #FF8A80; }

/* Home score lines (Driving / Face / Motion) with "More", and their signal panels (js/signals.js) */
.sig-row .bar-label { width: 50px; }
.sig-more { flex-shrink: 0; border: 0; background: none; padding: 2px 0 2px 4px; font: inherit; font-size: 11.5px;
  font-weight: 700; color: var(--ios-blue); cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
.sig-more span { display: inline-block; font-size: 14px; line-height: 1; transition: transform 0.2s ease; }
.sig-more.open span { transform: rotate(90deg); }
.sig-panel { margin-top: -4px; }
.sig-panel .raw-grid { margin-bottom: 8px; }
.sig-panel .tele-val { white-space: pre-line; line-height: 1.25; }
.sig-sub { font-size: 9.5px; color: var(--ios-subtext); margin-top: 2px; min-height: 11px; }
.sig-note { font-size: 11.5px; color: var(--ios-subtext); line-height: 1.4; margin: 2px 2px 4px; }
.sig-note:empty { display: none; }

/* ---------- Home while driving: glance only, as in ToShare (score, status line, camera alerts this
   trip, the Face / Driving / Motion bars, camera card, rest stop, arrived); details and the last trip hidden */
.phone.driving #last-trip-wrap,
.phone.driving #sig-details-btn,
.phone.driving .sig-tabs,
.phone.driving .sig-panel,
.phone.driving #cam-line { display: none !important; }

/* ---------- See details (one button) and its tabs */
.sig-details { margin: 8px 0 0; border: 0; background: none; padding: 0; font: inherit; font-size: 12.5px; font-weight: 700;
  color: var(--ios-blue); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.sig-details span { display: inline-block; font-size: 15px; line-height: 1; transition: transform 0.2s ease; }
.sig-details.open span { transform: rotate(90deg); }
.sig-tabs { display: flex; gap: 6px; margin: -4px 0 8px; }
.sig-tabs[hidden] { display: none; }
.sig-tabs button { flex: 1; border: 1px solid rgba(60, 60, 67, 0.16); background: var(--ios-card, #fff); border-radius: 999px;
  padding: 7px 0; font: inherit; font-size: 13px; font-weight: 700; color: var(--ios-subtext); cursor: pointer; }
.sig-tabs button.on { background: var(--ios-blue); border-color: var(--ios-blue); color: #fff; }
.sig-panel { margin-top: 0; }

/* ---------- map pins: orange face, yellow wheel (as the mockup), A / B */
.tv-pin { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 3px solid currentColor; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22); }
.tv-pin svg { width: 19px; height: 19px; }
.tv-pin.face { color: #F26B1D; }                         /* white fill, orange ring and icon */
.tv-pin.driving { color: #E2A400; }                      /* white fill, gold ring and icon */
.tv-pin.small { width: 24px; height: 24px; border-width: 2px; box-shadow: none; flex-shrink: 0; }
.tv-pin.small svg { width: 13px; height: 13px; }
.tv-endpin { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3)); }
/* OpenStreetMap, softened toward the mockup: light, gentle greens and blues */
.tv-tiles { filter: saturate(0.6) brightness(1.13) contrast(0.8); }
.tv-map .leaflet-control-attribution { font-size: 8.5px; background: rgba(255, 255, 255, 0.7); padding: 0 4px; }
.tv-nomap { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  color: var(--ios-subtext); font-size: 13px; font-weight: 600; padding: 12px; background: #EEF0F2; }
.tv-nomap small { font-weight: 500; margin-top: 4px; max-width: 260px; }

/* ---------- Home: Last trip */
.last-trip { cursor: pointer; padding: 14px; }
.lt-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lt-score { width: 46px; height: 46px; border-radius: 50%; border: 4px solid #34C759; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: 17px; flex-shrink: 0; }
.lt-head-text { flex: 1; display: flex; flex-direction: column; font-size: 12px; color: var(--ios-subtext); line-height: 1.3; }
.lt-head-text b { font-size: 14.5px; color: var(--ios-text); }
.lt-go { font-size: 12.5px; font-weight: 700; color: var(--ios-blue); white-space: nowrap; }
.lt-map { height: 130px; border-radius: 14px; overflow: hidden; background: #EEF0F2; margin-bottom: 10px; }
.lt-sub { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--ios-subtext); margin: 2px 0 6px; }

/* ---------- behavior bars (Home and Trip Analysis) */
.tv-beh { display: flex; align-items: center; gap: 11px; padding: 7px 4px; }
.tv-beh.face { background: rgba(255, 59, 48, 0.07); border-radius: 12px; padding: 8px 6px; }
.tv-beh-icon { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--ios-text); flex-shrink: 0; }
.tv-beh-icon svg { width: 25px; height: 25px; }
.tv-beh-icon.face { color: #F26B1D; }
.tv-beh-body { flex: 1; min-width: 0; }
.tv-beh-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--ios-text); }
.tv-beh-head span { font-size: 13px; font-weight: 800; color: var(--ios-text); }
.tv-beh-track { height: 7px; border-radius: 4px; background: rgba(120, 120, 128, 0.16); overflow: hidden; margin-top: 5px; }
.tv-beh-fill { height: 100%; border-radius: 4px; }
.tv-beh-note { font-size: 11px; color: var(--ios-subtext); margin-top: 3px; }
.tv-nodata { font-size: 12.5px; color: var(--ios-subtext); padding: 4px; }

/* ---------- Trip Analysis screen */
.tv-top { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.tv-back { border: 0; background: rgba(120, 120, 128, 0.14); width: 34px; height: 34px; border-radius: 50%; font-size: 24px;
  line-height: 1; color: var(--ios-text); cursor: pointer; padding: 0 0 3px; }
.tv-title { font-size: 21px; font-weight: 800; color: var(--ios-text); }
.tv-meta { font-size: 12px; color: var(--ios-subtext); }
.tv-chips { display: flex; gap: 8px; margin-bottom: 10px; }
.tv-chip { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; border-radius: 999px;
  border: 1.5px solid rgba(60, 60, 67, 0.16); background: var(--ios-card, #fff); font: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--ios-text); cursor: pointer; }
.tv-chip.on.face { border-color: #F26B1D; background: #FFF1E7; }
.tv-chip.on.driving { border-color: #F5B400; background: #FFF8DB; }
.tv-chip.on.all { border-color: var(--ios-blue); background: var(--ios-blue); color: #fff; }
.tv-map-card { padding: 0; overflow: hidden; }
.tv-map { height: 300px; background: #EEF0F2; }
.tv-summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; }
.tv-sum-row { grid-column: 1; display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ios-text); }
.tv-sum-row b { margin-left: auto; font-size: 15px; }
.tv-sum-dot { width: 22px; height: 22px; border-radius: 7px; background: rgba(120, 120, 128, 0.2); flex-shrink: 0; }
.tv-sum-scores { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 8px; padding-left: 14px;
  border-left: 1px solid rgba(60, 60, 67, 0.14); text-align: center; }
.tv-sum-scores small { display: block; font-size: 11px; color: var(--ios-subtext); font-weight: 600; }
.tv-sum-scores b { font-size: 24px; font-weight: 800; }
.tv-events { list-style: none; padding: 6px 12px; margin: 0 0 16px; }
.tv-events li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(60, 60, 67, 0.1);
  font-size: 13px; color: var(--ios-text); }
.tv-events li:last-child { border-bottom: 0; }
.tv-events li > div { flex: 1; min-width: 0; }
.tv-events li .mono { font-size: 11px; color: var(--ios-subtext); margin-left: 6px; }
.tv-ev-text { font-size: 12px; color: var(--ios-subtext); margin-top: 2px; }
.tv-ev-score { font-weight: 800; }
.tv-none { color: var(--ios-subtext); justify-content: center; }
.trip-analysis-btn { width: 100%; margin: 4px 0 10px; border: 0; border-radius: 12px; padding: 10px; background: var(--ios-blue);
  color: #fff; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.leaflet-popup-content { font-size: 12.5px; line-height: 1.4; }
