/* Консоль Slothicus — минималистичная тема.

   Написана с нуля одним слоем: никаких переопределений поверх старых
   правил. Принципы те же, что у панели (hud.css):
     • один почти чёрный фон, колонки разделены тонкими линиями;
     • один акцент (лаванда) — только для активного и главного действия;
     • без градиентов, свечений, теней-полосок, эмодзи-декора и капса;
     • движение короткое и тихое.
   Раскладка повторяет Discord, чтобы руки не переучивались. */

:root {
  --bg: #08090c;
  --bg-side: #0a0b0e;
  --bg-float: #111217;
  --surface: rgba(255, 255, 255, .03);
  --surface-2: rgba(255, 255, 255, .05);
  --surface-3: rgba(255, 255, 255, .08);
  --field: rgba(0, 0, 0, .28);
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .1);
  --line-3: rgba(255, 255, 255, .16);

  --text: #dcdde3;
  --text-strong: #eeeff3;
  --text-muted: #9b9ea9;
  --text-faint: #676a75;

  --acc: #aaa3ff;
  --acc-strong: #bdb7ff;
  --acc-ink: #121025;
  --acc-soft: rgba(170, 163, 255, .1);
  --acc-line: rgba(170, 163, 255, .35);

  --green: #56c596;
  --red: #ec6a6f;
  --yellow: #d9b15f;
  --link: #b3bcff;

  /* Совместимость с именами, которые использовали старые окна. */
  --brand: var(--acc);
  --brand-2: var(--acc-strong);
  --bg-chat: var(--bg);
  --bg-rail: var(--bg-side);
  --bg-hover: var(--surface-2);
  --bg-active: var(--surface-3);
  --surface-hover: var(--surface-2);
  --text-label: var(--text-muted);
  --divider: var(--line);

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --shadow: 0 16px 40px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); letter-spacing: -.003em;
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
::selection { background: rgba(170, 163, 255, .28); }
.spacer { flex: 1; }
.only-mobile { display: none !important; }
.nav-scrim { display: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .07); border: 3px solid transparent; background-clip: padding-box; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .14); }
::-webkit-scrollbar-track { background: transparent; }
.rail::-webkit-scrollbar { display: none; }

/* ================= Базовые элементы ================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border-radius: var(--r); white-space: nowrap;
  font-size: 13px; font-weight: 500; color: var(--text-strong);
  background: var(--surface-2); border: 1px solid var(--line-2);
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-3); text-decoration: none; }
.btn:active { opacity: .85; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-brand { background: var(--acc); border-color: transparent; color: var(--acc-ink); font-weight: 600; }
.btn-brand:hover { background: var(--acc-strong); border-color: transparent; }
.btn-danger { background: transparent; border-color: rgba(236, 106, 111, .45); color: var(--red); }
.btn-danger:hover { background: rgba(236, 106, 111, .1); border-color: var(--red); }
.btn-link { background: none; border-color: transparent; color: var(--text-muted); }
.btn-link:hover { background: var(--surface-2); color: var(--text-strong); }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); flex: none;
  color: var(--text-faint); transition: color .15s, background .15s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.icon-btn.is-on { color: var(--text); background: var(--surface-3); }
.icon-btn.sm { width: 26px; height: 26px; font-size: 12px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--red); background: rgba(236, 106, 111, .1); }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }

input:focus, textarea:focus, select:focus { outline: none; }
.field label, .sf-label {
  display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.sf-label i { font-style: normal; font-weight: 400; color: var(--text-faint); margin-left: 6px; }
.sf-label em { font-style: normal; font-weight: 400; color: var(--text-faint); margin-left: 6px; }
.field input, .field textarea, .field select,
.sf input, .sf textarea, .s-field-row input, .s-color-hex,
.s-target select, .mg-select, .s-forum-target select,
.threads-search input, .members-search input, .picker-search input, .gif-url-row input, .rp-search {
  width: 100%; padding: 8px 11px; border-radius: var(--r); font-size: 13.5px; color: var(--text);
  background: var(--field); border: 1px solid var(--line-2); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus,
.sf input:focus, .sf textarea:focus, .s-field-row input:focus, .s-color-hex:focus,
.threads-search input:focus, .members-search input:focus, .picker-search input:focus, .gif-url-row input:focus, .rp-search:focus {
  border-color: var(--acc-line); box-shadow: 0 0 0 3px var(--acc-soft);
}
.field textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-float); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r); font-size: 13px;
  background: transparent; border: 1px solid var(--line-2); color: var(--text-muted); transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-on { border-color: var(--acc-line); background: var(--acc-soft); color: var(--text-strong); }
.chip-sm {
  padding: 4px 9px; border-radius: var(--r-sm); font-size: 12px; color: var(--text-muted);
  border: 1px solid var(--line-2); background: transparent; transition: background .15s, color .15s;
}
.chip-sm:hover { background: var(--surface-3); color: var(--text-strong); }

/* ================= Вход ================= */

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card {
  width: min(380px, 100%); padding: 32px 28px 26px; text-align: center; border-radius: 16px;
  background: var(--bg-side); border: 1px solid var(--line-2);
}
.login-logo { color: var(--text-muted); display: grid; place-items: center; margin-bottom: 14px; }
.login-logo svg { width: 32px; height: 32px; }
.login-card h1 { color: var(--text-strong); font-size: 18px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.02em; }
.login-card p { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }

/* ================= Каркас ================= */

.app { display: flex; height: 100vh; height: 100dvh; }

/* Серверы */
.rail {
  width: 60px; flex: none; padding: 12px 0; overflow-y: auto; background: var(--bg-side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.rail-list { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.rail-sep { width: 20px; height: 1px; background: var(--line-2); margin: 4px 0; flex: none; }
.rail-item {
  position: relative; width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--line); transition: background .15s, border-color .15s, color .15s;
}
.rail-item img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.rail-item .rail-initials { pointer-events: none; }
.rail-item:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.rail-item.is-active { background: var(--surface-3); border-color: var(--line-3); color: var(--text-strong); }
.rail-pill {
  position: absolute; left: -12px; top: 50%; width: 2px; height: 0; border-radius: 2px; transform: translateY(-50%);
  background: var(--acc); opacity: 0; transition: height .2s var(--ease), opacity .2s;
}
.rail-item.has-unread .rail-pill { height: 6px; opacity: 1; background: var(--text-strong); }
.rail-item:hover .rail-pill { height: 10px; opacity: 1; }
.rail-item.is-active .rail-pill { height: 18px; opacity: 1; background: var(--acc); }
.rail-badge {
  position: absolute; right: -5px; bottom: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; color: var(--acc-ink); background: var(--acc);
  border: 2px solid var(--bg-side); box-sizing: content-box;
}

/* Каналы */
.sidebar { width: 232px; flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--bg-side); border-right: 1px solid var(--line); }
.guild-header {
  position: relative; z-index: 2; flex: none; height: 56px; padding: 0 14px; display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--text-strong); text-align: left; border-bottom: 1px solid var(--line);
  transition: background .15s;
}
.guild-header:hover, .guild-header.is-open { background: var(--surface); }
.guild-header #guildName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-header .chev { width: 16px; height: 16px; color: var(--text-faint); transition: transform .2s var(--ease); }
.guild-header.is-open .chev { transform: rotate(180deg); }

.channels { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.cat {
  display: flex; align-items: center; gap: 4px; width: 100%; padding: 16px 6px 5px;
  font-size: 11.5px; font-weight: 500; color: var(--text-faint); transition: color .15s;
}
.cat:hover { color: var(--text-muted); }
.cat svg { flex: none; transition: transform .2s var(--ease); }
.cat.is-collapsed svg { transform: rotate(-90deg); }
.cat-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s var(--ease); }
.cat-body > div { overflow: hidden; }
.cat.is-collapsed + .cat-body { grid-template-rows: 0fr; }
.cat.is-collapsed + .cat-body .ch.is-active, .cat.is-collapsed + .cat-body .ch.is-unread { visibility: visible; }

