/* Шрифт Noto Sans (лицензия SIL OFL, fonts/LICENSE-OFL.txt) — похож на шрифт Discord */
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/noto-sans-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/noto-sans-cyrillic-400.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/noto-sans-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/noto-sans-cyrillic-500.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/noto-sans-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/noto-sans-cyrillic-600.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/noto-sans-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/noto-sans-cyrillic-700.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 800; font-display: swap; src: url(/fonts/noto-sans-latin-800.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans"; font-style: normal; font-weight: 800; font-display: swap; src: url(/fonts/noto-sans-cyrillic-800.woff2) format("woff2"); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }

:root {
  --accent: #7c5cff;
  --accent-text: #fff;
  --bg: #17181c; --bg2: #1e1f24; --bg3: #26282e; --bg4: #30323a; --input: #2b2d34;
  --text: #e8e9ed; --muted: #9a9ca6; --faint: #6c6e78; --border: #2f3138;
  --ok: #3ecf8e; --warn: #f5b942; --danger: #f2545b; --idle: #f5b942; --dnd: #f2545b; --off: #747682;
  --radius: 12px; --font: 15px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --t: .16s;
}
body.light {
  --bg: #e9eaef; --bg2: #f3f4f7; --bg3: #ffffff; --bg4: #e2e4ea; --input: #eceef2;
  --text: #1c1d22; --muted: #5c5f6a; --faint: #8a8d97; --border: #d9dbe2;
  --shadow: 0 8px 32px rgba(0,0,0,.15);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 400 var(--font)/1.375 "Noto Sans", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; letter-spacing: .005em; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 8px; }

/* Режимы производительности */
body.no-anim *, body.no-anim *::before, body.no-anim *::after { transition: none !important; animation: none !important; }
body.lite .glass, body.max .glass { backdrop-filter: none !important; }
body.max .avatar img { display: none; }
body.max .msg .avatar { display: none; }
body.max .msg { padding-left: 16px; }

/* ---------- Кнопки и поля ---------- */
.btn { border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; transition: filter var(--t), transform var(--t); }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--bg4); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: inline-grid; place-items: center; font-size: 17px; transition: background var(--t), color var(--t); }
.icon-btn:hover { background: var(--bg4); color: var(--text); }
.icon-btn.on { color: var(--danger); }
.icon-btn.active { color: var(--accent); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid transparent; background: var(--input); outline: none; transition: border-color var(--t); }
.input:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.error-box { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }

