/* Golos Text (SIL OFL 1.1), с fonts.google.com — лежит у нас, чтобы страницы не ходили к Google */
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/golos-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/golos-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/golos-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Тёмная тема (оформление 10.11.2026): графит, светлый текст, одна яркая деталь —
   небесно-голубой Skycenter у главной кнопки и открытой вкладки. Все цвета — в переменных */
:root {
  --bg: #0f1317;
  --panel: #161c22;
  --line: #25303a;
  --text: #e8edf2;
  --muted: #8d9aa6;
  --accent: #30cffa;
  --on-accent: #06222c;
  --danger: #ff6b5e;
  --warn: #f0a14a;
  --ok: #5fd38d;
  --user-msg: #15303b;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 .75rem; }
table, .op-rows, .weight, .number { font-variant-numeric: tabular-nums; }

a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, button {
  font: inherit;
  color: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: .6rem .8rem;
}

input { background: var(--panel); width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* Обычная кнопка — спокойная; голубая — только главное действие формы (одна яркая деталь) */
button { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; cursor: pointer; }
button:hover { border-color: var(--muted); }
.card button[type=submit], .composer button[type=submit], .poisk-q-row button, .bot-form button[type=submit],
.bot-new button, .vpn-add button, .lock-dialog button[type=submit] {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600;
}
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 400; }

.hint { color: var(--muted); margin: 0 0 1rem; }
.error { color: var(--danger); margin: 0 0 1rem; }
.link { display: block; text-align: center; margin-top: 1rem; color: var(--muted); }

/* Вход */
.auth { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.card {
  width: min(100%, 360px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card label { display: block; color: var(--muted); margin-bottom: 1rem; }
.card label input { margin-top: .3rem; }
.card button[type=submit] { width: 100%; }
.card > input { margin-bottom: .8rem; font-size: 1.3rem; letter-spacing: .2em; text-align: center; }

/* Шапка с вкладками */
.top {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  min-height: 3.4rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 1rem .7rem calc(1rem - 2px);
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current=page] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .short { display: none; }
.icon {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); background: transparent;
}
.icon:hover, .icon[aria-current=page] { color: var(--text); }
.icon[aria-current=page] { background: var(--bg); }
.top form > button { padding: .45rem .8rem; }
.icon[aria-pressed=true] { position: relative; z-index: 1001; background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
body.is-locked::before { content: ""; position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); }
.lock-dialog { width: min(300px, 92vw); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.lock-dialog::backdrop { background: transparent; }
.lock-dialog h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.lock-dialog input { font-size: 1.25rem; letter-spacing: .5em; text-align: center; margin-bottom: .75rem; }
.lock-dialog .row { display: flex; gap: .5rem; }
.lock-dialog .row button { flex: 1; }
/* Значок «Разрешения»: число ждущих решений в уголке */
.perm-icon { position: relative; }
.badge {
  position: absolute; top: -.35rem; right: -.35rem; min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem;
  border-radius: .6rem; background: var(--warn); color: var(--on-accent); font-size: .7rem; font-weight: 700; line-height: 1.15rem; text-align: center;
}
.badge[hidden] { display: none; }
.icon svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.content { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }

/* Телефон: вкладки — нижней панелью во всю ширину, под большой палец */
@media (max-width: 640px) {
  .top { justify-content: flex-end; }
  .tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    gap: 0;
    padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid var(--line);
  }
  .tabs a { flex: 1 1 0; min-width: 0; text-align: center; padding: .6rem 0; font-size: .7rem; overflow: hidden; text-overflow: ellipsis;
            border-bottom: 0; border-top: 2px solid transparent; }
  .tabs a[aria-current=page] { border-top-color: var(--accent); }
  .tabs .full { display: none; }
  .tabs .short { display: inline; }
  .content { padding-bottom: 5rem; }
}

.number { font-size: 3rem; font-weight: 700; text-align: center; margin: .5rem 0 1rem; letter-spacing: .1em; }

/* Чат: список разговоров слева, беседа справа; на телефоне — по очереди */
select {
  font: inherit; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem;
}
textarea {
  font: inherit; color: inherit; background: var(--panel); width: 100%; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem;
}
button:disabled { opacity: .6; cursor: default; }
.small { font-size: .85rem; }

body:has(.split) { display: flex; flex-direction: column; height: 100dvh; }
.content:has(.split) { max-width: none; width: 100%; padding: 0; flex: 1; min-height: 0; }
.split { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.list { border-right: 1px solid var(--line); overflow-y: auto; padding: .75rem; }
.new-chat { display: flex; gap: .4rem; margin-bottom: .75rem; }
.new-chat button { flex: 1; min-width: 0; white-space: nowrap; padding-inline: .5rem; }
.perms .new-chat { max-width: 28rem; }
.perms .new-chat button { flex: none; }
.list nav a {
  display: block; padding: .5rem .6rem; border-radius: var(--radius);
  color: var(--muted); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list nav a:hover { color: var(--text); }
.list nav a[aria-current=page], .list nav a[aria-current=location] { background: var(--panel); color: var(--text); }

.dialog { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dialog.empty { display: grid; place-items: center; }
.dialog-head { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
.dialog-head h1 { flex: 1; font-size: 1.05rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-head .delete button, .dialog-head .rename { padding: .35rem .55rem; }
.weight { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.back { display: none; }

.feed { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.more { align-self: center; color: var(--muted); }
.msg { max-width: min(760px, 92%); padding: .6rem .9rem; border-radius: var(--radius); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user-msg); white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.live { white-space: pre-wrap; }
.msg.error { align-self: flex-start; color: var(--danger); border: 1px solid var(--danger); white-space: pre-wrap; }
.msg > :first-child { margin-top: 0; }
.msg > :last-child { margin-bottom: 0; }
.msg pre, .msg table { display: block; overflow-x: auto; max-width: 100%; }
.msg pre { background: var(--bg); padding: .6rem; border-radius: 6px; }
.msg code { font-size: .9em; }
.msg table { border-collapse: collapse; }
.msg th, .msg td { border: 1px solid var(--line); padding: .3rem .5rem; }
.meta { color: var(--muted); font-size: .75rem; margin-top: .4rem; }

.composer { padding: .6rem 1rem 1rem; border-top: 1px solid var(--line); }
.composer .row { display: flex; gap: .5rem; align-items: flex-end; }
.composer .hint { margin-bottom: .5rem; }

@media (max-width: 640px) {
  .content:has(.split) { padding-bottom: calc(2.9rem + env(safe-area-inset-bottom)); }
  .split { grid-template-columns: 1fr; }
  .split.has-open .list { display: none; }
  .split:not(.has-open) .dialog { display: none; }
  .list { border-right: 0; }
  .back { display: inline; white-space: nowrap; }
  .dialog-head { flex-wrap: wrap; padding: .5rem .75rem; }
  .dialog-head h1 { flex-basis: 100%; order: 3; }
  .feed { padding: .75rem; }
  .composer { padding: .5rem .75rem .75rem; }
}

/* Проекты: в левой колонке — проекты, а в открытом проекте — его темы */
.up { display: inline-block; color: var(--muted); margin-bottom: .5rem; }
.side-title { font-size: .95rem; font-weight: 600; margin: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.side-head .side-title { min-width: 0; overflow-wrap: anywhere; }
.project-delete button { padding: .35rem .55rem; }
.access { margin: .5rem 0 .75rem; }
.access label { display: block; margin-bottom: .2rem; cursor: pointer; }
.access input { width: auto; margin: 0 .3rem 0 0; vertical-align: -2px; }
.access .hint { margin: 0; }
.new-chat input { min-width: 0; }
.new-chat:has(input) button { flex: none; }

/* Файлы проекта: на компьютере — колонкой справа, на телефоне — своей страницей */
.split.with-rail { grid-template-columns: 300px 1fr 300px; }
.rail { border-left: 1px solid var(--line); overflow-y: auto; padding: .75rem; min-width: 0; }
.rail .side-title { margin-bottom: .6rem; }
.rail .upload input { flex-basis: 100%; }
.rail .upload button { width: 100%; }
.rail .file-row > a:first-child { flex-basis: 100%; }
.files-link { display: none; margin: 0 0 .75rem; }
.files-link[aria-current=page] { color: var(--text); }
.upload { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.upload input { flex: 1; min-width: 0; }
.file-row { display: flex; gap: .3rem 1rem; flex-wrap: wrap; align-items: baseline; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.file-row > a:first-child { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.file-row .hint { margin: 0; }
@media (max-width: 640px) {
  .split.with-rail { grid-template-columns: 1fr; }
  .rail { display: none; }
  .files-link { display: block; }
}
.msg.doc { max-width: 100%; width: 100%; }
pre.msg.doc { white-space: pre-wrap; margin: 0; font-size: .9rem; }

/* Боты */
.bot-new { display: grid; gap: .4rem; margin-bottom: .75rem; }
.bot-form { display: grid; gap: .75rem; max-width: 760px; }
.bot-form label { display: grid; gap: .3rem; color: var(--muted); }
.bot-form label.check { display: block; color: var(--text); cursor: pointer; }
.bot-form .check input { width: auto; margin: 0 .4rem 0 0; vertical-align: -2px; }
.bot-form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; display: grid; gap: .4rem; }
.bot-form legend { color: var(--muted); padding: 0 .3rem; }
.bot-form .hint, .bot-form p { margin: 0; }
.bot-form button[type=submit] { justify-self: start; }
.owner { max-width: 760px; border-top: 1px solid var(--line); padding-top: .75rem; }
.owner p { margin: 0 0 .5rem; }

/* Операторская */
.op-block { margin-top: 1rem; }
.op-block .side-title .hint { white-space: nowrap; }
.op-block .side-title { margin: .75rem 0 .3rem; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.op-rows { list-style: none; margin: 0; padding: 0; }
.op-rows li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .3rem .25rem; border-bottom: 1px solid var(--line); }
.op-rows li .hint { margin: 0; text-align: right; }
.op-rows li .waiting { flex-basis: 100%; text-align: left; }
.op-rows li.on .hint { color: var(--accent); }
.op-rows .op-check { margin-left: .5rem; padding: .1rem .5rem; font-size: .8rem; }
@media (max-width: 640px) { .feed > .back { display: block; margin-bottom: .5rem; } }
.op-topics { padding-left: .75rem; margin: .25rem 0 .5rem; }
.op-topics .new-chat { margin-bottom: .4rem; }

/* Кружки состояния: красный — работает, оранжевый — ждёт разрешения, зелёный — свободна */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--line); vertical-align: middle; }
.dot--run { background: var(--danger); border-color: var(--danger); }
.dot--ask { background: var(--warn); border-color: var(--warn); }
.dot--idle { background: var(--ok); border-color: var(--ok); }
.dot--off { background: transparent; }

/* Страница «Разрешения» */
.perms { max-width: 760px; }
.perms h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.restart p { margin: 0 0 .6rem; }
.perm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.perm { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.perm p { margin: 0 0 .35rem; }
.perm-target { margin: 0 0 .5rem; padding: .5rem; background: var(--bg); border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: .85rem; }
.perm-buttons { display: flex; gap: .5rem; }
.perm-outcome { color: var(--muted); font-size: .85rem; }
#perm-note:empty { display: none; }

/* VPN в настройках */
.vpn-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.vpn-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.vpn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-left: auto; }
.vpn-actions details img { display: block; background: #fff; padding: .4rem; border-radius: 6px; margin-top: .4rem; max-width: 100%; height: auto; }
.vpn-add { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: 1.5rem; }
.vpn-add input[name=name] { flex: 1 1 14rem; min-width: 0; }
.vpn-add input[type=checkbox] { width: auto; }
.vpn-link { border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; }
.vpn-link__row { display: flex; gap: .6rem; }
.vpn-link__row input { flex: 1; min-width: 0; }
.vpn-how { margin-bottom: .6rem; }
.vpn-how summary { cursor: pointer; font-weight: 600; }
.vpn-how ol { margin: .4rem 0 .8rem; padding-left: 1.4rem; display: grid; gap: .3rem; }
.badge--dot { min-width: .6rem; height: .6rem; padding: 0; top: -.1rem; right: -.1rem; background: var(--danger); }
.security ul { padding-left: 1.2rem; }
.security .doc { max-width: 100%; overflow-x: auto; }
.restart form { display: inline-block; margin-right: .5rem; }
/* Нагрузка сервера в настройках */
.server { padding-left: 1.2rem; }
.chart { margin: .5rem 0 1rem; }
.chart svg { display: block; width: 100%; height: 8rem; background: var(--panel, #1e2128); border-radius: .4rem; }
.chart polyline { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: #ffffff1a; vector-effect: non-scaling-stroke; }
.chart .cpu { stroke: var(--accent, #6aa8ff); }
.chart .mem { stroke: #e8b44c; }
.chart .key { display: inline-block; width: .8rem; height: .2rem; vertical-align: middle; }
.chart .key.cpu { background: var(--accent, #6aa8ff); }
.chart .key.mem { background: #e8b44c; }
/* Поиск по разговорам */
.found { padding-left: 1.4rem; }
.found li { margin-bottom: .9rem; }
.found p { margin: .2rem 0 0; color: var(--muted); overflow-wrap: anywhere; }
.found mark { background: #e8b44c55; color: var(--text); border-radius: .2rem; }
/* Мой агент: кто может писать */
.people { padding-left: 1.2rem; margin: 0; }
.people li { margin: .2rem 0; }
form.inline { display: inline; margin-left: .4rem; }
.pending { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Операторская → Поиск: форма и таблица найденного (широкая — листается в своей рамке) */
.poisk-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.poisk-row input[type=search] { flex: 1; min-width: 0; width: auto; }
/* Поле и «Найти» — всегда в одну строку: при переносе кнопка наезжала на поле (Саня, 10.11.2026) */
.poisk-q-row { flex-wrap: nowrap; }
.poisk-q-row button { flex: none; }
.poisk-row label.check { display: inline-block; }
.poisk-table { overflow-x: auto; max-width: 100%; }
.poisk-table table { border-collapse: collapse; width: 100%; }
.poisk-table th, .poisk-table td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.poisk-table td.poisk-path { white-space: normal; min-width: 16rem; word-break: break-word; font-size: .85rem; color: var(--muted); }
