/* ========================================================================
   AUDYT — Design System Premium 2026
   Editorial · Warm · Minimalist · Sources: Mercury · Linear · NYT Magazine
   ========================================================================== */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ---- Tokens ---- */
:root {
  /* Couleurs */
  --cream: #FDFBF3;
  --cream-deep: #F5F1E4;
  --paper: #FAF7EC;
  --ink: #1A1815;
  --ink-soft: #3D3A33;
  --ink-muted: #6B655B;
  --ink-faint: #A8A293;
  --stamp: #A4243B;
  --stamp-soft: #C9596F;
  --stamp-tint: rgba(164, 36, 59, 0.08);
  --success: #1F5128;
  --success-tint: rgba(31, 81, 40, 0.08);
  --warning: #A16207;
  --warning-tint: rgba(161, 98, 7, 0.10);
  --critical: #7F1D1D;
  --critical-tint: rgba(127, 29, 29, 0.08);
  --border: rgba(26, 24, 21, 0.08);
  --border-strong: rgba(26, 24, 21, 0.16);
  --border-stamp: rgba(164, 36, 59, 0.30);

  /* Typo */
  --font-display: 'Instrument Serif', 'Times New Roman', serif;
  --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', monospace;

  /* Tailles */
  --t-xs: 11px;
  --t-sm: 13px;
  --t-md: 15px;
  --t-base: 16px;
  --t-lg: 18px;
  --t-xl: 22px;
  --t-2xl: 28px;
  --t-3xl: 36px;
  --t-4xl: 48px;
  --t-5xl: 60px;
  --t-6xl: 72px;

  /* Espacements (base 4) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 9999px;

  /* Shadows */
  --shadow-paper: 0 1px 2px rgba(26, 24, 21, 0.04), 0 8px 24px -8px rgba(26, 24, 21, 0.08);
  --shadow-card: 0 1px 3px rgba(26, 24, 21, 0.06), 0 12px 32px -12px rgba(26, 24, 21, 0.12);
  --shadow-card-hover: 0 2px 4px rgba(26, 24, 21, 0.08), 0 24px 48px -16px rgba(26, 24, 21, 0.16);
  --shadow-modal: 0 4px 8px rgba(26, 24, 21, 0.08), 0 32px 80px -16px rgba(26, 24, 21, 0.24);

  /* Easing */
  --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  /* Texture papier ultra subtile */
  background-image:
    radial-gradient(circle at 15% 25%, rgba(164, 36, 59, 0.018) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(164, 36, 59, 0.012) 0%, transparent 50%);
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }

/* ---- Typo ---- */
.serif { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.serif em, .serif i { font-style: italic; }
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; letter-spacing: -0.015em; color: var(--ink); }
h1 { font-size: clamp(40px, 9vw, var(--t-6xl)); line-height: 1.02; }
h2 { font-size: clamp(28px, 6vw, var(--t-4xl)); line-height: 1.05; }
h3 { font-size: clamp(22px, 4vw, var(--t-2xl)); line-height: 1.15; }
p { color: var(--ink-soft); }

.lead { font-size: var(--t-lg); line-height: 1.55; color: var(--ink-soft); }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }

/* ---- Container ---- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--s-5);
  padding-right: var(--s-5);
}
@media (min-width: 768px) {
  .container { padding-left: var(--s-8); padding-right: var(--s-8); }
}

.container-narrow { max-width: 720px; }
.container-prose { max-width: 640px; }

/* ---- Sections ---- */
.section {
  padding: var(--s-16) 0;
}
@media (min-width: 768px) {
  .section { padding: var(--s-24) 0; }
}
.section--tight { padding: var(--s-10) 0; }
.section--deep { background: var(--paper); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  height: 48px;
  min-height: 48px;
  font-family: var(--font-sans);
  font-size: var(--t-md);
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: var(--r-md);
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn--full { width: 100%; }
.btn--lg { height: 56px; min-height: 56px; padding: 0 var(--s-6); font-size: var(--t-md); }
.btn--xl { height: 64px; min-height: 64px; padding: 0 var(--s-8); font-size: var(--t-lg); }
.btn--sm { height: 36px; min-height: 36px; padding: 0 var(--s-3); font-size: var(--t-sm); }

.btn--primary {
  background: var(--ink);
  color: var(--cream);
}
.btn--primary:hover {
  background: var(--ink-soft);
  box-shadow: var(--shadow-card);
}

.btn--accent {
  background: var(--stamp);
  color: #fff;
}
.btn--accent:hover {
  background: #8E1D32;
  box-shadow: 0 4px 12px rgba(164, 36, 59, 0.25);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn--ghost:hover {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}

.btn--soft {
  background: rgba(26, 24, 21, 0.06);
  color: var(--ink);
}
.btn--soft:hover {
  background: rgba(26, 24, 21, 0.10);
}

/* ---- Inputs ---- */
.input {
  width: 100%;
  height: 52px;
  padding: 0 var(--s-4);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--t-md);
  color: var(--ink);
  transition: all 0.2s var(--ease-out);
}
.input::placeholder { color: var(--ink-faint); }
.input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(26, 24, 21, 0.04);
}
.input--mono { font-family: var(--font-mono); letter-spacing: 0.04em; }

