*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-darkest: #202225;
  --bg-sidebar: #2f3136;
  --bg-main: #36393f;
  --bg-hover: #3a3d44;
  --bg-active: #393c43;
  --bg-input: #40444b;
  --bg-embed: #2f3136;
  --text-primary: #dcddde;
  --text-secondary: #96989d;
  --text-muted: #72767d;
  --text-bright: #ffffff;
  --text-category: #8e9297;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --link: #00b0f4;
  --mention-bg: rgba(88, 101, 242, 0.3);
  --mention-text: #dee0fc;
  --sidebar-width: 240px;
  --aside-width: 56px;
}

html, body { height: 100%; }
body { font-family: 'Whitney', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; background: var(--bg-main); color: var(--text-primary); overflow: hidden; }

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

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.server-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-bright);
  border-bottom: 1px solid var(--bg-darkest);
  flex-shrink: 0;
  cursor: default;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.channel-list::-webkit-scrollbar { width: 4px; }
.channel-list::-webkit-scrollbar-track { background: transparent; }
.channel-list::-webkit-scrollbar-thumb { background: var(--bg-darkest); border-radius: 2px; }

.stats-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 16px;
  margin: 1px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.1s, color 0.1s;
}
.stats-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.stats-link.active { background: var(--bg-active); color: var(--text-bright); }

.category {
  padding: 16px 8px 4px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-category);
  letter-spacing: 0.02em;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 4px 8px 4px 8px;
  margin: 1px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  gap: 4px;
  transition: background 0.1s, color 0.1s;
  overflow: hidden;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-item.active { background: var(--bg-active); color: var(--text-bright); }

.hash { color: var(--text-muted); font-weight: 700; flex-shrink: 0; }
.channel-item .channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-count { margin-left: auto; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ── Main ───────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--bg-darkest);
  flex-shrink: 0;
  background: var(--bg-main);
  z-index: 10;
}

.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  flex-shrink: 0;
}

