/* ═══════════════════════════════════════════════════════════
   Qyper — Web Scanner Stylesheet
   Aligned with Flutter app_theme.dart & UI widgets
   Colors, radii, shadows, typography all match the mobile app
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ─── Flutter AppTheme.lightColorScheme ─── */
  --primary: #4F46E5;
  /* Dominant color 1: Indigo 600 */
  --primary-dark: #4338CA;
  --primary-light: #EEF2FF;
  --primary-surface: rgba(79, 70, 229, 0.10);
  --primary-surface-20: rgba(79, 70, 229, 0.20);
  --on-primary: #FFFFFF;
  --secondary: #0D9488;
  /* Dominant color 2: Teal 600 */
  --secondary-light: #14B8A6;
  --secondary-surface: rgba(13, 148, 136, 0.10);
  --secondary-surface-20: rgba(13, 148, 136, 0.20);
  --on-secondary: #FFFFFF;
  --error: #EF4444;
  --on-error: #FFFFFF;
  --background: #FFFFFF;
  --on-background: #0F172A;
  --surface: #F8FAFC;
  --on-surface: #0F172A;
  --warning: #F59E0B;

  /* ─── Item (Lost & Found) Theming — Teal / Emerald ─── */
  --item-primary: #0D9488;
  --item-primary-dark: #0F766E;
  --item-primary-light: #F0FDFA;
  --item-primary-surface: rgba(13, 148, 136, 0.12);
  --item-primary-surface-20: rgba(13, 148, 136, 0.22);
  --item-secondary: #14B8A6;

  /* ─── Derived / Utility (Slate) ─── */
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --border-input: #CBD5E1;
  --hint: rgba(15, 23, 42, 0.40);
  --focus: rgba(79, 70, 229, 0.12);
  --unselected: #94A3B8;

  /* ─── Radii (from AppRatios) ─── */
  --radius-xl: 30px;
  --radius-l: 25px;
  --radius-m: 20px;
  --radius-s: 15px;
  --radius-xs: 10px;

  /* ─── Spacing (from AppRatios) ─── */
  --padding-l: 20px;
  --padding-m: 10px;
  --padding-s: 5px;
  --height-xl: 20px;
  --height-l: 15px;
  --height-m: 10px;
  --height-s: 5px;

  /* ─── Shadows ─── */
  --shadow: 0 2px 16px rgba(63, 81, 181, 0.08);
  --shadow-lg: 0 8px 32px rgba(63, 81, 181, 0.12);
  --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.05);

  /* ─── Typography ─── */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --title-size: 21px;
  --content-size: 16px;
  --content-small-size: 14.5px;
  --button-size: 16.5px;
}

/* ═══════════════════════════════════════════════════════════
   Reset
   ═══════════════════════════════════════════════════════════ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════════
   Theme Toggle Button
   ═══════════════════════════════════════════════════════════ */

.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--background);
  color: var(--text-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  color: var(--primary);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Show sun in dark mode, moon in light mode */
.icon-sun { display: none; }
.icon-moon { display: block; }

html.dark .icon-sun { display: block; }
html.dark .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .icon-sun { display: block; }
  html:not(.light) .icon-moon { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   Language Toggle Button
   ═══════════════════════════════════════════════════════════ */

.lang-toggle {
  position: fixed;
  top: 12px;
  right: 58px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--background);
  color: var(--text-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s, transform 0.3s, box-shadow 0.3s;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.lang-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  color: var(--primary);
}

.lang-toggle:active {
  transform: scale(0.95);
}

html.dark .lang-toggle {
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .lang-toggle {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
  }
}

/* ═══════════════════════════════════════════════════════════
   Cooldown Timer
   ═══════════════════════════════════════════════════════════ */

.cooldown-timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
  animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 16px;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 440px;
  padding-top: 50px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 30px);
}

/* ═══════════════════════════════════════════════════════════
   Screens (view switching)
   ═══════════════════════════════════════════════════════════ */

/* ─── App Header Branding ─── */
.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.app-brand {
  font-size: 26px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.screen {
  display: none !important;
  animation: fadeIn 0.3s ease-out;
}

.screen.active {
  display: block !important;
}

/* Zero-flash instant paint when an ongoing discussion is detected on page load/reload */
html.has-active-discussion #screen-loading {
  display: none !important;
}

html.has-active-discussion #screen-chat.active {
  display: block !important;
  animation: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   Card — matches AppCard widget
   background: white, borderRadius: S (15), shadow
   ═══════════════════════════════════════════════════════════ */

.card {
  position: relative;
  background: var(--background);
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
  padding: 26px 18px;
  text-align: center;
  margin-bottom: var(--height-l);
  width: 100%;
  overflow: hidden;
}

/* Card top accent ribbon — perfectly curves with 20px border-radius */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  border-radius: 20px 20px 0 0;
  z-index: 2;
}

/* Title — AppText.TitleText: 20px bold, primary (indigo) */
.card h2 {
  font-size: var(--title-size);
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
}

/* Section label — uppercase small */
.card h3 {
  font-size: var(--content-small-size);
  font-weight: 600;
  margin-bottom: 12px;
  text-align: left;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card p {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: var(--content-small-size);
}

/* Vehicle name badge — purple secondary chip */
.card .subtitle {
  font-size: var(--content-size);
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: var(--height-xl);
  display: inline-block;
  padding: 4px 16px;
  background: var(--secondary-surface);
  border-radius: var(--radius-xl);
}

.card-title {
  margin-bottom: 4px !important;
}

.card-header-icon {
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════
   Icon Circles
   ═══════════════════════════════════════════════════════════ */

.icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.primary-circle {
  background: var(--primary-surface);
  color: var(--primary);
}

.accent-circle {
  background: var(--secondary-surface);
  color: var(--secondary);
}

.error-circle {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
}

.warning-circle {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.timeout-circle {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

/* ═══════════════════════════════════════════════════════════
   Card variants — top accent borders
   ═══════════════════════════════════════════════════════════ */

/* Card top accent ribbons (respects 20px rounded corners) */
#screen-send-message .card::before,
#screen-loading .card::before,
#screen-waiting .card::before {
  background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
}

#screen-item-found .card::before {
  background: linear-gradient(90deg, var(--item-primary) 0%, var(--item-secondary) 100%);
}

.error-card::before {
  background: var(--error) !important;
}

.warning-card::before {
  background: var(--warning) !important;
}

.maintenance-card::before {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%) !important;
}

/* ═══════════════════════════════════════════════════════════
   Spinner — matches LoadingIndicator: secondary color,
   primary.withOpacity(0.1) background, strokeWidth 3
   ═══════════════════════════════════════════════════════════ */

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary-surface);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading-text {
  font-size: var(--content-small-size);
  color: var(--secondary);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════════════════════════════════════
   Buttons — matches AppTextButton
   borderRadius: XL (30), elevation 1, full-width
   Main: primary bg, white text
   Secondary: white bg, primary text, primary border
   ═══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--button-size);
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  letter-spacing: 0.3px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Main button — primary bg with purple→coral gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: var(--on-primary);
  box-shadow: 0 4px 12px rgba(77, 31, 124, 0.30);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--secondary-light) 0%, var(--primary-dark) 100%);
  box-shadow: 0 6px 16px rgba(77, 31, 124, 0.40);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary button — outline style for retry actions */