/* ---- Cards ---- */
.card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-paper);
  transition: all 0.3s var(--ease-out);
}
.card--paper { background: var(--paper); }
.card--ink { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.card--hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

/* ---- Pills / Badges ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3);
  font-size: var(--t-sm);
  font-weight: 500;
  background: var(--cream);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  color: var(--ink-soft);
}
.pill--stamp {
  background: var(--stamp-tint);
  border-color: var(--border-stamp);
  color: var(--stamp);
}
.pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2.5s ease-in-out infinite;
}
.pill__dot--stamp { background: var(--stamp); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ---- Source pill (signature Audyt) ---- */
.source-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px var(--s-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--stamp-tint);
  border: 1px solid var(--border-stamp);
  border-radius: var(--r-pill);
  color: var(--stamp);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.source-pill:hover {
  background: rgba(164, 36, 59, 0.12);
}
.source-pill::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--stamp);
}

/* ---- Stamp mark (signature Audyt) ---- */
.stamp-mark {
  width: 88px;
  height: 88px;
  border: 2px solid var(--stamp);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--stamp);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  line-height: 1.1;
  transform: rotate(-8deg);
  opacity: 0.85;
}
.stamp-mark::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--stamp);
  border-radius: 50%;
  opacity: 0.4;
}

/* ---- Risk levels ---- */
.risk-low    { color: var(--success); background: var(--success-tint); }
.risk-med    { color: var(--warning); background: var(--warning-tint); }
.risk-high   { color: var(--stamp);   background: var(--stamp-tint); }
.risk-crit   { color: var(--critical); background: var(--critical-tint); }

/* ---- Nav (sticky) ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(253, 251, 243, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: var(--s-4);
}
.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--t-xl);
  letter-spacing: -0.02em;
}
.nav__brand-mark {
  width: 28px;
  height: 28px;
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
}
.nav__links {
  display: none;
  gap: var(--s-6);
  font-size: var(--t-sm);
  color: var(--ink-soft);
}
.nav__links a:hover { color: var(--ink); }
@media (min-width: 768px) {
  .nav__links { display: flex; }
}

/* ---- Halo background ---- */
.halo {
  position: absolute;
  pointer-events: none;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--stamp-tint) 0%, transparent 65%);
  filter: blur(40px);
  z-index: 0;
}

/* ---- Animations ---- */
.fade-up {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s var(--ease-premium), transform 0.8s var(--ease-premium);
}
.fade-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.fade-up[data-delay="100"] { transition-delay: 0.10s; }
.fade-up[data-delay="200"] { transition-delay: 0.20s; }
.fade-up[data-delay="300"] { transition-delay: 0.30s; }
.fade-up[data-delay="400"] { transition-delay: 0.40s; }
.fade-up[data-delay="500"] { transition-delay: 0.50s; }
.fade-up[data-delay="600"] { transition-delay: 0.60s; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(253, 251, 243, 0.3);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ---- Conversation bubbles (assistant) ---- */
.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: var(--t-md);
  line-height: 1.5;
}
.bubble--user {
  margin-left: auto;
  background: rgba(26, 24, 21, 0.04);
  border-top-right-radius: var(--r-sm);
}
.bubble--ai {
  background: var(--paper);
  border: 1px solid var(--border);
  border-top-left-radius: var(--r-sm);
}

/* ---- Voice button (signature copilot) ---- */
.voice-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--stamp);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-out);
}
.voice-btn:hover { transform: scale(1.05); box-shadow: 0 8px 24px rgba(164, 36, 59, 0.35); }
.voice-btn--active {
  animation: voice-pulse 1.4s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(164, 36, 59, 0.5); }
  50% { box-shadow: 0 0 0 16px rgba(164, 36, 59, 0); }
}