/* ---------- Экран входа ---------- */
#auth { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 10%, color-mix(in srgb, var(--accent) 30%, transparent), transparent), var(--bg); padding: 16px; overflow: auto; }
.auth-card { width: min(420px, 100%); background: var(--bg2); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.logo { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; }
.logo b { color: var(--accent); }
.auth-card h2 { margin: 18px 0 18px; font-size: 20px; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.switch-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.switch-link a { cursor: pointer; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: -4px 0 16px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: Consolas, monospace; background: var(--bg); padding: 14px; border-radius: 10px; margin: 12px 0; }

/* ---------- Каркас ---------- */
#app { display: flex; height: 100vh; }
#rail { width: 72px; flex-shrink: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; }
.rail-item { position: relative; width: 48px; height: 48px; border-radius: 24px; background: var(--bg3); display: grid; place-items: center; font-weight: 700; overflow: hidden; border: 0; transition: border-radius var(--t), background var(--t); flex-shrink: 0; }
.rail-item:hover, .rail-item.active { border-radius: 16px; background: var(--accent); color: var(--accent-text); }
.rail-item img { width: 100%; height: 100%; object-fit: cover; }
.rail-item.add { color: var(--ok); font-size: 24px; font-weight: 400; }
.rail-item.add:hover { background: var(--ok); color: #fff; }
.rail-sep { width: 32px; height: 2px; background: var(--bg4); border-radius: 2px; }
.badge { position: absolute; right: -2px; bottom: -2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 4px; border: 3px solid var(--bg); }

#sidebar { width: 248px; flex-shrink: 0; background: var(--bg2); display: flex; flex-direction: column; }
.side-head { height: 52px; padding: 0 12px 0 16px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); font-weight: 700; flex-shrink: 0; }
.side-head .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list { flex: 1; overflow-y: auto; padding: 8px; }
.side-cat { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 14px 6px 4px; }
.side-cat .icon-btn { width: 22px; height: 22px; font-size: 16px; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; color: var(--muted); cursor: pointer; transition: background var(--t), color var(--t); position: relative; }
.side-item:hover { background: var(--bg3); color: var(--text); }
.side-item.active { background: var(--bg4); color: var(--text); }
.side-item.unread { color: var(--text); font-weight: 600; }
.side-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 6px; }
.voice-users { padding-left: 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 6px; font-size: 13px; color: var(--muted); }
.voice-user .avatar { width: 22px; height: 22px; font-size: 10px; }
.voice-user .flags { margin-left: auto; font-size: 12px; }

#userbar { height: 56px; background: var(--bg); background: color-mix(in srgb, var(--bg) 70%, var(--bg2)); display: flex; align-items: center; gap: 6px; padding: 0 8px; flex-shrink: 0; }
#userbar .who { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; padding: 4px; display: flex; align-items: center; gap: 8px; }
#userbar .who:hover { background: var(--bg3); }
#userbar .who .n { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#userbar .who .s { font-size: 12px; color: var(--muted); }
#voicebar { background: color-mix(in srgb, var(--bg) 70%, var(--bg2)); border-bottom: 1px solid var(--border); padding: 8px 10px; font-size: 13px; }
#voicebar .state { color: var(--ok); font-weight: 700; }

.avatar { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; font-size: 14px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; image-rendering: auto; transform: translateZ(0); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 80px; height: 80px; font-size: 32px; }
.avatar .dot { position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%; border: 3px solid var(--bg2); background: var(--off); }
.dot.online { background: var(--ok) !important; } .dot.idle { background: var(--idle) !important; } .dot.dnd { background: var(--dnd) !important; }
.avatar.speaking { box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--ok); }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg3); position: relative; }
.main-head { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); }
.main-head .title { font-weight: 700; display: flex; align-items: center; gap: 4px; min-width: 0; }
.main-head .h-icon { color: var(--muted); font-weight: 600; margin-right: 2px; }
.main-head .title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-head .tabs { display: flex; gap: 4px; margin-left: 12px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.tab:hover { background: var(--bg4); color: var(--text); }
.tab.active { background: var(--bg4); color: var(--text); }
.tab.add { background: var(--ok); color: #fff; }
.main-body { flex: 1; display: flex; min-height: 0; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#members { width: 240px; flex-shrink: 0; background: var(--bg2); overflow-y: auto; padding: 8px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.member:hover { background: var(--bg3); }
.member.offline { opacity: .5; }
.member .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* Иконки */
.ic { width: 20px; height: 20px; flex-shrink: 0; display: block; }
.icon-btn .ic { width: 20px; height: 20px; }
.msg .actions .ic { width: 18px; height: 18px; }
.call-btn { display: inline-grid; place-items: center; }
.call-btn .ic { width: 22px; height: 22px; }
.round-btn { display: inline-grid; place-items: center; }
.round-btn .ic { width: 18px; height: 18px; }
.side-item .ic { width: 18px; height: 18px; opacity: .8; }
.side-head .ic { width: 18px; height: 18px; }
.rail-item .ic { width: 24px; height: 24px; }
.menu button { align-items: center; }
.menu .ic { width: 16px; height: 16px; opacity: .85; }
.menu .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); margin: 0 3px; }
.empty .big .ic { width: 56px; height: 56px; margin: 0 auto; opacity: .5; stroke-width: 1.5; }
.ic.dim { width: 14px; height: 14px; opacity: .7; }
.ic.crown { display: inline-block; width: 14px; height: 14px; color: var(--warn); vertical-align: -2px; margin-left: 4px; }
.tile-actions .ic, .attach .ic, .reply .ic { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; }
.voice-user .flags .ic { display: inline-block; width: 14px; height: 14px; margin-left: 2px; }
.official { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-text); font-size: 10px; font-weight: 800; letter-spacing: .02em; line-height: 16px; vertical-align: middle; white-space: nowrap; }

