/* ================= Team Chat — dark theme ================= */

:root {
  --bg: #1a1d21;
  --bg-raised: #222529;
  --bg-sidebar: #19171d;
  --bg-sidebar-raised: #27242c;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: #1164a3;
  --border: #35373b;
  --border-soft: #2c2e33;
  --text: #d1d2d3;
  --text-bright: #ffffff;
  --text-muted: #9a9b9e;
  --text-faint: #6f7176;
  --accent: #1d9bd1;
  --accent-strong: #1164a3;
  --green: #2bac76;
  --red: #e0245e;
  --badge: #cd2553;
  --mention-bg: rgba(250, 168, 60, 0.14);
  --mention-fg: #efb662;
  --mention-me-bg: rgba(29, 155, 209, 0.22);
  --mention-me-fg: #6fc0e8;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-bright);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  width: 100%;
}

input:focus, textarea:focus { border-color: var(--accent); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3d4046; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= Auth ================= */

.auth-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 20% -10%, rgba(29, 155, 209, 0.12), transparent 60%),
    radial-gradient(800px 500px at 90% 110%, rgba(205, 37, 83, 0.09), transparent 60%),
    var(--bg-sidebar);
}

.auth-card {
  width: min(400px, calc(100vw - 40px));
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.auth-logo { font-size: 40px; }

.auth-brand {
  margin: 8px 0 4px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}

.auth-hint { margin: 0 0 22px; color: var(--text-muted); font-size: 14px; }

.auth-card form { text-align: left; }

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-label em { font-style: normal; text-transform: none; font-weight: 400; }

.auth-error {
  background: rgba(224, 36, 94, 0.12);
  border: 1px solid rgba(224, 36, 94, 0.4);
  color: #ff8aae;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius);
  padding: 10px 16px;
  transition: filter 0.12s;
}

.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.auth-switch { margin: 18px 0 0; font-size: 13.5px; color: var(--text-muted); }

.link-btn { color: var(--accent); font-size: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ================= App layout ================= */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #000;
}

.ws-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--bg-sidebar-raised);
}

.ws-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}

.ws-me {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.me-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--text-faint);
  flex: none;
}

.presence-dot.online { background: var(--green); border-color: var(--green); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 0 16px; }

.side-section { margin-bottom: 18px; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}

.channel-list, .member-list, .notif-list { list-style: none; margin: 0; padding: 0; }

.channel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 16px;
  cursor: pointer;
  color: var(--text-muted);
  border-left: 3px solid transparent;
}

.channel-item:hover { background: var(--bg-hover); }

.channel-item.active {
  background: var(--bg-active);
  color: #fff;
  border-left-color: var(--accent);
}

.channel-item.unread { color: var(--text-bright); font-weight: 700; }

.channel-hash { color: inherit; opacity: 0.75; flex: none; }

.channel-name-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  background: var(--badge);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 19px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 6px;
  flex: none;
}

.channel-item .join-hint {
  font-size: 11.5px;
  color: var(--accent);
  opacity: 0;
  flex: none;
}

.channel-item:hover .join-hint { opacity: 1; }

