:root {
  --bg: #100a1f;
  --bg2: #18122d;
  --panel: #1f1738;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f1ff;
  --muted: #a89bc8;
  --pink: #ff6b9d;
  --violet: #8b6cff;
  --mint: #2ee9a6;
  --gold: #ffc857;
  --sky: #4cc9f0;
  --danger: #ff5d73;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(8, 2, 24, 0.45);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Manrope, system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at -10% -10%, rgba(139, 108, 255, 0.28), transparent 55%),
    radial-gradient(900px 500px at 110% 0%, rgba(255, 107, 157, 0.22), transparent 50%),
    radial-gradient(700px 400px at 80% 110%, rgba(46, 233, 166, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.auth-glow {
  position: absolute; inset: 15% 20%;
  background: radial-gradient(circle, rgba(139,108,255,.35), transparent 70%);
  filter: blur(40px); pointer-events: none;
}
.auth-card {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(36, 26, 64, 0.92), rgba(22, 16, 40, 0.92));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
}
.logo-mark {
  width: 52px; height: 52px; border-radius: 18px;
  background: linear-gradient(135deg, var(--pink), var(--violet) 55%, var(--sky));
  display: grid; place-items: center; gap: 3px;
  box-shadow: 0 10px 24px rgba(139, 108, 255, 0.35);
}
.logo-mark span {
  display: block; height: 3px; border-radius: 99px; background: #fff;
}
.logo-mark span:nth-child(1) { width: 22px; }
.logo-mark span:nth-child(2) { width: 16px; opacity: .8; }
.logo-mark span:nth-child(3) { width: 10px; opacity: .6; }
.logo-mark.sm { width: 36px; height: 36px; border-radius: 12px; }
.logo-mark.lg { width: 72px; height: 72px; border-radius: 24px; margin: 0 auto 12px; }
.auth-card h1, .brand strong, .empty h2, .thread-head h2 {
  font-family: Sora, Manrope, sans-serif;
  letter-spacing: -0.03em;
}
.auth-card h1 { margin: 16px 0 6px; font-size: 32px; }
.tag, .hint, .muted { color: var(--muted); }
.tag { margin: 0 0 20px; line-height: 1.45; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; border: 0; background: rgba(255,255,255,.06);
  border-radius: 999px; padding: 10px; color: var(--muted);
}
.tab.on {
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: #fff; font-weight: 700;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0; }
input, textarea, .search {
  width: 100%;
  background: rgba(8, 4, 20, 0.45);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus, .search:focus {
  border-color: rgba(139, 108, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(139, 108, 255, 0.15);
}
.hint { font-size: 13px; line-height: 1.4; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 700;
}
.btn.primary, .btn.send {
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: #fff; width: 100%; margin-top: 12px;
}
.btn.send { width: 48px; height: 48px; margin: 0; border-radius: 16px; font-size: 18px; }
.btn.ghost {
  background: rgba(255,255,255,.06);
  color: var(--text); font-weight: 600; font-size: 13px;
}
.btn.danger { background: var(--danger); color: #fff; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.06);
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr;
}
.sidebar {
  background: rgba(18, 12, 36, 0.72);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  backdrop-filter: blur(16px);
}
.side-head, .thread-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; flex: 1; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px 0; }
.search { width: auto; margin: 12px 14px; }
.chat-list { overflow: auto; padding: 6px; flex: 1; }
.chat-item {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 10px;
  align-items: center; padding: 10px; border-radius: 16px; border: 0;
  background: transparent; width: 100%; text-align: left;
}
.chat-item:hover { background: rgba(255,255,255,.05); }
.chat-item.on { background: linear-gradient(90deg, rgba(255,107,157,.18), rgba(139,108,255,.16)); }
.chat-item b { display: block; font-size: 14px; }
.chat-item span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-dot { font-size: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800;
  color: #120816; letter-spacing: -0.04em;
}
.avatar.sm { width: 28px; height: 28px; border-radius: 10px; font-size: 12px; }

.main { position: relative; min-width: 0; display: flex; flex-direction: column; }
.empty {
  margin: auto; text-align: center; max-width: 420px; padding: 24px; color: var(--muted);
}
.empty h2 { color: var(--text); margin: 0 0 8px; }
.thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.grow { flex: 1; min-width: 0; }
.thread-head h2 { margin: 0; font-size: 18px; }
.avatars { display: flex; }
.avatars .avatar { margin-left: -8px; border: 2px solid var(--bg); }
.avatars .avatar:first-child { margin-left: 0; }
.topics {
  display: flex; gap: 8px; overflow: auto; padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.chip {
  border: 0; border-radius: 999px; padding: 7px 12px;
  background: rgba(255,255,255,.06); color: var(--text); white-space: nowrap; font-size: 13px;
}
.chip.on { background: linear-gradient(90deg, var(--mint), var(--sky)); color: #081016; font-weight: 700; }
.pins-bar {
  margin: 8px 14px 0; padding: 8px 12px; border-radius: 14px;
  background: linear-gradient(90deg, rgba(255,200,87,.14), rgba(139,108,255,.1));
  border: 1px solid rgba(255,200,87,.2);
  font-size: 13px;
}
.messages {
  flex: 1; overflow: auto; padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.day {
  align-self: center; font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,.05); padding: 4px 10px; border-radius: 99px; margin: 6px 0;
}
.row { display: flex; gap: 8px; max-width: min(720px, 92%); }
.row.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  padding: 9px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.row.mine .bubble {
  background: linear-gradient(180deg, rgba(255,107,157,.22), rgba(139,108,255,.18));
  border-color: rgba(255,107,157,.2);
  border-radius: 18px 18px 6px 18px;
}
.who { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.reply-quote {
  border-left: 3px solid var(--gold);
  padding: 4px 8px; margin-bottom: 6px;
  color: var(--muted); font-size: 12px; background: rgba(0,0,0,.15); border-radius: 0 8px 8px 0;
}
.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.meta { margin-top: 4px; font-size: 11px; color: var(--muted); display: flex; gap: 8px; }
.deleted { font-style: italic; color: var(--muted); }
.media img, .media video {
  display: block; max-width: min(360px, 70vw); max-height: 320px;
  border-radius: 12px; margin-top: 6px;
}
.file-link {
  display: inline-flex; gap: 8px; align-items: center;
  margin-top: 6px; padding: 8px 10px; border-radius: 12px;
  background: rgba(255,255,255,.06); color: var(--text); text-decoration: none;
}
.reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.react {
  border: 0; border-radius: 99px; padding: 2px 7px;
  background: rgba(255,255,255,.08); font-size: 12px;
}
.react.mine { outline: 1px solid var(--pink); }
.hover-actions {
  display: none; gap: 4px; align-self: center;
}
.row:hover .hover-actions { display: flex; }
.typing { padding: 0 20px 6px; color: var(--mint); font-size: 13px; min-height: 22px; }
.reply-bar, .composer {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px 12px;
}
.reply-bar {
  background: rgba(255,200,87,.08);
  border-top: 1px solid var(--line);
  justify-content: space-between;
}
.reply-bar span { color: var(--muted); margin-left: 8px; }
.composer { border-top: 1px solid var(--line); background: rgba(16,10,31,.65); }
.compose-box { flex: 1; background: rgba(8,4,20,.45); border: 1px solid var(--line); border-radius: 16px; padding: 6px 10px; }
.compose-box textarea {
  border: 0; background: transparent; resize: none; width: 100%;
  max-height: 140px; padding: 6px 0; outline: none; box-shadow: none;
}
.file-chip { font-size: 12px; color: var(--gold); padding: 4px 0; }

.modal {
  position: fixed; inset: 0; background: rgba(6, 2, 16, .62);
  display: grid; place-items: center; padding: 16px; z-index: 20;
}
.modal-card {
  width: min(460px, 100%);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 12px; font-family: Sora, sans-serif; }
.pick-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.pick {
  display: flex; gap: 10px; align-items: center;
  background: rgba(255,255,255,.04); border: 0; border-radius: 12px;
  padding: 8px; text-align: left; width: 100%;
}
.pick.on { outline: 1px solid var(--violet); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.sheet {
  position: fixed; z-index: 15;
  background: #241a42; border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; min-width: 160px;
  box-shadow: var(--shadow);
}
.sheet button {
  display: block; width: 100%; text-align: left; border: 0;
  background: transparent; padding: 8px 10px; border-radius: 10px;
}
.sheet button:hover { background: rgba(255,255,255,.06); }

.only-mobile { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 5; }
  .app.chat-open .sidebar { display: none; }
  .only-mobile { display: grid; place-items: center; }
}
