* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0e1117;
  --panel: #161b26;
  --panel2: #1d2433;
  --line: #2a3245;
  --accent: #7c5cff;
  --accent2: #ff5c9d;
  --text: #e6e9f0;
  --muted: #8b93a7;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1c1430 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.wrap { max-width: 820px; margin: 0 auto; padding: 18px 14px 40px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 2px 18px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 26px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 20px rgba(124, 92, 255, .35);
}
.brand h1 { font-size: 20px; }
.brand p { color: var(--muted); font-size: 13px; }

.top-right { display: flex; align-items: center; gap: 10px; }

.dm-btn {
  position: relative; display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: 12px; cursor: pointer; font-size: 13px;
}
.dm-btn:hover { border-color: var(--accent); }
.dm-ico { font-size: 15px; }
.dm-badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--accent2); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

.now { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #2fd17b; box-shadow: 0 0 10px #2fd17b; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.np-title { font-size: 13.5px; font-weight: 600; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { color: var(--muted); font-size: 11.5px; }

.player { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; }
#audio { width: 100%; height: 44px; }
.streams { margin-top: 12px; display: flex; gap: 8px; }
.stream-btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--muted); font-size: 12.5px; cursor: pointer; text-decoration: none;
}
.stream-btn.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); }

.chat { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.hint { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.users { color: var(--muted); font-weight: 400; font-size: 12.5px; }

.messages { height: 420px; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 2px; }
.msg .head { display: flex; align-items: baseline; gap: 8px; }
.msg .nick { font-weight: 700; font-size: 13px; color: var(--accent); cursor: pointer; }
.msg .nick:hover { text-decoration: underline; }
.msg .time { font-size: 10.5px; color: var(--muted); }
.msg .body { font-size: 14px; line-height: 1.45; word-break: break-word; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me .body { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 8px 12px; border-radius: 14px 14px 3px 14px; }
.msg.them .body { background: var(--panel2); border: 1px solid var(--line); padding: 8px 12px; border-radius: 14px 14px 14px 3px; }
.placeholder { color: var(--muted); text-align: center; margin-top: 40%; font-size: 13.5px; }

#msgform { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
#nick {
  width: 180px; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px;
}
.form-row { display: flex; gap: 10px; }
#text {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 14px; border-radius: 12px; font-size: 14px;
}
#msgform button {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0;
  border-radius: 12px; width: 46px; font-size: 17px; cursor: pointer;
}
#msgform button:hover { filter: brightness(1.1); }
#msgform input:focus { outline: none; border-color: var(--accent); }
.emojis { display: flex; gap: 6px; flex-wrap: wrap; }
.emojis span { cursor: pointer; font-size: 17px; padding: 3px; border-radius: 6px; }
.emojis span:hover { background: var(--panel2); }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding-top: 20px; }

/* ---------- private messages panel ---------- */
.dm-panel {
  position: fixed; inset: 0; background: rgba(5, 8, 14, .72);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.dm-panel.open { display: flex; }

.dm-box {
  width: 100%; max-width: 620px; height: 82vh; max-height: 640px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.dm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.dm-close {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.dm-close:hover { border-color: var(--accent); }

.dm-body { flex: 1; display: flex; min-height: 0; }
.dm-list {
  width: 190px; min-width: 190px; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 8px;
}
.dm-item {
  padding: 9px 10px; border-radius: 9px; cursor: pointer; margin-bottom: 4px;
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.dm-item:hover { background: var(--panel2); }
.dm-item.active { background: var(--panel2); border: 1px solid var(--accent); }
.dm-item-nick { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-item-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent2);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.dm-list .placeholder { margin-top: 20px; }

.dm-thread-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dm-thread {
  flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.pmsg { max-width: 82%; display: flex; flex-direction: column; gap: 2px; }
.pmsg .time { font-size: 10px; color: var(--muted); }
.pmsg .body { font-size: 13.5px; line-height: 1.45; word-break: break-word; }
.pmsg.me { align-self: flex-end; align-items: flex-end; }
.pmsg.them { align-self: flex-start; align-items: flex-start; }
.pmsg.me .body { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 8px 12px; border-radius: 12px 12px 3px 12px; }
.pmsg.them .body { background: var(--panel2); border: 1px solid var(--line); padding: 8px 12px; border-radius: 12px 12px 12px 3px; }
.dm-thread .placeholder { margin-top: 30%; }

#dm-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
#dm-text {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px;
}
#dm-form button {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0;
  border-radius: 10px; width: 42px; font-size: 16px; cursor: pointer;
}
#dm-form button:hover { filter: brightness(1.1); }
#dm-text:focus { outline: none; border-color: var(--accent); }
#dm-form + .emojis { padding: 0 14px 10px; }

/* scrollbar */
.messages::-webkit-scrollbar, .dm-thread::-webkit-scrollbar, .dm-list::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .dm-thread::-webkit-scrollbar-thumb, .dm-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.messages::-webkit-scrollbar-track, .dm-thread::-webkit-scrollbar-track, .dm-list::-webkit-scrollbar-track { background: transparent; }

/* ---------- auth / user / chat switch ---------- */
.auth-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0;
  padding: 9px 16px; border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.auth-btn:hover { filter: brightness(1.1); }

.user-area { display: flex; align-items: center; gap: 8px; }
.user-area .me-nick { font-size: 13px; font-weight: 700; color: var(--accent); }
.auth-link {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; text-decoration: none;
}
.auth-link:hover { color: var(--text); border-color: var(--accent); }

.chat-switch { display: flex; flex-direction: column; gap: 2px; }
.chat-switch label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.chat-switch select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 7px 10px; border-radius: 9px; font-size: 12.5px; max-width: 180px;
}
.chat-switch select:focus { outline: none; border-color: var(--accent); }

/* ---------- auth modal ---------- */
.auth-box { max-width: 400px; height: auto; }
.auth-body { padding: 18px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 9px; border-radius: 10px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 13.5px; font-weight: 600;
}
.auth-tab.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
#login-form, #reg-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input, #reg-form input {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font-size: 14px;
}
#login-form input:focus, #reg-form input:focus { outline: none; border-color: var(--accent); }
.auth-err { color: var(--accent2); font-size: 12.5px; min-height: 16px; }
.auth-submit {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0;
  padding: 12px; border-radius: 11px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.auth-submit:hover { filter: brightness(1.1); }

@media (max-width: 640px) {
  .dm-list { width: 130px; min-width: 130px; }
  .dm-box { height: 88vh; }
  .top-right { width: 100%; justify-content: space-between; }
  .hint { display: none; }
  .chat-switch { order: 10; width: 100%; }
}
