:root {
  --bg: #ffffff;
  --bg-soft: #f4f6f8;
  --fg: #16191d;
  --muted: #66707a;
  --border: #dde2e7;
  --accent: #2a8bd6;
  --accent-fg: #ffffff;
  --mark: #fff0a8;
  --error: #c0392b;
  --ok: #1e8e4e;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --bg-soft: #1b2027;
    --fg: #e6e9ec;
    --muted: #9aa3ad;
    --border: #2b323b;
    --accent: #4ea4e8;
    --accent-fg: #0b1117;
    --mark: #5c4d00;
    --error: #ff7b6b;
    --ok: #5fd08f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px 48px; flex: 1; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 32px 0 12px; }
code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

header.site {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 16px;
}
.logo { font-weight: 800; font-size: 1.25rem; color: var(--fg); letter-spacing: -0.02em; }
.logo span { color: var(--accent); }
header.site nav { display: flex; gap: 16px; font-size: 0.95rem; }
footer.site { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 24px 16px; border-top: 1px solid var(--border); }

.hero { padding: 40px 0 8px; text-align: center; }
.hero h1 { font-size: 2rem; }
.lede { color: var(--muted); margin: 0 0 20px; }

.searchbox { margin: 8px 0 16px; }
.searchrow { display: flex; gap: 8px; }
.searchrow input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.05rem;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--fg);
}
.searchrow input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button {
  font: inherit; cursor: pointer; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-fg); padding: 10px 18px; font-weight: 600;
  display: inline-block;
}
.button:hover { text-decoration: none; opacity: 0.9; }
.filters {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  margin-top: 10px; font-size: 0.9rem; color: var(--muted);
}
.hero .filters { justify-content: center; }
.filters select { font: inherit; background: var(--bg-soft); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; padding: 3px 6px; margin-left: 4px; }
.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.tabs label { padding: 4px 12px; cursor: pointer; }
.tabs input { position: absolute; opacity: 0; pointer-events: none; }
.tabs label:has(input:checked) { background: var(--accent); color: var(--accent-fg); }
.tabs label:has(input:focus-visible) { outline: 2px solid var(--accent); }

.scope, .count { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; }
.notice { background: var(--bg-soft); border-radius: var(--radius); padding: 12px 16px; }
.notice.error { color: var(--error); }
.notice.ok { color: var(--ok); }
.notice-page, .narrow { padding-top: 32px; }
.muted { color: var(--muted); }
.htmx-request #results, .htmx-request#results { opacity: 0.6; transition: opacity 0.2s; }

ol.results, ul.channels { list-style: none; margin: 0; padding: 0; }
.post { border-bottom: 1px solid var(--border); padding: 14px 0; }
.post header { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; flex-wrap: wrap; }
.post header .ch { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 600; }
.post header .when { color: var(--muted); }
.post .text { margin: 6px 0; white-space: pre-line; overflow-wrap: anywhere; }
.post .snippet { white-space: normal; }
.post footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 0.85rem; color: var(--muted); }
.post footer .open { margin-left: auto; }
.thumb { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; margin: 8px 0; object-fit: cover; }
.badge { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: 0.75rem; }
.more { text-align: center; padding: 20px 0; border: 0; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-fg); font-weight: 700;
}
.avatar.sm { width: 24px; height: 24px; font-size: 0.75rem; }
.avatar.lg { width: 80px; height: 80px; font-size: 2rem; }

.channels.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
@media (max-width: 720px) { .channels.grid { grid-template-columns: 1fr; } }
.channel-card a { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--radius); color: var(--fg); }
.channel-card a:hover { background: var(--bg-soft); text-decoration: none; }
.results.channels .channel-card { border-bottom: 1px solid var(--border); }
.channel-card .body { display: flex; flex-direction: column; min-width: 0; }
.channel-card .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-card .meta, .channel-card .desc { color: var(--muted); font-size: 0.85rem; }
.channel-card .desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.verified { color: var(--accent); font-size: 0.9em; }

.channel-head { display: flex; gap: 16px; align-items: flex-start; padding: 24px 0 8px; }
.channel-head .meta { color: var(--muted); margin: 0 0 8px; }
.channel-head .desc { white-space: pre-line; overflow-wrap: anywhere; margin: 0; }
@media (max-width: 520px) {
  .channel-head { flex-direction: column; }
  .hero h1 { font-size: 1.6rem; }
  .searchrow button { padding: 10px 12px; }
}
