:root {
  --bg: #11131a;
  --bg-soft: #1a1d28;
  --bg-input: #242838;
  --accent: #6c8cff;
  --accent-2: #9b6cff;
  --text: #eef1f8;
  --muted: #9aa3b8;
  --user: #2b3350;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --w: 420px;
  --h: 640px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse 120% 120% at 80% 110%, #161a2e 0%, #0b0d14 60%);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}

/* ----------------------------- Floating orb ----------------------------- */
.orb {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow), 0 0 0 0 rgba(108,140,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: orbPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
}
@keyframes orbPop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.orb:hover { transform: scale(1.06); box-shadow: var(--shadow), 0 0 0 8px rgba(108,140,255,0.15); }
.orb:active { transform: scale(0.96); }

.orb-glyph { pointer-events: none; }

.rec-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff4d5e;
  border: 2px solid var(--bg);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ------------------------------- Panel ---------------------------------- */
.panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: var(--w);
  height: var(--h);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* Document PiP — fills the tiny floating window */
body.pip {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}
body.pip .panel {
  position: static;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
  border: none;
  animation: none;
}

/* ----------------------------- Header ----------------------------------- */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: default;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-title { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.header-actions { display: flex; gap: 6px; }

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s ease;
  white-space: nowrap;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn.recording { background: #ff4d5e; border-color: #ff4d5e; color: #fff; }

/* ------------------------------ Settings -------------------------------- */
.settings {
  padding: 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field input,
.field select {
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  -webkit-user-select: text;
  user-select: text;
}
.settings-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.muted { color: var(--muted); }
.link, .link-btn {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
}
.primary-btn:hover { opacity: 0.9; }

/* ------------------------------ Messages -------------------------------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-user-select: text;
  user-select: text;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.assistant .bubble {
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom-left-radius: 4px;
}
.msg.user .bubble {
  background: var(--user);
  border-bottom-right-radius: 4px;
}
.bubble code {
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
.bubble pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}
.bubble pre code { background: none; padding: 0; }
.typing { color: var(--muted); font-style: italic; }

/* ------------------------------ Composer -------------------------------- */
.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--bg-soft);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  align-items: flex-end;
  flex-shrink: 0;
}
#input {
  flex: 1;
  resize: none;
  max-height: 120px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  -webkit-user-select: text;
  user-select: text;
}
#input:focus { outline: none; border-color: var(--accent); }
.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.send-btn:hover { opacity: 0.88; }
.send-btn:disabled { opacity: 0.4; cursor: default; }

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 6px; }
