:root {
  --bg: #0b0c0e;
  --bg-2: #0f1013;
  --panel: #141519;
  --panel-2: #191b20;
  --panel-3: #20232a;
  --line: #23262d;
  --line-2: #2f333b;
  --text: #ececee;
  --muted: #9a9ea8;
  --dim: #646872;
  --accent: #d6ff3d;
  --accent-hover: #e3ff70;
  --accent-ink: #111402;
  --accent-soft: rgba(214, 255, 61, .12);
  --ok: #46d39a;
  --err: #ff6b6b;
  --warn: #ffbe55;
  --ws: #a78bfa;
  --r: 10px;
  --r-sm: 7px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-2); }
code { font-family: var(--mono); }
.ic { width: 16px; height: 16px; flex: none; }

/* ---------------- layout ---------------- */
.app { display: grid; grid-template-columns: 256px 1fr; height: 100vh; overflow: hidden; }

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name { font-weight: 600; letter-spacing: -.01em; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--dim); }

.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  font: 500 10.5px/1 var(--mono);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: 16px 10px 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0; background: none;
  text-align: left; cursor: pointer;
  position: relative;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .ic { width: 17px; height: 17px; }
.nav-item.active .ic { color: var(--accent); }
.nav-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.nav-text b { font-weight: 500; font-size: 13.5px; }
.nav-text code { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item { text-decoration: none; }
.nav-badge { margin-left: auto; font: 600 9.5px var(--mono); letter-spacing: .06em; padding: 2px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.nav-item.busy::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.2s ease-in-out infinite;
}
.nav-item.live::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 3px rgba(70, 211, 154, .18);
}

.history { margin-top: auto; border-top: 1px solid var(--line); min-height: 0; display: flex; flex-direction: column; max-height: 36%; }
.history ul { list-style: none; margin: 0; padding: 0 10px 12px; overflow: auto; }
.history li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.history li:hover { background: var(--panel); color: var(--text); }
.history li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .st { font: 500 10.5px var(--mono); padding: 1px 6px; border-radius: 4px; background: var(--panel-3); }
.history .t { font: 10.5px var(--mono); color: var(--dim); }
.history .empty-h { color: var(--dim); font-size: 12px; padding: 4px 8px; cursor: default; }
.history .empty-h:hover { background: none; color: var(--dim); }
.st.ok { color: var(--ok); }
.st.err { color: var(--err); }
.link-btn { background: none; border: 0; color: var(--dim); cursor: pointer; font: 11px var(--font); letter-spacing: 0; text-transform: none; padding: 0; }
.link-btn:hover { color: var(--text); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 60px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--line); gap: 16px;
}
.ep-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.method {
  font: 600 11px/1 var(--mono); padding: 5px 7px; border-radius: 5px; letter-spacing: .04em;
  background: rgba(70, 211, 154, .12); color: var(--ok); flex: none;
}
.method.m-WS { background: rgba(167, 139, 250, .14); color: var(--ws); }
.method.m-GET { background: rgba(96, 165, 250, .14); color: #7cb4ff; }
.ep-path { font: 500 14.5px var(--mono); white-space: nowrap; }
.ep-desc { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.key-pill {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel);
  cursor: pointer; font: 12.5px var(--mono); color: var(--muted); transition: border-color .15s;
}
.key-pill:hover { border-color: var(--muted); color: var(--text); }
.key-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 190, 85, .16); }
.key-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(70, 211, 154, .16); }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; color: var(--muted);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--muted); color: var(--text); }

