:root {
  --bg: #0f1115;
  --panel: #151820;
  --panel-2: #1b1f29;
  --raise: #222734;
  --line: #262b37;
  --line-2: #313849;
  --text: #e8ebf1;
  --text-2: #aab2c0;
  --muted: #7b8494;
  --accent: #3ddc97;
  --accent-ink: #062b1c;
  --danger: #ff6b6b;
  --warn: #f5b84b;
  --user-bubble: #23324a;
  --code-bg: #0b0d12;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f8;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --raise: #eef0f5;
  --line: #e3e6ed;
  --line-2: #d3d8e2;
  --text: #171a21;
  --text-2: #464d5b;
  --muted: #7a8291;
  --accent: #14a86b;
  --accent-ink: #ffffff;
  --user-bubble: #dfe9fb;
  --code-bg: #f1f3f7;
  --shadow: 0 10px 30px rgba(20, 30, 50, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
select, input, textarea { font: inherit; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
[hidden] { display: none !important; }

/* ---------- title bar ---------- */
.titlebar { height: 44px; display: flex; align-items: center; gap: 16px; padding: 0 150px 0 14px; -webkit-app-region: drag; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; }
.test-mode .titlebar { background: #b4530f; border-bottom-color: #f59e0b; }
.test-badge { font-size: 12px; font-weight: 700; color: #1a0b00; background: #fbbf24; padding: 2px 9px; border-radius: 99px; }
.logo { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(135deg, #3ddc97, #1b9e6b); color: #04170f; font-weight: 800; font-size: 13px; }
.checks { display: flex; gap: 8px; margin-left: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--line); padding: 2px 9px; border-radius: 99px; }
.check i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.check.bad i { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.locks { font-size: 12px; color: var(--warn); }
.title-actions { margin-left: auto; display: flex; gap: 4px; -webkit-app-region: no-drag; }
.icon-btn { position: relative; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; -webkit-app-region: no-drag; }
.icon-btn:hover { background: var(--raise); color: var(--text); }
.voice-dot { position: absolute; right: 6px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.voice-on .voice-dot { background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 268px minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr); height: calc(100% - 44px); }
.sidebar, .rightbar { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; }
.rightbar { border-right: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 16px 8px; }
.side-label.row { display: flex; justify-content: space-between; align-items: center; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0; }

/* ---------- agent cards ---------- */
.agent-list { display: flex; flex-direction: column; gap: 4px; padding: 0 8px; }
.agent { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 12px; border: 1px solid transparent; background: transparent; text-align: left; width: 100%; }
.agent:hover { background: var(--panel-2); }
.agent.active { background: var(--panel-2); border-color: var(--line-2); }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 750; color: #0b0d12; position: relative; }
.avatar .st { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--panel); background: var(--muted); }
.st.idle { background: #6c7686; }
.st.busy { background: var(--warn); animation: pulse 1.2s infinite; }
.st.live { background: var(--accent); }
.st.error, .st.offline, .st.limited { background: var(--danger); }
.agent-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.agent-role { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 5px; font-weight: 500; }
.agent-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.agent-sub.busy { color: var(--warn); }
.agent-sub.bad { color: var(--danger); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: white; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.limitbar { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: -2px; }
.limitbar span { display: block; height: 100%; background: var(--accent); }
.limitbar.warn span { background: var(--warn); }
.limitbar.bad span { background: var(--danger); }

/* the team stays put, only the conversation list scrolls; in a very short window the whole sidebar scrolls as a fallback */
.sidebar { display: flex; flex-direction: column; }
.sidebar > * { flex: none; }
.conv-list { padding: 0 8px 16px; display: flex; flex-direction: column; gap: 2px; }
.sidebar > .conv-list { flex: 1 1 0; min-height: 132px; overflow-y: auto; }
.conv { flex: none; }
.conv { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 9px; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv:hover { background: var(--panel-2); color: var(--text); }
.conv.active { background: var(--panel-2); color: var(--text); }
.conv small { color: var(--muted); margin-left: 6px; }

/* ---------- chat ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); }
.chat-who { display: flex; align-items: center; gap: 12px; }
.chat-who .avatar { width: 32px; height: 32px; border-radius: 10px; }
.chat-who h1 { font-size: 15px; margin: 0; font-weight: 650; }
.chat-who .sub { font-size: 12px; color: var(--muted); }
.chat-head-actions { display: flex; gap: 8px; align-items: center; }
.override { font-size: 12px; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); padding: 3px 9px; border-radius: 99px; cursor: pointer; }
.ghost-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); padding: 6px 12px; border-radius: 10px; color: var(--text-2); }
.ghost-btn:hover { color: var(--text); border-color: var(--muted); }

.messages { flex: 1; overflow-y: auto; padding: 26px 0 12px; scroll-behavior: auto; }
.msg-col { max-width: 860px; margin: 0 auto; padding: 0 28px; display: flex; flex-direction: column; gap: 14px; }
.row-user { display: flex; justify-content: flex-end; }
.bubble-user { max-width: 78%; background: var(--user-bubble); padding: 10px 15px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; word-wrap: break-word; }
.row-ai { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
.row-ai .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; margin-top: 2px; }
.bubble-ai { min-width: 0; padding-top: 3px; }
.bubble-ai > :first-child { margin-top: 0; }
.bubble-ai > :last-child { margin-bottom: 0; }
.bubble-ai p { margin: 0 0 .7em; }
.bubble-ai h1, .bubble-ai h2, .bubble-ai h3 { font-size: 15px; margin: 1em 0 .4em; }
.bubble-ai ul, .bubble-ai ol { margin: 0 0 .7em; padding-left: 1.3em; }
.bubble-ai li { margin: .15em 0; }
.bubble-ai code { font-family: var(--mono); font-size: 12.5px; background: var(--raise); padding: 1px 5px; border-radius: 5px; }
.bubble-ai pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.bubble-ai pre code { background: none; padding: 0; }
.bubble-ai table { border-collapse: collapse; margin: .4em 0 .8em; font-size: 13px; display: block; overflow-x: auto; }
.bubble-ai th, .bubble-ai td { border: 1px solid var(--line-2); padding: 5px 9px; text-align: left; }
.bubble-ai th { background: var(--panel-2); }
.bubble-ai a { color: var(--accent); }
.bubble-ai blockquote { margin: 0 0 .7em; padding-left: 12px; border-left: 3px solid var(--line-2); color: var(--text-2); }
.streaming::after { content: "▍"; color: var(--accent); animation: pulse 1s infinite; margin-left: 2px; }

.hub-card { border: 1px solid var(--line-2); background: var(--panel); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.hub-card .hub-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.hub-card .hub-head b { color: var(--text-2); }
.hub-card .hub-body { color: var(--text-2); max-height: 260px; overflow: auto; padding-top: 0; }

.steps { margin-left: 42px; border-left: 2px solid var(--line); padding: 2px 0 2px 12px; font-size: 12.5px; color: var(--muted); }
.steps summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.steps summary::-webkit-details-marker { display: none; }
.steps summary .chev { transition: transform .15s; width: 14px; height: 14px; }
.steps[open] summary .chev { transform: rotate(90deg); }
.step { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.step .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; transform: translateY(-1px); }
.step.running .dot { background: var(--warn); animation: pulse 1s infinite; }
.step.done .dot { background: var(--accent); }
.step.error .dot { background: var(--danger); }
.step.error { color: var(--danger); }

.notice { text-align: center; font-size: 12.5px; color: var(--muted); }
.notice.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-radius: 10px; padding: 8px 12px; text-align: left; white-space: pre-wrap; }

.welcome { margin: 9vh auto 0; text-align: center; max-width: 560px; padding: 0 20px; }
.welcome .avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; margin: 0 auto 18px; }
.welcome h2 { font-size: 24px; font-weight: 650; margin: 0 0 8px; letter-spacing: -.2px; }
.welcome p { color: var(--muted); margin: 0 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 99px; padding: 7px 14px; color: var(--text-2); font-size: 13px; }
.chip:hover { border-color: var(--accent); color: var(--text); }

/* ---------- permission / question cards ---------- */
.pending { max-width: 860px; margin: 0 auto; padding: 0 28px; display: flex; flex-direction: column; gap: 8px; }
.perm { border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line)); background: var(--panel); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.perm-title { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.perm-title .tag { font-size: 11px; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); padding: 0 7px; border-radius: 99px; font-weight: 500; }
.perm-detail { color: var(--text-2); font-size: 13px; margin: 4px 0 10px; font-family: var(--mono); white-space: pre-wrap; max-height: 140px; overflow: auto; }
.perm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.q-opts { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.q-opt { text-align: left; border: 1px solid var(--line-2); background: var(--panel-2); padding: 8px 12px; border-radius: 10px; }
.q-opt:hover, .q-opt.sel { border-color: var(--accent); }
.q-opt small { display: block; color: var(--muted); }
.q-other { width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 10px; }

.primary-btn { background: var(--accent); color: var(--accent-ink); border: 0; padding: 7px 16px; border-radius: 10px; font-weight: 600; }
.primary-btn:hover { filter: brightness(1.08); }
.small-btn { background: var(--raise); border: 1px solid var(--line-2); padding: 6px 12px; border-radius: 9px; }
.small-btn:hover { border-color: var(--muted); }
.danger-btn { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); padding: 7px 14px; border-radius: 10px; }

/* ---------- composer ---------- */
.composer-wrap { padding: 8px 0 18px; }
.composer { max-width: 860px; margin: 8px auto 0; width: calc(100% - 56px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 12px 8px 14px; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2)); }
#input { width: 100%; resize: none; border: 0; outline: 0; background: transparent; max-height: 240px; min-height: 24px; padding: 4px 2px; line-height: 1.5; }
.composer-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.pickers { display: flex; gap: 8px; flex-wrap: wrap; }
.picker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px 4px 3px 9px; }
.picker select { background: transparent; border: 0; outline: 0; font-size: 12.5px; color: var(--text); padding: 2px 2px; max-width: 220px; cursor: pointer; }
.picker select option { background: var(--panel); }
.send-row { display: flex; align-items: center; gap: 4px; }
.send-btn, .stop-btn { width: 36px; height: 36px; border-radius: 11px; border: 0; display: grid; place-items: center; }
.send-btn { background: var(--accent); color: var(--accent-ink); }
.send-btn:disabled { opacity: .35; cursor: default; }
.stop-btn { background: var(--raise); color: var(--text); border: 1px solid var(--line-2); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.attachments:not(:empty) { margin-bottom: 6px; }
.att { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; background: var(--raise); border-radius: 8px; padding: 3px 4px 3px 9px; }
.att button { border: 0; background: none; color: var(--muted); padding: 0 4px; }
.drop-hint { position: absolute; inset: 58px 0 0; display: none; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); border: 2px dashed var(--accent); border-radius: 16px; margin: 10px; font-size: 16px; color: var(--accent); z-index: 5; }
.dragging .drop-hint { display: grid; }

/* ---------- right bar ---------- */
.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow: auto; padding: 12px; }
.feed, .tasks { display: flex; flex-direction: column; gap: 8px; }
.feed-item { font-size: 12.5px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 11px; padding: 8px 10px; }
.feed-head { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.feed-head b { font-weight: 600; }
.feed-head .time { margin-left: auto; }
.feed-text { color: var(--text-2); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.feed-item.open .feed-text { -webkit-line-clamp: unset; }
.feed-item.kind-limit, .feed-item.kind-failover { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.mini { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; font-size: 9.5px; font-weight: 800; color: #0b0d12; }
.task { border: 1px solid var(--line); background: var(--panel-2); border-radius: 11px; padding: 8px 10px; font-size: 12.5px; }
.task-top { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; }
.task-status { margin-left: auto; font-weight: 600; }
.task-status.erledigt { color: var(--accent); }
.task-status.fehlgeschlagen, .task-status.unterbrochen { color: var(--danger); }
.task-status.in\ Arbeit { color: var(--warn); }
.task-text { color: var(--text-2); margin-top: 3px; white-space: pre-wrap; }
.task-result { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line-2); color: var(--text); white-space: pre-wrap; max-height: 160px; overflow: auto; }
.task-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.task-form-row { display: flex; gap: 6px; }
.task-form select, .task-form textarea { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 8px; }
.task-form select { flex: 1; }
.task-form textarea { resize: vertical; }
.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px 8px; }
.voice-panel { display: flex; flex-direction: column; gap: 10px; }
.voice-status { font-weight: 600; }
.voice-lines { display: flex; flex-direction: column; gap: 6px; }
.vl { font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); }
.vl.you { background: var(--user-bubble); align-self: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- dialog / toasts ---------- */
.dialog { border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 16px; padding: 22px 24px; width: 460px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog h2 { margin: 0 0 14px; font-size: 18px; }
.dialog h3 { margin: 18px 0 4px; font-size: 14px; }
.set-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 8px 0; }
.set-row select, .set-row input { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 9px; flex: 1; max-width: 260px; }
.dlg-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.toasts { position: fixed; right: 340px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); border-radius: 12px; padding: 10px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; animation: slidein .2s ease-out; cursor: pointer; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1280px) { .layout { grid-template-columns: 236px minmax(0, 1fr) 272px; } .tab { padding-left: 8px; padding-right: 8px; } }
@media (max-width: 1000px) { .layout { grid-template-columns: 236px minmax(0, 1fr) 0; } .rightbar { display: none; } .toasts { right: 24px; } }

/* ---------- limits ---------- */
.card-lims { grid-column: 2 / 4; display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 8px; row-gap: 2px; margin-top: -2px; font-size: 11.5px; }
.card-lims .limitbar { grid-column: auto; margin-top: 0; height: 4px; }
.cl-label { color: var(--muted); }
.cl-pct { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 34px; }
.cl-pct.warn { color: var(--warn); }
.cl-pct.bad { color: var(--danger); }
.limits-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.limits { display: flex; flex-direction: column; gap: 10px; }
.lim-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.lim-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lim-head .avatar { width: 22px; height: 22px; border-radius: 7px; font-size: 11px; }
.lim-head .muted { margin-left: auto; }
.lim-row { display: grid; grid-template-columns: 74px 1fr 44px; align-items: center; gap: 8px; font-size: 12.5px; margin-top: 6px; }
.lim-label { color: var(--text-2); }
.lim-bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.lim-bar span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.lim-bar.warn span { background: var(--warn); }
.lim-bar.bad span { background: var(--danger); }
.lim-pct { text-align: right; font-variant-numeric: tabular-nums; }
.lim-note { font-size: 11.5px; color: var(--muted); margin: 1px 0 0 82px; }
.lim-row .muted, .lim-row b { grid-column: 2 / 4; }
#liveArea { display: flex; flex-direction: column; gap: 14px; }
#liveArea:empty { display: none; }

/* team cards: a long status line ("führt aus: …") must not push the limit numbers out of the card */
.agent { grid-template-columns: 36px minmax(0, 1fr) auto; padding: 7px 10px; }
.agent > span:nth-child(2) { min-width: 0; }
.agent-sub { display: block; max-width: none; }
.card-lims { font-size: 11px; line-height: 1.3; row-gap: 1px; min-width: 0; }
.card-lims { grid-template-columns: auto minmax(24px, 1fr) auto auto; }
.cl-reset { color: var(--muted); font-size: 10.5px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cl-label { white-space: nowrap; }