.ch {
  position: relative; display: flex; align-items: center; gap: 7px; width: 100%; height: 32px; margin: 1px 0; padding: 0 8px;
  border-radius: var(--r); font-size: 13.5px; font-weight: 500; color: var(--text-muted); text-align: left;
  transition: background .12s, color .12s;
}
.ch:hover { background: var(--surface-2); color: var(--text); }
.ch.is-active { background: var(--surface-3); color: var(--text-strong); box-shadow: inset 2px 0 0 var(--acc); }
.ch.is-unread { color: var(--text-strong); }
.ch.is-unread::before { content: ""; position: absolute; left: -10px; top: 50%; width: 3px; height: 6px; margin-top: -3px; border-radius: 0 3px 3px 0; background: var(--text-strong); }
.ch-icon { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--text-faint); }
.ch-icon svg { width: 16px; height: 16px; }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-badge { min-width: 16px; padding: 1px 5px; border-radius: 7px; font-size: 10.5px; font-weight: 600; text-align: center; color: var(--acc-ink); background: var(--acc); }
.ch.is-locked { opacity: .5; }
.ch.thread { height: 28px; padding-left: 32px; font-size: 13px; }
.ch.thread::after { content: ""; position: absolute; left: 17px; top: -12px; width: 11px; height: 26px; border-left: 1px solid var(--line-3); border-bottom: 1px solid var(--line-3); border-bottom-left-radius: 7px; }
.thread-more { width: 100%; padding: 4px 8px 4px 32px; border-radius: var(--r); font-size: 12.5px; text-align: left; color: var(--text-faint); }
.thread-more:hover { background: var(--surface-2); color: var(--text); }
.voice-users { padding: 0 0 4px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: var(--r); font-size: 13px; color: var(--text-muted); cursor: pointer; }
.voice-user:hover { background: var(--surface-2); color: var(--text); }
.voice-user img { width: 22px; height: 22px; border-radius: 50%; }
.voice-user .vflags { margin-left: auto; font-size: 11px; opacity: .7; }

