/* v04: the thread, bubbles, typing dots, the composer (replies, picks, the gate) */
.app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--bg);
}
.app.is-opening { animation: appIn .6s var(--ease) both; }
@keyframes appIn { from { opacity: 0; transform: translateY(40px); } }

/* header */
.top {
  position: relative; z-index: 3;
  padding: calc(var(--sat) + 10px) 16px 10px;
  background: rgba(248, 248, 250, .96);
  border-bottom: 1px solid var(--line);
  display: grid; justify-items: center;
}
.top__who { display: grid; justify-items: center; gap: 3px; }
.top__name { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; }
.top__name svg { color: var(--ink-3); }
.top__status { font-size: 12px; color: var(--ink-2); min-height: 16px; transition: color .3s; }
.top__status.is-typing { color: var(--out); }
.top__mute {
  position: absolute; right: 10px; top: calc(var(--sat) + 16px);
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--out);
}
.top__mute:active { transform: scale(.92); }
.top__bar { position: absolute; left: 16px; right: 16px; bottom: -1px; display: flex; gap: 4px; height: 3px; }
.top__bar i { flex: 1; border-radius: 2px; background: rgba(27, 124, 255, .14); position: relative; overflow: hidden; }
.top__bar i::after { content: ''; position: absolute; inset: 0; background: var(--out); transform: scaleX(0); transform-origin: left; transition: transform .7s var(--ease); }
.top__bar i.on::after { transform: scaleX(1); }
.top__bar i.ok::after { background: var(--green); }

/* thread */
.thread {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 18px;
  display: flex; flex-direction: column;
}
.thread > :first-child { margin-top: auto; }
.stamp { align-self: center; margin: 4px 0 12px; font-size: 11px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; }
.stamp b { color: var(--ink-2); font-weight: 600; }

.row { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; max-width: 100%; }
.row.in { padding-right: 40px; }
.row.out { justify-content: flex-end; padding-left: 56px; }
.row.in + .row.out, .row.out + .row.in, .row + .row.gapped { margin-top: 12px; }
.row .av { --s: 28px; visibility: hidden; }
.row.in.last .av { visibility: visible; }
.row.out .av { display: none; }
.row.wide { padding-right: 8px; }
.row.pop > .b, .row.pop > .card, .row.pop > .vb, .row.pop > .clipb { animation: pop .42s var(--spring) both; }
.row.in.pop > * { transform-origin: 0 100%; }
.row.out.pop > * { transform-origin: 100% 100%; }
@keyframes pop { from { opacity: 0; transform: scale(.6) translateY(10px); } }

.b {
  position: relative;
  max-width: 100%;
  padding: 8px 13px 9px;
  border-radius: 19px;
  font-size: 16.5px; line-height: 1.32;
  overflow-wrap: anywhere;
}
.b.in { background: var(--in); color: var(--ink); }
.b.out { background: var(--out); color: #fff; }
.b.big { font-size: 34px; line-height: 1.1; padding: 4px 6px; background: none !important; }
.b.big::before, .b.big::after { display: none; }
.b.muted { background: #f1f1f3; color: var(--ink-2); font-style: italic; }
.b strong { font-weight: 700; }
/* bubble tails (last bubble of a group) */
.row.last > .b.in::before, .row.last > .b.out::before { content: ''; position: absolute; bottom: 0; height: 18px; width: 18px; }
.row.last > .b.in::after, .row.last > .b.out::after { content: ''; position: absolute; bottom: 0; height: 18px; width: 10px; background: var(--bg); }
.row.last > .b.in::before { left: -6px; background: var(--in); border-bottom-right-radius: 14px; }
.row.last > .b.in::after { left: -10px; border-bottom-right-radius: 9px; }
.row.last > .b.out::before { right: -6px; background: var(--out); border-bottom-left-radius: 14px; }
.row.last > .b.out::after { right: -10px; border-bottom-left-radius: 9px; }
.row.last > .b.muted::before { background: #f1f1f3; }

/* tapback: the coach reacts to your reply */
.tb {
  position: absolute; top: -18px; left: -22px;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px;
  background: var(--in); border: 3px solid var(--bg);
  animation: tb .5s var(--spring) both;
}
@keyframes tb { from { opacity: 0; transform: scale(.2) rotate(-30deg); } }

.delivered { align-self: flex-end; font-size: 11px; color: var(--ink-3); font-weight: 600; margin: 3px 4px 0; animation: fade .4s both .2s; }
@keyframes fade { from { opacity: 0; } }

/* typing dots */
.b.typing { padding: 12px 14px; display: inline-flex; gap: 5px; }
.b.typing i { width: 8px; height: 8px; border-radius: 50%; background: #8e8e93; animation: dot 1.1s infinite ease-in-out; }
.b.typing i:nth-child(2) { animation-delay: .15s; }
.b.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* the moment's video bubble (the live 3D frame shows through it, see stage.css) */
.vb {
  position: relative; display: block; padding: 0; border: 0; cursor: pointer;
  width: min(66vw, 250px); aspect-ratio: 3 / 4;
  border-radius: 20px; overflow: hidden;
  background: #0d1424;
  color: #fff;
}
.vb.is-wait::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .12) 50%, transparent 70%) #16213a;
  background-size: 220% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0; } }