/* ── Search bar ─────────────────────────────────── */
.search-container {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

#search-input {
  background: var(--bg-darkest);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  color: var(--text-primary);
  font-size: 14px;
  width: 220px;
  outline: none;
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus { box-shadow: 0 0 0 2px var(--accent); }

/* ── Buttons ────────────────────────────────────── */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); }
.btn-secondary:hover { background: #4a4f59; }
.btn-secondary.active { background: var(--accent); color: #fff; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Messages area ──────────────────────────────── */
.messages-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 16px;
}
.messages-container::-webkit-scrollbar { width: 8px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--bg-darkest); border-radius: 4px; }
.messages-container::-webkit-scrollbar-thumb:hover { background: #1a1b1e; }

.loading { padding: 20px; color: var(--text-muted); text-align: center; }
.error { padding: 20px; color: #f04747; text-align: center; }
.no-results { padding: 20px; color: var(--text-muted); text-align: center; }
.hidden { display: none !important; }

/* ── Message containers ─────────────────────────── */
.message-container {
  display: flex;
  padding: 2px 16px 2px 16px;
  gap: 0;
  transition: background 0.1s;
  position: relative;
}
.message-container:hover { background: rgba(0,0,0,0.07); }

.message-container:not(.continuation) { padding-top: 14px; }

.message-aside {
  width: var(--aside-width);
  min-width: var(--aside-width);
  display: flex;
  justify-content: center;
  padding-top: 2px;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
}

.short-timestamp {
  font-size: 11px;
  color: transparent;
  white-space: nowrap;
  line-height: 22px;
  user-select: none;
  transition: color 0.1s;
}
.message-container:hover .short-timestamp { color: var(--text-muted); }

.message-primary {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.author {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-bright);
  cursor: default;
}
.author:hover { text-decoration: underline; }

.timestamp {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.message-content {
  font-size: 15px;
  line-height: 1.375;
  color: var(--text-primary);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Discord chatlog classes ────────────────────── */
.chatlog__markdown-preserve { white-space: pre-wrap; }

.chatlog__emoji {
  width: 22px;
  height: 22px;
  vertical-align: bottom;
  object-fit: contain;
}
.chatlog__emoji--large {
  width: 48px;
  height: 48px;
}

.chatlog__markdown-mention {
  background: var(--mention-bg);
  color: var(--mention-text);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
  cursor: default;
}
.chatlog__markdown-mention:hover { background: var(--accent); color: #fff; }

.chatlog__markdown-timestamp {
  background: var(--bg-input);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 14px;
  cursor: default;
}

/* Embeds */
.chatlog__embed {
  display: flex;
  max-width: 520px;
  margin: 4px 0;
  background: var(--bg-embed);
  border-radius: 4px;
  overflow: hidden;
}
.chatlog__embed-color-pill {
  width: 4px;
  min-width: 4px;
  border-radius: 4px 0 0 4px;
  background: var(--text-muted);
}
.chatlog__embed-content {
  padding: 8px 12px 10px;
  flex: 1;
  min-width: 0;
}
.chatlog__embed-content-container { display: flex; gap: 16px; }
.chatlog__embed-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}
.chatlog__embed-author-icon { width: 24px; height: 24px; border-radius: 50%; }
.chatlog__embed-author-name { font-size: 14px; font-weight: 600; }
.chatlog__embed-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
}
.chatlog__embed-title a { color: var(--link); text-decoration: none; }
.chatlog__embed-title a:hover { text-decoration: underline; }
.chatlog__embed-description {
  font-size: 14px;
  color: var(--text-primary);
  white-space: pre-wrap;
  margin-bottom: 4px;
}
.chatlog__embed-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}
.chatlog__embed-field { min-width: 100px; }
.chatlog__embed-field-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 2px;
}
.chatlog__embed-field-value {
  font-size: 14px;
  color: var(--text-primary);
  white-space: pre-wrap;
}
.chatlog__embed-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.chatlog__embed-footer-icon { width: 20px; height: 20px; border-radius: 50%; }
.chatlog__embed-image { max-width: 100%; border-radius: 4px; margin-top: 8px; display: block; }
.chatlog__embed-thumbnail { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.chatlog__embed-generic-gifv { max-width: 100%; border-radius: 4px; display: block; margin-top: 4px; }

/* Reactions */
.chatlog__reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chatlog__reaction {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--bg-input);
  border-radius: 4px;
  font-size: 13px;
  cursor: default;
}
.chatlog__reaction-count { color: var(--text-secondary); font-weight: 500; }

/* Code */
.chatlog__markdown code, code {
  background: #2f3136;
  border-radius: 3px;
  padding: 0 4px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  color: #e3e5e8;
}
.chatlog__markdown pre, pre {
  background: #2f3136;
  border-radius: 4px;
  padding: 8px 12px;
  margin: 4px 0;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.4;
}
.chatlog__markdown pre code { background: none; padding: 0; }

/* Spoilers */
.chatlog__markdown-spoiler {
  background: var(--text-muted);
  border-radius: 3px;
  color: transparent;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.1s, background 0.1s;
}
.chatlog__markdown-spoiler:hover, .chatlog__markdown-spoiler.revealed {
  color: var(--text-primary);
  background: var(--bg-input);
}

/* Reply */
.chatlog__reply {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}
.chatlog__reply::before {
  content: '';
  display: inline-block;
  width: 36px;
  height: 12px;
  border-top: 2px solid var(--text-muted);
  border-left: 2px solid var(--text-muted);
  border-radius: 4px 0 0 0;
  margin-right: 4px;
}
.chatlog__reply-author { font-weight: 500; color: var(--text-primary); }
.chatlog__reply-content { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }

/* Sticker */
.chatlog__sticker { max-width: 160px; max-height: 160px; }

/* ── Infinite scroll sentinel ────────────────────── */
.load-sentinel { height: 1px; }

/* ── Highlighted message (jump target) ──────────── */
.message-container.highlighted {
  background: rgba(250, 166, 26, 0.15) !important;
  border-left: 3px solid var(--accent);
  transition: background 1.5s ease, border-color 1.5s ease;
}
.message-container.highlighted.fade-out {
  background: transparent !important;
  border-left-color: transparent;
}

/* ── Date jump input ─────────────────────────────── */
.date-jump-input {
  background: var(--bg-darkest);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}
.date-jump-input:focus { box-shadow: 0 0 0 2px var(--accent); }

/* ── Search results panel ───────────────────────── */
.search-results {
  max-height: 60vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--bg-darkest);
  background: var(--bg-sidebar);
}
.search-count { padding: 10px 16px; font-size: 14px; color: var(--text-secondary); border-bottom: 1px solid var(--bg-darkest); }
.search-channel-group { padding: 0 0 8px; }
.search-channel-header {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-category);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--bg-darkest);
}
.search-result-item {
  padding: 6px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-size: 13px;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-author { font-weight: 600; color: var(--text-bright); margin-right: 8px; }
.search-ts { color: var(--text-muted); margin-right: 8px; }
.jump-link { color: var(--accent); text-decoration: none; font-size: 12px; }
.jump-link:hover { text-decoration: underline; }
.search-snippet { color: var(--text-secondary); margin-top: 2px; }
.search-snippet mark { background: rgba(88,101,242,0.3); color: var(--text-bright); border-radius: 2px; padding: 0 1px; }
.search-more { padding: 4px 16px; font-size: 12px; color: var(--text-muted); }
.search-count-inline { padding: 8px 16px; color: var(--text-secondary); font-size: 13px; border-bottom: 1px solid var(--bg-darkest); }

/* Channel pills in global search results */
.search-channel-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--bg-darkest); }
.search-channel-pill {
  background: var(--bg-input);
  border: none;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.search-channel-pill:hover { background: var(--accent); color: #fff; }
.pill-count { font-weight: 700; color: var(--accent); margin-left: 4px; }
.search-channel-pill:hover .pill-count { color: #fff; }
.search-show-channel {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.search-show-channel:hover { color: var(--accent-hover); }

/* ── Search navigator bar ───────────────────────── */
.search-navigator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--accent);
  border-bottom: 1px solid var(--bg-darkest);
  flex-shrink: 0;
}
.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  transition: background 0.1s;
}
.nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.nav-counter {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  font-weight: 500;
}
.nav-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}
.nav-clear:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── Search hit highlighting ─────────────────────── */
mark.search-hit {
  background: rgba(250, 166, 26, 0.4);
  color: var(--text-bright);
  border-radius: 2px;
  padding: 0 1px;
}
.message-container.search-hit-msg {
  background: rgba(250, 166, 26, 0.05);
  border-left: 2px solid rgba(250, 166, 26, 0.4);
}
.message-container.search-hit-msg:hover { background: rgba(250, 166, 26, 0.09); }

