@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin-ext.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #1B1B2F;
  --paper: #FBF6EE;
  --coral: #FF5A36;
  --coral-deep: #E2421F;
  --sea: #0F8B8D;
  --sea-pale: #DDF0EE;
  --mute: #6C6A75;
  --line: rgba(27, 27, 47, .12);
  --font: "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--ink);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, select, input { font: inherit; color: inherit; }

.talk {
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- Une moitié d'écran par personne ---------- */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 16px;
  background: var(--paper);
}
.side.them { background: var(--sea-pale); }
.talk.face .side.them { transform: rotate(180deg); }

.side-head { display: flex; align-items: center; gap: 8px; }
.lang-pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}
.lang-pick .flag { font-size: 1.3rem; line-height: 1; }
.lang-pick select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 1rem;
  padding: 4px 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.05rem;
  cursor: pointer;
}
.icon-btn[aria-pressed="false"] { opacity: .45; }

/* ---------- Fil de la conversation ---------- */
.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.feed:empty::before {
  content: attr(data-hint);
  margin: auto;
  max-width: 26ch;
  text-align: center;
  color: var(--mute);
  font-size: .95rem;
  line-height: 1.4;
}
.msg { max-width: 92%; line-height: 1.35; overflow-wrap: anywhere; }
.msg.said { align-self: flex-end; text-align: right; }
.msg.said .main { color: var(--mute); font-size: 1rem; }
.msg.said .check {
  margin-top: 4px;
  font-size: .85rem;
  color: var(--sea);
}
.msg.said .check::before { content: "↺ "; }
.msg.heard { align-self: flex-start; }
.msg.heard .main {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  background: #fff;
  font-size: 1.35rem;
  font-weight: 600;
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
}
.side.them .msg.heard .main { background: #fff; }
.msg.pending .main { color: var(--mute); font-style: italic; font-weight: 400; }

.kb { display: flex; gap: 8px; padding-bottom: 8px; }
.kb[hidden] { display: none; }
.kb input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1rem;
}
.kb button {
  width: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

/* ---------- Bouton micro ---------- */
.side-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.status { margin: 0; min-height: 1.2em; font-size: .85rem; color: var(--mute); text-align: center; }
.mic {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .1s;
}
.side.them .mic { background: var(--sea); }
.mic:active { transform: scale(.98); }
.mic-ico { font-size: 1.4rem; }
.mic-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(255, 90, 54, .55);
  pointer-events: none;
}
.mic.rec { background: var(--ink); }
.mic.rec .mic-ring { animation: pulse 1.1s ease-out infinite; box-shadow: 0 0 0 calc(var(--lvl, 0) * 14px) rgba(255, 90, 54, .35); }
.mic.busy { opacity: .6; pointer-events: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 54, .5); }
  100% { box-shadow: 0 0 0 16px rgba(255, 90, 54, 0); }
}

/* ---------- Barre centrale ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: var(--ink);
  color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand b { color: var(--coral); font-weight: 800; }
.bar-actions { display: flex; gap: 6px; }
.bar .icon-btn { width: 36px; height: 36px; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: .92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

[dir="rtl"] { unicode-bidi: plaintext; }

@media (min-width: 720px) {
  .side { padding: 16px max(16px, calc(50% - 320px)); }
}
