* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(79,140,255,.10), transparent 60%),
    #0b0d12;
  color: #e8eaf0;
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; font-size: 13px; color: #8b93a1;
}
#status { display: flex; align-items: center; gap: 8px; letter-spacing: .02em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6b7280; transition: background .3s; }
.dot.ok { background: #34d399; box-shadow: 0 0 10px rgba(52,211,153,.7); }
.dot.busy { background: #fbbf24; animation: pulse 1s infinite; }
.dot.err { background: #f87171; box-shadow: 0 0 10px rgba(248,113,113,.6); }
@keyframes pulse { 50% { opacity: .35; } }

.hbtns { display: flex; gap: 8px; }
#muteBtn, #outBtn {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 8px; color: #c7cdd8; cursor: pointer;
  transition: color .2s, transform .15s;
}
#muteBtn:active, #outBtn:active { transform: scale(.92); }

#outSheet {
  position: absolute; top: 54px; right: 14px; z-index: 10;
  min-width: 230px; max-width: 85vw;
  background: #171a21; border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: floatIn .25s cubic-bezier(.22,1,.36,1) both;
}
.sheetTitle {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: #8b93a1; padding: 6px 10px 8px;
}
.outItem {
  display: block; width: 100%; text-align: left;
  padding: 11px 12px; margin-bottom: 2px;
  font-size: 14px; color: #e8eaf0;
  background: none; border: none; border-radius: 10px; cursor: pointer;
}
.outItem:hover, .outItem:active { background: rgba(255,255,255,.06); }
.outItem.sel { background: rgba(79,140,255,.15); color: #9db9ff; }
#muteBtn.muted { color: #f87171; }
#muteBtn.muted .wave { opacity: 0; }
#muteBtn.muted .mute-line { display: inline !important; }
.wave { transition: opacity .25s; }
.w2 { animation: fadeWave 2.4s ease-in-out infinite; }
@keyframes fadeWave { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- auto badge ---------- */
#autoBadge {
  align-self: center; margin: 0 auto 10px;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; font-size: 14px; font-weight: 700; letter-spacing: .06em;
  color: #c7cdd8;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
}
#autoBadge svg { color: #5b8dff; animation: swapPulse 3s ease-in-out infinite; }
@keyframes swapPulse { 0%,100% { transform: none; } 50% { transform: scale(1.15); } }
.autoTag {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em;
  color: #34d399; background: rgba(52,211,153,.12);
  border: 1px solid rgba(52,211,153,.3);
  padding: 3px 8px; border-radius: 999px;
}

/* ---------- feed ---------- */
main#feed {
  flex: 1; overflow-y: auto; padding: 6px 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
#empty {
  margin: auto; text-align: center; color: #59606d;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: floatIn .6s ease both;
}
#empty p { font-size: 14px; line-height: 1.5; }
#empty svg { opacity: .5; }

.msg {
  max-width: 88%; padding: 11px 15px; border-radius: 18px; line-height: 1.4;
  animation: floatIn .35s cubic-bezier(.22,1,.36,1) both;
}
@keyframes floatIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.msg .tr { font-size: 17px; }
.origBtn {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px; padding: 3px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: rgba(232,234,240,.55);
  background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; cursor: pointer;
  transition: color .2s, background .2s;
}
.origBtn:active { background: rgba(0,0,0,.35); }
.origBtn svg { transition: transform .3s cubic-bezier(.22,1,.36,1); }
.msg.showOrig .origBtn svg { transform: rotate(180deg); }
.msg .src {
  font-size: 13px; color: rgba(232,234,240,.6);
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .35s cubic-bezier(.22,1,.36,1), opacity .3s, margin .3s;
}
.msg.showOrig .src { max-height: 200px; opacity: 1; margin-top: 6px; }
.msg.me {
  align-self: flex-end; border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, #2450c9, #3b6ff0);
  box-shadow: 0 4px 16px rgba(59,111,240,.25);
}
.msg.her {
  align-self: flex-start; border-bottom-left-radius: 5px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.06);
}
.msg.partial .tr::after {
  content: ''; display: inline-block; width: 7px; height: 16px; margin-left: 4px;
  background: currentColor; opacity: .6; vertical-align: text-bottom;
  animation: blink .9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- voice visualizer ---------- */
#viz {
  display: flex; justify-content: center; align-items: center; gap: 5px;
  height: 30px; opacity: 0; transition: opacity .3s;
}
#viz.on { opacity: 1; }
#viz span {
  width: 4px; height: 6px; border-radius: 3px;
  background: linear-gradient(#5b8dff, #34d399);
  transition: height .1s ease;
}
#viz.on span { animation: bar 1s ease-in-out infinite; }
#viz span:nth-child(1) { animation-delay: 0s; }
#viz span:nth-child(2) { animation-delay: .15s; }
#viz span:nth-child(3) { animation-delay: .3s; }
#viz span:nth-child(4) { animation-delay: .45s; }
#viz span:nth-child(5) { animation-delay: .3s; }
#viz span:nth-child(6) { animation-delay: .15s; }
#viz span:nth-child(7) { animation-delay: 0s; }
@keyframes bar { 0%,100% { height: 6px; } 50% { height: 24px; } }

/* ---------- mic button ---------- */
footer { padding: 8px 0 20px; text-align: center; }
#micWrap { position: relative; display: inline-block; }
.ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(239,68,68,.5); opacity: 0; pointer-events: none;
}
#micWrap.rec .r1 { animation: ripple 1.6s ease-out infinite; }
#micWrap.rec .r2 { animation: ripple 1.6s ease-out .8s infinite; }
@keyframes ripple {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.9); opacity: 0; }
}
#micBtn {
  touch-action: none; user-select: none; -webkit-user-select: none;
  position: relative; width: 92px; height: 92px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #3b6ff0, #5b8dff);
  box-shadow: 0 8px 28px rgba(79,140,255,.4), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s, background .3s, box-shadow .3s;
}
#micBtn:active { transform: scale(.93); }
#micWrap.rec #micBtn {
  background: linear-gradient(145deg, #dc2626, #ef4444);
  box-shadow: 0 8px 28px rgba(239,68,68,.45), inset 0 1px 0 rgba(255,255,255,.25);
}
#micHint { margin-top: 10px; font-size: 13px; color: #8b93a1; transition: color .3s; }
#micWrap.rec + #micHint { color: #f0a5a5; }