/* ── Stats page ─────────────────────────────────── */
.stats-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.stats-content::-webkit-scrollbar { width: 8px; }
.stats-content::-webkit-scrollbar-track { background: transparent; }
.stats-content::-webkit-scrollbar-thumb { background: var(--bg-darkest); border-radius: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-bright); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

.stats-section {
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.stats-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-category);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}
.stats-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-category);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 8px;
}

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label {
  width: 200px;
  min-width: 200px;
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-label:hover { color: var(--accent); }
.bar-track { flex: 1; height: 20px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; min-width: 2px; }
.bar-count { font-size: 13px; color: var(--text-muted); min-width: 60px; text-align: right; }

/* Leaderboard */
.leaderboard { overflow-x: auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leaderboard-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-category);
  border-bottom: 1px solid var(--bg-darkest);
  letter-spacing: 0.04em;
}
.leaderboard-table td { padding: 8px 12px; border-bottom: 1px solid rgba(0,0,0,0.15); }
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr:hover td { background: rgba(255,255,255,0.03); }
.rank { color: var(--text-muted); font-weight: 700; text-align: right; }
.username { font-weight: 500; color: var(--text-bright); }
.leaderboard-table a { color: var(--link); text-decoration: none; }
.leaderboard-table a:hover { text-decoration: underline; }

