/* Atheya workspace shell: consolidated navigation, Codex-style agent screen,
   bots panel and settings tabs. Uses the existing design tokens from styles.css. */

/* ---------- Light warm palette (owner preference, 2026-09-20: "как у Claude") ----------
   Cream ground, white cards, terracotta accent, hairline borders, almost no shadow. */
:root, html[data-resolved-theme="light"], html[data-theme="light"], html[data-theme="system"] {
  --bg: #faf9f5;
  --shell: #f3f2ec;
  --surface: #ffffff;
  --card: #ffffff;
  --hover: #f0efe8;
  --accent: #c96442;
  --text: #1f1e1b;
  --muted: #87867f;
  --border: rgba(31, 30, 27, 0.09);
  --danger: #b5482f;
  --ok: #5f8a5a;
  --shadow: 0 1px 2px rgba(31, 30, 27, 0.04);
  --cyan-glow: rgba(201, 100, 66, 0.18);
  --ws-ok: #5f8a5a;
  --ws-warn: #c08a3e;
  --ws-err: #b5482f;
  --ws-info: #6b7d94;
  --ws-primary: #c96442;
  --atheya-ok-light: #5f8a5a;
  --atheya-error-light: #b5482f;
  color-scheme: light;
}
html[data-resolved-theme="dark"], html[data-resolved-theme="dark"][data-theme] {
  --bg: #262624;
  --shell: #1f1e1c;
  --surface: #30302e;
  --card: #30302e;
  --hover: #3a3936;
  --accent: #d97757;
  --text: #ecebe6;
  --muted: #9b9a93;
  --border: rgba(236, 235, 230, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ws-ok: #8fb08a;
  --ws-warn: #d7a763;
  --ws-err: #d98a74;
  --ws-info: #9aabbf;
  --ws-primary: #d97757;
  color-scheme: dark;
}
html[data-resolved-theme="dark"] .ws-primary { color: #1f1e1b; }

:root {
  --ws-radius: 12px;
  --ws-radius-sm: 8px;
  --ws-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ws-soft: color-mix(in srgb, var(--text) 5%, transparent);
  --ws-softer: color-mix(in srgb, var(--text) 3%, transparent);
}

/* ---------- Navigation ---------- */
.nav-stack .nav-item[data-nav-group] { display: flex; align-items: center; gap: 10px; }
.nav-stack .nav-item .nav-icon { width: 18px; text-align: center; opacity: .8; }
.nav-stack .nav-item .nav-hint { margin-left: auto; font-size: 11px; color: var(--muted); }
.nav-stack .nav-badge { margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 9px; background: var(--ws-warn); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.nav-stack .nav-badge[hidden] { display: none; }

/* ---------- Settings tabs ---------- */
#settings-tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 14px 24px 0; margin: 0; }
#settings-tabs button { border: 1px solid transparent; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer; min-height: 0; }
#settings-tabs button:hover { background: var(--ws-soft); color: var(--text); }
#settings-tabs button.active { background: var(--card); border-color: var(--border); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
#settings-tabs[hidden] { display: none; }

/* ---------- Agent (Codex-style) ---------- */
#agent-view { padding: 0 !important; background: var(--bg) !important; height: 100%; overflow: hidden !important; max-width: none !important; }
.ws { display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; height: 100%; min-height: 0; }
.ws > * { min-width: 0; min-height: 0; }
.ws-threads { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--shell, var(--bg)); }
.ws-threads-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.ws-threads-head strong { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ws-thread-list { overflow: auto; padding: 0 8px 16px; }
.ws-thread-group { padding: 12px 8px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ws-thread { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; width: 100%; padding: 10px 10px; border: 0; border-radius: var(--ws-radius-sm); background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit; min-height: 0; }
.ws-thread:hover { background: var(--ws-soft); }
.ws-thread.active { background: var(--card); box-shadow: 0 0 0 1px var(--border); }
.ws-thread .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.ws-thread .title { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ws-thread .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ws-empty { padding: 24px 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }

[data-status] .dot { background: var(--muted); }
[data-status="running"] .dot, [data-status="applying"] .dot, [data-status="restoring"] .dot { background: var(--ws-info); animation: ws-pulse 1.2s infinite; }
[data-status="awaiting_approval"] .dot, [data-status="waiting_user"] .dot, [data-status="waiting_login"] .dot, [data-status="paused"] .dot { background: var(--ws-warn); }
[data-status="review"] .dot, [data-status="completed"] .dot, [data-status="applied"] .dot { background: var(--ws-ok); }
[data-status="failed"] .dot, [data-status="recovery_required"] .dot, [data-status="interrupted"] .dot { background: var(--ws-err); }
@keyframes ws-pulse { 50% { opacity: .35; } }

.ws-main { display: flex; flex-direction: column; background: var(--bg); }
.ws-main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); }
.ws-main-head h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-main-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.ws-run-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ws-conversation { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.ws-conversation > * { max-width: 860px; width: 100%; margin: 0 auto; }

.ws-user { align-self: flex-end; background: var(--card); border: 1px solid var(--border); border-radius: 16px 16px 4px 16px; padding: 12px 16px; white-space: pre-wrap; line-height: 1.55; font-size: 14px; max-width: 720px !important; margin-right: 0 !important; }
.ws-user .ws-user-meta { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; font-family: var(--ws-mono); }
.ws-assistant { line-height: 1.6; font-size: 14px; padding: 4px 2px; }
.ws-assistant p { margin: 0 0 10px; white-space: pre-wrap; }
.ws-assistant pre { background: var(--ws-softer); border: 1px solid var(--border); border-radius: var(--ws-radius-sm); padding: 12px; font: 12px/1.55 var(--ws-mono); overflow: auto; white-space: pre-wrap; }
.ws-assistant h3 { font-size: 14px; margin: 12px 0 6px; }
.ws-thinking { color: var(--muted); font-size: 13px; font-style: italic; padding: 0 2px; }

.ws-step { border: 1px solid var(--border); border-radius: var(--ws-radius); background: var(--card); overflow: hidden; }
.ws-step summary { list-style: none; display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; font-size: 13px; }
.ws-step summary::-webkit-details-marker { display: none; }
.ws-step summary .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--ws-soft); font-size: 12px; }
.ws-step summary code { font-family: var(--ws-mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-step summary .tag { font-size: 11px; color: var(--muted); }
.ws-step[data-outcome="error"] summary .ic { background: color-mix(in srgb, var(--ws-err) 15%, transparent); color: var(--ws-err); }
.ws-step[data-outcome="ok"] summary .ic { background: color-mix(in srgb, var(--ws-ok) 15%, transparent); color: var(--ws-ok); }
.ws-step pre { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--ws-softer); font: 12px/1.55 var(--ws-mono); white-space: pre-wrap; overflow: auto; max-height: 360px; }

.ws-card { border: 1px solid var(--border); border-radius: var(--ws-radius); background: var(--card); padding: 14px 16px; }
.ws-card h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.ws-card p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.ws-card code, .ws-card pre { font-family: var(--ws-mono); font-size: 12px; }
.ws-card pre { margin: 0 0 12px; padding: 10px 12px; background: var(--ws-softer); border-radius: var(--ws-radius-sm); white-space: pre-wrap; overflow: auto; }
.ws-card.approval { border-color: color-mix(in srgb, var(--ws-warn) 50%, var(--border)); background: color-mix(in srgb, var(--ws-warn) 6%, var(--card)); }
.ws-card.review { border-color: color-mix(in srgb, var(--ws-ok) 45%, var(--border)); }
.ws-card.error { border-color: color-mix(in srgb, var(--ws-err) 45%, var(--border)); }
.ws-card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ws-card .grow { flex: 1; }

.ws-diff { margin: 0; padding: 0; font: 12px/1.5 var(--ws-mono); background: var(--ws-softer); border: 1px solid var(--border); border-radius: var(--ws-radius-sm); overflow: auto; max-height: 460px; }
.ws-diff .l { display: block; padding: 0 12px; white-space: pre; }
.ws-diff .l.add { background: color-mix(in srgb, var(--ws-ok) 14%, transparent); }
.ws-diff .l.del { background: color-mix(in srgb, var(--ws-err) 12%, transparent); }
.ws-diff .l.hunk { color: var(--ws-info); background: var(--ws-soft); }
.ws-diff .l.file { font-weight: 600; background: var(--ws-soft); padding-top: 4px; padding-bottom: 4px; }

.ws-btn, .ws-primary, .ws-danger { min-height: 0; padding: 8px 12px; border-radius: var(--ws-radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.ws-btn:hover { background: var(--ws-soft); }
.ws-primary { background: var(--ws-primary); color: #fff; border-color: var(--ws-primary); font-weight: 600; }
.ws-primary:hover { opacity: .9; }
.ws-primary:disabled, .ws-btn:disabled { opacity: .5; cursor: default; }
.ws-danger { color: var(--ws-err); }
.ws-btn.small, .ws-primary.small { padding: 5px 9px; font-size: 12px; }

.ws-composer { border-top: 1px solid var(--border); padding: 12px 24px 16px; background: var(--bg); }
.ws-composer-inner { max-width: 860px; margin: 0 auto; border: 1px solid var(--border); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); padding: 10px 12px; }
.ws-composer textarea { width: 100%; box-sizing: border-box; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; resize: none; padding: 6px 4px; min-height: 44px; max-height: 220px; outline: none; }
.ws-composer-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ws-composer-row select, .ws-composer-row input { min-height: 0; padding: 6px 8px; font: inherit; font-size: 12px; border: 1px solid var(--border); border-radius: var(--ws-radius-sm); background: var(--bg); color: var(--text); max-width: 260px; }
.ws-composer-row .spacer { flex: 1; }
.ws-composer-row label.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 0; }
.ws-send { width: 36px; height: 36px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 16px; }
.ws-composer-hint { max-width: 860px; margin: 8px auto 0; font-size: 11px; color: var(--muted); }
.ws-composer-hint[data-tone="error"] { color: var(--ws-err); }

.ws-inspector { border-left: 1px solid var(--border); overflow: auto; padding: 16px; background: var(--shell, var(--bg)); font-size: 13px; }
.ws-inspector h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ws-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; margin-bottom: 16px; }
.ws-kv dt { color: var(--muted); }
.ws-kv dd { margin: 0; overflow-wrap: anywhere; }
.ws-files { list-style: none; margin: 0 0 16px; padding: 0; }
.ws-files li { font-family: var(--ws-mono); font-size: 12px; padding: 4px 0; overflow-wrap: anywhere; }
.ws-files li.changed::before { content: "●"; color: var(--ws-warn); margin-right: 6px; }
.ws-inspector .agent-advanced { margin-top: 12px; }
.ws-inspector .agent-advanced > summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.ws-inspector .agent-layout { grid-template-columns: 1fr; }
.ws-inspector .agent-card { padding: 12px; }
.ws-inspector-toggle { display: none; }

.ws-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--ws-soft); color: var(--muted); }
.ws-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ws-pill[data-status="running"], .ws-pill[data-status="applying"] { color: var(--ws-info); }
.ws-pill[data-status="awaiting_approval"], .ws-pill[data-status="paused"], .ws-pill[data-status="waiting_user"], .ws-pill[data-status="waiting_login"], .ws-pill[data-status="queued"] { color: var(--ws-warn); }
.ws-pill[data-status="review"], .ws-pill[data-status="completed"], .ws-pill[data-status="applied"] { color: var(--ws-ok); }
.ws-pill[data-status="failed"], .ws-pill[data-status="interrupted"], .ws-pill[data-status="recovery_required"] { color: var(--ws-err); }

@media (max-width: 1100px) { .ws { grid-template-columns: 220px minmax(0, 1fr); } .ws-inspector { display: none; } .ws-inspector.open { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 92vw); z-index: 30; box-shadow: -8px 0 30px rgba(0,0,0,.15); } .ws-inspector-toggle { display: inline-block; } }
@media (max-width: 760px) { .ws { grid-template-columns: 1fr; } .ws-threads { display: none; } .ws-threads.open { display: flex; position: fixed; inset: 0; z-index: 30; } .ws-conversation { padding: 14px; } .ws-composer { padding: 8px 12px 12px; } }

