/* Cards: sensors, toggles, Bluetooth, wheel, camera, score ring, interventions */

/* iOS Inset Grouped Cards */
.card, .rest-card, .intervention-card, .trip-card {
  background: var(--ios-card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03), 0 0 0 0.5px var(--ios-sep);
  margin-bottom: 12px;
  transition: background-color 0.25s ease;
}

/* Stage 1 Sentinel Card */
.sentinel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sentinel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ios-text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}
.sentinel-title svg { stroke: var(--ios-blue) !important; }
.sensor-status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--ios-card-secondary);
  color: var(--ios-subtext);
}
.sensor-status-pill.connected {
  background: rgba(52, 199, 89, 0.15);
  color: var(--ios-green);
}
.telemetry-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
}
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  transition: filter 0.3s ease, opacity 0.3s ease;
}
.telemetry-wrap.unlinked .telemetry-grid {
  filter: blur(6px);
  opacity: 0.38;
  pointer-events: none;
  user-select: none;
}
.sensor-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  z-index: 5;
  padding: 12px;
  text-align: center;
  transition: opacity 0.3s ease;
}
.phone.dark-mode .sensor-overlay {
  background: rgba(28, 28, 30, 0.68);
}
.sensor-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.btn-sensor-overlay {
  background: var(--ios-blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 14px rgba(var(--drifts-rgb), 0.3);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-sensor-overlay:active { transform: scale(0.96); opacity: 0.9; }
.sensor-overlay-sub {
  font-size: 11px;
  color: var(--ios-subtext);
  font-weight: 500;
}
.tele-box {
  background: var(--ios-card-secondary);
  border-radius: 14px;
  padding: 11px 6px;
  text-align: center;
}
.tele-lbl {
  font-size: 10px;
  color: var(--ios-subtext);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.tele-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--ios-text);
  margin-top: 3px;
}
.tele-sub { font-size: 10px; color: var(--ios-subtext); margin-top: 1px; }

/* Native iOS Toggle Switches */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 51px !important;
  height: 31px !important;
  background: rgba(120, 120, 128, 0.24);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  outline: none;
  border: none;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
input[type="checkbox"]:checked {
  background: var(--ios-green);
}
input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

/* Bluetooth Output Card */
.ble-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 0.5px solid var(--ios-sep);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ios-text);
}
.ble-toggle-row:first-of-type { border-top: none; }
.ble-toggle-row small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ios-subtext);
  margin-top: 2px;
  line-height: 1.3;
}
.ble-actions { display: flex; gap: 8px; margin-top: 12px; }
.ble-btn {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: var(--ios-card-secondary);
  color: var(--ios-blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.ble-btn:active { transform: scale(0.97); }
.ble-btn.primary {
  background: var(--ios-blue);
  color: #fff;
}
.ble-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ble-log {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 0.5px solid var(--ios-sep);
  font-size: 11px;
  color: var(--ios-subtext);
  line-height: 1.6;
}
.ble-log b { color: var(--ios-text); font-weight: 600; }

/* Stage 1b: G29 Wheel Card */
.wheel-row { display: flex; gap: 14px; align-items: center; }
.wheel-dial { width: 78px; height: 78px; flex-shrink: 0; }
.wheel-dial svg { width: 100%; height: 100%; display: block; }
#g29-wheel-graphic { transform-origin: 0 0; }
#g29-wheel-graphic circle, #g29-wheel-graphic path { stroke: var(--ios-blue) !important; }
.wheel-readouts { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.wheel-angle { font-size: 19px; font-weight: 700; color: var(--ios-text); }
.pedal-row { display: flex; align-items: center; gap: 8px; }
.pedal-lbl { font-size: 10px; font-weight: 600; color: var(--ios-subtext); width: 46px; text-transform: uppercase; }
.pedal-track { flex: 1; height: 6px; background: var(--ios-card-secondary); border-radius: 99px; overflow: hidden; }
.pedal-fill { height: 100%; width: 0%; border-radius: 99px; transition: width 0.05s linear; }
.pedal-pct { font-size: 10.5px; width: 32px; text-align: right; color: var(--ios-subtext); }
.wheel-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }

/* Stage 2 FaceMesh Gate Card (Apple Continuity Camera Style) */
.vision-card {
  background: #1C1C1E;
  color: #FFFFFF;
  border-radius: 22px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.vision-card.triggered {
  border-color: var(--ios-red);
  box-shadow: 0 0 25px rgba(255, 59, 48, 0.35);
}
.vision-topbar {
  padding: 14px 16px;
  background: rgba(44, 44, 46, 0.65);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.vision-topbar svg { stroke: var(--ios-blue) !important; }
.vision-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dropdown-arrow {
  width: 18px;
  height: 18px;
  color: #8E8E93;
  stroke: #8E8E93 !important;
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.vision-card.collapsed .dropdown-arrow {
  transform: rotate(-90deg);
}
.vision-collapsible { display: block; }
.vision-card.collapsed .vision-collapsible { display: none; }
.cam-timer-bar-wrap {
  width: 100%;
  padding: 10px 16px 12px;
  background: #141416;
  border-top: 0.5px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  display: none;
}
.vision-card.triggered .cam-timer-bar-wrap { display: block; }
.cam-timer-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #AEAEB2;
  margin-bottom: 6px;
}
.cam-timer-track {
  width: 100%;
  height: 6px;
  background: #2C2C2E;
  border-radius: 99px;
  overflow: hidden;
}
.cam-timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #30D158 0%, #FF9F0A 55%, #FF453A 100%);
  transition: width 0.1s linear;
}
.vision-state-pill {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(142, 142, 147, 0.24);
  color: #D1D1D6;
  letter-spacing: 0.3px;
}
.vision-state-pill.active {
  background: var(--ios-red);
  color: #fff;
}
.vision-viewport {
  position: relative;
  width: 100%;
  min-height: 220px;
  max-height: 360px;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.vision-viewport video { display: none; }
.vision-viewport canvas {
  width: 100%;
  height: auto;
  max-height: 360px;
  display: block;
  object-fit: contain;
}
.vision-standby-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 20, 0.86);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  z-index: 4;
  transition: opacity 0.3s ease;
}
.vision-standby-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.standby-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(var(--drifts-rgb), 0.18);
  color: #E06777;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.vision-hud-bottom {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
}
.hud-chip {
  background: rgba(28, 28, 30, 0.75);
  backdrop-filter: blur(10px);
  border: 0.5px solid rgba(255,255,255,0.16);
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 10.5px;
  color: #F2F2F7;
}

/* Apple Health / Fitness Ring Score Card */
.score-card {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 18px;
}
.gauge-wrap { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.gauge-wrap svg { transform: rotate(-90deg); width: 92px; height: 92px; }
.gauge-bg { fill: none; stroke: var(--ios-card-secondary); stroke-width: 9; }
.gauge-fg {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.32, 0.72, 0, 1), stroke 0.3s ease;
}
.gauge-wrap.idle .gauge-fg { stroke: var(--ios-tertiary) !important; }
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge-score {
  font-size: 26px;
  font-weight: 800;
  color: var(--ios-green);
  line-height: 1;
  letter-spacing: -1px;
}
.gauge-max { font-size: 10px; font-weight: 600; color: var(--ios-subtext); margin-top: 2px; }
.score-detail { flex: 1; min-width: 0; }
.score-status {
  font-size: 14px;
  font-weight: 700;
  color: var(--ios-green);
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.ufas-alert-line {
  font-size: 11px;
  font-weight: 600;
  color: var(--ios-subtext);
  margin: -4px 0 8px;
}
.bar-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.bar-label { font-size: 12px; color: var(--ios-subtext); width: 48px; font-weight: 500; }
.bar-track {
  flex: 1;
  height: 6px;
  background: var(--ios-card-secondary);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--ios-green);
  transition: width 0.3s ease;
}

/* Interventions */
.intervention-row { display: flex; align-items: center; justify-content: space-between; }
.intervention-left { display: flex; align-items: center; gap: 12px; }
.intervention-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(var(--drifts-rgb), 0.12);
  color: var(--ios-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.intervention-icon svg { width: 19px; height: 19px; }
.intervention-name { font-size: 14px; font-weight: 600; color: var(--ios-text); }
.intervention-sub { font-size: 11.5px; color: var(--ios-subtext); margin-top: 1px; }
.status-pill {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.status-pill.active { background: var(--ios-blue); color: #FFFFFF; }
.status-pill.standby { background: var(--ios-card-secondary); color: var(--ios-subtext); }

.audio-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0.5px solid var(--ios-sep);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.audio-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--ios-subtext);
  font-weight: 500;
}
.audio-ctrl-row input[type="range"] {
  flex: 1;
  accent-color: var(--ios-blue);
  height: 4px;
  cursor: pointer;
}
