:root {
  --bg: #0b1020; --panel: #131a2e; --panel2: #1a2340; --line: #263154;
  --text: #e8ecf6; --muted: #93a0c0; --brand: #6ea8fe; --brand2: #8b7bff;
  --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --c0: #6ea8fe; --c1: #8b7bff; --c2: #4ade80; --c3: #fbbf24; --c4: #f472b6;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .8rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.4rem 0 .5rem; }
.muted { color: var(--muted); }

.pg-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.pg-brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 700; }
.pg-brand span { color: var(--brand); }
.pg-top-right { display: flex; gap: .5rem; align-items: center; }
.pill { background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  padding: .25rem .6rem; border-radius: 999px; font-size: .8rem; }
.pill.link { text-decoration: none; }
.pill.ok { color: var(--good); border-color: #235; }
.pill.err { color: var(--bad); }

.pg-grid { display: grid; grid-template-columns: 300px 1fr 340px; gap: 1px; background: var(--line);
  height: calc(100vh - 55px); }
.pg-controls, .pg-telemetry { background: var(--panel); padding: 1.1rem; overflow-y: auto; }
.pg-chat { background: var(--bg); display: flex; flex-direction: column; min-height: 0; }

/* controls */
.ctl { display: block; margin-bottom: .9rem; }
.ctl > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.ctl select, .ctl textarea, .ctl input[type=text] {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: .5rem; font: inherit;
}
.ctl input[type=range] { width: 100%; accent-color: var(--brand); }
.ctl.toggle { display: flex; align-items: center; gap: .5rem; }
.ctl.toggle span { margin: 0; color: var(--text); }
.ctl.toggle input { accent-color: var(--brand); width: 16px; height: 16px; }
.ctl textarea { resize: vertical; }
.ctl-row { display: flex; gap: .5rem; margin-top: 1rem; }
.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: .5rem .8rem; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: #06122b; border-color: var(--brand); font-weight: 600; }
.btn.ghost { flex: 1; }
.mini { font-size: .72rem; padding: .2rem .5rem; background: var(--panel2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }

.tools-panel { margin: .4rem 0 .9rem; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; }
.tools-panel summary { cursor: pointer; font-size: .82rem; color: var(--muted); }
.tool-actions { display: flex; gap: .4rem; margin: .5rem 0; }
#tool_list label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; padding: .15rem 0; }
#tool_list input { accent-color: var(--brand); }

/* chat */
.chat-log { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
.bubble { max-width: 78%; padding: .6rem .85rem; border-radius: 14px; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--brand); color: #06122b; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble .tag { display: block; font-size: .68rem; color: var(--muted); margin-top: .4rem; }
.bubble.bot.thinking { color: var(--muted); font-style: italic; }
.voice-box { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .7rem .2rem; margin: .3rem 0 .9rem; background: rgba(139,123,255,.06); }
.voice-title { font-size: .8rem; color: var(--brand2); font-weight: 600; margin-bottom: .6rem; }

.mic-btn { width: 42px; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 10px; cursor: pointer; font-size: 1.1rem; }
.mic-btn:hover { border-color: var(--brand); }
.mic-btn.recording { background: var(--bad); border-color: var(--bad); animation: pulse 1s infinite; }
.mic-btn.transcribing { opacity: .6; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,.5); } 50% { box-shadow: 0 0 0 6px rgba(248,113,113,0); } }
.bubble.speaking { border-color: var(--brand2); box-shadow: 0 0 0 1px var(--brand2); }
.voice-stat .vrow { display: flex; justify-content: space-between; font-size: .78rem; padding: .2rem 0; border-bottom: 1px solid var(--line); }
.voice-stat .vrow b { color: var(--c2); }

.chat-input { display: flex; gap: .5rem; padding: .8rem 1.2rem; border-top: 1px solid var(--line); background: var(--panel); }
.chat-input input { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: .65rem .8rem; font: inherit; }
.quick { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0 1.2rem 1rem; background: var(--panel); }
.quick button { font-size: .74rem; padding: .3rem .6rem; background: var(--panel2); border: 1px solid var(--line);
  color: var(--muted); border-radius: 999px; cursor: pointer; }
.quick button:hover { color: var(--text); border-color: var(--brand); }

/* telemetry */
.lat-total { text-align: center; margin-bottom: .8rem; }
.lat-total span { font-size: 2rem; font-weight: 700; color: var(--brand); display: block; }
.lat-total small { color: var(--muted); font-size: .72rem; }
.lat-bars { display: flex; flex-direction: column; gap: .45rem; }
.lat-row { font-size: .78rem; }
.lat-row .lab { display: flex; justify-content: space-between; margin-bottom: .2rem; }
.lat-row .track { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.lat-row .fill { height: 100%; border-radius: 6px; }
.cmp { width: 100%; border-collapse: collapse; font-size: .8rem; }
.cmp th, .cmp td { text-align: left; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
.cmp th { color: var(--muted); font-weight: 600; }
.chunks .chunk { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .6rem; margin-bottom: .5rem; font-size: .76rem; }
.chunks .chunk .h { color: var(--brand); font-weight: 600; margin-bottom: .2rem; }
.chunks .chunk .sc { float: right; color: var(--muted); }
.tools-out .trec { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .6rem; margin-bottom: .45rem; font-size: .76rem; }
.tools-out .trec b { color: var(--c2); }
.tools-out .trec .ms { float: right; color: var(--muted); }
.cart-out .ci { display: flex; justify-content: space-between; font-size: .8rem; padding: .25rem 0;
  border-bottom: 1px solid var(--line); }
.cart-out .tot { display: flex; justify-content: space-between; font-weight: 700; padding-top: .4rem; }

@media (max-width: 1100px) {
  .pg-grid { grid-template-columns: 1fr; height: auto; }
  .pg-controls, .pg-telemetry { max-height: none; }
}
