/* Chat: header, messages, composer. The screen is pinned to the visible viewport so the keyboard never covers the composer. */
.chat {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vvt, 0);
  height: var(--vvh, 100dvh);
  max-width: 560px;
  margin: 0 auto;
  padding: 0;
  gap: 0;
  overflow: hidden;
  background: var(--bg);
}
.chathead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px calc(14px + env(safe-area-inset-left));
  padding-top: calc(6px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}
.dot.on {
  background: var(--ok);
}
.langbtn {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 1.02rem;
  text-align: left;
  border-radius: 14px;
  padding: 0 6px;
}
.langbtn .ln {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.langbtn .arrows {
  color: var(--dim);
}
.netbar {
  background: var(--accent-soft);
  color: var(--accent-text);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
}
.msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  padding: 14px 12px;
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 88%;
  border-radius: 24px;
  padding: 10px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-wrap: anywhere;
}
.msg.cont {
  margin-top: -8px;
}
.msg.theirs {
  align-self: flex-start;
  background: var(--panel2);
  border-bottom-left-radius: 8px;
}
.msg.mine {
  align-self: flex-end;
  background: var(--mine);
  color: var(--on-mine);
  border-bottom-right-radius: 8px;
}
.msg.local {
  opacity: 0.85;
}
.msg .line {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: -8px;
}
.msg .line > :first-child {
  flex: 1;
  min-width: 0;
}
.msg .orig {
  font-size: 1.05rem;
}
.msg.mine .orig {
  font-size: 1.3rem;
  font-weight: 600;
}
.msg .orig.solo {
  font-size: 1.5rem;
  font-weight: 700;
}
.msg .roman {
  font-size: 1.02rem;
  color: var(--roman);
  font-style: italic;
}
.msg.mine .roman {
  color: var(--roman-mine);
}
.msg .tr {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
}
.msg .lab {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}
.msg.mine .lab {
  color: var(--mine-dim);
}
.badge-detected {
  margin-left: 8px;
  text-transform: none;
  letter-spacing: 0;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 8px;
}
.msg .sent {
  border-top: 1px solid rgba(127, 127, 127, 0.35);
  margin-top: 6px;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg.mine .sent .tr {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--mine-dim);
}
.msg .err {
  color: var(--bad);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 0.92rem;
}
.msg.mine .err {
  color: #ffd9d4;
}
.msg .err .ib {
  color: inherit;
  border: 1px solid currentColor;
}
.pending {
  color: var(--dim);
  font-style: italic;
  font-size: 0.95rem;
}
.msg.mine .pending {
  color: var(--mine-dim);
}
.msg .meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--dim);
  min-height: 18px;
}
.msg.mine .meta {
  color: var(--mine-dim);
}
.tick svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}
.tick.done {
  color: #fff;
}
.msg .acts {
  display: none;
  gap: 4px;
  justify-content: flex-end;
  margin: 0 -8px;
}
.msg.open .acts {
  display: flex;
}
.msg.mine .ib,
.msg.mine .acts .ib {
  color: var(--mine-dim);
}
.msg.typing {
  flex-direction: row;
  gap: 5px;
  padding: 14px 16px;
  align-items: center;
}
.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}
.sys {
  align-self: center;
  color: var(--dim);
  font-size: 0.85rem;
  text-align: center;
  padding: 2px 10px;
}
.sys.stamp {
  font-size: 0.75rem;
}
.jump {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--composer-h, 72px) + 14px);
  z-index: 5;
  min-height: var(--tap);
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.jump[hidden] {
  display: none;
}
.quick {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px 2px;
  scrollbar-width: none;
}
.quick[hidden] {
  display: none;
}
.quick::-webkit-scrollbar {
  display: none;
}
.qbtn {
  flex: 0 0 auto;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 1.02rem;
  font-weight: 600;
  white-space: nowrap;
}
.composer-wrap {
  background: var(--bg);
  border-top: 1px solid transparent;
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  padding-left: calc(10px + env(safe-area-inset-left));
  padding-right: calc(10px + env(safe-area-inset-right));
}
.kb .composer {
  padding-bottom: 10px;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  border-radius: 26px;
  border: 2px solid var(--line);
  background: var(--input);
  padding: 11px 16px;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--text);
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent-text);
}
.composer .ib {
  min-width: 48px;
  min-height: 48px;
  background: var(--panel2);
  color: var(--text);
}
.composer .ib.primary-ib {
  background: var(--accent);
  color: var(--on-accent);
}
.composer .ib.mic.on {
  background: var(--bad-bg);
  color: var(--bad);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 0 8px transparent;
  }
  0% {
    box-shadow: 0 0 0 0 var(--bad-line);
  }
}
.flash {
  animation: flash 0.6s;
}
@keyframes flash {
  0% {
    box-shadow: inset 0 0 0 6px var(--accent);
  }
  100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
}
/* big view */
.big-view {
  background: var(--bg);
  align-items: stretch;
  flex-direction: column;
  padding: env(safe-area-inset-top) 18px calc(18px + env(safe-area-inset-bottom));
  z-index: 55;
}
.big-view > .ib {
  align-self: flex-end;
  margin-top: 8px;
}
.big-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  text-align: center;
  overflow-y: auto;
}
.big-text {
  margin: 0;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.big-roman {
  margin: 0;
  font-size: 1.5rem;
  font-style: italic;
  color: var(--roman);
}
.big-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.big-bar .ib {
  background: var(--panel2);
  color: var(--text);
  min-height: 52px;
  padding: 0 20px;
  font-size: 1rem;
}

/* Join code in the chat header: compact, easy to tap and copy on a phone. */
.joincode {
  flex: none;
  min-height: var(--tap);
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  line-height: 1;
}
.joincode:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.rejoin-hint {
  margin: 0;
  padding: 4px 12px 6px;
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  font-size: 0.78rem;
  color: var(--dim);
  text-align: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
