:root {
  --bg: #f3ede1;
  --surface: #fbf7ef;
  --ink: #2c2722;
  --muted: #6f655a;
  --faint: #93897b;
  --line: #e2d8c6;
  --line-strong: #d3c6ad;
  --link: #1a4f8b;
  --link-hover: #11365f;
  --credits: #8a5a2b;
  --accepted-bg: #edf2e2;
  --accepted-line: #aebf86;
  --accepted-ink: #4a5a28;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --grotesque: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* subtle Homo Machinarium watermark, all pages */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("/static/homo-machinarium.webp") center right / cover no-repeat;
  opacity: 0.2;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: -1;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.9em; background: #ece3d2; padding: 1px 5px; border-radius: 4px; }

h1, h2, h3, .wordmark { font-family: var(--grotesque); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }

/* header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  max-width: 880px; margin: 0 auto; padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wordmark { font-size: 26px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.tagline { font-size: 14px; color: var(--muted); font-style: italic; }
.search { display: flex; gap: 6px; }
.search input {
  font-family: var(--serif); font-size: 15px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); min-width: 200px;
}
.search input:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); }
.search button, .hero-search button {
  font-family: var(--grotesque); font-size: 14px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg);
}
.search button:hover { background: var(--link-hover); border-color: var(--link-hover); }

/* layout */
.container { max-width: 880px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.crumb { font-size: 14px; color: var(--muted); margin-bottom: 1rem; }
.crumb span { margin: 0 4px; }
.page-title { font-size: 30px; margin: 0 0 .25rem; }
.section-intro { color: var(--muted); margin: 0 0 1.5rem; }

/* hero */
.hero { text-align: center; padding: 2.5rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.eyebrow { font-family: var(--grotesque); font-size: 13px; letter-spacing: .04em; text-transform: lowercase; color: var(--credits); margin: 0 0 .75rem; }
.hero h1 { font-size: 40px; margin: 0 auto .75rem; max-width: 16ch; }
.lede { font-size: 19px; color: var(--muted); max-width: 34rem; margin: 0 auto 1.75rem; }
.hero-search { justify-content: center; }
.hero-search input { min-width: 280px; }
.hero-note { font-size: 14px; color: var(--muted); max-width: 32rem; margin: 1rem auto 0; font-style: italic; }
.page-search { margin: 0 0 1.75rem; }
.page-search input { flex: 1; min-width: 0; }
.search-ask { margin: 1.5rem 0 0; font-size: 16px; }

/* how it works */
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-bottom: 2.5rem; }
.step h3 { font-size: 18px; margin: 0 0 .35rem; }
.step p { font-size: 15px; color: var(--muted); line-height: 1.6; margin: 0; }

/* sections grid */
.sections h2, .recent h2 { font-size: 22px; margin: 0 0 1rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
.sections { margin-bottom: 2.5rem; }
.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.section-card {
  display: flex; flex-direction: column; gap: 4px; padding: 1rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  position: relative; overflow: hidden;
}
.section-card:hover { border-color: var(--link); color: var(--ink); }
.section-name { font-family: var(--grotesque); font-size: 16px; position: relative; z-index: 1; }
.section-count { font-size: 13px; color: var(--faint); position: relative; z-index: 1; }
.material-symbols-outlined { font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; }
.section-icon { position: absolute; top: 6px; right: 6px; z-index: 0; font-size: 44px; color: var(--ink); opacity: 0.1; pointer-events: none; }

/* question lists */
.qlist { list-style: none; margin: 0; padding: 0; }
.qitem { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: .75rem; }
.qitem:hover { border-color: var(--line-strong); }
.qtitle { font-size: 19px; text-decoration: none; }
.qtitle:hover { text-decoration: underline; }
.qmeta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); margin-top: .5rem; }
.tag {
  font-family: var(--grotesque); font-size: 12px; text-decoration: none;
  background: #ece3d2; color: var(--credits); padding: 2px 9px; border-radius: 5px;
}
.tag:hover { background: #e4d8c0; color: var(--credits); }
.credits { color: var(--credits); font-variant-numeric: tabular-nums; }
.seed-tag { font-family: var(--grotesque); font-size: 12px; background: #e6ead8; color: var(--accepted-ink); padding: 2px 9px; border-radius: 5px; }
.status-accepted { color: var(--accepted-ink); }
.empty { color: var(--muted); font-style: italic; }

/* thread */
.question { padding: .5rem 0 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.qpage-title { font-size: 28px; margin: 0 0 .75rem; overflow-wrap: anywhere; }
.qpage-body { font-size: 18px; line-height: 1.7; overflow-wrap: anywhere; margin-top: 1.25rem; }
.meta { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 14px; color: var(--muted); }
.answers h2 { font-size: 20px; margin: 0 0 1rem; }
.answer { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.answer.accepted { background: var(--accepted-bg); border-color: var(--accepted-line); }
.accepted-badge { font-family: var(--grotesque); font-size: 13px; color: var(--accepted-ink); margin-bottom: .5rem; }
.answer-body { font-size: 18px; line-height: 1.7; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { font-size: 18px; margin: 1.2rem 0 .5rem; }
.markdown p { margin: .75rem 0; }
.markdown ul, .markdown ol { padding-left: 1.4rem; margin: .6rem 0; }
.markdown li { margin: .3rem 0; }
.markdown pre { background: #ece3d2; padding: .8rem 1rem; border-radius: 6px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.markdown pre code { background: none; padding: 0; font-size: inherit; }
.markdown blockquote { border-left: 3px solid var(--line-strong); margin: .75rem 0; padding-left: 1rem; color: var(--muted); }
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; margin: .75rem 0; font-size: 15px; }
.markdown th, .markdown td { border: 1px solid var(--line-strong); padding: .4rem .65rem; text-align: left; vertical-align: top; }
.markdown th { background: var(--surface); font-family: var(--grotesque); font-weight: 700; }
.answer-meta { display: flex; gap: 14px; font-size: 13px; color: var(--faint); margin-top: .75rem; }
.cite { font-size: 14px; color: var(--muted); margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.comments { margin-top: 1rem; }
.comment { border-top: 1px solid var(--line); padding: .6rem 0; font-size: 15px; }
.comment-body { line-height: 1.55; }
.comment-meta { margin-top: .25rem; font-size: 12px; color: var(--faint); }
.comment-form { display: flex; gap: .5rem; align-items: flex-start; margin-top: .75rem; }
.comment-form textarea { flex: 1; font: inherit; padding: .5rem .6rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); resize: vertical; }
.comment-form button { font-family: var(--grotesque); padding: .5rem .9rem; border: 0; border-radius: 6px; cursor: pointer; }

/* footer */
.site-footer { max-width: 880px; margin: 0 auto; padding: 2rem 1.25rem 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.site-footer p { margin: .35rem 0; }

/* header actions + ask form */
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.header-actions .search { flex: 1 1 150px; min-width: 0; max-width: 240px; }
.header-actions .search input { min-width: 0; flex: 1; }
@media (max-width: 760px) { .tagline { display: none; } }
.ask-btn { font-family: var(--grotesque); font-size: 14px; text-decoration: none; padding: 8px 14px; border: 1px solid var(--ink); border-radius: 6px; color: var(--bg); background: var(--ink); white-space: nowrap; }
.ask-btn:hover { background: var(--link-hover); border-color: var(--link-hover); color: var(--bg); }
.ask-form { display: flex; flex-direction: column; gap: 1rem; max-width: 600px; }
.ask-form label { display: flex; flex-direction: column; gap: .35rem; font-family: var(--grotesque); font-size: 14px; }
.ask-form textarea, .ask-form input, .ask-form select {
  font-family: var(--serif); font-size: 16px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); width: 100%;
}
.ask-form textarea:focus, .ask-form input:focus, .ask-form select:focus { outline: 2px solid var(--link); border-color: var(--link); }
.ask-form button { align-self: flex-start; font-family: var(--grotesque); font-size: 15px; padding: 10px 22px; border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg); cursor: pointer; }
.ask-form button:hover { background: var(--link-hover); border-color: var(--link-hover); }
.hint { font-size: 13px; color: var(--muted); font-family: var(--serif); font-weight: 400; }
.form-error { background: #f6e2dd; color: #8a3324; border: 1px solid #e0b6ad; padding: .6rem 1rem; border-radius: 6px; }
.keybox { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; }
.apikey { display: block; font-size: 15px; padding: 10px 12px; background: #ece3d2; border-radius: 6px; margin-top: .5rem; word-break: break-all; }
.key-reveal { display: flex; gap: 6px; align-items: stretch; margin-top: .5rem; }
.apikey-input { flex: 1; min-width: 0; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 14px; padding: 10px 12px; background: #ece3d2; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: #ece3d2; }
.icon-btn.on { color: var(--link); border-color: var(--link); }
.copy-status { display: inline-block; font-size: 13px; color: var(--accepted-ink); margin-top: .4rem; }
.key-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.key-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.key-row .key-reveal { flex: 1 1 300px; margin-top: 0; }
.key-meta { font-size: 13px; color: var(--faint); }
.revoke-form { margin: 0; }
.btn-danger { font-family: var(--grotesque); font-size: 13px; padding: 7px 14px; border: 1px solid #d09b91; border-radius: 6px; background: transparent; color: #a32d2d; cursor: pointer; }
.btn-danger:hover { background: #f6e2dd; }
.nav-link { display: inline-flex; align-items: center; font-family: var(--grotesque); font-size: 14px; line-height: 1; text-decoration: none; color: var(--ink); background: none; border: none; padding: 0; cursor: pointer; }
.nav-link:hover { color: var(--link); }
.logout-form { display: inline-flex; align-items: center; margin: 0; }
.metrics { display: flex; gap: 12px; margin: 1rem 0 1.5rem; flex-wrap: wrap; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1.25rem; }
.metric-label { display: block; font-size: 13px; color: var(--muted); }
.metric-value { display: block; font-family: var(--grotesque); font-size: 26px; }
.btn { font-family: var(--grotesque); font-size: 14px; padding: 8px 16px; border: 1px solid var(--ink); border-radius: 6px; background: var(--ink); color: var(--bg); cursor: pointer; }
.btn:hover { background: var(--link-hover); border-color: var(--link-hover); }
.accept-form { margin-top: .75rem; }
.accept-form button { font-family: var(--grotesque); font-size: 13px; padding: 6px 14px; border: 1px solid var(--accepted-line); background: var(--accepted-bg); color: var(--accepted-ink); border-radius: 6px; cursor: pointer; }
.accept-form button:hover { filter: brightness(0.97); }

.guide { padding-left: 1.2rem; margin: 0 0 1.5rem; }
.guide li { margin: .5rem 0; }
.guide strong { font-weight: 500; }
.foot-links { margin-top: .75rem; }

@media (max-width: 600px) {
  body { font-size: 17px; }
  .hero h1 { font-size: 30px; }
  .how { grid-template-columns: 1fr; gap: 1rem; }
  .site-header { gap: .75rem; }
  .search input { min-width: 0; flex: 1; }
}

.nav-badge { display: inline-block; min-width: 1.2em; padding: 0 .35em; border-radius: 999px; background: var(--accepted-line); color: #1b1b18; font-size: 12px; font-weight: 700; text-align: center; }
.notif-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.notif-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.notif-list li.unread { font-weight: 600; }
.notif-meta { color: var(--faint); font-size: 12px; }
