: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 { display: flex; align-items: center; gap: 8px; font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.5; min-width: 0; }
.tool-line.err { color: var(--err); }
.tool-line .tool-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-line .tool-time { flex-shrink: 0; margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tool-line.err .tool-time { color: inherit; }
.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; grid-template-columns: minmax(0,1fr); place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(760px, 100%); min-width: 0; 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; min-width: 0; }
.modal .row > label { min-width: 0; }
.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; }
.chat-primary, .chat-options { display: contents; }
.header-toggle { display: none; }
.toolbar-title { 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; }
  .topbar:has(.chat-primary) { display: grid; grid-template-columns: 28px max-content minmax(0,1fr) 30px; gap: 3px 6px; padding: 8px 10px; }
  .topbar:has(.chat-primary) > .menu-btn { padding: 0; width: 28px; height: 32px; }
  .topbar:has(.chat-primary) h2 { min-width: 0; font-size: 14px; }
  .chat-title { display: none; }
  .toolbar-title { display: inline; }
  .chat-primary { display: contents; }
  .chat-primary > .agent-select { grid-column: 3; grid-row: 1; justify-self: start; width: 100%; max-width: 210px; min-width: 0; font-size: 13px; }
  .agent-select > select { padding-top: 6px; padding-bottom: 6px; text-overflow: ellipsis; }
  .chat-primary .usage-chip { grid-column: 3 / -1; grid-row: 2; justify-self: start; max-width: 100%; white-space: normal; text-align: left; padding: 2px 0; }
  .header-toggle { grid-column: 4; grid-row: 1; display: inline-grid; place-items: center; width: 30px; height: 32px; padding: 0; font-size: 20px; }
  .chat-options { display: none; }
  .settings-open .chat-options { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%; max-height: min(240px,30dvh); overflow: auto; padding-top: 4px; border-top: 1px solid var(--line); }
  .chat-options select.compact { max-width: 100%; }
}
@media (min-width: 650px) and (max-width: 900px) {
  .topbar:has(.chat-primary) { grid-template-columns: 28px max-content minmax(140px,1fr) auto 30px; }
  .chat-primary .usage-chip { grid-column: 4; grid-row: 1; white-space: nowrap; }
  .header-toggle { grid-column: 5; }
}

