:root {
  --maroon: #8d0011;
  --maroon-dark: #6a000d;
  --maroon-light: #fbeaec;
  --gold: #c9a227;
  --ink: #1f1f24;
  --muted: #6b6b76;
  --line: #e3e3e8;
  --bg: #f4f4f6;
  --card: #ffffff;
  --ok: #1a7f4b;
  --warn: #b7791f;
  --err: #b42318;
  --radius: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--maroon); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }
code { background: #f0f0f3; padding: .1em .3em; border-radius: 4px; font-size: .92em; }
pre { background: #f0f0f3; padding: .75rem; border-radius: 6px; overflow-x: auto; }
blockquote { border-left: 3px solid var(--line); margin: .5rem 0; padding: .25rem .75rem; color: var(--muted); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* Header */
.topbar { background: var(--maroon); color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.env-pill { background: #ffb020; color: #1f1f24; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .5rem; border-radius: 999px; margin-left: .35rem; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--maroon); font-weight: 800; font-size: .8rem; }
.topnav { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.topnav a, .topnav button { color: #fff; padding: .45rem .7rem; border-radius: 6px; font-weight: 500; background: none; border: 0; font: inherit; cursor: pointer; }
.topnav a:hover, .topnav button:hover { background: rgba(255,255,255,.14); text-decoration: none; }
.topnav .badge { background: var(--gold); color: #1f1f24; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; margin-left: .25rem; }
.topsearch { display: flex; }
.topsearch input { border: 0; border-radius: 6px; padding: .45rem .7rem; width: 180px; font: inherit; }
.btn-new { background: var(--gold) !important; color: #1f1f24 !important; font-weight: 700 !important; }
.btn-new:hover { filter: brightness(1.05); }
.banner { background: #fff7e0; border-bottom: 1px solid #f0dca0; padding: .5rem 1rem; text-align: center; font-size: .92rem; }

/* Layout */
.page { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.5rem; align-items: start; }
.layout.single { grid-template-columns: minmax(0, 1fr); }
.layout.narrow { max-width: 640px; margin: 0 auto; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } .sidebar { order: 2; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.card.tight { padding: .5rem .75rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .lead { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

/* Sidebar */
.sidebar h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .5rem; }
.group-list { list-style: none; margin: 0; padding: 0; }
.group-list li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line); }
.group-list li:first-child { border-top: 0; }
.group-list .name { flex: 1; min-width: 0; }
.group-list .name a { color: var(--ink); font-weight: 500; }
.group-list .count { color: var(--muted); font-size: .8rem; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--maroon-light); color: var(--maroon); font-weight: 700; font-size: .8rem; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar.group { border-radius: 8px; background: var(--maroon); color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--maroon); }

/* Thread list */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .75rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .7rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--maroon); border-color: var(--maroon); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); align-items: start; }
.thread-item:first-child { border-top: 0; }
.thread-item .title { font-weight: 600; font-size: 1.02rem; color: var(--ink); }
.thread-item .title:hover { color: var(--maroon); }
.thread-item .meta { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.thread-item .meta a { color: var(--muted); }
.thread-item .excerpt { color: #444; font-size: .9rem; margin-top: .2rem; }
.thread-item .stats { text-align: right; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.thread-item .stats strong { display: block; color: var(--ink); font-size: 1rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: #eee; color: #444; vertical-align: middle; }
.pill.maroon { background: var(--maroon-light); color: var(--maroon); }
.pill.gold { background: #fff3cc; color: #7a5a00; }
.pill.ok { background: #e3f5ea; color: var(--ok); }
.pill.warn { background: #fff3cc; color: #7a5a00; }
.pill.err { background: #fde8e6; color: var(--err); }
.pill.gray { background: #ececef; color: var(--muted); }

/* Thread page */
.post { padding: 1rem 0; border-top: 1px solid var(--line); }
.post:first-child { border-top: 0; padding-top: 0; }
.post-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.post-head .who { font-weight: 600; }
.post-head .when { color: var(--muted); font-size: .84rem; }
.post-body { font-size: 1rem; }
.post-body > :last-child { margin-bottom: 0; }
.post-actions { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.post.deleted .post-body { color: var(--muted); font-style: italic; }
.thread-title { font-size: 1.5rem; margin-bottom: .25rem; }
.thread-meta { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.reply-target:target { background: #fffbe6; outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--maroon); background: var(--maroon); color: #fff; font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--maroon-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--maroon); }
.btn.secondary:hover { background: var(--maroon-light); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { background: #f0f0f3; }
.btn.ghost.active { border-color: var(--maroon); color: var(--maroon); background: var(--maroon-light); }
.btn.sm { padding: .25rem .6rem; font-size: .84rem; }
.btn.danger { background: #fff; border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: #fde8e6; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn:disabled { opacity: .5; cursor: default; }
.inline-form { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--maroon); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Forms */
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: .3rem; }
.form-row .help { color: var(--muted); font-size: .84rem; margin-top: .25rem; }
.form-row ul.errorlist { color: var(--err); font-size: .86rem; margin: .25rem 0 0; padding-left: 1.1rem; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cfcfd6; border-radius: 7px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--maroon); outline-offset: 1px; border-color: var(--maroon); }
textarea { resize: vertical; min-height: 6rem; }
.form-row.check { display: flex; align-items: flex-start; gap: .5rem; }
.form-row.check label { font-weight: 500; margin: 0; }
.form-row.check input { width: auto; margin-top: .3rem; }
.radio-list label { display: flex; gap: .5rem; align-items: center; font-weight: 500; margin-bottom: .3rem; }
.radio-list input { width: auto; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.errornote { background: #fde8e6; color: var(--err); border: 1px solid #f5c2bd; padding: .6rem .8rem; border-radius: 7px; margin-bottom: 1rem; }
.markdown-hint { color: var(--muted); font-size: .82rem; }

/* Messages */
.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.messages li { padding: .6rem .9rem; border-radius: 7px; margin-bottom: .5rem; background: #e8f0fe; border: 1px solid #c6d8f7; }
.messages li.success { background: #e3f5ea; border-color: #b6e3c6; }
.messages li.error { background: #fde8e6; border-color: #f5c2bd; }
.messages li.warning { background: #fff3cc; border-color: #f0dca0; }

/* Pagination */
.pagination { display: flex; gap: .4rem; align-items: center; justify-content: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.pagination a { padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* Notifications */
.notif { display: flex; gap: .7rem; padding: .7rem 0; border-top: 1px solid var(--line); align-items: flex-start; }
.notif:first-child { border-top: 0; }
.notif.unread { font-weight: 600; }
.notif .when { color: var(--muted); font-size: .82rem; font-weight: 400; }

/* Auth pages */
.auth { max-width: 440px; margin: 2rem auto; }
.auth .card { padding: 1.5rem; }
.auth h1 { margin-bottom: 1rem; }
.auth .alt { text-align: center; margin-top: 1rem; color: var(--muted); font-size: .92rem; }

/* Manage */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .n { font-size: 1.6rem; font-weight: 700; display: block; }
.stat .l { color: var(--muted); font-size: .84rem; }
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subnav a { padding: .35rem .7rem; border-radius: 6px; color: var(--ink); font-weight: 500; border: 1px solid var(--line); background: #fff; }
.subnav a.active { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.subnav a:hover { text-decoration: none; }
.filter-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.filter-bar input[type=text] { width: 240px; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }
.checklist label { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem 0; border-top: 1px solid var(--line); font-weight: 500; cursor: pointer; }
.checklist label:first-child { border-top: 0; }
.checklist input { width: auto; margin-top: .3rem; }
.checklist .desc { color: var(--muted); font-weight: 400; font-size: .88rem; display: block; }
footer.site { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem; }