.vb.is-played { cursor: default; aspect-ratio: 16 / 10; width: min(56vw, 210px); }
.vb.is-played { background: linear-gradient(160deg, #0d1b33, #1b3a6e); }
.vb__art { position: absolute; inset: 0; width: 100%; height: 100%; }
.vb__you { position: absolute; left: 12px; top: 11px; right: 12px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .75); text-align: left; }
.vb__tag {
  position: absolute; left: 10px; bottom: 10px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(0, 0, 0, .55); color: #fff;
}
.vb__tag.ok { background: var(--green); }
.vb__tag.no { background: rgba(255, 255, 255, .92); color: var(--ink); }

/* the real clip, sent as a video message */
.clipb {
  position: relative; width: min(78vw, 330px); aspect-ratio: 16 / 9;
  border-radius: 20px; overflow: hidden; background: #000; border: 0; padding: 0; cursor: pointer; display: block;
}
.clipb video, .clipb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clipb__label {
  position: absolute; left: 8px; top: 8px; padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em; color: #fff; background: rgba(0, 0, 0, .55);
}
.clipb__label::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 6px; vertical-align: 1px; }
.clipb__replay {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .3s;
  background: rgba(0, 0, 0, .35); color: #fff; font-weight: 700; font-size: 14px;
}
.clipb.is-ended .clipb__replay { opacity: 1; }
.clipb__bar { position: absolute; left: 0; bottom: 0; height: 3px; background: #fff; width: 0; }

/* ---------- composer ---------- */
.composer {
  position: relative; z-index: 3;
  padding: 10px 12px calc(var(--sab) + 12px);
  background: rgba(248, 248, 250, .97);
  border-top: 1px solid var(--line);
  min-height: calc(var(--sab) + 66px);
  display: grid; gap: 8px;
}
.composer > * { animation: up .38s var(--ease) both; }
@keyframes up { from { opacity: 0; transform: translateY(14px); } }
.hint { margin: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 500; text-align: center; }
.hint .arr { display: inline-block; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-4px); } }
.hint.is-typing { color: var(--ink-3); }

.reply {
  width: 100%; min-height: 54px; border: 0; border-radius: 27px; cursor: pointer;
  background: var(--out); color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 22px;
  box-shadow: 0 6px 18px rgba(27, 124, 255, .3);
  transition: transform .15s var(--ease), background .2s;
}
.reply:active { transform: scale(.97); }
.reply .send { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: grid; place-items: center; }
.reply.is-done .send { display: none; }
.reply.is-done { background: var(--green); box-shadow: 0 6px 18px rgba(34, 197, 94, .3); cursor: default; }

.picks-q { margin: 0; font-size: 13px; color: var(--ink-2); font-weight: 600; text-align: center; }
.picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.picks button {
  min-height: 50px; border-radius: 16px; border: 1.5px solid rgba(27, 124, 255, .3); cursor: pointer;
  background: #fff; color: var(--out); font-weight: 800; font-size: 19px;
  transition: transform .15s var(--spring), background .15s, color .15s;
  animation: up .4s var(--spring) both; animation-delay: calc(var(--k) * 25ms);
}
.picks button:active, .picks button.is-on { transform: scale(.92); background: var(--out); color: #fff; }
.picks-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); padding: 0 4px; font-weight: 600; }

/* gate: the two fields as reply bubbles */
.gate { display: grid; gap: 8px; }
.field {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 16px; border-radius: 26px;
  background: #fff; border: 1.5px solid #d5d8de; transition: border-color .2s, box-shadow .2s;
}
.field:focus-within { border-color: var(--out); box-shadow: 0 0 0 4px rgba(27, 124, 255, .12); }
.field.is-bad { border-color: var(--red); animation: shake .4s; }
.field__icon { flex: none; color: var(--ink-3); font-weight: 700; font-size: 17px; width: 20px; text-align: center; }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 500 17px var(--font); color: var(--ink); padding: 12px 0; }
.field input::placeholder { color: var(--ink-3); }
.err { margin: -2px 16px 0; font-size: 13px; color: var(--red); font-weight: 600; }
.err:empty { display: none; }
.gate__note { margin: 0; text-align: center; font-size: 12px; color: var(--ink-3); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* desktop: the thread as a window on a quiet page */
@media (min-width: 900px) {
  body { background: radial-gradient(90% 80% at 50% 0%, #f7f8fb 0%, #dfe3ea 100%); }
  body::before {
    content: ''; position: fixed; inset: 0; pointer-events: none; opacity: .5;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1440' height='900' viewBox='0 0 1440 900'%3E%3Cg fill='none' stroke='%23c3cad6' stroke-width='2'%3E%3Crect x='60' y='60' width='1320' height='780' rx='6'/%3E%3Cline x1='720' y1='60' x2='720' y2='840'/%3E%3Ccircle cx='720' cy='450' r='120'/%3E%3Crect x='60' y='250' width='190' height='400'/%3E%3Crect x='1190' y='250' width='190' height='400'/%3E%3C/g%3E%3C/svg%3E") center / cover no-repeat;
  }
  .app { top: 24px; bottom: 24px; max-width: 600px; border-radius: 28px; overflow: hidden; box-shadow: 0 30px 80px rgba(20, 30, 50, .22), 0 0 0 1px rgba(20, 30, 50, .06); }
  .thread { padding: 18px 22px 22px; }
  .vb { width: 270px; }
  .vb.is-played { width: 250px; }
  .clipb { width: 380px; }
  .composer > * { width: 100%; max-width: 480px; justify-self: center; }
}
