:root {
  --bg-main: #070a13;
  --bg-gradient: radial-gradient(circle at 50% 20%, #151e36 0%, #070a13 70%);
  --suada-gold: #CC9F33;
  --suada-gold-hover: #e5b43c;
  --suada-gold-glow: rgba(204, 159, 51, 0.35);
  --suada-gold-dim: rgba(204, 159, 51, 0.12);
  --card-bg: rgba(15, 23, 42, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --success: #10b981;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* App Container */
.app-container {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* Top Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
}

.brand-wrapper  { display: flex; align-items: center; gap: 12px; }

.brand-logo  { height: 34px; width: auto; filter: drop-shadow(0 2px 8px var(--suada-gold-glow)); }

.brand-title  { display: flex; flex-direction: column; }

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--suada-gold);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.pill-badge.offline  { background: rgba(239, 68, 68, 0.12); color: var(--danger); border-color: rgba(239, 68, 68, 0.25); }

.btn-icon {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover  { background: var(--suada-gold-dim); border-color: var(--suada-gold); color: var(--suada-gold); }

/* Glass Card */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Context Input Bar (Prospect & Commercial) */
.context-card {
  margin-bottom: 20px;
}

.context-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-group  { display: flex; flex-direction: column; gap: 6px; }

.input-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-field {
  background: rgba(7, 10, 19, 0.7);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.input-field:focus {
  border-color: var(--suada-gold);
}

/* Central Cockpit */
.recorder-cockpit {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  min-height: 380px;
  padding: 30px 20px;
}

/* Wave Canvas */
.visualizer-wrapper {
  width: 100%;
  height: 90px;
  margin-bottom: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visualizer-canvas  { width: 100%; height: 100%; display: block; }

/* Big Tactile Trigger Button */
.record-trigger-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid var(--suada-gold);
  color: var(--suada-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 25px var(--suada-gold-glow);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.record-btn:active {
  transform: scale(0.94);
}

.record-btn.recording {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 35px var(--danger-glow);
  animation: pulse-ring 1.8s infinite;
}

.record-btn svg  { width: 48px; height: 48px; }

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 var(--danger-glow);
  }
  70% {
    box-shadow: 0 0 0 25px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Status & Timer */
.timer-display {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.timer-display.active {
  color: var(--suada-gold);
}

.status-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Result / Status Card */
.result-card  { margin-top: 20px; animation: slideUp 0.3s ease-out; }

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to  { opacity: 1; transform: translateY(0); }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.closing-badge {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(204, 159, 51, 0.15);
  color: var(--suada-gold);
  border: 1px solid var(--suada-gold);
}

.audio-player-custom {
  width: 100%;
  margin: 12px 0;
  border-radius: var(--radius-sm);
  background: #0f172a;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--suada-gold) 0%, #b88628 100%);
  color: #070a13;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.94rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px var(--suada-gold-glow);
}

.btn-primary:hover  { filter: brightness(1.1); transform: translateY(-1px); }

/* Slide Drawer (History) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.open  { opacity: 1; pointer-events: auto; }

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 460px;
  background: #0a0e1a;
  border-left: 1px solid var(--card-border);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
}

.drawer-backdrop.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--card-border);
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover  { border-color: var(--suada-gold); background: rgba(204, 159, 51, 0.06); }

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-item-title  { font-size: 0.92rem; font-weight: 600; color: var(--text-main); }

.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Lucide Icon Standard Align */
i[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

/* --- Animations & Utilities --- */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin  { animation: spin 1s linear infinite; display: inline-block; }

/* Toast Container & Notification */
.toast-container {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--suada-gold);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  animation: toastFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-error  { border-color: var(--danger); color: #fca5a5; }

.toast.toast-success  { border-color: var(--success); color: #86efac; }

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to  { opacity: 1; transform: translateY(0) scale(1); }
}

/* Framework Cards in Audit Modal */
.framework-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.framework-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.framework-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--suada-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.framework-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(204, 159, 51, 0.12);
  color: var(--suada-gold);
  border: 1px solid rgba(204, 159, 51, 0.3);
}

.framework-body  { font-size: 0.84rem; color: #cbd5e1; line-height: 1.5; }

/* History Delete Action */
.history-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-small {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-small:hover  { background: rgba(239, 68, 68, 0.12); border-color: var(--danger); color: var(--danger); }

/* --- In-flight Cancel & Review Bar --- */
.record-trigger-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 16px;
  width: 100%;
}

.btn-cancel-in-flight {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel-in-flight:hover  { background: rgba(239, 68, 68, 0.25); border-color: #ef4444; transform: scale(1.05); }

.review-bar  { width: 100%; margin-top: 20px; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px;
  margin-top: 10px;
}

@media (max-width: 440px) {
  .review-actions {
    grid-template-columns: 1fr;
  }
}

.btn-secondary-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-danger:hover  { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }

.btn-primary-gold {
  background: linear-gradient(135deg, var(--suada-gold) 0%, #b88628 100%);
  color: #070a13;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.94rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--suada-gold-glow);
  transition: all 0.2s ease;
}

.btn-primary-gold:hover  { filter: brightness(1.1); transform: translateY(-1px); }

/* --- Mobile Responsive Header (Screen <= 480px) --- */
@media (max-width: 480px) {
  .app-container {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-header  { gap: 8px; padding-bottom: 14px; }

  .brand-wrapper {
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .brand-logo  { height: 28px; flex-shrink: 0; }

  .brand-name  { font-size: 1.05rem; white-space: nowrap; }

  .brand-subtitle {
    display: none; /* Masqué sur mobile pour laisser respirer les actions */
  }

  .header-actions  { gap: 6px; flex-shrink: 0; }

  .pill-badge  { padding: 6px 10px; font-size: 0.72rem; white-space: nowrap; }

  .btn-icon  { width: 38px; height: 38px; flex-shrink: 0; }
}

@media (max-width: 360px) {
  .pill-badge #connectionText {
    display: none; /* Mode ultra-compact : icône wifi seule */
  }
  .pill-badge {
    padding: 6px;
  }
}

/* --- PWA Install Banner & iOS Modal --- */
.install-card {
  margin-bottom: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--suada-gold-glow);
  background: rgba(204, 159, 51, 0.06);
}
.install-card-content { display: flex; align-items: center; gap: 10px; flex: 1; }
.install-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-primary-small {
  background: linear-gradient(135deg, var(--suada-gold) 0%, #b88628 100%);
  color: #070a13;
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.btn-icon-small {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #e2e8f0;
}
.ios-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--suada-gold);
  color: #070a13;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