.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--primary-surface);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
}

/* Retry button spacing */
.retry-btn {
  margin-top: 16px;
  width: auto;
  padding: 10px 24px;
}

/* Chat send cooldown animation */
.btn-send.cooldown {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Error button */
.btn-error {
  background: var(--error);
  color: var(--on-error);
}

.btn-icon {
  flex-shrink: 0;
}

.btn-text {
  /* inline with icon */
}

/* ═══════════════════════════════════════════════════════════
   Predefined Messages — matches _MessageTile widget
   border: 1px, borderRadius: S (15), row layout
   ═══════════════════════════════════════════════════════════ */

.predefined-section {
  margin-bottom: var(--height-xl);
  text-align: left;
}

.predefined-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.predefined-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  min-height: 52px;
  background: var(--background);
  border: 1.5px solid var(--border-input);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 15.5px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--on-surface);
  line-height: 1.35;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.predefined-btn:hover:not(:disabled) {
  border-color: var(--secondary);
  background: var(--secondary-surface);
  transform: translateX(4px);
}

.predefined-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.predefined-text {
  flex: 1;
}

.predefined-btn .send-icon {
  color: var(--secondary);
  margin-left: 12px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.predefined-btn:hover .send-icon {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   Owner Default / Auto-Message Card
   Prominently displays the vehicle owner's default message
   ═══════════════════════════════════════════════════════════ */

.owner-message-card {
  margin: 16px 0 20px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary-surface) 0%, var(--secondary-surface) 100%);
  border: 1.5px solid rgba(79, 70, 229, 0.22);
  border-radius: var(--radius-m);
  text-align: left;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.08);
  animation: fadeIn 0.3s ease-out;
}

.owner-message-card.hidden {
  display: none !important;
}

.owner-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--primary);
}

.owner-message-header svg {
  color: var(--secondary);
  flex-shrink: 0;
}

.owner-message-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
}

.owner-message-body {
  padding-left: 4px;
}

.owner-message-text {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--on-surface);
  font-style: italic;
  margin: 0;
}

html.dark .owner-message-card {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.12) 0%, rgba(45, 212, 191, 0.08) 100%);
  border-color: rgba(129, 140, 248, 0.30);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

html.dark .owner-message-label {
  color: #818CF8;
}

html.dark .owner-message-text {
  color: #E2E8F0;
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .owner-message-card {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.12) 0%, rgba(45, 212, 191, 0.08) 100%);
    border-color: rgba(129, 140, 248, 0.30);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  }

  html:not(.light) .owner-message-label {
    color: #818CF8;
  }

  html:not(.light) .owner-message-text {
    color: #E2E8F0;
  }
}

/* ═══════════════════════════════════════════════════════════
   Unavailable Owner Auto-Message Variant
   ═══════════════════════════════════════════════════════════ */

.owner-message-card.unavailable {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(220, 38, 38, 0.05) 100%);
  border: 1.5px solid rgba(239, 68, 68, 0.35);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.12);
}

.owner-message-card.unavailable .owner-message-header {
  color: #EF4444;
}

.owner-message-card.unavailable .owner-message-label {
  color: #EF4444;
}

.owner-message-card.unavailable .owner-message-text {
  color: var(--on-surface);
  font-weight: 600;
}

html.dark .owner-message-card.unavailable {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.20) 0%, rgba(185, 28, 28, 0.10) 100%);
  border-color: rgba(239, 68, 68, 0.45);
}

html.dark .owner-message-card.unavailable .owner-message-text {
  color: #FCA5A5;
}

/* ═══════════════════════════════════════════════════════════
   Retry & Cooldown Card on Send Message Screen
   ═══════════════════════════════════════════════════════════ */

.retry-cooldown-card {
  margin: 14px 0 16px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(63, 81, 181, 0.06) 0%, rgba(77, 31, 124, 0.04) 100%);
  border: 1.5px solid rgba(63, 81, 181, 0.20);
  border-radius: var(--radius-m);
  text-align: left;
  animation: fadeIn 0.3s ease-out;
}

html.dark .retry-cooldown-card {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.12) 0%, rgba(45, 212, 191, 0.08) 100%);
  border: 1.5px solid rgba(129, 140, 248, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.retry-cooldown-card.hidden {
  display: none !important;
}

.retry-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.retry-badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(63, 81, 181, 0.10);
  border: 1px solid rgba(63, 81, 181, 0.25);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

html.dark .retry-badge-pill {
  background: rgba(129, 140, 248, 0.15);
  border: 1px solid rgba(129, 140, 248, 0.40);
  color: #818CF8;
}

.retry-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: monospace;
  color: #DC2626;
}

html.dark .retry-timer-pill {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #F87171;
}

.retry-timer-pill.hidden {
  display: none !important;
}

.retry-notice-desc {
  font-size: 13px;
  line-height: 1.45;
  color: var(--on-surface);
  margin: 0;
}

html.dark .retry-notice-desc {
  color: rgba(255, 255, 255, 0.85);
}

/* ═══════════════════════════════════════════════════════════
   Nickname & Custom Message Input
   Matches Flutter TextField styling
   ═══════════════════════════════════════════════════════════ */

.nickname-section {
  text-align: left;
  margin-bottom: var(--height-xl);
}

.nickname-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-s);
  font-size: var(--content-small-size);
  font-family: var(--font);
  color: var(--text);
  background: var(--background);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.nickname-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-surface);
}

.nickname-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.8;
}

.custom-message-section {
  text-align: left;
}

