:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #252a43;
  background: #667eea;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,154,86,.95), transparent 30%),
    radial-gradient(circle at 86% 20%, rgba(78,205,196,.85), transparent 34%),
    linear-gradient(135deg, #ff6b6b 0%, #667eea 52%, #764ba2 100%);
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(255,255,255,.95);
  outline-offset: 3px;
}
.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-footer {
  margin-top: auto;
  padding: 18px;
  text-align: center;
  color: rgba(255,255,255,.92);
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.app-footer a { color: white; font-weight: 800; }

/* Accueil */
.home-page { width: min(1000px, calc(100% - 32px)); margin: 0 auto; padding: 64px 0 30px; text-align: center; }
.hero { color: white; margin-bottom: 34px; }
.hero-eyebrow, .eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .12em;
}
.hero-eyebrow { padding: 7px 12px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; }
.hero h1 { margin: 18px 0 8px; font-size: clamp(2.4rem, 7vw, 4.6rem); line-height: 1; }
.hero p { margin: 0; font-size: clamp(1rem, 3vw, 1.3rem); }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 24px; }
.role-card {
  border: 0;
  border-radius: 26px;
  padding: 34px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 22px 55px rgba(38,43,82,.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  color: #252a43;
  transition: transform .2s, box-shadow .2s;
}
.role-card:hover { transform: translateY(-5px); box-shadow: 0 28px 65px rgba(38,43,82,.28); }
.role-icon { font-size: 4rem; }
.role-card strong { font-size: 2rem; }
.role-card .role-description { color: #606681; }
.role-card em { width: 100%; margin-top: 8px; padding: 13px; border-radius: 13px; color: white; font-style: normal; font-weight: 900; background: #667eea; }
.role-card.server em { background: #3b9c91; }
.setup-link { display: inline-block; margin-top: 28px; color: white; font-weight: 900; }

/* Pages en carte */
.join-page, .setup-page, .privacy-page, .communication-page { width: min(900px, calc(100% - 28px)); margin: 0 auto; padding: 32px 0; }
.join-page { width: min(650px, calc(100% - 28px)); }
.setup-page { width: min(760px, calc(100% - 28px)); }
.join-card, .setup-card, .privacy-card, .fatal-card, .consent-card {
  position: relative;
  background: rgba(255,255,255,.97);
  border-radius: 28px;
  padding: 38px;
  box-shadow: 0 25px 65px rgba(32,39,78,.24);
}
.join-card { text-align: center; }
.back { position: absolute; top: 22px; left: 24px; color: #59617d; font-weight: 800; text-decoration: none; }
.join-card .role-icon { display: block; margin-top: 12px; }
.join-card h1 { margin: 8px 0 24px; }
.field-label { display: block; margin: 0 0 8px; color: #4d536e; font-weight: 900; }
select, input, textarea {
  max-width: 100%;
  border: 2px solid #d9ddef;
  border-radius: 13px;
  padding: 12px 14px;
  background: white;
  color: #252a43;
}
select { min-width: 240px; font-weight: 700; }
select:focus, input:focus, textarea:focus { outline: 3px solid rgba(102,126,234,.22); border-color: #667eea; }
.error-box, .notice.error { color: #962929; background: #fff0f0; }
.error-box { margin-top: 16px; padding: 12px; border-radius: 12px; font-weight: 800; }
.info-box { margin-top: 16px; padding: 12px; border-radius: 12px; color: #3c5875; background: #edf6ff; }

/* Scanner */
.qr-scanner { width: 100%; max-width: 430px; margin: 20px auto 0; }
.camera-container { border: 1px solid #dfe3f4; border-radius: 18px; padding: 20px; background: #f9faff; }
.camera-container h2 { font-size: 1.15rem; margin: 0 0 14px; }
.camera-frame { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: #1f2539; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; }
.camera-guide { position: absolute; inset: 17%; border: 3px solid #ff6b6b; border-radius: 15px; box-shadow: 0 0 0 999px rgba(0,0,0,.16); pointer-events: none; }
.camera-status { min-height: 1.4em; margin: 10px 0; color: #59617d; font-size: .86rem; }
.manual-label { margin: 14px 0 8px; color: #555; font-size: .9rem; }
.qr-scanner textarea { width: 100%; resize: vertical; }
.primary-button, .secondary-button, .action-button {
  border: 0;
  border-radius: 12px;
  padding: 12px 15px;
  cursor: pointer;
  font-weight: 900;
}
.primary-button { width: 100%; margin-top: 10px; color: white; background: #667eea; }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { width: 100%; margin-top: 10px; background: #e9ecf8; color: #38405f; }

/* Générateur */
.setup-card { text-align: center; }
.setup-card .eyebrow { margin-top: 25px; color: #667eea; }
.setup-card h1 { margin: 8px 0; }
.intro { max-width: 620px; margin: 0 auto 24px; color: #606681; line-height: 1.55; }
.setup-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; text-align: left; }
.setup-form label { display: flex; flex-direction: column; gap: 7px; color: #474d68; font-weight: 900; }
.setup-form .primary-button { grid-column: 1 / -1; }
.qr-result { margin-top: 28px; padding-top: 25px; border-top: 1px solid #e5e8f3; }
.qr-result h2 { font-size: 1.25rem; }
.qr-code { display: flex; justify-content: center; margin: 15px auto; }
.qr-code img, .qr-code canvas { max-width: 100%; height: auto; border: 10px solid white; box-shadow: 0 10px 35px rgba(37,42,67,.15); }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.action-button { background: #e9ecfa; color: #343b5c; }

/* Consentement et conversation */
.fatal-card, .consent-card { max-width: 650px; margin: 35px auto; text-align: center; }
.consent-icon { font-size: 4rem; }
.consent-card p { color: #606681; line-height: 1.6; }
.consent-check { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-radius: 14px; background: #f4f5fb; text-align: left; line-height: 1.45; }
.consent-check input { min-width: 20px; width: 20px; height: 20px; margin: 0; padding: 0; }
.consent-card .primary-button { margin: 18px 0 12px; }
.cancel-link { color: #56608b; font-weight: 800; }
.session-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 25px 28px; background: rgba(255,255,255,.97); border-radius: 22px; box-shadow: 0 15px 40px rgba(31,38,77,.18); }
.session-header h1 { margin: 7px 0 3px; }
.session-header p { margin: 0; color: #646b85; }
.leave { color: #59617d; font-weight: 800; text-decoration: none; }
.connection-badge { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 12px; background: #eef0f7; color: #626980; font-size: .82rem; font-weight: 900; }
.connection-badge i { width: 9px; height: 9px; border-radius: 50%; background: #8c93a8; }
.connection-badge.online { color: #176b50; background: #e4f7f0; }
.connection-badge.online i { background: #22a879; box-shadow: 0 0 0 4px rgba(34,168,121,.15); }
.connection-badge.connecting i { background: #e59f23; }
.connection-badge.offline i { background: #cf4c56; }
.main-card { margin-top: 18px; padding: clamp(18px,4vw,32px); background: rgba(255,255,255,.97); border-radius: 24px; box-shadow: 0 18px 50px rgba(31,38,77,.2); }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 13px 15px; border-radius: 12px; font-weight: 700; }
.notice button { border: 0; background: transparent; color: inherit; text-decoration: underline; cursor: pointer; }
.microphone-section { padding: 18px 0 30px; text-align: center; }
.mic-button { min-width: min(360px,100%); border: 0; border-radius: 999px; padding: 18px 28px; background: linear-gradient(135deg,#667eea,#7655b7); color: white; display: inline-flex; align-items: center; justify-content: center; gap: 15px; cursor: pointer; box-shadow: 0 12px 30px rgba(102,126,234,.35); }
.mic-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.mic-button.recording { background: linear-gradient(135deg,#f05c62,#ca3f4d); animation: recordingPulse 1.4s infinite; }
.mic-icon { font-size: 1.8rem; }
.mic-button strong, .mic-button small { display: block; }
.mic-button small { margin-top: 2px; opacity: .82; }
.mic-help { color: #737991; font-size: .88rem; }
.transcript-section { overflow: hidden; border: 1px solid #e4e7f2; border-radius: 18px; }
.transcript-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: #f8f9fd; border-bottom: 1px solid #e4e7f2; }
.transcript-header h2 { margin: 3px 0 0; font-size: 1.25rem; color: #303650; }
.transcript-header .eyebrow { color: #667eea; font-size: .68rem; }
.message-count { min-width: 32px; padding: 7px; border-radius: 999px; background: #667eea; color: white; text-align: center; font-weight: 900; }
.messages-container { height: 390px; overflow-y: auto; padding: 20px; background: white; }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #737991; text-align: center; }
.empty-state > span { font-size: 3rem; }
.empty-state strong { margin-top: 12px; color: #3d435f; }
.empty-state p { max-width: 470px; }
.message { width: min(78%,620px); margin: 0 0 16px; }
.message.own { margin-left: auto; }
.message.other { margin-right: auto; }
.message-meta { display: flex; justify-content: space-between; margin-bottom: 5px; color: #6f768e; font-size: .75rem; }
.message p { margin: 0; padding: 13px 15px; border-radius: 16px 16px 16px 4px; background: #f0f2f8; color: #303650; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.own p { border-radius: 16px 16px 4px 16px; background: #667eea; color: white; }
.message > small { display: block; margin-top: 4px; color: #9a6220; }

/* Confidentialité */
.privacy-card h1 { text-align: center; }
.privacy-card h2 { margin-top: 28px; color: #3a4162; }
.privacy-card p, .privacy-card li { color: #59617d; line-height: 1.65; }
.privacy-card .back { position: static; display: inline-block; }
.tech-badge { display: inline-block; margin: 4px; padding: 6px 10px; border-radius: 999px; color: #42506d; background: #edf0fa; font-size: .82rem; font-weight: 800; }

@keyframes recordingPulse { 50% { transform: scale(1.025); box-shadow: 0 14px 35px rgba(202,63,77,.45); } }
@media (max-width: 700px) {
  .home-page { padding-top: 34px; }
  .role-grid { grid-template-columns: 1fr; }
  .role-card { padding: 25px; }
  .session-header { align-items: flex-start; flex-direction: column; padding: 20px; }
  .messages-container { height: 340px; padding: 14px; }
  .message { width: 92%; }
}
@media (max-width: 620px) {
  .join-card, .setup-card, .privacy-card { padding: 62px 18px 25px; }
  .setup-form { grid-template-columns: 1fr; }
  .setup-form .primary-button { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
