:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #5865f2;
  --code-bg: #eef0f3;
  --flash: rgba(88, 101, 242, 0.12);
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1f22;
    --surface: #2b2d31;
    --text: #dbdee1;
    --muted: #949ba4;
    --border: #3a3c42;
    --accent: #7983f5;
    --code-bg: #1e1f22;
    --flash: rgba(121, 131, 245, 0.16);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.title h1 { margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hash { color: var(--muted); font-size: 20px; font-weight: 500; }
.guild { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.status[data-state="offline"] .dot { background: var(--err); }

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

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

.msg {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  padding: 6px 16px;
}
.msg:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.msg.new { animation: flash 1.6s ease-out; }
.msg.grouped { padding-top: 1px; }
.msg.grouped .avatar { visibility: hidden; height: 0; }
.msg.grouped .meta { display: none; }

@keyframes flash { from { background: var(--flash); } to { background: transparent; } }

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

.body { min-width: 0; }
.meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.author { font-weight: 600; }
.badge { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; }
.time, .edited { color: var(--muted); font-size: 12px; }

.content { white-space: pre-wrap; overflow-wrap: anywhere; }
.content:empty { display: none; }
.content a { color: var(--accent); }
.content code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.content pre { background: var(--code-bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 4px 0; }
.content pre code { padding: 0; background: none; }
.content .note { color: var(--muted); font-style: italic; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.attachments:empty { display: none; }
.attachments img { max-width: min(400px, 100%); max-height: 300px; border-radius: 6px; display: block; }
.attachments a.file { display: inline-block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--accent); text-decoration: none; }

.jump {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