.section-label {
  display: block;
  font-size: var(--content-small-size);
  font-weight: 700;
  margin-bottom: var(--padding-m);
  color: var(--text);
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-s);
  font-size: var(--content-small-size);
  font-family: var(--font);
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
  background: var(--background);
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-surface);
}

textarea::placeholder {
  color: var(--hint);
}

.char-counter {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════
   Countdown — matches alert_bottom_sheet timer
   error.withOpacity(0.1), borderRadius: M (20), tabular-nums
   ═══════════════════════════════════════════════════════════ */

.countdown-container {
  margin: 28px 0 var(--height-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.countdown-ring-wrapper {
  position: relative;
  width: 130px;
  height: 130px;
}

.countdown-ring {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border-input);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--secondary);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.countdown-ring.urgent .ring-progress {
  stroke: var(--error);
}

.countdown-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Timer text — matches alert_bottom_sheet: bold, tabular */
.countdown {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface);
  letter-spacing: 1px;
}

.countdown.urgent {
  color: var(--error);
}

.countdown-label {
  font-size: var(--content-small-size);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Status Dot ─── */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.connecting {
  background: var(--warning);
  animation: pulse-amber 1.2s ease-in-out infinite;
}

.status-dot.ringing,
.status-dot.acknowledged {
  background: var(--secondary);
  animation: pulse-green 1.2s ease-in-out infinite;
}

.countdown.connecting {
  letter-spacing: 4px;
  animation: pulse 1.5s ease-in-out infinite;
  color: var(--secondary);
}

@keyframes pulse-amber {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

@keyframes pulse-green {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(1.3);
  }
}

/* ═══════════════════════════════════════════════════════════
   Sent Message Preview
   ═══════════════════════════════════════════════════════════ */

.sent-message-preview {
  margin: 16px 0 4px;
}

.sent-message-bubble {
  display: inline-block;
  max-width: 85%;
  padding: var(--padding-m) 16px;
  background: var(--secondary-surface);
  border-radius: var(--radius-m) var(--radius-m) 4px var(--radius-m);
  text-align: left;
  font-size: 13px;
  color: var(--secondary);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   Response Area
   ═══════════════════════════════════════════════════════════ */

.response-area {
  margin-top: var(--height-xl);
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  animation: fadeIn 0.3s ease-out;
}

.response-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--secondary);
}

.response-header strong {
  font-size: var(--content-small-size);
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   Chat — matches chat_screen.dart BottomSheet layout
   Header: primary bg, white text, S radius top
   Messages: surface bg
   Bubbles: owner = primary bg; scanner = 8% opacity
   ═══════════════════════════════════════════════════════════ */

.chat-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
  border-radius: var(--radius-s);
}

/* Header — purple-to-coral gradient with avatar and vehicle badge */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--padding-l);
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: #FFFFFF;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  color: #FFFFFF;
  flex-shrink: 0;
}

.chat-header-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.chat-title {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #FFFFFF !important;
  line-height: 1.2;
  margin: 0 !important;
}

.chat-vehicle-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  margin-top: 2px;
}

/* ─── Live Status / Countdown Banner ─── */
.chat-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--primary-surface);
  border-bottom: 1px solid rgba(79, 70, 229, 0.12);
  font-size: 13px;
  color: var(--text);
  transition: all 0.3s ease;
}

html.dark .chat-status-banner {
  background: rgba(255, 255, 255, 0.04);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  animation: pulse-ring 1.8s infinite;
  flex-shrink: 0;
}

.status-pulse-dot.online,
.status-pulse-dot.active,
.chat-status-banner.online .status-pulse-dot {
  background: var(--secondary);
  box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.6);
  animation: pulse-ring-green 1.8s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-ring-green {
  0% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(13, 148, 136, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

.chat-status-text {
  flex: 1;
  font-weight: 500;
  text-align: left;
}

.chat-status-timer {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  font-variant-numeric: tabular-nums;
}

/* ─── Messages area ─── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 250px;
  max-height: 55vh;
  padding: 16px var(--padding-l);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--background);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* ─── WhatsApp Style Date Separator Pill ─── */
.chat-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 8px 0;
  width: 100%;
}

.chat-date-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
  letter-spacing: 0.2px;
  user-select: none;
}

html.dark .chat-date-pill {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* ─── Message Bubbles — Modern Cards ─── */
.message-bubble {
  position: relative;
  padding: 10px 14px;
  max-width: 78%;
  word-wrap: break-word;
  font-size: 14.5px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform 0.15s ease;
}

/* Scanner (outgoing message from this web user) — Indigo */
.message-bubble.scanner,
.message-bubble.other {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #FFFFFF;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
  border: none;
  text-align: left;
}

/* Owner (incoming message from vehicle owner) — Clean card */
.message-bubble.owner {
  align-self: flex-start;
  background: #FFFFFF;
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  text-align: left;
}

.message-content {
  font-size: 14.5px;
  line-height: 1.45;
}

.message-content.message-location-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.msg-location-icon {
  flex-shrink: 0;
  color: #2dd4bf;
}

.message-bubble.owner .msg-location-icon {
  color: #0d9488;
}

.message-system {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90%;
  margin: 6px 0;
  padding: 9px 14px;
  border-radius: 16px;
  border: 1.2px solid color-mix(in srgb, var(--sys-accent) 40%, transparent);
  background: color-mix(in srgb, var(--sys-accent) 12%, transparent);
  --sys-accent: #818cf8;
}
.message-system.retrigger { --sys-accent: #f59e0b; }
.message-system.location { --sys-accent: #38bdf8; }
.message-system.emergency { --sys-accent: #ef4444; }
.message-system .sys-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--sys-accent);
  background: color-mix(in srgb, var(--sys-accent) 22%, transparent);
}
.message-system .sys-body { display: flex; flex-direction: column; min-width: 0; }
.message-system .sys-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--sys-accent);
}
.message-system .sys-text {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.message-system .message-time { margin-left: 4px; font-size: 10px; opacity: 0.6; }

.message-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: flex-end;
  margin-top: 1px;
}

.message-time {
  font-size: 11px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.message-bubble.scanner .message-time,
.message-bubble.other .message-time {
  color: rgba(255, 255, 255, 0.85);
}

.message-bubble.owner .message-time {
  color: var(--text-muted);
}

.message-status-icon {
  display: inline-flex;
  align-items: center;
  opacity: 0.8;
  color: #FFFFFF;
}

/* ─── Chat Input — Modern Floating Pill Bar ─── */
.chat-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 16px 16px 16px;
  background: transparent;
  border: none;
  border-top: none;
}

