/* Coach — design « quiet luxury » : neutres chauds, beaucoup d'air, typographie soignée.
   Aucune ressource externe : polices du système uniquement. */

:root {
  --bg: #f6f2ec;
  --surface: #fffdf9;
  --sand: #ece4d8;
  --ink: #2a2420;
  --ink-soft: #4a423b;
  --muted: #8b8075;
  --line: #e4dbcf;
  --accent: #9a7b5f;
  --accent-soft: #c9b39c;
  --danger: #a5563f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;

  --radius: 22px;
  --gutter: 20px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --surface: #1f1b18;
    --sand: #2b2521;
    --ink: #efe8df;
    --ink-soft: #cfc6bb;
    --muted: #9a8f84;
    --line: #2f2925;
    --accent: #c4a487;
    --accent-soft: #6f5d4d;
    --danger: #d98a72;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Boutons ---------- */

.btn-primary {
  display: block; width: 100%;
  padding: 15px 22px;
  border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.45; }

.btn-quiet {
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink-soft);
  padding: 11px 18px; font-size: 14px;
}
.btn-quiet.small { padding: 7px 14px; font-size: 12.5px; letter-spacing: 0.02em; white-space: nowrap; flex: none; }

/* ---------- Connexion / inscription ---------- */

.auth {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 32px) var(--gutter) calc(env(safe-area-inset-bottom) + 28px);
  gap: 28px;
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.eyebrow {
  margin: 0 0 18px;
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
}
.wordmark {
  margin: 0;
  font-family: var(--serif); font-weight: 400;
  font-size: 56px; line-height: 1; letter-spacing: 0.01em;
}
.rule { width: 36px; height: 1px; background: var(--accent); margin: 26px auto; }
.lead { margin: 0 0 34px; color: var(--ink-soft); font-size: 15.5px; }
.auth-card .btn-quiet { margin-top: 14px; width: 100%; }
.field { display: block; text-align: left; margin: 0 0 18px; }
.field span {
  display: block; margin-bottom: 8px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.field input {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); font-size: 16px;
}
.status { min-height: 1.5em; margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.status.error { color: var(--danger); }
.auth-foot { max-width: 320px; margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Conversation ---------- */

.app {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 760px; margin: 0 auto;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--serif); font-size: 23px; line-height: 1.1; }
.brand-sub {
  margin-top: 3px;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 400px) {
  .brand-sub { letter-spacing: 0.14em; font-size: 9.5px; }
}

.thread {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px var(--gutter) 16px;
  -webkit-overflow-scrolling: touch;
}

.empty { padding: 18vh 8px 0; text-align: center; color: var(--ink-soft); }
.empty-title { margin: 0 0 12px; font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--ink); }
.empty p { margin: 0 auto; max-width: 300px; font-size: 15px; }

.messages { list-style: none; margin: 0; padding: 0; }

.day {
  margin: 28px 0 18px; text-align: center;
  font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}

.msg { display: flex; flex-direction: column; margin: 0 0 16px; }
.msg.user { align-items: flex-end; }
.msg.coach { align-items: flex-start; }

.bubble {
  max-width: min(86%, 560px);
  padding: 12px 16px;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.msg.user .bubble { background: var(--sand); border-bottom-right-radius: 7px; }
.msg.coach .bubble {
  background: var(--surface); border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
}
.bubble p { margin: 0; }
.bubble p + p, .bubble p + ul, .bubble ul + p { margin-top: 10px; }
.bubble ul { margin: 6px 0 0; padding-left: 18px; }
.bubble li + li { margin-top: 4px; }
.bubble li::marker { color: var(--accent); }
.bubble strong { font-weight: 600; }

.meta { margin: 5px 6px 0; font-size: 11px; color: var(--muted); }
.msg.pending .bubble { opacity: 0.6; }
.msg.failed .meta { color: var(--danger); }
.msg.failed .meta button {
  border: 0; background: none; padding: 0; color: inherit; text-decoration: underline;
}

.typing {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 14px 18px; margin: 0 0 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); border-bottom-left-radius: 7px;
}
.typing[hidden] { display: none; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft);
  animation: breathe 1.4s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes breathe { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.composer {
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 5px 5px 5px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 26px;
}
.composer textarea {
  flex: 1; min-width: 0;
  max-height: 160px; padding: 9px 0;
  border: 0; outline: none; resize: none; background: transparent;
  font-size: 16px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  flex: none; width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  transition: opacity 0.2s ease;
}
.send:disabled { opacity: 0.25; }

@media (min-width: 768px) {
  :root { --gutter: 32px; }
  .thread { padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
