:root {
  --bg: #0e0f12;
  --panel: #17191e;
  --text: #e9eaee;
  --muted: #8b8f99;
  --accent: #7c9cff;
  --listen: #3ddc97;
  --think: #ffb547;
  --speak: #7c9cff;
  --ask: #ff7ab6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; }
#name { font-weight: 600; letter-spacing: .02em; flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--listen); }
.dot.off { background: #e5484d; }

button { font: inherit; color: var(--text); background: var(--accent); border: 0; border-radius: 10px; padding: 10px 16px; }
button.ghost { background: transparent; color: var(--muted); font-size: 20px; padding: 6px 10px; }

main { flex: 1; display: flex; flex-direction: column; align-items: center; overflow: hidden; padding: 8px 18px; }

.orb {
  position: relative; width: 150px; height: 150px; border-radius: 50%; margin: 10px 0 10px; flex: none;
  background: radial-gradient(circle at 50% 40%, #23262e, #121318); color: var(--text);
  display: grid; place-items: center; font-size: 15px; transition: transform .2s;
}
.orb:active { transform: scale(.97); }
.orb .ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid #2a2d36; transition: border-color .3s; }
.orb.listening .ring { border-color: var(--listen); animation: pulse 2.2s ease-in-out infinite; }
.orb.awake .ring { border-color: var(--listen); border-width: 6px; }
.orb.thinking .ring { border-color: var(--think); animation: spin 1.2s linear infinite; border-top-color: transparent; }
.orb.speaking .ring { border-color: var(--speak); animation: pulse .8s ease-in-out infinite; }
.orb.asking .ring { border-color: var(--ask); border-width: 6px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); opacity: .7; } }
@keyframes spin { to { transform: rotate(360deg); } }

#hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 320px; margin: 0 0 4px; }
#status { color: var(--think); font-size: 13px; min-height: 18px; margin: 0 0 8px; }

#log { width: 100%; max-width: 760px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 8px; }
.msg { position: relative; padding: 8px 34px 9px 12px; border-radius: 12px; max-width: 88%; line-height: 1.4; font-size: 15px;
  user-select: text; -webkit-user-select: text; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: #233056; }
.msg.bot { align-self: flex-start; background: var(--panel); }
.msg.ask { align-self: flex-start; background: #3a1f2e; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 8px; text-align: center; }
.msg small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.msg .copy { position: absolute; top: 4px; right: 4px; background: transparent; color: var(--muted); padding: 4px 6px; font-size: 14px; border-radius: 6px; opacity: .55; }
.msg .copy:hover { opacity: 1; background: rgba(255,255,255,.06); }
.older { align-self: center; background: transparent; color: var(--accent); font-size: 13px; padding: 6px 10px; }
@media (min-width: 900px) { #typeForm { max-width: 760px; width: 100%; margin: 0 auto; } }

#typeForm { display: flex; gap: 8px; padding: 10px 14px 14px; }
#typeForm input { flex: 1; background: var(--panel); border: 1px solid #262931; color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; }

dialog { background: var(--panel); color: var(--text); border: 1px solid #262931; border-radius: 16px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
dialog input, dialog select { background: var(--bg); color: var(--text); border: 1px solid #262931; border-radius: 8px; padding: 9px 10px; font: inherit; }
.row { display: flex; justify-content: space-between; align-items: center; }
dialog h3 { margin: 16px 0 10px; font-size: 14px; color: var(--text); }
button.ghost.small { font-size: 14px; border: 1px solid #262931; margin-bottom: 14px; }
#elevenBox[hidden], #phoneVoiceBox[hidden] { display: none; }
