/* style.css — RAT CORPS dark neon theme.
   Mobile-first (390px baseline); desktop centers the app as a 520px max-width
   panel over a dark backdrop. Per-agent color is set via --c/--glow on
   elements that need it (avatars, chips, cards). */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&family=Rajdhani:wght@500;600;700&display=swap');

:root {
  --bg: #04040c;
  --panel: rgba(255,255,255,0.035);
  --panel-strong: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.08);
  --text: #dde2f0;
  --muted: #6a6a88;
  --muted-2: #4a4a65;
  --purple: #9333ea;
  --purple-2: #a855f7;
  --emerald: #10b981;
  --amber: #f59e0b;
  --cyan: #22d3ee;
  --red: #ef4444;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --topbar-h: 58px;
  --tabbar-h: 62px;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 45% at 15% 10%, rgba(120,40,200,0.14) 0%, transparent 65%),
    radial-gradient(ellipse 55% 40% at 90% 85%, rgba(16,185,129,0.09) 0%, transparent 65%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 60px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 60px);
  font-family: 'Rajdhani', system-ui, sans-serif;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

@media (min-width: 560px) {
  body { align-items: flex-start; padding: 24px 0; }
}

button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--purple-2); }
button { cursor: pointer; }

.mono { font-family: 'Share Tech Mono', monospace; }
.orbitron { font-family: 'Orbitron', sans-serif; }

/* ── APP SHELL ─────────────────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(10,8,20,0.4), transparent 200px);
  overflow: hidden;
}

@media (min-width: 560px) {
  #app {
    min-height: calc(100dvh - 48px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 40px 120px rgba(0,0,0,0.6), 0 0 80px rgba(147,51,234,0.08);
  }
}

/* ── TOP BAR ───────────────────────────────────────────────────────────── */
.topbar {
  flex-shrink: 0;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: max(12px, var(--safe-l));
  padding-right: max(12px, var(--safe-r));
  background: rgba(6,6,16,0.75);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 12px;
  color: var(--text); font-size: 1.15rem;
  transition: background .2s;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--panel-strong); }

.topbar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.topbar-title .name {
  font-family: 'Orbitron', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title .name[contenteditable="true"] {
  outline: none; border-bottom: 1px dashed var(--purple-2);
}
.topbar-title .sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: .58rem;
  color: var(--muted);
  letter-spacing: .08em;
}

.health-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 6px var(--muted-2);
  flex-shrink: 0;
}
.health-led.ok { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); animation: pulse-led 2s infinite; }
.health-led.down { background: var(--red); box-shadow: 0 0 8px var(--red); }

@keyframes pulse-led { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.participants-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px max(12px, var(--safe-l)) 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(6,6,16,0.55);
  border-bottom: 1px solid var(--border);
}
.participants-strip::-webkit-scrollbar { display: none; }

.p-avatar {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--c, var(--purple));
  overflow: hidden;
  background: #0a0a14;
  animation: avatar-in .45s cubic-bezier(.22,.68,0,1.35);
}
.p-avatar img { width: 100%; height: 100%; object-fit: cover; }
.p-avatar.orchestrator { box-shadow: 0 0 0 2px rgba(147,51,234,.25); }
.p-avatar.orchestrator::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--purple-2);
  animation: ring-pulse 2.4s ease-in-out infinite;
}
.p-avatar.leaving { animation: avatar-out .35s forwards; }

@keyframes avatar-in { from { transform: scale(0) translateY(6px); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes avatar-out { to { transform: scale(0); opacity: 0; } }
@keyframes ring-pulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.18); opacity: 0; } }

/* ── TABS (bottom nav) ────────────────────────────────────────────────── */
.tabbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(6,6,16,0.85);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 30;
}
.tab-btn {
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: .62rem;
  font-family: 'Share Tech Mono', monospace;
  letter-spacing: .06em;
  min-height: 44px;
  position: relative;
}
.tab-btn .ic { font-size: 1.25rem; line-height: 1; }
.tab-btn.active { color: var(--purple-2); }
.tab-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--purple), var(--emerald));
}
.tab-btn .dot {
  position: absolute; top: 4px; right: calc(50% - 18px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

/* ── VIEWS ─────────────────────────────────────────────────────────────── */
.view {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.view.active { display: flex; }

/* ── TOASTS ────────────────────────────────────────────────────────────── */
#toasts {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 90; pointer-events: none;
  padding: 0 16px;
}
.toast {
  pointer-events: auto;
  background: rgba(16,16,28,0.95);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple-2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  animation: toast-in .25s cubic-bezier(.22,.68,0,1.3);
  max-width: 100%;
}
.toast.error { border-left-color: var(--red); }
.toast.leaving { animation: toast-out .25s forwards; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-8px); opacity: 0; } }

