:root {
  --bg: #11151c; --panel: #171c25; --panel2: #1e2430; --line: #2a3242; --text: #e6e9ef; --muted: #8b95a7;
  --accent: #7c9cff; --ok: #4fd1a5; --warn: #f2b84b; --err: #ff6b6b; --radius: 10px;
  --claude: #d9a066; --codex: #7c9cff; --gemini: #4fd1a5;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 600; }
button.danger { border-color: var(--err); color: var(--err); }
button.ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #0c0f14; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
#app { height: 100%; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* Pieslēgšanās */
.center { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(420px, 100%); }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.error { color: var(--err); margin: 8px 0; }
.success { color: var(--ok); margin: 8px 0; }

/* Izkārtojums */
.layout { display: grid; grid-template-columns: 280px 1fr; height: 100vh; height: 100dvh; }
.layout.with-panel { grid-template-columns: 280px 1fr minmax(320px, 40%); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar header { padding: 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.sidebar header strong { font-size: 15px; }
.tree { overflow: auto; flex: 1; padding: 8px; }
.server { margin-bottom: 12px; }
.server > .head { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 4px 6px; }
.workspace { margin: 2px 0 6px; }
.workspace > .head { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.workspace > .head:hover { background: var(--panel2); }
.chat-link { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 22px; border-radius: 6px; cursor: pointer; color: var(--text); text-decoration: none; }
.chat-link:hover { background: var(--panel2); }
.chat-link.active { background: #253049; }
.chat-link .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.claude { background: var(--claude); } .dot.codex { background: var(--codex); } .dot.gemini { background: var(--gemini); }
.busy { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.sidebar footer { padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 16px; flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button.on { background: var(--accent); color: #0b1020; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 920px; width: 100%; align-self: center; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg .body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; overflow-wrap: anywhere; }
.msg.user .body { background: #1d2740; border-color: #2c3a5e; }
.msg.system .body { background: transparent; border-style: dashed; color: var(--muted); }
.body p { margin: 0 0 8px; } .body p:last-child { margin-bottom: 0; }
.body ul, .body ol { margin: 0 0 8px 20px; padding: 0; }
.body h3, .body h4 { margin: 8px 0 4px; font-size: 15px; }
.run { max-width: 920px; width: 100%; align-self: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.run > .head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.run .live { padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.run .tools { padding: 0 14px 10px; font-size: 12px; color: var(--muted); }
.tool-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; font-size: 12px; }
.tool-line.err { color: var(--err); }
.tool-list { max-height: 260px; overflow: auto; margin-top: 4px; }
.status-running { color: var(--warn); } .status-done { color: var(--ok); } .status-failed, .status-cancelled { color: var(--err); }
details.helper { max-width: 920px; width: 100%; align-self: center; border: 1px dashed var(--line); border-radius: var(--radius); padding: 6px 12px; }
details.helper summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.composer { border-top: 1px solid var(--line); padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 40vh; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 520px; padding: 20px; }

.panel { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel .tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.panel .tabs button.on { border-color: var(--accent); color: var(--accent); }
.panel .content { flex: 1; overflow: auto; padding: 10px; min-height: 0; }
.files div.entry { display: flex; gap: 8px; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.files div.entry:hover { background: var(--panel2); }
.diff .add { color: #7ee2a8; } .diff .del { color: #ff8f8f; } .diff .hunk { color: var(--accent); }
.terminal-host { height: 100%; min-height: 360px; background: #000; border-radius: 8px; padding: 4px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(760px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal header { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.modal header h3 { margin: 0; flex: 1; }
.modal .body { padding: 16px; overflow: auto; }
.modal .tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.modal .tabs button.on { border-color: var(--accent); color: var(--accent); }
.agent-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); } .badge.no { color: var(--err); border-color: var(--err); } .badge.unk { color: var(--warn); border-color: var(--warn); }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 8px 0 8px 36px; border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: 12px; }
.steps li.done::before { content: "✓"; background: var(--ok); color: #0b1020; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; z-index: 60; }

.menu-btn { display: none; }
@media (max-width: 900px) {
  .layout, .layout.with-panel { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 86vw; max-width: 320px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .panel { position: fixed; inset: 0; z-index: 45; }
  .menu-btn { display: inline-block; }
  .messages { padding: 10px; }
}

/* Vadītā aģentu pieslēgšanās */
a.button { display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: inherit; margin-top: 6px; }
a.button.primary { background: var(--accent, #6d8cff); border-color: transparent; color: #0b1020; font-weight: 600; }
.login-panel:not(:empty) { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.login-panel .steps li { border-bottom: none; }
.user-code { font-size: 22px; letter-spacing: 2px; padding: 4px 10px; user-select: all; }
.login-output { max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
ul.prep { margin: 6px 0 10px; padding-left: 18px; }
ul.prep li { margin-bottom: 4px; }
details.advanced { margin-top: 10px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); } .warn { color: var(--warn); }

/* Aģentu profili, limiti, konteksts */
.avatar { display: inline-grid; place-items: center; width: 1.4em; height: 1.4em; font-size: 14px; line-height: 1; flex: none; }
.avatar.big { font-size: 22px; width: 1.5em; height: 1.5em; }
.row.wrap { flex-wrap: wrap; }
button.emoji { padding: 2px 6px; font-size: 18px; }
.usage-chip { font-size: 12px; white-space: nowrap; padding: 4px 8px; border: 1px solid var(--line); }
.usage-chip .ok { color: var(--ok); } .usage-chip .warn { color: var(--warn); } .usage-chip .err { color: var(--err); }
.icon-btn { display: inline-grid; place-items: center; }
.limit-bars { display: grid; gap: 4px; margin: 6px 0; }
.limit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.limit-label { width: 4.5em; }
.bar { display: inline-block; width: 120px; height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.bar .fill { display: block; height: 100%; }
.bar .fill.ok { background: var(--ok); } .bar .fill.warn { background: var(--warn); } .bar .fill.err { background: var(--err); }
.err { color: var(--err); }
select.compact { width: auto; max-width: 190px; font-size: 13px; padding: 4px 6px; }
.hint { background: transparent; border: 0; padding: 0 4px; color: var(--muted); cursor: help; font-size: 14px; }
.hint:hover { color: var(--accent); }
.profile-editor { margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.toast { max-width: min(560px, 92vw); cursor: pointer; }

.composer-wrap { border-top: 1px solid var(--line); }
.composer-wrap .composer { border-top: 0; padding-top: 4px; }
.composer-tools { display: flex; gap: 12px; padding: 6px 14px 0; }
.trace-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); user-select: none; }
.trace-toggle input { display: none; }
.trace-toggle .switch { width: 28px; height: 16px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); position: relative; transition: background .15s; }
.trace-toggle .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.trace-toggle input:checked + .switch { background: var(--accent); }
.trace-toggle input:checked + .switch::after { left: 14px; background: #0b1020; }
.trace-toggle:has(input:checked) { color: var(--text, inherit); }
.run-info { margin-top: 4px; gap: 8px; }
.trace { max-height: 75vh; overflow: auto; }
.trace-item { border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.trace-item summary { cursor: pointer; list-style: none; }
.trace-head { display: inline; }
.trace-head.err { color: var(--err); }
.trace-detail { display: block; margin: 3px 0 0 18px; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
.trace-item pre { margin: 6px 0 0 18px; }
