/* Командный чат — оформление. Тёплая «бумага», проза ответов набрана антиквой. */
:root {
  --bg: #f6f4ee;
  --side: #eeebe2;
  --surface: #ffffff;
  --raised: #fbfaf6;
  --text: #23211c;
  --muted: #736f64;
  --faint: #9b968a;
  --line: #ddd8cb;
  --line-soft: #e8e4d9;
  --accent: #b5562f;
  --accent-hover: #9d4925;
  --accent-ink: #ffffff;
  --accent-wash: #f3e3d9;
  --bubble: #e9e5d9;
  --danger: #a8321f;
  --danger-wash: #f8e6e1;
  --ok: #2f6b45;
  --code-bg: #f1eee6;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 8px 24px rgba(40, 30, 10, .07);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --hl-kw: #a3421f; --hl-str: #2f6b45; --hl-num: #7a4fa0; --hl-com: #8c877a; --hl-fn: #1f5f8b; --hl-attr: #8a6a00;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #242320;
  --side: #1c1b19;
  --surface: #2e2d29;
  --raised: #292825;
  --text: #ece8de;
  --muted: #a39e91;
  --faint: #7d786d;
  --line: #403e38;
  --line-soft: #35332f;
  --accent: #d98056;
  --accent-hover: #e39369;
  --accent-ink: #1c1b19;
  --accent-wash: #3b2d25;
  --bubble: #383630;
  --danger: #e8836f;
  --danger-wash: #3d2622;
  --ok: #7fc79a;
  --code-bg: #1d1c1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --hl-kw: #e39369; --hl-str: #9ccfa9; --hl-num: #c4a3e0; --hl-com: #8a857a; --hl-fn: #8fc1e3; --hl-attr: #dcc27a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* --- кнопки и поля -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--raised); border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-wash); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.field small { color: var(--faint); font-size: 12.5px; line-height: 1.4; }
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea.input { resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 20px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

/* --- вход ----------------------------------------------------------------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); }
.login .mark { width: 44px; height: 44px; margin-bottom: 22px; }
.login h1 { font: 500 34px/1.15 var(--serif); margin: 0 0 6px; letter-spacing: -.01em; }
.login p { margin: 0 0 26px; color: var(--muted); }
.login .btn { width: 100%; height: 42px; margin-top: 6px; }
.login .error { color: var(--danger); min-height: 22px; margin: 4px 0 8px; font-size: 14px; }

/* --- каркас --------------------------------------------------------------- */
.shell { height: 100%; display: flex; overflow: hidden; }
.side {
  width: 284px; flex: none; background: var(--side); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; transition: margin-left .2s ease;
}
.shell.side-closed .side { margin-left: -284px; }
.side-top { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 16px/1.2 var(--serif); flex: 1; min-width: 0; }
.brand img { width: 24px; height: 24px; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { padding: 2px 10px 8px; display: grid; gap: 8px; }
.new-chat { justify-content: flex-start; width: 100%; height: 38px; border-color: transparent; background: transparent; color: var(--accent); font-weight: 600; padding: 0 8px; }
.new-chat:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: transparent; }
.new-chat .plus { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.new-chat .plus svg { width: 15px; height: 15px; stroke-width: 2.2; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--faint); width: 16px; height: 16px; }
.search input { width: 100%; height: 34px; padding: 0 10px 0 32px; border-radius: 9px; border: 1px solid transparent; background: color-mix(in srgb, var(--text) 6%, transparent); }
.search input:focus { outline: 0; border-color: var(--accent); background: var(--surface); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; }
.chat-group { font-size: 12px; color: var(--faint); padding: 14px 10px 5px; }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 9px; }
.chat-item a { flex: 1; min-width: 0; padding: 7px 10px; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; border-radius: 9px; }
.chat-item:hover, .chat-item.menu-open { background: color-mix(in srgb, var(--text) 6%, transparent); }
.chat-item.active { background: color-mix(in srgb, var(--text) 10%, transparent); }
.chat-item .icon-btn { width: 28px; height: 28px; margin-right: 3px; opacity: 0; }
.chat-item:hover .icon-btn, .chat-item.menu-open .icon-btn, .chat-item .icon-btn:focus-visible { opacity: 1; }
.chat-empty { color: var(--faint); font-size: 13.5px; padding: 18px 10px; line-height: 1.45; }
.side-bottom { border-top: 1px solid var(--line-soft); padding: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: transparent; border-radius: 10px; text-align: left; }
.user-chip:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 12.5px; font-weight: 600; flex: none; }
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who small { color: var(--faint); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { height: 50px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.topbar .title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 8px; border-radius: 8px; border: 0; background: transparent; max-width: min(60vw, 520px); }
.topbar .title:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.topbar .grow { flex: 1; }
.scroll { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.column { width: min(780px, 100%); margin: 0 auto; padding: 8px 22px 28px; }
.to-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted); }