.offline-banner {
  background: rgba(239,68,68,0.15);
  border-bottom: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-family: 'Share Tech Mono', monospace;
  font-size: .68rem;
  text-align: center;
  padding: 6px 10px;
  letter-spacing: .04em;
  display: none;
}
.offline-banner.show { display: block; }

.install-banner {
  display: none;
  align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(147,51,234,.14), rgba(16,185,129,.1));
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  font-size: .74rem;
  flex-shrink: 0;
  z-index: 31;
}
.install-banner.show {
  display: flex;
  padding-top: max(8px, var(--safe-t));
}
.install-banner.show ~ .topbar {
  height: var(--topbar-h);
  padding-top: 0;
}
.install-banner > span:nth-child(2) { flex: 1; min-width: 0; line-height: 1.25; }
.install-banner button {
  margin-left: auto;
  background: var(--purple); color: #fff; border: none;
  padding: 6px 12px; border-radius: 8px; font-size: .7rem; font-weight: 600;
  flex-shrink: 0;
}
.install-banner .dismiss { background: none; color: var(--muted); padding: 6px; margin-left: 4px; }

/* ═══════════════════════════ CHAT VIEW ═══════════════════════════════════ */
#view-chat { position: relative; }

.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.hero-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 30px 24px;
  gap: 14px;
}
.hero-empty .portrait {
  width: 140px; height: 140px; border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(147,51,234,.4);
  box-shadow: 0 0 60px rgba(147,51,234,.25);
  background: #0a0a14;
  transition: transform .1s ease-out;
}
.hero-empty .portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero-empty h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  background: linear-gradient(120deg, #a855f7, #60a5fa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  max-width: 260px;
}
.quick-pills {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 340px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: .78rem;
  color: var(--text);
  transition: transform .15s, border-color .2s, box-shadow .2s;
  min-height: 40px;
}
.pill:active { transform: scale(.95); }

.choice-pill {
  position: relative;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(147,51,234,0.08);
  border: 1px solid transparent;
  background-image: linear-gradient(rgba(10,8,20,.9), rgba(10,8,20,.9)), linear-gradient(120deg, var(--purple-2), var(--emerald));
  background-origin: border-box;
  background-clip: padding-box, border-box;
  min-height: 40px;
  transition: transform .12s, box-shadow .2s;
}
.choice-pill:active { transform: scale(.94); box-shadow: 0 0 20px rgba(147,51,234,.4); }
.choice-pill:disabled { opacity: .45; }
.choice-pill.selected { box-shadow: 0 0 0 2px var(--purple-2), 0 0 24px rgba(147,51,234,.5); opacity: 1; }
.choices-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* message row */
.msg-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.msg-mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--c, var(--purple));
  overflow: hidden; background: #0a0a14;
}
.msg-mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-col { display: flex; flex-direction: column; max-width: 78%; gap: 3px; }
.msg-row.user .msg-col { align-items: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  position: relative;
}
.msg-row.user .bubble {
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-row.assistant .bubble {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-row.assistant .bubble.alert {
  border-left: 3px solid var(--amber);
  background: rgba(245,158,11,0.08);
}
.msg-row.assistant .bubble.error {
  border-left: 3px solid var(--red);
  background: rgba(239,68,68,0.08);
}

.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 6px 18px; }
.bubble .md-code {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  font-family: 'Share Tech Mono', monospace;
  font-size: .76rem;
  margin: 6px 0;
}
.bubble code {
  font-family: 'Share Tech Mono', monospace;
  background: rgba(0,0,0,0.35);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .84em;
}

.msg-meta {
  display: flex; align-items: center; gap: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: .6rem;
  color: var(--muted);
  padding: 0 4px;
}
.msg-meta .ticker.seen { color: var(--cyan); }
.msg-meta .ticker.done { color: var(--emerald); }
.msg-meta .tts-btn { background: none; border: none; color: var(--muted); font-size: .85rem; padding: 2px 4px; }
.msg-meta .retry-btn {
  background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.35);
  border-radius: 6px; padding: 3px 8px; font-size: .62rem;
}

.typing-bubble { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.typing-bubble .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--purple-2);
  animation: typing-bounce 1.1s infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: .15s; }
