/* Theme. Light is the base; dark applies when the device prefers it and the
   visitor made no choice, or when they chose dark (html[data-theme]). The
   choice is set before first paint by the inline script in the <head>. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --soft: #eef6fb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220;
    --panel: #111a2b;
    --ink: #e5eaf2;
    --muted: #8b98ad;
    --line: #1f2b40;
    --accent: #38bdf8;
    --accent-ink: #06121f;
    --soft: #12233a;
    --danger: #fca5a5;
    --danger-soft: #2a1414;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111a2b;
  --ink: #e5eaf2;
  --muted: #8b98ad;
  --line: #1f2b40;
  --accent: #38bdf8;
  --accent-ink: #06121f;
  --soft: #12233a;
  --danger: #fca5a5;
  --danger-soft: #2a1414;
}

/* Theme toggle shows the theme in effect (sun = light, moon = dark), resolved
   the same way the tokens are: the explicit choice, else the device. */
.theme-btn { flex: none; width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.theme-btn:hover { color: var(--ink); background: var(--soft); filter: none; }
.theme-btn svg { width: 18px; height: 18px; fill: currentColor; }
.theme-btn .i-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-light { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-dark { display: block; }
}
:root[data-theme="dark"] .theme-btn .i-light { display: none; }
:root[data-theme="dark"] .theme-btn .i-dark { display: block; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
h1, h2 { line-height: 1.2; margin: 0 0 .4em; }
.wrap { max-width: 740px; margin: 0 auto; padding: 0 16px; }

/* header — its own, wider container so brand, platforms, search and the
   theme button sit on one line on a desktop; the platform strip scrolls
   (without a visible bar) only when a phone is too narrow for it. */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .wrap { max-width: 1100px; display: flex; align-items: center; gap: 14px; height: 56px; }
.brand { font-weight: 800; color: var(--ink); white-space: nowrap; font-size: 18px; }
.brand .logo { color: var(--accent); }
.platforms { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.platforms::-webkit-scrollbar { display: none; }
.platforms a, .platforms .soon { padding: 6px 10px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.platforms a.on { background: var(--soft); color: var(--accent); font-weight: 600; }
.platforms .soon { color: var(--muted); opacity: .7; }
.quick { display: none; gap: 6px; flex: 0 1 320px; min-width: 200px; }
.quick input { flex: 1; }
@media (min-width: 720px) { .quick { display: flex; } }
input[type="search"], input[type="text"] {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-width: 0;
}
button { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; }
button:hover { filter: brightness(1.05); }

/* landing */
.hero { text-align: center; padding: 56px 0 32px; }
.hero h1 { font-size: clamp(26px, 5vw, 40px); letter-spacing: -.02em; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto 22px; }
.search { display: flex; gap: 8px; margin: 12px 0 18px; }
.search input { flex: 1; }
.search.big { max-width: 560px; margin: 0 auto 10px; }
.search.big input { padding: 13px 18px; font-size: 17px; }
.search.big button { padding: 13px 22px; }
.hint { font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 12px 0 40px; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); }
.tile h2 { font-size: 17px; margin-bottom: 4px; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.tile.on { border-color: var(--accent); }
.tile.soon { opacity: .55; }

/* profile */
.profile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0 12px; overflow: hidden; }
.banner { aspect-ratio: 3 / 1; background: var(--soft); }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.head { display: flex; align-items: flex-end; gap: 14px; padding: 0 16px; margin-top: -44px; }
.ava { border-radius: 50%; object-fit: cover; background: var(--line); }
.ava.big { width: 96px; height: 96px; border: 4px solid var(--panel); }
.ident { padding-bottom: 6px; min-width: 0; }
.ident h1 { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 6px; }
.handle { color: var(--muted); font-size: 15px; }
.pill { display: inline-block; margin-left: 8px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--muted); }
.bio { padding: 0 16px; margin: 10px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 16px; margin: 6px 0; color: var(--muted); font-size: 14px; }
.stats { list-style: none; display: flex; gap: 18px; padding: 6px 16px 12px; margin: 0; font-size: 14px; color: var(--muted); }
.stats b { color: var(--ink); font-size: 16px; }
.tabs { display: flex; border-top: 1px solid var(--line); }
.tabs a { flex: 1; text-align: center; padding: 12px 8px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; background: var(--soft); }
.badge { fill: var(--accent); vertical-align: -3px; margin-left: 2px; }
/* Affiliation badge: the organisation's square logo after the name, X-style. */
.affil { display: inline-flex; flex: none; margin-left: 2px; vertical-align: -3px; line-height: 0; }
.affil-img { width: 18px; height: 18px; border-radius: 3px; border: 1px solid var(--line); object-fit: cover; background: var(--panel); }
.quote .affil-img { width: 16px; height: 16px; }
.profile h1 .affil-img { width: 20px; height: 20px; }
.fresh { color: var(--muted); font-size: 13px; margin: 6px 4px 10px; }

/* tweets */
.list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.tweet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow-wrap: anywhere; }
.tweet.focal { padding: 18px; font-size: 17px; }
.tweet.focal .text { font-size: 20px; line-height: 1.4; }
.thread .tweet { border-left: 3px solid var(--accent); border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.thread.ancestors .tweet { border-left-color: var(--line); }
.ctx { color: var(--muted); font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.ctx svg { fill: var(--muted); }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.who.compact .ava { width: 32px; height: 32px; }
.who .ava { width: 40px; height: 40px; flex: none; }
.who-text { min-width: 0; }
.name { font-weight: 700; display: flex; align-items: center; gap: 4px; }
.name a { color: var(--ink); }
.text { white-space: pre-wrap; }
.text a { overflow-wrap: anywhere; }
.when { color: var(--muted); font-size: 14px; margin: 10px 0 4px; }
.counts { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 14px; margin-top: 10px; }
.counts span { display: inline-flex; align-items: center; gap: 5px; }
.counts svg { fill: var(--muted); }

/* media */
.media { display: grid; gap: 4px; margin-top: 10px; border-radius: 12px; overflow: hidden; }
.media.n1 { grid-template-columns: 1fr; }
.media.n2, .media.n4 { grid-template-columns: 1fr 1fr; }
.media.n3 { grid-template-columns: 1fr 1fr; }
.media.n3 .m:first-child { grid-row: span 2; }
.media .m { display: block; background: var(--line); }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; max-height: 520px; }
.media.n1 img { object-fit: contain; background: var(--bg); }
.wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 14px; }
.wall .cell { position: relative; aspect-ratio: 1; background: var(--line); border-radius: 8px; overflow: hidden; }
.wall img { width: 100%; height: 100%; object-fit: cover; }
.wall .play { position: absolute; right: 8px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 6px; }

/* cards */
.card { display: flex; flex-direction: column; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--ink); }
.card img { max-height: 320px; width: 100%; object-fit: cover; }
.card-text { padding: 10px 12px; font-size: 14px; }
.card .domain { color: var(--muted); font-size: 13px; }
.card .title { font-weight: 600; }
.card .desc { color: var(--muted); }
.quote { position: relative; display: block; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font-size: 15px; }
.quote:hover { background: var(--soft); }
/* The card's own link sits under the content; text lets clicks fall through
   to it, while the links inside the text and the media stay their own targets. */
.quote-link { position: absolute; inset: 0; border-radius: 12px; z-index: 0; }
.quote .who, .quote .text { position: relative; z-index: 1; pointer-events: none; }
.quote .who a, .quote .text a { pointer-events: auto; }
.quote .media { position: relative; z-index: 1; }
.quote .who { margin-bottom: 4px; gap: 6px; }
.quote .ava { width: 20px; height: 20px; }
.quote .handle { font-size: 13px; }
.user-card { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.user-card .ava { width: 48px; height: 48px; }
.user-card .bio { padding: 0; margin: 4px 0 0; font-size: 14px; }

/* misc */
.pager { text-align: center; margin: 8px 0 28px; }
.more { display: inline-block; padding: 10px 22px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 12px; margin: 10px 0 16px; background: var(--soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.section { font-size: 17px; margin: 18px 4px 10px; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty h1 { color: var(--ink); }
.prose { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 20px 0; }
.foot { color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }
.foot p { margin: 0 0 8px; }