/* ---------- Bots ---------- */
#bots-view { padding: 0 !important; height: 100%; overflow: auto !important; background: var(--bg) !important; max-width: none !important; }
.bots-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px 8px; }
.bots-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.bots-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.bots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding: 12px 28px 24px; }
.bot-card { border: 1px solid var(--border); border-radius: 16px; background: var(--card); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 178px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.bot-card:hover { border-color: rgba(31,30,27,.18); }
.bot-card.new { border-style: dashed; align-items: center; justify-content: center; color: var(--muted); background: transparent; text-align: center; }
.bot-card.new strong { font-size: 24px; display: block; }
.bot-card .bot-top { display: flex; align-items: center; gap: 12px; }
.bot-card .bot-avatar { width: 44px; height: 44px; border-radius: 14px; object-fit: cover; background: var(--ws-soft); flex: 0 0 44px; }
.bot-card .bot-name { font-weight: 600; font-size: 15px; }
.bot-card .bot-role { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.bot-card .bot-now { font-size: 12px; line-height: 1.4; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bot-card .bot-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.bot-card .bot-foot .spacer { flex: 1; }
.bot-card .ws-pill[data-op="WORKING"] { color: var(--ws-info); }
.bot-card .ws-pill[data-op="WAITING_APPROVAL"], .bot-card .ws-pill[data-op="WAITING_USER"], .bot-card .ws-pill[data-op="WAITING_LOGIN"], .bot-card .ws-pill[data-op="QUEUED"], .bot-card .ws-pill[data-op="PAUSED"] { color: var(--ws-warn); }
.bot-card .ws-pill[data-op="DONE"] { color: var(--ws-ok); }
.bot-card .ws-pill[data-op="ERROR"] { color: var(--ws-err); }
.bot-card[data-needs-decision="true"] { border-color: color-mix(in srgb, var(--ws-warn) 55%, var(--border)); }

.bots-workspace { padding: 0 28px 28px; }
.bots-workspace[hidden] { display: none; }
.bots-workspace-bar { display: flex; align-items: center; gap: 10px; padding: 8px 0 12px; }
.bots-workspace .employee-workspace { max-width: none; margin: 0; height: min(820px, calc(100dvh - 190px)); }

.bots-wizard { max-width: 640px; margin: 12px 28px 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--card); padding: 20px; }
.bots-wizard[hidden] { display: none; }
.bots-wizard h2 { margin: 0 0 4px; font-size: 17px; }
.bots-wizard p.lead { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.bots-wizard label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.bots-wizard input, .bots-wizard textarea, .bots-wizard select { font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--ws-radius-sm); padding: 9px 11px; min-height: 0; }
.bots-wizard .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bots-wizard .templates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.bots-wizard .templates button { font-size: 12px; }
.bots-wizard .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.bots-wizard .row .grow { flex: 1; font-size: 12px; color: var(--ws-err); }
@media (max-width: 700px) { .bots-grid { padding: 12px 14px; } .bots-head, .bots-workspace, .bots-wizard { padding-left: 14px; padding-right: 14px; margin-left: 0; margin-right: 0; } .bots-wizard .two { grid-template-columns: 1fr; } }

/* Legacy panels: align hardcoded whites/greys with the beige tokens. */
.employee-workspace, .agent-card, #employee-work-surface, .view-card, .memory-create-form { background: var(--card) !important; border-color: var(--border) !important; }
#employees-list [aria-pressed=true] { background: var(--hover) !important; }
.employee-user { background: var(--hover) !important; }
.agent-result pre, .employee-message pre { background: var(--shell) !important; color: var(--text) !important; }
#coding-approval { background: color-mix(in srgb, var(--ws-warn) 10%, var(--card)) !important; }
.agent-badge { background: color-mix(in srgb, var(--ws-ok) 14%, var(--card)) !important; color: var(--ws-ok) !important; }
.topbar, .top-action, .studio-topbar { background: transparent; }

/* Recolor hardcoded light-theme surfaces from styles.css onto the beige tokens.
   Specificity (html body …) + !important intentionally beats the legacy override layer. */
html body .sidebar { background: var(--shell) !important; }
html body .workspace, html body .composer, html body .ops-overview, html body .hero-panel, html body .monitor-card, html body .kpi-card, html body .ops-table-card, html body .view-card, html body .settings-card, html body .memory-create-form { background: var(--card) !important; }
html body .view-card.active, html body .message-body pre, html body .message-body code, html body .attachment-chip, html body .secondary, html body .message.user .message-card, html body #settings-top-button:hover, html body .icon:hover { background: var(--hover) !important; }
html body .composer-shell { background: linear-gradient(transparent, var(--bg) 40%) !important; }
html body .composer.drag-over { background: var(--hover) !important; }
html body .topbar, html body .app, html body .view-panel, html body .messages { background: var(--bg) !important; }
html body .composer { border-color: var(--border) !important; box-shadow: var(--shadow) !important; }
html body .top-action.active, html body .primary, html body button.primary, html body .composer button:not(.attach-button), html body .new-chat.primary { background: var(--ws-primary) !important; color: #fff !important; border-color: var(--ws-primary) !important; box-shadow: none !important; }
html body .nav-item.active, html body .nav-item:hover, html body .history-row.active, html body .history-row:hover, html body .new-chat:hover { background: var(--hover) !important; color: var(--text) !important; }
html body .nav-item span, html body .nav-item .nav-icon { color: var(--accent) !important; }
html body, html body .app, html body .sidebar, html body .topbar strong, html body .message-body, html body .workspace { color: var(--text); }
html[data-resolved-theme="dark"] body .top-action.active, html[data-resolved-theme="dark"] body .primary, html[data-resolved-theme="dark"] body .composer button:not(.attach-button) { color: #1f1b17 !important; }
html body, html[data-resolved-theme="light"] body, html[data-theme="system"] body { background: var(--bg) !important; }
html body .top-action.active { background: var(--ws-primary) !important; }
#settings-tabs a.nav-item { border: 1px solid transparent; background: transparent; color: var(--muted); padding: 7px 12px !important; border-radius: 999px; font-size: 13px; text-decoration: none; min-height: 0; margin: 0; }
#settings-tabs a.nav-item:hover { background: var(--ws-soft) !important; color: var(--text) !important; }

/* Lighter chrome: hairline borders, no heavy shadows, softer text weight. */
html body .composer, html body .view-card, html body .hero-panel, html body .monitor-card, html body .kpi-card, html body .agent-card, html body .employee-workspace { box-shadow: none !important; border: 1px solid var(--border) !important; }
html body .sidebar { border-right: 1px solid var(--border) !important; }
html body .new-chat { background: var(--card) !important; border: 1px solid var(--border) !important; box-shadow: none !important; color: var(--text) !important; }
html body .topbar { border-bottom: 1px solid var(--border) !important; }
html body .nav-item.active { background: var(--hover) !important; font-weight: 600; }

/* Bot schedule editor (employees.js settings) */
.employee-schedule { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.employee-schedule > label { font-weight: 600; font-size: 13px; }
.employee-schedule input[type="number"], .employee-schedule input[type="text"] { width: min(240px, 100%); }
.employee-schedule textarea { min-height: 64px; width: 100%; }
.employee-weekdays { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 6px; }
.employee-weekdays label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

/* Group tasks */
.bots-group-members { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.bots-group-members label { flex-direction: row; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); }
.bots-group-members input { width: auto; min-height: 0; }
.bots-groups { padding: 4px 28px 28px; }
.bots-groups h2 { font-size: 17px; margin: 8px 0 12px; }
.group-card { border: 1px solid var(--border); border-radius: 16px; background: var(--card); padding: 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.group-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-top .muted { color: var(--muted); font-size: 12px; margin-left: auto; }
.group-message { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.group-members { display: flex; flex-wrap: wrap; gap: 6px; }
.group-result { font-size: 13px; padding: 6px 0; border-top: 1px solid var(--border); white-space: pre-wrap; }
.group-synthesis { font-size: 13px; white-space: pre-wrap; background: var(--ws-soft); border-radius: 12px; padding: 10px 12px; }
.ws-pill[data-op="DONE"] .dot { background: #4f8a5b; }
.ws-pill[data-op="ERROR"] .dot { background: #b4433a; }

/* Agent composer: Codex-like — textarea + one slim chip row; extras hidden behind ⋯ */
html body .ws-composer-row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
html body .ws-composer-row select, html body .ws-composer-extra select, html body .ws-composer-extra input { width: auto; flex: 0 1 auto; max-width: 240px; min-width: 0; min-height: 0; margin: 0; padding: 4px 26px 4px 10px; font: inherit; font-size: 12px; line-height: 1.4; border: 1px solid transparent; border-radius: 999px; background: var(--ws-soft, var(--hover)); color: var(--muted); appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 3.5l3 3 3-3' fill='none' stroke='%2387867f' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; cursor: pointer; }
html body .ws-composer-row select:hover, html body .ws-composer-extra select:hover { color: var(--text); border-color: var(--border); }
html body .ws-composer-row .spacer { flex: 1 1 auto; }
html body .ws-composer-more { width: 30px; height: 30px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 15px; color: var(--muted); border: 1px solid transparent; background: transparent; }
html body .ws-composer-more:hover, html body .ws-composer-more[aria-expanded="true"] { background: var(--hover); color: var(--text); }
html body .ws-send { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 16px; }
html body .ws-composer-extra { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 2px 2px; }
html body .ws-composer-extra[hidden] { display: none; }
html body .ws-composer-extra input#ws-project-custom { flex: 1 1 260px; max-width: none; border-radius: var(--ws-radius-sm); padding: 5px 10px; background: var(--bg); border-color: var(--border); }
html body .ws-composer-extra label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 0; white-space: nowrap; }
html body .ws-composer-extra label.check input { width: auto; min-height: 0; margin: 0; }
html body .ws-conversation:empty::before { content: "Опишите задачу внизу. Бот работает в изолированной копии папки проекта, а правки в оригинал применяются только с вашего подтверждения."; display: block; max-width: 520px; margin: 18vh auto 0; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* Bots as a team (Grok Bot idiom) */
#bots-view.bc-on > .bots-head, #bots-view.bc-on > #bots-status, #bots-view.bc-on > #bots-grid, #bots-view.bc-on > #bots-groups, #bots-view.bc-on > #bots-group-wizard { display: none !important; }
#bots-view.bc-on.bc-settings-open > #bc-root, #bots-view.bc-on.bc-wizard-open > #bc-root { display: none; }
.bc { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 64px); min-height: 520px; border-top: 1px solid var(--border); }
.bc-side { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--shell, var(--bg)); min-height: 0; }
.bc-side-top { display: flex; gap: 8px; padding: 14px 14px 8px; }
.bc-side-top input { flex: 1; min-height: 0; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font: inherit; font-size: 13px; }
.bc-icon { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); display: grid; place-items: center; font-size: 16px; color: var(--text); cursor: pointer; padding: 0; min-height: 0; }
.bc-icon:hover { border-color: var(--accent); }
/* Two-step confirm («Очистить?», «Стоп?»): grow into a pill so the text never overlaps neighbours. */
.bc-icon[data-c="1"] { width: auto; flex: 0 0 auto; border-radius: 17px; padding: 0 12px; font-size: 13px; white-space: nowrap; border-color: var(--accent); }
.bc-chief { margin: 6px auto 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 18px 10px; border-radius: 16px; border: 1px solid transparent; background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); min-height: 0; }
.bc-chief:hover, .bc-chief.active { background: var(--hover); border-color: var(--border); }
.bc-list { flex: 1; overflow-y: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.bc-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 14px; border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit; color: var(--text); min-height: 0; position: relative; }
.bc-item:hover { background: var(--hover); }
.bc-item.active { background: var(--card); box-shadow: 0 1px 0 var(--border), 0 0 0 1px var(--border); }
.bc-item-text { display: flex; flex-direction: column; min-width: 0; }
.bc-item-text strong { font-size: 14px; font-weight: 600; }
.bc-item-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-item-text small.warn { color: var(--accent); }
.bc-dot { position: absolute; left: 38px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: #4fae7c; border: 2px solid var(--shell, var(--bg)); }
.bc-ava { display: inline-grid; place-items: center; flex: 0 0 auto; }
.bc-side-foot { padding: 10px 14px 14px; }
.bc-market { width: 100%; padding: 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); min-height: 0; }
.bc-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.bc-head { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.bc-head > div { display: flex; flex-direction: column; min-width: 0; }
.bc-head strong { font-size: 14px; }
.bc-head small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.bc-head .spacer { flex: 1; }
.bc-thread { flex: 1; overflow-y: auto; padding: 22px max(22px, calc((100% - 820px) / 2)); display: flex; flex-direction: column; gap: 6px; }
.bc-msg { display: flex; flex-direction: column; max-width: 78%; }
.bc-msg.user { align-self: flex-end; align-items: flex-end; }
.bc-msg.user .bc-bubble { background: var(--text); color: var(--bg); border-radius: 20px 20px 6px 20px; }
.bc-msg.bot, .bc-msg.chief, .bc-msg.relay { align-self: flex-start; }
.bc-bubble { padding: 10px 14px; border-radius: 20px 20px 20px 6px; background: var(--card); border: 1px solid var(--border); font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bc-msg.relay .bc-bubble { background: transparent; border-style: dashed; color: var(--muted); font-size: 13px; }
.bc-msg.waiting .bc-bubble { border-color: var(--accent); }
.bc-meta { font-size: 11px; color: var(--muted); margin: 3px 6px 0; }
.bc-from { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 12px 0 2px 2px; }
.bc-from span { color: var(--muted); }
.bc-relay { display: flex; align-items: center; gap: 6px; align-self: flex-start; font-size: 12px; color: var(--muted); margin: 8px 0 0 2px; }
.bc-system { align-self: center; font-size: 12px; color: var(--muted); margin: 8px 0; }
.bc-link { align-self: flex-start; background: none; border: 0; padding: 2px 6px; font-size: 12px; color: var(--accent); cursor: pointer; min-height: 0; }
.bc-hello { margin: auto; text-align: center; max-width: 460px; display: grid; justify-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.bc-hello h3 { margin: 4px 0 0; color: var(--text); }
.bc-hello .muted { font-size: 12px; }
.bc-empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }
.bc-typing { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.bc-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bc-blink 1.2s infinite; }
.bc-typing i:nth-child(2) { animation-delay: .2s; } .bc-typing i:nth-child(3) { animation-delay: .4s; }
.bc-typing span { margin-left: 6px; font-size: 13px; }
@keyframes bc-blink { 50% { opacity: .25; } }
.bc-approve { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--accent); display: grid; gap: 8px; font-size: 13px; }
.bc-approve pre { margin: 0; white-space: pre-wrap; font-size: 12px; max-height: 160px; overflow: auto; }
.bc-approve-row { display: flex; gap: 8px; }
.bc-compose { display: flex; align-items: flex-end; gap: 10px; margin: 0 max(22px, calc((100% - 820px) / 2)) 18px; padding: 8px 8px 8px 16px; border: 1px solid var(--border); border-radius: 26px; background: var(--card); box-shadow: 0 2px 12px rgba(0,0,0,.04); }
.bc-compose textarea { flex: 1; border: 0; background: transparent; resize: none; font: inherit; font-size: 14px; line-height: 1.5; padding: 8px 0; min-height: 0; max-height: 180px; outline: none; color: var(--text); }
.bc-send { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 17px; cursor: pointer; padding: 0; min-height: 0; }
.bc-send:disabled { opacity: .5; }
@media (max-width: 820px) { .bc { grid-template-columns: 1fr; height: auto; } .bc-side { max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--border); } .bc-main { min-height: 70vh; } .bc-msg { max-width: 92%; } }

/* Chief of Staff panel */
.bc-pill { white-space: nowrap; flex: 0 0 auto; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 0; }
.bc-pill:hover, .bc-pill.active { border-color: var(--accent); }
.bc-stop { color: var(--accent); font-size: 12px; }
.bc-stop[data-c="1"] { width: auto; padding: 0 10px; border-radius: 999px; background: var(--accent); color: #fff; }
#bc-form.hidden { display: none; }
.bc-panel { display: grid; gap: 12px; width: 100%; }
.bc-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.bc-tabs button { border: 1px solid var(--border); background: transparent; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); min-height: 0; }
.bc-tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.bc-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.bc-doc { width: 100%; box-sizing: border-box; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--card); color: var(--text); resize: vertical; }
.bc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.bc-row .spacer { flex: 1; }
.bc-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.bc-routine { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.bc-routine small { color: var(--muted); font-size: 12px; }
.bc-day { min-width: 34px; min-height: 0; padding: 4px 0; border-radius: 8px; border: 1px solid var(--border); background: transparent; font: inherit; font-size: 12px; cursor: pointer; color: var(--muted); }
.bc-day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.bc-time, .bc-num { min-height: 0; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); font: inherit; font-size: 13px; color: var(--text); }
.bc-num { width: 64px; }
.bc-halt { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--accent); font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bc-logrow { display: grid; grid-template-columns: 110px 110px 1fr; gap: 10px; font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.bc-logrow > span:first-child { color: var(--muted); }
.bc-logrow.k-stop b, .bc-logrow.k-kill b { color: var(--accent); }
@media (max-width: 640px) { .bc-logrow { grid-template-columns: 1fr; gap: 2px; } }
/* In-app notice for the bots chat (replaces alert/toast, which the macOS WKWebView does not show) */
#bc-root .bc-main { position: relative; }
.bc-notice { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: min(560px, 90%); padding: 9px 16px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 13px; line-height: 1.4; box-shadow: 0 6px 24px rgba(0,0,0,.18); text-align: center; }
.bc-notice[data-tone="error"] { background: #b3261e; color: #fff; border-radius: 14px; }
.bc-notice[hidden] { display: none; }
.bc-botcard .btn[data-c="1"] { border-color: #b3261e; color: #b3261e; }
/* Bot settings card */
.bc-botcard { max-width: 760px; }
.bc-field { display: grid; gap: 6px; font-size: 13px; }
.bc-field > span { font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
.bc-botcard [hidden] { display: none !important; } /* .bc-field's display:grid must not override [hidden] */
.bc-field > small { color: var(--muted); line-height: 1.45; }
.bc-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); min-height: 0; }
.bc-input:focus { outline: none; border-color: var(--accent); }
textarea.bc-input { resize: vertical; line-height: 1.5; }
.bc-row .bc-input { flex: 1; width: auto; }
.bc-input.bc-num { max-width: 140px; }
.bc-facts { display: grid; gap: 6px; }
.bc-fact { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-size: 13px; }
.bc-fact span { flex: 1; }
.bc-more { font-size: 13px; }
.bc-more summary { cursor: pointer; color: var(--muted); }
.bc-more[open] { display: grid; gap: 8px; }
.bc-check input { width: auto; flex: 0 0 auto; min-height: 0; margin: 0; accent-color: var(--accent); }
.bc-routine .bc-check b { font-size: 14px; }
.bc-time { width: auto; flex: 0 0 auto; }
.bc-row select { width: auto; min-height: 0; padding: 4px 8px; border-radius: 8px; }

/* Team chat: composer toolbar, chips, live plan card, next-step cards */
.bc-compose { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 10px 8px 16px; border-radius: 22px; }
.bc-compose textarea { width: 100%; }
.bc-toolbar { display: flex; align-items: center; gap: 8px; }
.bc-tools { display: flex; align-items: center; gap: 6px; flex: 1; flex-wrap: wrap; min-width: 0; }
.bc-tool { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; min-height: 0; white-space: nowrap; }
.bc-tool:hover { border-color: var(--accent); color: var(--text); }
.bc-tool.m-on { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.bc-tool.m-off { text-decoration: line-through; opacity: .75; }
.bc-pick select { border: 0; background: transparent; font: inherit; font-size: 12px; color: var(--text); min-height: 0; padding: 0; width: auto; max-width: 180px; outline: none; cursor: pointer; }
.bc-ico { display: inline-grid; place-items: center; }
.bc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -8px max(22px, calc((100% - 820px) / 2)) 16px; }
.bc-chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; min-height: 0; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-chip:hover { border-color: var(--accent); }
.bc-item-top { display: flex; align-items: baseline; gap: 8px; }
.bc-item-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-item-top time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.bc-msg.wide { max-width: min(640px, 92%); width: 100%; }
.bc-plan { border: 1px solid var(--border); background: var(--card); border-radius: 20px 20px 20px 6px; padding: 12px 8px 8px; display: grid; gap: 2px; }
.bc-plan-head { display: flex; align-items: baseline; gap: 10px; padding: 0 8px 8px; font-size: 14px; line-height: 1.5; }
.bc-plan-head span { flex: 1; }
.bc-plan-head small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bc-plan-row { display: grid; grid-template-columns: 22px 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 12px; background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; min-height: 0; }
.bc-plan-row:hover { background: var(--hover); }
.bc-plan-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.bc-plan-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-plan-row em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.bc-mark { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--hover); color: var(--muted); }
.s-ok .bc-mark { background: #4fae7c; color: #fff; }
.s-ask .bc-mark { background: var(--accent); color: #fff; }
.s-ask em { color: var(--accent); font-weight: 600; }
.s-bad .bc-mark { background: #b85450; color: #fff; }
.bc-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: bc-rot .8s linear infinite; }
@keyframes bc-rot { to { transform: rotate(360deg); } }
.bc-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 8px 0 4px; max-width: 760px; }
.bc-action { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-height: 0; }
.bc-action:hover { border-color: var(--accent); }
.bc-action .bc-ico { width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); flex: 0 0 32px; }
.bc-action span { display: flex; flex-direction: column; min-width: 0; }
.bc-action b { font-size: 13px; }
.bc-action small { font-size: 11px; color: var(--muted); }
.bc-webmark { color: var(--accent) !important; }
@media (max-width: 640px) { .bc-plan-row { grid-template-columns: 22px 22px minmax(0, 1fr); } .bc-plan-row em { grid-column: 3; } }
#bc-root #bc-input { border: 0; box-shadow: none !important; background: transparent; padding: 6px 0; min-height: 0; width: 100%; }
#bc-root #bc-input:focus { outline: none; box-shadow: none !important; }

/* Bot «Задачи»: one tick per task; unticked tasks stay visible and can come back. */
.bc-duties { display: grid; gap: 8px; }
.bc-duty { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.bc-duty .bc-check { flex: 1; align-items: flex-start; }
.bc-duty .bc-check > span { display: grid; gap: 2px; }
.bc-duty .bc-check b { font-size: 14px; font-weight: 600; }
.bc-duty .bc-check small { color: var(--muted); font-size: 12px; }
.bc-duty.off .bc-check b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

.bc-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--card); border: 1px solid var(--border); overflow-wrap: anywhere; flex: 1; }
.bc-trigger-made { display: grid; gap: 8px; }

.bc-net { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.bc-netlog { display: grid; gap: 2px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; max-height: 240px; overflow: auto; }
.bc-netlog .no { color: var(--danger, #b3261e); }
.bc-netlog span { color: var(--muted); }

.bc-screen { width: 100%; max-width: 960px; aspect-ratio: 1280 / 800; border-radius: 10px; border: 1px solid var(--border); background: #111; cursor: crosshair; }