.typing-bubble .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.activity-line {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px;
}
.chip {
  font-family: 'Share Tech Mono', monospace;
  font-size: .62rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.chip.error { color: #fca5a5; border-color: rgba(239,68,68,.3); }
.chip.subagent { color: var(--emerald); }
.activity-toggle {
  background: none; border: none; color: var(--muted); font-family: 'Share Tech Mono', monospace;
  font-size: .62rem; padding: 2px 4px;
}

/* ── COMPOSER ──────────────────────────────────────────────────────────── */
.composer-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: rgba(6,6,16,0.85);
  backdrop-filter: blur(14px);
  padding: 8px 10px;
}
.composer {
  display: flex; align-items: flex-end; gap: 8px;
}
.composer textarea {
  flex: 1;
  resize: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 11px 16px;
  font-size: .92rem;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.3;
}
.composer textarea:focus { outline: none; border-color: var(--purple-2); }
.composer button.round {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; font-size: 1.1rem;
}
.mic-btn { background: var(--panel-strong); color: var(--text); }
.mic-btn.recording { background: var(--red); color: #fff; animation: mic-pulse 1s infinite; }
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); } 50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } }
.send-btn { background: linear-gradient(135deg, #7c3aed, #9333ea); color: #fff; }
.send-btn:disabled { opacity: .4; }
.send-btn.stop { background: var(--red); }
.voice-toggle-btn.on { color: var(--emerald); }

/* voice room overlay */
.voice-room {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(4,4,12,0.96);
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
}
.voice-room.show { display: flex; }
.voice-orb {
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(168,85,247,.5), rgba(16,185,129,.15) 60%, transparent 75%);
  border: 1px solid rgba(168,85,247,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
  animation: orb-idle 3s ease-in-out infinite;
}
.voice-orb.listening { animation: orb-listen 1.1s ease-in-out infinite; border-color: var(--cyan); }
.voice-orb.speaking { animation: orb-speak .5s ease-in-out infinite alternate; border-color: var(--emerald); }
@keyframes orb-idle { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes orb-listen { 0%,100% { transform: scale(1); box-shadow: 0 0 30px rgba(34,211,238,.3); } 50% { transform: scale(1.1); box-shadow: 0 0 60px rgba(34,211,238,.5); } }
@keyframes orb-speak { from { transform: scale(1); } to { transform: scale(1.12); } }
.voice-room .state-label { font-family: 'Share Tech Mono', monospace; color: var(--muted); letter-spacing: .12em; font-size: .74rem; }
.voice-room .exit-btn {
  background: var(--panel-strong); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 22px; font-size: .82rem; color: var(--text);
}

/* ── AGENT DETAIL SHEET ────────────────────────────────────────────────── */
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 51;
  background: #0a0a16;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + var(--safe-b));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,.68,0,1.1);
  max-height: 82vh;
  overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 14px; }

.agent-card-detail { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.agent-card-detail .portrait {
  width: 130px; height: 130px; border-radius: 18px; overflow: hidden;
  background: #050510; border: 1px solid var(--c, var(--border));
  box-shadow: 0 0 40px var(--glow, transparent);
}
.agent-card-detail .portrait img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.agent-card-detail .badge {
  font-family: 'Orbitron', sans-serif; font-size: .58rem; font-weight: 700;
  background: var(--c); color: #000; padding: 3px 10px; border-radius: 5px; letter-spacing: .2em;
}
.agent-card-detail .name { font-family: 'Orbitron', sans-serif; font-size: 1.05rem; color: var(--c); letter-spacing: .08em; }
.agent-card-detail .class { font-family: 'Share Tech Mono', monospace; font-size: .65rem; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; }
.agent-card-detail .desc { font-size: .8rem; color: rgba(220,226,240,.6); max-width: 280px; }
.agent-card-detail .stats { width: 100%; max-width: 260px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 6px; }
.stat { display: flex; align-items: center; gap: 6px; }
.stat-k { font-family: 'Share Tech Mono', monospace; font-size: .58rem; color: var(--muted); width: 26px; flex-shrink: 0; }
.stat-bar { flex: 1; height: 4px; background: rgba(255,255,255,.07); border-radius: 2px; overflow: hidden; }
.stat-fill { height: 100%; background: var(--c); border-radius: 2px; }
.stat-v { font-family: 'Share Tech Mono', monospace; font-size: .58rem; color: var(--c); width: 26px; text-align: right; }

.sheet .primary-btn {
  width: 100%; margin-top: 16px;
  background: linear-gradient(135deg, #7c3aed, #9333ea); color: #fff;
  border: none; border-radius: 14px; padding: 13px; font-weight: 600; font-size: .88rem;
}
.sheet .danger-btn { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }
.sheet .ghost-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.sheet .btn-row { display: flex; gap: 8px; margin-top: 14px; }
.sheet .btn-row button { flex: 1; border-radius: 14px; padding: 12px; font-size: .84rem; font-weight: 600; border: none; }

/* action sheet list (long-press / swipe actions) */
.action-sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; color: var(--text);
  padding: 13px 6px; font-size: .88rem; border-bottom: 1px solid var(--border);
  text-align: left;
}
.action-sheet-item:last-child { border-bottom: none; }
.action-sheet-item.danger { color: #fca5a5; }

/* ═══════════════════════════ DISCUSSIONS VIEW ═══════════════════════════ */
.disc-header { padding: 10px 14px 6px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 14px;
}
.search-bar input { flex: 1; background: none; border: none; font-size: .88rem; }
.search-bar input:focus { outline: none; }

.chip-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: .72rem; color: var(--muted);
  min-height: 32px;
}
.filter-chip.active { color: var(--text); border-color: var(--purple-2); background: rgba(147,51,234,.12); }
.filter-chip img { width: 16px; height: 16px; border-radius: 50%; }

.conv-list { flex: 1; overflow-y: auto; padding: 6px 10px 90px; }
.conv-item-wrap { position: relative; overflow: hidden; border-radius: 16px; margin-bottom: 8px; }
.conv-item-actions {
  position: absolute; inset: 0; display: flex; justify-content: flex-end; align-items: stretch;
}
.conv-item-actions button {
  width: 64px; border: none; color: #fff; font-size: .68rem; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
}
.conv-item-actions .pin-a { background: #2563eb; }
.conv-item-actions .archive-a { background: #f59e0b; }
.conv-item-actions .delete-a { background: var(--red); }

.conv-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  background: #0c0c18; border: 1px solid var(--border);
  border-radius: 16px; padding: 12px;
  transition: transform .18s;
  touch-action: pan-y;
}
.conv-item .icon-stack { display: flex; flex-shrink: 0; }
.conv-item .icon-stack img {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--bg);
  margin-left: -10px; background: #0a0a14; object-fit: cover;
}
.conv-item .icon-stack img:first-child { margin-left: 0; }
.conv-item .body { flex: 1; min-width: 0; }
.conv-item .title-row { display: flex; align-items: center; gap: 6px; }
.conv-item .title { font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .pin-ic { color: var(--amber); font-size: .7rem; }
.conv-item .preview { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-item .preview mark { background: rgba(147,51,234,.35); color: #fff; border-radius: 3px; }
.conv-item .meta-col { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.conv-item .time { font-family: 'Share Tech Mono', monospace; font-size: .6rem; color: var(--muted); }
.conv-item .unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--purple-2); box-shadow: 0 0 6px var(--purple-2); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: .85rem; }

.fab {
  position: absolute; right: 18px; bottom: calc(18px + var(--tabbar-h) + var(--safe-b));
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  border: none; color: #fff; font-size: 1.6rem;
  box-shadow: 0 10px 30px rgba(147,51,234,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.fab:active { transform: scale(.92); }

.pull-refresh-indicator {
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; color: var(--muted); font-size: .68rem;
  font-family: 'Share Tech Mono', monospace;
  transition: height .15s;
  flex-shrink: 0;
}
.pull-refresh-indicator.show { height: 36px; }

/* ═══════════════════════════ RATS VIEW ══════════════════════════════════ */
.rats-header { padding: 14px 16px 6px; flex-shrink: 0; }
.rats-header .stat-line {
  font-family: 'Share Tech Mono', monospace; font-size: .68rem; color: var(--muted); letter-spacing: .06em;
}
.rats-grid {
  flex: 1; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 12px 14px 90px;
  align-content: start;
}
.rat-card {
  --c: #9333ea; --glow: rgba(147,51,234,.25);
  position: relative;
  width: calc(50% - 6px);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  transition: transform .2s, border-color .2s;
}
.rat-card:active { transform: scale(.97); border-color: var(--c); }
.rat-card .portrait { width: 100%; aspect-ratio: 1; position: relative; background: #08080f; }
.rat-card .portrait img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; padding: 4px 4px 0; }
.rat-card .portrait::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 32%;
  background: linear-gradient(to top, var(--bg), transparent); pointer-events: none;
}
.rat-card .badge {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: var(--c); color: #000; font-family: 'Orbitron', sans-serif;
  font-size: .48rem; font-weight: 700; padding: 3px 7px; border-radius: 4px; letter-spacing: .16em;
}
.rat-card .on-mission {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  width: 8px; height: 8px; border-radius: 50%; background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald); animation: pulse-led 1.6s infinite;
}
.rat-card .info { padding: 9px 10px 12px; border-top: 1px solid var(--border); }
.rat-card .name { font-family: 'Orbitron', sans-serif; font-size: .68rem; font-weight: 700; color: var(--c); letter-spacing: .06em; }
.rat-card .class { font-family: 'Share Tech Mono', monospace; font-size: .5rem; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin: 2px 0 6px; }
.rat-card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; }
.rat-card .stat-k, .rat-card .stat-v { font-size: .46rem; }
.rat-card .stat-bar { height: 3px; }

/* ═══════════════════════════ CRON VIEW ══════════════════════════════════ */
.cron-header { padding: 12px 14px 4px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.cron-header .imm-toggle { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: .68rem; color: var(--muted); }
.cron-list { flex: 1; overflow-y: auto; padding: 8px 14px 90px; display: flex; flex-direction: column; gap: 10px; }

.job-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px;
}
.job-card .row1 { display: flex; align-items: center; gap: 8px; }
.job-card .name { font-weight: 700; font-size: .88rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-card .schedule { font-family: 'Share Tech Mono', monospace; font-size: .68rem; color: var(--muted); margin-top: 3px; }
.job-card .times { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .64rem; color: var(--muted); font-family: 'Share Tech Mono', monospace; }

.status-pill { font-size: .58rem; font-family: 'Share Tech Mono', monospace; padding: 3px 9px; border-radius: 999px; letter-spacing: .06em; flex-shrink: 0; }
.status-pill.ok { background: rgba(16,185,129,.15); color: #6ee7b7; }
.status-pill.error { background: rgba(239,68,68,.15); color: #fca5a5; }
.status-pill.paused { background: rgba(107,107,136,.2); color: var(--muted); }
.status-pill.never { background: rgba(245,158,11,.12); color: #fcd34d; }

.ios-toggle { width: 46px; height: 27px; border-radius: 16px; background: var(--panel-strong); border: 1px solid var(--border); position: relative; flex-shrink: 0; transition: background .2s; }
.ios-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.ios-toggle.on { background: var(--emerald); border-color: var(--emerald); }
.ios-toggle.on::after { transform: translateX(19px); }
.ios-toggle.pending { box-shadow: 0 0 0 2px var(--amber); }

.cron-footer-save {
  position: absolute; left: 14px; right: 14px; bottom: calc(14px + var(--tabbar-h) + var(--safe-b));
  background: linear-gradient(135deg, #7c3aed, #9333ea); color: #fff; border: none; border-radius: 14px;
  padding: 13px; font-weight: 700; font-size: .84rem; z-index: 20;
  box-shadow: 0 10px 30px rgba(147,51,234,.4);
  display: none;
}
.cron-footer-save.show { display: block; }

/* cron form */
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-field label { font-size: .72rem; color: var(--muted); font-family: 'Share Tech Mono', monospace; letter-spacing: .04em; }
.form-field input[type=text], .form-field textarea, .form-field select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font-size: .86rem;
}
.form-field textarea { resize: vertical; min-height: 80px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-row button { background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 6px 11px; font-size: .68rem; color: var(--muted); }
.preset-row button.active { color: var(--text); border-color: var(--purple-2); }

/* ═══════════════════════════ SETTINGS SHEET ═════════════════════════════ */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid var(--border); gap: 10px; }
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-size: .84rem; min-width: 0; flex: 1; }
.settings-row .sub-label { font-size: .64rem; color: var(--muted); margin-top: 2px; }
.settings-row select, .settings-row input[type=text], .settings-row input[type=password] {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: .8rem;
  max-width: 58%; min-width: 0;
}

/* ── Scrollbars (desktop) ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Utility ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex-1 { flex: 1; }

/* ── CALL SCREEN ─────────────────────────────────────────────────────── */
.call-screen { justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 18px max(26px, env(safe-area-inset-bottom)); gap: 10px;
  background: radial-gradient(ellipse 80% 50% at 50% 30%, rgba(147,51,234,.22), transparent 70%), rgba(4,4,12,.985); }
.call-top { width: 100%; display: flex; align-items: center; gap: 10px; font-size: .7rem; letter-spacing: .18em; color: var(--muted); }
.call-led { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 10px var(--emerald); animation: orb-idle 1.6s infinite; }
.call-timer { margin-left: auto; color: var(--text); }
.call-portrait-wrap { position: relative; width: 230px; height: 230px; display: flex; align-items: center; justify-content: center; }
.call-orb { width: 210px; height: 210px; overflow: hidden; font-size: 0; border-width: 2px;
  background: radial-gradient(circle at 50% 30%, rgba(147,51,234,.35), rgba(4,4,12,.9) 70%); }
.call-orb img { width: 100%; height: 100%; object-fit: cover; object-position: center top; transform: scale(1.15) translateY(8px); }
.call-rings { position: absolute; inset: 0; pointer-events: none; }
.call-rings i { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(147,51,234,.35); opacity: 0; }
.voice-orb.speaking ~ .call-rings i { animation: ring 1.6s ease-out infinite; border-color: rgba(16,185,129,.5); }
.voice-orb.listening ~ .call-rings i { animation: ring 2.2s ease-out infinite; border-color: rgba(34,211,238,.45); }
.call-rings i:nth-child(2) { animation-delay: .5s !important; } .call-rings i:nth-child(3) { animation-delay: 1s !important; }
@keyframes ring { 0% { transform: scale(.9); opacity: .8; } 100% { transform: scale(1.45); opacity: 0; } }
.call-name { font-size: 1.05rem; letter-spacing: .2em; color: #c084fc; }
.call-caption { min-height: 3.2em; max-height: 5.6em; overflow: hidden; text-align: center; font-size: .95rem; line-height: 1.4; color: rgba(221,226,240,.8); padding: 0 8px; }
.call-actions { display: flex; gap: 26px; align-items: center; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; color: var(--muted); font-size: .68rem; letter-spacing: .08em; }
.call-btn span { width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--panel-strong); border: 1px solid var(--border); transition: transform .15s, background .2s; }
.call-btn:active span { transform: scale(.92); }
.call-btn.hangup span { width: 74px; height: 74px; background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: transparent; font-size: 1.8rem; }
.call-btn.muted span { background: rgba(239,68,68,.25); border-color: var(--red); }
.call-btn.muted small::after { content: " coupé"; }

/* ── UPDATE POPUP ────────────────────────────────────────────────────── */
.update-pop { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); padding: 0 12px max(14px, env(safe-area-inset-bottom)); }
.update-pop[hidden] { display: none; }
.update-card { width: 100%; max-width: 480px; background: linear-gradient(160deg, rgba(30,14,54,.98), rgba(6,6,16,.98)); border: 1px solid rgba(168,85,247,.45); border-radius: 22px; padding: 18px 18px 16px; box-shadow: 0 -10px 60px rgba(147,51,234,.35); animation: update-in .35s cubic-bezier(.22,.68,0,1.2); }
@keyframes update-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.update-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.update-badge { font-size: .6rem; letter-spacing: .25em; background: linear-gradient(90deg,#a855f7,#10b981); color: #000; padding: 4px 10px; border-radius: 6px; font-weight: 700; }
.update-head .mono { font-size: .72rem; color: var(--muted); letter-spacing: .1em; }
.update-title { font-family: 'Orbitron', sans-serif; font-size: .95rem; letter-spacing: .08em; margin-bottom: 8px; }
.update-notes { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 5px; font-size: .86rem; color: rgba(221,226,240,.75); }
.update-notes li::before { content: '◆ '; color: #a855f7; font-size: .7rem; }
.update-actions { display: flex; gap: 10px; }
.update-actions .primary-btn { flex: 1; }
.ghost-btn { background: transparent; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); padding: 12px 16px; font-size: .9rem; }
.topbar .update-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }

/* ── MODEL CHIP + PICKER ─────────────────────────────────────────────── */
.model-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: .66rem; letter-spacing: .08em;
  background: rgba(147,51,234,.14); border: 1px solid rgba(168,85,247,.4); color: #d8b4fe; max-width: 100%; }
.model-chip[hidden] { display: none; }
.model-chip #modelChipName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.model-chip .chev { opacity: .8; font-size: .7rem; }
.model-chip .model-dot { width: 6px; height: 6px; border-radius: 50%; background: #a855f7; box-shadow: 0 0 6px #a855f7; flex-shrink: 0; }
.model-chip.custom { border-color: rgba(16,185,129,.55); background: rgba(16,185,129,.12); color: #6ee7b7; }
.model-chip.custom .model-dot { background: #10b981; box-shadow: 0 0 6px #10b981; }
.topbar-title .sub { display: none; }
.topbar-title .sub.show { display: block; }

.model-picker { position: fixed; inset: 0; z-index: 85; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; }
.model-picker[hidden] { display: none; }
.model-picker-card { width: 100%; max-width: 520px; max-height: 82vh; display: flex; flex-direction: column; background: linear-gradient(170deg, rgba(24,12,44,.98), rgba(6,6,16,.99));
  border: 1px solid rgba(168,85,247,.4); border-radius: 22px 22px 0 0; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); animation: update-in .3s cubic-bezier(.22,.68,0,1.2); }
.mp-head { display: flex; align-items: center; justify-content: space-between; }
.mp-title { font-size: .78rem; letter-spacing: .18em; color: #c084fc; }
.mp-scope { font-size: .66rem; color: var(--muted); letter-spacing: .1em; margin: 4px 0 10px; }
.mp-search { width: 100%; background: var(--panel-strong); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text); font-size: .95rem; margin-bottom: 10px; }
.mp-list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 4px; }
.mp-group { font-family: 'Share Tech Mono', monospace; font-size: .62rem; letter-spacing: .2em; color: var(--muted); padding: 10px 6px 4px; text-transform: uppercase; position: sticky; top: 0; background: rgba(10,6,22,.95); }
.mp-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid transparent; background: rgba(255,255,255,.03); text-align: left; color: var(--text); font-size: .92rem; width: 100%; }
.mp-item:active { transform: scale(.985); }
.mp-item.selected { border-color: #a855f7; background: rgba(147,51,234,.16); }
.mp-item .mp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-item .mp-tag { font-family: 'Share Tech Mono', monospace; font-size: .58rem; letter-spacing: .12em; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.mp-item .mp-tag.default { border-color: rgba(168,85,247,.5); color: #d8b4fe; }
.mp-item .mp-tag.fast { border-color: rgba(34,211,238,.5); color: #67e8f9; }
.mp-item .mp-check { color: #a855f7; }

/* ── CALL SETTINGS ───────────────────────────────────────────────────── */
.call-gear { margin-left: 4px; }
.cs-body { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 16px; padding-bottom: 6px; }
.cs-label { font-size: .62rem; letter-spacing: .2em; color: var(--muted); margin-bottom: 7px; }
.cs-sub { color: #a855f7; margin-left: 6px; }
.cs-hint { font-size: .74rem; color: rgba(221,226,240,.5); margin-top: 5px; }
.cs-row { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: rgba(147,51,234,.12); border: 1px solid rgba(168,85,247,.4); color: #d8b4fe; font-size: .95rem; }
.cs-cards { display: flex; flex-direction: column; gap: 6px; }
.cs-card { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text); }
.cs-card.on { border-color: #a855f7; background: rgba(147,51,234,.16); }
.cs-card b { display: block; font-size: .9rem; } .cs-card small { color: var(--muted); font-size: .72rem; }
.cs-filter { display: flex; gap: 6px; margin-bottom: 8px; }
.cs-filter button, .cs-chips button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--muted); font-size: .8rem; }
.cs-filter button.on, .cs-chips button.on { border-color: #10b981; color: #6ee7b7; background: rgba(16,185,129,.12); }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-voices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 240px; overflow-y: auto; }
.cs-voice { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text); text-align: left; }
.cs-voice.on { border-color: #a855f7; background: rgba(147,51,234,.16); }
.cs-voice .g { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-family: 'Orbitron', sans-serif; flex-shrink: 0; }
.cs-voice .g.H { background: rgba(37,99,235,.3); color: #93c5fd; } .cs-voice .g.F { background: rgba(255,45,85,.25); color: #fda4af; }
.cs-voice b { display: block; font-size: .84rem; } .cs-voice small { color: var(--muted); font-size: .66rem; }
.cs-voice .play { margin-left: auto; opacity: .7; font-size: .8rem; }
#csPersona { width: 100%; background: var(--panel-strong); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text); font-size: .9rem; resize: vertical; font-family: inherit; }
.cs-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cs-presets button { padding: 6px 10px; border-radius: 999px; border: 1px dashed rgba(168,85,247,.5); background: transparent; color: #c084fc; font-size: .74rem; }
.cs-actions { display: flex; gap: 10px; position: sticky; bottom: 0; background: linear-gradient(to top, rgba(6,6,16,1) 60%, transparent); padding-top: 10px; }
.cs-actions .primary-btn { flex: 1; }
.cs-preview-playing { animation: orb-idle 1s infinite; }

/* mic level ring on the mute button */
#callMuteBtn span { position: relative; }
#callMuteBtn span::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(34,211,238, calc(0.15 + var(--lvl, 0) * 0.85)); transform: scale(calc(1 + var(--lvl, 0) * 0.25)); transition: transform .08s, border-color .08s; pointer-events: none; }
#callMuteBtn.muted span::after { display: none; }

/* ── CALL DIAGNOSTICS (VU meters + status icons) ─────────────────────── */
.call-diag { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--border); }
.vu-row { display: flex; align-items: center; gap: 8px; }
.vu-ico { font-size: .85rem; width: 18px; }
.vu { flex: 1; height: 10px; border-radius: 6px; background: rgba(255,255,255,.06); position: relative; overflow: hidden;
  background-image: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,.35) 6px 7px); }
.vu-fill { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, #10b981 0%, #10b981 60%, #f59e0b 80%, #ef4444 100%); background-size: 100% 100%; transition: width .06s linear; }
.vu.out .vu-fill { background: linear-gradient(90deg, #a855f7, #60a5fa); }
.vu-peak { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: 0%; opacity: .8; transition: left .1s; }
.vu-db { width: 58px; text-align: right; font-size: .66rem; color: var(--muted); }
.diag-icons { display: flex; justify-content: space-between; gap: 4px; font-size: .58rem; letter-spacing: .04em; color: var(--muted); margin-top: 2px; }
.diag-icons span { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 4px; border-radius: 8px; border: 1px solid transparent; min-width: 52px; }
.diag-icons b { font-weight: 500; }
.diag-icons span.ok { color: #6ee7b7; border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.08); }
.diag-icons span.warn { color: #fcd34d; border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.08); }
.diag-icons span.bad { color: #fca5a5; border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.1); animation: orb-idle 1s infinite; }
.diag-icons span.idle { color: var(--muted); border-color: var(--border); }

/* ── CALL PARTY (agents in the call) ─────────────────────────────────── */
.call-party { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; min-height: 54px; }
.party-tile { --c: #9333ea; position: relative; width: 50px; height: 50px; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); overflow: visible; background: #080810; transition: transform .25s, border-color .2s, box-shadow .2s; animation: party-in .4s cubic-bezier(.22,.68,0,1.3); }
.party-tile img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: center top; display: block; }
.party-tile .pl { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); font-family: 'Orbitron', sans-serif; font-size: .46rem; letter-spacing: .1em; color: var(--c); white-space: nowrap; }
.party-tile.speaking { border-color: var(--c); box-shadow: 0 0 0 3px rgba(255,255,255,.08), 0 0 22px var(--c); transform: scale(1.18); z-index: 2; }
.party-tile.speaking::before { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--c); opacity: .6; animation: ring 1.2s ease-out infinite; }
.party-tile.queued { border-style: dashed; border-color: rgba(245,158,11,.6); }
.party-tile.leaving { animation: party-out .35s forwards; }
@keyframes party-in { from { transform: scale(.3) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes party-out { to { transform: scale(.3); opacity: 0; } }
.call-queue { font-size: .6rem; letter-spacing: .14em; color: #fcd34d; margin-top: 10px; }
.call-queue[hidden] { display: none; }
.call-orb.agent img { object-position: center top; }
/* chat bubbles by agent */
.msg-row.assistant .msg-mini-avatar { border-color: var(--c); }
.msg-agent-name { font-family: 'Orbitron', sans-serif; font-size: .55rem; letter-spacing: .14em; color: var(--c, #c084fc); margin: 0 0 3px 2px; }

.cs-agents { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.cs-agent { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text); }
.cs-agent img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: center top; border: 1.5px solid var(--c); }
.cs-agent .an { font-family: 'Orbitron', sans-serif; font-size: .62rem; letter-spacing: .1em; color: var(--c); width: 72px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; }
.cs-agent select { flex: 1; background: var(--panel-strong); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: .82rem; }
.cs-agent .play { opacity: .8; padding: 4px 8px; }

/* ── iPhone 16 / tall PWA layout ─────────────────────────────────────── */
#app.in-call .tabbar,
#app.in-call .install-banner { display: none !important; }
#app.in-call .voice-room.show {
  position: fixed; inset: 0; z-index: 70;
  padding: max(14px, var(--safe-t)) 16px max(22px, var(--safe-b));
}
.call-screen {
  justify-content: flex-start;
  min-height: 0;
}
.call-portrait-wrap {
  flex: 1 1 auto;
  width: min(280px, 68vw);
  height: auto;
  max-height: min(42dvh, 320px);
  aspect-ratio: 1;
}
.call-orb { width: 90%; height: 90%; }
.call-caption:empty { display: none; }
.call-caption { min-height: 0; }
.call-diag { flex-shrink: 0; max-width: min(360px, 100%); }
.call-actions { flex-shrink: 0; padding-top: 4px; }
.diag-icons span { min-width: 0; flex: 1; }
.model-picker-card { max-height: min(92dvh, 920px); }
.cs-body { flex: 1; min-height: 0; }
.mp-list { padding-bottom: 12px; }
.sheet { max-height: min(86dvh, 820px); }
.cron-header { justify-content: flex-end; }

@media (max-height: 740px) {
  .call-portrait-wrap { max-height: 28dvh; }
  .call-btn span { width: 54px; height: 54px; }
  .call-btn.hangup span { width: 64px; height: 64px; }
  .call-diag { padding: 6px 8px; }
  .diag-icons { display: none; }
}
