* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b0e1a; --panel: #12162a; --panel2: #1a1f3a; --text: #eef1ff;
  --muted: #8b92b8; --accent: #22d3ee; --accent2: #7c6cff; --err: #ff6b7a;
  --ok: #34d399; --radius: 16px;
}
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1b2350 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
/* ── Top bar ── */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: rgba(11,14,26,.7); backdrop-filter: blur(10px); border-bottom: 1px solid #ffffff10; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 0 12px var(--accent); }
.brand-free { color: var(--accent); font-weight: 500; }
.chips { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid #ffffff14; }
.chip.ok { color: var(--ok); border-color: #34d39944; }
.chip.warn { color: #fbbf24; border-color: #fbbf2444; }
.icon-btn { background: var(--panel2); color: var(--text); border: 1px solid #ffffff18; border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }
.icon-btn:hover { border-color: var(--accent); }

/* ── Chat area ── */
.chat { flex: 1; overflow-y: auto; padding: 20px 16px 8px; display: flex; flex-direction: column; scroll-behavior: smooth; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 440px; padding: 24px; }
.empty-orb { font-size: 44px; margin-bottom: 12px; }
.empty h2 { color: var(--text); margin-bottom: 8px; font-weight: 600; }
.messages { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 760px; margin: 0 auto; }
.bubble { max-width: 78%; padding: 12px 15px; border-radius: var(--radius); line-height: 1.55; font-size: 15px; white-space: normal; word-wrap: break-word; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 8px 18px; } .bubble li { margin: 2px 0; }
.bubble pre { background: #0a0d1a; border: 1px solid #ffffff14; padding: 10px; border-radius: 10px; overflow-x: auto; font-size: 13px; margin: 6px 0; }
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: #ffffff12; padding: 1px 5px; border-radius: 6px; }
.bubble pre code { background: none; padding: 0; }
.bubble a { color: var(--accent); }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, #1c2a63, #24328a); border-bottom-right-radius: 6px; }
.bubble.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid #ffffff14; border-bottom-left-radius: 6px; }
.bubble.error { align-self: flex-start; background: #3a1620; border: 1px solid var(--err); color: #ffd7dc; }
.bubble .meta { display: block; font-size: 10px; color: var(--muted); margin-top: 6px; }
.typing { color: var(--muted); font-style: italic; }

/* ── Composer ── */
.composer-wrap { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: rgba(11,14,26,.8); backdrop-filter: blur(10px); border-top: 1px solid #ffffff10; }
.live { background: var(--panel); border: 1px dashed var(--accent); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; color: var(--text); min-height: 20px; }
.hidden { display: none !important; }
.composer { display: flex; gap: 8px; max-width: 760px; margin: 0 auto; }
.composer input { flex: 1; background: var(--panel2); border: 1px solid #ffffff18; border-radius: 14px; color: var(--text); padding: 13px 16px; font-size: 15px; outline: none; }
.composer input:focus { border-color: var(--accent); }
.send-btn { width: 48px; border-radius: 14px; border: 1px solid #ffffff18; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04121a; font-size: 17px; cursor: pointer; }
.talk-row { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 12px; }
.talk-btn {
  position: relative; width: 96px; height: 96px; border-radius: 50%; cursor: pointer; border: 2px solid var(--accent);
  background: radial-gradient(circle at 35% 30%, #1b2a5e, #131a3a 70%);
  color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .08s ease, box-shadow .2s ease; user-select: none; -webkit-user-select: none; touch-action: none;
}
.talk-btn .mic { font-size: 26px; }
.talk-label { font-size: 11px; color: var(--muted); }
.talk-btn:hover { box-shadow: 0 0 22px #22d3ee55; }
.talk-btn:active, .talk-btn.listening { transform: scale(.96); box-shadow: 0 0 34px #22d3eeaa; border-color: #fff; animation: pulse 1.2s infinite; }
.talk-btn.busy { border-color: var(--accent2); box-shadow: 0 0 30px #7c6cff99; cursor: wait; }
.talk-btn.error { border-color: var(--err); box-shadow: 0 0 26px var(--err); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 18px #22d3ee66; } 50% { box-shadow: 0 0 40px #22d3eeee; } }
.hint { font-size: 11px; color: var(--muted); }
.disclaimer { text-align: center; font-size: 10px; color: #5a6188; margin-top: 6px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; background: #00000088; display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid #ffffff1c; border-radius: 18px; padding: 20px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.modal-card h3 { font-weight: 600; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal-card input[type=text], .modal-card input[type=password], .modal-card select { background: var(--panel2); border: 1px solid #ffffff1c; color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; }
.modal-card .row { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.server-info { font-size: 12px; color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.ghost-btn, .primary-btn { border: 1px solid #ffffff22; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-size: 13px; }
.ghost-btn { background: transparent; color: var(--muted); }
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #04121a; font-weight: 600; border: none; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #232a4d; border: 1px solid #ffffff26; color: var(--text); padding: 10px 18px; border-radius: 12px; font-size: 13px; z-index: 30; max-width: 90vw; box-shadow: 0 8px 30px #000a; }
.toast.error { border-color: var(--err); background: #3a1620; }

@media (max-width: 560px) {
  .bubble { max-width: 88%; }
  .talk-btn { width: 84px; height: 84px; }
}