.voice-orb {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--stamp-soft), var(--stamp));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 48px rgba(164, 36, 59, 0.30), inset 0 0 60px rgba(255, 255, 255, 0.15);
}
.voice-orb::before, .voice-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--stamp);
  opacity: 0;
}
.voice-orb--active::before { animation: orb-ring 2s ease-out infinite; }
.voice-orb--active::after  { animation: orb-ring 2s ease-out 1s infinite; }
@keyframes orb-ring {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ---- Sticky bottom CTA mobile ---- */
.sticky-cta {
  position: sticky;
  bottom: 0;
  background: rgba(253, 251, 243, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  padding: var(--s-3) var(--s-5) calc(var(--s-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  z-index: 40;
}

/* ---- Utilities ---- */
.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;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }
.text-center { text-align: center; }

.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--s-6); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: var(--s-6); }
}
@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .fade-up { opacity: 1; transform: none; }
}

/* ========================================================================
   APP SHELL — Bottom nav mobile + Sidebar desktop
   ========================================================================== */

.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(253, 251, 243, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px var(--s-3);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
}
.app-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: var(--r-md);
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s var(--ease-out);
  min-height: 48px;
}
.app-bottom-nav__item.is-active {
  color: var(--stamp);
}
.app-bottom-nav__item:hover {
  color: var(--ink);
}
.app-bottom-nav__icon {
  width: 22px;
  height: 22px;
}

@media (min-width: 1024px) {
  .app-bottom-nav { display: none; }
}

/* App body padding for bottom nav on mobile */
.app-body {
  padding-bottom: 80px;
}
@media (min-width: 1024px) {
  .app-body { padding-bottom: 0; }
}

/* — Settings tabs — */
.settings-tabs {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  margin-bottom: var(--s-6);
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  flex-shrink: 0;
  padding: var(--s-3) var(--s-4);
  font-size: var(--t-sm);
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-weight: 500;
}
.settings-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--stamp);
}

/* — Empty state — */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-5);
}
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto var(--s-4);
  background: var(--paper);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
}

/* — Call screen specifics — */
.call-screen {
  position: fixed;
  inset: 0;
  background: var(--always-ink-bg);
  color: var(--always-cream-fg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.call-screen::before {
  content: '';
  position: absolute;
  top: -200px; left: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(164, 36, 59, 0.30) 0%, transparent 60%);
  filter: blur(60px);
  pointer-events: none;
}
.call-screen::after {
  content: '';
  position: absolute;
  bottom: -200px; right: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(164, 36, 59, 0.20) 0%, transparent 60%);
  filter: blur(60px);
  pointer-events: none;
}
.call-content { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: var(--s-8) var(--s-5); }

.call-orb {
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--stamp-soft), var(--stamp));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 80px rgba(164, 36, 59, 0.4), inset 0 0 80px rgba(255, 255, 255, 0.15);
  position: relative;
}
@media (max-width: 380px) { .call-orb { width: 220px; height: 220px; } }
.call-orb::before, .call-orb::after {
  content: ''; position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--stamp);
  opacity: 0;
}
.call-orb--listening::before { animation: orb-ring 2s ease-out infinite; }
.call-orb--listening::after  { animation: orb-ring 2s ease-out 1s infinite; }
.call-orb--speaking { animation: orb-pulse 1.6s ease-in-out infinite; }
@keyframes orb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.call-controls {
  display: flex; gap: var(--s-4);
  align-items: center; justify-content: center;
}
.call-btn-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease-out);
  background: rgba(253, 251, 243, 0.12);
  color: var(--cream);
}
.call-btn-circle:hover { background: rgba(253, 251, 243, 0.20); }
.call-btn-circle--end {
  background: var(--stamp);
  width: 72px; height: 72px;
}
.call-btn-circle--end:hover { background: #8E1D32; }

/* — Calendar — */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-name {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: var(--s-2) 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 4px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  position: relative;
  cursor: pointer;
}
.cal-day--inactive { color: var(--ink-faint); }
.cal-day--today { background: var(--ink); color: var(--cream); font-weight: 600; }
.cal-day--has-event::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 5px; height: 5px;
  background: var(--stamp);
  border-radius: 50%;
}
.cal-day--has-event.cal-day--critical::after { background: var(--critical); }

