/* MuseChat pilot — purple / lilac theme */
:root {
  --bg: #17121f;
  --bg2: #1f1830;
  --panel: #241c38;
  --panel2: #2b2145;
  --line: #3a2d5c;
  --lilac: #b79df5;
  --lilac2: #d3bdfb;
  --purple: #7c4dff;
  --purple-d: #5b34c7;
  --text: #efe9fb;
  --muted: #a793c9;
  --accent: #c9a6ff;
  --danger: #ff7b9c;
  --ok: #7ee2a8;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Quicksand, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #2c1f4d 0%, var(--bg) 55%) fixed;
  color: var(--text); height: 100vh;
}
#app { height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---------- auth ---------- */
.auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; width: 380px; box-shadow: 0 12px 48px rgba(124,77,255,.25);
}
.auth-portrait {
  display: block; width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--purple); box-shadow: 0 0 36px rgba(124,77,255,.55);
  margin: 0 auto 14px;
}
.auth-kicker {
  font-size: 11px; text-transform: uppercase; letter-spacing: .22em;
  color: var(--lilac); margin-bottom: 8px; text-align: center;
}
.auth-card h1 { margin: 0 0 4px; color: var(--lilac2); font-size: 26px; text-align: center; }
.auth-card p.sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; text-align: center; }
.auth-card p.sub a { color: var(--lilac2); text-decoration: none; font-weight: 600; }
.auth-card p.sub a:hover { color: #fff; text-decoration: underline; }
.auth-card .field { text-align: left; }
#auth-back { margin-top: 10px; width: 100%; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
}
.tabs button.active { background: var(--purple); border-color: var(--purple); color: #fff; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 15px;
}
.field textarea { resize: vertical; font-family: monospace; font-size: 13px; }
/* presence status */
.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sdot.online { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.7); }
.sdot.busy { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,.7); }
.sdot.offline { background: #6b7280; }
.status-line {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: fit-content; margin: 12px auto 22px; padding: 7px 16px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 13px;
}
.profile-card h1 { margin-bottom: 2px; }
.prof-links { margin-top: 2px; }
.peer-status { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.field .hint { color: var(--muted); font-weight: normal; }
.btn {
  width: 100%; padding: 11px; border: 0; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--purple-d)); color: #fff;
  font-size: 15px; font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--lilac); }
.btn.small { width: auto; padding: 6px 12px; font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0; }
.profiles { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.profiles h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }
.profile-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: 8px; background: var(--bg2); margin-bottom: 6px; font-size: 14px;
}
.profile-row button { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 12px; }