.inline-bar { display: flex; align-items: center; gap: 8px; }
.inline-bar-fill { height: 8px; background: var(--accent); border-radius: 4px; min-width: 2px; }
.inline-bar span { font-size: 13px; color: var(--text-secondary); }

/* Timeline */
.timeline-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  overflow-x: auto;
  padding-bottom: 28px;
  position: relative;
}
.timeline-chart::-webkit-scrollbar { height: 4px; }
.timeline-chart::-webkit-scrollbar-track { background: transparent; }
.timeline-chart::-webkit-scrollbar-thumb { background: var(--bg-darkest); border-radius: 2px; }

.timeline-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 14px;
  height: 100%;
  position: relative;
}
.timeline-fill {
  width: 10px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  cursor: default;
  transition: background 0.1s;
}
.timeline-bar:hover .timeline-fill { background: #7289da; }
.timeline-label {
  position: absolute;
  bottom: -22px;
  font-size: 9px;
  color: var(--text-muted);
  transform: rotate(-45deg);
  transform-origin: top left;
  white-space: nowrap;
}

/* Keyword search */
.keyword-search { display: flex; gap: 8px; margin-bottom: 12px; }
#keyword-input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
#keyword-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.keyword-total { font-size: 15px; color: var(--text-primary); margin-bottom: 12px; }
.keyword-breakdown { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.keyword-ch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--bg-input);
  border-radius: 4px;
}
.keyword-ch-row a { color: var(--link); text-decoration: none; font-size: 14px; }
.keyword-ch-row a:hover { text-decoration: underline; }
.keyword-ch-count { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.keyword-users { display: flex; flex-direction: column; gap: 4px; }
.keyword-user-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 14px;
  border-radius: 4px;
}
.keyword-user-row:hover { background: var(--bg-input); }
.keyword-user-row span:first-child { color: var(--text-primary); }
.keyword-user-row span:last-child { color: var(--text-secondary); font-weight: 600; }

mark { background: rgba(88,101,242,0.3); color: var(--text-bright); border-radius: 2px; padding: 0 1px; }

/* ── Leaderboard controls (Phase 3) ─────────────── */
.lb-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
#member-filter {
  background: var(--bg-input);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  min-width: 200px;
}
#member-filter:focus { box-shadow: 0 0 0 2px var(--accent); }
#member-filter::placeholder { color: var(--text-muted); }
.lb-sort-btns { display: flex; gap: 4px; }
.lb-count { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* Expand button in leaderboard rows */
.lb-expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
}
.lb-expand-btn:hover { background: var(--bg-input); color: var(--text-primary); }

/* Per-channel breakdown rows */
.lb-breakdown-row td { padding: 0; border-bottom: 1px solid rgba(0,0,0,0.15); }
.lb-breakdown-wrap {
  padding: 8px 12px 8px 48px;
  background: rgba(0,0,0,0.15);
}
.lb-breakdown-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-breakdown-table td { padding: 3px 8px; }
.lb-breakdown-ch { color: var(--text-secondary); text-decoration: none; }
.lb-breakdown-ch:hover { color: var(--accent); }
.lb-breakdown-count { color: var(--text-muted); text-align: right; font-weight: 500; }

/* Keyword "show all" button */
.kw-show-all {
  background: none;
  border: 1px solid var(--bg-input);
  border-radius: 4px;
  color: var(--accent);
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.1s;
}
.kw-show-all:hover { background: var(--bg-input); }

/* Links */
a { color: var(--link); }
.message-content a { color: var(--link); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 200px; min-width: 200px; }
  --sidebar-width: 200px;
  .bar-label { width: 120px; min-width: 120px; }
  .stats-content { padding: 16px; }
}

@media (max-width: 520px) {
  .sidebar { display: none; }
  .search-bar-wrap { width: 160px; }
}

