:root {
  --graphite: #26282e;
  --ink: #3b3f48;
  --muted: #5d636f;
  --yellow: #ffc21a;
  --yellow-deep: #e8a900;
  --mist: #edeff2;
  --line: #d5d9e0;
  --white: #fff;
  --red: #b3261e;
  --green: #1d7a46;
  --radius: 0.75rem;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--mist);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 1rem; line-height: 1.5; background: var(--mist); }
h1, h2 { color: var(--graphite); line-height: 1.2; margin: 0 0 0.75rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 1.75rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--graphite); text-decoration-color: var(--yellow-deep); text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--graphite); outline-offset: 2px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  background: var(--graphite); color: var(--white);
  border-bottom: 5px solid var(--yellow);
}
.brand { color: var(--white); text-decoration: none; font-size: 1.1rem; }
.brand strong { color: var(--yellow); }
#nav { display: flex; gap: 0.25rem; margin-left: auto; flex-wrap: wrap; }
#nav a, #nav .linklike { color: var(--white); padding: 0.4rem 0.75rem; border-radius: 999px; text-decoration: none; margin: 0; }
#nav a[aria-current] { background: var(--yellow); color: var(--graphite); }
#nav a:hover, #nav .linklike:hover { background: rgb(255 255 255 / 0.12); }

main { padding: clamp(1rem, 3vw, 2rem); max-width: 90rem; margin: 0 auto; }
.card { background: var(--white); border-radius: 1rem; padding: clamp(1.25rem, 3vw, 2rem); box-shadow: 0 1px 2px rgb(38 40 46 / 0.08); }
.narrow { max-width: 30rem; margin: 2rem auto; }
.stack { display: grid; gap: 0.6rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; }
.loading { color: var(--muted); }
.error { color: var(--red); background: #fdecea; padding: 0.6rem 0.8rem; border-radius: 0.5rem; margin: 0.5rem 0; }

label { font-weight: 600; color: var(--graphite); }
input, textarea, select {
  width: 100%; font: inherit; padding: 0.65rem 0.8rem;
  border: 1.5px solid #aeb4bf; border-radius: var(--radius); background: var(--white); color: var(--graphite);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); border-color: var(--graphite); }
textarea { resize: vertical; }
.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 500; margin: 1rem 0; }
.check input { width: 1.2rem; height: 1.2rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.75rem; padding: 0.55rem 1.2rem; border-radius: 999px; border: 2px solid transparent;
  font-family: inherit; font-size: 1rem; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--yellow); color: var(--graphite); }
.btn.primary:hover:not(:disabled) { background: var(--yellow-deep); }
.btn.ghost { border-color: var(--line); background: var(--white); color: var(--graphite); }
.btn.ghost:hover:not(:disabled) { border-color: var(--graphite); }
.btn.big { min-height: 3.25rem; font-size: 1.05rem; width: 100%; margin-top: 1rem; }
.btn.small { min-height: 2.25rem; padding: 0.3rem 0.8rem; font-size: 0.875rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; margin-top: 1rem; justify-self: start; }

.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); margin: 1.25rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.recovery { margin-top: 1.25rem; }
summary { cursor: pointer; color: var(--graphite); font-weight: 600; margin: 0.5rem 0; }

.options { display: grid; gap: 0.6rem; }
.option {
  display: grid; gap: 0.15rem; text-align: left; padding: 0.9rem 1rem; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--white); font: inherit; color: var(--ink);
}
.option strong { color: var(--graphite); }
.option span { font-size: 0.9rem; color: var(--muted); }
.option:hover { border-color: var(--graphite); }
.steps { padding-left: 1.2rem; margin: 1rem 0 0.5rem; }
.qr { width: min(220px, 70vw); margin: 0.5rem auto; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { display: block; word-break: break-all; padding: 0.5rem; background: var(--mist); border-radius: 0.5rem; font-size: 0.95rem; }
.codes { background: var(--mist); padding: 1rem; border-radius: var(--radius); font-size: 1.05rem; line-height: 1.8; columns: 2; }

.list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.7rem 0; border-bottom: 1px solid var(--mist); }
.posts li > div:first-child { flex: 1 1 18rem; }

/* Chat + prévia */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.25rem; align-items: start; }
.chat { display: grid; gap: 0.75rem; position: sticky; top: 1rem; }
.messages { display: grid; gap: 0.6rem; max-height: 45vh; overflow-y: auto; padding: 0.25rem; }
.msg { padding: 0.6rem 0.85rem; border-radius: 0.9rem; max-width: 92%; }
.msg p { margin: 0; white-space: pre-wrap; }
.msg .who { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.msg.equipe { background: var(--graphite); color: var(--white); justify-self: end; }
.msg.equipe .who { color: var(--yellow); }
.msg.assistente { background: var(--mist); }
.composer { display: grid; gap: 0.6rem; }
.composer .row .btn.primary { margin-left: auto; }
.composer label.btn { cursor: pointer; }
.composer input[type=file]:focus-visible + span, .composer label.btn:focus-within { outline: 3px solid var(--graphite); }

.preview { display: grid; gap: 0.75rem; }
.preview .empty { padding: 3rem 0; text-align: center; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.preview-head select { width: auto; }
.badge { background: var(--yellow); color: var(--graphite); font-weight: 700; font-size: 0.8rem; padding: 0.2rem 0.6rem; border-radius: 999px; }
.cover { width: 100%; max-height: 22rem; object-fit: cover; border-radius: var(--radius); }
.title-input { font-size: 1.5rem; font-weight: 800; color: var(--graphite); border-color: transparent; padding: 0.3rem 0.4rem; }
.title-input:hover { border-color: var(--line); }
.questions { background: #fff8e1; border-left: 4px solid var(--yellow); padding: 0.75rem 1rem; border-radius: 0.5rem; }
.questions ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.prose { font-family: Georgia, 'Source Serif 4', serif; font-size: 1.05rem; line-height: 1.7; color: #2f323a; border-top: 1px solid var(--mist); padding-top: 0.75rem; }
.prose h2, .prose h3 { font-family: system-ui, sans-serif; }
.prose img { max-width: 100%; border-radius: 0.5rem; }
.gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gallery .hint { flex-basis: 100%; margin: 0; }
.thumb { padding: 0; border: 3px solid transparent; border-radius: 0.6rem; cursor: pointer; background: none; }
.thumb img { width: 88px; height: 66px; object-fit: cover; border-radius: 0.4rem; display: block; }
.thumb.is-cover { border-color: var(--yellow); }
.live-status { font-size: 1.1rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); transition: transform 0.2s;
  background: var(--graphite); color: var(--white); padding: 0.75rem 1.25rem; border-radius: 999px; max-width: 90vw; z-index: 10;
  pointer-events: none; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }
#toast.error { background: var(--red); }
#toast.warn { background: #8a5a00; }

@media (max-width: 60rem) {
  .workspace { grid-template-columns: 1fr; }
  .chat { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