/* ---------- main layout ---------- */
.shell { display: flex; width: 100%; height: 100vh; max-width: 1200px; margin: 0 auto; }
.sidebar {
  width: 320px; min-width: 280px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head { padding: 14px; border-bottom: 1px solid var(--line); }
.side-head .me { display: flex; align-items: center; justify-content: space-between; }
.side-head .me .handle { font-weight: 700; color: var(--lilac2); font-size: 16px; }
.credits {
  margin-top: 8px; font-size: 13px; color: var(--muted); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.credits b { color: var(--accent); }
.side-search { padding: 10px 14px 0; }
.side-search input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 14px;
}
.side-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.side-section { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 10px 14px 4px; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer;
  border-left: 3px solid transparent;
}
.row:hover { background: var(--panel2); }
.row.active { background: var(--panel2); border-left-color: var(--purple); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple), var(--lilac));
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff;
}
img.avatar { object-fit: cover; padding: 0; }
/* ---------- profile ---------- */
.chat-peer { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.chat-peer:hover .name { text-decoration: underline; }
.profile-card { width: 420px; max-height: 92vh; overflow-y: auto; }
.profile-card h1 { overflow-wrap: anywhere; }
.prof-avatar-wrap { display: flex; justify-content: center; margin: 6px 0 10px; }
.profile-card .prof-avatar-wrap .auth-portrait { width: 168px; height: 168px; }
.auth-portrait.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--lilac));
}
.profile-card .bio {
  color: var(--text); font-size: 14px; text-align: center;
  margin: 0 0 16px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.prof-links { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; flex-wrap: wrap; }
.prof-links a { text-decoration: none; }
.profile-card textarea { width: 100%; box-sizing: border-box; }
#prof-back { display: block; margin: 0 0 6px; }
.row .name { font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.badge {
  background: var(--purple); color: #fff; font-size: 11px; border-radius: 10px;
  padding: 1px 8px; font-weight: 700;
}
.time { font-size: 11px; color: var(--muted); }
.req-actions { display: flex; gap: 6px; }
.req-actions button { border: 0; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.accept { background: var(--purple); color: #fff; }
.decline { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px; }
.icon-btn:hover { color: var(--lilac2); }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; background: var(--bg2); min-width: 0; }
.chat-head {
  padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 10px; background: var(--panel);
}
.chat-head .name { font-weight: 700; font-size: 16px; color: var(--lilac2); flex: 1; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 70%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4;
  background: var(--panel2); border: 1px solid var(--line); word-break: break-word;
}
.msg.mine .bubble { background: linear-gradient(135deg, var(--purple), var(--purple-d)); border: 0; color: #fff; }
.bubble img { max-width: 240px; border-radius: 8px; display: block; margin: 4px 0; cursor: pointer; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.read { color: var(--lilac); }
.reactions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.react {
  font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 1px 8px; cursor: pointer; color: var(--text);
}
.react.mine { border-color: var(--purple); }
.react-btn { background: none; border: 0; cursor: pointer; font-size: 13px; color: var(--muted); }
.typing-ind { font-size: 12px; color: var(--lilac); font-style: italic; padding: 0 18px 6px; min-height: 20px; }
.composer { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel); position: relative; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 14px; max-height: 120px; font-family: inherit;
}
.send-btn {
  border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  background: linear-gradient(135deg, var(--purple), var(--purple-d)); color: #fff; font-weight: 600;
}
.attach-preview { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.attach-preview img { height: 64px; border-radius: 8px; border: 1px solid var(--line); }
.emoji-pop {
  position: absolute; bottom: 64px; left: 18px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5); z-index: 10;
}
.emoji-pop button { background: none; border: 0; font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; }
.emoji-pop button:hover { background: var(--line); }
.empty-chat { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; }

/* ---------- modal / toast ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,6,20,.7); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 340px; }
.modal h2 { margin: 0 0 10px; color: var(--lilac2); font-size: 18px; }
.modal .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-family: inherit; font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--purple); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; display: none;
}
.stake-note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; padding: 8px 12px 0; }
.tab {
  flex: 1; padding: 8px; border-radius: 10px 10px 0 0; border: 1px solid var(--line);
  border-bottom: 0; background: var(--bg2); color: var(--muted); cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--panel); color: var(--lilac2); font-weight: 700; }

/* ---------- lobby ---------- */
.lobby { flex: 1; overflow-y: auto; padding: 20px; }
.lobby-inner { max-width: 640px; margin: 0 auto; }
.lobby h2 { color: var(--lilac2); margin: 0 0 14px; }
.lobby-sec { margin: 18px 0; }
.lobby-sec h3 { font-size: 15px; color: var(--text); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.lobby-list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.stat-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-card {
  flex: 1 1 100px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; text-align: center;
}
.stat-card b { display: block; font-size: 22px; color: var(--lilac2); }
.stat-card span { font-size: 12px; color: var(--muted); }
.msg-sender { font-size: 11px; color: var(--lilac2); font-weight: 700; margin-bottom: 2px; }
.group-av { display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--bg2); }
.pick { display: flex; align-items: center; gap: 8px; cursor: pointer; width: 100%; }
.pick input { width: 16px; height: 16px; accent-color: var(--purple); }
.code-box {
  background: var(--bg2); border: 1px dashed var(--purple); border-radius: 10px;
  padding: 14px; margin: 12px 0; word-break: break-all; text-align: center;
}
.code-box code { font-size: 15px; color: var(--lilac2); }
.holder-badge {
  font-size: 11px; background: var(--bg2); border: 1px solid var(--purple); color: var(--lilac2);
  border-radius: 20px; padding: 2px 8px; margin-left: 6px; white-space: nowrap;
}
.holder-note {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; color: var(--muted); font-size: 13px; margin-bottom: 12px;
}
.btn.danger { background: #5b1f2a; border-color: #8a3040; color: #ffd7dd; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.req-actions { display: flex; gap: 6px; margin-left: auto; }
.req-actions .accept, .req-actions .decline {
  border: 0; border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.req-actions .accept { background: var(--purple); color: #fff; }
.req-actions .decline { background: var(--bg2); color: var(--muted); }
.lobby-list a { color: var(--lilac2); text-decoration: none; }
.lobby-list a:hover { text-decoration: underline; }
@media (max-width: 720px) {
  .stat-cards { gap: 8px; }
  .stat-card { flex: 1 1 45%; }
}

/* ---------- mini icons (no emojis in UI) ---------- */
.ico { width: 24px; height: 24px; border-radius: 6px; vertical-align: middle; }
.ico-xs { width: 15px; height: 15px; border-radius: 4px; vertical-align: -2px; }
.tab-ico { width: 18px; height: 18px; border-radius: 5px; vertical-align: -3px; }
.h-ico { width: 24px; height: 24px; border-radius: 6px; vertical-align: -4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; display: inline-block; }
.icon-btn .ico { display: block; }
.holder-badge .ico-xs { margin-right: 2px; }
.holder-note .ico-xs { margin-right: 4px; }
.btn .ico-xs { margin-right: 4px; }

/* ---------- sidebar footer (logout, bottom-left) ---------- */
.side-foot {
  padding: 10px 14px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-start; align-items: center;
}
.side-foot .icon-btn { opacity: .75; }
.side-foot .icon-btn:hover { opacity: 1; }
.side-foot .icon-btn.soon { cursor: default; opacity: .45; }
.side-foot .icon-btn.soon:hover { opacity: .45; }

/* ---------- group info ---------- */
.group-head { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; }
.group-photo { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; background: var(--bg2); }
