/* App shell — the production chat experience. Distinct from the marketing
   pages on purpose: system sans, full viewport, docked composer. */
:root {
  --bg: #f3efe7;
  --thread-bg: #faf6ef;
  --bar: #faf6efee;
  --ink: #221c19;
  --ink-soft: #6d635c;
  --line: #ddd2c2;
  --me: #b4552f;
  --me-ink: #ffffff;
  --them: #ffffff;
  --prv: #efe7d8;
  --accent: #b4552f;
  --good: #2e7d5b;
  --warn: #b98b1f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100d0b;
    --thread-bg: #171310;
    --bar: #171310ee;
    --ink: #ece5dc;
    --ink-soft: #a89e94;
    --line: #382f27;
    --me: #b4552f;
    --me-ink: #fff7f2;
    --them: #241e19;
    --prv: #1d1813;
    --accent: #e08055;
    --good: #5cc496;
    --warn: #d8a83a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}
#app {
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--thread-bg);
  box-shadow: 0 0 40px rgb(0 0 0 / 8%);
}

/* ---- top bar ---- */
.bar {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.9rem calc(0.6rem);
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  background: var(--bar); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--me); color: var(--me-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.bar-name { font-weight: 650; }
.bar-sub { font-size: 0.75rem; color: var(--ink-soft); }
.bar-spacer { flex: 1; }
.bar-btn {
  font: inherit; background: none; border: none; color: var(--ink-soft);
  font-size: 1.15rem; cursor: pointer; padding: 0.3rem 0.5rem;
}

/* ---- thread ---- */
.thread {
  flex: 1; overflow-y: auto; padding: 0.9rem 0.9rem 0.4rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  scroll-behavior: smooth;
}
.msg { display: flex; gap: 0.5rem; max-width: 86%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 26px; height: 26px; font-size: 0.7rem; align-self: flex-end; }
.blb {
  padding: 0.5rem 0.75rem; border-radius: 16px;
  border-bottom-left-radius: 5px;
  background: var(--them); border: 1px solid var(--line);
  animation: pop 0.22s ease;
}
.msg.me .blb {
  background: var(--me); color: var(--me-ink); border: none;
  border-radius: 16px; border-bottom-right-radius: 5px;
}
.meta { font-size: 0.68rem; color: var(--ink-soft); margin-top: 0.25rem; }
.msg.me .meta { color: var(--me-ink); opacity: 0.75; }
/* The native-language text always rides with the target-language message —
   every message lives in both languages. */
.gloss { font-size: 0.85rem; opacity: 0.85; margin-top: 0.3rem; font-style: italic; }
.blb .g-btn {
  font: inherit; font-size: 0.72rem; background: none; border: none;
  color: inherit; opacity: 0.8; cursor: pointer; padding: 0.15rem 0; display: block;
}

/* private (coach / practice) items */
.prv-wrap { align-self: stretch; display: flex; flex-direction: column; gap: 0.35rem; }
.prv-label {
  font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); text-align: center;
}
.prv-msg {
  background: var(--prv); border: 1px dashed var(--line); border-radius: 12px;
  padding: 0.45rem 0.7rem; font-size: 0.92rem; align-self: flex-start; max-width: 86%;
  animation: pop 0.22s ease;
}
.prv-msg.mine { align-self: flex-end; }
.card {
  background: var(--prv); border: 1px dashed var(--line);
  border-radius: 14px; padding: 0.8rem 0.9rem; animation: pop 0.22s ease;
}
.card .big { font-size: 1.15rem; font-weight: 650; }
.respell { color: var(--accent); font-size: 0.95rem; margin: 0.15rem 0 0.5rem; }
.tips { margin: 0.3rem 0 0.5rem; padding-left: 1.1rem; color: var(--ink-soft); font-size: 0.85rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.4rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; }
.chip { padding: 0.1rem 0.45rem; border-radius: 7px; font-size: 0.88rem; background: var(--them); border: 1px solid var(--line); }
.chip.match { background: color-mix(in srgb, var(--good) 25%, transparent); border-color: transparent; }
.chip.close { background: color-mix(in srgb, var(--warn) 28%, transparent); border-color: transparent; }
.chip.missed { background: color-mix(in srgb, var(--accent) 28%, transparent); border-color: transparent; text-decoration: line-through; }
.tip-line { font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.3rem; }
.pass-line { color: var(--good); font-weight: 650; margin-top: 0.3rem; }
.sys { align-self: center; text-align: center; color: var(--ink-soft); font-size: 0.8rem; max-width: 90%; }

/* typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 0.6rem 0.8rem; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---- composer ---- */
.composer {
  flex-shrink: 0; border-top: 1px solid var(--line); background: var(--bar);
  backdrop-filter: blur(8px);
  padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom));
  display: flex; gap: 0.5rem; align-items: flex-end;
}
.composer textarea {
  flex: 1; resize: none; max-height: 110px; min-height: 40px;
  font: inherit; color: var(--ink); background: var(--them);
  border: 1px solid var(--line); border-radius: 20px; padding: 0.55rem 0.9rem;
  outline: none;
}
.icon-btn {
  font: inherit; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--them); color: var(--ink);
  font-size: 1.15rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.primary { background: var(--me); border-color: var(--me); color: var(--me-ink); }
.icon-btn.live { background: var(--accent); border-color: var(--accent); color: #fff; animation: pulse 1.1s infinite; }
.icon-btn:disabled { opacity: 0.45; cursor: default; }
@keyframes pulse { 50% { opacity: 0.6; } }
.listen-hint {
  position: absolute; bottom: calc(70px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--prv); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.5rem 0.9rem; font-size: 0.85rem; max-width: 85%; text-align: center;
  box-shadow: 0 4px 18px rgb(0 0 0 / 15%);
}
.listen-hint .interim { color: var(--accent); font-style: italic; min-height: 1.2em; }
#app { position: relative; }

/* ---- buttons in cards ---- */
.btn {
  font: inherit; font-size: 0.9rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--them); color: var(--ink);
  border-radius: 10px; padding: 0.45rem 0.9rem; cursor: pointer;
}
.btn.primary { background: var(--me); border-color: var(--me); color: var(--me-ink); }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---- onboarding (partner list) ---- */
.onboard { flex: 1; overflow-y: auto; padding: 1.1rem 1rem 6rem; }
.onboard h1 { font-size: 1.3rem; margin: 0.4rem 0 0.2rem; }
.onboard .sub { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 1rem; }
.contact {
  display: flex; gap: 0.8rem; align-items: center; width: 100%; text-align: left;
  background: var(--them); border: 1px solid var(--line); border-radius: 14px;
  padding: 0.7rem 0.85rem; margin-bottom: 0.55rem; cursor: pointer; font: inherit; color: var(--ink);
}
.contact.sel { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.contact.dim { opacity: 0.55; cursor: default; }
.contact .c-name { font-weight: 650; }
.contact .c-home { font-size: 0.78rem; color: var(--ink-soft); }
.contact .c-tag { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.15rem; }
.c-diff {
  margin-left: auto; flex-shrink: 0; font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.06em; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.14rem 0.5rem; color: var(--ink-soft);
}
.c-diff.spirited { color: var(--accent); border-color: var(--accent); }
.onboard-cta {
  position: sticky; bottom: 0; padding: 0.8rem 0 calc(0.4rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--thread-bg) 35%);
  display: flex; gap: 0.6rem; align-items: center;
}
.onboard-cta .btn { flex: 1; padding: 0.75rem; font-size: 1rem; }
.mini-note { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.7rem; }

/* ---- info sheet ---- */
.sheet-back {
  position: absolute; inset: 0; background: rgb(0 0 0 / 45%);
  display: flex; align-items: flex-end; z-index: 10;
}
.sheet {
  background: var(--thread-bg); width: 100%; border-radius: 18px 18px 0 0;
  padding: 1.1rem 1.1rem calc(1.3rem + env(safe-area-inset-bottom));
  max-height: 80%; overflow-y: auto;
}
.sheet h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }
.sheet p { font-size: 0.88rem; color: var(--ink-soft); margin: 0.4rem 0; }
.sheet .row { margin-top: 0.9rem; }