/* — Toggle — */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.2s var(--ease-out);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s var(--ease-out);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.toggle.is-on {
  background: var(--success);
}
.toggle.is-on::after {
  transform: translateX(20px);
}

/* — File row — */
.file-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all 0.2s var(--ease-out);
}
.file-row:hover { background: var(--paper); border-color: var(--border-strong); }
.file-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--stamp-tint);
  display: flex; align-items: center; justify-content: center;
  color: var(--stamp);
  flex-shrink: 0;
}

/* — Section heading inline — */
.section-head-inline {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--s-5);
  gap: var(--s-3);
  flex-wrap: wrap;
}


/* ========================================================================
   DARK MODE — Premium warm dark, pas noir générique
   ========================================================================== */

:root[data-theme="dark"] {
  /* Backgrounds — warm dark, pas froid */
  --cream: #1B1714;
  --paper: #221E1A;
  --paper-strong: #2A2520;

  /* Text */
  --ink: #F5EFE0;
  --ink-soft: #C9C2B0;
  --ink-muted: #8E8779;
  --ink-faint: #5C5650;

  /* Borders */
  --border: rgba(245, 239, 224, 0.10);
  --border-strong: rgba(245, 239, 224, 0.18);

  /* Stamp légèrement boosté pour visibilité */
  --stamp: #D14156;
  --stamp-soft: #DD6B7C;
  --stamp-tint: rgba(209, 65, 86, 0.16);
  --border-stamp: rgba(209, 65, 86, 0.40);

  /* States */
  --success: #6FBF7E;
  --success-tint: rgba(111, 191, 126, 0.16);
  --warning: #E0A437;
  --warning-tint: rgba(224, 164, 55, 0.16);
  --critical: #E54B5E;
  --critical-tint: rgba(229, 75, 94, 0.16);

  /* Shadows réduites en dark */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.70);
}

/* Dark mode adjustments — éléments spéciaux */
:root[data-theme="dark"] body { background: var(--cream); color: var(--ink); }

/* La carte "ink" en dark = inversion premium subtile (toujours plus claire que bg) */
:root[data-theme="dark"] .card--ink {
  background: linear-gradient(180deg, #2D2723, #221E1A);
  border-color: var(--border-strong);
  color: var(--ink);
}
:root[data-theme="dark"] .card--ink * { color: var(--ink); }
:root[data-theme="dark"] .card--ink .muted { color: var(--ink-muted); }

/* Halo plus discret en dark */
:root[data-theme="dark"] .halo {
  background: radial-gradient(circle, rgba(209, 65, 86, 0.18) 0%, rgba(209, 65, 86, 0.06) 30%, transparent 70%);
  opacity: 0.7;
}

/* Paper texture désactivée en dark (causerait du grain visible) */
:root[data-theme="dark"] .paper-noise { opacity: 0; }

/* Stamp mark : fond cream-ish en dark */
:root[data-theme="dark"] .stamp-mark {
  color: var(--stamp);
  border-color: var(--stamp);
}

/* Nav backdrop en dark */
:root[data-theme="dark"] .nav {
  background: rgba(27, 23, 20, 0.85);
  border-bottom-color: var(--border);
}

/* Bottom nav backdrop en dark */
:root[data-theme="dark"] .app-bottom-nav {
  background: rgba(27, 23, 20, 0.92);
  border-top-color: var(--border);
}

/* Theme toggle button */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--border-strong);
}
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Inputs — fond paper en dark */
:root[data-theme="dark"] .input,
:root[data-theme="dark"] input.input,
:root[data-theme="dark"] textarea.input,
:root[data-theme="dark"] select.input {
  background: var(--paper);
  border-color: var(--border-strong);
  color: var(--ink);
}
:root[data-theme="dark"] .input::placeholder { color: var(--ink-faint); }

/* Voice orb en dark */
:root[data-theme="dark"] .voice-orb {
  box-shadow: 0 0 60px rgba(209, 65, 86, 0.35), inset 0 0 60px rgba(245, 239, 224, 0.10);
}

/* Smooth transition between themes */
html {
  transition: background-color 0.3s var(--ease-out);
}
body, .nav, .card, .btn, .input, .feat-card, .file-row, .source-pill, .pill {
  transition: background-color 0.25s var(--ease-out), border-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  html, body, .nav, .card, .btn, .input, .feat-card { transition: none; }
}