.workspace { flex: 1; display: grid; grid-template-columns: minmax(360px, 440px) 1fr; min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.req-panel { border-right: 1px solid var(--line); background: var(--bg-2); }
.panel-head {
  height: 46px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line); gap: 12px;
}
.panel-label { font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.panel-sub { font: 11.5px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { flex: 1; overflow: auto; min-height: 0; }
.req-panel .panel-body { padding: 18px; }
.panel-foot { padding: 14px 18px; border-top: 1px solid var(--line); }

/* ---------------- form ---------------- */
.ep-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin: 0; }
.field > span { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field > span em, .field > span output { font-style: normal; color: var(--dim); font-size: 11.5px; font-family: var(--mono); }
.field small { color: var(--dim); font-size: 11.5px; }
.field small code { background: var(--panel-3); padding: 0 4px; border-radius: 3px; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=url], textarea, select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 42px; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--dim); }
input[name=model], input[name=voice], input[name=voice_id], input[name=language], input[name=image_url], input[name=url] { font-family: var(--mono); font-size: 13px; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { margin: 0; font-size: 12px; color: var(--dim); line-height: 1.6; }

.seg { display: flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg label { flex: 1; position: relative; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 5px 6px; border-radius: 5px;
  font: 12px var(--mono); color: var(--muted); cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; transition: background .12s, color .12s;
}
.seg span:hover { color: var(--text); }
.seg input:checked + span { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.switches { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; position: relative; }
.switch:hover { color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 30px; height: 18px; border-radius: 999px; background: var(--panel-3); border: 1px solid var(--line-2); position: relative; transition: .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { left: 14px; background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range] { accent-color: var(--accent); width: 100%; margin: 4px 0; }

.extra summary {
  cursor: pointer; color: var(--dim); font-size: 12.5px; list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.extra summary::-webkit-details-marker { display: none; }
.extra summary::before { content: "+"; font-family: var(--mono); width: 14px; text-align: center; }
.extra[open] summary::before { content: "−"; }
.extra summary:hover { color: var(--text); }
.extra textarea { margin-top: 8px; font: 12.5px/1.6 var(--mono); }

.combo { position: relative; }
.combo input { padding-right: 34px; }
.combo-btn {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 32px;
  display: grid; place-items: center; border: 0; background: none;
  color: var(--dim); cursor: pointer; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.combo-btn:hover { color: var(--text); }
.combo-btn .ic { width: 15px; height: 15px; transition: transform .15s; }
.combo.open .combo-btn .ic { transform: rotate(180deg); color: var(--accent); }
.combo-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  max-height: 260px; overflow: auto; padding: 4px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
}
.combo-opt {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 5px;
  cursor: pointer; font-size: 13px; color: var(--muted);
}
.combo-opt .v { font-family: var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt .l { color: var(--dim); font-size: 12px; white-space: nowrap; }
.combo-opt .ic { width: 14px; height: 14px; margin-left: auto; color: var(--accent); }
.combo-opt.active { background: var(--panel-3); }
.combo-opt.sel .v { color: var(--accent); }
.combo-none { padding: 8px 10px; font-size: 12px; color: var(--dim); }

.imglist { display: flex; flex-direction: column; gap: 8px; }
.il-items { display: flex; flex-wrap: wrap; gap: 8px; }
.il-item { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-2); background: var(--panel); }
.il-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.il-item i { position: absolute; left: 4px; top: 4px; font: 600 10px var(--mono); font-style: normal; background: rgba(0, 0, 0, .65); color: #fff; border-radius: 4px; padding: 0 4px; }
.il-item button { position: absolute; right: 3px; top: 3px; width: 18px; height: 18px; border-radius: 4px; border: 0; background: rgba(0, 0, 0, .7); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; padding: 0; }
.il-item button .ic { width: 11px; height: 11px; }
.il-item:hover button, .il-item button:focus-visible { opacity: 1; }
.il-item button:hover { background: var(--err); }
.imglist input:disabled { opacity: .5; }
.vsrc { display: flex; flex-direction: column; gap: 8px; }
.vsrc-preview { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); }
.vsrc-preview video { width: 100%; max-height: 200px; border-radius: 6px; background: #000; display: block; }
.vsrc-meta { display: flex; align-items: center; gap: 10px; font: 11.5px var(--mono); color: var(--muted); }
.vsrc-meta span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vsrc-warn { font-size: 12px; color: var(--warn); }
.mode-hint { margin: 0; font: 11.5px/1.5 var(--mono); color: var(--dim); padding: 7px 10px; border: 1px dashed var(--line-2); border-radius: var(--r-sm); }
.mode-hint.on { color: var(--accent); border-style: solid; border-color: rgba(214, 255, 61, .3); background: var(--accent-soft); }

.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }

.btn {
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: pointer; font-size: 13px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: none; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--err); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn .ic { width: 14px; height: 14px; }

.thumb { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); font: 12px var(--mono); color: var(--muted); }
.thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 5px; }
.thumb span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 22px 16px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--panel);
  transition: border-color .15s, color .15s, background .15s; outline: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.drop b { color: var(--accent); font-weight: 500; }
.drop small { color: var(--dim); font: 11.5px var(--mono); }
.drop .ic { width: 22px; height: 22px; margin-bottom: 4px; color: var(--dim); }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.file-info { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--panel); }
.file-info .fi-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 12px var(--mono); color: var(--muted); }
.file-info .fi-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info audio { width: 100%; height: 34px; }