/* 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; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ui-icon { display: inline-block; width: 1.2em; height: 1.2em; background: currentColor; mask: var(--icon) center / contain no-repeat; -webkit-mask: var(--icon) center / contain no-repeat; vertical-align: middle; flex: none; }
.avatar .ui-icon { width: 100%; height: 100%; }
.agent-select { position: relative; display: inline-flex; min-width: 0; max-width: 210px; }
.agent-select > .avatar { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.agent-select > select { width: 100%; min-width: 0; padding-left: 34px; }
.icon-preview { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(42px,1fr)); gap: 6px; max-width: 420px; }
.icon-choice { display: grid; place-items: center; height: 42px; padding: 8px; font-size: 20px; }
.icon-choice img { width: 24px; height: 24px; object-fit: contain; }
.icon-choice[aria-pressed="true"] { border-color: var(--accent); background: var(--panel); outline: 1px solid var(--accent); }
.avatar-picker { margin-bottom: 12px; min-width: 0; }
.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; }
.composer-side { display: contents; }
.composer-tools-toggle { display: none; }
@media (max-width: 900px) {
  .composer-wrap:not(.tools-open) .composer-tools { display: none; }
  .composer-tools { flex-wrap: wrap; max-height: min(160px,25dvh); overflow: auto; }
  .composer-tools .trace-toggle { min-width: 0; overflow-wrap: anywhere; }
  .composer-tools .switch { flex-shrink: 0; }
  .composer-wrap .composer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin: 8px 10px max(8px,env(safe-area-inset-bottom)); padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); align-items: center; }
  .composer textarea { grid-column: 1 / -1; grid-row: 1; width: 100%; min-width: 0; min-height: 62px; padding: 8px 4px; border: 0; border-radius: 6px; background: transparent; resize: none; font-size: 16px; }
  .composer-side { grid-column: 1; grid-row: 2; display: flex; flex-direction: row; align-items: center; gap: 4px; }
  .composer-side .attach { align-self: center; }
  .composer-side .attach-btn, .composer-tools-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; font-size: 20px; }
  .composer-tools-toggle[aria-expanded="true"] { color: var(--accent); background: var(--panel); }
  .composer #send-btn { grid-column: 2; grid-row: 2; min-height: 40px; padding: 8px 16px; margin: 0; }
  .composer .attach-menu { bottom: 46px; max-width: calc(100vw - 40px); }
}
.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; }

/* Pielikumi */
.main { position: relative; }
.drop-hint { display: none; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: 12px; background: rgba(15, 20, 35, .85); color: var(--accent); font-size: 18px; place-items: center; z-index: 30; pointer-events: none; }
.main.dragging .drop-hint { display: grid; }
.attach { position: relative; align-self: flex-end; }
.attach-btn { font-size: 20px; padding: 6px 8px; }
.attach-menu { position: absolute; bottom: 44px; left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 2px; z-index: 40; min-width: 220px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.attach-menu[hidden] { display: none; }
.attach-menu button { text-align: left; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 0; }
.attachments[hidden] { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 3px 4px 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); font-size: 12px; }
.chip.loading { opacity: .6; }
.chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-attachments img { max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.files .entry.selected { background: var(--panel2); }
.memory-view { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; max-height: 60vh; overflow: auto; background: var(--panel2); }
.kb-modal { width: min(1400px, 98vw); height: 92vh; display: flex; flex-direction: column; padding: 0; }
.kb-modal header { padding: 10px 14px; gap: 10px; }
.kb-modal header a.button { margin-top: 0; padding: 4px 10px; font-size: 13px; }
.kb-path { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-frame { flex: 1; width: 100%; border: 0; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--radius) var(--radius); }

.modal .body > label { display: block; margin: 12px 0; }
.modal .body input { width: 100%; }

/* Skrollēšana: poga uz jaunāko, ja lietotājs lasa augstāk */
.jump-wrap { position: relative; height: 0; display: flex; justify-content: center; z-index: 5; }
.jump-latest { position: absolute; bottom: 10px; border-radius: 999px; padding: 6px 14px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.35); background: var(--panel2); border: 1px solid var(--line); cursor: pointer; }
.jump-latest.unseen { background: var(--accent); color: #0b1020; border-color: transparent; font-weight: 600; }
.jump-latest[hidden] { display: none; }

/* Starplaiki starp rīkiem (modelis domā / raksta / gaida) */
.tool-line.gap-line { color: var(--muted); font-style: italic; border-left: 2px solid var(--line); padding-left: 8px; }
.tool-line.gap-line.open { border-left-color: var(--accent); }
.tool-line .tool-time.live { color: var(--accent); }
.tool-line .tool-time.slow { color: var(--warn, #e0b341); font-weight: 600; }
.tools .row.small { gap: 10px; flex-wrap: wrap; }
details.gap-details > summary { list-style: none; cursor: pointer; }
details.gap-details > summary::-webkit-details-marker { display: none; }
details.gap-details > summary .tool-text::after { content: ' ▸'; font-style: normal; }
details.gap-details[open] > summary .tool-text::after { content: ' ▾'; }
.thinking-text { font-family: ui-monospace, monospace; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; margin: 4px 0 6px 10px; padding: 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); }

/* Laika līnijas logs */
.tl-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 70px; gap: 4px 10px; align-items: center; font-size: 12px; }
.tl-row .tl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; }
.tl-row.gap .tl-label, .tl-row.prep .tl-label { font-style: italic; color: var(--muted); }
.tl-row.err .tl-label { color: var(--err); }
.tl-row .tl-time { text-align: right; font-variant-numeric: tabular-nums; }
.tl-row .tl-time.slow { color: var(--warn, #e0b341); font-weight: 600; }
.tl-track { grid-column: 2 / 4; height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; display: flex; }
.tl-bar { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.tl-bar.gap { background: #a78bfa; }
.tl-bar.prep { background: var(--muted); }
.trace-item summary .tl-row { cursor: pointer; }

/* Git */
.git-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.git-dialog label { display: block; margin: 8px 0; }
.git-dialog .choice { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; cursor: pointer; }
.git-dialog .choice input { width: auto; margin-top: 3px; }
.git-dialog .choice.on { border-color: var(--accent); }

/* „/” komandas un „@” pieminējumi */
.composer { position: relative; }
.ac-menu { position: absolute; left: 14px; right: 14px; bottom: calc(100% + 4px); max-height: 300px; overflow: auto; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.4); padding: 4px; }
.ac-menu[hidden] { display: none; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ac-item.on { background: var(--panel2); outline: 1px solid var(--accent); }
.ac-item .ac-icon { width: 1.4em; text-align: center; flex-shrink: 0; }
.ac-item .ac-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .badge { flex-shrink: 0; }
.ac-item.warn .ac-main strong { color: var(--muted); }
.ac-foot { padding: 6px 8px 2px; border-top: 1px solid var(--line); margin-top: 4px; }
.mention-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 14px 0; font-size: 12px; }
.mention-bar[hidden] { display: none; }
.mention-chip { display: inline-flex; align-items: center; gap: 4px; }
.mention-chip.warn { border-color: var(--warn); color: var(--warn); }
.mention-chip button { padding: 0 4px; }
.mention-plan { color: var(--muted); }


.composer-wrap { flex: none; min-width: 0; }
.messages { min-height: 0; }
.queue { border-bottom: 1px solid var(--line); min-width: 0; }
.queue[hidden], .queue-list[hidden] { display: none; }
.queue-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 12px; }
.queue-toggle { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 5px 0; min-width: 0; }
.queue-toggle strong { font-size: 13px; }
.queue-list { max-height: min(220px, 24dvh); overflow: auto; overscroll-behavior: contain; padding: 0 12px 8px; }
.queue-hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.queue-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.queue-info { min-width: 0; }
.queue-meta { font-size: 12px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-preview { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.queue-actions { display: flex; gap: 3px; }
.queue-icon { width: 30px; height: 30px; padding: 0; font-size: 16px; }
.queue-detail { grid-column: 1 / -1; min-width: 0; }
.queue-full-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: auto; font-size: 13px; padding: 6px 0; }
.queue-parallel { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; align-items: center; }
.queue-parallel select { width: auto; max-width: 100%; min-width: 0; font-size: 12px; }
.queue-parallel button { min-height: 36px; }
.queue-delivery { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.queue-delivery select { width: auto; max-width: 100%; flex: 1; min-width: 140px; font-size: 12px; }
@media (max-width: 600px) {
  .composer-tools { flex-wrap: wrap; gap: 6px 8px; }
  .composer-tools input[type="checkbox"] { width: auto; }
  .queue-header { padding: 4px 10px; }
  .queue-list { max-height: min(180px,22dvh); padding-inline: 10px; }
  .queue-item { gap: 6px; }
  .queue-icon { width: 32px; height: 34px; }
  .queue-actions { display: grid; grid-template-columns: repeat(2,32px); gap: 3px; }
  .queue-preview { -webkit-line-clamp: 2; }
}

/* Attēli atveras virs čata; navigācija paliek sasniedzama arī šaurā ekrānā. */
.image-thumbnail { padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.image-viewer { width: min(1100px, calc(100vw - 24px)); max-width: none; height: min(850px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); padding: 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--bg, #11151c); overflow: hidden; }
.image-viewer::backdrop { background: rgba(0,0,0,.85); }
.image-viewer[open] { display: flex; flex-direction: column; gap: 12px; }
.image-viewer header { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.image-viewer-caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.image-viewer button { min-width: 44px; min-height: 44px; flex-shrink: 0; }
.image-viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 10px; }
.image-viewer-stage img { width: 100%; min-width: 0; height: 100%; object-fit: contain; }
.image-viewer-stage button { font-size: 32px; padding: 0; }
.image-viewer-stage p { position: absolute; bottom: 0; background: #11151c; padding: 8px; }
@media (max-width: 600px) {
  .image-viewer { padding: 8px; }
  .image-viewer-stage { padding-bottom: 54px; }
  .image-viewer-stage button { position: absolute; bottom: 0; }
  .image-viewer-stage button:first-child { left: 0; }
  .image-viewer-stage button:nth-of-type(2) { right: 0; }
}

.chat-name-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; color: var(--text); }
.chat-name-dialog:not([open]) { display: none; }
.chat-name-dialog::backdrop { background: rgba(0,0,0,.65); }
.chat-name-dialog form { display: grid; gap: 12px; }
.chat-name-dialog form .row { justify-content: flex-end; }

.delete-dialog .delete-options { display: grid; gap: 12px; }
.delete-dialog .delete-options label { display: flex; gap: 10px; align-items: flex-start; }
.delete-dialog .delete-options input { width: auto; flex: 0 0 auto; margin-top: 3px; }
.delete-dialog .body p, .delete-dialog .body label { overflow-wrap: anywhere; }
.delete-dialog { max-height: calc(100dvh - 32px); overflow: auto; }

.delete-dialog .body > label[hidden] { display: none; }

.telegram-logo { display: inline-block; vertical-align: middle; flex-shrink: 0; object-fit: contain; }