/* ---------- Список друзей ---------- */
.list-pad { padding: 16px 24px; overflow-y: auto; flex: 1; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px; border-top: 1px solid var(--border); border-radius: 10px; }
.person:hover { background: var(--bg4); }
.person .info { flex: 1; min-width: 0; }
.person .info .n { font-weight: 600; }
.person .info .u { font-size: 13px; color: var(--muted); }
.round-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg2); color: var(--muted); font-size: 16px; }
.round-btn:hover { color: var(--text); background: var(--bg); }
.round-btn.ok:hover { color: var(--ok); } .round-btn.no:hover { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 48px; margin-bottom: 12px; }

/* ---------- Сообщения ---------- */
#messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.msg { position: relative; display: flex; gap: 14px; padding: 3px 48px 3px 16px; }
.msg:hover { background: color-mix(in srgb, var(--bg) 25%, transparent); }
.msg.first { margin-top: 14px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.mention { background: color-mix(in srgb, var(--warn) 10%, transparent); box-shadow: inset 3px 0 var(--warn); }
.msg .body { flex: 1; min-width: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 600; cursor: pointer; }
.msg .time { font-size: 11px; color: var(--faint); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .text .mention-tag { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); border-radius: 4px; padding: 0 3px; }
.msg .edited { font-size: 11px; color: var(--faint); }
.msg .reply { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 2px; cursor: pointer; }
.msg .reply::before { content: "↱"; }
.msg .pin-flag { font-size: 11px; color: var(--warn); }
.msg .actions { position: absolute; right: 16px; top: -14px; display: none; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.msg:hover .actions { display: flex; }
.msg .actions .icon-btn { width: 30px; height: 30px; font-size: 15px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { border: 1px solid transparent; background: var(--bg4); border-radius: 8px; padding: 1px 8px; font-size: 13px; }
.reaction.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.attach { margin-top: 6px; }
.attach img, .attach video { max-width: min(420px, 100%); max-height: 320px; border-radius: 10px; display: block; cursor: pointer; background: var(--bg); }
.attach audio { width: min(340px, 100%); }
.attach .file { display: inline-flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; text-decoration: none; color: var(--text); max-width: 100%; }
.attach .file .sz { font-size: 12px; color: var(--muted); }
.attach .placeholder { background: var(--bg2); border: 1px dashed var(--border); border-radius: 10px; padding: 14px; color: var(--muted); cursor: pointer; display: inline-block; }
.receipt { font-size: 11px; color: var(--faint); padding: 0 16px 0 66px; }
.day-sep { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 18px 16px 4px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#typing { height: 22px; font-size: 12px; color: var(--muted); padding: 0 18px; }
.composer { margin: 0 16px 6px; background: var(--input); border-radius: 12px; }
.composer .replybar, .composer .files { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.composer .chip { background: var(--bg4); border-radius: 8px; padding: 4px 8px; display: inline-flex; gap: 6px; align-items: center; color: var(--text); }
.composer .inner { display: flex; align-items: flex-end; gap: 4px; padding: 4px 6px; }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; outline: none; padding: 9px 6px; max-height: 200px; }
.composer .rec { color: var(--danger); font-weight: 700; padding: 9px 6px; flex: 1; }
.search-results { position: absolute; right: 12px; top: 56px; width: min(420px, calc(100% - 24px)); max-height: 60vh; overflow-y: auto; background: var(--bg2); border-radius: 12px; box-shadow: var(--shadow); z-index: 20; padding: 8px 0; }
.load-more { text-align: center; padding: 8px; color: var(--muted); font-size: 13px; }

/* ---------- Звонок ---------- */
#call { background: #0d0e11; display: flex; flex-direction: column; min-height: 240px; height: 46%; border-bottom: 1px solid var(--border); position: relative; }
#call.full { height: 100%; }
#call .grid { flex: 1; display: grid; gap: 8px; padding: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); grid-auto-rows: minmax(120px, 1fr); overflow: auto; }
.tile { position: relative; background: #1b1c21; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 120px; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.tile .tile-actions { position: absolute; right: 8px; top: 8px; display: none; gap: 4px; }
.tile:hover .tile-actions { display: flex; }
.tile .tile-actions button { background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 6px; padding: 4px 8px; font-size: 12px; }
.tile.screen { grid-column: 1 / -1; grid-row: span 2; }
#call .bar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; flex-wrap: wrap; }
#call .bar .info { position: absolute; left: 14px; bottom: 16px; color: #aab; font-size: 13px; }
.call-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #2a2c33; color: #fff; font-size: 19px; transition: background var(--t); }
.call-btn:hover { background: #3a3d46; }
.call-btn.off { background: #fff; color: #111; }
.call-btn.hang { background: var(--danger); }
.call-btn.live { background: var(--ok); }
.live-badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; font-weight: 700; font-size: 12px; padding: 4px 10px; border-radius: 8px; z-index: 2; }
body.compact #rail, body.compact #sidebar, body.compact #members, body.compact .content > *:not(#call), body.compact .main-head { display: none !important; }
body.compact #call { height: 100%; }

/* ---------- Модальные окна ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 90vh; overflow-y: auto; background: var(--bg2); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 50vh; overflow-y: auto; margin: 10px 0; }
.source { border: 2px solid transparent; border-radius: 10px; background: var(--bg3); padding: 6px; cursor: pointer; font-size: 12px; text-align: center; }
.source.sel { border-color: var(--accent); }
.source img { width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #000; border-radius: 6px; }
.menu { position: fixed; z-index: 200; background: var(--bg2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 190px; }
.menu button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--accent); color: var(--accent-text); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--bg2); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 340px; font-size: 14px; }
.toast.err { border-color: var(--danger); }
.incoming { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 250; background: var(--bg2); border-radius: 16px; padding: 18px 22px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 400; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }
.banner { background: var(--accent); color: var(--accent-text); padding: 8px 16px; font-size: 14px; display: flex; gap: 12px; align-items: center; }
.banner .btn { background: rgba(255,255,255,.2); padding: 4px 10px; }
.emoji-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pick button { border: 0; background: transparent; font-size: 20px; border-radius: 6px; padding: 4px; }
.emoji-pick button:hover { background: var(--bg4); }

/* ---------- Настройки ---------- */
#settings { position: fixed; inset: 0; z-index: 90; display: flex; background: var(--bg3); }
#settings nav { width: 240px; background: var(--bg2); padding: 40px 10px 20px; overflow-y: auto; flex-shrink: 0; }
#settings nav .side-item { margin-bottom: 2px; }
#settings nav .grp { font-size: 12px; font-weight: 700; color: var(--faint); text-transform: uppercase; padding: 12px 8px 4px; }
#settings .pane { flex: 1; overflow-y: auto; padding: 40px; max-width: 760px; }
#settings .pane h2 { margin-top: 0; }
#settings .close { position: fixed; right: 24px; top: 24px; }
.card { background: var(--bg2); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.card h4 { margin: 0 0 12px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.opt:last-child { border-bottom: 0; }
.opt .t { flex: 1; }
.opt .t small { display: block; color: var(--muted); font-size: 13px; }
.toggle { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: var(--bg4); position: relative; cursor: pointer; transition: background var(--t); flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left var(--t); }
.toggle:checked { background: var(--ok); }
.toggle:checked::after { left: 21px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.radio-card { border: 2px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; }
.radio-card.sel { border-color: var(--accent); }
.radio-card b { display: block; margin-bottom: 4px; }
.radio-card small { color: var(--muted); }
.meter { height: 8px; background: var(--bg4); border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: var(--ok); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--text); }
.session-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }

/* ---------- Мобильная/узкая вёрстка ---------- */
.mobile-back { display: none; }
@media (max-width: 640px) { .mobile-back { display: inline-grid; } }
@media (max-width: 860px) {
  #members { display: none; }
}
@media (max-width: 640px) {
  #rail { width: 60px; }
  .rail-item { width: 42px; height: 42px; }
  #sidebar { position: absolute; left: 60px; top: 0; bottom: 0; z-index: 30; width: calc(100vw - 60px); }
  body.mobile-chat #sidebar, body.mobile-chat #rail { display: none; }
  .msg { padding-right: 12px; }
  #settings { flex-direction: column; }
  #settings nav { width: 100%; padding: 56px 10px 10px; max-height: 40vh; }
  #settings .pane { padding: 16px; }
}
