:root {
  --bg: #f5f9fc;
  --bg-secondary: #ffffff;
  --card: #ffffff;
  --card-hover: #f0f8ff;
  --ink: #1a1a1a;
  --ink-secondary: #333333;
  --muted: #666666;
  --accent: #2196f3;
  --accent-strong: #1976d2;
  --accent-light: #b3e5fc;
  --accent-pale: #eaf6fb;
  --border: rgba(33, 150, 243, 0.15);
  --border-strong: rgba(33, 150, 243, 0.3);
  --shadow-sm: 0 2px 8px rgba(33, 150, 243, 0.1);
  --shadow: 0 8px 24px rgba(33, 150, 243, 0.15);
  --shadow-lg: 0 16px 48px rgba(33, 150, 243, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { 
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
}

body { 
  margin: 0; 
  min-height: 100vh; 
  background: var(--bg);
  font-size: 16px; 
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html { font-size: clamp(14px, 2vw, 16px); }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px) 80px;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}
.header-bar h1 { 
  margin: 0; 
  font-size: clamp(26px, 5vw, 32px); 
  letter-spacing: -0.8px;
  font-weight: 600;
}
.back-link { 
  color: var(--muted); 
  text-decoration: none; 
  font-weight: 600; 
  font-size: clamp(13px, 2vw, 14px); 
  transition: all 200ms ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.back-link:hover { 
  color: var(--ink);
  transform: translateX(-3px);
}

/* Responsive navigation */
.site-nav { 
  display: flex; 
  gap: 6px; 
  align-items: center; 
}
.site-nav a { 
  color: #ffffff;
  text-decoration: none; 
  padding: 11px 20px; 
  border-radius: var(--radius); 
  font-weight: 600;
  font-size: 14px;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  border: none;
  outline: none;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
}
.site-nav a:hover { 
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.site-nav a:focus {
  outline: none;
  box-shadow: none;
}
.site-nav a.active {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  box-shadow: var(--shadow), inset 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(0);
}
.site-nav a:active {
  transform: translateY(0);
}

.menu-button { 
  display: none; 
  background: var(--bg-secondary); 
  border: 1px solid var(--border); 
  color: var(--ink); 
  padding: 10px 14px; 
  border-radius: var(--radius-sm); 
  font-size: 20px; 
  cursor: pointer;
  transition: all 200ms ease;
  flex-direction: column;
  gap: 5px;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  outline: none;
}
.menu-button:hover {
  background: var(--card);
  border-color: var(--border-strong);
}
.menu-button:focus {
  outline: none;
  box-shadow: none;
}

/* Mobile nav styles */
.mobile-nav {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(300px, 80vw);
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
}

.mobile-nav.active {
  right: 0;
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.mobile-nav-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: all 200ms ease;
}

.close-btn:hover {
  transform: scale(1.1);
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-nav-links a,
.mobile-nav-links button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 12px 16px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  border: none;
  border-radius: var(--radius);
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.mobile-nav-links a:hover,
.mobile-nav-links button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.mobile-nav-links a:focus,
.mobile-nav-links button:focus {
  outline: none;
  box-shadow: none;
}

.mobile-nav-links a.active {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  box-shadow: var(--shadow), inset 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(0);
}

.mobile-nav-links a:active,
.mobile-nav-links button:active {
  transform: translateY(0);
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.nav-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Footer */
.site-footer {
  margin-top: 60px;
  padding: 32px 0 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

.site-footer .copyright {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Discreet donate link for footer */
.donate-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0;
  margin-left: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
  line-height: 1;
  vertical-align: baseline;
  opacity: 0.95;
  transition: color 160ms ease, transform 120ms ease, opacity 160ms ease;
}
.donate-inline svg { width: 12px; height: 12px; display: inline-block; vertical-align: text-bottom; }
.donate-inline:hover { color: var(--accent-strong); transform: translateY(-1px); opacity: 1; }

/* Keep the donate text accessible but visually hidden (screen-reader only) */
.donate-inline .donate-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Make the icon even smaller and less prominent */
.donate-inline {
  gap: 4px;
  font-size: 0.75rem;
  margin-left: 6px;
  opacity: 0.75;
}
.donate-inline svg { width: 8px; height: 8px; stroke-width: 1; opacity: 0.85; }
.donate-inline:hover { color: var(--accent-strong); transform: translateY(-1px); opacity: 0.95; }


.support-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  text-decoration: none;
  padding: 10px 18px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 8px;
  outline: none;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

.support-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.support-link:focus {
  outline: none;
  box-shadow: none;
}

.support-link:active {
  transform: translateY(0);
}

.mobile-nav-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.mobile-nav-footer p {
  margin: 0 0 10px 0;
  line-height: 1.5;
}

.mobile-nav-footer .support-link {
  display: flex;
  justify-content: center;
  font-size: 0.9rem;
  margin-top: 12px;
}

/* Mobile: collapse nav into menu button */
@media (max-width: 768px) {
  .site-nav { display: none; }
  .menu-button { display: flex; }
}

.hero { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.hero h1 { margin: 6px 0 4px; font-size: clamp(28px, 6vw, 32px); letter-spacing: -0.02em; }
.hero .sub { margin: 0; color: var(--muted); max-width: 640px; line-height: 1.4; font-size: clamp(14px, 2vw, 16px); }
.hero-badge { background: var(--accent-pale); color: var(--accent-strong); padding: 10px 14px; border-radius: 12px; font-weight: 600; border: 1px solid var(--accent-light); font-size: clamp(12px, 2vw, 14px); display: inline-block; width: fit-content; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: clamp(10px, 1.5vw, 12px); color: var(--muted); margin: 0; }

.card { 
  background: var(--card); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  padding: clamp(20px, 4vw, 28px); 
  margin-bottom: 24px; 
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card-head { 
  display: flex; 
  justify-content: space-between;
  align-items: center;
  gap: 16px; 
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.card h2 { 
  margin: 0; 
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 600;
  letter-spacing: -0.5px;
}
.hint { 
  margin: 0; 
  color: var(--muted); 
  font-size: clamp(13px, 2vw, 14px); 
  line-height: 1.5;
}

.grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
  gap: 16px 20px; 
}
label { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  font-weight: 500; 
  color: var(--ink); 
  font-size: clamp(13px, 2vw, 14px);
  word-break: break-word;
}
label input:not([type="checkbox"]):not([type="radio"]), 
label textarea, 
select { 
  width: 100%; 
  padding: clamp(10px, 2vw, 12px) clamp(12px, 2vw, 14px); 
  border-radius: var(--radius-sm); 
  border: 1px solid var(--border); 
  background: var(--bg-secondary); 
  color: var(--ink); 
  font-size: clamp(14px, 2vw, 15px); 
  font-family: inherit;
  transition: all 0.2s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
label textarea { 
  resize: vertical; 
  min-height: 120px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
label input:not([type="checkbox"]):not([type="radio"]):focus, 
label textarea:focus,
select:focus { 
  outline: none;
  border-color: var(--border-strong);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
select { 
  cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position-x: calc(100% - 8px);
  background-position-y: center;
  padding-right: 36px;
}
select option { 
  background: var(--card); 
  color: var(--ink); 
}

.group-title { 
  grid-column: 1 / -1; 
  font-size: clamp(12px, 1.5vw, 13px); 
  letter-spacing: 0.1em; 
  text-transform: uppercase; 
  color: var(--muted); 
  padding-top: 12px;
  margin-top: 8px;
  font-weight: 600;
}
.check { 
  flex-direction: row; 
  align-items: center; 
  gap: 10px; 
  font-weight: 500;
  cursor: pointer;
}
.check input { 
  width: 18px;
  height: 18px;
  accent-color: var(--accent); 
  cursor: pointer; 
}
.radio-group { 
  grid-column: 1 / -1; 
  display: flex; 
  align-items: center; 
  gap: 16px; 
  flex-wrap: wrap; 
  padding: 8px 0; 
}
.radio { 
  flex-direction: row; 
  align-items: center; 
  gap: 8px; 
  font-weight: 500;
  cursor: pointer;
}
.radio input { 
  width: 18px;
  height: 18px;
  accent-color: var(--accent); 
  cursor: pointer; 
}

.wide { grid-column: 1 / -1; }

.actions { 
  display: flex; 
  gap: 12px; 
  align-items: center; 
  margin-top: 16px; 
  flex-wrap: wrap; 
}
button { 
  cursor: pointer; 
  border: none; 
  font-weight: 600; 
  border-radius: var(--radius-sm); 
  padding: clamp(10px, 2vw, 12px) clamp(16px, 3vw, 20px); 
  font-size: clamp(14px, 2vw, 15px); 
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
button.primary { 
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%); 
  color: #ffffff; 
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
button.primary:hover { 
  transform: translateY(-2px); 
  box-shadow: var(--shadow);
}
button.ghost { 
  background: transparent; 
  color: var(--ink); 
  border: 1px solid var(--border); 
  transition: all 200ms ease;
}
button.ghost:hover {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
button:active { 
  transform: translateY(0); 
}
button:disabled { 
  opacity: 0.5; 
  cursor: not-allowed;
  transform: none !important;
}

#toast { 
  position: fixed; 
  bottom: 24px; 
  right: 24px; 
  background: var(--card); 
  color: var(--ink); 
  padding: 14px 18px; 
  border-radius: var(--radius); 
  border: 1px solid var(--border-strong); 
  box-shadow: var(--shadow-lg); 
  opacity: 0; 
  pointer-events: none; 
  transition: opacity 200ms ease, transform 200ms ease;
  font-size: clamp(13px, 2vw, 14px);
  max-width: calc(100vw - 48px);
  z-index: 1000;
  transform: translateY(10px);
}
#toast.show { 
  opacity: 1;
  transform: translateY(0);
}

/* Tablettes et écrans petits */
@media (max-width: 768px) {
  .shell {
    padding: 16px 12px 48px;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  
  .hero {
    align-items: flex-start;
  }
  
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  button {
    width: 100%;
    text-align: center;
  }
  
  .card-head {
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .shell {
    padding: 12px 8px 40px;
    .card {
      padding: 8px 4px;
      margin-bottom: 8px;
    }
    label, .group-title {
      font-size: 15px;
    }
    label input, label textarea, select {
      font-size: 15px;
      padding: 8px 8px;
    }
    .card-head {
      gap: 6px;
    }
    .signature-block {
      padding: 0.5rem 0.25rem;
    }
  }
  
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .header-bar h1 {
    font-size: 20px;
    margin-bottom: 4px;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 10px 12px;
  }
  
  .card {
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  
  label input:not([type="checkbox"]):not([type="radio"]):not([type="date"]),
  label textarea,
  select {
    font-size: 16px;
  }
  
  .actions {
    gap: 8px;
  }
  
  button {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .radio-group {
    gap: 10px;
  }
  
  #toast {
    bottom: 12px;
    right: 8px;
    left: 8px;
    max-width: 100%;
  }
  
  .check {
    flex-wrap: wrap;
  }
  
  select {
    width: 100% !important;
  }
}

/* Très petits écrans (paysage mobile) */
@media (max-height: 500px) {
  .shell {
    padding: 12px 8px 24px;
  }
  
  .card {
    margin-bottom: 10px;
  }
}

/* Signature canvas: make full-width and prevent horizontal scrolling */
/* Signature block stays within the layout (no breakout) to avoid overflow */
/* Default signature block: contained, no breakout */
.signature-block {
  width: 100%;
  box-sizing: border-box;
  padding: 1rem 0.5rem;
  margin: 0 0 1rem 0;
  overflow: hidden;
}

/* Form page: let the block use the viewport width but cap it; does not affect account page */
.form-page .signature-block {
  position: relative;
  left: auto;
  transform: none;
  width: min(960px, 95vw);
  margin: 0 auto; /* center within viewport */
  padding: 1.25rem 1rem;
}

.signature-canvas {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  display: block;
  height: 100px;
  border-radius: 4px;
}

/* Form page: allow a wider cap that adapts to viewport */
.form-page .signature-canvas {
  max-width: min(700px, 95vw);
}

/* Slightly larger on tablets */
@media (min-width: 768px) {
  .signature-canvas { height: 130px; }
}

/* Larger but capped on very large screens */
@media (min-width: 1200px) {
  .signature-canvas { height: 150px; }
}