.rec { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); }
.rec-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: border-color .15s;
}
.rec-btn span { width: 16px; height: 16px; border-radius: 50%; background: var(--err); transition: .15s; }
.rec-btn:hover { border-color: var(--err); }
.rec-btn.on { border-color: var(--err); animation: ring 1.4s ease-out infinite; }
.rec-btn.on span { border-radius: 3px; width: 14px; height: 14px; }
.rec-info { display: flex; flex-direction: column; }
.rec-info b { font-weight: 500; font-size: 13px; }
.rec-info small { font: 12px var(--mono); color: var(--dim); }

/* ---------------- send ---------------- */
.send-btn {
  width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: var(--r); background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: transform .08s, background .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: translateY(1px); }
.send-btn .ic { width: 14px; height: 14px; fill: currentColor; }
.send-btn kbd { font: 11px var(--mono); opacity: .5; margin-left: 2px; }
.send-btn.busy { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.send-btn.busy .ic { display: none; }
.send-btn.busy::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.send-btn.live { background: rgba(255, 107, 107, .1); color: var(--err); box-shadow: inset 0 0 0 1px rgba(255, 107, 107, .35); }
.send-btn.live .ic { display: none; }

/* ---------------- response ---------------- */
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button {
  background: none; border: 0; padding: 0 12px; color: var(--dim); cursor: pointer;
  font-size: 13px; position: relative; height: 100%; transition: color .12s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); }
.tabs button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.res-meta { display: flex; gap: 12px; align-items: center; font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
.chip { padding: 3px 8px; border-radius: 5px; font: 500 11.5px var(--mono); background: var(--panel-3); color: var(--muted); }
.chip.ok { color: var(--ok); background: rgba(70, 211, 154, .1); }
.chip.err { color: var(--err); background: rgba(255, 107, 107, .1); }
.chip.ws { color: var(--ws); background: rgba(167, 139, 250, .12); }
.chip.run { color: var(--accent); background: var(--accent-soft); }

.res-panel .panel-body {
  background-image: radial-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px);
  background-size: 22px 22px;
}
.view { min-height: 100%; display: flex; flex-direction: column; }
.pane { display: none; }
#views[data-tab=preview] .pane[data-pane=preview] { display: flex; flex-direction: column; flex: 1; padding: 26px; }
#views[data-tab=raw] .pane[data-pane=raw] { display: block; flex: 1; background: var(--bg); }
#views[data-tab=req] .pane[data-pane=req] { display: flex; flex-direction: column; gap: 16px; flex: 1; padding: 22px; background: var(--bg); }