/* Nav account link — icône user only sur mobile, texte+icône sur desktop */
.nav-account-link { padding-left: 10px; padding-right: 10px; }
.nav-account-icon { display: block; }
.nav-account-label { display: none; }
@media (min-width: 640px) {
  .nav-account-link { padding-left: var(--s-3); padding-right: var(--s-3); gap: 6px; }
  .nav-account-label { display: inline; }
}
@media (max-width: 380px) {
  .nav__cta-group { gap: 6px; }
  .theme-toggle { width: 32px; height: 32px; }
}


/* ========================================================================
   DARK MODE — Ajustements éléments spéciaux
   ========================================================================== */

/* Source pill plus visible en dark */
:root[data-theme="dark"] .source-pill {
  background: rgba(209, 65, 86, 0.12);
  border-color: rgba(209, 65, 86, 0.30);
  color: var(--stamp-soft);
}

/* Pills neutral plus visibles */
:root[data-theme="dark"] .pill {
  background: rgba(245, 239, 224, 0.06);
}

/* Quick prompts en dark */
:root[data-theme="dark"] .quick-prompt {
  background: var(--paper);
  border-color: var(--border-strong);
  color: var(--ink-soft);
}
:root[data-theme="dark"] .quick-prompt:hover {
  background: var(--paper-strong);
  color: var(--ink);
}

/* Settings tabs underline en dark */
:root[data-theme="dark"] .settings-tab.is-active {
  color: var(--ink);
}

/* Tool chips */
:root[data-theme="dark"] .tool-chip {
  background: var(--paper);
  border-color: var(--border-strong);
  color: var(--ink-soft);
}

/* Calendar today en dark */
:root[data-theme="dark"] .cal-day--today {
  background: var(--ink);
  color: var(--cream);
}

/* Buttons primary boost en dark */
:root[data-theme="dark"] .btn--primary {
  background: var(--ink);
  color: var(--cream);
}
:root[data-theme="dark"] .btn--primary:hover {
  background: #FFFAEC;
}

/* Btn ghost en dark */
:root[data-theme="dark"] .btn--ghost {
  border-color: var(--border-strong);
  color: var(--ink);
}
:root[data-theme="dark"] .btn--ghost:hover {
  background: var(--paper);
  border-color: var(--ink-muted);
}

/* Btn soft en dark */
:root[data-theme="dark"] .btn--soft {
  background: var(--paper);
  color: var(--ink-soft);
}
:root[data-theme="dark"] .btn--soft:hover {
  background: var(--paper-strong);
  color: var(--ink);
}

/* Mockup screens in dark — keep them visible */
:root[data-theme="dark"] .mockup-screen,
:root[data-theme="dark"] .mock-card,
:root[data-theme="dark"] .mock-row {
  background: var(--paper);
  border-color: var(--border);
  color: var(--ink);
}

/* Bottom nav active state visibility */
:root[data-theme="dark"] .app-bottom-nav__item.is-active {
  color: var(--stamp);
}

/* Card hover en dark */
:root[data-theme="dark"] .card--hover:hover {
  background: var(--paper-strong);
  border-color: var(--border-strong);
}

/* Voice overlay dark */
:root[data-theme="dark"] .voice-overlay {
  background: rgba(27, 23, 20, 0.96);
}

/* Stamp tint backgrounds (paywall, alerts) */
:root[data-theme="dark"] .card[style*="background: var(--paper)"],
:root[data-theme="dark"] .card--paper {
  background: var(--paper-strong) !important;
  border-color: var(--border-strong);
}


/* ========================================================================
   FIX BUGS DARK MODE — patches après rapport bug audit
   ========================================================================== */

/* Variables stables qui ne flippent JAMAIS — pour cards toujours sombres */
:root, :root[data-theme="dark"] {
  --always-ink-bg: #1A1815;
  --always-cream-fg: #F5EFE0;
}

/* FIX 1 : copilot-hero (dashboard) — toujours sombre, jamais cream */
.copilot-hero {
  background: var(--always-ink-bg) !important;
  color: var(--always-cream-fg) !important;
}
.copilot-hero * { color: inherit; }
.copilot-hero .serif em { color: var(--stamp-soft); }

