/* SkyNet — минималистичная тёмная тема. Одна гарнитура, две плоскости, тонкие рамки. */

:root {
  --bg: #0f0f10;
  --side: #141415;
  --surface: #18181a;
  --surface-2: #1f1f22;
  --hover: rgba(255, 255, 255, .045);
  --active: rgba(255, 255, 255, .075);
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .12);
  --focus: rgba(255, 255, 255, .28);
  --text: #ececed;
  --text-2: #a3a3a8;
  --text-3: #6e6e74;
  --ok: #5fd38d;
  --warn: #e2b55e;
  --danger: #f07a7a;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --f: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', Consolas, monospace;
  --col: 760px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--f);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--text-3); }
::selection { background: rgba(255, 255, 255, .2); }
.vbar { display: none; }

/* ============ базовые элементы ============ */

.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg, .btn svg { width: 100%; height: 100%; stroke-width: 1.7; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border-2); background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn .ico { width: 15px; height: 15px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: #ececed; color: #111; border-color: transparent; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); border-color: rgba(240, 122, 122, .28); }
.btn.danger:hover { background: rgba(240, 122, 122, .08); }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .35; cursor: default; }
.btn:disabled:hover { background: transparent; }
.btn.primary:disabled:hover { background: #ececed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.ghost { border-color: transparent; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small .ico { width: 15px; height: 15px; }
.icon-btn:disabled { opacity: .3; cursor: default; }

input[type=text], input[type=password], textarea, select {
  background: rgba(255, 255, 255, .03); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 8px 11px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select {
  height: 32px; padding: 0 28px 0 10px; cursor: pointer; appearance: none; font-size: 13px; color: var(--text-2);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%236e6e74' stroke-width='1.5'%3E%3Cpath d='m1 1 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center;
  border-color: var(--border);
}
select:hover { color: var(--text); background-color: var(--hover); }
select option { background: var(--surface); color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.tags { font-size: 12px; color: var(--text-3); }
.tags span + span::before { content: '·'; margin: 0 6px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 12px; text-align: center; }

@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pulse { 50% { opacity: .3; } }

/* ============ вход ============ */

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; animation: fade-in .4s ease; }
.login-logo { width: 44px; height: 44px; opacity: .9; }
.login-title { font-size: 22px; margin-top: 18px; }
.login-label { margin: 6px 0 28px; color: var(--text-3); font-size: 14px; }
.code { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.code-group { display: flex; gap: 5px; }
.code-dash { width: 8px; height: 1px; background: var(--text-3); flex: none; }
.code input {
  width: 30px; height: 42px; padding: 0; text-align: center; caret-color: transparent;
  font: 500 17px var(--f-mono); text-transform: uppercase; border-radius: 7px;
  background: var(--surface); border-color: var(--border);
}
.code input.filled { border-color: var(--border-2); }
.code input:focus { border-color: var(--focus); background: var(--surface-2); }
.login-btn { margin-top: 24px; height: 40px; }
.login-card.shake { animation: shake .35s; }
.login-card.shake .code input { border-color: rgba(240, 122, 122, .5); }
@keyframes shake { 25%, 75% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }

/* ============ раскладка ============ */

.app { height: 100%; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--side); border-right: 1px solid var(--border); padding: 12px 10px 10px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 14px 6px; }
.brand img { width: 22px; height: 22px; opacity: .9; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.collapse-btn { margin-left: auto; }
.new-chat { width: 100%; justify-content: flex-start; height: 36px; padding: 0 10px; color: var(--text); background: var(--surface); border-color: var(--border); }
.new-chat:hover { background: var(--surface-2); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 4px 8px; }
.section-label { font-size: 12px; font-weight: 500; color: var(--text-3); }

/* ============ проекты и чаты ============ */

.session-list { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; }
.pgroup { margin-bottom: 6px; }
.pgroup-head {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 4px; border-radius: 6px;
  cursor: pointer; color: var(--text-3); user-select: none; font-size: 12.5px;
}
.pgroup-head:hover { color: var(--text-2); }
.pgroup-head .caret { width: 14px; height: 14px; display: grid; transition: transform .15s; transform: rotate(90deg); }
.pgroup.closed .caret { transform: none; }
.pgroup-head svg { width: 100%; height: 100%; }
.pgroup-head .pg-ico { display: none; width: 16px; height: 16px; }
.pg-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-count { display: none; }
.pg-add { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; opacity: 0; }
.pg-add svg { width: 14px; height: 14px; }
.pgroup-head:hover .pg-add { opacity: 1; }
.pg-add:hover { background: var(--hover); color: var(--text); }
.pgroup.closed .pgroup-rows { display: none; }

.session {
  position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px;
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-2);
}
.session:hover { background: var(--hover); }
.session.active { background: var(--active); color: var(--text); }
.session .s-ico { display: none; width: 16px; height: 16px; color: var(--text-3); }
.session .s-ico svg { width: 100%; height: 100%; }
.session .s-body { min-width: 0; flex: 1; }
.session .s-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session .s-tags { display: none; }
.session .busy-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; animation: pulse 1.4s infinite; }
.session .s-actions { display: none; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); gap: 0; padding-left: 16px; background: linear-gradient(90deg, transparent, var(--side) 30%); }
.session.active .s-actions { background: linear-gradient(90deg, transparent, #222224 30%); }
.session:hover .s-actions { display: flex; }
.session .s-actions button { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-3); border-radius: 6px; cursor: pointer; }
.session .s-actions button:hover { color: var(--text); background: var(--hover); }
.session .s-actions svg { width: 14px; height: 14px; }
.session-list.first .session { animation: fade .3s ease both; }

.sidebar-foot { position: relative; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.profile-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px; background: transparent;
  border: 0; border-radius: var(--r-sm); cursor: pointer; text-align: left;
}
.profile-btn:hover, .profile-btn.open { background: var(--hover); }
.profile-btn .me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.profile-btn b { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-btn .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .15s; }
.profile-btn.open .chev { transform: rotate(180deg); }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.conn i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.conn.on i { background: var(--ok); }

.avatar { position: relative; width: 30px; height: 30px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.avatar.xl { width: 88px; height: 88px; }
.avatar.xl span { font-size: 30px; }

.pmenu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 25; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45); animation: fade-in .14s ease;
}
.pmenu button { width: 100%; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left; font-size: 13.5px; color: var(--text-2); }
.pmenu button:hover { background: var(--hover); color: var(--text); }
.pmenu button.danger:hover { color: var(--danger); }
.pmenu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ============ шапка ============ */

.topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px 0 24px; flex: none; }
.title-block { flex: 1; min-width: 0; }
.chat-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tags { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.controls { display: flex; gap: 6px; align-items: center; }
.mobile-only { display: none; }

/* ============ лента ============ */

.messages { flex: 1; overflow-y: auto; padding: 8px 24px 24px; overscroll-behavior: contain; }
.messages > * { max-width: var(--col); margin-left: auto; margin-right: auto; }

.empty { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 24px 0 64px; animation: fade .4s ease; }
.hero-hi { color: var(--text-3); font-size: 14px; margin-bottom: 6px; }
.hero-hi:empty { display: none; }
.hero-title { font-size: 28px; margin-bottom: 24px; }
.suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.roster-row {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r); color: var(--text-2); font-size: 13.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.roster-row:hover { background: var(--hover); border-color: var(--border-2); color: var(--text); }
.roster-row .ico { color: var(--text-3); }

.msg { margin-top: 24px; animation: fade-in .2s ease; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .u-col { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; max-width: 82%; }
.msg.user .bubble { background: var(--surface-2); border-radius: 18px; padding: 9px 15px; white-space: pre-wrap; word-wrap: break-word; max-width: 100%; }
.msg.user .imgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg.user .imgs img { max-width: 220px; max-height: 160px; border-radius: var(--r); cursor: zoom-in; object-fit: cover; border: 1px solid var(--border); }
.msg.user .u-ava { display: none; }
.u-actions { display: flex; gap: 0; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg.user:hover .u-actions { opacity: 1; }
.u-actions button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; }
.u-actions button:hover { background: var(--hover); color: var(--text); }
.u-actions svg { width: 14px; height: 14px; }
.u-edit { width: min(620px, 78vw); }
.u-edit textarea { width: 100%; resize: vertical; min-height: 60px; max-height: 360px; line-height: 1.55; border-radius: var(--r); padding: 10px 13px; background: var(--surface-2); }
.u-edit-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }

.msg.assistant { line-height: 1.65; }
.md { word-wrap: break-word; color: #dedee0; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: .25em; }
.md strong { color: var(--text); font-weight: 600; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); line-height: 1.3; margin: 1.4em 0 .5em; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md code { font: 12.5px var(--f-mono); background: rgba(255, 255, 255, .06); padding: 1.5px 5px; border-radius: 5px; }
.md pre { position: relative; background: #131315; border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; }
.md pre .copy { position: absolute; top: 6px; right: 6px; opacity: 0; background: var(--surface-2); }
.md pre:hover .copy { opacity: 1; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border-2); padding: 6px 11px; }
.md th { background: var(--surface); font-weight: 600; }
.md blockquote { margin: .6em 0; padding-left: 14px; border-left: 2px solid var(--border-2); color: var(--text-2); }
.md img { max-width: 100%; border-radius: var(--r); cursor: zoom-in; }
.md hr { border: 0; height: 1px; background: var(--border); margin: 1.5em 0; }
.hljs { background: transparent !important; }
.cursor::after { content: ''; display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; background: var(--text-2); border-radius: 1px; animation: pulse 1s infinite; }

.thinking { margin: 4px 0 10px; font-size: 13px; color: var(--text-3); }
.thinking summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: ''; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.thinking[open] summary::before { transform: rotate(45deg); }
.thinking summary:hover { color: var(--text-2); }
.thinking .t-body { white-space: pre-wrap; margin-top: 8px; padding-left: 12px; border-left: 1px solid var(--border-2); max-height: 300px; overflow-y: auto; }
body.no-thinking .thinking { display: none; }

/* ============ команды (инструменты) ============ */

.tool { margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; animation: fade-in .2s ease; }
.tool.nested { margin-left: 20px; }
.nested-list { border-left: 1px solid var(--border); margin-left: 10px; padding-left: 10px; }
.tool-head { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 8px 0 12px; cursor: pointer; user-select: none; }
.tool-head:hover { background: rgba(255, 255, 255, .02); }
.tool-head .t-ico { width: 15px; height: 15px; flex: none; color: var(--text-3); }
.tool-head .t-ico svg { width: 100%; height: 100%; }
.tool-head .t-text { min-width: 0; flex: 1; display: flex; align-items: baseline; gap: 8px; }
.tool-head .t-name { font-size: 13px; font-weight: 500; color: var(--text-2); flex: none; }
.tool-head .t-arg { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-head .t-arg.mono { font: 12px var(--f-mono); }
.tool-head .t-status { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin: 0 6px; animation: pulse 1.2s infinite; }
.tool.done .t-status { background: var(--text-3); animation: none; opacity: .6; }
.tool.error .t-status { background: var(--danger); animation: none; }
.tool-head .t-dl { width: 26px; height: 26px; border: 0; }
.tool-head .t-dl svg { width: 14px; height: 14px; }
.tool-body { display: none; border-top: 1px solid var(--border); padding: 10px 12px 12px; background: rgba(0, 0, 0, .12); }
.tool.open .tool-body { display: block; }
.tool-body pre { margin: 0; font: 12px/1.55 var(--f-mono); white-space: pre-wrap; word-break: break-word; max-height: 400px; overflow: auto; color: #c9c9cd; }
.tool-body .label { font-size: 11.5px; color: var(--text-3); margin: 12px 0 6px; }
.tool-body .label:first-child { margin-top: 0; }
.tool-body img { max-width: 100%; border-radius: var(--r-sm); cursor: zoom-in; }
.diff .del { color: #f2a1a1; background: rgba(240, 122, 122, .07); display: block; }
.diff .add { color: #9fdfb6; background: rgba(95, 211, 141, .06); display: block; }
.mdiff { width: 100%; min-height: 56px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: #131315; }
.mdiff:not(.mounted) { display: grid; place-items: center; }
.mdiff:not(.mounted)::after { content: 'Загрузка…'; font-size: 12px; color: var(--text-3); }

.todos { list-style: none; margin: 0; padding: 0; }
.todos li { display: flex; gap: 10px; padding: 3px 0; font-size: 13.5px; color: var(--text-2); }
.todos li .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--border-2); flex: none; margin-top: 3px; display: grid; place-items: center; font-size: 10px; }
.todos li.completed { color: var(--text-3); text-decoration: line-through; }
.todos li.completed .box { background: var(--text-2); border-color: transparent; color: var(--bg); }
.todos li.in_progress { color: var(--text); }
.todos li.in_progress .box { border-color: var(--warn); }

/* ============ разрешения и вопросы ============ */

.perm { margin: 10px 0; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border-2); animation: fade-in .2s ease; }
.perm-title { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.perm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.perm .p-what { margin-top: 10px; }
.perm .p-what .sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.perm pre { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .25); font: 12px/1.55 var(--f-mono); white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto; }
.perm .p-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.perm .p-actions .btn { height: 30px; font-size: 13px; }
.perm .p-actions input { flex: 1; min-width: 180px; height: 30px; padding: 0 10px; font-size: 13px; }
.perm.resolved { opacity: .55; }
.perm.resolved .p-actions, .perm.resolved .q-block input { display: none; }
.perm .p-result { margin-top: 10px; font-size: 12.5px; color: var(--text-3); }
.perm.resolved .perm-dot { background: var(--text-3); }

.q-block { margin-top: 12px; }
.q-block .q-text { margin-bottom: 8px; }
.q-opts { display: flex; flex-direction: column; gap: 5px; }
.q-opt { text-align: left; border: 1px solid var(--border); background: transparent; border-radius: var(--r-sm); padding: 8px 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.q-opt:hover { background: var(--hover); }
.q-opt.sel { border-color: var(--focus); background: var(--active); }
.q-opt b { font-weight: 500; font-size: 13.5px; }
.q-opt small { display: block; color: var(--text-3); font-size: 12.5px; }
.q-block input { width: 100%; margin-top: 6px; }

.notice { margin: 14px 0; text-align: center; font-size: 12px; color: var(--text-3); }
.result-line { display: flex; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--text-3); animation: fade .3s ease; }
.result-line span + span::before { content: '·'; margin: 0 7px; }
.rl-retry { display: inline-flex; align-items: center; gap: 5px; margin-left: 10px; height: 24px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; font-size: 12px; opacity: 0; transition: opacity .15s; }
.rl-retry svg { width: 12px; height: 12px; }
.result-line:hover .rl-retry, .messages > .result-line:last-child .rl-retry { opacity: 1; }
.rl-retry:hover { background: var(--hover); color: var(--text); }
.err-box { margin: 10px 0; padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid rgba(240, 122, 122, .25); background: rgba(240, 122, 122, .06); color: #f4b4b4; white-space: pre-wrap; font-size: 13.5px; }

.typing { display: flex; align-items: center; gap: 10px; margin-top: 22px; font-size: 13px; color: var(--text-3); animation: fade .3s ease; }
.typing .dots { display: flex; gap: 3px; }
.typing .dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite ease-in-out; }
.typing .dots i:nth-child(2) { animation-delay: .2s; }
.typing .dots i:nth-child(3) { animation-delay: .4s; }

/* ============ файлы от Claude ============ */

.attach { margin: 10px 0; max-width: 440px; overflow: hidden; animation: fade-in .2s ease; }
.attach-img { display: block; width: 100%; max-height: 380px; object-fit: contain; background: #111; cursor: zoom-in; }
video.attach-img { cursor: default; }
.attach-audio { display: block; width: calc(100% - 20px); margin: 10px; }
.attach-row { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; }
.attach.is-image .attach-row { border-top: 1px solid var(--border); }
.attach-ico { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.attach-ico svg { width: 100%; height: 100%; }
.attach-text { flex: 1; min-width: 0; }
.attach-text b { display: block; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-text .tags { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-row .btn { flex: none; }

.mermaid-box { margin: .8em 0; padding: 16px; border-radius: var(--r); background: #131315; border: 1px solid var(--border); overflow-x: auto; text-align: center; }
.mermaid-box svg { max-width: 100%; height: auto; }
.mermaid-loading { font-size: 12px; color: var(--text-3); }

/* ============ ввод ============ */

.composer {
  position: relative; width: calc(100% - 48px); max-width: var(--col); margin: 0 auto 18px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); transition: border-color .15s;
}
.composer:focus-within { border-color: rgba(255, 255, 255, .2); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 7px 4px; min-height: 34px; max-height: 240px; line-height: 1.5; font-size: 14px; }
.composer .icon-btn { width: 34px; height: 34px; }
.send {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: #ececed; color: #111; transition: background .15s, opacity .15s;
}
.send:hover { background: #fff; }
.send .ico { width: 16px; height: 16px; }
.send.stop { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
.send.stop .ico { width: 12px; height: 12px; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.attachments:not(:empty) { padding: 4px 4px 8px; }
.att { position: relative; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 4px 28px 4px 4px; font-size: 12.5px; max-width: 220px; }
.att img { width: 44px; height: 44px; object-fit: cover; border-radius: 7px; }
.att > .ico { margin-left: 6px; color: var(--text-3); }
.att .att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att.uploading { opacity: .5; }
.att .rm { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .5); cursor: pointer; font-size: 10px; line-height: 1; color: var(--text-2); }
.slash-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); max-height: 260px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r); padding: 4px; z-index: 5; box-shadow: 0 16px 40px rgba(0, 0, 0, .4); }
.slash-menu div { padding: 6px 10px; border-radius: 6px; cursor: pointer; font: 13px var(--f-mono); color: var(--text-2); }
.slash-menu div.sel, .slash-menu div:hover { background: var(--hover); color: var(--text); }

/* ============ модалки и диалоги ============ */

.modal-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .6); animation: fade .15s; }
.modal {
  display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 32px);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55); animation: fade-in .2s ease;
}
.modal-sm { max-width: 380px; }
.modal-md { max-width: 580px; height: min(640px, calc(100vh - 32px)); }
.modal-xl { max-width: 1240px; height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 16px 14px 12px 20px; }
.modal-head h3 { font-size: 15px; flex: none; }
.modal-head [data-close] { margin-left: auto; }
.modal-scroll { flex: 1; overflow-y: auto; padding: 4px 20px 22px; }

.profile-body { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 20px 22px; }
.avatar-edit { position: relative; cursor: pointer; }
.avatar-cam { position: absolute; right: 0; bottom: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #ececed; color: #111; border: 2px solid var(--surface); }
.avatar-cam .ico { width: 14px; height: 14px; }
.profile-body .field { width: 100%; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field.grow { flex: 1; margin: 0; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); margin: 20px 0 8px; }
.field > .field-label { margin: 0; }
.field-hint { font-size: 12px; color: var(--text-3); }
.field input, .field select { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.row.gap { gap: 8px; margin: 12px 0; }
.row.wrap { flex-wrap: wrap; }

.tabs { display: flex; gap: 2px; margin: 0 20px; padding: 3px; background: var(--bg); border-radius: 10px; align-self: flex-start; }
.tab { border: 0; background: transparent; cursor: pointer; height: 28px; padding: 0 12px; border-radius: 7px; color: var(--text-3); font-size: 13px; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); }
.tab-pane { padding-top: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat span { display: block; font-size: 12px; color: var(--text-3); }
.stat b { display: block; margin-top: 2px; font-size: 15px; font-weight: 600; }
.stat b.ok { color: var(--ok); }
.stat b.bad { color: var(--danger); }

.toggle { display: flex; align-items: center; gap: 11px; padding: 7px 0; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.toggle:hover { color: var(--text); }
.toggle input { display: none; }
.toggle i { position: relative; width: 32px; height: 18px; flex: none; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border-2); transition: background .15s; }
.toggle i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); transition: transform .15s, background .15s; }
.toggle input:checked + i { background: #ececed; border-color: transparent; }
.toggle input:checked + i::after { transform: translateX(14px); background: #111; }

.kv { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.kv div { display: flex; gap: 14px; padding: 7px 12px; font-size: 12.5px; }
.kv div + div { border-top: 1px solid var(--border); }
.kv span { width: 120px; flex: none; color: var(--text-3); }
.kv b { font: 400 12px var(--f-mono); color: var(--text-2); word-break: break-all; }
.log { margin: 0; height: 200px; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font: 11px/1.5 var(--f-mono); color: var(--text-2); white-space: pre-wrap; word-break: break-all; }

.dialog-wrap { z-index: 80; }
.dialog-body { padding: 0 20px 18px; }
.dialog-text { margin: 0 0 14px; color: var(--text-2); font-size: 13.5px; }
.dialog-input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 16px; }

/* ============ файловый менеджер ============ */

.chips { display: flex; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 28px; padding: 0 10px; border-radius: 7px; cursor: pointer; border: 0; background: transparent; color: var(--text-3); font-size: 12.5px; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip .ico { width: 14px; height: 14px; }

.fx { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); border-top: 1px solid var(--border); }
.fx-nav { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); padding: 10px 8px 8px; }
.fx-tools { display: flex; align-items: center; gap: 4px; }
.crumbs { flex: 1; display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; white-space: nowrap; min-width: 0; }
.crumb { border: 0; background: transparent; cursor: pointer; padding: 3px 5px; border-radius: 5px; color: var(--text-3); font-size: 12.5px; }
.crumb:hover { background: var(--hover); color: var(--text); }
.crumb.last { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--text-3); font-size: 11px; opacity: .5; }
.fx-search { position: relative; margin: 8px 2px 6px; }
.fx-search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
.fx-search input { width: 100%; height: 32px; padding-left: 32px; font-size: 13px; }
.fx-list { flex: 1; overflow-y: auto; }
.fx-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.fx-row:hover { background: var(--hover); color: var(--text); }
.fx-row.sel { background: var(--active); color: var(--text); }
.fx-ico { width: 16px; height: 16px; color: var(--text-3); }
.fx-ico svg { width: 100%; height: 100%; }
.fx-row.dir .fx-ico { color: var(--text-2); }
.fx-main { min-width: 0; display: flex; flex-direction: column; }
.fx-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-sub { font: 10.5px var(--f-mono); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; line-height: 1.2; }
.fx-row:has(.fx-sub) { height: 40px; }
.fx-size, .fx-date { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.fx-foot { padding: 8px 6px 0; font-size: 11.5px; color: var(--text-3); border-top: 1px solid var(--border); margin-top: 6px; }

.fx-view { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.fx-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.fx-icon { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.fx-icon svg { width: 100%; height: 100%; }
.fx-title { flex: 1; min-width: 0; }
.fx-title b { display: block; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.fx-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.fx-body.center { align-items: center; justify-content: center; overflow: auto; padding: 24px; }
.fx-body.checker { background-image: conic-gradient(rgba(255,255,255,.025) 25%, transparent 0 50%, rgba(255,255,255,.025) 0 75%, transparent 0); background-size: 20px 20px; }
.fx-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); cursor: zoom-in; }
.fx-media { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.fx-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.fx-code { flex: 1; min-height: 0; }
.fx-pre { margin: 0; padding: 16px; height: 100%; overflow: auto; font: 12.5px/1.6 var(--f-mono); white-space: pre; }
.fx-md { flex: 1; overflow: auto; padding: 20px 28px; }
.fx-tabs { display: flex; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.fx-placeholder { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-3); font-size: 13.5px; text-align: center; padding: 20px; }
.fx-placeholder .ico { width: 28px; height: 28px; }
.fx-placeholder .ico.big { width: 40px; height: 40px; }

/* ============ пустые состояния ============ */

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 32px 16px; color: var(--text-3); animation: fade .3s ease; }
.empty-state .es-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 8px; color: var(--text-3); border: 1px solid var(--border-2); }
.empty-state .es-ico svg, .empty-state .es-ico .ico { width: 18px; height: 18px; }
.empty-state b { font-weight: 500; font-size: 13.5px; color: var(--text-2); }
.empty-state span:not(.es-ico):not(.ico) { font-size: 12.5px; max-width: 260px; line-height: 1.5; }
.empty-state.big { margin: auto; }
.session-list .empty-state { padding: 28px 8px; }

/* ============ оверлеи ============ */

.drop-overlay { position: fixed; inset: 12px; z-index: 50; display: grid; place-items: center; background: rgba(15, 15, 16, .88); border: 1.5px dashed var(--border-2); border-radius: var(--r-lg); }
.drop-text { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text-2); }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .88); display: grid; place-items: center; cursor: zoom-out; animation: fade .15s; }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: var(--r-sm); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; background: var(--surface-2); border: 1px solid var(--border-2); padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 12px 32px rgba(0, 0, 0, .4); animation: fade .15s; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .14); }
::-webkit-scrollbar-track { background: transparent; }