pre.code { margin: 0; font: 12.5px/1.65 var(--mono); white-space: pre-wrap; word-break: break-word; color: #c8cbd2; }
.pane[data-pane=raw] > pre { padding: 20px 22px; }
.j-k { color: #8ec5ff; }
.j-s { color: #c3e88d; }
.j-n { color: #f8c555; }
.j-b { color: #ff9ac1; }
.dimtext { color: var(--dim); }

.empty { flex: 1; min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--dim); gap: 4px; }
.empty-mark {
  width: 60px; height: 60px; border-radius: 16px; border: 1px dashed var(--line-2);
  display: grid; place-items: center; margin-bottom: 14px; color: var(--muted); background: var(--bg-2);
}
.empty-mark .ic { width: 24px; height: 24px; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; }
.empty small { font-size: 12.5px; }

.loading { flex: 1; min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.orb {
  width: 56px; height: 56px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), transparent 72%);
  -webkit-mask: radial-gradient(circle, transparent 54%, #000 56%);
  mask: radial-gradient(circle, transparent 54%, #000 56%);
  animation: spin 1s linear infinite;
}
.loading p { margin: 0; }
.elapsed { font: 12px var(--mono); color: var(--dim); }

.err-card { max-width: 760px; width: 100%; margin: 0 auto; border: 1px solid rgba(255, 107, 107, .35); background: rgba(255, 107, 107, .06); border-radius: var(--r); padding: 16px 18px; }
.err-card h4 { margin: 0 0 8px; color: var(--err); font-size: 14px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.err-card pre { margin: 0; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; color: #f3c4c4; }
.note-card { max-width: 760px; width: 100%; margin: 0 auto 14px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* chat */
.chat-wrap { max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.chat-toolbar { display: flex; justify-content: space-between; align-items: center; font: 11.5px var(--mono); color: var(--dim); }
.chat { display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; }
.msg .avatar { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; font: 600 11.5px var(--mono); }
.msg.user .avatar { background: var(--panel-3); color: var(--muted); }
.msg.assistant .avatar { background: var(--accent); color: var(--accent-ink); }
.msg .bubble { min-width: 0; flex: 1; padding-top: 3px; }
.msg .who { font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.msg.user .body { white-space: pre-wrap; word-break: break-word; }
.msg .foot { margin-top: 8px; font: 11.5px var(--mono); color: var(--dim); }
.msg .foot:empty { display: none; }
.msg.err .body { color: var(--err); font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.thinking { display: inline-flex; gap: 4px; padding: 6px 0; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }

.md { line-height: 1.7; word-break: break-word; }
.md p { margin: 0 0 .75em; }
.md > :last-child { margin-bottom: 0; }
.md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 .5em; font-size: 15px; font-weight: 600; }
.md ul, .md ol { margin: 0 0 .8em; padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md code { font-size: 12.5px; background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }
.md pre.code { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: .3em 0 .9em; }
.md pre code { background: none; padding: 0; }
.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; }

/* image */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; width: 100%; }
.img-card { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.img-card a.img { display: block; background: var(--panel-2); }
.img-card img { display: block; width: 100%; height: auto; }
.img-card figcaption { padding: 10px 12px 4px; font-size: 12.5px; color: var(--muted); }
.img-card .actions { display: flex; gap: 8px; padding: 10px 12px 12px; margin-top: auto; }

/* video */
.job { max-width: 520px; width: 100%; margin: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.job-head { display: flex; justify-content: space-between; align-items: center; }
.job-head b { font-weight: 600; }
.bar { height: 4px; background: var(--panel-3); border-radius: 4px; overflow: hidden; position: relative; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; transition: width .4s; }
.bar.indet span { width: 35%; animation: indet 1.4s ease-in-out infinite; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; font-family: var(--mono); color: var(--text); word-break: break-all; }
.vid-wrap { max-width: 920px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.vid-wrap video { width: 100%; max-height: 68vh; border-radius: 12px; background: #000; border: 1px solid var(--line); }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions .grow { flex: 1; font: 12px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* search */
.answer { max-width: 820px; width: 100%; margin: 0 auto; }
.answer-head { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.section-label { font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin: 26px 0 10px; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.source {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  text-decoration: none; color: var(--text); min-width: 0; transition: border-color .15s;
}
.source:hover { border-color: var(--accent); }
.source .n { font: 600 11px var(--mono); color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 1px 5px; flex: none; margin-top: 2px; }
.source .s-body { min-width: 0; display: flex; flex-direction: column; }
.source .ttl { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .d { font: 11px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tts */
.audio-card { max-width: 660px; width: 100%; margin: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.audio-top { display: flex; align-items: center; gap: 14px; }
.play-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; transition: transform .1s; }
.play-btn:hover { transform: scale(1.05); }
.play-btn .ic { width: 18px; height: 18px; fill: currentColor; }
.audio-top .meta { display: flex; flex-direction: column; min-width: 0; }
.audio-top .meta b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-top .meta small { font: 12px var(--mono); color: var(--dim); }
.wave { width: 100%; height: 64px; display: block; cursor: pointer; }

/* stt */
.transcript { max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.transcript .text { font-size: 16px; line-height: 1.8; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; white-space: pre-wrap; word-break: break-word; }
.words { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.words th { text-align: left; font: 500 11px var(--mono); color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.words td { padding: 5px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); color: var(--muted); }
.words td:last-child { color: var(--text); font-family: var(--font); }

/* realtime */
.rt { display: flex; flex-direction: column; flex: 1; max-width: 820px; width: 100%; margin: 0 auto; }
.rt-stage { display: flex; align-items: center; gap: 18px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 20px; }
.rt-orb { width: 54px; height: 54px; border-radius: 50%; flex: none; position: relative; display: grid; place-items: center; }
.rt-orb::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--panel-3); transform: scale(var(--lvl, 1)); transition: transform .08s, background .2s; }
.rt-orb::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: var(--dim); position: relative; transition: background .2s; }
.rt-orb[data-s=open]::after, .rt-orb[data-s=ready]::after { background: var(--ok); }
.rt-orb[data-s=listening]::before { background: rgba(214, 255, 61, .18); }
.rt-orb[data-s=listening]::after { background: var(--accent); }
.rt-orb[data-s=speaking]::before { background: rgba(167, 139, 250, .2); animation: breathe 1s ease-in-out infinite; }
.rt-orb[data-s=speaking]::after { background: var(--ws); }
.rt-orb[data-s=thinking]::after { background: var(--warn); animation: pulse 1s infinite; }
.rt-orb[data-s=connecting]::after { background: var(--warn); animation: pulse .8s infinite; }
.rt-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rt-info b { font-weight: 600; }
.rt-info small { font: 12px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt .chat { flex: 1; padding-bottom: 12px; }
.rt-bar {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center;
  padding: 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 14px;
  margin-top: 16px; box-shadow: 0 -12px 30px var(--bg);
}
.rt-bar input { flex: 1; background: var(--panel); }
.mic-btn {
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text); flex: none;
}
.mic-btn:disabled, .rt-bar input:disabled, .rt-bar .btn:disabled { opacity: .4; cursor: not-allowed; }
.mic-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.rt-empty { text-align: center; color: var(--dim); font-size: 13px; padding: 40px 0; }

.evlog { white-space: normal !important; font: 12px/1.55 var(--mono); padding: 14px 18px !important; }
.ev { display: grid; grid-template-columns: 92px 14px minmax(0, auto) 1fr; gap: 10px; padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, .04); align-items: baseline; }
.ev .ts { color: var(--dim); }
.ev .dir { color: var(--ok); }
.ev-out .dir { color: var(--ws); }
.ev-sys .dir { color: var(--warn); }
.ev b { font-weight: 500; color: var(--text); white-space: nowrap; }
.ev code { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-err b { color: var(--err); }

/* request pane */
.req-line { display: flex; align-items: center; gap: 10px; font: 13px var(--mono); word-break: break-all; }
.block { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.block-head {
  display: flex; justify-content: space-between; align-items: center; padding: 7px 12px;
  border-bottom: 1px solid var(--line); font: 500 11px var(--mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--dim);
}
.block pre { padding: 12px 14px; }
.copy { background: none; border: 1px solid var(--line-2); color: var(--muted); border-radius: 5px; font: 11.5px var(--font); padding: 2px 9px; cursor: pointer; letter-spacing: 0; text-transform: none; }
.copy:hover { color: var(--text); border-color: var(--muted); }
.req-note { font-size: 12.5px; color: var(--muted); margin: 0; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw;
  background: var(--bg-2); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  z-index: 50; display: flex; flex-direction: column;
}
.drawer.open { transform: none; box-shadow: -30px 0 60px rgba(0, 0, 0, .4); }
.drawer-head { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.drawer-body { padding: 22px 20px; display: flex; flex-direction: column; gap: 20px; overflow: auto; }
.drawer-actions { display: flex; gap: 8px; }
.drawer-actions .ghost { margin-left: auto; }
.conn-result:empty { display: none; }
.conn-result { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 14px; font-size: 13px; }
.conn-result .ok { color: var(--ok); }
.conn-result .err { color: var(--err); }
.models { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; max-height: 260px; overflow: auto; }
.model-chip { font: 11.5px var(--mono); padding: 3px 8px; border-radius: 5px; background: var(--panel-3); color: var(--muted); }

/* toast */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; font-size: 13px; max-width: 380px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45); animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, .45); } 100% { box-shadow: 0 0 0 12px rgba(255, 107, 107, 0); } }
@keyframes breathe { 50% { transform: scale(1.12); } }
@keyframes indet { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .workspace { display: block; overflow: auto; }
  .panel, .panel-body { min-height: auto; }
  .panel-body { flex: none; overflow: visible; }
  .req-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .res-panel { min-height: 70vh; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { display: none; }
  .nav { flex-direction: row; padding: 8px; }
  .nav-group, .history, .nav-text code { display: none; }
  .nav-item { white-space: nowrap; }
  .nav-item.active::before { display: none; }
  .ep-desc { display: none; }
}
