/* forum_like — server-rendered UI stylesheet.
 * Light/dark via prefers-color-scheme; a single embedded file keeps the
 * deployment a static binary. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-alt: #f5f6f8;
  --card: #ffffff;
  --fg: #1c1c1e;
  --muted: #6b7280;
  --border: #d9dde3;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --accent-soft: #e8effc;
  --up: #2f9e44;
  --down: #e03131;
  --danger: #e03131;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  --max-width: 960px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --bg-alt: #1b1d20;
    --card: #1b1d20;
    --fg: #e7e8ea;
    --muted: #9ba1a8;
    --border: #2d3036;
    --accent: #6d9bf8;
    --accent-contrast: #0d1220;
    --accent-soft: #1d2a44;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav .brand { font-weight: 700; color: var(--fg); }
nav form { margin: 0; }
nav button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
  color: var(--accent);
}
nav button:hover { text-decoration: underline; }
nav .muted a { color: var(--muted); }
nav .search { margin-left: auto; }
nav .search input {
  width: 14rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
}
nav .search input:focus { outline: 2px solid var(--accent-soft); }

.search-page { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-page input {
  flex: 1;
  max-width: 32rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}
.search-page .nsfw-toggle {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--fg-soft);
}
.search-page .nsfw-toggle input { width: auto; flex: none; }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

h1 { font-size: 1.6rem; margin: 0.4rem 0; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 0.2rem 0; }

.muted { color: var(--muted); }
.deleted { color: var(--muted); font-style: italic; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  margin-right: 0.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: lowercase;
}
.badge.nsfw {
  color: var(--down);
  border-color: color-mix(in srgb, var(--down) 40%, transparent);
}
.badge.pinned {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.badge.locked {
  color: var(--muted);
  border-color: var(--border);
}
.badge.removed {
  color: var(--down);
  border-color: color-mix(in srgb, var(--down) 40%, transparent);
}

label.check { display: flex; align-items: center; gap: 0.4rem; }
label.check input { width: auto; }

.flash {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  border: 1px solid var(--border);
}
.flash.ok {
  background: color-mix(in srgb, var(--up) 12%, transparent);
  color: var(--up);
  border-color: color-mix(in srgb, var(--up) 40%, transparent);
}
.flash.error {
  background: color-mix(in srgb, var(--down) 12%, transparent);
  color: var(--down);
  border-color: color-mix(in srgb, var(--down) 40%, transparent);
}

.row { display: flex; gap: 1.5rem; align-items: flex-start; }
.sidebar { flex: 0 0 220px; }
.sidebar ul { list-style: none; padding: 0; margin: 0.4rem 0 1rem; }
.sidebar li { padding: 0.25rem 0; }
.feed { flex: 1; min-width: 0; }

article.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
article.post h3 { margin: 0.35rem 0; }
article.post h3 a { color: var(--fg); }
.post-meta, .comment-meta { font-size: 0.85rem; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  vertical-align: middle;
}
.avatar-xl { width: 96px; height: 96px; }
.avatar-sm { width: 22px; height: 22px; }
.avatar-nav { width: 26px; height: 26px; }
.nav-user { position: relative; display: flex; align-items: center; }
.nav-user-link { display: inline-flex; align-items: center; gap: 0.4rem; }
.nav-notif {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.8rem;
}
.notif-badge {
  display: inline-block;
  min-width: 1.2rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 1rem;
  background: var(--accent);
  color: var(--card);
}
.notifications { list-style: none; padding: 0; margin: 1rem 0; }
.notif {
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.notif.unread {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.notif-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  color: var(--fg);
}
.notif-link .avatar { width: 34px; height: 34px; flex: none; }
.notif-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.notif-text em { color: var(--fg); }

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 9rem;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}
.nav-user:hover .nav-dropdown,
.nav-user:focus-within .nav-dropdown { display: flex; }
.nav-dropdown::before {
  content: "";
  position: absolute;
  top: -0.5rem;
  left: 0;
  right: 0;
  height: 0.5rem;
}
.nav-dropdown a,
.nav-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-radius: calc(var(--radius) - 3px);
  color: var(--fg);
}
.nav-dropdown a:hover,
.nav-dropdown button:hover {
  background: var(--accent-soft);
  text-decoration: none;
  color: var(--fg);
}

.profile-head { display: flex; align-items: center; gap: 1rem; }
.profile-head h1 { margin: 0; }

.banner { margin-bottom: 1rem; }
.banner img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.banner.preview { max-width: 40rem; }
.banner.preview img { max-height: 120px; }
.edited-marker { font-style: italic; color: var(--muted); }
.post-footer, .comment-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}
.post-content { overflow-wrap: anywhere; }
.post-content p:first-child { margin-top: 0.4rem; }

.post-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
  margin: 0.6rem 0;
}
.post-media img, .post-media video {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  background: var(--bg-alt);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.feed-thumb {
  display: block;
  margin: 0.45rem 0 0.2rem;
}
.feed-thumb img, .feed-thumb video {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}

.sortbar {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.sortbar a {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.sortbar a:hover { text-decoration: none; color: var(--fg); }
.sortbar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sortbar-window {
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.votes { display: inline-flex; align-items: center; gap: 0.1rem; }
.votes form { margin: 0; }
.votes button {
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  color: var(--muted);
}
.votes button:hover { background: var(--bg-alt); color: var(--fg); }
.votes button.voted-up { color: var(--up); }
.votes button.voted-down { color: var(--down); }
.votes .score { min-width: 1.7em; text-align: center; font-weight: 600; }

.comments { list-style: none; padding-left: 1rem; margin: 0.25rem 0; }
.comments > li { border-left: 2px solid var(--border); padding-left: 0.85rem; }
.comment { margin: 0.7rem 0; }
.comment.collapsed > .comment-body,
.comment.collapsed > ul.comments,
.comment.collapsed > .continue { display: none; }
.toggle {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0 0.2rem;
  margin-right: 0.2rem;
}
.toggle:hover { color: var(--fg); }
.continue { display: block; margin: 0.4rem 0; font-size: 0.85rem; }
.thread-context { font-size: 0.85rem; color: var(--muted); margin: 0.25rem 0 0.5rem; }
.comment-content { overflow-wrap: anywhere; }
.comment-content p:first-child { margin-top: 0.25rem; }
.comment-content p:last-child { margin-bottom: 0.25rem; }

/* Markdown-rendered content (posts, comments, bios, community descriptions). */
.post-content h1, .post-content h2, .post-content h3,
.comment-content h1, .comment-content h2, .comment-content h3,
.profile-summary h1, .profile-summary h2, .profile-summary h3,
.post-content h4, .post-content h5, .post-content h6,
.comment-content h4, .comment-content h5, .comment-content h6,
.profile-summary h4, .profile-summary h5, .profile-summary h6 {
  margin: 0.8rem 0 0.4rem;
}
.post-content h1, .comment-content h1, .profile-summary h1 { font-size: 1.25rem; }
.post-content h2, .comment-content h2, .profile-summary h2 { font-size: 1.15rem; }
.post-content h3, .comment-content h3, .profile-summary h3 { font-size: 1.05rem; }
.post-content h1:first-child, .comment-content h1:first-child,
.profile-summary h1:first-child { margin-top: 0.3rem; }

