:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212d;
  --border: #253244;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.hidden { display: none !important; }
.shell { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.offline { background: var(--warn); }
.top-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
select, input, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.active { border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { border-right: 1px solid var(--border); background: var(--panel); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.conv-item { text-align: left; background: transparent; border: 1px solid transparent; color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.active, .conv-item:hover { background: var(--panel-2); border-color: var(--border); }
.chat-panel { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 820px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); white-space: pre-wrap; word-break: break-word; line-height: 1.45; font-size: 14px; }
.msg.user { align-self: flex-end; background: #16243a; border-color: #264068; }
.msg.assistant { align-self: flex-start; }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.composer-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.composer-row { display: flex; gap: 8px; }
.composer-row textarea { flex: 1; resize: vertical; min-height: 44px; }
.tasks-view { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; max-width: 960px; width: 100%; margin: 0 auto; }
.task-card, .task-item { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.task-card h3 { margin: 0; font-size: 15px; }
.task-grid { display: grid; grid-template-columns: 1fr 220px; gap: 8px; }
.task-actions { display: flex; gap: 8px; }
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); text-transform: uppercase; }
.badge.pending { color: var(--warn); border-color: var(--warn); }
.badge.running { color: var(--accent); border-color: var(--accent); }
.badge.done { color: var(--ok); border-color: var(--ok); }
.badge.failed { color: var(--err); border-color: var(--err); }
.task-body { font-size: 13px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.task-result { font-size: 13px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; white-space: pre-wrap; word-break: break-word; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.modal-box h3 { margin: 0; }
.modal-box p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.modal-actions { display: flex; justify-content: flex-end; }
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 120px; }
  .conv-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .conv-item { max-width: 180px; flex-shrink: 0; }
  .task-grid { grid-template-columns: 1fr; }
}