.chat-input-area textarea,
#chat-input {
  flex: 1;
  border-radius: 22px;
  padding: 10px 16px;
  border: 1.5px solid var(--border-input);
  resize: none;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  height: 42px;
  min-height: 42px;
  max-height: 100px;
  background: var(--background);
  color: var(--text);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-area textarea::-webkit-scrollbar,
#chat-input::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.chat-input-area textarea:focus,
#chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-surface);
}

.btn-send {
  width: 42px !important;
  height: 42px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35) !important;
  border: none !important;
  cursor: pointer !important;
  transition: transform 0.2s, box-shadow 0.2s !important;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.06) !important;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45) !important;
}

.btn-send .btn-text {
  display: none;
}

/* ─── Closed Banner ─── */

.closed-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(36, 30, 48, 0.08);
  color: var(--on-surface);
  padding: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.closed-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.closed-banner svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.closed-text {
  opacity: 0.8;
  line-height: 1.4;
}

.leave-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  background: var(--surface);
  color: var(--on-surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.leave-chat-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.closed-banner.resolved {
  background: rgba(77, 31, 124, 0.08);
  color: var(--on-surface);
  border-top: 1px solid rgba(77, 31, 124, 0.20);
}

.closed-banner.resolved svg {
  color: var(--primary);
  opacity: 1;
}

.closed-banner.resolved .closed-text {
  color: var(--on-surface);
  opacity: 1;
  font-weight: 600;
}

html.dark .closed-banner.resolved {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

html.dark .closed-banner.resolved svg,
html.dark .closed-banner.resolved .closed-text {
  color: #FFFFFF;
  opacity: 1;
}

html.dark .leave-chat-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* ═══════════════════════════════════════════════════════════
   Misc / Utility
   ═══════════════════════════════════════════════════════════ */

.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 12px;
}

.scan-desc,
.timeout-desc {
  margin-bottom: var(--padding-m);
}

.waiting-subtitle {
  color: var(--secondary) !important;
  font-weight: 500;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════════════════════════════════
   Responsive — Mobile Devices (fill width, avoid narrow centering)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  body {
    padding: 14px 14px;
  }

  #app {
    width: 100%;
    max-width: 440px;
    padding-top: 50px;
  }

  .card {
    padding: 24px 16px;
    border-radius: 18px;
  }

  .predefined-btn {
    padding: 13px 16px;
    min-height: 52px;
    font-size: 15px;
    border-radius: 14px;
  }

  .theme-toggle {
    top: 10px;
    right: 10px;
  }

  .lang-toggle {
    top: 10px;
    right: 56px;
  }

  .test-mode-bar {
    top: 10px;
    left: 10px;
  }
}

@media (max-width: 360px) {
  body {
    padding: 10px 10px;
  }

  #app {
    padding-top: 46px;
  }

  .card {
    padding: 18px 12px;
    border-radius: 14px;
  }

  .predefined-btn {
    padding: 11px 12px;
    font-size: 14px;
    min-height: 46px;
  }

  .countdown {
    font-size: 28px;
  }

  .countdown-ring-wrapper {
    width: 110px;
    height: 110px;
  }

  .countdown-ring {
    width: 110px;
    height: 110px;
  }
}

/* ═══════════════════════════════════════════════════════════
   Dark Mode — matches Flutter AppTheme.darkColorScheme
   primary: #818CF8, secondary: #2DD4BF
   background: #1E293B, surface: #0F172A
   onSurface: #F8FAFC, onPrimary: #0F172A
   ═══════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --primary: #818CF8;
    --primary-dark: #6366F1;
    --primary-light: #312E81;
    --primary-surface: rgba(129, 140, 248, 0.12);
    --primary-surface-20: rgba(129, 140, 248, 0.22);
    --on-primary: #0F172A;
    --secondary: #2DD4BF;
    --secondary-light: #5EEAD4;
    --secondary-surface: rgba(45, 212, 191, 0.12);
    --secondary-surface-20: rgba(45, 212, 191, 0.22);
    --on-secondary: #0F172A;
    --error: #EF4444;
    --on-error: #FFFFFF;
    --background: #1E293B;
    --on-background: rgba(255, 255, 255, 0.05);
    --surface: #0F172A;
    --on-surface: #E2E8F0;

    --item-primary: #2DD4BF;
    --item-primary-dark: #14B8A6;
    --item-primary-light: #134E4A;
    --item-primary-surface: rgba(45, 212, 191, 0.16);
    --item-primary-surface-20: rgba(45, 212, 191, 0.25);
    --item-secondary: #5EEAD4;

    --text: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: #334155;
    --border-input: #334155;
    --hint: rgba(248, 250, 252, 0.40);
    --focus: rgba(129, 140, 248, 0.15);
    --unselected: #64748B;

    --shadow: 0 2px 16px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.40);
    --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.15);
  }

  html:not(.light) .message-bubble.owner {
    background: linear-gradient(135deg, #818CF8 0%, #6366F1 100%);
    color: #0F172A;
    font-weight: 600;
    border: none;
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.25);
  }

  html:not(.light) .message-bubble.owner .message-time {
    color: rgba(15, 23, 42, 0.70);
  }

  html:not(.light) .message-bubble.scanner,
  html:not(.light) .message-bubble.other {
    background: var(--surface);
    color: var(--on-surface);
    border: 1px solid var(--border-input);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  }

  html:not(.light) .message-bubble.scanner .message-time,
  html:not(.light) .message-bubble.other .message-time {
    color: rgba(255, 255, 255, 0.70);
  }

  html:not(.light) .predefined-btn {
    background: var(--surface);
    border-color: var(--border-input);
    color: var(--text);
  }

  html:not(.light) .predefined-btn:hover:not(:disabled) {
    background: var(--secondary-surface);
    border-color: var(--secondary);
  }

  html:not(.light) textarea,
  html:not(.light) .nickname-input {
    background: var(--background);
    color: var(--text);
    border-color: var(--border-input);
  }

  html:not(.light) .chat-messages {
    background: var(--background);
  }

  html:not(.light) .chat-input-area {
    background: transparent;
    border: none;
    border-top: none;
  }

  html:not(.light) .chat-input-area textarea {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }

  html:not(.light) .chat-header {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    color: #FFFFFF;
  }

  html:not(.light) .chat-title {
    color: #FFFFFF !important;
  }

  html:not(.light) .closed-banner {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }

  html:not(.light) .sent-message-bubble {
    background: var(--secondary-surface);
    color: var(--secondary-light);
  }

  html:not(.light) body {
    background: var(--background);
  }

  html:not(.light) .app-brand {
    color: rgba(255, 255, 255, 0.9);
  }

  html:not(.light) #screen-send-message .card::before,
  html:not(.light) #screen-loading .card::before,
  html:not(.light) #screen-waiting .card::before {
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  }

  html:not(.light) #screen-item-found .card::before {
    background: linear-gradient(90deg, var(--item-primary) 0%, var(--item-secondary) 100%);
  }

  html:not(.light) .loading-text {
    color: var(--secondary-light);
  }

  html:not(.light) .spinner {
    border-color: var(--primary-surface);
    border-top-color: var(--primary);
  }

  html:not(.light) .waiting-subtitle {
    color: var(--secondary-light) !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Dark Mode — Manual toggle (html.dark class)
   Duplicates @media rules so the toggle button can override
   system preferences via a CSS class on <html>
   ═══════════════════════════════════════════════════════════ */

