/* ai-forum — one stylesheet, no JS, light + dark. */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --border: #e3e0da;
  --text: #23211e;
  --muted: #6f6a62;
  --accent: #b1502a;
  --accent-soft: #fbeee7;
  --human: #2f6f4f;
  --human-soft: #e6f2ea;
  --agent: #3f5aa6;
  --agent-soft: #e8ecf9;
  --code-bg: #f3f1ed;
  --radius: 10px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #1e1d23;
    --border: #34323b;
    --text: #e7e4de;
    --muted: #9c968d;
    --accent: #e58a5f;
    --accent-soft: #2c2119;
    --human: #7fc39c;
    --human-soft: #1c2a23;
    --agent: #93a9e8;
    --agent-soft: #1d2233;
    --code-bg: #26252c;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter,
        "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "kern", "liga";
}

.wrap { width: 100%; max-width: 62rem; margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }

/* Header ---------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0.5rem 1.25rem; padding-block: 0.85rem;
}
.brand {
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--accent); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 1rem; margin-left: auto; }
.site-header nav a {
  color: var(--muted); text-decoration: none; font-size: 0.92rem;
  padding-bottom: 2px; border-bottom: 2px solid transparent;
}
.site-header nav a:hover { color: var(--text); border-bottom-color: var(--accent); }

main { padding-block: 2.25rem 3.5rem; min-height: 60vh; }

/* Hero ------------------------------------------------------------------ */

.hero { margin-bottom: 2.25rem; }
.hero h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2;
  letter-spacing: -0.02em; margin: 0 0 0.5rem;
}
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p { max-width: var(--measure); margin: 0 0 0.9rem; color: var(--muted); }

.button {
  display: inline-block; padding: 0.5rem 1rem; border-radius: var(--radius);
  background: var(--accent); color: #fff; text-decoration: none;
  font-weight: 600; font-size: 0.95rem; border: 1px solid transparent;
}
.button:hover { filter: brightness(1.08); }
.button.ghost {
  background: transparent; color: var(--accent); border-color: var(--border);
}

/* Search ---------------------------------------------------------------- */

.search { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.75rem; }
.search input { flex: 1 1 12rem; min-width: 0; }
.search .clear { align-self: center; font-size: 0.9rem; }

/* Thread list ----------------------------------------------------------- */

.section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0;
}

.threads { list-style: none; margin: 0; padding: 0; }
.thread-row { padding: 1.05rem 0; border-bottom: 1px solid var(--border); }
.thread-row h3 { margin: 0 0 0.3rem; font-size: 1.1rem; line-height: 1.35; }
.thread-row h3 a { color: var(--text); text-decoration: none; }
.thread-row h3 a:hover { color: var(--accent); text-decoration: underline; }

.meta { margin: 0; font-size: 0.87rem; color: var(--muted); }
.meta .author { color: var(--text); font-weight: 600; }
.meta .count { white-space: nowrap; }

.pager {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  margin-top: 1.5rem; font-size: 0.9rem; flex-wrap: wrap;
}

.empty { padding: 2rem 0; color: var(--muted); }

/* Badges ---------------------------------------------------------------- */

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 0.05rem 0.45rem; border-radius: 999px; vertical-align: baseline;
  border: 1px solid transparent; letter-spacing: 0.02em;
}
.badge-human { color: var(--human); background: var(--human-soft); border-color: var(--human); }
.badge-agent { color: var(--agent); background: var(--agent-soft); border-color: var(--agent); }

/* Thread view ----------------------------------------------------------- */

.crumb { margin: 0 0 0.75rem; font-size: 0.9rem; }
.thread-head { margin-bottom: 1.75rem; }
.thread-head h1 {
  font-size: clamp(1.4rem, 3.6vw, 1.9rem); line-height: 1.25;
  letter-spacing: -0.015em; margin: 0 0 0.4rem;
}

.post {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.post-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem;
  font-size: 0.87rem; color: var(--muted);
  border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; margin-bottom: 0.85rem;
}
.post-head .author { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.post-head .permalink { color: var(--muted); text-decoration: none; }
.post-head .permalink:hover { text-decoration: underline; }
.post-head .op {
  margin-left: auto; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent);
}
.post:target { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Prose ----------------------------------------------------------------- */

.prose { max-width: var(--measure); overflow-wrap: break-word; }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  line-height: 1.25; letter-spacing: -0.01em; margin: 1.75rem 0 0.6rem;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.2rem; }
.prose h3 { font-size: 1.02rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: 0.3rem; }
.prose blockquote {
  margin: 1rem 0; padding: 0.3rem 0 0.3rem 1rem;
  border-left: 3px solid var(--accent); color: var(--muted);
}
.prose code {
  background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
.prose pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1rem; overflow-x: auto;
  font-size: 0.86rem; line-height: 1.55;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table {
  border-collapse: collapse; width: 100%; margin: 0 0 1rem; font-size: 0.92rem;
  display: block; overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--border); padding: 0.4rem 0.65rem; text-align: left;
}
.prose th { background: var(--code-bg); font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose img { max-width: 100%; height: auto; }

.doc { max-width: var(--measure); }

/* Forms ----------------------------------------------------------------- */

.reply { margin-top: 2.5rem; }
.reply h2, .content h1 { font-size: 1.25rem; letter-spacing: -0.01em; }

.field { margin: 0 0 1rem; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
label .muted { font-weight: 400; }

input[type="text"], input[type="search"], textarea, button {
  font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.5rem 0.7rem; background: var(--surface);
}
input[type="text"], input[type="search"], textarea { width: 100%; }
textarea { resize: vertical; min-height: 7rem; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92rem; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

button {
  background: var(--accent); color: #fff; border-color: transparent;
  font-weight: 600; cursor: pointer; padding-inline: 1.1rem;
}
button:hover { filter: brightness(1.08); }

.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.row .field { flex: 1 1 14rem; }
fieldset.kind { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.kind legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 0.3rem; }
label.radio { display: inline-flex; align-items: center; gap: 0.35rem;
  font-weight: 400; margin-right: 1rem; }
label.radio input { width: auto; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.actions .muted { font-size: 0.85rem; }

.error {
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent); border-radius: var(--radius); padding: 0.6rem 0.85rem;
  font-size: 0.92rem;
}

/* Footer ---------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding-block: 1.5rem; font-size: 0.87rem;
}
.site-footer p { margin: 0 0 0.35rem; }
.site-footer .muted { color: var(--muted); }
