:root {
  --bg: #16110e;
  --surface: #211a16;
  --surface-2: #2b221d;
  --line: #3a2f28;
  --text: #f3eae2;
  --muted: #a99c90;
  --danger: #e07a6a;

  --feu: #ec5a3c;
  --braise: #e8a05a;
  --neutre: #b9ad9f;
  --givre: #b8d0da;
  --glace: #7db4dc;

  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }

.lvl2  { --c: var(--feu); }
.lvl1  { --c: var(--braise); }
.lvl0  { --c: var(--neutre); }
.lvl-1 { --c: var(--givre); }
.lvl-2 { --c: var(--glace); }

/* ---------- mise en page ---------- */
.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 32px);
  display: flex; flex-direction: column; gap: 16px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }
h1, h2, h3 { margin: 0; font-weight: 500; }
h2 { font-family: var(--serif); font-size: 24px; }
h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
p { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- barre du haut ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { font-family: var(--serif); font-size: 22px; letter-spacing: .02em; }
.brand.small { font-size: 18px; }
.top-actions { display: flex; gap: 4px; }
.icon-btn, .icon-spacer { width: 44px; height: 44px; }
.icon-btn {
  display: grid; place-items: center; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:active { background: var(--surface); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- boutons ---------- */
.btn {
  min-height: 48px; padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2);
  cursor: pointer; font-weight: 500;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.link { background: transparent; border: 0; color: var(--muted); min-height: 40px; }
.btn:disabled { opacity: .5; }
.chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; min-height: 40px;
}
.chip.on { background: var(--surface-2); color: var(--text); border-color: var(--muted); }

/* ---------- formulaires ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 16px;
}
textarea { resize: vertical; font-size: 15px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--braise); outline-offset: 1px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------- connexion ---------- */
.auth { justify-content: center; min-height: 100dvh; }
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0 8px; }
.hero h1 { font-family: var(--serif); font-size: 40px; }
.ember {
  width: 110px; height: 110px;
  background: radial-gradient(closest-side, #ffd7a0 0%, var(--braise) 28%, color-mix(in srgb, var(--feu) 65%, transparent) 55%, transparent 100%);
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.08); opacity: .85; } }
.lang-switch { display: flex; justify-content: center; gap: 8px; }

/* ---------- appairage ---------- */
.code { font-family: ui-monospace, Menlo, monospace; font-size: 40px; letter-spacing: .3em; padding: 8px 0 4px 0.3em; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-family: ui-monospace, Menlo, monospace; text-align: center; }

/* ---------- signal du partenaire ---------- */
.signal {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 28px 22px 24px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line));
  transition: border-color .6s;
}
.signal::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 30% 0%, color-mix(in srgb, var(--c) 28%, transparent), transparent 70%);
  pointer-events: none; transition: background .6s;
}
.signal.lvl0::before { opacity: .35; }
.signal > * { position: relative; }
.who { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.level-name { font-family: var(--serif); font-size: 44px; line-height: 1.1; margin-top: 6px; color: var(--c); }
.meaning { margin-top: 6px; font-size: 17px; }
.meta { color: var(--muted); font-size: 14px; margin-top: 12px; }

/* ---------- mon thermomètre ---------- */
.mine { display: flex; flex-direction: column; gap: 10px; }
.scale { position: relative; display: flex; flex-direction: column; gap: 6px; }
.scale::before {
  content: ""; position: absolute; left: 25px; top: 30px; bottom: 30px; width: 2px; border-radius: 2px;
  background: linear-gradient(var(--feu), var(--braise), var(--neutre), var(--givre), var(--glace));
  opacity: .45;
}
.step {
  position: relative; display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 10px 14px 10px 10px; text-align: left;
  border-radius: 16px; border: 1px solid transparent; background: transparent; cursor: pointer;
  transition: background .3s, border-color .3s;
}
.step .dot { justify-self: center; }
.dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 4px var(--bg); transition: transform .3s, box-shadow .3s;
}
.step-text { display: flex; flex-direction: column; }
.step-name { font-size: 17px; font-weight: 500; }
.step-meaning { font-size: 13px; color: var(--muted); }
.step.active {
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--c) 55%, transparent);
}
.step.active .dot { transform: scale(1.35); box-shadow: 0 0 0 4px var(--bg), 0 0 18px var(--c); }
.step.active .step-name { color: var(--c); }
.step:active { transform: scale(.99); }
.status { display: flex; flex-direction: column; gap: 10px; }
.status .meta { margin-top: 2px; text-align: center; }

/* ---------- réglages ---------- */
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented button {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
}
.segmented .on { background: var(--surface-2); color: var(--text); border-color: var(--muted); }

/* ---------- définitions ---------- */
.def { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 22px 1fr; gap: 6px 10px; }
.def legend { display: contents; }
.def legend .dot { grid-row: 1; margin-top: 16px; }
.def input { grid-column: 2; color: var(--c); font-weight: 500; }
.def textarea { grid-column: 2; }

/* ---------- historique ---------- */
.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.cell { aspect-ratio: 1; border-radius: 6px; background: var(--c); }
.cell.empty { background: var(--surface-2); }
.hist-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.hist-list li {
  display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.hist-list .dot { box-shadow: none; width: 10px; height: 10px; }
.hist-level { color: var(--c); }
.hist-time { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- divers ---------- */
.banner {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 14px;
}
.banner .btn { align-self: flex-start; padding: 0; min-height: 32px; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  animation: fade 2.2s forwards;
}
@keyframes fade { 0% { opacity: 0; } 10%, 85% { opacity: 1; } 100% { opacity: 0; } }

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