html.dark {
  --primary: #818CF8;
  --primary-dark: #6366F1;
  --primary-light: #312E81;
  --primary-surface: rgba(129, 140, 248, 0.12);
  --primary-surface-20: rgba(129, 140, 248, 0.22);
  --on-primary: #0F172A;
  --secondary: #2DD4BF;
  --secondary-light: #5EEAD4;
  --secondary-surface: rgba(45, 212, 191, 0.12);
  --secondary-surface-20: rgba(45, 212, 191, 0.22);
  --on-secondary: #0F172A;
  --error: #EF4444;
  --on-error: #FFFFFF;
  --background: #1E293B;
  --on-background: rgba(255, 255, 255, 0.05);
  --surface: #0F172A;
  --on-surface: #E2E8F0;

  --item-primary: #2DD4BF;
  --item-primary-dark: #14B8A6;
  --item-primary-light: #134E4A;
  --item-primary-surface: rgba(45, 212, 191, 0.16);
  --item-primary-surface-20: rgba(45, 212, 191, 0.25);
  --item-secondary: #5EEAD4;

  --text: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: #334155;
  --border-input: #334155;
  --hint: rgba(248, 250, 252, 0.40);
  --focus: rgba(129, 140, 248, 0.15);
  --unselected: #64748B;

  --shadow: 0 2px 16px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.40);
  --shadow-soft: 0 1px 4px rgba(0, 0, 0, 0.15);
}

html.dark .message-bubble.owner {
  background: linear-gradient(135deg, #818CF8 0%, #6366F1 100%);
  color: #0F172A;
  font-weight: 600;
  border: none;
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.25);
}

html.dark .message-bubble.owner .message-time {
  color: rgba(15, 23, 42, 0.70);
}

html.dark .message-bubble.scanner,
html.dark .message-bubble.other {
  background: var(--surface);
  color: var(--on-surface);
  border: 1px solid var(--border-input);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

html.dark .message-bubble.scanner .message-time,
html.dark .message-bubble.other .message-time {
  color: rgba(255, 255, 255, 0.70);
}

html.dark .predefined-btn {
  background: var(--surface);
  border-color: var(--border-input);
  color: var(--text);
}

html.dark .predefined-btn:hover:not(:disabled) {
  background: var(--secondary-surface);
  border-color: var(--secondary);
}

html.dark textarea,
html.dark .nickname-input {
  background: var(--background);
  color: var(--text);
  border-color: var(--border-input);
}

html.dark .chat-messages {
  background: var(--background);
}

html.dark .chat-input-area {
  background: transparent;
  border: none;
  border-top: none;
}

html.dark .chat-input-area textarea {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

html.dark .chat-header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: #FFFFFF;
}

html.dark .chat-title {
  color: #FFFFFF !important;
}

html.dark .closed-banner {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

html.dark .sent-message-bubble {
  background: var(--secondary-surface);
  color: var(--secondary-light);
}

html.dark body {
  background: var(--background);
}

html.dark .app-brand {
  color: rgba(255, 255, 255, 0.9);
}

html.dark #screen-send-message .card::before,
html.dark #screen-loading .card::before,
html.dark #screen-waiting .card::before {
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
}

html.dark #screen-item-found .card::before {
  background: linear-gradient(90deg, var(--item-primary) 0%, var(--item-secondary) 100%);
}

html.dark .loading-text {
  color: var(--secondary-light);
}

html.dark .spinner {
  border-color: var(--primary-surface);
  border-top-color: var(--primary);
}

html.dark .waiting-subtitle {
  color: var(--secondary-light) !important;
}

html.dark .theme-toggle {
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
}

/* ═══════════════════════════════════════════════════════════
   Anti-Burst Banner & Progressive Captcha Card
   ═══════════════════════════════════════════════════════════ */

.anti-burst-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--border-radius-m, 12px);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.anti-burst-banner svg {
  flex-shrink: 0;
  stroke: var(--error);
}

.captcha-card {
  background: rgba(77, 31, 124, 0.08);
  border: 1px solid rgba(77, 31, 124, 0.25);
  border-radius: var(--border-radius-m, 14px);
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.captcha-card.shake {
  animation: captchaShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.35);
}

@keyframes captchaShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

html.dark .captcha-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

.captcha-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

html.dark .captcha-header {
  color: var(--primary);
}

.captcha-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.slider-captcha-track {
  position: relative;
  height: 48px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-input, rgba(0, 0, 0, 0.12));
  border-radius: 24px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.dark .slider-captcha-track {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.slider-captcha-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  opacity: 0.25;
  transition: width 0.05s ease;
}

.slider-captcha-handle {
  position: absolute;
  left: 4px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 2;
  transition: left 0.05s ease, background 0.3s;
}

.slider-captcha-handle:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.slider-captcha-handle svg {
  stroke: white;
  transition: transform 0.2s;
}

.slider-captcha-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.2s;
  padding: 0 44px;
  text-align: center;
  white-space: nowrap;
}

.captcha-card.verified {
  background: rgba(46, 125, 50, 0.08);
  border-color: rgba(46, 125, 50, 0.3);
}

.captcha-card.verified .slider-captcha-track {
  background: rgba(46, 125, 50, 0.12);
  border-color: rgba(46, 125, 50, 0.4);
}

.captcha-card.verified .slider-captcha-handle {
  left: calc(100% - 44px) !important;
  background: #2e7d32;
  cursor: default;
}