/* полоса заголовка в десктоп-клиенте (вставляется из preload) */
html.electron #sn-titlebar { background: var(--bg); border-bottom: 1px solid var(--border); font: 500 12px var(--f); letter-spacing: 0; color: var(--text-3); }
html.electron #sn-titlebar i { display: none; }

/* ============ свёрнутая боковая панель ============ */

body.sb-collapsed .app { grid-template-columns: 56px minmax(0, 1fr); }
body.sb-collapsed .sidebar { padding: 12px 8px 8px; }
body.sb-collapsed .brand { flex-direction: column; gap: 10px; padding: 2px 0 12px; }
body.sb-collapsed .brand-name { display: none; }
body.sb-collapsed .collapse-btn { margin: 0; }
body.sb-collapsed .new-chat { justify-content: center; padding: 0; }
body.sb-collapsed .new-chat .lbl { display: none; }
body.sb-collapsed .section-head { justify-content: center; margin: 12px 0 4px; }
body.sb-collapsed .section-label, body.sb-collapsed .pgroup-head { display: none; }
body.sb-collapsed .pgroup.closed .pgroup-rows { display: block; }
body.sb-collapsed .session { justify-content: center; padding: 0; }
body.sb-collapsed .session > :not(.s-ico):not(.busy-dot) { display: none; }
body.sb-collapsed .session .s-ico { display: grid; }
body.sb-collapsed .session .busy-dot { position: absolute; top: 6px; right: 6px; }
body.sb-collapsed .session-list .empty-state { display: none; }
body.sb-collapsed .profile-btn { justify-content: center; padding: 6px 0; }
body.sb-collapsed .profile-btn > :not(.avatar) { display: none; }
body.sb-collapsed .pmenu { right: auto; width: 220px; }

