:root {
  --accent: #2563eb;
  --accent-ink: #fff;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-side: #f3f4f6;
  --line: #e3e5e9;
  --ink: #1f2328;
  --muted: #6b7280;
  --danger: #b42318;
  --radius: 12px;
  --side-w: 280px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.ico { display: block; flex: none; }
#new-chat { display: flex; align-items: center; justify-content: center; gap: 6px; }
.chip, .att { display: inline-flex; align-items: center; gap: 4px; }
.chip .ico, .chat-item .acts .ico { display: inline-block; vertical-align: -2px; }
.send, .stop, .icon-btn { display: inline-flex; align-items: center; justify-content: center; }

/* кнопки */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.btn:hover { background: var(--bg-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; padding: 6px 8px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { background: var(--bg-soft); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
.link-btn:hover { color: var(--ink); }

/* вход */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg-soft); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.05); }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 6px; }
.login-card .brand-logo { max-height: 56px; max-width: 200px; align-self: flex-start; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label input { font-size: 15px; color: var(--ink); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
label input:focus, .search:focus, textarea:focus, .model:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* каркас */
.app { display: flex; height: 100%; height: 100dvh; }
.side { width: var(--side-w); flex: none; background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; padding: 12px; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.side-head .brand-logo { max-height: 32px; max-width: 120px; }
.side-head .brand-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
.chat-list { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.chat-group { font-size: 12px; color: var(--muted); margin: 12px 8px 4px; }
.chat-item { display: flex; align-items: center; gap: 4px; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.chat-item:hover { background: rgba(0,0,0,.05); }
.chat-item.active { background: color-mix(in srgb, var(--accent) 13%, #fff); }
.chat-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.chat-item .acts { display: none; gap: 2px; }
.chat-item:hover .acts, .chat-item.active .acts { display: flex; }
.chat-item .acts button { border: 0; background: none; cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; color: var(--muted); }
.chat-item .acts button:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.chat-item input { flex: 1; font-size: 14px; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 6px; min-width: 0; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.me { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.usage .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.usage .bar i { display: block; height: 100%; background: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.model { padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; max-width: 60vw; }
.top-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }

/* сообщения */
.msgs { flex: 1; overflow-y: auto; padding: 20px 16px 8px; min-height: 0; }
.msg { max-width: 820px; margin: 0 auto 18px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .body { word-wrap: break-word; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .actions { display: flex; gap: 4px; margin-top: 4px; opacity: .75; }
.msg .actions button, .msg .actions a { border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--muted); padding: 3px 6px; border-radius: 6px; text-decoration: none; }
.msg .actions button:hover, .msg .actions a:hover { background: var(--bg-soft); color: var(--ink); }
.msg .note { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 4px; }
.msg.error .body, .err-box { color: var(--danger); background: #fef3f2; border: 1px solid #fecdca; border-radius: 10px; padding: 10px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.chip { font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips img { max-width: 180px; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.empty { max-width: 560px; margin: 12vh auto 0; text-align: center; }
.empty h2 { margin: 8px 0; }
.empty .brand-logo.big { max-height: 64px; max-width: 220px; }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

/* markdown */
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p, .body ul, .body ol, .body blockquote, .body table, .body pre { margin: 0 0 12px; }
.body h1, .body h2, .body h3, .body h4 { margin: 18px 0 8px; line-height: 1.3; }
.body h3 { font-size: 1.15em; } .body h4 { font-size: 1.05em; } .body h5, .body h6 { font-size: 1em; }
.body ul, .body ol { padding-left: 24px; }
.body blockquote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
.body a { color: var(--accent); }
.body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--bg-soft); padding: 1px 4px; border-radius: 4px; }
.body table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.body th, .body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.body th { background: var(--bg-soft); }
.body img { max-width: 100%; }
.code-wrap { position: relative; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; background: var(--bg-soft); border-bottom: 1px solid var(--line); padding: 3px 6px 3px 12px; font-size: 12px; color: var(--muted); }
.code-head button { border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--muted); padding: 3px 6px; border-radius: 6px; }
.code-head button:hover { background: #fff; color: var(--ink); }
.code-wrap pre { margin: 0; padding: 12px; overflow-x: auto; background: #fbfbfc; }
.code-wrap pre code { background: none; padding: 0; font-size: 13px; }

/* ввод */
.composer { padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.compose-row { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--line); border-radius: 16px; padding: 6px; background: #fff; }
.compose-row:focus-within { border-color: var(--accent); }
.compose-row.drag { border-style: dashed; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, #fff); }
textarea { flex: 1; border: 0; outline: none; resize: none; max-height: 40vh; padding: 7px 4px; background: transparent; line-height: 1.45; box-shadow: none !important; }
.send, .stop { border-radius: 12px; padding: 7px 14px; }
.stop { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: 12px; text-align: center; margin-top: 6px; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.atts:empty { display: none; }
.att { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 8px; font-size: 13px; background: var(--bg-soft); max-width: 280px; }
.att img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att.loading { opacity: .6; }
.att button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; }

/* диалог, тост */
.dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(400px, 92vw); }
.dialog::backdrop { background: rgba(0,0,0,.3); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; }

.only-mobile { display: none; }
.backdrop { display: none; }
@media (max-width: 800px) {
  .only-mobile { display: inline-block; }
  .side { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; width: min(86vw, 320px); }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 20; }
  .chat-item .acts { display: none; }
  .chat-item.active .acts { display: flex; }
  .msgs { padding: 14px 10px 6px; }
  .composer { padding-left: 8px; padding-right: 8px; }
  .msg.user .bubble { max-width: 92%; }
  .top { padding: 6px 10px; gap: 6px; }
  .model { max-width: 42vw; padding: 5px 6px; font-size: 14px; }
  .top-title { min-width: 0; }
  body { font-size: 16px; }   /* iOS не зумит поле ввода */
}

/* ---- этап 2: ветки, размышление, настройки, шаринг, закрепление, поиск ---- */
.small { font-size: 12px; }
.msg.user .actions { justify-content: flex-end; }
.msg.user.editing { align-items: stretch; }
.edit-box { display: flex; flex-direction: column; gap: 6px; background: var(--bg-soft); border: 1px solid var(--accent); border-radius: 14px; padding: 8px; }
.edit-ta { width: 100%; box-sizing: border-box; border: 0; background: transparent; padding: 4px; min-height: 60px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 6px; }
.edit-actions .btn { padding: 5px 12px; }
.branch-nav { display: inline-flex; align-items: center; gap: 0; font-size: 12px; color: var(--muted); user-select: none; }
.branch-nav button { padding: 3px 2px !important; }
.branch-nav button:disabled { opacity: .35; cursor: default; background: none !important; }
.msg .actions .ico { display: inline-block; vertical-align: -2px; }
.reasoning { margin: 2px 0 8px; border-left: 3px solid var(--line); padding: 2px 0 2px 10px; font-size: 13px; color: var(--muted); }
.reasoning summary { cursor: pointer; user-select: none; }
.reasoning.live summary::after { content: " ▍"; animation: blink 1s steps(2) infinite; }
.reasoning-body { white-space: pre-line; word-wrap: break-word; max-height: 320px; overflow-y: auto; margin-top: 4px; }
.think { font-size: 13px; gap: 4px; color: var(--muted); border: 1px solid transparent; }
.think.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, #fff); }
.think span { white-space: nowrap; }
.chat-item.has-snip { flex-wrap: wrap; }
.chat-item .snip { order: 3; flex-basis: 100%; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .acts button.pinned { color: var(--accent); }
.dialog.wide { width: min(560px, 94vw); }
.dialog select, .dialog textarea { font-size: 15px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.dialog textarea { resize: vertical; max-height: 50vh; line-height: 1.45; }
.share-box { display: flex; flex-direction: column; gap: 10px; }
.share-box h3, .share-box p { margin: 0; }
.share-row { display: flex; gap: 6px; }
#share-on { display: flex; flex-direction: column; gap: 10px; }
#share-on[hidden] { display: none; }
.set-note { display: flex; justify-content: space-between; gap: 12px; }
.set-note #set-count { white-space: nowrap; }
.dialog select:focus, .dialog textarea:focus, .share-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search { accent-color: var(--accent); }
.search::-webkit-search-cancel-button { filter: grayscale(1); opacity: .6; cursor: pointer; }
@media (max-width: 600px) {
  .branch-nav button { padding: 8px 8px !important; }
  .chat-item .acts button { padding: 6px 8px; }
  .msg .actions button, .msg .actions a { padding: 6px 8px; }
}
.share-404 { text-align: center; margin-top: 18vh; }
.share-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
/* публичная страница */
.share-page { max-width: 820px; margin: 0 auto; padding: 16px; }
.share-head { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 18px; }
.share-head .brand-logo { max-height: 32px; max-width: 120px; }
.share-head h1 { font-size: 18px; margin: 0; flex: 1; }
.share-foot { font-size: 12px; text-align: center; margin: 24px 0; }

/* этап 3: проекты */
.proj-sec { margin: 2px 0 6px; }
.proj-sec-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 4px 2px 4px; }
.proj-sec-toggle { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.proj-sec-toggle:hover { color: var(--ink); background: rgba(0,0,0,.05); }
.proj-sec-toggle .ico { transition: transform .15s; }
.proj-sec.collapsed .proj-sec-toggle .ico { transform: rotate(-90deg); }
.small-btn { padding: 3px 5px; color: var(--muted); }
.small-btn:hover { color: var(--ink); background: rgba(0,0,0,.06); }
.proj-list { display: flex; flex-direction: column; }
.proj-sec.collapsed .proj-list { display: none; }
.proj-empty { border: 1px dashed var(--line); background: none; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--muted); cursor: pointer; text-align: left; margin: 2px 0; }
.proj-empty:hover { color: var(--ink); border-color: var(--accent); }
.proj-item .ico:first-child { color: var(--muted); }
.proj-mark, .in-proj { color: var(--muted); display: inline-flex; flex: none; }
.chat-item .in-proj { order: 1; }
.chat-item .acts { order: 2; }
.proj-mark .ico, .in-proj .ico { display: inline-block; }
.proj-badge { display: inline-flex; align-items: center; gap: 5px; max-width: 34vw; border: 1px solid var(--line); background: var(--bg-soft); border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--ink); flex: none; }
.proj-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-badge:hover { border-color: var(--accent); }
.proj-view { flex: 1; overflow-y: auto; min-height: 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--bg); }
.proj-wrap { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.proj-head { display: flex; flex-direction: column; gap: 8px; }
.proj-title { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.proj-title h2 { margin: 0; font-size: 22px; line-height: 1.25; color: var(--ink); word-break: break-word; }
.proj-desc { margin: 0; }
.proj-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); background: var(--bg-soft); }
.tag .ico { display: inline-block; }
.proj-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.proj-actions .btn, .prow .btn { display: inline-flex; align-items: center; gap: 6px; }
.pcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.pcard h3 { margin: 0; font-size: 16px; }
.pcard p { margin: 0; }
.pinput { width: 100%; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; max-height: 50vh; line-height: 1.45; background: #fff; flex: none; }
.pinput:focus, .pselect:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.pinstr { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; background: var(--bg-soft); border-radius: 10px; padding: 10px 12px; max-height: 300px; overflow-y: auto; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prow.start { justify-content: flex-start; }
.prow.end { justify-content: flex-end; }
.pfield { display: flex; flex-direction: column; gap: 4px; }
.plabel { font-size: 13px; color: var(--muted); }
.pfiles, .pchats { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pfiles:empty { display: none; }
.pfile { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); }
.pfile:last-child, .pchat:last-child { border-bottom: 0; }
.pfile > .ico { color: var(--muted); }
.pfile-name { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; border: 0; background: none; cursor: pointer; text-align: left; padding: 2px 0; }
.pfile-name .t, .pchat .t { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pfile-name:hover .t { color: var(--accent); }
.pchat { display: flex; align-items: center; gap: 8px; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 9px 12px; cursor: pointer; text-align: left; }
.pchat .t { flex: 1; min-width: 0; }
.pchat .ico { color: var(--muted); }
.pchat:hover { background: var(--bg-soft); }
.vis-opts { display: flex; flex-direction: column; gap: 6px; }
.vis-opt { flex-direction: row; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; color: var(--ink); font-size: 14px; }
.vis-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, #fff); }
.vis-opt input { margin: 3px 0 0; accent-color: var(--accent); }
.vis-opt .ico { margin-top: 2px; color: var(--muted); }
.vis-opt > span { display: flex; flex-direction: column; }
.pselect { font-size: 14px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; max-width: 100%; }
.people { display: flex; flex-direction: column; gap: 10px; }
.groups-box { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink); }
.chk { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); cursor: pointer; }
.chk input { accent-color: var(--accent); }
.up-state:empty { display: none; }
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.sources .ico { display: inline-block; }
.src { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-proj { color: var(--muted); font-size: 14px; text-wrap: balance; }
.pfile-preview { margin: 0; max-height: 50vh; overflow: auto; white-space: pre-wrap; word-wrap: break-word; font-size: 13px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
#chats-box { display: block; }
@media (max-width: 800px) {
  .proj-badge { max-width: 52vw; padding: 4px 8px; }
  .proj-badge:not([hidden]) ~ .top-title { display: none; }
  .proj-actions .btn:not(.primary) span { display: none; }
  .proj-actions .btn:not(.primary) { padding: 8px 10px; }
  .proj-view { padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
  .pcard { padding: 12px; }
  .proj-title h2 { font-size: 19px; }
}
.pcard .form-error:empty { display: none; }

/* ---------------------------------------------------------------- артефакты (этап 4) */
:root { --art-w: min(46vw, 760px); }
.art-card { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 460px; margin: 4px 0 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.art-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--bg-soft); }
.art-card.live { border-style: dashed; }
.art-ico { flex: none; width: 36px; height: 36px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); }
.art-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.art-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-sub { font-size: 12.5px; color: var(--muted); }
.art-open { flex: none; font-size: 13px; color: var(--accent); }
.cursor:has(> .art-card:last-child)::after { content: none; }
body.art-shown .model { max-width: 45%; min-width: 0; }
body.art-shown .top-title { min-width: 60px; }
.art-card.live .art-sub::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%;
  background: var(--accent); vertical-align: middle; animation: blink 1s steps(2) infinite; }

.art-resizer { flex: none; width: 6px; margin: 0 -3px; cursor: col-resize; position: relative; z-index: 5; touch-action: none; }
.art-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 2px; background: transparent; transition: background .15s; }
.art-resizer:hover::after, body.art-resizing .art-resizer::after { background: color-mix(in srgb, var(--accent) 55%, transparent); }
body.art-resizing { cursor: col-resize; user-select: none; }
body.art-resizing .art-frame { pointer-events: none; }
.art-panel { flex: none; width: var(--art-w); min-width: 320px; max-width: max(320px, calc(100vw - var(--side-w) - 420px)); display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: #fff; min-height: 0; }
.art-panel[hidden], .art-resizer[hidden] { display: none; }
.art-panel.full { position: fixed; inset: 0; z-index: 60; width: auto; max-width: none; border: 0; }
.art-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.art-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.art-ptitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-psub { font-size: 12px; color: var(--muted); }
.art-tools { display: flex; gap: 2px; flex: none; }
.icon-btn.sm { padding: 6px; color: var(--muted); }
.icon-btn.sm:hover { color: var(--ink); }
.icon-btn.sm:disabled { opacity: .35; cursor: default; background: none; }
.art-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.art-tabs { display: inline-flex; background: var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.art-tabs[hidden] { display: none; }
.art-tab { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--muted); }
.art-tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.art-tab:disabled { cursor: default; opacity: .55; }
.art-vbox { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.art-vbox[hidden] { display: none; }
.art-ver { padding: 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; }
.art-body { flex: 1; min-height: 0; overflow: auto; background: #fff; }
.art-body.framed { overflow: hidden; }
.art-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.art-code { margin: 0; padding: 14px 16px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; tab-size: 2; color: var(--ink); background: #fafbfc; min-height: 100%; box-sizing: border-box; }
.art-doc { padding: 16px 20px; max-width: 820px; }
@media (max-width: 800px) {
  .art-panel { position: fixed; inset: 0; z-index: 50; width: auto; min-width: 0; max-width: none; border: 0;
    padding-bottom: env(safe-area-inset-bottom); }
  .art-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .art-card { max-width: 100%; }
  .art-fullbtn { display: none; }
  .art-panel .icon-btn.sm { padding: 10px; }
  .art-ver { padding: 8px 8px; font-size: 15px; }
  .art-tab { padding: 8px 14px; }
}

/* этап 6: «Интернет», «Исследование», шаги поиска, сноски и источники */
.compose-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.compose-tools:not(:has(button:not([hidden]))) { display: none; }
.compose-tools .think { padding: 5px 10px; border-radius: 999px; border-color: var(--line); background: #fff; font-size: 13px; }
.compose-tools .think:hover { background: var(--bg-soft); }
.compose-tools .think.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 9%, #fff); }
.compose-tools .think:disabled { opacity: .45; cursor: default; }
.websteps { margin: 2px 0 8px; border-left: 3px solid color-mix(in srgb, var(--accent) 35%, var(--line)); padding: 2px 0 2px 10px; font-size: 13px; color: var(--muted); }
.websteps summary { cursor: pointer; user-select: none; }
.websteps.live summary::after { content: " ▍"; animation: blink 1s steps(2) infinite; }
.websteps ul { list-style: none; margin: 6px 0 2px; padding: 0; max-height: 280px; overflow-y: auto; }
.websteps li { display: flex; gap: 6px; align-items: baseline; padding: 1px 0; overflow: hidden; }
.websteps li .ico { flex: none; position: relative; top: 2px; }
.websteps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.websteps li.run span::after { content: " …"; }
.websteps li.err { opacity: .6; text-decoration: line-through; }
.websteps .plan-title { color: var(--ink); font-weight: 600; margin-top: 4px; }
.websteps .interim { font-style: italic; white-space: pre-line; margin: 4px 0; }
a.cite { display: inline-block; min-width: 1.35em; padding: 0 4px; margin: 0 1px; font-size: 11px; line-height: 1.5; text-align: center; vertical-align: 2px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); text-decoration: none; font-weight: 600; }
a.cite:hover { background: var(--accent); color: #fff; }
.websrc { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.websrc .lead { margin-right: 2px; font-weight: 600; }
.wchip { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--ink); text-decoration: none; }
.wchip:hover { border-color: var(--accent); color: var(--accent); }
.wchip b { color: var(--accent); font-weight: 600; }
.wchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.websrc .more { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.webstats { font-size: 12px; color: var(--muted); margin-top: 6px; }
.cites { white-space: nowrap; }
.art-doc { overflow-wrap: anywhere; }
.art-doc table { display: block; overflow-x: auto; max-width: 100%; }
@media (max-width: 520px) { .compose-tools { gap: 4px; } .compose-tools .think { padding: 4px 8px; font-size: 12.5px; gap: 4px; } }
.art-doc th, .art-doc td { overflow-wrap: normal; min-width: 7em; }

/* ---- этап 7: память, инкогнито, голос ---- */
#set-dialog { max-height: 92vh; overflow-y: auto; }
.set-sec { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.set-sec h4 { margin: 0; font-size: 15px; }
.set-sec p { margin: 0; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
label.check input { flex: none; width: 17px; height: 17px; margin: 1px 0 0; padding: 0; accent-color: var(--accent); }
.mem-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.mem-list.off { opacity: .55; }
.mem-empty { font-size: 13px; color: var(--muted); padding: 4px 0; }
.mem-item { display: flex; align-items: flex-start; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 10px; font-size: 14px; }
.mem-item .mt { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.4; padding-top: 2px; }
.mem-item .mp { display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-right: 4px; background: #fff; }
.mem-item input { flex: 1; min-width: 0; font-size: 14px; padding: 5px 8px; border: 1px solid var(--accent); border-radius: 8px; }
.mem-item .icon-btn { padding: 4px; color: var(--muted); flex: none; }
.mem-item .icon-btn:hover { color: var(--ink); }
.mem-add { display: flex; gap: 6px; }
.mem-add input { flex: 1; min-width: 0; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.mem-add input:focus { outline: none; border-color: var(--accent); }
.incog-btn { font-size: 13px; gap: 5px; color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.incog-btn.on { color: #fff; background: #374151; border-color: #374151; }
.incog-btn.on:hover { background: #1f2937; }
.incog-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 14px; background: #374151; color: #f3f4f6; font-size: 13px; text-align: center; }
.incog-bar[hidden] { display: none; }
.incog-bar .ico { flex: none; }
body.incognito .compose-row { border-color: #6b7280; background: #f9fafb; }
.mic.rec { color: #fff; background: var(--accent); animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); } }
.msg .actions button.speaking { color: var(--accent); }
.wchip.chat b { color: #374151; }
@media (max-width: 600px) {
  .incog-btn span { display: none; }
  .incog-bar { font-size: 12px; padding: 5px 10px; }
}
.mem-clear { display: flex; justify-content: flex-end; padding-top: 2px; }
.mem-clear .btn { font-size: 13px; padding: 5px 10px; }
.mem-item input:focus { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.mem-item > .mp { align-self: center; margin: 0; }
.mem-clear[hidden] { display: none; }

/* этап 8: навыки */
.skill-list { display: flex; flex-direction: column; gap: 4px; }
.skill-item { display: flex; align-items: flex-start; gap: 8px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 7px 6px 7px 10px; font-size: 14px; }
.skill-item.off .sk-meta { opacity: .55; }
.skill-item .sk-toggle { flex: none; padding-top: 2px; }
.skill-item .sk-toggle input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.sk-meta { flex: 1; min-width: 0; }
.sk-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.sk-desc { margin-top: 2px; overflow-wrap: anywhere; }
.sk-scope { font-size: 11px; font-weight: 400; border-radius: 999px; padding: 1px 7px; border: 1px solid var(--line); color: var(--muted); background: #fff; }
.sk-scope.tenant { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.sk-scope.user { color: #047857; border-color: #a7f3d0; }
.skill-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.file-btn { position: relative; display: inline-flex; flex-direction: row; align-items: center; gap: 6px; cursor: pointer; color: var(--ink); font-size: inherit; }
.file-btn input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#skill-form textarea[name=instructions] { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* этап 8: PWA — вырезы и «чёлки» (viewport-fit=cover) */
.top { padding-top: calc(8px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
.side { padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); padding-left: calc(12px + env(safe-area-inset-left)); }
.composer { padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
@media (max-width: 800px) {
  .top { padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 6px calc(10px + env(safe-area-inset-left)); }
  .composer { padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
}
@media (max-width: 800px) { .skill-item .icon-btn { min-width: 36px; min-height: 36px; } }
/* этап 9: подключения Google (настройки) и коннекторы компании (админ) */
.conn-box { display: flex; flex-direction: column; gap: 8px; }
.conn-head { display: flex; align-items: center; gap: 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.conn-head.bad { border-color: #fecdca; background: #fef3f2; }
.conn-head.bad .muted { color: var(--danger); }
.conn-g { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--accent); }
.conn-who { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.conn-list { display: flex; flex-direction: column; gap: 4px; }
.conn-svc { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 2px; color: var(--muted); }
.conn-svc .cs-t { flex: 1; color: var(--ink); }
.conn-svc .cs-s { font-size: 12.5px; }
.conn-svc.on .cs-s { color: #067647; }
.err-box.warn { color: #93370d; background: #fffaeb; border-color: #fedf89; }
#conn-admin-dialog .dialog-actions { margin-top: 4px; }
.ca-h { margin: 6px 0 0; font-size: 15px; }
.ca-services { display: flex; flex-direction: column; gap: 8px; }
.ca-svc { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.ca-deps { display: flex; flex-wrap: wrap; gap: 4px 12px; padding-left: 25px; }
.ca-deps.off { opacity: .45; pointer-events: none; }
.ca-dep { flex-direction: row; align-items: center; gap: 5px; font-size: 13px; color: var(--ink); cursor: pointer; }
.ca-dep input { width: 15px; height: 15px; margin: 0; padding: 0; accent-color: var(--accent); }
.ca-accounts { display: flex; flex-direction: column; gap: 6px; }
.ca-acc { align-items: center; }
.ca-acc .mp.bad { color: var(--danger); border-color: #fecdca; margin-left: 6px; }
.ca-acc .btn { flex: none; padding: 5px 10px; font-size: 13px; margin-right: 4px; }
.ca-audit-wrap summary { cursor: pointer; font-size: 14px; padding: 4px 0; }
.ca-scroll { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
.ca-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.ca-table th, .ca-table td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }
.ca-table td:first-child { white-space: nowrap; }
.ca-table th { position: sticky; top: 0; background: var(--bg-soft); }
.ca-table td.tg { overflow-wrap: anywhere; }
.nw { white-space: nowrap; }
#conn-admin-row { margin-top: 0; }
.ca-table tr.bad td { color: var(--danger); }
@media (max-width: 600px) {
  .ca-deps { padding-left: 0; } .conn-svc { padding: 6px 2px; }
  /* аудит на телефоне — карточки вместо таблицы: без горизонтальной прокрутки */
  .ca-table tr:first-child { display: none; }
  .ca-table tr { display: block; padding: 5px 8px; border-bottom: 1px solid var(--line); }
  .ca-table td { display: inline; border: 0; padding: 0; white-space: normal; }
  .ca-table td + td::before { content: " · "; color: var(--muted); }
  .ca-table td:empty { display: none; }
  .ca-table th { position: static; }
}

/* этап 5: выполнение кода — шаг «код + вывод», файлы результата, админ-журнал */
.websteps ul:has(li.code) { max-height: none; overflow: visible; }
.websteps li.code { display: block; overflow: visible; }
.websteps li.code.err { text-decoration: none; }
.websteps li.code.bad > .codestep > summary { color: #b3261e; }
.codestep > summary { display: flex; gap: 6px; align-items: center; cursor: pointer; list-style: none; min-width: 0; }
.codestep > summary::-webkit-details-marker { display: none; }
.codestep > summary::after { content: "›"; margin-left: 2px; transition: transform .15s; }
.codestep[open] > summary::after { transform: rotate(90deg); }
.codestep > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.websteps li.code.run .codestep > summary span::after { content: " …"; }
.codestep .cs-h { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 3px; }
.codestep pre { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-soft);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); max-height: 320px; overflow: auto; white-space: pre; }
.codestep pre code { background: none; padding: 0; font: inherit; }
.codestep pre.cs-out.empty { color: var(--muted); }
.codestep pre.cs-err { margin-top: 4px; color: #b3261e; border-color: color-mix(in srgb, #b3261e 30%, var(--line)); }
.codestep .cs-note { margin-top: 4px; color: #b3261e; }
.codestep .cs-files { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.codestep .cs-files a { color: var(--accent); word-break: break-all; }
.codefiles { margin: 4px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.codefiles .cf-img { display: block; max-width: 100%; width: fit-content; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.codefiles .cf-img img { display: block; max-width: 100%; height: auto; max-height: 560px; }
.cf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cf-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); color: var(--ink); text-decoration: none; font-size: 13px; }
.cf-chip:hover { border-color: var(--accent); }
.cf-chip .cf-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cf-chip .cf-s { color: var(--muted); flex: none; }
#code-runs { overflow-x: auto; }
.code-audit { border-collapse: collapse; font-size: 12px; width: 100%; }
.code-audit th, .code-audit td { text-align: left; padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.code-audit td.ca-who { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
