:root {
  --bg: #f6f7fb; --bg2: #ffffff; --bg3: #eef0f6; --line: #e2e5ee; --text: #161a24; --muted: #6b7386;
  --accent: #6a4dff; --accent2: #14a88f; --accent-soft: #ece8ff; --ok: #14a35c; --warn: #d98a00; --bad: #d64545;
  --user: #6a4dff; --user-text: #fff; --shadow: 0 6px 24px rgba(20, 24, 40, .08); --radius: 16px;
  --code: #f1f3f8; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14; --bg2: #151821; --bg3: #1c202b; --line: #262b38; --text: #e8eaf1; --muted: #8b93a7;
    --accent: #8b74ff; --accent2: #2fd3b5; --accent-soft: #241f3f; --ok: #3ccf7f; --warn: #f0b03a; --bad: #ff6b6b;
    --user: #5b43e0; --shadow: 0 8px 30px rgba(0, 0, 0, .35); --code: #11141b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14; --bg2: #151821; --bg3: #1c202b; --line: #262b38; --text: #e8eaf1; --muted: #8b93a7;
  --accent: #8b74ff; --accent2: #2fd3b5; --accent-soft: #241f3f; --ok: #3ccf7f; --warn: #f0b03a; --bad: #ff6b6b;
  --user: #5b43e0; --shadow: 0 8px 30px rgba(0, 0, 0, .35); --code: #11141b; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
h2 { font-size: 15px; margin: 22px 0 10px; }
button { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 9px 14px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.btn.wide { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 20px; cursor: pointer; padding: 6px 8px; border-radius: 10px; display: inline-flex; align-items: center; }
.icon-btn:hover { background: var(--bg3); }

/* login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 0%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: min(360px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 24px; padding: 32px 24px; text-align: center; box-shadow: var(--shadow); display: grid; gap: 12px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
.login-logo { width: 64px; height: 64px; margin: 0 auto; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg3); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.err { color: var(--bad); min-height: 1em; }

/* layout */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100dvh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px; gap: 12px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 32px; height: 32px; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-left: auto; }
.live.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; color: var(--text); }
.nav a:hover { background: var(--bg3); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.badge.warn { background: var(--warn); }
.convs-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.convs { overflow: auto; display: grid; gap: 2px; align-content: start; min-height: 0; flex: 1; }
.conv { padding: 8px 10px; border-radius: 10px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.conv:hover { background: var(--bg3); }
.conv.active { background: var(--bg3); }
.conv .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .x { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); }
.conv:hover .x { opacity: 1; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.topbar .title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#menuBtn { display: none; }
.status-pill { font-size: 12px; color: var(--muted); white-space: nowrap; }
.view { flex: 1; overflow: auto; padding: 16px; min-height: 0; }
#view-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tabbar { display: none; }
.scrim { display: none; }

/* chat */
.messages { flex: 1; overflow: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(760px, 92%); }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-text); padding: 10px 14px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.bruce { align-self: flex-start; width: min(760px, 100%); }
.msg.bruce .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.msg.bruce .who img { width: 18px; height: 18px; }
.md { word-wrap: break-word; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin: 0; }
.md pre { background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto; position: relative; font: 13px/1.45 var(--mono); }
.md code { font-family: var(--mono); font-size: .9em; background: var(--code); padding: 1px 5px; border-radius: 6px; }
.md pre code { background: none; padding: 0; }
.md .copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; opacity: .8; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; }
.md h3, .md h4 { margin: 10px 0 6px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file-chip { font-size: 12px; background: var(--bg3); border: 1px solid var(--line); padding: 3px 8px; border-radius: 99px; color: var(--text); }
.msg.user .file-chip { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.empty-chat { margin: auto; text-align: center; max-width: 520px; padding: 20px; }
.empty-chat img { width: 72px; }
.empty-chat h2 { font-size: 22px; margin: 10px 0 4px; }
.suggest { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-top: 18px; text-align: left; }
.suggest button { text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; }
.suggest button:hover { border-color: var(--accent); }
.suggest b { display: block; font-size: 13px; }
.suggest span { font-size: 12px; color: var(--muted); }

/* task card inside chat */
.tcard { border: 1px solid var(--line); background: var(--bg2); border-radius: var(--radius); padding: 12px; margin-top: 8px; box-shadow: var(--shadow); }
.tcard .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tcard .goal { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg3); color: var(--muted); white-space: nowrap; }
.pill.running { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.completed { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.failed, .pill.cancelled { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill.waiting, .pill.paused { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.steps { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); display: grid; gap: 3px; }
.steps li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps li::before { content: "› "; color: var(--accent); }
.ask { margin-top: 10px; padding: 10px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.ask .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ask input { flex: 1; min-width: 140px; }
.result { margin-top: 10px; }
.media { display: grid; gap: 8px; margin-top: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.media img, .media video { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #000; }
.media audio { width: 100%; }
.progress-bar { height: 3px; border-radius: 3px; background: var(--bg3); overflow: hidden; margin-top: 10px; }
.progress-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--accent), var(--accent2)); animation: slide 1.4s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* composer */
.composer-wrap { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); position: relative; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips button { white-space: nowrap; font-size: 13px; border: 1px solid var(--line); background: var(--bg2); border-radius: 99px; padding: 5px 11px; cursor: pointer; }
.chips button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.composer { display: flex; align-items: flex-end; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 6px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 8px 6px; max-height: 40vh; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 16px; cursor: pointer; flex: none; }
.send:disabled { opacity: .4; }
.palette { position: absolute; bottom: 100%; left: 16px; right: 16px; max-height: 300px; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 10; }
.palette div { padding: 8px 10px; border-radius: 9px; cursor: pointer; display: flex; gap: 10px; }
.palette div.sel, .palette div:hover { background: var(--accent-soft); }
.palette b { font-family: var(--mono); color: var(--accent); min-width: 90px; }
.attached { display: flex; flex-wrap: wrap; gap: 6px; }
.attached:not(:empty) { padding-bottom: 8px; }

/* lists, cards, grids */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg3); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--bg2); box-shadow: var(--shadow); font-weight: 600; }
.list { display: grid; gap: 8px; }
.row-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; }
.row-item:hover { border-color: var(--accent); }
.row-item .top { display: flex; gap: 8px; align-items: center; min-width: 0; }
.row-item .top .g { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.row-item .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid { display: grid; gap: 10px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.meter { height: 5px; border-radius: 5px; background: var(--bg3); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent2); }
.machines { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.machine { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; align-content: start; }
.machine .h { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.machine img { width: 100%; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.caps { display: flex; flex-wrap: wrap; gap: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.feed { max-height: 420px; overflow: auto; padding: 6px; display: grid; gap: 2px; align-content: start; }
.fe { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 6px 8px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.fe:hover { background: var(--bg3); }
.fe .tm { color: var(--muted); font-family: var(--mono); font-size: 11px; padding-top: 2px; }
.fe .tx { min-width: 0; }
.fe .tx div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fe .tx .d { color: var(--muted); font-size: 12px; }
.fe.new { animation: flash 1.2s; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.table-wrap { overflow: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; }
.models { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mcard { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 6px; cursor: pointer; }
.mcard:hover { border-color: var(--accent); }
.mcard .h { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.mcard .h span:not(.dot):not(.pill) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; color: var(--muted); }
.mcard .nums b { display: block; color: var(--text); font-size: 15px; }
.qual { height: 4px; border-radius: 4px; background: var(--bg3); overflow: hidden; }
.qual i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.agent { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--bg3); }
.agent .n { font-weight: 600; } .agent .s { font-size: 12px; color: var(--muted); }
pre.block { background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; font: 12.5px/1.5 var(--mono); max-height: 50vh; }

/* settings */
.settings { display: grid; gap: 14px; max-width: 760px; }
.set-group { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.set-group h3 { margin: 0; padding: 12px 14px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
.set { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set .lbl { flex: 1; min-width: 0; }
.set .lbl small { display: block; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:disabled + span { opacity: .4; cursor: not-allowed; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(5, 7, 12, .55); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; width: min(900px, 100%); max-height: 90dvh; overflow: auto; padding: 18px; position: relative; box-shadow: var(--shadow); }
.modal-card .close { position: absolute; top: 10px; right: 10px; }
.modal-card h3 { margin: 0 36px 8px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; margin: 10px 0; }
.kv span:nth-child(odd) { color: var(--muted); }
.timeline { display: grid; gap: 2px; font-size: 13px; margin: 8px 0; }
.timeline div { display: grid; grid-template-columns: 60px 110px 1fr; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.timeline .tm { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: calc(100% - 32px); }

/* phone */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); padding-top: calc(14px + env(safe-area-inset-top)); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
  #menuBtn { display: inline-flex; }
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: var(--bg2); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: grid; justify-items: center; font-size: 11px; color: var(--muted); padding: 7px 0 6px; }
  .tabbar a i { font-style: normal; font-size: 19px; line-height: 1.2; }
  .tabbar a.active { color: var(--accent); }
  .app:has(#view-chat:not(.hidden)) .tabbar { display: none; }
  .composer-wrap { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .two { grid-template-columns: 1fr; }
  .view { padding: 12px; }
  .messages { padding: 14px 12px 6px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .msg { max-width: 94%; }
  .timeline div { grid-template-columns: 50px 1fr; }
  .timeline div .ev { display: none; }
  .status-pill { display: none; }
}
.set select { max-width: 55%; }
@media (max-width: 860px) {
  .set:has(select) { flex-wrap: wrap; }
  .set:has(select) select { width: 100%; max-width: none; }
}

/* planner */
.plan-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.addform { display: grid; gap: 8px; margin-bottom: 10px; }
.addform textarea { resize: vertical; }
.addform .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.addform .row input:not([type=checkbox]) { flex: 1; min-width: 150px; }
.days label { display: inline-flex; gap: 4px; align-items: center; background: var(--bg3); padding: 4px 9px; border-radius: 99px; font-size: 13px; cursor: pointer; }
.hint { margin: 4px 2px 10px; }
.pitem { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; }
.pitem.dragging { opacity: .4; }
.pitem.over { border-color: var(--accent); box-shadow: 0 -3px 0 var(--accent); }
.pitem .handle { cursor: grab; color: var(--muted); user-select: none; font-size: 18px; line-height: 1; padding-top: 2px; }
.pitem .txt { min-width: 0; word-wrap: break-word; }
.pitem .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.pitem .acts { display: flex; gap: 2px; }
.pitem .acts button { border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.pitem .acts button:hover { background: var(--bg3); color: var(--text); }
.pitem.working { border-color: var(--accent); }
.pill.bruce { background: color-mix(in srgb, var(--accent2) 18%, transparent); color: var(--accent2); }
.pill.high { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.hist summary { cursor: pointer; color: var(--muted); margin: 14px 0 8px; }
.sitem { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 4px; }
.sitem .top { display: flex; gap: 8px; align-items: center; }
.sitem .top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitem.off { opacity: .6; }
@media (max-width: 1100px) { .plan-cols { grid-template-columns: 1fr; } }
#upStatus { margin-bottom: 10px; }
.pre { background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow: auto; max-height: 65vh; white-space: pre-wrap; word-break: break-word; font: 12px/1.45 var(--mono); }

/* «Работа»: live model and agent cards */
.live-card .top, .card.model .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
pre.stream { background: var(--code); border-radius: 10px; padding: 10px; font: 12px/1.45 var(--mono); max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
pre.stream.think { border-left: 3px solid var(--accent); color: var(--muted); }
.card.model.busy { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dot.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.rate .icon-btn { font-size: 16px; padding: 2px 6px; opacity: .6; } .rate .icon-btn.on, .rate .icon-btn:hover { opacity: 1; background: var(--accent-soft); }

/* ===== theme «KARA»: a dark android interface (inspired by the mood of Detroit: Become Human; original art) ===== */
:root[data-theme="kara"] {
  --bg: #070b14; --bg2: rgba(13, 22, 38, .86); --bg3: rgba(26, 40, 64, .7); --line: rgba(88, 196, 255, .18);
  --text: #e6f1ff; --muted: #7f94b3; --accent: #3ad0ff; --accent2: #2a7dff; --accent-soft: rgba(58, 208, 255, .12);
  --ok: #3ad0ff; --warn: #ffc93a; --bad: #ff3b55; --user: rgba(42, 125, 255, .28); --user-text: #e6f1ff;
  --shadow: 0 0 0 1px rgba(58, 208, 255, .06), 0 10px 40px rgba(0, 0, 0, .55); --radius: 4px; --code: rgba(4, 8, 16, .8);
  --led-idle: #3ad0ff; --led-busy: #ffc93a; --led-alert: #ff3b55; color-scheme: dark;
}
[data-theme="kara"] body {
  font-family: "Rajdhani", "Exo 2", "Segoe UI", Inter, Roboto, sans-serif; letter-spacing: .01em;
  background:
    linear-gradient(rgba(58, 208, 255, .035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(58, 208, 255, .035) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(900px 500px at 85% -10%, rgba(42, 125, 255, .22), transparent 70%),
    radial-gradient(700px 500px at -10% 110%, rgba(58, 208, 255, .12), transparent 70%), #070b14;
}
[data-theme="kara"].has-bg body::before {  /* the owner's own picture, dimmed so the text stays readable */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(7, 11, 20, .72), rgba(7, 11, 20, .86)), var(--user-bg) center / cover no-repeat;
}
[data-theme="kara"].has-bg body { background: #070b14; }
[data-theme="kara"] .sidebar, [data-theme="kara"] .topbar { background: rgba(8, 14, 26, .82); backdrop-filter: blur(14px); }
[data-theme="kara"] h2, [data-theme="kara"] h3, [data-theme="kara"] .convs-title, [data-theme="kara"] .brand span:not(.led),
[data-theme="kara"] .nav a span { text-transform: uppercase; letter-spacing: .14em; }
[data-theme="kara"] h2, [data-theme="kara"] h3 { color: var(--accent); font-weight: 600; }
[data-theme="kara"] .brand { font-size: 20px; letter-spacing: .3em; }
[data-theme="kara"] .brand-icon:not(.own) { display: none; }
[data-theme="kara"] .brand-icon.own, [data-theme="kara"] .who img.own { border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--accent); }
[data-theme="kara"] .who img.own { width: 26px; height: 26px; }
[data-theme="kara"] .card, [data-theme="kara"] .tcard, [data-theme="kara"] .login-card, [data-theme="kara"] .set-group {
  position: relative; border-radius: 3px; border-color: var(--line);
  background: linear-gradient(180deg, rgba(20, 34, 58, .78), rgba(10, 18, 32, .86)); }
/* corner brackets, like the in-world holographic panels */
[data-theme="kara"] .card::before, [data-theme="kara"] .tcard::before, [data-theme="kara"] .login-card::before {
  content: ""; position: absolute; inset: -1px; pointer-events: none; border-radius: 3px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 12px 2px no-repeat, linear-gradient(var(--accent), var(--accent)) 0 0 / 2px 12px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 100% 100% / 12px 2px no-repeat, linear-gradient(var(--accent), var(--accent)) 100% 100% / 2px 12px no-repeat;
  opacity: .8; }
[data-theme="kara"] .tcard .goal::before { content: "МИССИЯ · "; color: var(--accent); font-size: 11px; letter-spacing: .18em; }
[data-theme="kara"] .btn { border-radius: 2px; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
[data-theme="kara"] .btn.primary { background: linear-gradient(90deg, #1d6dff, #3ad0ff); color: #02101f; box-shadow: 0 0 18px rgba(58, 208, 255, .35); }
[data-theme="kara"] .msg.user { border: 1px solid rgba(58, 208, 255, .35); border-radius: 3px 3px 0 3px; }
[data-theme="kara"] input, [data-theme="kara"] textarea, [data-theme="kara"] select { border-radius: 2px !important; }
[data-theme="kara"] .nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
[data-theme="kara"] .login { background: transparent; }
[data-theme="kara"] .login-logo { display: none; }
[data-theme="kara"] .login-card h1 { letter-spacing: .5em; font-weight: 500; }

/* LED ring: KARA's state, like an android's temple light — blue free, yellow working, red needs you */
.led, .k-boot, .stab { display: none; }
[data-theme="kara"] .led { display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 3px solid var(--led-idle); box-shadow: 0 0 10px var(--led-idle), inset 0 0 6px var(--led-idle); transition: .4s; }
[data-theme="kara"] .led[data-state="busy"] { border-color: var(--led-busy); box-shadow: 0 0 12px var(--led-busy), inset 0 0 6px var(--led-busy);
  border-top-color: transparent; animation: led-spin 1.4s linear infinite; }
[data-theme="kara"] .led[data-state="alert"] { border-color: var(--led-alert); box-shadow: 0 0 14px var(--led-alert), inset 0 0 6px var(--led-alert); animation: led-pulse 1s ease-in-out infinite; }
[data-theme="kara"] .led[data-state="off"] { border-color: var(--muted); box-shadow: none; }
[data-theme="kara"] .login-led { width: 64px; height: 64px; border-width: 6px; margin: 0 auto 4px; animation: led-pulse 2.6s ease-in-out infinite; }
[data-theme="kara"] .k-boot { display: block; font-size: 11px; letter-spacing: .2em; }
[data-theme="kara"] .live { display: none; }
@keyframes led-spin { to { transform: rotate(360deg); } }
@keyframes led-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { [data-theme="kara"] .led { animation: none !important; } }

/* stability meter */
[data-theme="kara"] .stab { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .16em; color: var(--muted); }
[data-theme="kara"] .stab.hidden { display: none; }
[data-theme="kara"] .stab i { width: 90px; height: 4px; background: rgba(58, 208, 255, .15); position: relative; }
[data-theme="kara"] .stab b { position: absolute; inset: 0 auto 0 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); transition: width .6s; }
[data-theme="kara"] .stab[data-level="warn"] b { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
[data-theme="kara"] .stab[data-level="bad"] b { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
[data-theme="kara"] .stab em { font-style: normal; color: var(--text); min-width: 34px; }
@media (max-width: 860px) { [data-theme="kara"] .stab { display: none; } }