/* пустой чат: приветствие и поле ввода по центру */
.main.empty .scroll { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.main.empty .composer-wrap { margin-bottom: auto; padding-bottom: 12vh; }
.greeting { text-align: center; padding: 0 0 26px; }
.greeting h1 { font: 400 clamp(28px, 4.2vw, 40px)/1.15 var(--serif); margin: 0; letter-spacing: -.012em; }
.greeting p { color: var(--muted); margin: 10px 0 0; }

/* --- сообщения ------------------------------------------------------------ */
.msg { margin: 16px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { max-width: min(86%, 620px); background: var(--bubble); border-radius: 16px 16px 4px 16px; padding: 10px 15px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.msg.user .attach-row { justify-content: flex-end; margin-bottom: 6px; }
.msg .actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.msg:hover .actions, .msg .actions:focus-within, .msg.last .actions { opacity: 1; }
.msg .actions .icon-btn { width: 30px; height: 30px; }
.msg .actions .icon-btn svg { width: 16px; height: 16px; }
.msg.user .edit-box { width: min(86%, 620px); }
.msg.user .edit-box textarea { min-height: 80px; }
.msg.user .edit-box .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.prose { font: 16.5px/1.68 var(--serif); overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .9em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 1.35em 0 .5em; letter-spacing: -.005em; }
.prose h1 { font-size: 1.5em; } .prose h2 { font-size: 1.28em; } .prose h3 { font-size: 1.12em; } .prose h4 { font-size: 1em; }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.5em; }
.prose li { margin: .25em 0; }
.prose li > p { margin: 0 0 .4em; }
.prose blockquote { margin: 0 0 .9em; padding: 2px 0 2px 16px; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.prose code { font: .86em/1.5 var(--mono); background: var(--code-bg); padding: .12em .38em; border-radius: 5px; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 10px; }
.prose table { border-collapse: collapse; width: 100%; font: 14.5px/1.45 var(--sans); }
.prose th, .prose td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.prose th { background: var(--raised); font-weight: 600; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose a.cite { display: inline-block; font: 11.5px/1 var(--sans); padding: 3px 7px; margin: 0 2px; border-radius: 20px; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); text-decoration: none; vertical-align: 2px; white-space: nowrap; }
.prose a.cite:hover { background: var(--accent-wash); color: var(--accent); }

.code { margin: 0 0 1em; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 13px; font: 12.5px/1 var(--sans); color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.code-head .lang { flex: 1; }
.code-head button { border: 0; background: transparent; color: var(--muted); height: 26px; padding: 0 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.code-head button:hover { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); }
.code-head button svg { width: 14px; height: 14px; }
.code pre { margin: 0; padding: 13px 15px; overflow-x: auto; font: 13.3px/1.55 var(--mono); tab-size: 2; }
.code pre code { background: none; padding: 0; font: inherit; border-radius: 0; }
.hljs-keyword, .hljs-literal, .hljs-built_in, .hljs-selector-tag, .hljs-doctag, .hljs-meta .hljs-keyword, .hljs-name { color: var(--hl-kw); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: var(--hl-str); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable.constant_ { color: var(--hl-num); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-com); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section, .hljs-type { color: var(--hl-fn); }
.hljs-attr, .hljs-attribute, .hljs-selector-class, .hljs-selector-id, .hljs-property, .hljs-params { color: var(--hl-attr); }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

/* шаги: размышление, поиск, код */
.steps { margin: 0 0 14px; display: grid; gap: 2px; }
.body > .prose + .steps { margin-top: 12px; }
.step { border-radius: 9px; font-size: 14px; color: var(--muted); }
.step > summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 4px; border-radius: 9px; cursor: pointer; user-select: none; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.step > summary svg { width: 16px; height: 16px; }
.step > summary .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.step > summary .count { color: var(--faint); font-size: 12.5px; flex: none; }
.step > summary .chev { margin-left: auto; transition: transform .15s; color: var(--faint); }
.step[open] > summary .chev { transform: rotate(90deg); }
.step.fail > summary { color: var(--danger); }
.step-body { margin: 2px 0 8px 12px; padding: 4px 0 4px 16px; border-left: 2px solid var(--line); font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.step-body .think { white-space: pre-wrap; font: 14.5px/1.6 var(--serif); color: var(--muted); }
.step-body pre { margin: 6px 0; padding: 10px 12px; background: var(--code-bg); border-radius: 8px; overflow-x: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; color: var(--text); max-height: 320px; overflow-y: auto; }
.step-body .src { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.step-body .src a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-body .src a:hover { color: var(--accent); text-decoration: underline; }
.step-body .src small { color: var(--faint); flex: none; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; margin: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { display: inline-flex; gap: 5px; padding: 8px 2px; }
.pulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: pulse 1.2s ease-in-out infinite; }
.pulse i:nth-child(2) { animation-delay: .15s; } .pulse i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; padding: 9px 13px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--muted); }
.notice.error { background: var(--danger-wash); color: var(--danger); }
.notice .btn { margin-left: auto; }

/* вложения и файлы */
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 9px; max-width: 260px; padding: 6px 10px 6px 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-size: 13px; color: var(--text); text-decoration: none; }
.chip .ext { flex: none; min-width: 34px; height: 30px; padding: 0 5px; border-radius: 7px; background: var(--accent-wash); color: var(--accent); font: 600 10.5px/30px var(--sans); text-align: center; letter-spacing: .02em; }
.chip .meta { min-width: 0; display: grid; }
.chip .meta b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .meta small { color: var(--faint); font-size: 11.5px; }
.chip img { width: 30px; height: 30px; border-radius: 7px; object-fit: cover; flex: none; }
.chip .x { border: 0; background: transparent; color: var(--faint); padding: 2px; margin-right: -4px; border-radius: 6px; display: grid; }
.chip .x:hover { color: var(--danger); }
.chip.busy { opacity: .6; }
.chip.failed { border-color: var(--danger); color: var(--danger); }
a.chip:hover { border-color: var(--accent); }
.files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin: 14px 0 0; }
.file-card { display: flex; align-items: center; gap: 12px; width: min(340px, 100%); padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); text-decoration: none; }
.file-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.file-card .ext { flex: none; width: 42px; height: 42px; border-radius: 9px; background: var(--accent-wash); color: var(--accent); font: 700 11px/42px var(--sans); text-align: center; }
.file-card .meta { min-width: 0; flex: 1; display: grid; }
.file-card .meta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .meta small { color: var(--faint); font-size: 12.5px; }
.file-card > svg { color: var(--muted); }
.image-card { display: block; max-width: min(520px, 100%); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--surface); }
.image-card img { display: block; max-width: 100%; max-height: 420px; }

/* --- поле ввода ----------------------------------------------------------- */
.composer-wrap { flex: none; padding: 0 22px 14px; }
.composer { width: min(780px, 100%); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s; }
.composer:focus-within { border-color: var(--faint); }
.composer.drag { border-color: var(--accent); border-style: dashed; }
.composer .attach-row { margin: 2px 0 8px; }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 6px 2px; min-height: 40px; max-height: 40vh; line-height: 1.5; font-size: 16px; }
.composer textarea::placeholder { color: var(--faint); }
.composer .bar { display: flex; align-items: center; gap: 4px; margin-top: 4px; margin-left: -6px; }
.composer .bar .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-size: 13.5px; }
.pill:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.pill svg { width: 15px; height: 15px; }
.pill svg:last-child { transform: rotate(90deg); width: 13px; height: 13px; }
.send { width: 36px; height: 36px; border-radius: 11px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-left: 4px; }
.send:hover { background: var(--accent-hover); }
.send:disabled { background: var(--line); color: var(--surface); cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.send svg { stroke-width: 2.2; }
.footnote { text-align: center; color: var(--faint); font-size: 12px; margin: 8px 0 0; }
.banner { width: min(780px, 100%); margin: 0 auto 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent-wash); color: var(--text); font-size: 14px; }