/* ============ лёгкий режим ============ */

body.lite *, body.lite *::before, body.lite *::after { animation: none !important; transition: none !important; }
body.lite .modal, body.lite .pmenu, body.lite .toast { box-shadow: none; }

/* ============ адаптив ============ */

@media (max-width: 900px) {
  .fx { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 42%) minmax(0, 1fr); }
  .fx-nav { border-right: 0; border-bottom: 1px solid var(--border); }
  .fx-date { display: none; }
  .modal-head { flex-wrap: wrap; }
  .modal-head .chips { order: 3; width: 100%; }
  .modal-xl { height: calc(100vh - 16px); }
  .modal-wrap { padding: 8px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .fx-head { flex-wrap: wrap; }
}
@media (max-width: 780px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  #model-select { display: none; }
  .topbar { padding: 0 10px; gap: 8px; height: 50px; }
  .topbar .tags { display: none; }
  .messages { padding: 4px 14px 16px; }
  .composer { width: calc(100% - 20px); margin-bottom: max(10px, env(safe-area-inset-bottom)); }
  .suggest { grid-template-columns: 1fr; }
  .hero-title { font-size: 24px; }
}
@media (max-width: 440px) {
  .code { gap: 5px; }
  .code-group { gap: 3px; flex: 1; }
  .code input { flex: 1; width: auto; min-width: 0; }
}