.post-content pre, .comment-content pre, .profile-summary pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  line-height: 1.45;
}
.post-content code, .comment-content code, .profile-summary code {
  background: var(--bg-alt);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.post-content pre code, .comment-content pre code, .profile-summary pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
.post-content blockquote, .comment-content blockquote, .profile-summary blockquote {
  margin: 0.5rem 0;
  padding: 0.1rem 0.9rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.post-content blockquote p:last-child, .comment-content blockquote p:last-child,
.profile-summary blockquote p:last-child {
  margin-bottom: 0.1rem;
}
.post-content .table-wrap, .comment-content .table-wrap, .profile-summary .table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
}
.post-content table, .comment-content table, .profile-summary table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}
.post-content th, .post-content td,
.comment-content th, .comment-content td,
.profile-summary th, .profile-summary td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.post-content th, .comment-content th, .profile-summary th {
  background: var(--bg-alt);
  font-weight: 600;
}
.profile-summary p:first-child { margin-top: 0.4rem; }
.profile-summary p:last-child { margin-bottom: 0.4rem; }

.reply { margin: 0.4rem 0; }
.reply summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.reply textarea { width: 100%; }

form.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 40rem;
}
form.stack label { display: block; font-weight: 600; }
form.stack input, form.stack textarea, form.stack select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
form.stack textarea { font-family: inherit; }
form.stack .hint { font-size: 0.85rem; color: var(--muted); margin-top: -0.3rem; }

