:root {
  --bg: #0b1020;
  --panel: #141a2e;
  --bot: #1e2740;
  --me: #4f46e5;
  --text: #e7e9f2;
  --muted: #8b93ad;
  --accent: #7c83ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  height: 100dvh;
}
header {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid #222b45;
}
.brand { font-weight: 700; letter-spacing: .5px; flex: 1; }
.modes { display: flex; gap: .25rem; }
button {
  background: #263255; color: var(--text); border: 0; border-radius: 10px;
  padding: .5rem .7rem; font-size: 1rem; cursor: pointer;
}
.mode { min-width: 2.4rem; opacity: .55; }
.mode.on { opacity: 1; background: var(--accent); color: #0b1020; font-weight: 700; }
#gear { background: transparent; }

main {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.msg { max-width: 82%; padding: .6rem .8rem; border-radius: 14px; white-space: pre-wrap;
  word-wrap: break-word; line-height: 1.35; }
.msg.me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.bot a { color: var(--accent); }
.msg audio { display: block; margin-top: .5rem; width: 100%; }
.msg.typing { color: var(--muted); font-style: italic; }

form#bar {
  display: flex; gap: .5rem; align-items: flex-end;
  padding: .6rem; padding-bottom: max(.6rem, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid #222b45;
}
#input {
  flex: 1; resize: none; max-height: 8rem;
  background: #0f1525; color: var(--text); border: 1px solid #2a3457;
  border-radius: 12px; padding: .6rem .8rem; font: inherit;
}
#mic.rec { background: #e0245e; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid #2a3457;
  border-radius: 14px; max-width: 90%;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 0 0 .3rem; }
dialog p { color: var(--muted); margin: .2rem 0 .8rem; }
dialog input {
  width: 100%; background: #0f1525; color: var(--text);
  border: 1px solid #2a3457; border-radius: 10px; padding: .6rem;
}
dialog menu { padding: 0; margin: .8rem 0 0; text-align: right; }
