:root {
  --bg: #1a1c20;
  --bg2: #23262d;
  --bg3: #2c303a;
  --accent: #c5a253;
  --accent2: #a98a42;
  --accent-grad: linear-gradient(180deg, #d6bd78 0%, #c5a253 52%, #b08e44 100%);
  --accent-grad-hover: linear-gradient(180deg, #cbb068 0%, #b8954a 52%, #a3823c 100%);
  --text: #e6e8ee;
  --muted: #8a8f9a;
  --green: #3ba55d;
  --error: #f04747;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; }

/* ---------- Экран входа ---------- */
#auth-screen { display: flex; align-items: center; justify-content: center; }
.auth-box { background: var(--bg2); padding: 32px; border-radius: 12px; width: 360px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.logo { text-align: center; font-size: 34px; letter-spacing: 4px; margin-bottom: 20px; color: var(--accent); }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { flex: 1; padding: 10px; background: var(--bg3); border: none; color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--accent); color: #1a1c20; }
#auth-form { display: flex; flex-direction: column; gap: 12px; }

input {
  padding: 12px; background: var(--bg); border: 1px solid var(--bg3);
  border-radius: 8px; color: var(--text); font-size: 15px; outline: none;
}
input:focus { border-color: var(--accent); }

button.primary {
  padding: 12px; background: var(--accent-grad); color: #1a1c20; border: none;
  border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.25);
}
button.primary:hover { background: var(--accent-grad-hover); }

button.ghost {
  padding: 12px; background: none; border: 1px solid var(--bg3); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 15px;
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }

.error { color: var(--error); font-size: 13px; min-height: 16px; }

/* ---------- Главный экран ---------- */
.app { display: flex; height: 100vh; }

/* Рейл пространств (как серверы в Discord) */
.space-rail {
  width: 68px; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; padding: 12px 0; gap: 10px; overflow-y: auto;
}
.space-list { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.space-icon {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--bg3); color: var(--text); font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.space-icon:hover { background: var(--accent2); color: #1a1c20; }
.space-icon.active { background: var(--accent-grad); color: #1a1c20; }
.rail-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px dashed var(--bg3);
  background: none; color: var(--muted); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rail-btn:hover { border-color: var(--accent); color: var(--accent); }
.home-btn { margin-top: auto; } /* прижата к низу рейла (левый нижний угол) */

/* Сайдбар: комнаты */
.sidebar { width: 230px; background: var(--bg2); display: flex; flex-direction: column; padding: 12px; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 17px; font-weight: 700; color: var(--accent); padding: 6px 8px; margin-bottom: 6px;
}
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.icon-btn:hover { color: var(--accent); }

.channels { flex: 1; overflow-y: auto; }
.group-title { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; padding: 12px 10px 4px; }

.channel {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-height: 38px; padding: 6px 10px; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.channel:hover { background: var(--bg3); color: var(--text); }
.channel.active { background: var(--bg3); color: var(--accent); }
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; opacity: 0; padding: 2px 4px; }
.channel:hover .channel-del { opacity: 1; }
.channel-del:hover { color: var(--error); }

.add-channel {
  width: 100%; margin-top: 8px; padding: 8px; min-height: 38px; background: none;
  border: 1px dashed var(--bg3); color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 14px;
}
.add-channel:hover { border-color: var(--accent); color: var(--accent); }

.me-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; margin-top: 8px; background: var(--bg3); border-radius: 8px; font-size: 14px;
}
.me-actions { display: flex; gap: 4px; }
.me-bar button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; min-width: 30px; min-height: 30px; }
#logout-btn:hover { color: var(--error); }
#settings-btn:hover { color: var(--accent); }

/* Центр */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-header { height: 52px; display: flex; align-items: center; padding: 0 20px; font-weight: 600; border-bottom: 1px solid var(--bg2); }
.text-view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 12px; position: relative; }
.msg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }

/* Аватарки */
.avatar { border-radius: 50%; flex: 0 0 auto; }
img.avatar { object-fit: cover; }
.avatar-letter { background: var(--accent-grad); color: #1a1c20; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.av-sm { width: 28px; height: 28px; font-size: 13px; }
.av-msg { width: 40px; height: 40px; font-size: 17px; }
.av-big { width: 72px; height: 72px; font-size: 30px; }
.msg-nick { font-weight: 600; color: var(--text); }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-edited { font-size: 11px; color: var(--muted); font-style: italic; }

/* Плавающая панель действий над сообщением (как в Discord) */
.msg-actions {
  position: absolute; top: -16px; right: 8px; display: flex; gap: 2px;
  background: var(--bg2); border: 1px solid var(--bg3); border-radius: 8px;
  padding: 2px; box-shadow: 0 2px 10px rgba(0, 0, 0, .4); opacity: 0;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-act {
  background: none; border: none; color: var(--text); cursor: pointer;
  font-size: 18px; line-height: 1; border-radius: 6px; padding: 6px 8px;
}
.msg-act:hover { background: var(--bg3); }
.edit-input { width: 100%; padding: 8px 10px; font-size: 15px; }
.msg-text { color: #d2d5dc; word-break: break-word; }
.msg-text.jumbo { font-size: 40px; line-height: 1.2; }
.sticker { width: 120px; height: 120px; }
.sticker-fallback { font-size: 90px; line-height: 1; }

/* Вложения */
.attach-img { max-width: 320px; max-height: 320px; border-radius: 10px; display: block; cursor: pointer; }
.attach-video { max-width: 360px; max-height: 320px; border-radius: 10px; display: block; background: #000; }
.attach-file {
  display: inline-flex; align-items: center; gap: 10px; max-width: 320px;
  background: var(--bg2); border: 1px solid var(--bg3); border-radius: 10px;
  padding: 10px 14px; text-decoration: none; color: var(--text);
}
.attach-file:hover { border-color: var(--accent); }
.attach-icon { font-size: 26px; flex: 0 0 auto; }
.attach-info { display: flex; flex-direction: column; min-width: 0; }
.attach-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: 12px; color: var(--muted); }
.attach-caption { margin-top: 6px; }

/* Просмотр картинки поверх окна (лайтбокс) */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .85);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.lightbox-img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.lightbox-close {
  position: absolute; top: 18px; right: 24px; background: rgba(0, 0, 0, .45); color: #fff;
  border: none; font-size: 22px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .2); }

/* Строка «прикреплён файл» над полем ввода */
.attach-preview { display: flex; align-items: center; gap: 8px; padding: 8px 20px; background: var(--bg2); border-top: 1px solid var(--bg3); font-size: 14px; }
.ap-icon { font-size: 16px; flex: 0 0 auto; }
.ap-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ap-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.ap-remove:hover { color: var(--error); }

/* Кнопки эмодзи/стикеров у поля ввода */
.input-icon { background: none; border: none; cursor: pointer; font-size: 20px; padding: 0 2px; }
.input-icon:hover { transform: scale(1.1); }

/* Панели выбора эмодзи/стикеров */
.picker-panel {
  position: absolute; bottom: 74px; left: 16px; width: 320px; max-height: 260px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--bg3); border-radius: 10px; padding: 10px;
  display: flex; flex-wrap: wrap; gap: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.45); z-index: 6;
}
.emoji-item { font-size: 22px; cursor: pointer; line-height: 1; padding: 4px; border-radius: 6px; }
.emoji-item:hover { background: var(--bg3); }
.sticker-item { width: 56px; height: 56px; cursor: pointer; border-radius: 8px; padding: 4px; }
.sticker-item:hover { background: var(--bg3); }

/* Реакции на сообщения */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; align-items: center; }
.reaction {
  font-size: 14px; background: var(--bg3); color: var(--text);
  border-radius: 12px; padding: 3px 10px; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.reaction:hover { filter: brightness(1.15); }
.reaction.mine { background: rgba(197, 162, 83, .22); outline: 1px solid var(--accent); }
.reaction-add {
  background: var(--bg3); border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 3px 10px; border-radius: 12px; line-height: 1; opacity: 0;
}
.msg:hover .reaction-add { opacity: 1; }
.reaction-add:hover { color: var(--accent); }
.reaction-picker {
  position: fixed; background: var(--bg2); border: 1px solid var(--bg3); border-radius: 10px;
  padding: 6px; display: flex; gap: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.45); z-index: 20;
}
.reaction-pick-item { font-size: 20px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.reaction-pick-item:hover { background: var(--bg3); }

.chat-input { display: flex; gap: 10px; padding: 16px 20px; background: var(--bg2); }
.chat-input input { flex: 1; }
.chat-input button {
  padding: 0 20px; min-height: 44px; background: var(--accent-grad); color: #1a1c20; border: none;
  border-radius: 8px; cursor: pointer; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 6px rgba(0,0,0,.25);
}
.chat-input button:hover { background: var(--accent-grad-hover); }

/* Пустой экран */
.empty-view { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 22px 0 0; }
.welcome-title { font-size: 64px; font-weight: 800; letter-spacing: 12px; color: var(--accent); text-align: center; }
.empty-mid { flex: 1; display: flex; align-items: center; justify-content: center; }
.welcome-img { width: 100%; max-width: 760px; height: auto; display: block; }
.empty-box { text-align: center; color: var(--muted); }
.voice-icon { font-size: 56px; margin-bottom: 16px; opacity: .6; }
.empty-box p { line-height: 1.6; }
.empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* Голосовая комната */
.voice-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.voice-idle { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.voice-idle p { line-height: 1.6; }
.voice-active { flex: 1; overflow-y: auto; padding: 24px; }
.voice-participants { display: flex; flex-wrap: wrap; gap: 16px; }
.voice-tile {
  width: 120px; height: 120px; background: var(--bg2); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px solid transparent; transition: border-color .15s, box-shadow .15s;
}
.voice-tile.speaking { border-color: var(--green); box-shadow: 0 0 0 3px rgba(59,165,93,.25); }
.voice-avatar { width: 54px; height: 54px; font-size: 22px; }
.voice-tile-name { font-size: 13px; color: var(--text); max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-vol { width: 96px; accent-color: var(--accent); cursor: pointer; }

/* Постоянная панель голоса в сайдбаре */
.voice-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; margin-top: 8px; background: var(--bg3); border-radius: 8px; font-size: 14px;
}
.voice-bar-name { color: var(--green); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-bar-actions { display: flex; gap: 4px; }
.voice-bar button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; min-width: 30px; min-height: 30px; }
.voice-bar button:hover { color: var(--text); }
#voice-leave-btn:hover { color: var(--error); }

/* Правая колонка: участники */
.online-panel { width: 210px; background: var(--bg2); padding: 12px; display: flex; flex-direction: column; }
.online-title { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; padding: 8px 10px 4px; }
.online-list { flex: 1; overflow-y: auto; }
.member {
  padding: 6px 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; border-radius: 6px;
}
.member.online { color: var(--text); }
.member.offline { color: var(--muted); }
.member.offline .avatar { opacity: .5; }
.member-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-kick { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; opacity: 0; padding: 2px 4px; }
.member:hover .member-kick { opacity: 1; }
.member-kick:hover { color: var(--error); }
.member-muted { font-size: 12px; flex: 0 0 auto; opacity: .85; }
.member-act { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; opacity: 0; padding: 2px 4px; flex: 0 0 auto; }
.member:hover .member-act { opacity: 1; }
.member-act:hover { color: var(--accent); }

/* Баннер «вы заглушены» над полем ввода */
.mute-banner { padding: 8px 20px; background: var(--bg2); border-top: 1px solid var(--bg3); color: var(--error); font-size: 13px; }
/* Окно выбора срока заглушки */
.mute-dur { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px 24px; }
.mute-dur input { width: 90px; }
input:disabled, button:disabled { opacity: .5; cursor: not-allowed; }

/* Согласие с политикой при регистрации */
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); text-align: left; }
.consent input { margin-top: 2px; flex: 0 0 auto; }
.consent a { color: var(--accent); cursor: pointer; }
/* Текст политики в поп-апе */
.policy-text { max-height: 60vh; overflow-y: auto; font-size: 13px; line-height: 1.6; color: var(--text); padding-right: 6px; margin-bottom: 14px; }
.policy-text h4 { margin: 14px 0 4px; color: var(--accent); font-size: 14px; }
.policy-text ul { margin: 4px 0 4px 18px; }
.policy-text li { margin: 2px 0; }
.policy-muted { color: var(--muted); }

