:root {
  --ink: #1b1f24;
  --ink-soft: #3a414a;
  --muted: #6b7280;
  --paper: #ffffff;
  --paper-alt: #f3f4f6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --line: #e5e7eb;
  --max: 1100px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--paper-alt); }
img { max-width: 100%; height: auto; }
a { color: var(--accent-dark); }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }

/* header */
.site-header { background: var(--ink); color: #fff; }
.header-inner { display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; flex: 1; }
.nav a { color: #e5e7eb; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.nav .search input { padding: 6px 10px; border-radius: 6px; border: 1px solid #444; background: #2a2f36; color: #fff; min-width: 160px; }
.user-nav { display: flex; gap: 12px; align-items: center; }
.user-nav a { color: #e5e7eb; text-decoration: none; font-weight: 600; }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: .9rem; }
.site-footer .container { display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap; }

/* controls */
.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; padding: 9px 16px; border-radius: 6px; border: 2px solid var(--accent); cursor: pointer; font-size: .95rem; font-family: inherit; }
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--accent-dark); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-dark); cursor: pointer; font: inherit; text-decoration: underline; }
.field { display: block; margin: 0 0 14px; font-weight: 600; }
.field input, .field textarea, .field select, .search-form input, .editor textarea, .inline-form input, .inline-form select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; background: #fff; }
.check { display: block; margin: 0 0 14px; }
.error { color: #b91c1c; margin: -8px 0 12px; font-size: .9rem; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.narrow { max-width: 520px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.narrow h2 { margin-top: 28px; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h1 { margin-bottom: 16px; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.tag-muted { background: var(--muted); }

/* forum index */
.node-group { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 20px; overflow: hidden; }
.node-group-title { background: var(--paper-alt); border-bottom: 1px solid var(--line); padding: 10px 16px; font-size: 1rem; margin: 0; }
.node-group-title a { text-decoration: none; color: var(--ink); }
.node-row, .thread-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.node-row:last-child, .thread-row:last-child { border-bottom: 0; }
@media (min-width: 760px) {
  .node-row, .thread-row { grid-template-columns: 1fr 140px 220px; align-items: center; gap: 16px; }
}
.node-main h3, .thread-main h3 { margin: 0 0 2px; }
.node-main h3 a, .thread-main h3 a { text-decoration: none; color: var(--ink); }
.node-main h3 a:hover, .thread-main h3 a:hover { color: var(--accent-dark); }
.node-main p { margin: 0; font-size: .9rem; }
.subforums a { margin-right: 12px; font-size: .9rem; }
.node-counts, .thread-counts { display: flex; gap: 12px; font-size: .85rem; color: var(--muted); }
@media (min-width: 760px) { .node-counts, .thread-counts { flex-direction: column; gap: 0; } }
.node-last, .thread-last { font-size: .85rem; display: flex; flex-direction: column; }
.node-last a, .thread-last a { text-decoration: none; }
.stats { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }

/* thread list */
.thread-list { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.thread-row.sticky { background: #fffbeb; }
.thread-row.deleted { opacity: .6; }
.thread-main .muted { font-size: .85rem; }
.pages { margin-left: 8px; font-size: .8rem; }
.pages a { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-radius: 3px; margin-right: 2px; text-decoration: none; }

/* posts */
.posts { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.post { display: grid; grid-template-columns: 1fr; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
@media (min-width: 760px) { .post { grid-template-columns: 180px 1fr; } }
.post.deleted { opacity: .6; }
.post-author { background: var(--paper-alt); padding: 14px; display: flex; gap: 12px; align-items: flex-start; border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .post-author { flex-direction: column; border-bottom: 0; border-right: 1px solid var(--line); } }
.post-author div { display: flex; flex-direction: column; gap: 2px; }
.username { font-weight: 700; text-decoration: none; word-break: break-word; }
.avatar { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.avatar-letter { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 1.6rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 2.4rem; }
.post-body { padding: 14px 18px; min-width: 0; }
.post-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.post-meta a { color: var(--muted); text-decoration: none; }
.post-actions { display: flex; gap: 14px; margin-top: 12px; font-size: .85rem; }
.post-actions form { display: inline; }
.signature { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 8px; font-size: .85rem; color: var(--muted); }
.attachments { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attachments img { max-width: 240px; max-height: 240px; width: auto; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.reply-box { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-top: 20px; }
.mod-tools { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 8px 14px; margin-bottom: 14px; font-size: .9rem; }
.mod-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.mod-row form, .inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { width: auto; margin: 0; padding: 5px 8px; }

/* editor */
.editor { border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; margin-bottom: 12px; }
.bb-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--paper-alt); }
.bb-toolbar button { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 4px 9px; cursor: pointer; font: inherit; font-size: .85rem; }
.bb-toolbar button:hover { border-color: var(--accent); }
.editor textarea { border: 0; border-radius: 0 0 6px 6px; margin: 0; resize: vertical; min-height: 160px; }
.preview { padding: 12px 14px; border-top: 1px solid var(--line); }

/* rendered BBCode */
.bb { overflow-wrap: anywhere; }
.bb img { max-width: 100%; }
.bb-img img, .bb-attach img { max-width: 100%; max-height: 600px; width: auto; height: auto; }
.bb-quote { margin: 10px 0; padding: 8px 14px; border-left: 4px solid #cbd5e1; background: var(--paper-alt); border-radius: 0 6px 6px 0; }
.bb-quote-attr { font-weight: 700; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.bb-code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 6px; overflow-x: auto; font-size: .9em; }
.bb-code code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bb-spoiler { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin: 8px 0; }
.bb-spoiler summary { cursor: pointer; font-weight: 600; }
.bb-ispoiler { background: var(--ink); color: var(--ink); border-radius: 3px; }
.bb-ispoiler:hover { color: #fff; }
.bb-media { aspect-ratio: 16 / 9; max-width: 640px; margin: 10px 0; }
.bb-media iframe { width: 100%; height: 100%; border: 0; border-radius: 6px; }
.bb-indent { margin-left: 24px; }
.bb ul, .bb ol { margin: 6px 0 10px; }

/* misc */
.result { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; }
.result-title { font-weight: 700; text-decoration: none; display: block; }
.result p { margin: 6px 0 0; font-size: .95rem; color: var(--ink-soft); }
.search-form { display: flex; gap: 8px; max-width: 520px; margin-bottom: 16px; }
.search-form input { margin: 0; }
.profile { display: flex; gap: 20px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.table .num { text-align: right; }

/* pagination */
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; font-size: .9rem; }
.pager-item { display: inline-block; min-width: 32px; text-align: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; text-decoration: none; }
.pager-item.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager-item.disabled { color: var(--muted); }