/* ============ ER-диаграммы ============ */

.er-box { margin: .8em 0; border: 1px solid var(--border); border-radius: var(--r); background: #131315; overflow: hidden; }
.er-canvas { overflow: auto; padding: 8px; max-height: 560px; touch-action: none; }
.er-canvas svg { display: block; max-width: 100%; height: auto; margin: 0 auto; user-select: none; }
.er-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 12px; border-top: 1px solid var(--border); }
.er-hint { flex: 1; font-size: 12px; color: var(--text-3); }
.er-bar button { height: 26px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; }
.er-bar button:hover { background: var(--hover); color: var(--text); }
.er-bar button svg { width: 14px; height: 14px; }
.er-error { padding: 10px 14px; font-size: 13px; color: var(--danger); }
.er-box > pre { margin: 0; border: 0; border-radius: 0; }
.er-box.er-full { position: fixed; inset: 16px; z-index: 45; margin: 0; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0, 0, 0, .6); }
.er-box.er-full .er-canvas { flex: 1; max-height: none; }
.er-box.er-full .er-canvas svg { max-width: none; }

/* ============ общая память ============ */

.mem-hint { margin: 0 0 12px; line-height: 1.5; }
#mem-form { margin-bottom: 14px; }
.mem-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mem-list:has(.empty-state) { border: 0; }
.mem-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px; padding: 10px 8px 10px 14px; }
.mem-row + .mem-row { border-top: 1px solid var(--border); }
.mem-text { font-size: 13.5px; line-height: 1.5; word-wrap: break-word; }
.mem-meta { grid-row: 2; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.mem-actions { grid-row: 1 / 3; grid-column: 2; display: flex; align-items: center; gap: 0; opacity: 0; transition: opacity .15s; }
.mem-row:hover .mem-actions { opacity: 1; }
.mem-actions button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; }
.mem-actions button:hover { background: var(--hover); color: var(--text); }
.mem-actions svg { width: 14px; height: 14px; }