/* ── Floating jump buttons ───────────────────────── */
.jump-float-btn {
  position: absolute;
  right: 20px;
  z-index: 5;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, background 0.1s, color 0.1s;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.jump-float-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.jump-float-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.jump-float-top { top: 12px; }
.jump-float-bottom { bottom: 12px; }

/* ── Search bar redesign ─────────────────────────── */
.search-container {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-bar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-darkest);
  border-radius: 4px;
  padding: 0 6px 0 10px;
  gap: 4px;
  transition: box-shadow 0.15s;
  width: 260px;
  min-height: 32px;
}
.search-bar-wrap:focus-within {
  box-shadow: 0 0 0 2px var(--accent);
}
.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
}
.search-bar-wrap #search-input {
  background: transparent;
  border: none;
  padding: 6px 0;
  color: var(--text-primary);
  font-size: 14px;
  flex: 1;
  min-width: 0;
  outline: none;
  box-shadow: none !important;
  width: auto;
}
.search-bar-wrap #search-input::placeholder { color: var(--text-muted); }

.search-scope-toggle {
  background: rgba(255,255,255,0.07);
  border: none;
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.search-scope-toggle:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.search-scope-toggle.active { background: rgba(88,101,242,0.35); color: #dee0fc; }

.search-bar-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.1s;
  flex-shrink: 0;
  line-height: 1;
}
.search-bar-clear:hover { color: var(--text-primary); }

/* ── Search dropdown ─────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 200;
  overflow: hidden;
  min-width: 280px;
}
.search-dropdown-header {
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-category);
}
.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.search-dropdown-item:hover { background: var(--bg-hover); }
.search-filter-label {
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 64px;
  text-align: center;
}
.search-filter-label.sfl-pink { background: #eb459e; }
.search-filter-label.sfl-green { background: #3ba55d; }
.search-filter-label.sfl-yellow { background: #c9a227; color: #fff; }
.search-filter-desc {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.3;
}
.search-filter-example {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'Consolas', 'Courier New', monospace;
}
.search-dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 0;
}

/* ── Navigator sort buttons ──────────────────────── */
.nav-sort {
  display: flex;
  gap: 3px;
  margin-left: 4px;
}
.search-sort-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  font-weight: 500;
}
.search-sort-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.search-sort-btn.active { background: rgba(255,255,255,0.22); color: #fff; font-weight: 700; }

/* ── Navigator match mode buttons ────────────────── */
.nav-match {
  display: flex;
  gap: 3px;
  margin-left: 4px;
}

/* ── Search dropdown match mode ──────────────────── */
.search-match-mode-wrap {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
}
.search-match-mode-btn {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 6px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  text-align: center;
  letter-spacing: 0.02em;
}
.search-match-mode-btn:hover { background: rgba(255,255,255,0.13); color: var(--text-primary); border-color: rgba(255,255,255,0.2); }
.search-match-mode-btn.active { background: rgba(88,101,242,0.35); color: #dee0fc; border-color: rgba(88,101,242,0.5); font-weight: 700; }

/* ── Search results panel redesign ──────────────── */
.search-results-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-darkest);
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 2;
}
.search-results-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-bright);
  flex: 1;
}
.search-results-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.search-results-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.1s, background 0.1s;
}
.search-results-close:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Search result cards ─────────────────────────── */
.search-result-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  position: relative;
  transition: background 0.1s;
}
.search-result-card:hover { background: var(--bg-hover); }
.search-result-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  user-select: none;
}
.search-result-body { flex: 1; min-width: 0; padding-right: 60px; }
.search-result-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.search-result-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}
.search-result-ts {
  font-size: 11px;
  color: var(--text-muted);
}
.search-result-channel-tag {
  font-size: 11px;
  color: var(--accent);
  margin-left: auto;
}
.search-result-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  word-break: break-word;
}
.search-result-text mark {
  background: rgba(88,101,242,0.3);
  color: var(--text-bright);
  border-radius: 2px;
  padding: 0 1px;
}
.search-result-jump {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, background 0.1s;
  white-space: nowrap;
}
.search-result-card:hover .search-result-jump { opacity: 1; }
.search-result-jump:hover { background: var(--accent-hover); }

