/* Relay — deep-harbor dark palette with amber signal accent */
:root {
  --bg-0: #0f131d;   /* rail */
  --bg-1: #141824;   /* sidebar / members */
  --bg-2: #1b2130;   /* chat */
  --bg-3: #232b3d;   /* hover / inputs */
  --line: #2b3348;
  --text: #e7ebf2;
  --text-dim: #8a93a6;
  --accent: #e8a33d; /* amber signal */
  --accent-ink: #1a1204;
  --online: #5bb98c;
  --danger: #e5484d;
  --radius: 10px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg-2);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ brand ============ */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-family: var(--font-display); font-size: 30px; margin: 0; letter-spacing: 0.5px; }
.brand-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at center, var(--bg-0) 0 34%, var(--accent) 35% 100%);
  animation: pulse 2.4s ease-in-out infinite;
}
.brand-dot.small { width: 20px; height: 20px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(232, 163, 61, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-dot { animation: none; }
}

/* ============ auth ============ */
.auth-screen {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(232,163,61,0.08), transparent 60%),
    var(--bg-0);
}
.auth-card {
  width: min(400px, calc(100vw - 32px));
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
}
.auth-sub { color: var(--text-dim); margin: 10px 0 22px; font-size: 14px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; padding: 8px 0; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--text-dim);
}
.auth-tab.active { background: var(--bg-3); color: var(--text); border-color: var(--bg-3); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .modal input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-0);
  color: var(--text); font-size: 15px;
}
.field input:focus, .modal input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.btn-primary {
  width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-family: var(--font-display); font-size: 15px; letter-spacing: 0.02em;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ============ app layout ============ */
.app {
  display: grid;
  grid-template-columns: 72px 240px 1fr auto;
  height: 100vh;
}

/* rail */
.rail {
  background: var(--bg-0);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 10px; overflow-y: auto;
}
.rail-item {
  width: 46px; height: 46px; border-radius: 50%;
  border: none; background: var(--bg-3); color: var(--text);
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: border-radius 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}
.rail-item:hover, .rail-item.active { border-radius: 14px; background: var(--accent); color: var(--accent-ink); }
.rail-home { background: var(--bg-1); }
.rail-home:hover, .rail-home.active { background: var(--bg-3); }
.rail-add { color: var(--accent); font-size: 22px; background: transparent; border: 1px dashed var(--line); }
.rail-add:hover { border-radius: 50%; background: var(--bg-3); color: var(--accent); }
.rail-sep { width: 28px; height: 1px; background: var(--line); flex-shrink: 0; }
#rail-guilds { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* sidebar */
.sidebar {
  background: var(--bg-1);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.sidebar-head {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-body { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); padding: 10px 8px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.side-label button { background: none; border: none; color: var(--text-dim); font-size: 16px; padding: 0 4px; }
.side-label button:hover { color: var(--accent); }
.chan {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px;
  border: none; background: none; color: var(--text-dim); font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chan:hover { background: var(--bg-3); color: var(--text); }
.chan.active { background: var(--bg-3); color: var(--text); }
.chan .hash { color: var(--accent); opacity: 0.7; font-family: var(--font-display); }
.chan .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.chan .dot.on { background: var(--online); }

/* voice channels */
.chan .speaker { color: var(--online); opacity: 0.8; font-size: 13px; }
.voice-roster { padding: 0 0 4px 26px; }
.voice-user {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 8px; border-radius: 6px;
  color: var(--text-dim); font-size: 13px;
}
.voice-user .avatar { width: 20px; height: 20px; font-size: 9px; }
.voice-user.speaking .avatar { box-shadow: 0 0 0 2px var(--online); }
.voice-user .muted-mark { margin-left: auto; font-size: 11px; opacity: 0.7; }

/* voice bar */
.voice-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--line);
  background: var(--bg-0);
}
.voice-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.voice-status { color: var(--online); font-size: 12px; font-weight: 600; }
.voice-status.connecting { color: var(--accent); }
.voice-chan { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-leave:hover { color: var(--danger); }
#btn-mute.muted { color: var(--danger); }

/* me bar */
.me-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-0);
}
.me-name { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: none; border: none; color: var(--text-dim); font-size: 16px;
  padding: 4px 6px; border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: var(--bg-3); }

/* avatar */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; font-family: var(--font-display);
}

/* chat */
.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.chat-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.chat-invite { color: var(--text-dim); font-size: 12px; flex: 1; user-select: all; }
.messages { flex: 1; overflow-y: auto; padding: 18px 18px 8px; }
.msg { display: flex; gap: 12px; padding: 3px 0; }
.msg.group-start { margin-top: 14px; }
.msg .avatar { margin-top: 2px; }
.msg .spacer { width: 34px; flex-shrink: 0; }
.msg-body { min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; font-size: 15px; }
.msg-time { color: var(--text-dim); font-size: 11px; }
.msg-text { font-size: 15px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; color: #d6dbe6; }
.load-more {
  display: block; margin: 0 auto 12px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--text-dim); font-size: 12px;
}
.load-more:hover { color: var(--accent); border-color: var(--accent); }

/* empty state */
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-dim); padding: 20px; }
.empty-state h2 { font-family: var(--font-display); color: var(--text); margin: 18px 0 6px; }
.empty-state p { max-width: 380px; font-size: 14px; line-height: 1.5; margin: 0; }
.empty-mark {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at center, var(--bg-2) 0 34%, var(--accent) 35% 100%);
  opacity: 0.9;
}

/* typing + composer */
.typing { min-height: 20px; padding: 0 20px; font-size: 12px; color: var(--text-dim); font-style: italic; }
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 0 16px 16px;
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-3);
  color: var(--text); font: inherit; font-size: 15px; line-height: 1.4;
}
.composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.send-btn {
  border: none; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  width: 44px; height: 44px; font-size: 16px; flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.08); }

/* members */
.members {
  width: 220px; background: var(--bg-1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.members-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); padding: 16px 16px 8px;
}
.members-body { overflow-y: auto; padding: 4px 8px 12px; }
.member {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: none; text-align: left;
  padding: 6px 8px; border-radius: 8px; color: var(--text);
}
.member:hover { background: var(--bg-3); }
.member .m-name { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member.offline { opacity: 0.45; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.status-dot.on { background: var(--online); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 10, 16, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: min(380px, calc(100vw - 32px));
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px;
}
.modal h3 { font-family: var(--font-display); margin: 0 0 16px; }
.modal .field { margin-bottom: 16px; }
.modal-row { display: flex; gap: 10px; margin-top: 8px; }
.modal-row .btn-primary { flex: 1; }
.btn-ghost {
  flex: 1; padding: 11px; border-radius: 8px;
  border: 1px solid var(--line); background: none; color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.modal-or { text-align: center; color: var(--text-dim); font-size: 12px; margin: 14px 0; text-transform: uppercase; letter-spacing: 0.08em; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ responsive ============ */
.members-toggle { display: none; }
@media (max-width: 980px) {
  .members { display: none; }
  .members.open { display: flex; position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: -8px 0 30px rgba(0,0,0,0.4); }
  .members-toggle { display: block; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 60px 180px 1fr; }
  .rail-item { width: 40px; height: 40px; }
}
