:root {
  --brand: #6c5ce7;
  --brand-d: #5847d6;
  --bg: #f5f5fa;
  --card: #ffffff;
  --ink: #1c1b2b;
  --muted: #7a7890;
  --line: #e7e6f0;
  --ok: #14a06a;
  --warn: #c9831a;
  --shadow: 0 1px 2px rgba(28,27,43,.05), 0 8px 24px rgba(28,27,43,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 14px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.logo { color: var(--brand); font-size: 22px; }
.brand .sub { font-weight: 500; color: var(--muted); font-size: 13px; }
.pills { display: flex; gap: 8px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f0eefc; color: var(--brand-d); font-weight: 500; }
.pill.ok { background: #e3f6ee; color: var(--ok); }
.pill.bad { background: #fbe9e9; color: #c0392b; }

.grid {
  display: grid; grid-template-columns: 230px 330px 1fr 250px; gap: 16px;
  padding: 18px 22px; max-width: 1500px; margin: 0 auto; align-items: start;
}
@media (max-width: 1280px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }

label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select, input[type=text], textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fcfcff; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,92,231,.12); }
textarea { resize: vertical; line-height: 1.45; }
input[type=range] { width: 100%; accent-color: var(--brand); margin-top: 8px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > select { flex: 1; }
button { font: inherit; font-weight: 600; cursor: pointer; border-radius: 9px; padding: 9px 14px; border: 1px solid transparent; }
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-d); }
button.ghost { background: #f3f2fb; color: var(--brand-d); border-color: var(--line); }
button.ghost:hover { background: #ebe9f9; }
button:disabled { opacity: .5; cursor: default; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* dialog */
.dialog { display: flex; flex-direction: column; min-height: 540px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.mic.live { background: #c0392b; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.4); } 50% { box-shadow: 0 0 0 8px rgba(192,57,43,0); } }
.note { background: #fff7e8; border: 1px solid #f3e2bd; color: var(--warn); padding: 8px 11px; border-radius: 9px; font-size: 12.5px; margin: 4px 0 0; }
.hidden { display: none; }

.log { flex: 1; overflow-y: auto; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 13px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #eef0ff; color: #2a2a4a; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #f5f4fb; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; font-weight: 600; }
.msg.interim { opacity: .55; font-style: italic; }
.log:empty::after { content: 'Нажмите «Говорить» (нужен Chrome + HTTPS) или напишите сообщение.'; color: var(--muted); font-size: 13px; }

.composer { display: flex; gap: 8px; }
.composer input { flex: 1; margin: 0; }

/* usage */
.metric { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.metric span { color: var(--muted); font-size: 12.5px; }
.metric b { font-variant-numeric: tabular-nums; }
.metric.big b { font-size: 20px; color: var(--brand-d); }
.bymodel { margin-top: 10px; font-size: 12px; }
.bymodel .bm { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }

/* preset actions */
.preset-actions { margin-top: 8px; gap: 6px; }
.preset-actions button { padding: 7px 9px; font-size: 12.5px; flex: 0 0 auto; }
.preset-actions button#preset-activate { flex: 1; }
button.danger { color: #c0392b; background: #fbeeee; }
button.danger:hover { background: #f7e0e0; }
select.mini { padding: 6px 8px; font-size: 12.5px; margin: 8px 0; }

/* history */
.history { max-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.hist-list { overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.hist-item { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; cursor: pointer; background: #fcfcff; }
.hist-item:hover { border-color: var(--brand); background: #f7f6fe; }
.hi-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.hi-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-badge { flex: 0 0 auto; }
.hi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* disposition badge */
.dispo { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: #f0eefc; color: var(--brand-d); margin-left: 8px; vertical-align: middle; }

/* состояния */
.dialog-controls { display: flex; gap: 8px; margin-bottom: 12px; }
button.big { width: 100%; padding: 12px; font-size: 15px; }
.live-status { font-size: 12.5px; font-weight: 700; color: #c0392b; white-space: nowrap; }
#mic-toggle { flex: 1; }
.msg.sys { align-self: center; max-width: 92%; text-align: center; background: #f0eefc; color: var(--brand-d); border: none; font-style: normal; opacity: .95; }
input:disabled, select:disabled, textarea:disabled, button:disabled { opacity: .55; cursor: not-allowed; }
.composer input:disabled { background: #f3f2f7; }
