:root {
  --bg: #0a0a0a;
  --panel: #111;
  --line: #262626;
  --text: #e8e8e8;
  --dim: #777;
  --acc: #00ff66;
  --font: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; border-radius: 0; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
}
::selection { background: var(--acc); color: #000; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); }

.center { height: 100%; display: grid; place-items: center; }
.box { width: min(360px, 90vw); text-align: center; }
.box img { width: 96px; margin-bottom: 8px; }
.title { letter-spacing: 0.5em; font-weight: 700; margin: 0 0 28px; padding-left: 0.5em; }
input, textarea, button {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); outline: none;
}
input:focus, textarea:focus { border-color: var(--acc); }
.box input { width: 100%; padding: 12px; margin-bottom: 10px; }
button { cursor: pointer; padding: 12px 18px; text-transform: uppercase; letter-spacing: 0.15em; }
button:hover { background: var(--acc); color: #000; border-color: var(--acc); }
button.stop { border-color: #ff3b3b; color: #ff3b3b; }
button.stop:hover { background: #ff3b3b; color: #000; border-color: #ff3b3b; }
.box button { width: 100%; }
.err { color: #ff3b3b; min-height: 1.6em; margin-top: 10px; }

.app { height: 100%; display: flex; flex-direction: column; max-width: 920px; margin: 0 auto; }
header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
header img { width: 32px; }
header b { letter-spacing: 0.4em; }
header .sp { flex: 1; }
header .meta { color: var(--dim); font-size: 12px; }
header button { padding: 6px 12px; font-size: 12px; }
.picker { position: relative; }
.picker > button {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.25em; color: var(--acc);
  border-color: var(--acc);
}
.picker > button:hover { background: var(--acc); color: #000; }
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.msg.bot .who { display: flex; align-items: center; gap: 8px; }
.msg.bot .who::before { content: none; }
.picker .caret { transition: transform 0.15s; letter-spacing: 0; }
.picker.open .caret { transform: rotate(180deg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10;
  min-width: 270px; background: var(--bg); border: 1px solid var(--acc);
  box-shadow: 6px 6px 0 rgba(0, 255, 102, 0.15);
  visibility: hidden; opacity: 0; transform-origin: top right;
  clip-path: inset(0 0 100% 0); transform: translateY(-8px) scale(0.96);
  transition: clip-path 0.28s cubic-bezier(.2,.8,.2,1), opacity 0.2s, transform 0.28s cubic-bezier(.2,.8,.2,1), visibility 0s 0.28s;
}
.picker.open .menu {
  visibility: visible; opacity: 1; clip-path: inset(0 -10px -10px -10px); transform: none;
  transition-delay: 0s;
}
.menu .item { opacity: 0; transform: translateX(18px); transition: opacity 0.2s, transform 0.25s; }
.picker.open .menu .item { opacity: 1; transform: none; }
.picker.open .menu .item:nth-child(1) { transition-delay: 0.06s; }
.picker.open .menu .item:nth-child(2) { transition-delay: 0.13s; }
.picker.open .menu .item:nth-child(3) { transition-delay: 0.2s; }
.menu .item {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; cursor: pointer; border-left: 3px solid transparent;
  border-bottom: 1px solid var(--line);
}
.menu .item .ico { width: 28px; height: 28px; color: var(--dim); transition: transform 0.2s, color 0.2s; }
.menu .item:hover .ico { transform: scale(1.18) rotate(-6deg); }
.menu .item.picked { animation: pick 0.4s ease-out; }
.menu .item.picked .ico { animation: pop 0.4s ease-out; }
.menu .item.picked::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 102, 0.45), transparent);
  animation: sweep 0.4s ease-out;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes pick { 0% { background: rgba(0, 255, 102, 0.3); } 100% { background: var(--panel); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.5) rotate(-12deg); } 100% { transform: scale(1); } }
.picker > button.flash { animation: flash 0.5s ease-out; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 102, 0.7); transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { box-shadow: 0 0 0 14px rgba(0, 255, 102, 0); transform: scale(1); }
}
.menu .item.on .ico, .menu .item:hover .ico { color: var(--acc); }
.menu .item:last-child { border-bottom: 0; }
.menu .item b { display: block; letter-spacing: 0.25em; font-size: 13px; }
.menu .item small { color: var(--dim); font-size: 11px; letter-spacing: 0.05em; }
.menu .item:hover { background: var(--panel); border-left-color: var(--text); }
.menu .item.on { border-left-color: var(--acc); background: var(--panel); }
.menu .item.on b { color: var(--acc); }
.menu .item.on b::after { content: " ●"; font-size: 9px; }

#log { flex: 1; overflow-y: auto; padding: 20px 16px; }
.msg { margin-bottom: 22px; white-space: pre-wrap; word-wrap: break-word; }
.msg .who { color: var(--dim); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }
.msg.bot .who { color: var(--acc); }
.msg.bot .who::before { content: "▌"; }
.msg .body { padding-left: 14px; border-left: 1px solid var(--line); margin-top: 4px; }
.msg.bot .body { border-left-color: var(--acc); }
pre {
  background: var(--panel); border: 1px solid var(--line); padding: 12px;
  overflow-x: auto; margin: 8px 0; white-space: pre;
}
code { color: var(--acc); }
.cursor::after {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 8px;
  vertical-align: -2px; border: 2px solid rgba(0, 255, 102, 0.25); border-top-color: var(--acc);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.typing::after {
  content: ""; display: inline-block; width: 18px; height: 18px; margin-left: 8px; vertical-align: -3px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2300ff66'%3E%3Cellipse cx='12' cy='16' rx='6' ry='5'/%3E%3Cellipse cx='4.5' cy='10' rx='2.3' ry='3'/%3E%3Cellipse cx='9' cy='5' rx='2.3' ry='3'/%3E%3Cellipse cx='15' cy='5' rx='2.3' ry='3'/%3E%3Cellipse cx='19.5' cy='10' rx='2.3' ry='3'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: paw 1.1s ease-in-out infinite;
}
@keyframes paw { 0%, 100% { opacity: 0.25; transform: translateY(2px) scale(0.9); } 50% { opacity: 1; transform: translateY(-2px) scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
.drawing::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  vertical-align: -2px; border: 2px solid rgba(0, 255, 102, 0.25); border-top-color: var(--acc);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.empty { color: var(--dim); text-align: center; margin-top: 18vh; letter-spacing: 0.2em; }

form { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
textarea { flex: 1; resize: none; padding: 12px; max-height: 200px; }
#attach { padding: 0 16px; font-size: 20px; letter-spacing: 0; color: var(--acc); }
#chips { padding: 8px 16px 0; display: flex; flex-wrap: wrap; gap: 6px; }
#chips:empty { display: none; }
.chip {
  border: 1px solid var(--acc); color: var(--acc); padding: 2px 10px;
  font-size: 12px; cursor: pointer;
}
.chip:hover { background: var(--acc); color: #000; }
.chip.err { border-color: #ff3b3b; color: #ff3b3b; cursor: default; }
img.gen { display: block; max-width: min(100%, 512px); border: 1px solid var(--line); }
img.gen:hover { border-color: var(--acc); }
a.save { display: inline-block; margin-top: 6px; color: var(--dim); font-size: 12px; letter-spacing: 0.1em; }
a.save:hover { color: var(--acc); }
a.src { color: var(--dim); font-size: 12px; word-break: break-all; }
#mic.on, #tts.on { background: var(--acc); color: #000; }
#chatlist { overflow-y: auto; padding: 6px 0; }
.chat-row span { cursor: pointer; }
.chat-row span:hover, .chat-row.on span { color: var(--acc); }
button.ib { width: 46px; padding: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); }
button.ib svg { width: 20px; height: 20px; }
button.ib:hover, button.ib.on { color: #000; }
#mic.on { animation: micpulse 1s infinite; }
#mic.busy { animation: micpulse 0.5s infinite; color: var(--acc); }
.vbar { display: none; align-items: center; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--acc); color: var(--acc); letter-spacing: 0.2em; font-size: 12px; text-transform: uppercase; }
.vbar.open { display: flex; }
.vbar button { margin-left: auto; padding: 6px 12px; font-size: 11px; }
.vorb { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 14px var(--acc); transition: transform 0.06s linear; }
.vbar[data-s="listen"] .vorb { opacity: 0.5; }
.vbar[data-s="rec"] .vorb { opacity: 1; }
.vbar[data-s="think"] .vorb { background: none; box-shadow: none; border: 2px solid var(--line); border-top-color: var(--acc); animation: spin 0.8s linear infinite; }
.vbar[data-s="talk"] .vorb { animation: talkpulse 0.7s ease-in-out infinite alternate; }
@keyframes talkpulse { from { box-shadow: 0 0 6px var(--acc); } to { box-shadow: 0 0 22px var(--acc); } }
#talk.on { color: #000; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.35); } }
#tts:not(.on) { text-decoration: none; }
.mem-head .sp, .sp { flex: 1; }
a.src:hover { color: var(--acc); }
.mem {
  position: fixed; top: 60px; right: 16px; width: min(380px, calc(100vw - 32px)); max-height: 70vh;
  display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--acc);
  box-shadow: 6px 6px 0 rgba(0, 255, 102, 0.15); z-index: 20;
  visibility: hidden; opacity: 0; transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.25s, visibility 0s 0.25s;
}
.mem.open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
.mem-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--acc); letter-spacing: 0.25em; font-size: 12px; }
.mem-head button { padding: 4px 8px; font-size: 11px; }
#memlist { overflow-y: auto; padding: 6px 0; }
.mem-row { display: flex; gap: 8px; align-items: flex-start; padding: 6px 12px; font-size: 13px; }
.mem-row span { flex: 1; }
.mem-row button { padding: 0 6px; font-size: 12px; border: 0; color: var(--dim); }
.mem-row button:hover { background: none; color: #ff3b3b; }
.mem-empty { padding: 12px; color: var(--dim); font-size: 12px; }
#memf { display: flex; border-top: 1px solid var(--line); }
#memf input { flex: 1; background: transparent; border: 0; color: var(--text); padding: 10px 12px; font-family: inherit; outline: none; }
#memf button { padding: 8px 14px; border: 0; border-left: 1px solid var(--line); }
details.eye { border: 1px solid var(--line); margin: 4px 0 12px; font-size: 12px; }
details.eye summary {
  cursor: pointer; padding: 6px 10px; color: var(--dim); display: flex;
  align-items: center; gap: 8px; letter-spacing: 0.1em;
}
details.eye summary .ico { width: 16px; height: 16px; color: var(--acc); }
details.eye .eyetxt { padding: 8px 12px; border-top: 1px solid var(--line); color: var(--dim); max-height: 260px; overflow-y: auto; }
#scrollb { width: 32px; height: 32px; align-self: center; border-color: var(--line); color: var(--dim); background: none; }
#scrollb svg { width: 16px; height: 16px; }
#scrollb.on { border-color: var(--acc); color: var(--acc); background: none; }
#scrollb:hover { background: var(--acc); color: #000; border-color: var(--acc); }
.msg .body strong { color: #fff; font-weight: 700; }
.chip .thumb { width: 36px; height: 36px; object-fit: cover; vertical-align: middle; margin-right: 8px; border: 1px solid var(--line); }
.chip:has(.thumb) { padding: 3px 10px 3px 3px; display: inline-flex; align-items: center; }
.pics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pics img { max-width: 160px; max-height: 160px; object-fit: cover; border: 1px solid var(--line); }

.qpill { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 32px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.03); font-size: 12px; line-height: 1; letter-spacing: 0.08em; color: #d8d8d8; overflow: hidden; white-space: nowrap; flex: none; cursor: default; }
.qpill .qv { display: inline-flex; align-items: center; font-weight: 700; color: var(--acc); line-height: 1; }
.qpill .qd { color: var(--dim); }
.qpill .qd:empty { display: none; }
.qpill .qd:not(:empty)::before { content: "·"; margin-right: 8px; }
.qpill .qbar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,0.06); }
.qpill .qbar i { display: block; height: 100%; width: 0; background: var(--acc); box-shadow: 0 0 8px var(--acc); transition: width 0.6s ease; }
.qpill.low { border-color: #ff9d2e; }
.qpill.low .qv { color: #ff9d2e; }
.qpill.low .qbar i { background: #ff9d2e; box-shadow: 0 0 8px #ff9d2e; }
.qpill.out { border-color: #ff3b3b; }
.qpill.out .qv { color: #ff3b3b; }
.qpill.inf { border-color: rgba(255,200,61,0.55); background: rgba(255,200,61,0.07); box-shadow: 0 0 14px rgba(255,200,61,0.18); padding: 0 16px; }
.qpill.inf .qv { color: #ffc83d; font-size: 24px; text-shadow: 0 0 10px rgba(255,200,61,0.75); letter-spacing: 0; transform: translateY(-1px); }
.qpill.inf .qbar i { background: linear-gradient(90deg, transparent, #ffc83d, transparent); box-shadow: none; }
@media (max-width: 700px) { .qpill .qd { display: none; } }