/* Booky — fond crème commun, une couleur par personne.
   --pastel / --deep suivent le thème de l'élément : la racine prend celui de la personne connectée,
   et n'importe quel bloc peut porter data-theme pour signer ce qui vient de l'autre. */
:root {
  --bg: #faf6ee;
  --surface: #fffdf8;
  --line: #e6dfd2;
  --text: #2d2a26;
  --muted: #6f675d;
  --danger: #a3312f;
  --pastel: #ece5d8;
  --deep: #5a4d3c;
  --on-deep: #fffdf8;
  --radius: 18px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: light;
}
[data-theme="green"] { --pastel: #dcebd9; --deep: #2f5d43; }
[data-theme="pink"] { --pastel: #f8dde4; --deep: #a8355a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { font-family: var(--serif); color: var(--deep); letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.25rem; margin-bottom: 6px; }
p { margin: 0 0 10px; }
a { color: var(--deep); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2.5px solid var(--deep); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.i { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Boutons et champs */
.btn {
  min-height: var(--tap); padding: 10px 20px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); font-weight: 600;
}
.btn.primary { background: var(--deep); border-color: var(--deep); color: var(--on-deep); width: 100%; }
.btn.link { border: 0; background: none; color: var(--deep); text-decoration: underline; font-weight: 500; width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff;
}
input:focus { border-color: var(--deep); outline: none; box-shadow: 0 0 0 3px var(--pastel); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.4em; margin: 6px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* Connexion */
.login {
  min-height: 100dvh; max-width: 400px; margin: 0 auto;
  padding: calc(48px + var(--safe-t)) 20px calc(32px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-logo { border-radius: 22px; box-shadow: 0 6px 20px rgba(90, 77, 60, .14); }
.login h1 { font-size: 2.4rem; margin-top: 16px; }
.tagline { color: var(--muted); margin-bottom: 28px; }
.login .card { width: 100%; text-align: left; }
.login .card .small { margin: 12px 0 0; }
.login .card label[for="code"] { margin-top: 16px; }
.code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

/* Coquille */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + var(--safe-t)) 16px 12px;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.topbar h1 { font-size: 1.7rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap);
  padding: 0 14px 0 10px; border-radius: 999px; background: var(--pastel);
  color: var(--deep); font-weight: 600; text-decoration: none; white-space: nowrap;
}
main#view { max-width: 720px; margin: 0 auto; padding: 4px 16px calc(96px + var(--safe-b)); }
section { margin-bottom: 28px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-b);
  background: rgba(250, 246, 238, .94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px 7px; min-height: 56px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600;
}
.tabbar a[aria-current] { color: var(--deep); }
.tabbar a[aria-current] .i { background: var(--pastel); border-radius: 999px; box-shadow: 0 0 0 5px var(--pastel); }

/* États vides */
.empty { text-align: center; padding: 14vh 12px 0; }
.empty-mark {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--pastel); color: var(--deep);
}
.empty-mark .i { width: 36px; height: 36px; }
.empty p { max-width: 34ch; margin: 0 auto; }

/* Profil */
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  border-radius: var(--radius); background: var(--pastel); color: var(--deep);
}
.person.waiting { background: none; border: 1.5px dashed var(--line); }
.person-emoji {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.7rem; background: var(--surface);
}
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin: 12px 0; }
.emoji-grid button {
  aspect-ratio: 1; min-height: 48px; font-size: 1.5rem; padding: 0;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
}
.emoji-grid button[aria-pressed="true"] { border-color: var(--deep); background: var(--pastel); }
.inline-form { display: flex; align-items: center; gap: 10px; }
.inline-form label { margin: 0; white-space: nowrap; font-weight: 500; }
.inline-form input { width: 96px; text-align: center; font-size: 1.3rem; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); z-index: 40;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: .92rem;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Grand écran : la navigation passe sur le côté */
@media (min-width: 860px) {
  .tabbar {
    top: 0; right: auto; width: 96px; grid-template-columns: 1fr; align-content: center; gap: 6px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .topbar, main#view { margin-left: 96px; }
  main#view { max-width: none; padding-left: 32px; padding-right: 32px; }
  main#view > * { max-width: 720px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
  #toast { bottom: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