/* ── Paginated viewer additions ──────────────────────────────── */
.page-counter {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: 99px;
  pointer-events: none;
  opacity: 0.7;
  z-index: 2;
}

.search-progress {
  height: 3px;
  background: var(--bg-tertiary);
  margin: 0;
  overflow: hidden;
}
.search-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}
.search-no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.search-more {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--bg-tertiary);
}

/* searching pulse */
@keyframes search-pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.search-navigator.searching #nav-counter { animation: search-pulse 1.2s ease-in-out infinite; }

/* Leaderboard user links */
.lb-user-link {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.1s;
}
.lb-user-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Changes (deleted / edited) ──────────────────────────────── */
.changes-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.changes-group {
  margin-bottom: 24px;
}
.changes-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-category);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.changes-empty {
  font-size: 13px;
  color: var(--text-muted);
}
.changes-more {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.change-row {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 6px;
  border-left: 3px solid transparent;
}
.change-row.deleted {
  background: rgba(237, 66, 69, 0.08);
  border-left-color: #ed4245;
}
.change-row.edited {
  background: rgba(250, 166, 26, 0.08);
  border-left-color: #faa61a;
}
.change-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}
.change-author {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-bright);
}
.change-ts {
  font-size: 12px;
  color: var(--text-muted);
}
.change-text {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
}
.change-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.change-before, .change-after {
  font-size: 13px;
  word-break: break-word;
  padding: 4px 8px;
  border-radius: 4px;
}
.change-before {
  background: rgba(237, 66, 69, 0.12);
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: rgba(237,66,69,0.5);
}
.change-after {
  background: rgba(87, 242, 135, 0.1);
  color: var(--text-secondary);
}
.diff-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 8px;
  opacity: 0.6;
}

/* ── Changes page ────────────────────────────────────────────── */
.changes-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-darkest);
  flex-shrink: 0;
}
.changes-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.changes-tab:hover { color: var(--text-primary); }
.changes-tab.active {
  color: var(--text-bright);
  border-bottom-color: var(--accent);
}
.changes-tab-count {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.7;
}

/* deleted / edited message rows */
.message-container.deleted-msg {
  background: rgba(237, 66, 69, 0.05);
  border-left: 2px solid rgba(237,66,69,0.4);
}
.message-container.edited-msg {
  background: rgba(250, 166, 26, 0.05);
  border-left: 2px solid rgba(250,166,26,0.4);
}
.deleted-avatar, .edited-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.deleted-avatar { background: rgba(237,66,69,0.15); }
.edited-avatar  { background: rgba(250,166,26,0.15); }

.change-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-deleted { background: rgba(237,66,69,0.25); color: #ff7070; }
.badge-edited  { background: rgba(250,166,26,0.25); color: #fcc04a; }

.edit-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
.edit-before, .edit-after {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  word-break: break-word;
  line-height: 1.5;
}
.edit-before {
  background: rgba(237,66,69,0.1);
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: rgba(237,66,69,0.5);
}
.edit-after {
  background: rgba(87,242,135,0.08);
  color: var(--text-primary);
}
.edit-before .diff-label { color: #ff7070; }
.edit-after  .diff-label { color: #57f287; }

.edit-before mark, .edit-after mark {
  background: rgba(88,101,242,0.35);
  color: var(--text-bright);
  border-radius: 2px;
  padding: 0 1px;
  text-decoration: none;
}

/* Jump to chat link */
.jump-to-chat {
  margin-left: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.message-container:hover .jump-to-chat { opacity: 1; }
.jump-to-chat:hover { text-decoration: underline; }

/* Deleted context banner in the chat view */
.deleted-context-banner {
  margin: 4px 16px;
  padding: 6px 12px;
  background: rgba(237,66,69,0.12);
  border-left: 3px solid #ed4245;
  border-radius: 4px;
  font-size: 12px;
  color: #ff7070;
  font-weight: 500;
}

.stat-sub { font-size: 12px; margin-top: 4px; }
.stat-sub a { color: var(--accent); text-decoration: none; }
.stat-sub a:hover { text-decoration: underline; }