.captcha-card.verified .slider-captcha-label {
  color: #2e7d32;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   Test Mode Toolbar & Dev Toast
   ═══════════════════════════════════════════════════════════ */

/* Production Mode: Hide test mode bar, debug panel, dev toast, and debug reset buttons */
.test-mode-bar,
.debug-info-panel,
#dev-toast,
#reset-cooldown-btn,
#reset-blocked-btn {
  display: none !important;
}

html.test-mode .test-mode-bar {
  display: flex !important;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  align-items: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 4px 8px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.3s ease;
}

html.test-mode .debug-info-panel,
html.test-mode #reset-cooldown-btn,
html.test-mode #reset-blocked-btn {
  display: block !important;
}

html.dark .test-mode-bar {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.45);
}

.test-mode-badge {
  font-size: 11px;
  font-weight: 700;
  color: #4338ca;
  letter-spacing: 0.3px;
  user-select: none;
  cursor: pointer;
}

html.dark .test-mode-badge {
  color: #a5b4fc;
}

.test-target-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 2px;
  gap: 2px;
}

html.dark .test-target-toggle {
  background: rgba(255, 255, 255, 0.12);
}

.test-target-btn {
  background: transparent;
  color: #4b5563;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

html.dark .test-target-btn {
  color: #94a3b8;
}

.test-target-btn:hover {
  color: #111827;
}

html.dark .test-target-btn:hover {
  color: #f1f5f9;
}

.test-target-btn.active {
  background: #4f46e5;
  color: #ffffff !important;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.35);
}

html.dark .test-target-btn.active {
  background: #6366f1;
  color: #ffffff !important;
}

.test-mode-reset-btn {
  background: #4f46e5;
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.test-mode-reset-btn:hover {
  background: #4338ca;
  transform: scale(1.05);
}

.test-mode-reset-btn:active {
  transform: scale(0.95);
}

.dev-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #181824;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.dev-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   Home / Default Screen (When no vehicle in URL)
   ═══════════════════════════════════════════════════════════ */

.home-card {
  text-align: center;
  padding: 40px 28px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.home-logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: transparent !important;
}

.home-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.35));
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.home-logo:hover {
  transform: scale(1.04);
}

/* Default / Dark theme rules */
.home-logo.logo-dark {
  display: block;
}

.home-logo.logo-light {
  display: none;
}

/* Light theme overrides */
html.light .home-logo.logo-dark {
  display: none !important;
}

html.light .home-logo.logo-light {
  display: block !important;
  filter: drop-shadow(0 4px 12px rgba(63, 81, 181, 0.2));
}

html.dark .home-logo.logo-dark {
  display: block !important;
}

html.dark .home-logo.logo-light {
  display: none !important;
}

@media (prefers-color-scheme: light) {
  html:not(.dark) .home-logo.logo-dark {
    display: none;
  }
  html:not(.dark) .home-logo.logo-light {
    display: block;
    filter: drop-shadow(0 4px 12px rgba(63, 81, 181, 0.2));
  }
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .home-logo.logo-dark {
    display: block;
  }
  html:not(.light) .home-logo.logo-light {
    display: none;
  }
}

.home-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

html.dark .home-status-badge {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}

.home-desc {
  max-width: 320px;
  margin: 0 auto 24px auto !important;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
}

html.dark .home-desc {
  color: #D1D5DB;
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .home-desc {
    color: #D1D5DB;
  }
}

.home-info-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
  text-align: left;
  width: 100%;
}

.home-info-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface-variant, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  line-height: 1.45;
}

.home-info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.home-info-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.home-info-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--on-surface, #ffffff);
  line-height: 1.35;
}

.home-info-sub {
  font-size: 12.5px;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   Debug Info Panel (Sticky / Collapsible in Local Dev & Tests)
   ═══════════════════════════════════════════════════════════ */

.debug-info-panel {
  position: fixed;
  bottom: 10px;
  right: 10px;
  max-width: 340px;
  width: calc(100vw - 20px);
  background: rgba(18, 18, 28, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  z-index: 10000;
  transition: all 0.25s ease;
  overflow: hidden;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.debug-header:hover {
  background: rgba(255, 255, 255, 0.1);
}

.debug-arrow {
  transition: transform 0.2s;
  font-size: 12px;
}

.debug-info-panel.collapsed .debug-arrow {
  transform: rotate(-90deg);
}

.debug-content {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.debug-info-panel.collapsed .debug-content {
  display: none;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  word-break: break-all;
}

.debug-label {
  color: #94a3b8;
  flex-shrink: 0;
}

.debug-val {
  color: #38bdf8;
  font-weight: 600;
  text-align: right;
}

.debug-val.ok {
  color: #4ade80;
}

.debug-val.warn {
  color: #facc15;
}

/* ─── Nickname Header & Auto Badge ─── */
.nickname-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.nickname-auto-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.2px;
  transition: all 0.2s ease;
}

.nickname-auto-badge.hidden {
  display: none !important;
}

/* ─── Chat Status Unavailable Banner ─── */
.chat-status-banner.unavailable {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.status-pulse-dot.unavailable {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  animation: none;
}

/* ─── Cooldown Attempt Badge ─── */
.cooldown-attempt-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #f59e0b;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

html.dark .cooldown-attempt-badge {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

/* ─── Item Drop-off Location Bar ─── */
.chat-dropoff-location-bar {
  margin: 6px 14px 4px 14px;
  padding: 8px 12px;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: 12px;
  animation: fadeIn 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

html.dark .chat-dropoff-location-bar {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.35);
}

.dropoff-location-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.dropoff-pin-icon {
  color: #0d9488;
  flex-shrink: 0;
}

html.dark .dropoff-pin-icon {
  color: #2dd4bf;
}

.dropoff-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.dropoff-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-edit-dropoff {
  background: transparent;
  border: none;
  color: #0d9488;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

html.dark .btn-edit-dropoff {
  color: #2dd4bf;
}

.dropoff-actions-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-quick-gps {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(20, 184, 166, 0.12);
  color: #0d9488;
  border: 1px solid rgba(20, 184, 166, 0.35);
  transition: all 0.15s ease;
  white-space: nowrap;
}

html.dark .btn-quick-gps {
  background: rgba(45, 212, 191, 0.15);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.4);
}

.btn-quick-gps:hover:not(:disabled) {
  background: rgba(20, 184, 166, 0.22);
  transform: translateY(-1px);
}

.btn-quick-gps:disabled {
  opacity: 0.6;
  cursor: wait;
}

.dropoff-maps-inline-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

.dropoff-maps-inline-link:hover {
  color: #0d9488;
}

html.dark .dropoff-maps-inline-link:hover {
  color: #2dd4bf;
}

/* ─── Item Drop-off Inline Edit Card ─── */
.chat-dropoff-edit-card {
  margin: 6px 14px 4px 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid rgba(20, 184, 166, 0.4);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.25s ease;
}

html.dark .chat-dropoff-edit-card {
  background: #1e293b;
  border-color: rgba(45, 212, 191, 0.45);
}

.dropoff-edit-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #0d9488;
  margin-bottom: 2px;
}

html.dark .dropoff-edit-header {
  color: #2dd4bf;
}

.dropoff-edit-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.3;
}

.dropoff-edit-input-wrap {
  margin-bottom: 10px;
}

.dropoff-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease;
}

.dropoff-input:focus {
  border-color: #0d9488;
}

html.dark .dropoff-input:focus {
  border-color: #2dd4bf;
}

.dropoff-edit-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.btn-dropoff-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.btn-dropoff-cancel:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.btn-dropoff-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #0d9488;
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.35);
  transition: all 0.15s ease;
}

