:root {
  --bg: #12100E;
  --panel: #1E1B17;
  --panel-2: #27231E;
  --line: #3A342C;
  --text: #F4EFE6;
  --muted: #A79F92;
  --accent: #F2A33A;
  --accent-ink: #1B1814;
  --danger: #E58F7B;
  --ok: #3FB6A8;
  --radius: 20px;
  --nav-h: 68px;
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }
.screen { max-width: 520px; margin-left: auto; margin-right: auto; width: 100%; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; color: var(--muted); }

.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; color: var(--accent); text-transform: uppercase; }
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1.03;
  letter-spacing: -0.02em;
}
h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.01em; }
h3 { margin: 0; font-size: 17px; font-weight: 700; }
p { margin: 0; }
.lead { font-size: 17px; line-height: 1.5; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.grow { flex-grow: 1; }

.card { background: var(--panel); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 20px;
  border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 17px;
  width: 100%;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.small { min-height: 44px; font-size: 15px; border-radius: 14px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 500; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; color: var(--muted); }
.input {
  width: 100%; min-height: 52px; padding: 12px 16px;
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: 14px;
  font-size: 17px;
}
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 52px; resize: none; line-height: 1.35; }

.error { color: var(--danger); font-size: 14px; min-height: 20px; }

.avatars { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar svg { width: 22px; height: 22px; fill: #1B1814; }
.avatar.lg { width: 56px; height: 56px; }
.avatar.lg svg { width: 30px; height: 30px; }
.avatar.xs { width: 28px; height: 28px; }
.avatar.xs svg { width: 16px; height: 16px; }
.avatar-pick { border: 3px solid transparent; border-radius: 50%; padding: 2px; background: none; }
.avatar-pick[aria-checked="true"] { border-color: var(--accent); }
.stack { display: flex; margin-left: 0; }
.stack .avatar { border: 3px solid var(--bg); margin-left: -12px; }
.stack .avatar:first-child { margin-left: 0; }
.row { display: flex; align-items: center; gap: 14px; }

/* Application */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.app-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 24px 8px;
}
.app-head .who { display: flex; flex-direction: column; }
.app-head .who b { font-family: var(--font-display); font-size: 20px; }
.content {
  flex-grow: 1;
  padding: 12px 24px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--line);
  display: flex; max-width: 520px; margin: 0 auto;
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 0; color: var(--muted); font-size: 12px; font-weight: 500; position: relative;
}
.nav button[aria-current="page"] { color: var(--text); font-weight: 700; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 10px; height: 10px; border-radius: 5px; background: var(--accent);
}

.opp { border: 1.5px solid var(--accent); background: var(--panel); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.opp .timer { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; font-size: 14px; }
.opp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; background: var(--panel); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.chip { min-height: 40px; }

.feed { display: flex; flex-direction: column; gap: 10px; }
.trace { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--panel); border-radius: 16px; }
.trace .mark { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex-shrink: 0; }
.trace time { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty { padding: 22px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 18px; }

.cand { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-2); border-radius: 16px; }
.cand b { flex-grow: 1; }
.cand .btn { width: auto; min-height: 40px; padding: 0 16px; font-size: 15px; }

/* Discussion */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .bubble { background: var(--panel); border-radius: 16px; padding: 10px 14px; max-width: calc(100% - 44px); }
.msg.me { flex-direction: row-reverse; }
.msg.me .bubble { background: #3A2D17; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.msg .meta b { color: var(--text); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.msg .body { overflow-wrap: anywhere; white-space: pre-wrap; }
.sys { align-self: center; text-align: center; font-size: 13px; color: var(--accent); letter-spacing: 0.04em; padding: 4px 10px; }

.composer {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--bg); padding: 10px 0 6px;
  display: flex; flex-direction: column; gap: 8px;
}
.composer .send { display: flex; gap: 8px; align-items: flex-end; }
.composer .btn { width: 52px; padding: 0; flex-shrink: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px;
  font-weight: 500; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.banner { background: #3A2017; color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

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

/* Tablette */
@media (min-width: 600px) {
  #app { max-width: 720px; }
  .nav { max-width: 720px; }
  .content { padding-left: 32px; padding-right: 32px; }
  .app-head { padding-left: 32px; padding-right: 32px; }
}

/* Bureau : barre latérale + contenu large */
@media (min-width: 960px) {
  #app { max-width: 1120px; }
  .screen { justify-content: center; }
  .app {
    display: grid; grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto 1fr; column-gap: 40px; padding: 32px 32px 0; align-items: start;
  }
  .app-head { grid-column: 1; grid-row: 1; padding: 0; }
  .nav {
    position: sticky; top: 24px; grid-column: 1; grid-row: 2;
    flex-direction: column; height: auto; max-width: none; margin: 16px 0 0;
    padding: 0; border: 0; background: none; gap: 4px;
  }
  .nav button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 48px; padding: 0 16px; border-radius: 14px; font-size: 16px; text-align: left;
  }
  .nav button:hover { background: var(--panel); }
  .nav button[aria-current="page"] { background: var(--panel); }
  .nav .badge { position: static; margin-left: auto; }
  .content { grid-column: 2; grid-row: 1 / span 2; padding: 0 0 40px; max-width: 760px; width: 100%; }
  .composer { bottom: 0; }
  #toast { bottom: 24px; }
}

[hidden] { display: none !important; }
