:root {
  --bg-main: #313338;
  --bg-sidebar: #2b2d31;
  --bg-server: #1e1f22;
  --bg-hover: #35373c;
  --bg-active: #404249;
  --text: #f2f3f5;
  --text-muted: #949ba4;
  --text-dim: #80848e;
  --accent: #5865f2;
  --link: #00a8fc;
  --mention: #5865f2;
  --mention-bg: rgba(88, 101, 242, 0.15);
  --border: #1e1f22;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "gg sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.guild-header {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.channels { flex: 1; overflow-y: auto; padding: 8px 0; }
.channels::-webkit-scrollbar { width: 6px; }
.channels::-webkit-scrollbar-thumb { background: #202225; border-radius: 3px; }
.category {
  padding: 16px 8px 4px 16px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.channel-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 20px;
  margin: 1px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.channel-link.active { background: var(--bg-active); color: var(--text); }
.channel-link .hash { color: var(--text-dim); font-weight: 400; }

/* ---------- Main ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.ch-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  font-weight: 600;
  min-height: 48px;
}
.ch-header .hash { color: var(--text-muted); }
.ch-header .ch-name { color: var(--text); font-weight: 600; }
.ch-header .ch-topic {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.filters select, .filters input[type="search"], .filters input[type="number"] {
  background: var(--bg-server);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.filters input[type="search"] { width: 260px; }
.filters button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.filters button:hover { background: #4752c4; }
.filters .reset { font-size: 13px; color: var(--text-muted); }
.filters .stats { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 24px 0;
}
.pager-top, .pager-bottom {
  text-align: center;
  padding: 8px 0;
}
.pager-top a, .pager-bottom a {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-hover);
  border-radius: 4px;
  font-size: 13px;
}

.msg-group {
  display: flex;
  gap: 16px;
  padding: 8px 16px 2px 16px;
  margin-top: 12px;
}
.msg-group:hover { background: rgba(4,4,5,0.07); }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: 0 0 40px;
  margin-top: 2px;
  background: var(--bg-server);
}
.msg-group-body { flex: 1; min-width: 0; }
.msg-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.author-name {
  font-weight: 500;
  font-size: 15px;
}
.msg-ts {
  color: var(--text-muted);
  font-size: 12px;
}
.msg {
  padding: 1px 0;
  position: relative;
}
.msg-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-content code {
  background: var(--bg-server);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
  font-family: "JetBrains Mono", Consolas, monospace;
}
.msg-edited {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}
.mention {
  color: var(--mention);
  background: var(--mention-bg);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
}
.emoji {
  width: 20px;
  height: 20px;
  vertical-align: -0.2em;
  margin: 0 1px;
}

.reply-ref {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 14px;
  margin-bottom: 2px;
  font-size: 13px;
  color: var(--text-muted);
  position: relative;
}
.reply-ref::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--text-dim);
  border-top: 2px solid var(--text-dim);
  border-top-left-radius: 4px;
}
.reply-author { color: var(--text); font-weight: 500; }
.reply-content {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}

.attachments {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 520px;
}
.attach-img {
  max-width: 400px;
  max-height: 300px;
  border-radius: 4px;
  background: var(--bg-server);
}
.attach-file {
  display: inline-block;
  background: var(--bg-sidebar);
  padding: 8px 12px;
  border-radius: 4px;
  max-width: 400px;
}
.muted { color: var(--text-muted); font-size: 12px; }

.reactions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.reaction {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Pager ---------- */
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.pager a { color: var(--link); }
.pager .jump input[type="number"] {
  width: 80px;
  background: var(--bg-server);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 6px;
  border-radius: 3px;
}
.pager .jump button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.empty {
  padding: 40px;
  color: var(--text-muted);
  text-align: center;
}