.browse-empty, .member-empty {
  padding: 4px 16px;
  color: var(--text-faint);
  font-size: 13px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.member-item .you { color: var(--text-faint); font-size: 12px; }

.conn-status {
  padding: 8px 16px;
  font-size: 12.5px;
  color: #ffcf70;
  background: rgba(250, 168, 60, 0.09);
  border-top: 1px solid var(--bg-sidebar-raised);
}

/* ---------- Main pane ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 56px;
}

.chan-id { min-width: 0; }

.chan-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chan-topic {
  margin: 1px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chan-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-bright); }

.ghost-btn {
  color: var(--text-muted);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.ghost-btn:hover { color: var(--text-bright); border-color: var(--text-faint); }

.btn-small {
  background: var(--accent-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
}

.btn-small:hover { filter: brightness(1.15); }

/* Bell + notifications */

.bell-wrap { position: relative; }

.bell { position: relative; width: 32px; height: 32px; }

.bell-count {
  position: absolute;
  top: -3px;
  right: -5px;
  background: var(--badge);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  text-align: center;
  border: 2px solid var(--bg);
}

.notif-dropdown {
  position: absolute;
  top: 40px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: 60;
  overflow: hidden;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 700;
  color: var(--text-bright);
  font-size: 14px;
}

.notif-head .link-btn { font-size: 12.5px; font-weight: 400; }

.notif-list { max-height: 380px; overflow-y: auto; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex: none;
}

.notif-item.read .notif-dot { background: transparent; }

.notif-body { min-width: 0; flex: 1; }

.notif-title { font-size: 13.5px; color: var(--text); }
.notif-title b { color: var(--text-bright); }

.notif-snippet {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.notif-time { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.notif-empty { padding: 22px 14px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* Push banner */

.push-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 18px 0;
  padding: 10px 14px;
  background: rgba(29, 155, 209, 0.08);
  border: 1px solid rgba(29, 155, 209, 0.3);
  border-radius: 10px;
  font-size: 13.5px;
}

.push-banner-actions { display: flex; gap: 8px; }

/* ---------- Messages ---------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 8px;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 0 24px;
}

.empty-emoji { font-size: 44px; margin-bottom: 8px; }
.empty-state h3 { color: var(--text-bright); margin: 0 0 6px; }
.empty-state p { margin: 0; max-width: 380px; }

.load-older-wrap { text-align: center; padding: 4px 0 10px; }

.load-older {
  color: var(--accent);
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.load-older:hover { background: var(--bg-hover); }

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 18px 6px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
}

.day-divider::before, .day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.msg {
  display: flex;
  gap: 10px;
  padding: 3px 18px;
}

.msg:hover { background: var(--bg-hover); }

.msg.first { margin-top: 8px; }

.msg.flash { animation: flash 2s ease-out; }

@keyframes flash {
  0%, 40% { background: rgba(250, 168, 60, 0.16); }
  100% { background: transparent; }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  user-select: none;
}

.msg-gutter {
  width: 36px;
  flex: none;
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: right;
  padding-top: 3px;
  opacity: 0;
}

.msg:hover .msg-gutter { opacity: 1; }

.msg-body { min-width: 0; flex: 1; }

.msg-meta { display: flex; align-items: baseline; gap: 8px; }

.msg-author { font-weight: 800; color: var(--text-bright); font-size: 14.5px; }

.msg-time { font-size: 11.5px; color: var(--text-faint); }

.msg-content {
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.mention {
  background: var(--mention-bg);
  color: var(--mention-fg);
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 600;
}

.mention-me { background: var(--mention-me-bg); color: var(--mention-me-fg); }

.thread-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--accent);
}

.thread-chip:hover { background: var(--bg-raised); border-color: var(--accent); }

.thread-chip .chip-time { color: var(--text-faint); }

.reply-in-thread {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-faint);
  opacity: 0;
}

.msg:hover .reply-in-thread { opacity: 1; }
.reply-in-thread:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Composer ---------- */

.composer { padding: 0 18px 14px; }

.thread-composer { padding: 0 14px 12px; }

.composer-box {
  position: relative;
  display: flex;
  align-items: flex-end;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.12s;
}

.composer-box:focus-within { border-color: var(--text-faint); }

.composer-input {
  border: none;
  background: transparent;
  resize: none;
  max-height: 180px;
  padding: 11px 12px;
  line-height: 1.4;
}

.composer-input:focus { border: none; }

.send-btn {
  flex: none;
  margin: 0 8px 8px 0;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-strong);
  color: #fff;
}

.send-btn:hover { filter: brightness(1.15); }

.composer-hint {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: right;
}

/* Mention autocomplete */

.mention-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-width: 320px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  z-index: 50;
}

.mention-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
}

.mention-opt.selected { background: var(--bg-active); color: #fff; }

.mention-opt .mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  flex: none;
}

/* ---------- Thread panel ---------- */

.thread-panel {
  width: 380px;
  min-width: 320px;
  border-left: 1px solid var(--border-soft);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.16s ease-out;
}

@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0.4; }
  to { transform: translateX(0); opacity: 1; }
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  min-height: 56px;
}

.thread-head h3 { margin: 0; font-size: 15.5px; color: var(--text-bright); }

.thread-chan { font-size: 12.5px; color: var(--text-muted); }

.thread-scroll { flex: 1; overflow-y: auto; padding: 10px 0; }

.thread-scroll .msg { padding: 3px 14px; }

.thread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 14px;
  font-size: 12px;
  color: var(--text-faint);
}

.thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  width: min(440px, calc(100vw - 40px));
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal h3 { margin: 0 0 16px; color: var(--text-bright); font-size: 18px; }

.hash-input { position: relative; }

.hash-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-weight: 700;
}

.hash-input input { padding-left: 26px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .btn-primary { width: auto; padding: 9px 18px; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .thread-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 80;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
}

@media (max-width: 640px) {
  .sidebar { width: 200px; min-width: 200px; }
  .composer-hint { display: none; }
}