/* --- всплывающие меню, окна, уведомления ---------------------------------- */
.menu { position: fixed; z-index: 50; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 6px; }
.menu button, .menu label.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); cursor: pointer; }
.menu button:hover, .menu label.row:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.menu button.danger { color: var(--danger); }
.menu button .check { margin-left: auto; color: var(--accent); }
.menu button small { display: block; color: var(--faint); font-size: 12px; }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 6px 4px; }
.menu .cap { font-size: 12px; color: var(--faint); padding: 6px 10px 3px; }
.menu label.row { justify-content: space-between; }

dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--bg); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); width: min(520px, calc(100vw - 28px)); max-height: calc(100vh - 40px); }
dialog.wide { width: min(940px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(20, 16, 8, .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 42px); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px 22px; }
.dlg-head h2 { font: 600 20px/1.2 var(--serif); margin: 0; flex: 1; }
.dlg-body { padding: 4px 22px 20px; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; }
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding-top: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.section-title { font: 600 15px/1.3 var(--sans); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 14px; }
.status { font-size: 13.5px; margin-left: 4px; }
.status.ok { color: var(--ok); } .status.bad { color: var(--danger); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .input { min-height: 32px; padding: 4px 8px; }
table.data tr.off td { color: var(--faint); }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 7px; border-radius: 20px; background: var(--accent-wash); color: var(--accent); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 8px 0 0; }
.bars div { flex: 1; min-width: 3px; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .85; }
.bars div.zero { background: var(--line); }
.bars div:hover { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 4px; }
.kpis { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 18px; }
.kpis div b { display: block; font: 600 26px/1.15 var(--serif); }
.kpis div span { color: var(--muted); font-size: 13px; }

.toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

/* --- панель предпросмотра ------------------------------------------------- */
.panel { width: 0; flex: none; overflow: hidden; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.shell.panel-open .panel { width: min(46vw, 760px); }
.panel-head { display: flex; align-items: center; gap: 6px; height: 50px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.panel-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.seg { display: inline-flex; background: color-mix(in srgb, var(--text) 7%, transparent); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.panel iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.panel pre { flex: 1; margin: 0; padding: 16px; overflow: auto; font: 13px/1.55 var(--mono); background: var(--code-bg); }

@media (min-width: 861px) { .shell:not(.side-closed) .topbar > .icon-btn:first-child { display: none; } .shell:not(.side-closed) .topbar { padding-left: 20px; } }

/* --- узкие экраны --------------------------------------------------------- */
.scrim { display: none; }
@media (max-width: 860px) {
  .side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow); }
  .shell:not(.side-closed) .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(20, 16, 8, .4); }
  .shell.panel-open .panel { position: fixed; inset: 0; width: 100%; z-index: 45; }
  .column { padding: 8px 14px 24px; }
  .composer-wrap { padding: 0 10px 10px; }
  .prose { font-size: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .msg .actions { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
