:root {
  --bg: #090c11; --bg2: #0d1118; --panel: #111722; --panel2: #171f2c; --line: #1f2937; --line2: #2a3646;
  --text: #e8eef7; --muted: #8796ab; --accent: #46c8ff; --accent2: #8b7bff; --ok: #4ade80; --warn: #fbbf24; --danger: #ff5c6c;
  --r: 14px; --top: 56px; --tabs: 0px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.grow { flex: 1; }
.link { color: var(--muted); font-size: 13px; } .link:hover { color: var(--text); }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

/* шар */
.orb { position: relative; display: grid; place-items: center; border-radius: 50%; flex: none; }
.orb i { position: absolute; inset: 14%; border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #f1fcff 0%, var(--accent) 34%, var(--accent2) 72%, #1d1655 100%);
  box-shadow: 0 0 30px #46c8ff55, inset 0 0 14px #ffffff3d; animation: breathe 4s ease-in-out infinite; transition: transform .08s linear; }
.orb u { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #46c8ff40; opacity: 0; }
.orb-sm { width: 46px; height: 46px; } .orb-md { width: 72px; height: 72px; } .orb-lg { width: 112px; height: 112px; } .orb-xl { width: min(62vw, 300px); height: min(62vw, 300px); }
@keyframes breathe { 50% { transform: scale(1.05); box-shadow: 0 0 48px #46c8ff77, inset 0 0 14px #ffffff4d; } }
.v-listening .orb u { animation: ring 2s ease-out infinite; opacity: 1; }
.v-thinking .orb i { animation: think 1.1s ease-in-out infinite; }
.v-speaking .orb i { animation: none; }
@keyframes ring { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.18); opacity: 0; } }
@keyframes think { 50% { filter: hue-rotate(45deg) brightness(1.25); transform: scale(.93); } }

/* вход */
.login { height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 34px 26px; }
.login-card h1 { margin: 2px 0 6px; font-weight: 650; letter-spacing: .3px; }
.login-card input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font-size: 16px; outline: none; }
.login-card input:focus { border-color: var(--accent); }
.btn-primary { width: 100%; padding: 13px; border-radius: 12px; font-weight: 650; color: #04111a;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn-ghost { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--line2); color: var(--muted); text-align: left; }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* каркас */
.app { height: 100dvh; display: flex; flex-direction: column; }
.top { height: var(--top); flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.ibtn { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--muted); flex: none; }
.ibtn:hover { background: var(--panel2); color: var(--text); }
.ibtn.on { color: var(--accent); background: #13202e; }
.title { min-width: 0; max-width: 46vw; padding: 6px 10px; border-radius: 10px; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title:hover { background: var(--panel2); }
.pill { display: inline-flex; align-items: center; gap: 8px; max-width: 34vw; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--panel); font-size: 13px; white-space: nowrap; overflow: hidden; }
.pill span { overflow: hidden; text-overflow: ellipsis; }
.pill b { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.pill.busy b { background: var(--accent); box-shadow: 0 0 0 0 #46c8ff88; animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px #46c8ff00; } 100% { box-shadow: 0 0 0 0 #46c8ff00; } }

.layout { flex: 1; min-height: 0; display: flex; }
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.activity { width: 380px; flex: none; border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
body.no-activity .activity { display: none; }

/* сообщения */
.messages { flex: 1; overflow-y: auto; padding: 22px 16px 10px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.msg { max-width: 780px; width: 100%; margin: 0 auto; display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.msg .bubble { overflow-wrap: anywhere; min-width: 0; }
.msg.user .bubble { background: #182638; border: 1px solid #22364e; padding: 10px 14px; border-radius: 18px 18px 6px 18px; max-width: 85%; white-space: pre-wrap; }
.msg.assistant .bubble { width: 100%; padding-top: 2px; }
.msg.assistant .av { flex: 0 0 28px; height: 28px; margin-top: 2px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #d9f6ff, var(--accent) 45%, var(--accent2)); box-shadow: 0 0 12px #46c8ff44; }
.msg.live .bubble { opacity: .8; }
.via { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.via svg { width: 12px; height: 12px; }
.bubble p { margin: 0 0 .65em; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 1.3em; margin: .3em 0 .7em; }
.bubble pre { background: #0b1017; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; }
.bubble code { font: 13px/1.5 ui-monospace, "JetBrains Mono", Menlo, monospace; }
.bubble :not(pre) > code { background: #18212e; padding: 1px 5px; border-radius: 5px; }
.bubble a { color: var(--accent); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tool { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); max-width: 100%;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; }
.tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
.tool.done::before { background: var(--ok); animation: none; }
.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; } }
.sysmsg { max-width: 780px; width: 100%; margin: 0 auto; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 8px 12px; }
.sysmsg b { color: var(--text); font-weight: 600; }

.empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px; }
.empty h2 { margin: 18px 0 0; font-weight: 650; font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; max-width: 560px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel); font-size: 13.5px; }
.chip:hover { border-color: var(--accent); }

/* нижний док: поле ввода или голос */
.dock { flex: none; padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); }
body.has-tabs .dock { padding-bottom: 10px; }
.composer, .voice-dock { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 22px; padding: 6px 6px 6px 14px; }
.composer:focus-within { border-color: #2f5f80; }
.composer textarea { flex: 1; resize: none; max-height: 200px; padding: 9px 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.round-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--muted); background: var(--panel2); }
.round-btn:hover { color: var(--text); }
.round-btn.send { color: #04111a; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.round-btn.send:disabled { opacity: .35; }
.round-btn.mic { color: var(--accent); }
.round-btn.danger { background: var(--danger); color: #fff; }
.round-btn.off { color: var(--danger); background: #2a1519; }
.round-btn.lg { width: 60px; height: 60px; } .round-btn.lg svg { width: 26px; height: 26px; }
.voice-dock { align-items: center; padding: 6px; border-color: #24425f; background: linear-gradient(90deg, #0f1c2b, var(--panel)); }
.vd-text { flex: 1; min-width: 0; }
.vd-state { font-weight: 600; font-size: 14px; }
.vd-caption { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* активность */
.act-head { padding: 14px 16px 6px; display: flex; flex-direction: column; }
.act-now { padding: 4px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.now-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: #0f1b28; border: 1px solid #1d3348; font-size: 13.5px; }
.now-item .spin { flex: none; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 2px solid #46c8ff33; border-top-color: var(--accent); animation: spin .9s linear infinite; }
.now-item b { display: block; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; font-weight: 650; }
.now-idle { padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line2); color: var(--muted); font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.now-idle::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
@keyframes spin { to { transform: rotate(360deg); } }
.act-block { padding: 6px 12px; min-height: 0; }
.act-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 6px 4px; }
.task-list { display: flex; flex-direction: column; gap: 6px; max-height: 32vh; overflow-y: auto; }
.task { text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13.5px; }
.task:hover { border-color: var(--line2); }
.task .row { display: flex; gap: 8px; align-items: center; }
.task .goal { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.task .sum { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 650; padding: 2px 7px; border-radius: 6px; background: #1a2433; flex: none; }
.st.running { color: var(--accent); } .st.done { color: var(--ok); } .st.failed, .st.cancelled { color: var(--danger); }
.feed-wrap { flex: 1; display: flex; flex-direction: column; padding-bottom: 12px; }
.feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ev { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 4px; border-radius: 8px; font-size: 13px; }
.ev:hover { background: #111a26; }
.ev time { color: #5d6b80; font-size: 11.5px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.ev .src { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-right: 6px; }
.ev.k-think .t { color: #b9c6d8; font-style: italic; }
.ev.k-tool .t { color: var(--accent); }
.ev.k-output .t { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.ev.k-progress .t, .ev.k-done .t { color: var(--text); }
.ev.k-done .t::before { content: "✓ "; color: var(--ok); }
.ev.k-error .t { color: var(--danger); }
.ev details summary { cursor: pointer; list-style: none; }
.ev details summary::-webkit-details-marker { display: none; }
.ev pre { margin: 6px 0 0; background: #0b1017; border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-x: auto;
  white-space: pre-wrap; max-height: 240px; font: 11.5px/1.45 ui-monospace, Menlo, monospace; color: #b8c4d4; }

/* история */
.scrim { position: fixed; inset: 0; background: #0009; z-index: 30; backdrop-filter: blur(2px); }
.history { position: fixed; z-index: 31; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-102%); transition: transform .22s ease; }
.history.open { transform: none; box-shadow: 20px 0 60px #000a; }
.hist-head { display: flex; justify-content: space-between; align-items: center; padding-left: 4px; }
.search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font-size: 15px; outline: none; }
.search:focus { border-color: var(--accent); }
.hist-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.hist-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 12px 8px 4px; }
.hist-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.hist-item span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.hist-item:hover { background: var(--panel2); }
.hist-item.active { background: #1a2638; }
.hist-foot { display: flex; justify-content: space-between; align-items: center; padding: 4px; }

/* карточка задачи */
.sheet { position: fixed; inset: 0; z-index: 40; background: #000a; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: min(760px, 100%); max-height: 86dvh; background: var(--panel); border: 1px solid var(--line2); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; animation: up .2s ease; padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet-head > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sheet-body { overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }

/* голос на весь экран */
.immersive { position: fixed; inset: 0; z-index: 50; background: radial-gradient(ellipse at 50% 38%, #12253c 0%, var(--bg) 66%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px 20px calc(30px + env(safe-area-inset-bottom)); }
.imm-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; }
.imm-state { color: var(--muted); font-size: 16px; letter-spacing: .3px; }
.imm-caption { max-width: 640px; min-height: 3.2em; text-align: center; font-size: 19px; line-height: 1.5; color: var(--text); }
.imm-ctrl { display: flex; gap: 22px; margin-top: 10px; }

.toasts { position: fixed; right: 16px; bottom: calc(100px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(380px, 92vw); }
.toast { background: #13202f; border: 1px solid #24425f; border-radius: 12px; padding: 10px 14px; box-shadow: 0 10px 30px #000a; font-size: 14px; animation: up .2s; cursor: pointer; }
.toast b { display: block; font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }

/* вкладки (телефон) */
.tabs { display: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); position: absolute; top: 6px; right: calc(50% - 22px); }

@media (max-width: 899px) {
  :root { --top: 52px; }
  .desk { display: none; }
  .activity { position: absolute; inset: 0; width: auto; border: 0; display: none; z-index: 5; }
  body.tab-activity .activity { display: flex; }
  body.tab-activity .chat { visibility: hidden; }
  .layout { position: relative; }
  .pill { max-width: 42vw; }
  .title { max-width: 34vw; }
  .tabs { display: flex; flex: none; height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line); background: var(--bg); }
  .tabs button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); }
  .tabs button svg { width: 21px; height: 21px; }
  .tabs button.active { color: var(--accent); }
  .dock { padding-bottom: 10px; }
  .msg.user .bubble { max-width: 90%; }
  .task-list { max-height: 30vh; }
  .toasts { bottom: calc(140px + env(safe-area-inset-bottom)); left: 12px; right: 12px; max-width: none; }
}