.btn-dropoff-save:hover:not(:disabled) {
  background: #0f766e;
  transform: translateY(-1px);
}

.btn-dropoff-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropoff-gps-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.btn-dropoff-gps {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(20, 184, 166, 0.1);
  color: #0d9488;
  border: 1px dashed rgba(20, 184, 166, 0.45);
  transition: all 0.15s ease;
}

html.dark .btn-dropoff-gps {
  background: rgba(45, 212, 191, 0.1);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.45);
}

.btn-dropoff-gps:hover:not(:disabled) {
  background: rgba(20, 184, 166, 0.18);
}

.btn-dropoff-gps:disabled {
  opacity: 0.6;
  cursor: wait;
}

.dropoff-gps-status {
  font-size: 11px;
  line-height: 1.35;
  padding: 5px 9px;
  border-radius: 6px;
  display: block;
  animation: fadeIn 0.2s ease;
}

.dropoff-gps-status.status-locating {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

html.dark .dropoff-gps-status.status-locating {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.dropoff-gps-status.status-error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

html.dark .dropoff-gps-status.status-error {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

.dropoff-gps-status.status-success {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

html.dark .dropoff-gps-status.status-success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.sys-maps-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: #0d9488;
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  width: fit-content;
}

html.dark .sys-maps-link {
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.4);
}

.sys-maps-link:hover {
  background: rgba(20, 184, 166, 0.22);
  text-decoration: underline;
  transform: translateY(-1px);
}

/* ─── Item Re-Alert Action Bar (Hybrid Mode) ─── */
.chat-re-alert-bar {
  margin: 10px 14px 4px 14px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px;
  animation: fadeIn 0.3s ease;
}

html.dark .chat-re-alert-bar {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.38);
}

.chat-re-alert-bar.ringing {
  background: rgba(239, 68, 68, 0.09);
  border-color: rgba(239, 68, 68, 0.3);
}

html.dark .chat-re-alert-bar.ringing {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
}

.re-alert-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.re-alert-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 180px;
}

.re-alert-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.re-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #d97706;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
}

html.dark .re-alert-badge {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.re-alert-timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
}

html.dark .re-alert-timer-pill {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.re-alert-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.btn-re-alert {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  white-space: nowrap;
  background: #f59e0b;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.btn-re-alert:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.45);
}

.btn-re-alert:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-re-alert.ringing {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  animation: pulse-ring-red 1.5s infinite;
}

@keyframes pulse-ring-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ─── Chat Async Card ─── */
.chat-async-card {
  margin: 12px 14px 4px 14px;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeIn 0.3s ease;
}

html.dark .chat-async-card {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
}

.async-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f59e0b;
  font-size: 13px;
  font-weight: 700;
}

html.dark .async-card-header {
  color: #fbbf24;
}

.async-card-desc {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
}

/* ─── Status banner async mode ─── */
.chat-status-banner.async-mode {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.status-pulse-dot.async-mode {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  animation: none;
}

/* ─── Unreachable / Phone Did Not Ring Notice ─── */
.unreachable-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md, 12px);
  padding: 16px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-in-out;
}

html.dark .unreachable-card {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}

.unreachable-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.unreachable-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

html.dark .unreachable-badge-pill {
  color: #f87171;
}

.unreachable-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.45;
}

/* ─── Item Status Banners ─── */
.item-banner-forced-urgent {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(239, 68, 68, 0.10);
  border: 1.5px solid #ef4444;
  border-radius: var(--radius-s);
  text-align: center;
}

.item-banner-forced-urgent .banner-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #ef4444;
}

.item-banner-forced-urgent .banner-title {
  color: #ef4444;
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-banner-forced-urgent .banner-desc {
  font-size: 11.5px;
  color: #dc2626;
  margin: 0;
  line-height: 1.4;
  font-weight: 500;
}

html.dark .item-banner-forced-urgent .banner-desc {
  color: #fca5a5;
}

.item-banner-declared-lost {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.10);
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-s);
  text-align: center;
}

.item-banner-declared-lost .banner-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #f59e0b;
}

.item-banner-declared-lost .banner-title {
  color: #f59e0b;
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-banner-declared-lost .banner-desc {
  font-size: 11.5px;
  color: #b45309;
  margin: 0;
  line-height: 1.4;
  font-weight: 500;
}

html.dark .item-banner-declared-lost .banner-desc {
  color: #fde68a;
}

/* ─── Item Urgent Buttons & Voluntary Card ─── */
.btn-urgent {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
  font-weight: 700;
  border-radius: var(--radius-xl);
}

.btn-urgent:hover:not(:disabled) {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
  transform: translateY(-1px);
}

.item-voluntary-urgent-card {
  margin-top: 20px;
  padding: 16px;
  background: rgba(239, 68, 68, 0.05);
  border: 1.5px dashed rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-s);
  text-align: center;
  transition: all 0.2s ease;
}

html.dark .item-voluntary-urgent-card {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.5);
}

.item-voluntary-urgent-card .voluntary-urgent-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
  color: #ef4444;
}

.item-voluntary-urgent-card .voluntary-urgent-title {
  color: #ef4444;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.item-voluntary-urgent-card .voluntary-urgent-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.45;
}

