/* ============ Astra — стили интерфейса ============ */
:root, html[data-theme="dark"] {
  --bg: #0a0f16;
  --bg-sidebar: #0d131c;
  --panel: #101825;
  --panel-2: #131d2c;
  --border: #1c2836;
  --border-soft: #17212e;
  --text: #e8eef5;
  --muted: #8494a8;
  --muted-2: #5d6d80;
  --accent: #3f8cff;
  --accent-2: #66b2ff;
  --accent-soft: rgba(63, 140, 255, .14);
  --danger: #ff5d5d;
  --ok: #3ecf8e;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --glow: 0 0 0 1px rgba(63, 140, 255, .35), 0 0 24px rgba(63, 140, 255, .12);
}
html[data-theme="light"] {
  --bg: #f3f6fa;
  --bg-sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --border: #dce4ee;
  --border-soft: #e6ecf4;
  --text: #17212b;
  --muted: #5b6b7d;
  --muted-2: #8a99ab;
  --accent-soft: rgba(63, 140, 255, .10);
  --shadow: 0 18px 50px rgba(23, 33, 43, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #24313f; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; height: 100vh; }

/* ==================== Сайдбар ==================== */
#sidebar {
  width: 320px; min-width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  transition: margin-left .25s ease, opacity .2s;
  z-index: 30;
}
body.sb-collapsed #sidebar { margin-left: -320px; opacity: 0; pointer-events: none; }

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; }
.brand-logo svg, .hero-logo svg { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background .15s, color .15s;
  flex: none;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.win:hover { background: #2a3646; }
.icon-btn.win-close:hover { background: #e5484d; color: #fff; }

.sb-nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  font-size: 14.5px; color: var(--text); text-align: left;
  transition: background .15s;
}
.nav-btn:hover { background: var(--panel-2); }
.nav-btn.active { background: var(--accent-soft); }
.nav-ic { color: var(--muted); display: inline-flex; width: 20px; justify-content: center; }
.nav-ic svg { width: 19px; height: 19px; }
.nav-txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hotkey { font-size: 12px; color: var(--muted-2); }
.nav-new {
  background: var(--panel-2); border: 1px solid var(--border);
  margin-bottom: 8px; font-weight: 600;
}
.nav-new:hover { border-color: #2c3d52; background: #16202e; }
html[data-theme="light"] .nav-new:hover { background: #e8eef6; }

.sb-recent { flex: 1; overflow-y: auto; padding: 14px 12px 8px; min-height: 60px; }
.sb-label { font-size: 12.5px; color: var(--muted-2); padding: 0 12px 8px; }
#recent-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  color: var(--text); font-size: 14px;
}
.recent-item:hover { background: var(--panel-2); }
.recent-item.active { background: var(--accent-soft); }
.recent-ic { color: var(--muted-2); display: inline-flex; flex: none; }
.recent-ic svg { width: 16px; height: 16px; }
.recent-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { font-size: 12px; color: var(--muted-2); flex: none; }
.recent-del {
  opacity: 0; color: var(--muted); width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.recent-item:hover .recent-del { opacity: 1; }
.recent-del:hover { color: var(--danger); background: rgba(255, 93, 93, .12); }
.recent-del svg { width: 14px; height: 14px; }
.recent-empty { color: var(--muted-2); font-size: 13px; padding: 6px 12px; }

.sb-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #4f9bff, #1f62d8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff; flex: none;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 14.5px; font-weight: 600; }
.user-badge {
  display: inline-block; font-size: 11px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 6px; margin-top: 3px;
}
.foot-icons { display: flex; gap: 2px; }

/* Persistent session («Не выходить») — вторая строка футера сайдбара */
.sb-session {
  flex-basis: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 6px;
}
.stay-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted); cursor: pointer;
  user-select: none; white-space: nowrap;
}
.stay-check input { accent-color: var(--accent, #2f7ff0); cursor: pointer; margin: 0; width: 15px; height: 15px; }
.stay-check:hover { color: var(--text); }
.logout-btn {
  font-size: 12.5px; padding: 4px 10px; flex: none;
  color: var(--muted); border-color: var(--border);
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); background: rgba(255, 93, 93, .08); }

/* ==================== Основная область ==================== */
#main { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px 0 20px; z-index: 20;
}
.tb-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tb-right { display: flex; align-items: center; gap: 4px; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
.chat-title-top { font-size: 14px; color: var(--muted); max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#home-view, #chat-view { flex: 1; display: flex; flex-direction: column; overflow-y: auto; position: relative; }
#chat-view { overflow: hidden; }

/* ---------- Стартовый экран ---------- */
.hero { text-align: center; margin-top: 96px; }
.hero-logo { width: 118px; height: 118px; margin: 0 auto 26px; filter: drop-shadow(0 12px 40px rgba(63, 140, 255, .35)); }
.hero-title { font-size: 46px; font-weight: 700; letter-spacing: .5px; }
.hero-sub { color: var(--muted); font-size: 16px; margin-top: 12px; }
.hero-tags { color: var(--muted-2); font-size: 15px; margin-top: 8px; }

.input-slot { display: flex; justify-content: center; padding: 34px 24px 0; }
.input-slot-docked { padding: 10px 24px 18px; flex: none; }

/* ---------- Поле ввода ---------- */
.input-card {
  width: min(960px, 100%);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid #223650;
  border-radius: 18px;
  box-shadow: var(--glow), 0 10px 30px rgba(0, 0, 0, .25);
  padding: 14px 14px 10px;
  backdrop-filter: blur(6px);
  transition: border-color .2s, box-shadow .2s;
}
.input-card:focus-within { border-color: #35597f; box-shadow: 0 0 0 1px rgba(63,140,255,.5), 0 0 34px rgba(63,140,255,.16), 0 10px 30px rgba(0,0,0,.25); }
html[data-theme="light"] .input-card { border-color: #c8d6e8; box-shadow: 0 8px 26px rgba(23,33,43,.08); }

#prompt {
  width: 100%; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 15.5px; font-family: inherit; line-height: 1.5;
  max-height: 200px; padding: 2px 4px;
}
#prompt::placeholder { color: var(--muted-2); }

.input-toolbar { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.tb-group { display: flex; align-items: center; gap: 8px; }

.round-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s; background: transparent;
}
.round-btn:hover { color: var(--text); border-color: #31465e; background: var(--panel-2); }
.round-btn.active { color: var(--accent-2); border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 14px rgba(63,140,255,.25); }
.round-btn svg { width: 18px; height: 18px; }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 13px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 14px; color: var(--text); transition: all .15s; max-width: 260px;
}
.pill-btn:hover { border-color: #31465e; }
.pill-btn svg { width: 15px; height: 15px; color: var(--muted); }
.model-btn span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.send-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #4f9bff, #2268e0);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(47, 127, 240, .4);
  transition: all .15s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.send-btn.stop { background: #2a3646; box-shadow: none; color: #ffb4b4; }
.send-btn svg { width: 19px; height: 19px; }

/* ---------- Карточки быстрых действий ---------- */
.cards { display: flex; justify-content: center; gap: 14px; padding: 26px 24px 0; flex-wrap: wrap; }
.qcard {
  display: flex; align-items: center; gap: 12px;
  width: 228px; padding: 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  text-align: left; transition: all .18s;
}
.qcard:hover { border-color: #31465e; transform: translateY(-2px); background: var(--panel-2); }
.qcard-ic { color: var(--accent-2); display: inline-flex; flex: none; }
.qcard-ic svg { width: 22px; height: 22px; }
.qcard b { display: block; font-size: 14px; font-weight: 600; }
.qcard i { display: block; font-style: normal; font-size: 12px; color: var(--muted-2); margin-top: 3px; }

.quote-block { text-align: center; margin: auto; padding: 40px 20px 34px; }
.quote-line { width: 42px; height: 2px; background: #2a3a4e; margin: 0 auto 18px; border-radius: 2px; }
.quote { font-size: 15px; color: var(--muted); }
.quote-author { font-size: 13.5px; color: var(--muted-2); margin-top: 8px; }

/* ==================== Чат ==================== */
.messages { flex: 1; overflow-y: auto; padding: 80px 24px 12px; }
.msgs-inner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 12px; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 16px 16px 4px 16px; padding: 11px 15px;
  max-width: 78%; white-space: pre-wrap; word-break: break-word;
}
.msg-assistant { }
.msg-ava {
  width: 30px; height: 30px; flex: none; margin-top: 2px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 3px;
}
.msg-ava svg { width: 100%; height: 100%; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.msg-name { font-size: 13.5px; font-weight: 600; }
.msg-model { font-size: 11.5px; color: var(--muted-2); }
.bubble-md { line-height: 1.65; word-break: break-word; }

/* markdown */
.bubble-md p { margin: 0 0 10px; }
.bubble-md p:last-child { margin-bottom: 0; }
.bubble-md h1, .bubble-md h2, .bubble-md h3 { margin: 14px 0 8px; line-height: 1.3; }
.bubble-md h1 { font-size: 20px; } .bubble-md h2 { font-size: 17px; } .bubble-md h3 { font-size: 15.5px; }
.bubble-md ul, .bubble-md ol { margin: 4px 0 10px 22px; }
.bubble-md li { margin: 3px 0; }
.bubble-md code.inline {
  background: rgba(120, 150, 190, .14); border: 1px solid var(--border-soft);
  padding: 1px 6px; border-radius: 6px; font-size: 13px;
  font-family: "Cascadia Code", Consolas, monospace;
}
.bubble-md blockquote { border-left: 3px solid var(--accent); padding: 2px 12px; color: var(--muted); margin: 8px 0; }
.bubble-md a { color: var(--accent-2); }
.bubble-md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.codeblock { margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #0b1219; }
html[data-theme="light"] .codeblock { background: #f6f8fb; }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 13px; background: rgba(120,150,190,.07); border-bottom: 1px solid var(--border-soft);
  font-size: 12px; color: var(--muted);
}
.code-copy { font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.code-copy:hover { color: var(--text); background: var(--panel-2); }
.codeblock pre { padding: 13px 15px; overflow-x: auto; }
.codeblock code { font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; line-height: 1.55; }

.cursor-blink::after {
  content: "▍"; color: var(--accent-2); animation: blink 1s steps(1) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* инструменты */
.tool-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 9px; cursor: pointer; max-width: 100%;
}
.tool-chip:hover { border-color: #31465e; color: var(--text); }
.tool-chip .st { font-size: 12px; }
.tool-chip.denied { border-color: rgba(255, 93, 93, .4); color: #ff9c9c; }
.tool-chip .tool-name { font-weight: 600; color: var(--text); }
.tool-detail {
  display: none; margin: -4px 0 10px; padding: 10px 13px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  font-size: 12.5px; color: var(--muted); font-family: Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow-y: auto;
}
.tool-detail.open { display: block; }

.msg.error .bubble-md { color: #ff9c9c; }
.typing-dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: tdots 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes tdots { 0%, 60%, 100% { opacity: .3; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-3px);} }

/* вложения */
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 8px; color: var(--muted);
}
.attach-chip b { color: var(--text); font-weight: 500; }
.attach-chip button { color: var(--muted); display: inline-flex; }
.attach-chip button:hover { color: var(--danger); }
.attach-chip button svg { width: 12px; height: 12px; }
.att-file { font-size: 12px; color: var(--muted-2); background: var(--panel-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 6px; }

/* ==================== Выпадающие списки ==================== */
.dropdown {
  position: fixed; z-index: 200; min-width: 240px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 13px; box-shadow: var(--shadow); padding: 6px;
  animation: dpop .12s ease;
}
@keyframes dpop { from { opacity: 0; transform: translateY(-5px);} }
.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer; font-size: 14px;
}
.dd-item:hover { background: var(--panel-2); }
.dd-item .dd-ic { color: var(--muted); display: inline-flex; width: 20px; justify-content: center; }
.dd-item .dd-ic svg { width: 16px; height: 16px; }
.dd-txt { flex: 1; min-width: 0; }
.dd-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-sub { font-size: 12px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-check { color: var(--accent); visibility: hidden; display: inline-flex; }
.dd-item.active .dd-check { visibility: visible; }
.dd-check svg { width: 15px; height: 15px; }
.dd-sep { height: 1px; background: var(--border-soft); margin: 5px 8px; }
.dd-title { font-size: 11.5px; color: var(--muted-2); padding: 7px 11px 3px; text-transform: uppercase; letter-spacing: .4px; }

/* ==================== Оверлей и админ-панель ==================== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 13, .62); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 26px;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } }
.admin-panel {
  width: min(860px, 96vw); max-height: 90vh;
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.admin-head {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.admin-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.admin-shield { color: var(--accent-2); display: inline-flex; }
.admin-shield svg { width: 21px; height: 21px; }
.admin-tabs { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 11px; padding: 4px; margin: 0 auto; }
.atab { padding: 7px 16px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.atab:hover { color: var(--text); }
.atab.active { background: var(--accent-soft); color: var(--text); }
.admin-body { padding: 20px; overflow-y: auto; }

/* карточки прав */
.perm-card {
  display: flex; align-items: center; gap: 15px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 15px; padding: 17px 18px; margin-bottom: 12px;
  transition: border-color .2s;
}
.perm-card.on { border-color: rgba(63, 140, 255, .45); }
.perm-card.danger.on { border-color: rgba(255, 93, 93, .45); }
.perm-ico {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-2);
}
.perm-card.danger .perm-ico { background: rgba(255, 93, 93, .12); color: #ff8c8c; }
.perm-ico svg { width: 22px; height: 22px; }
.perm-info { flex: 1; min-width: 0; }
.perm-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.perm-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.perm-use { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; }
.perm-state { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; }
.perm-state.on { background: rgba(62, 207, 142, .14); color: var(--ok); }
.perm-state.off { background: var(--panel-2); color: var(--muted-2); }

/* тумблер */
.switch {
  position: relative; width: 48px; height: 27px; border-radius: 15px; flex: none;
  background: #263444; border: 1px solid var(--border);
  transition: background .22s, box-shadow .22s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #8b9aab; transition: transform .22s, background .22s;
}
.switch.on { background: linear-gradient(135deg, #4f9bff, #2268e0); border-color: transparent; box-shadow: 0 0 14px rgba(63,140,255,.45); }
.switch.on::after { transform: translateX(21px); background: #fff; }
.switch.danger.on { background: linear-gradient(135deg, #ff7a5c, #e5484d); box-shadow: 0 0 14px rgba(229,72,77,.45); }

.admin-section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 12px; }
.admin-hint { font-size: 12.5px; color: var(--muted-2); line-height: 1.5; margin: -4px 0 14px; }
.danger-zone { display: flex; justify-content: flex-end; margin-top: 14px; }
.ws-actions { display: flex; gap: 8px; flex-shrink: 0; align-self: center; }
.ws-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.ws-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
.ws-input:focus { outline: none; border-color: #3f8cff; }
.ws-row { display: flex; align-items: center; gap: 16px; }
.ws-check { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ws-row .btn { margin-left: auto; }
.btn {
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  transition: all .15s;
}
.btn:hover { border-color: #31465e; }
.btn.primary { background: linear-gradient(135deg, #4f9bff, #2268e0); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger-ghost { color: #ff9c9c; border-color: rgba(255, 93, 93, .35); background: transparent; }
.btn.danger-ghost:hover { background: rgba(255, 93, 93, .1); }
.btn.small { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }

/* модели */
.prov-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 15px 17px; margin-bottom: 10px;
}
.prov-head { display: flex; align-items: center; gap: 10px; }
.prov-name { font-size: 15px; font-weight: 600; flex: 1; }
.prov-badges { display: flex; gap: 6px; align-items: center; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--border-soft); color: var(--muted); }
.badge.active { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(63,140,255,.4); }
.badge.keyok { color: var(--ok); }
.prov-meta { font-size: 12.5px; color: var(--muted-2); margin-top: 6px; font-family: Consolas, monospace; overflow: hidden; text-overflow: ellipsis; }
.prov-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 12px 0; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input.mono { font-family: Consolas, monospace; font-size: 12.5px; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; }
.test-result { font-size: 12.5px; margin-top: 9px; line-height: 1.5; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: #ff9c9c; }
.models-list { max-height: 120px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.model-tag {
  font-size: 12px; font-family: Consolas, monospace; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid rgba(63,140,255,.3);
  padding: 3px 9px; border-radius: 7px; cursor: pointer;
}
.model-tag:hover { border-color: var(--accent); }

/* журнал */
.journal-row {
  display: grid; grid-template-columns: 110px 150px 1fr 30px; gap: 10px;
  padding: 9px 12px; border-radius: 10px; font-size: 13px; align-items: center;
}
.journal-row:nth-child(odd) { background: var(--panel); }
.jr-time { color: var(--muted-2); font-size: 12px; }
.jr-tool { font-weight: 600; font-size: 13px; }
.jr-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.jr-st { text-align: center; }
.jr-st.ok { color: var(--ok); }
.jr-st.deny { color: var(--danger); }
.journal-empty { color: var(--muted-2); text-align: center; padding: 26px 0; font-size: 13.5px; }

/* о системе */
.about-box { text-align: center; padding: 12px 0 4px; }
.about-box .hero-logo { width: 84px; height: 84px; margin-bottom: 14px; }
.about-box h3 { font-size: 20px; }
.about-box p { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.hotkey-list { margin-top: 16px; text-align: left; display: inline-block; }
.hotkey-list div { font-size: 13px; color: var(--muted); padding: 3px 0; display: flex; gap: 10px; align-items: center; }
.kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-size: 11.5px; font-family: Consolas, monospace; color: var(--text); }

/* ==================== Тосты ==================== */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 13px; padding: 12px 15px; min-width: 260px; max-width: 420px;
  box-shadow: var(--shadow); animation: tin .2s ease; font-size: 13.5px;
}
@keyframes tin { from { opacity: 0; transform: translateY(8px);} }
.toast .t-ic { display: inline-flex; flex: none; }
.toast .t-ic svg { width: 18px; height: 18px; }
.toast.ok .t-ic { color: var(--ok); }
.toast.err .t-ic { color: var(--danger); }
.toast.info .t-ic { color: var(--accent-2); }
.toast .t-txt { flex: 1; line-height: 1.4; }
.toast .t-act { color: var(--accent-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.toast .t-act:hover { text-decoration: underline; }

/* режим фокуса */
body.zen #sidebar { margin-left: -320px; opacity: 0; pointer-events: none; }
body.zen #quick-cards .qcard:not(.qcard-focus) { display: none; }
body.zen .quote-block { display: none; }

/* адаптив */
@media (max-width: 900px) {
  #app { height: 100dvh; }
  #sidebar { position: fixed; height: 100vh; height: 100dvh; box-shadow: var(--shadow); }
  body:not(.sb-collapsed) #sidebar { margin-left: 0; opacity: 1; pointer-events: auto; }
  body:not(.sb-collapsed)::before {
    content: ""; position: fixed; inset: 0; z-index: 25;
    background: rgba(4, 8, 13, .55); animation: fadein .15s ease;
  }
  html[data-theme="light"] body:not(.sb-collapsed)::before { background: rgba(23, 33, 43, .35); }
  .chat-title-top { max-width: calc(100vw - 180px); }
  .cards { gap: 10px; }
  .qcard { width: 46%; min-width: 160px; }
  .overlay { padding: 0; align-items: stretch; }
  .admin-panel { width: 100%; height: 100%; max-height: none; border-radius: 0; border: none; }
  .admin-head { flex-wrap: wrap; row-gap: 10px; justify-content: space-between; }
  .admin-tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .atab { flex: 1 0 auto; text-align: center; padding: 8px 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .journal-row { grid-template-columns: 1fr auto; }
  .jr-detail { grid-column: 1 / -1; white-space: normal; }
  #toasts { left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
}

/* телефон */
@media (max-width: 640px) {
  .topbar { height: 54px; padding: 0 10px 0 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 20px; height: 20px; }
  .hotkey { display: none; }
  .chat-title-top { font-size: 13px; }
  .hero { margin-top: 64px; }
  .hero-logo { width: 84px; height: 84px; margin-bottom: 18px; }
  .hero-title { font-size: 34px; }
  .hero-sub { font-size: 14.5px; margin-top: 10px; }
  .hero-tags { font-size: 13px; }
  .input-slot { padding: 22px 12px 0; }
  .input-slot-docked { padding: 8px 12px max(14px, env(safe-area-inset-bottom)); }
  .input-card { border-radius: 15px; padding: 11px 11px 8px; }
  #prompt { font-size: 16px; } /* 16px — чтобы WebView не зумил поле при фокусе */
  .round-btn { width: 40px; height: 40px; }
  .pill-btn { height: 40px; max-width: 150px; }
  .send-btn { width: 42px; height: 42px; }
  .qcard { width: 100%; }
  .quote-block { padding: 26px 16px 20px; }
  .messages { padding: 66px 12px 10px; }
  .msgs-inner { gap: 18px; }
  .msg-user .bubble { max-width: 86%; }
  .admin-body { padding: 14px; }
  .admin-title { font-size: 15px; }
  .admin-tabs { padding: 3px; }
  .atab { padding: 7px 9px; font-size: 12.5px; }
  .perm-card { padding: 14px; gap: 11px; }
  .ws-actions { flex-direction: column; align-self: stretch; justify-content: center; }
}