.inline { display: inline; }
.inline input, .inline select, .inline button { margin-right: 0.4rem; }
.inline-comms { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.inline-comms li { display: flex; align-items: center; gap: 0.35rem; }
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: var(--danger); }
.btn-link.saved { color: var(--link, var(--accent)); }
.btn-link.saved:hover { color: var(--danger); }

/* Expandable post previews in feeds: a collapsed <details> that reveals the
 * post body without leaving the feed. */
.post-preview { margin: 0.4rem 0; }
.post-preview summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; user-select: none; }
.post-preview-body {
  margin-top: 0.4rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  overflow-wrap: anywhere;
  max-height: 18rem;
  overflow: auto;
}

/* Follow-from-another-instance widget on community pages. */
.follow-from { margin: 0.75rem 0; }
.follow-from summary { cursor: pointer; color: var(--muted); }
.follow-from form { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.follow-from input, .follow-from select,
.join-remote input, .list-add input, .add-to-list select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.follow-from input { flex: 1 1 16rem; }
.follow-from code { color: var(--fg); }

/* Community and list feed header actions. */
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.actions form { margin: 0; }
.sidebar .actions {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0;
}
.sidebar .actions .btn { text-align: center; }
.sidebar .actions form { display: flex; flex-direction: column; gap: 0.4rem; }
.sidebar .actions select, .sidebar .actions input { width: 100%; }

/* Community sidebar sections. */
.sidebar-meta { margin-top: 0.75rem; }
.sidebar-head { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 1rem 0 0.25rem; }
.mods { margin-bottom: 0; }
.stats {
  margin: 0.75rem 0 0;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}
.stat {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
}
.stat dt { color: var(--muted); }
.stat dd { margin: 0; font-weight: 600; }

/* List feed header and management. */
.list-head { margin-bottom: 0.75rem; }
.list-head h1 { margin: 0; }
.list-head .list-add { margin-top: 0.5rem; }
.list-head .list-add summary { cursor: pointer; color: var(--muted); }
.list-head .list-add form { margin-top: 0.4rem; }
.list-card { margin-bottom: 1rem; }
.list-card .inline { float: right; }
.add-to-list { margin-left: 0.4rem; }

.btn {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.disabled { opacity: 0.45; cursor: default; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
}
.pager .btn { display: inline-block; }

.profile-comments li { margin-bottom: 0.75rem; }
.profile-comments .comment-content { max-height: 6em; overflow: hidden; }

.admin-links { list-style: none; padding: 0; }
.admin-links li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.admin-links a { font-weight: 600; }

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

.mono, code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
}
.invite-link {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0;
  word-break: break-all;
}

footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 720px) {
  .row { flex-direction: column; }
  .sidebar { flex: 0 0 auto; width: 100%; }
  main { padding: 0.75rem 0.75rem 2.5rem; }
  .comments { padding-left: 0.35rem; }
}