.userbar { flex: none; height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-top: 1px solid var(--line); }
.avatar-wrap { position: relative; flex: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg-side); box-sizing: content-box; }
.userbar-names { flex: 1; min-width: 0; line-height: 1.25; }
.userbar-name { font-size: 13px; font-weight: 500; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar-sub { font-size: 11.5px; color: var(--text-faint); }

/* ================= Чат ================= */

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-header {
  position: relative; z-index: 2; flex: none; height: 56px; padding: 0 12px 0 20px; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--line);
}
.chat-hash { display: grid; place-items: center; font-size: 17px; color: var(--text-faint); }
.chat-hash svg { width: 18px; height: 18px; }
.chat-title { margin: 0; max-width: 40%; font-size: 14.5px; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topic { min-width: 0; flex: 0 1 auto; margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line-2); font-size: 12.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topic:empty { display: none; }
.crumb { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 13px; }
.crumb-parent { display: inline-flex; align-items: center; gap: 4px; color: var(--text-faint); white-space: nowrap; transition: color .15s; }
.crumb-parent:hover { color: var(--text); }
.crumb-sep { color: var(--text-faint); flex: none; }
.chat-body { flex: 1; min-height: 0; display: flex; }
.chat-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.messages-scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overflow-anchor: none; }
.messages { min-height: 100%; padding: 16px 0 20px; display: flex; flex-direction: column; justify-content: flex-end; }
.messages.is-switching { animation: fade-in .2s var(--ease); }
.channel-welcome { padding: 24px 20px 12px; }
.channel-welcome .big-hash { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--line); }
.channel-welcome h2 { margin: 12px 0 4px; font-size: 20px; font-weight: 600; color: var(--text-strong); letter-spacing: -.02em; }
.channel-welcome p { margin: 0; font-size: 13px; color: var(--text-faint); }
.load-more { align-self: center; margin: 8px; padding: 4px 10px; border-radius: var(--r); font-size: 12.5px; color: var(--link); }
.load-more:hover { background: var(--surface-2); }
.day-divider { display: flex; align-items: center; gap: 8px; margin: 22px 20px 8px; font-size: 11.5px; color: var(--text-faint); }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Сообщение */
.msg { position: relative; min-height: 22px; padding: 2px 48px 2px 72px; transition: background-color .1s; }
.msg.head { margin-top: 14px; min-height: 42px; }
.msg:hover, .msg.menu-open, .msg.editing { background: rgba(255, 255, 255, .018); }
.msg.is-new { animation: msg-in .3s var(--ease); }
.msg.is-sending { opacity: .5; }
.msg.is-failed .msg-content { color: var(--red); }
.msg.is-deleting { animation: msg-out .25s ease forwards; }
.msg.is-highlight { animation: highlight 1.6s ease; }
.msg.mentioned { background: rgba(170, 163, 255, .05); }
.msg.mentioned::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--acc); }
.msg-avatar { position: absolute; left: 20px; top: 4px; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; cursor: pointer; background: var(--surface-3); }
.msg-time-side { position: absolute; left: 0; top: 3px; width: 72px; text-align: center; font-size: 10.5px; line-height: 22px; color: var(--text-faint); opacity: 0; }
.msg:hover .msg-time-side { opacity: 1; }
.msg-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; line-height: 22px; }
.msg-author { font-size: 14px; font-weight: 600; color: var(--text-strong); cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.bot-tag {
  position: relative; top: -1px; display: inline-flex; align-items: center; gap: 2px; height: 16px; padding: 0 5px; border-radius: 4px;
  font-size: 10px; font-weight: 500; color: var(--acc-strong); background: var(--acc-soft);
}
.msg-time { font-size: 11.5px; color: var(--text-faint); }
.msg-content { user-select: text; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.5; color: var(--text); }
.msg-content.jumbo img.emoji { width: 44px; height: 44px; }
.msg-content.jumbo .uemoji { font-size: 40px; line-height: 1.2; }
.edited { margin-left: 3px; font-size: 10px; color: var(--text-faint); user-select: none; }
.msg-reply {
  position: relative; display: flex; align-items: center; gap: 5px; min-width: 0; margin: 0 0 4px -52px; padding-left: 52px;
  font-size: 13px; line-height: 18px; color: var(--text-faint); cursor: pointer;
}
.msg-reply::before { content: ""; position: absolute; left: 36px; top: 9px; width: 30px; height: 12px; border-left: 1px solid var(--line-3); border-top: 1px solid var(--line-3); border-top-left-radius: 6px; }
.msg-reply img { width: 16px; height: 16px; border-radius: 50%; }
.msg-reply b { flex: none; font-weight: 500; color: var(--text-muted); }
.msg-reply .reply-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-reply:hover .reply-text { color: var(--text); }
.msg-system { display: flex; align-items: center; gap: 8px; color: var(--text-faint); }
.msg-system .sys-icon { position: absolute; left: 30px; top: 6px; color: var(--green); }

.msg-actions {
  position: absolute; right: 16px; top: -16px; z-index: 1; display: flex; padding: 2px; border-radius: var(--r);
  background: var(--bg-float); border: 1px solid var(--line-2);
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.msg:hover .msg-actions, .msg.menu-open .msg-actions { opacity: 1; pointer-events: auto; }
.msg-actions button { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--text-faint); }
.msg-actions button:hover { color: var(--text); background: var(--surface-3); }
.msg-actions button.danger:hover { color: var(--red); }

/* Разметка текста */
.mention { padding: 0 3px; border-radius: 4px; font-weight: 500; color: var(--acc-strong); background: var(--acc-soft); cursor: pointer; }
.mention:hover { background: rgba(170, 163, 255, .2); }
.mention.role { color: var(--rc, var(--acc-strong)); background: color-mix(in srgb, var(--rc, var(--acc)) 14%, transparent); }
code.inline { padding: .1em .3em; border-radius: 4px; font: .85em/1.1 var(--mono); background: var(--field); border: 1px solid var(--line); }
pre.code { max-width: 90%; margin: 4px 0 0; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; border-radius: var(--r); font: 12.5px/1.55 var(--mono); background: var(--field); border: 1px solid var(--line); }
blockquote { margin: 0; padding: 0 8px 0 12px; border-left: 2px solid var(--line-3); }
.md-h1, .md-h2, .md-h3 { display: block; margin: 8px 0 0; font-weight: 600; color: var(--text-strong); letter-spacing: -.02em; }
.md-h1 { font-size: 20px; } .md-h2 { font-size: 17px; } .md-h3 { font-size: 15px; }
.md-sub { display: block; font-size: 12.5px; color: var(--text-faint); }
.md-li { position: relative; display: block; padding-left: 16px; }
.md-li::before { content: "•"; position: absolute; left: 4px; color: var(--text-faint); }
.spoiler { border-radius: 4px; color: transparent; background: var(--surface-3); cursor: pointer; transition: background .15s, color .15s; }
.spoiler * { visibility: hidden; }
.spoiler.shown { color: inherit; background: var(--surface-2); }
.spoiler.shown * { visibility: visible; }
img.emoji { display: inline-block; width: 22px; height: 22px; margin: 0 1px; vertical-align: bottom; object-fit: contain; }
.timestamp { padding: 0 3px; border-radius: 4px; background: var(--surface-2); }

/* Вложения */
.attachments { display: flex; flex-wrap: wrap; gap: 4px; max-width: 550px; margin-top: 4px; }
.att-media { position: relative; max-width: 100%; overflow: hidden; border-radius: var(--r-lg); cursor: zoom-in; background: var(--surface); border: 1px solid var(--line); }
.att-media img, .att-media video { display: block; width: auto; height: auto; max-width: 400px; max-height: 350px; }
.att-media.is-spoiler img, .att-media.is-spoiler video { filter: blur(40px); transition: filter .3s; }
.att-media.is-spoiler::after { content: "Спойлер"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 5px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 500; color: #fff; background: rgba(0, 0, 0, .6); }
.att-media.is-spoiler.shown img, .att-media.is-spoiler.shown video { filter: none; }
.att-media.is-spoiler.shown::after { display: none; }
.att-file { display: flex; align-items: center; gap: 12px; width: min(420px, 100%); padding: 10px 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.att-file .file-ic { flex: none; font-size: 24px; opacity: .7; }
.att-file .file-meta { flex: 1; min-width: 0; }
.att-file .file-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-file .file-size { font-size: 12px; color: var(--text-faint); }
.att-file audio { width: 100%; height: 32px; margin-top: 6px; }
.stickers img { width: 150px; height: 150px; object-fit: contain; }

/* Эмбеды и компоненты бота */
.embed {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; max-width: 520px; margin-top: 4px; padding: 10px 14px 14px;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--ec, var(--line-3));
}
.embed > * { grid-column: 1; min-width: 0; }
.embed-author { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.embed-author img { width: 22px; height: 22px; border-radius: 50%; }
.embed-title { margin-top: 4px; font-weight: 600; color: var(--text-strong); }
.embed-desc { font-size: 13.5px; white-space: pre-wrap; }
.embed-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.embed-field { grid-column: 1 / -1; font-size: 13.5px; }
.embed-field.inline { grid-column: auto; }
.embed-field b { display: block; margin-bottom: 2px; font-weight: 600; color: var(--text-strong); }
.embed-thumb { grid-column: 2; grid-row: 1 / 8; margin-top: 6px; }
.embed-thumb img { max-width: 80px; max-height: 80px; border-radius: var(--r-sm); }
.embed-image img, .embed-image video { max-width: 100%; max-height: 300px; border-radius: var(--r-sm); cursor: zoom-in; }
.embed-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); }
.embed-footer img { width: 18px; height: 18px; border-radius: 50%; }
.embed-provider { margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.gifv { position: relative; max-width: 400px; margin-top: 4px; overflow: hidden; border-radius: var(--r-lg); }
.gifv video, .gifv img { display: block; max-width: 100%; max-height: 300px; }
.gifv::after { content: "GIF"; position: absolute; left: 6px; top: 6px; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); }

.cv2-container {
  max-width: 620px; margin-top: 4px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); border-left: 2px solid var(--ac, var(--line-3));
}
.cv2-text { white-space: pre-wrap; word-wrap: break-word; }
.cv2-sep { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.cv2-sep.invisible { border-color: transparent; }
.cv2-sep.large { margin: 10px 0; }
.cv2-section { display: flex; align-items: flex-start; gap: 12px; }
.cv2-section > .cv2-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cv2-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; }
.cv2-gallery img, .cv2-gallery video { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--r-sm); cursor: zoom-in; }
.cv2-thumb img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--r); }
.cv2-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cv2-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border-radius: var(--r); font-size: 13px; font-weight: 500; color: #fff; background: #4e5058; cursor: default; }
.cv2-btn.primary { background: #5865f2; }
.cv2-btn.success { background: #248046; }
.cv2-btn.danger { background: #da373c; }
.cv2-btn.link { cursor: pointer; }
.cv2-btn[disabled] { opacity: .5; }
.cv2-select { display: flex; align-items: center; height: 38px; min-width: min(340px, 100%); padding: 0 12px; border-radius: var(--r); font-size: 13.5px; color: var(--text-faint); background: var(--field); border: 1px solid var(--line-2); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 7px; border-radius: 99px; font-size: 12.5px; font-weight: 500; color: var(--text-muted); background: var(--surface); border: 1px solid var(--line); transition: background .12s, border-color .12s; }
.reaction:hover { background: var(--surface-2); border-color: var(--line-3); }
.reaction.me { background: var(--acc-soft); border-color: var(--acc-line); color: var(--acc-strong); }
.reaction img { width: 16px; height: 16px; }
.reaction .r-emoji { font-size: 15px; line-height: 1; }

.msg-thread {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin-top: 6px; padding: 5px 12px 5px 8px;
  border-radius: var(--r); font-size: 13px; cursor: pointer; background: var(--surface); border: 1px solid var(--line); transition: background .15s, border-color .15s;
}
.msg-thread:hover { background: var(--surface-2); border-color: var(--line-3); }
.msg-thread .mt-icon { flex: none; display: grid; place-items: center; color: var(--text-faint); }
.msg-thread .mt-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread .mt-count { flex: none; font-size: 12px; font-weight: 500; color: var(--acc); }
.msg-thread .mt-go { flex: none; font-size: 12px; color: var(--text-faint); }

/* Поле ввода */
.composer { position: relative; flex: none; margin: 0 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-2); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--acc-line); box-shadow: 0 0 0 3px var(--acc-soft); }
.composer.is-disabled { opacity: .5; pointer-events: none; }
.composer-row { display: flex; align-items: flex-start; min-height: 44px; padding-right: 6px; }
.composer-btn { flex: none; width: 38px; height: 44px; display: grid; place-items: center; color: var(--text-faint); transition: color .15s; }
.composer-btn svg { width: 20px; height: 20px; }
.composer-btn:hover { color: var(--text); }
.composer-btn:first-child { width: 48px; }
.send-btn { color: var(--text-faint); }
.composer.can-send .send-btn { color: var(--acc); }
#input { flex: 1; min-width: 0; max-height: 50vh; padding: 12px 0; border: 0; outline: none; resize: none; background: none; font-size: 14.5px; line-height: 20px; color: var(--text); }
#input::placeholder { color: var(--text-faint); }
.reply-bar { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 14px; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid var(--line); }
.reply-bar b { font-weight: 600; color: var(--text); }
.reply-ping { padding: 2px 6px; border-radius: 4px; font-size: 11.5px; font-weight: 600; color: var(--text-faint); }
.reply-ping.is-on { color: var(--acc); }
.upload-tray { display: flex; gap: 16px; padding: 16px 10px 10px 14px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.upload-item { position: relative; flex: none; width: 200px; padding: 8px; display: flex; flex-direction: column; gap: 6px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.upload-item.leaving { animation: fade-out .2s ease forwards; }
.upload-preview { height: 150px; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-sm); font-size: 48px; background: var(--field); }
.upload-preview img, .upload-preview video { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-item.is-spoiler .upload-preview img, .upload-item.is-spoiler .upload-preview video { filter: blur(20px); }
.upload-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-size { font-size: 11.5px; color: var(--text-faint); }
.upload-size.too-big { color: var(--red); font-weight: 600; }
.upload-tools { position: absolute; top: -10px; right: -10px; display: flex; overflow: hidden; border-radius: var(--r); background: var(--bg-float); border: 1px solid var(--line-2); }
.upload-tools button { width: 28px; height: 28px; display: grid; place-items: center; color: var(--text-faint); }
.upload-tools button:hover { background: var(--surface-3); color: var(--text); }
.upload-tools button.danger:hover { color: var(--red); }
.upload-tools button.is-on { color: var(--acc); }
.composer-foot { flex: none; height: 26px; display: flex; align-items: center; padding: 0 22px; font-size: 12px; }
.typing { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing b { font-weight: 600; }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 2px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
.counter { font-size: 11.5px; color: var(--text-faint); }
.counter.over { color: var(--red); font-weight: 600; }

.jump-bar { position: absolute; left: 20px; right: 20px; bottom: 84px; z-index: 3; height: 30px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border-radius: var(--r); font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--bg-float); border: 1px solid var(--line-2); animation: slide-up .2s var(--ease); }
.jump-bar:hover { border-color: var(--line-3); }

.autocomplete { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); max-height: 320px; overflow-y: auto; padding: 6px; border-radius: var(--r-lg); background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: slide-up .15s var(--ease); }
.ac-title { padding: 4px 8px 6px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.ac-item img { width: 22px; height: 22px; border-radius: 50%; }
.ac-item .ac-sub { margin-left: auto; font-size: 12px; color: var(--text-faint); }
.ac-item.is-sel { background: var(--surface-3); }

.empty-state { position: absolute; inset: 0; z-index: 4; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: var(--bg); }
.empty-state .empty-art { display: none; }
.empty-state h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; color: var(--text-strong); }
.empty-state p { max-width: 420px; margin: 0; font-size: 13px; color: var(--text-faint); }

.skeleton { position: relative; padding: 16px 16px 0 72px; }
.skeleton::before { content: ""; position: absolute; left: 20px; top: 16px; width: 36px; height: 36px; border-radius: 50%; }
.skeleton::before, .skeleton span { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-3) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton span { display: block; height: 12px; margin: 6px 0; border-radius: 6px; }

/* ================= Участники и ветки ================= */

.members { width: 232px; flex: none; overflow-y: auto; padding: 0 10px 20px; background: var(--bg-side); border-left: 1px solid var(--line); transition: width .2s var(--ease), padding .2s var(--ease); }
.members.is-hidden { width: 0; padding: 0; overflow: hidden; border-left: 0; }
.members-search { position: sticky; top: 0; z-index: 1; padding: 12px 0 6px; background: var(--bg-side); }
.members-search input { height: 32px; padding: 0 10px; font-size: 13px; }
.m-group { padding: 18px 8px 4px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.m-item { width: 100%; height: 38px; padding: 0 8px; display: flex; align-items: center; gap: 10px; border-radius: var(--r); text-align: left; color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s; }
.m-item:hover, .m-item.is-open { background: var(--surface-2); color: var(--text); }
.m-item .avatar { width: 28px; height: 28px; }
.m-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-flags { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.m-item.is-timeout .m-name { opacity: .55; }
.m-more { padding: 8px; font-size: 12.5px; text-align: center; color: var(--text-faint); }

.threads { width: 320px; flex: none; display: flex; flex-direction: column; background: var(--bg-side); border-left: 1px solid var(--line); animation: panel-in .2s var(--ease); }
.threads-head { flex: none; height: 56px; padding: 0 8px 0 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.threads-head b { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.threads-search { padding: 12px 12px 8px; }
.threads-search input { height: 32px; padding: 0 10px; font-size: 13px; }
.threads-body { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.thread-card { display: block; width: 100%; margin-bottom: 6px; padding: 10px 12px; text-align: left; cursor: pointer; border-radius: var(--r-lg); background: transparent; border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.thread-card:hover { background: var(--surface); border-color: var(--line-3); }
.thread-card.is-active { background: var(--acc-soft); border-color: var(--acc-line); }
.thread-card .tc-name { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.thread-card .tc-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-card .tc-preview { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-card .tc-preview img { flex: none; width: 16px; height: 16px; border-radius: 50%; }
.thread-card .tc-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.tc-tag { padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 500; background: var(--surface-2); }
.tc-tag.archived { color: var(--text-faint); }
.tc-tag.live { color: var(--green); }
.threads-more { width: 100%; padding: 8px; border-radius: var(--r); font-size: 12.5px; color: var(--text-faint); }
.threads-more:hover { background: var(--surface-2); color: var(--text); }

/* ================= Всплывающие слои ================= */

.layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.layer > * { pointer-events: auto; }

.popout, .menu, .picker, .tooltip { background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); }

.popout { position: fixed; width: 320px; max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden; border-radius: 14px; animation: pop-in .18s var(--ease); transform-origin: var(--origin, left top); }
.pop-banner { height: 56px; background: var(--banner, var(--surface-3)); opacity: .45; }
.pop-avatar-wrap { position: absolute; left: 16px; top: 16px; border: 5px solid var(--bg-float); border-radius: 50%; background: var(--bg-float); }
.pop-avatar-wrap img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.pop-body { margin: 46px 14px 14px; padding: 12px; display: flex; flex-direction: column; gap: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.pop-name { font-size: 17px; font-weight: 600; line-height: 1.2; color: var(--text-strong); word-break: break-word; }
.pop-tag { font-size: 13px; color: var(--text-muted); }
.pop-hr { height: 1px; margin: 0; border: 0; background: var(--line); }
.pop-label { margin-bottom: 6px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.pop-text { font-size: 13px; color: var(--text); }
.pop-alert { padding: 6px 8px; border-radius: var(--r-sm); font-size: 12.5px; color: var(--yellow); background: rgba(217, 177, 95, .1); }
.roles { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px 0 6px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; color: var(--text); border: 1px solid var(--line-2); }
.role-chip .dot { width: 9px; height: 9px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; color: transparent; background: var(--rc, var(--text-faint)); }
.role-chip.removable { cursor: pointer; }
.role-chip.removable:hover .dot { color: #000; }
.role-add { width: 22px; height: 22px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--text-faint); border: 1px solid var(--line-2); }
.role-add:hover { color: var(--text); }
.pop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pop-actions .btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.pop-actions .full { grid-column: 1 / -1; }
.note-input { width: 100%; padding: 4px; border: 0; border-radius: 4px; outline: none; font-size: 12.5px; color: var(--text); background: transparent; }
.note-input:focus { background: var(--field); }

.menu { position: fixed; min-width: 190px; max-width: 320px; max-height: calc(100vh - 16px); overflow-y: auto; padding: 5px; border-radius: 12px; animation: pop-in .14s var(--ease); transform-origin: var(--origin, left top); }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 30px; padding: 5px 8px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; text-align: left; color: var(--text-muted); }
.menu-item:hover { background: var(--surface-3); color: var(--text-strong); }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: rgba(236, 106, 111, .12); color: var(--red); }
.menu-item .mi-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--rc, var(--text-faint)); }
.menu-item .mi-check { flex: none; width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; font-size: 11px; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.menu-head { padding: 10px 8px 4px; font-size: 11px; font-weight: 500; color: var(--text-faint); }
.menu-head:first-child { padding-top: 4px; }
.menu-rich { justify-content: flex-start; gap: 10px; padding: 6px 8px; }
.menu-rich .mi-ic { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r); color: var(--text-faint); border: 1px solid var(--line); transition: color .15s; }
.menu-rich:hover .mi-ic { color: var(--acc); }
.menu-rich .mi-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.menu-rich .mi-label { font-size: 13px; color: var(--text); }
.menu-rich .mi-hint { font-size: 11.5px; font-weight: 400; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-foot { margin-top: 4px; padding: 8px 8px 3px; border-top: 1px solid var(--line); font: 500 10.5px/1 var(--mono); color: var(--text-faint); }
.menu-reacts { display: flex; gap: 4px; padding: 2px 0 6px; }
.menu-reacts button { width: 34px; height: 34px; border-radius: 50%; font-size: 18px; border: 1px solid var(--line); }
.menu-reacts button:hover { background: var(--surface-3); }

.tooltip { position: fixed; z-index: 200; padding: 5px 9px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; color: var(--text-strong); white-space: nowrap; pointer-events: none; animation: fade-in .1s ease; }

.backdrop { position: fixed; inset: 0; padding: 16px; display: grid; place-items: center; background: rgba(0, 0, 0, .6); animation: fade-in .15s ease; }
.backdrop.leaving { animation: fade-out .15s ease forwards; }
.backdrop.leaving .modal { animation: fade-out .15s ease forwards; }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: modal-in .22s var(--ease); }
.modal.wide { width: min(640px, 100%); }
.modal-head { padding: 18px 18px 0; }
.modal-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; }
.modal-head p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.preview-msg { padding: 8px 0; border-radius: var(--r); pointer-events: none; border: 1px solid var(--line); }
.preview-msg .msg { padding-right: 16px; }
.preview-msg .msg-actions { display: none; }
.ban-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r); }
.ban-row:hover { background: var(--surface-2); }
.ban-row img { width: 30px; height: 30px; border-radius: 50%; }
.ban-row .ban-meta { flex: 1; min-width: 0; }
.ban-row .ban-reason { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.picker { position: fixed; width: 400px; height: 420px; max-width: calc(100vw - 16px); max-height: calc(100vh - 80px); display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; animation: pop-in .18s var(--ease); transform-origin: right bottom; }
.picker-tabs { display: flex; gap: 4px; padding: 10px 10px 0; }
.picker-tabs button { padding: 5px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--text-faint); }
.picker-tabs button:hover { color: var(--text); background: var(--surface-2); }
.picker-tabs button.is-on { color: var(--text-strong); background: var(--surface-3); }
.picker-search { padding: 10px; }
.picker-search input { height: 32px; padding: 0 10px; font-size: 13px; }
.picker-body { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.picker-cat { padding: 8px 0 4px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.emoji-grid button { height: 38px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 24px; transition: background .1s; }
.emoji-grid button:hover { background: var(--surface-3); }
.emoji-grid img { width: 28px; height: 28px; object-fit: contain; }
.gif-grid { columns: 2; column-gap: 6px; }
.gif-grid button { position: relative; display: block; width: 100%; margin-bottom: 6px; overflow: hidden; break-inside: avoid; border-radius: var(--r); background: var(--field); }
.gif-grid button:hover { outline: 2px solid var(--acc); }
.gif-grid img { width: 100%; height: auto; }
.gif-note { padding: 8px 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.gif-url-row { display: flex; gap: 6px; }
.gif-url-row input { flex: 1; height: 34px; padding: 0 10px; }

.lightbox { position: fixed; inset: 0; padding: 32px; display: grid; place-items: center; cursor: zoom-out; background: rgba(0, 0, 0, .9); animation: fade-in .2s ease; }
.lightbox img, .lightbox video { max-width: 90vw; max-height: 82vh; border-radius: var(--r); cursor: default; }
.lightbox a { position: absolute; bottom: 24px; font-size: 13px; color: #fff; opacity: .7; }

.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(520px, calc(100vw - 32px)); padding: 10px 14px; border-radius: var(--r-lg); font-size: 13px; color: var(--text); background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: toast-in .25s var(--ease); }
.toast::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.toast.ok::before { background: var(--green); }
.toast.err::before { background: var(--red); }
.toast.leaving { animation: toast-out .2s ease forwards; }

.dropzone { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(0, 0, 0, .65); animation: fade-in .15s ease; }
.dropzone-card { width: 320px; padding: 28px 20px; text-align: center; border-radius: 16px; color: var(--text); background: var(--bg-float); border: 1px dashed var(--acc-line); }
.dropzone-icons { display: none; }
.dropzone-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.dropzone-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ================= Окна-конструкторы ================= */

.studio-backdrop { padding: 0; }
.studio {
  position: relative; width: min(1240px, 100vw); height: min(92vh, 100dvh); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 14px; background: var(--bg); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: modal-in .22s var(--ease);
}
.studio-head { flex: none; height: 56px; padding: 0 12px 0 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.studio-title { font-size: 14px; font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.mg-head-title { display: flex; flex-direction: column; line-height: 1.2; }
.mg-head-title small { font-size: 11.5px; font-weight: 400; color: var(--text-faint); }
.studio-tabs, .mg-tabs, .au-groups { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); }
.studio-tabs button, .mg-tabs button, .au-groups button { height: 26px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-faint); transition: background .15s, color .15s; }
.studio-tabs button:hover, .mg-tabs button:hover, .au-groups button:hover { color: var(--text); }
.studio-tabs button.is-on, .mg-tabs button.is-on, .au-groups button.is-on { color: var(--text-strong); background: var(--surface-3); }
.studio-body { flex: 1; min-height: 0; display: flex; }
.studio-col { flex: 1; min-width: 0; overflow-y: auto; padding: 18px; }
.studio-edit { flex: 0 0 55%; border-right: 1px solid var(--line); }
.studio-prev { display: flex; flex-direction: column; padding: 0; background: var(--bg-side); }
.studio-prev-head { flex: none; padding: 10px 16px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); border-bottom: 1px solid var(--line); }
.studio-preview { flex: 1; overflow-y: auto; padding: 12px 0; background: var(--bg); }
.studio-preview .msg:hover { background: none; }
.studio-preview-inner { pointer-events: none; }
.studio-prev-empty { padding: 40px 20px; text-align: center; font-size: 13px; color: var(--text-faint); }
.studio-foot { flex: none; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.studio.is-drop .s-drop { border-color: var(--acc); background: var(--acc-soft); }
.studio.is-drop::after { content: "Отпустите — файлы добавятся"; position: absolute; inset: auto 0 0; padding: 10px; text-align: center; font-size: 13px; font-weight: 500; color: var(--acc-ink); background: var(--acc); }
.studio-scroll-view { display: block; overflow-y: auto; padding: 20px; }
.studio-saved-view { display: block; overflow-y: auto; padding: 18px; }

.s-target, .s-forum-target { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-faint); }
.s-target { margin-left: auto; }
.s-target select, .mg-select { width: auto; min-width: 190px; max-width: 320px; height: 32px; padding: 0 10px; }
.s-forum-target select { width: auto; min-width: 150px; max-width: 280px; height: 32px; padding: 0 10px; }
.s-editing { font-size: 12.5px; color: var(--yellow); }

.sf { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.sf textarea { resize: vertical; line-height: 1.5; }
.s-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.s-check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.s-check.sm { margin: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.s-check input, .fam-toggle input, .rp-sim-opt input { width: 15px; height: 15px; accent-color: var(--acc); }
.s-hint { font-size: 12px; color: var(--text-faint); }
.s-note { margin: 0 0 12px; padding: 8px 10px; border-radius: var(--r); font-size: 12.5px; color: var(--text-faint); border: 1px solid var(--line); }
.s-note code { padding: 1px 5px; border-radius: 4px; font-size: 12px; background: var(--field); }

.s-block, .s-card, .rp-section, .fam-q { margin-bottom: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.s-block { overflow: hidden; }
.s-block > summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; list-style: none; cursor: pointer; user-select: none; font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.s-block > summary::-webkit-details-marker { display: none; }
.s-block > summary:hover { background: var(--surface); }
.s-block[open] > summary { border-bottom: 1px solid var(--line); }
.s-block > *:not(summary) { margin-left: 12px; margin-right: 12px; }
.s-block > summary + * { margin-top: 12px; }
.s-block > *:last-child { margin-bottom: 12px; }
.s-dot { flex: none; width: 9px; height: 9px; border-radius: 3px; }
.s-card, .rp-section, .fam-q { padding: 14px; }
.s-card-head, .rp-section-head, .fam-q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.s-card-head b, .rp-section-head b, .fam-q-head b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.s-card-ico, .s-kind-ico, .rp-card-ico, .rp-intro-art, .s-drop-ico { display: none; }

.s-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.s-color { width: 24px; height: 24px; border-radius: 7px; border: 0; transition: box-shadow .15s; }
.s-color.is-on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text-strong); }
.s-color-hex { width: 100px; height: 30px; padding: 0 8px; font-size: 12.5px; }
.s-field-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.s-fields { margin-top: 8px; }
.s-btn-row { margin-bottom: 10px; padding: 10px; border-radius: var(--r); border: 1px solid var(--line); }
.s-btn-row-head { display: flex; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--text-faint); }
.s-attach-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.s-uploads { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.s-upload { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); border: 1px solid var(--line); }
.s-upload-prev { flex: none; width: 44px; height: 44px; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-sm); font-size: 20px; background: var(--field); }
.s-upload-prev img, .s-upload-prev video { width: 100%; height: 100%; object-fit: cover; }
.s-upload-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.s-upload-meta span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-upload-meta i { font-style: normal; font-size: 11px; color: var(--text-faint); }
.s-upload .chip-sm { flex: none; }
.s-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 12px; text-align: center; cursor: pointer; border-radius: var(--r-lg); border: 1px dashed var(--line-3); transition: border-color .15s, background .15s; }
.s-drop:hover { border-color: var(--acc-line); background: var(--surface); }
.s-drop b { font-size: 13.5px; color: var(--text-strong); }
.s-drop .btn { margin-top: 6px; }
.s-ping { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }
.s-ping i { font-style: normal; color: var(--text-faint); }
.s-more { margin-top: 4px; }
.s-more > summary { padding: 6px 0; list-style: none; cursor: pointer; user-select: none; font-size: 12.5px; color: var(--text-faint); }
.s-more > summary::-webkit-details-marker { display: none; }
.s-more > summary::before { content: "› "; }
.s-more[open] > summary::before { content: "⌄ "; }
.s-more > summary:hover { color: var(--text); }
.s-more[open] > summary { margin-bottom: 8px; }

.s-toolbar { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 2px; }
.s-toolbar button { min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; color: var(--text-faint); transition: background .12s, color .12s; }
.s-toolbar button:hover { color: var(--text-strong); background: var(--surface-3); }
.s-toolbar-sep { width: 1px; margin: 5px 4px; background: var(--line-2); }

.s-kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.s-kind { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; text-align: center; border-radius: var(--r-lg); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.s-kind:hover { background: var(--surface); }
.s-kind.is-on { background: var(--acc-soft); border-color: var(--acc-line); }
.s-kind-name { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.s-kind-good { font-size: 11.5px; color: var(--text-faint); }
.s-kind-about { margin: 0 0 16px; padding: 10px 12px; border-radius: var(--r); font-size: 12.5px; line-height: 1.5; color: var(--text-muted); border: 1px solid var(--line); }
.s-kind-about b { color: var(--text); }

.s-h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.s-h3:not(:first-child) { margin-top: 26px; }
.s-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.s-example { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; text-align: left; border-radius: var(--r-lg); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.s-example:hover { background: var(--surface); border-color: var(--line-3); }
.s-example b { font-size: 13.5px; color: var(--text-strong); }
.s-example span { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.s-anatomy { display: flex; flex-direction: column; gap: 1px; overflow: hidden; border-radius: var(--r-lg); background: var(--line); border: 1px solid var(--line); }
.s-anatomy-row { display: grid; grid-template-columns: 160px 1fr; gap: 14px; padding: 10px 14px; font-size: 12.5px; background: var(--bg); }
.s-anatomy-row b { color: var(--text-strong); font-weight: 500; }
.s-anatomy-row span { line-height: 1.5; color: var(--text-muted); }
.s-steps { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: var(--text-muted); }
.s-steps li { margin-bottom: 2px; }

.studio-saved, .studio-saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.s-saved { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.s-saved-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.s-saved-meta b { font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-saved-meta i { font-style: normal; font-size: 12px; color: var(--text-faint); }

/* Управление сервером */
.mg-body-wrap { display: block; overflow-y: auto; }
.mg-body { max-width: 980px; margin: 0 auto; padding: 20px 24px; }
.mg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.mg-group { display: flex; flex-direction: column; gap: 2px; }
.mg-cat { margin-bottom: 18px; }
.mg-cat-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 6px; font-size: 11.5px; color: var(--text-faint); }
.mg-cat-head b { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.mg-ch { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r); border: 1px solid transparent; transition: background .12s, border-color .12s; }
.mg-ch:hover { background: var(--surface); border-color: var(--line); }
.mg-ch-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg-ch-type { font-size: 11px; color: var(--text-faint); }
.mg-role-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.mg-ch .btn-sm, .mg-cat-head .btn-sm { min-height: 26px; background: transparent; }
@media (hover: hover) {
  .mg-ch .btn, .mg-ch .icon-btn, .mg-cat-head .btn, .mg-cat-head .icon-btn { opacity: 0; transition: opacity .15s; }
  .mg-ch:hover .btn, .mg-ch:hover .icon-btn, .mg-cat-head:hover .btn, .mg-cat-head:hover .icon-btn,
  .mg-ch :focus-visible, .mg-cat-head :focus-visible { opacity: 1; }
}
.mg-matrix-wrap { max-height: calc(92vh - 200px); overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--line); }
.mg-matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.mg-matrix th, .mg-matrix td { padding: 7px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.mg-matrix thead th { position: sticky; top: 0; z-index: 2; font-weight: 500; color: var(--text-strong); background: var(--bg-float); }
.mg-sticky { position: sticky; left: 0; z-index: 1; min-width: 220px; text-align: left !important; background: var(--bg); }
.mg-matrix thead .mg-sticky { z-index: 3; background: var(--bg-float); }
.mg-group-row td { font-size: 11.5px; font-weight: 500; color: var(--text-faint); background: var(--bg-side); }
.mg-target { font-weight: 500; }
.mg-cell { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-sm); background: var(--field); }
.mg-tri { width: 28px; height: 24px; border-radius: 5px; font-size: 12px; color: var(--text-faint); transition: background .12s, color .12s; }
.mg-tri:hover:not([disabled]) { color: var(--text); background: var(--surface-3); }
.mg-tri[disabled] { opacity: .35; cursor: not-allowed; }
.mg-tri.is-on.allow { color: var(--green); background: rgba(86, 197, 150, .14); }
.mg-tri.is-on.deny { color: var(--red); background: rgba(236, 106, 111, .14); }
.mg-tri.is-on.none { color: var(--text); background: var(--surface-3); }
.mg-perm-group { margin-bottom: 12px; }

/* Журнал аудита */
.au-list { display: flex; flex-direction: column; gap: 2px; }
.au-row { display: flex; gap: 12px; padding: 9px 10px; border-radius: var(--r); transition: background .12s; }
.au-row:hover { background: var(--surface); }
.au-icon { flex: none; width: 22px; text-align: center; font-size: 15px; line-height: 20px; opacity: .7; }
.au-body { flex: 1; min-width: 0; }
.au-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.au-who { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text-strong); }
.au-who img { width: 18px; height: 18px; border-radius: 50%; }
.au-label { font-weight: 400; color: var(--text-muted); }
.au-target { font-weight: 500; color: var(--text-strong); }
.au-target.au-channel { color: var(--acc-strong); }
.au-target.au-role { color: var(--yellow); }
.au-time { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.au-extra { margin-top: 3px; font-size: 12px; color: var(--text-muted); }
.au-reason { display: inline-block; max-width: 100%; margin-top: 5px; padding: 4px 8px; border-radius: var(--r-sm); font-size: 12px; color: var(--text); border: 1px solid var(--line); }
.au-changes { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.au-change { display: grid; grid-template-columns: 150px minmax(0, 1fr) 14px minmax(0, 1fr); align-items: baseline; gap: 8px; font-size: 12px; }
.au-key { color: var(--text-faint); }
.au-from { overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); text-decoration: line-through; }
.au-arrow { color: var(--text-faint); }
.au-to { overflow: hidden; text-overflow: ellipsis; color: var(--green); }

/* Заявки в семью */
.fam .studio-scroll-view { padding: 20px 20px 28px; }
.fam-backdrop { padding: 0; }
.fam-body { display: flex; flex-direction: column; gap: 18px; max-width: 760px; }
.fam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.fam-hint { display: block; margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.fam-hint code { padding: 1px 5px; border-radius: 4px; background: var(--field); }
.fam-hint a { color: var(--link); }
.fam #famErrors, .rp #rpErrors { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fam .error-line, .rp .error-line { padding: 8px 10px; border-radius: var(--r); font-size: 13px; color: #f3b9bc; background: rgba(236, 106, 111, .08); border: 1px solid rgba(236, 106, 111, .3); }
.fam-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.fam-banner-file { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-muted); }
.fam-banner-file img { width: 80px; height: 45px; object-fit: cover; border-radius: var(--r-sm); }
.fam-questions { display: flex; flex-direction: column; gap: 12px; }
.fam-q .field + .field, .fam-q .fam-grid { margin-top: 12px; }
.fam-toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }

/* ================= Панель выдачи ролей ================= */

.rp-launch {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; margin: 0 4px; padding: 0 11px 0 9px; white-space: nowrap;
  border-radius: var(--r); font-size: 12.5px; font-weight: 500; color: var(--text-muted); border: 1px solid var(--line-2); transition: background .15s, color .15s;
}
.rp-launch svg { width: 16px; height: 16px; color: var(--acc); }
.rp-launch:hover { background: var(--surface-2); color: var(--text-strong); }
.rp .rp-count:not(:empty) { display: inline-grid; place-items: center; min-width: 16px; height: 16px; margin-left: 4px; padding: 0 5px; border-radius: 8px; font-size: 10.5px; font-weight: 600; color: var(--acc-ink); background: var(--acc); }
.rp-main.is-saved .studio-prev { display: none; }
.rp-main.is-saved .studio-edit { flex: 1; border-right: 0; }
.rp-editor { display: flex; flex-direction: column; gap: 4px; padding-bottom: 20px; }
.rp #rpSend.is-busy { opacity: .6; pointer-events: none; }
.rp-intro { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.rp-intro b { display: block; margin-bottom: 3px; font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.rp-intro span { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.rp-templates { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.rp-template { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px; color: var(--text-muted); border: 1px solid var(--line-2); transition: background .15s, color .15s; }
.rp-template:hover { background: var(--surface-2); color: var(--text-strong); }
.rp-counter { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.rp-gap { display: block; margin: 14px 0 6px; }
.rp-search { width: 180px; height: 30px; padding: 0 10px; font-size: 12.5px; }
.rp-empty { padding: 22px; text-align: center; font-size: 13px; color: var(--text-faint); border-radius: var(--r-lg); border: 1px dashed var(--line-3); }
.rp-empty.big { padding: 56px 20px; line-height: 1.6; }
.rp-role-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--rc, #99aab5); }
.rp-roles { display: flex; flex-direction: column; gap: 8px; }
.rp-role { position: relative; padding: 12px 12px 4px 14px; border-radius: var(--r-lg); border: 1px solid var(--line); transition: border-color .15s, opacity .15s; }
.rp-role::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px; border-radius: 0 2px 2px 0; background: var(--rc); }
.rp-role.is-bad { border-color: rgba(217, 177, 95, .45); }
.rp-role.is-drag { opacity: .4; }
.rp-role.is-over { border-color: var(--acc-line); }
.rp-role-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rp-role-head b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.rp-grip { padding-right: 4px; letter-spacing: -3px; color: var(--text-faint); cursor: grab; user-select: none; }
.rp-grip:active { cursor: grabbing; }
.rp-bad { font-size: 12px; color: var(--yellow); }
.rp-mini { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 12px; color: var(--text-faint); border: 1px solid var(--line); transition: background .12s, color .12s; }
.rp-mini:hover:not([disabled]) { color: var(--text-strong); background: var(--surface-3); }
.rp-mini.danger:hover { color: var(--red); background: rgba(236, 106, 111, .1); }
.rp-mini[disabled] { opacity: .3; cursor: default; }
.rp-role-grid { display: grid; grid-template-columns: 1fr 190px; gap: 10px; }
.rp-emoji-wrap { display: flex; gap: 6px; }
.rp-emoji-wrap input { flex: 1; min-width: 0; }
.rp-emoji-btn { flex: none; width: 34px; display: grid; place-items: center; border-radius: var(--r); font-size: 16px; border: 1px solid var(--line-2); }
.rp-emoji-btn:hover { background: var(--surface-2); }
.rp-emoji-btn img { width: 20px; height: 20px; }
.rp-styles { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.rp-style { padding: 4px 11px; border-radius: var(--r); font-size: 12px; font-weight: 500; color: #fff; background: var(--bc); opacity: .45; border: 1px solid transparent; transition: opacity .15s; }
.rp-style:hover { opacity: .75; }
.rp-style.is-on { opacity: 1; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text-strong); }
.rp-picker { display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px; margin-bottom: 8px; padding: 2px; overflow-y: auto; }
.rp-pick { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 99px; font-size: 12.5px; color: var(--text-muted); border: 1px solid var(--line-2); transition: background .12s, border-color .12s; }
.rp-pick:hover:not([disabled]) { color: var(--text); border-color: var(--rc); }
.rp-pick.is-on { color: var(--text-strong); border-color: var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent); }
.rp-pick.is-off { opacity: .35; cursor: not-allowed; }
.rp-chips .chip { padding: 5px 10px; font-size: 12.5px; }
.rp-cards { display: grid; gap: 8px; margin-bottom: 14px; }
.rp-cards.two, .rp-cards.four { grid-template-columns: 1fr 1fr; }
.rp-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; text-align: left; border-radius: var(--r-lg); color: var(--text); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.rp-card:hover { background: var(--surface); }
.rp-card.is-on { background: var(--acc-soft); border-color: var(--acc-line); }
.rp-card b { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.rp-card span:last-child { font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.rp-range { width: 100%; accent-color: var(--acc); }
.rp-color-input { width: 30px; height: 26px; padding: 0; border: 0; background: none; cursor: pointer; }
.rp .sf input.rp-color-input { flex: none; width: 32px; height: 28px; padding: 2px; border-radius: var(--r); cursor: pointer; }
.rp .s-colors .s-color-hex { flex: none; width: 100px; }
.rp-prev-head { display: flex; align-items: center; gap: 8px; }
.rp-preview { position: relative; }
.rp-preview .msg:hover { background: none; }
.rp-preview-inner { pointer-events: none; }
.rp-preview [data-rp-sim] { pointer-events: auto; cursor: pointer; }
.rp-preview .cv2-btn[data-rp-sim]:hover { filter: brightness(1.12); }
.rp-preview .cv2-btn.rp-has { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px #fff; }
.rp-preview .cv2-btn.rp-has::after { content: "✓"; margin-left: 2px; font-weight: 700; }
.rp-preview .cv2-select[data-rp-sim] { position: relative; }
.rp-preview .cv2-select[data-rp-sim]::after { content: "⌄"; margin-left: auto; }
.rp-sim-menu { max-width: 420px; margin-top: 4px; padding: 5px; display: flex; flex-direction: column; gap: 2px; pointer-events: auto; border-radius: var(--r-lg); background: var(--bg-float); border: 1px solid var(--line-2); animation: pop-in .15s var(--ease); }
.rp-sim-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; }
.rp-sim-opt:hover { background: var(--surface-2); }
.rp-sim-opt b { display: block; font-size: 13.5px; font-weight: 500; color: var(--text-strong); }
.rp-sim-opt i { display: block; font-style: normal; font-size: 12px; color: var(--text-faint); }
.rp-sim-emoji img { width: 20px; height: 20px; }
.rp-sim-menu .btn { align-self: flex-end; margin-top: 4px; }
.rp-sim { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); background: var(--bg-side); }
.rp-sim-hint { font-size: 12.5px; color: var(--text-faint); }
.rp-ephemeral { padding: 8px 12px; border-left: 2px solid var(--acc); background: var(--acc-soft); border-radius: 0 var(--r) var(--r) 0; animation: slide-up .25s var(--ease); }
.rp-eph-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12.5px; }
.rp-eph-bot { font-weight: 600; color: var(--text-strong); }
.rp-eph-note { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.rp-eph-body { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; color: var(--text); }
.rp-sim-have { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); }
.rp-sim-have i { font-style: normal; }
.rp-mini-role { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; color: var(--text); border: 1px solid color-mix(in srgb, var(--rc, #99aab5) 40%, transparent); }
.rp-mini-role .rp-role-dot { width: 6px; height: 6px; }
.rp-emoji-pop { position: fixed; z-index: 400; width: 300px; max-height: 360px; overflow-y: auto; padding: 10px; }
.rp-emoji-title { margin: 4px 2px 6px; font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
.rp-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-bottom: 6px; }
.rp-emoji-grid button { height: 32px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 18px; }
.rp-emoji-grid button:hover { background: var(--surface-3); }
.rp-emoji-grid img { width: 22px; height: 22px; }
.rp-emoji-none { width: 100%; }
.rp-saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.rp-saved-card { position: relative; overflow: hidden; padding: 14px 14px 12px 16px; display: flex; flex-direction: column; gap: 10px; border-radius: var(--r-lg); border: 1px solid var(--line); transition: border-color .15s; }
.rp-saved-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 2px; background: var(--ac); }
.rp-saved-card:hover { border-color: var(--line-3); }
.rp-saved-card.is-on { border-color: var(--acc-line); }
.rp-saved-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rp-saved-top b { margin-right: auto; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.rp-tag { padding: 2px 8px; border-radius: 99px; font-size: 11px; color: var(--text-faint); border: 1px solid var(--line); }
.rp-saved-roles { display: flex; flex-wrap: wrap; gap: 5px; }
.rp-saved-meta { font-size: 12px; color: var(--text-faint); }
.rp-saved-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rp-replace { margin-right: 4px; }

/* ================= Движение ================= */

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes msg-out { to { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; } }
@keyframes highlight { 0%, 40% { background: rgba(170, 163, 255, .12); } 100% { background: transparent; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes panel-in { from { opacity: 0; transform: translateX(12px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes typing { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ================= Узкие экраны ================= */

@media (max-width: 1100px) {
  .chat { position: relative; }
  .chat-topic { display: none; }
  .members, .threads { position: absolute; right: 0; top: 56px; bottom: 0; z-index: 6; box-shadow: var(--shadow); }
}
@media (max-width: 900px) {
  .rp-launch span { display: none; }
  .rp-launch { padding: 0 8px; }
  .studio { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .studio-body { flex-direction: column; }
  .studio-edit { flex: 1 1 auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .studio-prev { min-height: 220px; }
  .studio-title { display: none; }
  .s-row, .rp-role-grid, .rp-cards.two, .rp-cards.four { grid-template-columns: 1fr; }
  .s-kinds { grid-template-columns: 1fr; }
  .s-kind { flex-direction: row; justify-content: flex-start; gap: 10px; text-align: left; }
  .s-kind-good { margin-left: auto; }
  .s-anatomy-row { grid-template-columns: 1fr; gap: 2px; }
  .s-target select { min-width: 140px; }
  .rp .rp-tabs { max-width: 52vw; overflow-x: auto; }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-grid !important; }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 20; transition: transform .25s var(--ease); }
  .rail { left: 0; transform: translateX(-300px); }
  .sidebar { left: 60px; transform: translateX(-300px); }
  .app.nav-open .rail, .app.nav-open .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .chat-header { padding-left: 6px; }
  .chat-title { max-width: none; }
  .msg { padding-left: 62px; padding-right: 12px; }
  .msg-avatar { left: 14px; }
  .msg-time-side { width: 62px; }
  .msg-actions { right: 8px; }
  .composer { margin: 0 10px; }
  .composer-btn { width: 34px; }
  .composer-btn:first-child { width: 42px; }
  .jump-bar { left: 10px; right: 10px; }
  .members { width: min(280px, 85vw); }
  .threads { width: min(320px, 92vw); }
  .popout { width: min(320px, calc(100vw - 16px)); }
  .att-media img, .att-media video { max-width: 100%; }
  .au-change { grid-template-columns: 1fr; gap: 1px; }
  .au-arrow { display: none; }
  .au-from { text-decoration: none; opacity: .7; }
}

/* Правка сообщения на месте и блок ошибок в окнах */
.edit-input { width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: var(--r); resize: vertical; font: inherit; line-height: 1.5; color: var(--text); background: var(--field); border: 1px solid var(--acc-line); outline: none; }
.errors { display: flex; flex-direction: column; gap: 6px; }
