:root {
  /* Тёмная (почти чёрная) тема AudioHub */
  --bg-0: #141417;      /* поля ввода, линии */
  --bg-1: #0b0b0d;      /* боковые панели */
  --bg-2: #050506;      /* основной фон чата */
  --bg-3: #1b1b1f;      /* наведение, кнопки */
  --border: #1d1d21;
  --active: #212126;
  --text: #f2f3f5;
  --muted: #8b8d96;
  --accent: #7c5cff;
  --accent-hover: #6a4bf0;
  --brand: linear-gradient(135deg, #8b5cf6, #22d3ee);
  --green: #23a55a;
  --red: #da373c;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-2);
  color: var(--text);
  font: 15px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: #00a8fc; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- кнопки и поля ---------- */
.btn {
  border: 0; border-radius: 4px; padding: 9px 16px; cursor: pointer;
  background: var(--bg-3); transition: background .15s;
}
.btn:hover { background: #2a2a30; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; border-radius: 4px;
  width: 32px; height: 32px; display: inline-grid; place-items: center; font-size: 16px; flex: none;
}
.icon-btn:hover { background: var(--bg-3); }
.icon-btn.active { background: var(--green); }
.icon-btn.off { background: var(--red); }
.icon-btn.danger:hover { background: var(--red); }
label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted); margin: 12px 0 0; }
label input:not([type=checkbox]):not([type=radio]), label select {
  display: block; width: 100%; margin-top: 6px; padding: 10px; border: 0; border-radius: 4px;
  background: var(--bg-0); text-transform: none; font-weight: normal; color: var(--text); font-size: 15px;
}
label.check { text-transform: none; font-weight: normal; font-size: 14px; color: var(--text); display: flex; gap: 8px; align-items: center; }