.mem-note {
  display: inline-flex; align-items: center; gap: 8px; margin: 8px 0; padding: 5px 10px 5px 8px; max-width: 100%;
  border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-3);
  font-size: 12.5px; cursor: pointer; text-align: left; animation: fade-in .2s ease;
}
.mem-note:hover { color: var(--text-2); background: var(--hover); }
.mem-note svg { width: 14px; height: 14px; flex: none; }
.mem-note span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-note b { font-weight: 500; color: var(--text-2); }

/* ============ админка ============ */

.modal-lg { max-width: 920px; height: min(680px, calc(100vh - 32px)); }
.modal-head .btn.small + [data-close] { margin-left: 0; }
.modal-head h3 + .btn { margin-left: auto; }
.adm { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--border); }
.adm:has(.adm-form:not(.hidden)) { grid-template-columns: minmax(0, 1fr) 380px; }
.adm-list { overflow-y: auto; padding: 6px; }
.adm-row { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; cursor: pointer; }
.adm-row:hover { background: var(--hover); }
.adm-row.sel { background: var(--active); }
.adm-main { flex: 1; min-width: 0; }
.adm-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-row .tags { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-status { flex: none; font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.adm-status.ok { color: var(--text-2); }
.adm-status.warn { color: var(--warn); border-color: rgba(226, 181, 94, .3); }
.adm-status.bad { color: var(--danger); border-color: rgba(240, 122, 122, .3); }
.muted { color: var(--text-3); font-weight: 400; }

.adm-form { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--bg); }
.adm-form-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 18px; }
.adm-form-head b { font-weight: 600; font-size: 14px; }
.adm-form-body { flex: 1; overflow-y: auto; padding: 0 18px 10px; }
.adm-form-body .field { margin: 12px 0; }
.adm-form-body textarea { resize: vertical; min-height: 64px; font: 12.5px/1.5 var(--f-mono); }
.adm-form-body input[type=date] { color-scheme: dark; flex: 1; }
.adm-form-foot { display: flex; align-items: center; gap: 6px; padding: 10px 18px 14px; border-top: 1px solid var(--border); }
.adm-form-foot .grow { flex: 1; }
.adm-form.is-new .adm-edit-only { display: none; }
.adm-form.is-admin .adm-limited, .adm-form.is-owner .adm-limited { display: none; }
.adm-form.is-owner #adm-delete { display: none; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; align-self: flex-start; }
.seg button { height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 13px; cursor: pointer; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.active { background: var(--surface-2); color: var(--text); }
.seg button:disabled { cursor: default; }

.chk-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chk { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.chk:has(input:checked) { border-color: var(--focus); color: var(--text); background: var(--active); }
.chk input { margin: 0; accent-color: #ececed; }

.code-show { margin: 4px 0 2px; padding: 14px; text-align: center; font: 500 22px var(--f-mono); letter-spacing: .08em; background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; user-select: all; }

/* «Мой доступ» в профиле */
.pf-access { width: 100%; }
.pf-access .field-label { margin: 8px 0 8px; }
.pf-access .kv span { width: 70px; }
.pf-access .kv b { font: 13px var(--f); color: var(--text); }
.pf-folders { display: flex; flex-direction: column; gap: 3px; }
.pf-folders code { font: 11.5px var(--f-mono); color: var(--text-2); word-break: break-all; }
.modal-sm:has(#pf-access) { max-width: 420px; }

@media (max-width: 780px) {
  .adm:has(.adm-form:not(.hidden)) { grid-template-columns: minmax(0, 1fr); }
  .adm:has(.adm-form:not(.hidden)) .adm-list { display: none; }
  .adm-form { border-left: 0; }
}

/* SQL: панель под ER-диаграммой, песочница и результаты запросов */
.sql-panel { border-top: 1px solid var(--border); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.sql-panel-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sql-panel-head .grow { flex: 1; }
.sql-panel-head b { font-size: 13px; font-weight: 600; }
.sql-panel .seg button { height: 24px; padding: 0 10px; font-size: 12.5px; }
.sql-panel pre.sql-ddl { margin: 0; max-height: 320px; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; }
.sql-panel pre.sql-ddl code { font-size: 12.5px; background: none; padding: 0; }
.sql-sandbox { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.sql-hint { font-size: 12px; color: var(--text-3); }
.sql-q { width: 100%; resize: vertical; min-height: 64px; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--bg); font: 12.5px/1.55 var(--f-mono); outline: none; }
.sql-q:focus { border-color: var(--focus); }
.sql-run-bar { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; }
.md pre + .sql-run-bar { margin-top: -6px; }
.sql-res { margin: 6px 0 10px; display: flex; flex-direction: column; gap: 6px; }
.sql-table { overflow: auto; max-height: 360px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.sql-table table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12.5px; display: table; }
.sql-table th, .sql-table td { border: 0; border-bottom: 1px solid var(--border); padding: 5px 10px; text-align: left; white-space: nowrap; font-family: var(--f-mono); }
.sql-table th { position: sticky; top: 0; background: var(--surface-2); font-family: var(--f); font-weight: 600; }
.sql-table td.null { color: var(--text-3); font-style: italic; }
.sql-msg { font-size: 12px; color: var(--text-3); }
.sql-msg.ok { color: var(--ok); }
.sql-msg.err { color: var(--danger); font-family: var(--f-mono); white-space: pre-wrap; }
.rl-retry + .rl-retry { margin-left: 2px; }

/* формулы (KaTeX) */
.md .math-d { display: block; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.md .katex { font-size: 1.08em; }
.md .katex-display { margin: .6em 0; }
