:root {
  --bg: #151821;
  --bg-2: #1b1f2a;
  --bg-3: #232836;
  --line: #2e3444;
  --ink: #f2f4f8;
  --ink-2: #b8c0d0;
  --mute: #8b93a7;
  --brand: #e63b2e;
  --brand-2: #ff6a4d;
  --ok: #2f9e6b;
  --danger: #e05a5a;
  --radius: 14px;
  --font: "Vazirmatn", Tahoma, sans-serif;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(230,59,46,.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(47,158,107,.12), transparent 50%),
    var(--bg);
  color: var(--ink);
}
#app { min-height: 100%; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(35,40,54,.95), rgba(27,31,42,.98));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: rise .45s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.brand p { margin: 4px 0 0; color: var(--mute); font-size: .9rem; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), #9f1f18);
  font-weight: 700; font-size: 1.25rem;
  box-shadow: 0 8px 24px rgba(230,59,46,.35);
}
.brand-mark.sm { width: 32px; height: 32px; border-radius: 10px; font-size: .95rem; }
.stack { display: grid; gap: 10px; }
.stack label { font-size: .85rem; color: var(--ink-2); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: rgba(230,59,46,.55);
  box-shadow: 0 0 0 3px rgba(230,59,46,.15);
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, filter .12s, background .12s;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn.sm { padding: 8px 12px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.msg { min-height: 1.4em; margin: 14px 0 0; color: var(--mute); font-size: .9rem; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

.chat-view {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg-2);
}
.sidebar {
  background: #12151d;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head, .main-head, .composer, .me-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
}
.brand-mini { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1rem;
}
.me-row { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .9rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: .75rem; }
.side-section { padding: 12px 10px; }
.side-section.grow { flex: 1; overflow: auto; min-height: 0; }
.side-section h2 {
  margin: 0 8px 8px; font-size: .72rem; letter-spacing: .08em;
  color: var(--mute); text-transform: uppercase;
}
.channel-list { display: grid; gap: 2px; }
.channel-btn {
  text-align: right; border: 0; background: transparent; color: var(--ink-2);
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font: inherit;
}
.channel-btn:hover { background: var(--bg-3); color: var(--ink); }
.channel-btn.active {
  background: rgba(230,59,46,.14);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand);
}
.online-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.online-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; color: var(--ink-2); font-size: .88rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(47,158,107,.2);
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.main-head h2 { margin: 0; font-size: 1.1rem; }
.topic { margin: 4px 0 0; color: var(--mute); font-size: .85rem; }
.messages {
  flex: 1; overflow: auto; padding: 18px 20px 8px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.msg-row { display: grid; grid-template-columns: 40px 1fr; gap: 10px; animation: fadein .25s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-body { min-width: 0; }
.msg-meta { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.msg-meta .name { font-weight: 600; }
.msg-meta .time { color: var(--mute); font-size: .75rem; }
.msg-text { white-space: pre-wrap; word-break: break-word; line-height: 1.65; color: var(--ink); }
.day-sep {
  align-self: center; color: var(--mute); font-size: .78rem;
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px; margin: 6px 0;
}
.typing { padding: 0 20px 6px; color: var(--mute); font-size: .82rem; min-height: 1.2em; }
.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end;
  border-bottom: 0; border-top: 1px solid var(--line);
  background: #171b25;
}
.composer textarea {
  resize: none; max-height: 140px; min-height: 46px; line-height: 1.5;
}
.composer .send { min-width: 88px; }

@media (max-width: 820px) {
  .chat-view { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px);
    transform: translateX(110%); transition: transform .2s ease; z-index: 20;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
}
[hidden] { display: none !important; }