.btn-urgent-outline {
  background: transparent;
  color: #ef4444;
  border: 1.5px solid #ef4444;
  border-radius: var(--radius-xl);
  font-weight: 600;
  padding: 12px 20px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--button-size);
  transition: all 0.2s ease;
}

.btn-urgent-outline:hover:not(:disabled) {
  background: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

/* ═══════════════════════════════════════════════════════════
   Item (Lost & Found) Theming & Color Inversion
   Teal / Emerald Dominant, Indigo Accent
   ═══════════════════════════════════════════════════════════ */

/* Header icon circle for Item */
#item-icon-circle {
  background: var(--item-primary-surface);
  color: var(--item-primary);
}

/* Card title & subtitle for Item */
#screen-item-found h2.card-title {
  color: var(--item-primary);
}

#screen-item-found .subtitle {
  background: var(--item-primary-surface);
  color: var(--item-primary);
}

/* Item Primary Action Button */
#send-item-btn {
  background: linear-gradient(135deg, var(--item-primary) 0%, var(--item-secondary) 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

#send-item-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--item-primary-dark) 0%, #0369a1 100%);
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.45);
}

/* Predefined list on Item screen */
#item-predefined-list .predefined-btn:hover:not(:disabled) {
  border-color: var(--item-primary);
  background: var(--item-primary-surface);
}

#item-predefined-list .predefined-btn .send-icon {
  color: var(--item-primary);
}

/* Owner message card on Item screen */
#item-owner-message-card {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(2, 132, 199, 0.08) 100%);
  border: 1.5px solid rgba(13, 148, 136, 0.25);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.08);
}

html.dark #item-owner-message-card {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.12) 0%, rgba(56, 189, 248, 0.12) 100%);
  border-color: rgba(45, 212, 191, 0.35);
}

#item-owner-message-card .owner-message-header {
  color: var(--item-primary);
}

#item-owner-message-card .owner-message-header svg {
  color: var(--item-primary);
}

#item-owner-message-card .owner-message-label {
  color: var(--item-primary);
}

/* Owner message card on Vehicle screen (Secondary Accent) */
#owner-default-message-card {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(79, 70, 229, 0.08) 100%);
  border: 1.5px solid rgba(13, 148, 136, 0.25);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.08);
}

html.dark #owner-default-message-card {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.12) 0%, rgba(129, 140, 248, 0.12) 100%);
  border-color: rgba(45, 212, 191, 0.35);
}

#owner-default-message-card .owner-message-header {
  color: var(--secondary);
}

#owner-default-message-card .owner-message-header svg {
  color: var(--secondary);
}

#owner-default-message-card .owner-message-label {
  color: var(--secondary);
}

/* Non-clickable informational icons in web interface */
.home-info-icon {
  color: var(--secondary);
}

.home-info-icon svg {
  color: var(--secondary);
  fill: var(--secondary);
}

.retry-timer-pill svg {
  color: var(--secondary);
}

/* Input focus on Item screen */
#screen-item-found input:focus,
#screen-item-found textarea:focus {
  border-color: var(--item-primary);
  box-shadow: 0 0 0 3px var(--item-primary-surface);
}

/* Test switcher button for Item active state */
.test-target-btn[data-target="item"].active {
  background: var(--item-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 1px 4px rgba(13, 148, 136, 0.35);
}

/* ─── Footer & Privacy Compliance ─── */
.app-footer {
  margin-top: auto;
  text-align: center;
  padding: 24px 12px 64px;
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
  width: 100%;
}

.footer-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  flex-wrap: wrap;
}

.footer-dot {
  color: var(--text-muted, #94a3b8);
  opacity: 0.5;
  user-select: none;
}

.footer-link-btn {
  background: none;
  border: none;
  color: var(--primary, #6366f1);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.2s;
  border-radius: 4px;
}

.footer-link-btn:hover {
  opacity: 0.8;
}

/* Privacy Modal */
.privacy-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.privacy-modal.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.privacy-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.privacy-modal-dialog {
  position: relative;
  background: var(--bg-card, #ffffff);
  color: var(--text-main, #1e293b);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 16px);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: modalScaleIn 0.2s ease-out;
}

html.dark .privacy-modal-dialog {
  background: var(--bg-card, #1e1e2e);
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.1);
}

.privacy-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

html.dark .privacy-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.privacy-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.privacy-modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.privacy-modal-body {
  padding: 16px 20px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.privacy-modal-body ul {
  padding-left: 20px;
  margin: 12px 0;
}

.privacy-modal-body li {
  margin-bottom: 8px;
}

.privacy-note {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 12px;
  margin-bottom: 0;
}

.privacy-modal-footer {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
}

@keyframes modalScaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════
   Discussions Hub Toggle & List
   ═══════════════════════════════════════════════════════════ */

.discussions-toggle {
  position: fixed;
  top: 12px;
  right: 104px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--background);
  color: var(--text-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, color 0.3s, transform 0.3s, box-shadow 0.3s;
}

.discussions-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  color: var(--primary);
}

.discussions-toggle:active {
  transform: scale(0.95);
}

html.dark .discussions-toggle {
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .discussions-toggle {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
  }
}

.discussions-toggle.hidden {
  display: none !important;
}

.discussions-toggle-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary, #4F46E5);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.discussions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 0;
}

.hub-empty-state {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted, #94a3b8);
  font-size: 0.9rem;
}

.hub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m, 12px);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.hub-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.hub-card--item:hover {
  border-color: var(--item-primary, #0D9488);
}

.hub-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hub-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.hub-card-icon--vehicle {
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary, #4F46E5);
}

.hub-card-icon--item {
  background: rgba(13, 148, 136, 0.12);
  color: var(--item-primary, #0D9488);
}

.hub-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.hub-card-time {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.hub-card-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.hub-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 2px;
}

.hub-card-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.hub-card-badge--reply {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  font-weight: 600;
}

html.dark .hub-card-badge--reply {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

.hub-card-badge--waiting {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted, #64748b);
}

.hub-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.hub-delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  transform: scale(1.1);
}

.hub-delete-btn:active {
  transform: scale(0.95);
}

.hub-card-badge--inactive {
  background: rgba(234, 179, 8, 0.15);
  color: #b45309;
  margin-left: 6px;
}

html.dark .hub-card-badge--inactive {
  background: rgba(234, 179, 8, 0.22);
  color: #facc15;
}

/* ─── Home Screen Download Banner ─── */
.home-download-card {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: center;
}

.home-download-card .btn-primary {
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-download-card .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.home-download-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.4;
}