.header-actions { display: flex; gap: 6px; }

/* ---------- Окна (модалки) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal { background: var(--bg2); border-radius: 12px; width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; font-weight: 600; border-bottom: 1px solid var(--bg3); }
.modal-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.radio { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--bg); border-radius: 8px; cursor: pointer; font-size: 15px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }
.invite-code {
  text-align: center; font-size: 26px; font-weight: 700; letter-spacing: 4px; color: var(--accent);
  background: var(--bg); padding: 14px; border-radius: 8px; user-select: all;
}

/* Панель управления пространствами (владелец EDEM) */
.modal-wide { width: 460px; }
.admin-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
}
.admin-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-meta { font-size: 12px; color: var(--muted); }
.admin-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; flex: 0 0 auto; }
.admin-del:hover { color: var(--error); }
.admin-empty { color: var(--muted); text-align: center; padding: 24px; }

/* Панель «Люди и коды» */
.people-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.ptab { flex: 1; padding: 9px; background: var(--bg3); border: none; color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 14px; }
.ptab.active { background: var(--accent); color: #1a1c20; }
.code-create { display: flex; gap: 8px; margin-bottom: 12px; }
.code-create input { flex: 1; }
.code-create button { flex: 0 0 auto; }
.code-value { font-family: ui-monospace, monospace; letter-spacing: 2px; font-size: 16px; }
.code-value.used { text-decoration: line-through; color: var(--muted); }

/* Настройки звука */
select {
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--bg3);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
}
select:focus { border-color: var(--accent); }
.field-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.ptt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--text); }
.ghost-sm {
  background: none; border: 1px solid var(--bg3); color: var(--text);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
.ghost-sm:hover { border-color: var(--accent); color: var(--accent); }

/* Кнопка «заглушить наушники» в активном состоянии */
#voice-deafen-btn.off { color: var(--error); }

/* Профиль в настройках */
.settings-section-title { font-weight: 700; color: var(--accent); margin: 2px 0 4px; }
.settings-sep { border: none; border-top: 1px solid var(--bg3); margin: 8px 0; }
.profile-edit { display: flex; gap: 16px; align-items: center; }
.profile-fields { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.profile-msg { font-size: 13px; color: var(--muted); min-height: 16px; }

/* Я внизу сайдбара */
.me-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
#me-nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