/* FIX 2 : chat-header + chat-input-bar (assistant) — suivent le thème */
.chat-header {
  background: rgba(253, 251, 243, 0.92) !important;
  border-bottom: 1px solid var(--border);
}
.chat-input-bar {
  background: rgba(253, 251, 243, 0.95) !important;
  border-top: 1px solid var(--border);
}
:root[data-theme="dark"] .chat-header {
  background: rgba(27, 23, 20, 0.92) !important;
  border-bottom-color: var(--border);
}
:root[data-theme="dark"] .chat-input-bar {
  background: rgba(27, 23, 20, 0.95) !important;
  border-top-color: var(--border);
}
:root[data-theme="dark"] .input-wrap {
  background: var(--paper);
  border-color: var(--border-strong);
}
:root[data-theme="dark"] .chat-textarea { color: var(--ink); }
:root[data-theme="dark"] .chat-textarea::placeholder { color: var(--ink-faint); }

/* FIX 4 : pill "Connecté à ACME" — visible en dark */
:root[data-theme="dark"] .chat-header .mono.muted {
  color: var(--ink-soft);
}
:root[data-theme="dark"] .chat-header .pill__dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-tint);
}

/* Disclaimer band (assistant) en dark */
:root[data-theme="dark"] .chat-header > div:last-child {
  background: var(--paper) !important;
  border-top-color: var(--border) !important;
}

/* FIX 5 : Quick prompts wrap — jamais tronqués */
.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: 0 var(--s-3);
  justify-content: center;
}
.quick-prompt {
  flex-shrink: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 480px) {
  .quick-prompt {
    font-size: 12px;
    padding: 8px 14px;
    flex: 1 1 calc(50% - 4px);
    max-width: calc(50% - 4px);
  }
}

/* FIX 7 : Pill Solo · actif — boost contraste en dark */
:root[data-theme="dark"] .pill {
  background: rgba(245, 239, 224, 0.08);
  color: var(--ink);
  border-color: var(--border-strong);
}
:root[data-theme="dark"] .pill__dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-tint);
}

/* Reset démo — discret, en lien gris pas en bouton */
.debug-reset {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.debug-reset:hover { opacity: 1; }
@media (max-width: 380px) {
  .debug-reset { display: none; } /* sur très petits écrans, on cache */
}


/* ========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.audyt-toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 200;
  background: var(--ink);
  color: var(--cream);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  font-size: var(--t-sm);
  font-weight: 500;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-overflow: ellipsis;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.audyt-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 480px) {
  .audyt-toast {
    bottom: 90px;
    font-size: 13px;
    padding: 10px 16px;
    max-width: calc(100vw - 24px);
  }
}
.audyt-toast--success { background: var(--success); }
.audyt-toast--error { background: var(--stamp); }


/* ========================================================================
   FILTER CHIPS — état actif visuel
   ========================================================================== */

.quick-prompt.is-active {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
}
.quick-prompt.is-active:hover {
  background: var(--ink-soft);
}

/* Tools strip horizontal scroll smoothness */
.tools-strip {
  overflow-x: auto;
  scrollbar-width: none;
  display: flex;
  gap: var(--s-2);
  padding: var(--s-1) 0;
  -webkit-overflow-scrolling: touch;
}
.tools-strip::-webkit-scrollbar { display: none; }
.tools-strip .quick-prompt {
  flex-shrink: 0;
  flex-grow: 0;
  white-space: nowrap;
  max-width: none;
}


/* ========================================================================
   POLISH FINAL — UX micro-improvements
   ========================================================================== */

/* Focus states accessibilité — visible sans être moche */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Smooth scroll global */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Tap highlight removed (Safari iOS) */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Touch feedback subtil sur boutons */
@media (hover: none) and (pointer: coarse) {
  .btn:active,
  .feat-card:active,
  .file-row:active,
  .quick-prompt:active,
  .card--hover:active {
    transform: scale(0.98);
    transition: transform 0.1s ease-out;
  }
}

/* Prevent text selection sur les boutons (UX mobile cleaner) */
button, .btn, .quick-prompt, .pill {
  user-select: none;
  -webkit-user-select: none;
}

/* Cards un peu plus élégantes au hover */
.card--hover {
  transition: all 0.25s var(--ease-out);
}
.card--hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Safe area harmonisée sur les écrans avec section padding-tight */
.section--tight {
  padding-bottom: calc(var(--s-12) + env(safe-area-inset-bottom));
}

/* App body bottom nav clearance */
.app-body {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

/* Empty inputs placeholder sober */
.input::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

/* Disabled state propre */
.btn:disabled,
button:disabled,
.input:disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* Mobile : éviter zoom auto sur input focus iOS */
@media (max-width: 480px) {
  input, textarea, select {
    font-size: 16px !important; /* iOS zoom only kicks in below 16px */
  }
}

/* Scrollbar webkit clean */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