/* ---------- вход ---------- */
.auth {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 25% 15%, #2a1d5e, #050506 55%), #050506;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-2); padding: 32px; border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.4); text-align: center;
}
.auth-card label { text-align: left; }
.auth-card .btn { width: 100%; margin-top: 20px; padding: 12px; }
.auth-card h1 { margin: 12px 0 4px; font-size: 24px; }
.logo { width: 64px; height: 64px; margin: 0 auto; display: block; filter: drop-shadow(0 6px 24px rgba(124, 92, 255, .35)); }
.auth-card { border: 1px solid var(--border); }
.error { color: #fa777c; min-height: 20px; margin-top: 10px; font-size: 14px; }

/* ---------- раскладка ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 240px; background: var(--bg-1); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex: none; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.members { width: 220px; background: var(--bg-1); border-left: 1px solid var(--border); padding: 16px 8px; overflow-y: auto; flex: none; }

.server-header {
  height: 48px; padding: 0 16px; display: flex; align-items: center; font-weight: 700;
  border-bottom: 1px solid var(--border); flex: none;
}
.channels { flex: 1; overflow-y: auto; padding: 8px; }
.cat {
  display: flex; align-items: center; justify-content: space-between; text-transform: uppercase;
  font-size: 12px; font-weight: 700; color: var(--muted); padding: 16px 8px 4px;
}
.cat button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.cat button:hover { color: var(--text); }
.channel {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 4px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.channel:hover { background: var(--bg-3); color: var(--text); }
.channel.active { background: var(--active); color: #fff; }
.channel .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .del { visibility: hidden; background: none; border: 0; color: var(--muted); cursor: pointer; }
.channel:hover .del { visibility: visible; }
.channel .badge { background: var(--red); color: #fff; border-radius: 8px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.voice-members { padding-left: 28px; }
.vm { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 14px; color: var(--muted); }
.vm .avatar { width: 22px; height: 22px; font-size: 11px; }
.vm .icons { margin-left: auto; font-size: 12px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 14px; position: relative; transition: box-shadow .1s;
}
.avatar.speaking { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--green); }
.avatar .dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  border: 3px solid var(--bg-1); background: #80848e;
}
.avatar .dot.on { background: var(--green); }

.voice-panel {
  display: flex; align-items: center; justify-content: space-between; padding: 8px;
  border-top: 1px solid var(--border); background: #08080a; flex: none;
}
.voice-status { color: var(--green); font-weight: 700; font-size: 13px; }
.voice-buttons { display: flex; gap: 2px; }
.user-panel {
  display: flex; align-items: center; gap: 4px; padding: 8px; background: #08080a; border-top: 1px solid var(--border); flex: none;
}
.user-name { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }

.main-header {
  height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px; font-weight: 700;
  border-bottom: 1px solid var(--border); flex: none;
}
.hash { color: var(--muted); font-size: 20px; }
.spacer { flex: 1; }
.mobile-only { display: none; }

/* ---------- чат ---------- */
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0; }
.msg { display: flex; gap: 14px; padding: 4px 16px; position: relative; }
.msg:hover { background: #0c0c0e; }
.msg.cont { padding-top: 1px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; }
.msg .author { font-weight: 600; }
.msg .time { font-size: 11px; color: var(--muted); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .avatar { width: 40px; height: 40px; margin-top: 2px; }
.msg.cont .avatar-slot { width: 40px; flex: none; }
.msg .tools { position: absolute; right: 16px; top: -8px; display: none; background: var(--bg-1); border-radius: 4px; }
.msg:hover .tools { display: block; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.attachments img, .attachments video { max-width: min(400px, 100%); max-height: 300px; border-radius: var(--radius); cursor: zoom-in; display: block; }
.file-card {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--bg-1);
  border: 1px solid var(--bg-0); border-radius: var(--radius); text-decoration: none; color: var(--text); max-width: 360px;
}
.file-card .fname { color: #00a8fc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 16px; border-top: 1px solid var(--bg-3); line-height: 0; }
.day-divider span { background: var(--bg-2); padding: 0 8px; }
.welcome { padding: 16px; }
.welcome h2 { margin: 0 0 4px; }

.typing { height: 20px; padding: 0 16px; }
.composer { padding: 0 16px 20px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; background: #0d0d10; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; }
.composer textarea {
  flex: 1; resize: none; border: 0; background: transparent; outline: none; padding: 6px 4px; max-height: 200px;
}
.composer .btn { padding: 6px 12px; }
.attach { font-size: 20px; }
.pending-files { display: flex; gap: 8px; flex-wrap: wrap; }
.pending-files:not(:empty) { margin-bottom: 8px; }
.pending { background: var(--bg-1); padding: 6px 10px; border-radius: 4px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.pending button { background: none; border: 0; color: var(--muted); cursor: pointer; }

/* ---------- участники ---------- */
.members h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 8px 8px 4px; }
.member { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 4px; }
.member:hover { background: var(--bg-3); }
.member.offline { opacity: .4; }
.member .crown { font-size: 12px; }

/* ---------- голос / видео ---------- */
.voice-view { flex: 1; display: flex; flex-direction: column; padding: 16px; min-height: 0; background: #000; }
.tiles {
  flex: 1; display: grid; gap: 10px; align-content: center; overflow-y: auto;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.tile {
  position: relative; background: var(--bg-1); border-radius: var(--radius); aspect-ratio: 16/9;
  display: grid; place-items: center; overflow: hidden; border: 2px solid transparent;
}
.tile.speaking { border-color: var(--green); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .avatar { width: 80px; height: 80px; font-size: 32px; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 4px; font-size: 13px;
}
.tile .full { position: absolute; right: 8px; top: 8px; opacity: 0; transition: opacity .15s; }
.tile:hover .full { opacity: 1; }
.tile.screen { grid-column: 1 / -1; }
.voice-hint { text-align: center; padding: 8px; }

/* ---------- модальные окна ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; }
.modal-card h2 { margin: 0 0 8px; }
.modal-card .btn { margin-top: 20px; margin-right: 8px; }
hr { border: 0; border-top: 1px solid var(--bg-3); margin: 20px 0 0; }
.meter { height: 8px; background: var(--bg-0); border-radius: 4px; overflow: hidden; margin-top: 16px; }
.meter div { height: 100%; width: 0; background: var(--green); transition: width .05s; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 20; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #232328; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- телефоны ---------- */
@media (max-width: 800px) {
  .members { display: none; position: fixed; right: 0; top: 48px; bottom: 0; z-index: 5; box-shadow: -4px 0 20px rgba(0,0,0,.5); }
  .members.open { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 6; transform: translateX(-100%); transition: transform .2s; width: 280px; }
  .sidebar.open { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.5); }
  .mobile-only { display: inline-grid; }
}
@media (min-width: 801px) {
  .members.closed { display: none; }
}

/* логотип в шапке сервера */
.server-header img { width: 24px; height: 24px; margin-right: 10px; border-radius: 6px; }
.voice-view { background: var(--bg-2); }
.tile { background: #0e0e11; border: 2px solid var(--border); }
.tile.speaking { border-color: var(--green); }
[hidden] { display: none !important; }
.voice-panel > div:first-child { min-width: 0; }
.voice-status { white-space: nowrap; }
#voiceChannelName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
