:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --border: #e3e6ea;
  --cat: #334155;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

/* header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.8rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.search { display: flex; gap: 0.4rem; }
.search input {
  padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  min-width: min(50vw, 320px); font-size: 0.95rem;
}
.search button {
  padding: 0.45rem 0.9rem; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.search button:hover { filter: brightness(1.05); }

/* layout */
.breadcrumbs {
  max-width: 980px; margin: 1rem auto 0; padding: 0 1rem;
  color: var(--muted); font-size: 0.9rem;
}
.breadcrumbs .sep { margin: 0 0.4rem; color: #c3c9d2; }
#app { max-width: 980px; margin: 0.75rem auto 3rem; padding: 0 1rem; }
.loading, .error, .notfound { color: var(--muted); padding: 2rem 0; }
.error { color: #b42318; }

h1 { font-size: 1.5rem; margin: 0.4rem 0 1rem; }

/* forum index */
.cat {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #fff; background: var(--cat);
  padding: 0.5rem 0.85rem; border-radius: 8px 8px 0 0; margin: 1.4rem 0 0;
}
.forum-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--panel); border: 1px solid var(--border); border-top: 0;
  padding: 0.85rem 1rem;
}
.forum-row:first-of-type { border-top: 1px solid var(--border); border-radius: 8px 8px 0 0; }
.forum-name { font-weight: 600; font-size: 1.05rem; }
.forum-desc { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }
.forum-stats { display: flex; gap: 1rem; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

/* topic list */
.topic-list table, .thread { width: 100%; }
table {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
th, td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafbfc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; color: var(--muted); }
.t-title a { font-weight: 600; }
.t-preview { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.t-author, .t-date { white-space: nowrap; color: var(--muted); font-size: 0.9rem; }

.subforums { margin: 0.5rem 0 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.2rem 0.7rem; font-size: 0.85rem;
}

/* tags */
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.05rem 0.45rem;
  border-radius: 999px; margin-left: 0.4rem; vertical-align: middle;
}
.tag.locked { background: #fef3c7; color: #92400e; }
.tag.guest { background: #e0e7ff; color: #3730a3; }
.tag.deleted-tag { background: #fee2e2; color: #991b1b; }

/* thread / posts */
.post {
  display: grid; grid-template-columns: 170px 1fr; gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.post.deleted { opacity: 0.6; }
.post-author { background: #fafbfc; padding: 1rem; text-align: center; }
.post-body { background: var(--panel); padding: 1rem 1.2rem; min-width: 0; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: inline-block;
}
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 1.5rem;
}
.post-author-name { margin-top: 0.5rem; font-weight: 600; }
.post-author-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }
.post-head {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0.7rem;
}
.post-subject { font-weight: 600; }
.post-date { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.post-content { overflow-wrap: anywhere; }
.post-content img { max-width: 100%; height: auto; }

/* rendered bbcode */
.bb-u { text-decoration: underline; }
.bb-quote {
  margin: 0.6rem 0; padding: 0.5rem 0.9rem; border-left: 3px solid var(--accent);
  background: #f8fafc; border-radius: 0 8px 8px 0; color: #334155;
}
.bb-quote cite { display: block; font-weight: 600; font-style: normal; color: var(--muted); margin-bottom: 0.25rem; }
.bb-code {
  background: #0f172a; color: #e2e8f0; padding: 0.8rem 1rem; border-radius: 8px;
  overflow-x: auto; font: 0.85rem/1.5 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* author links */
.author-link { color: inherit; }
.author-link .author { color: inherit; }
.author-link:hover { text-decoration: underline; }

/* user profile */
.user-head { display: flex; align-items: center; gap: 1rem; margin: 0.4rem 0 0.6rem; }
.user-head h1 { margin: 0; }
.user-profile h2 { font-size: 1.05rem; margin: 1.2rem 0 0.6rem; }

/* search + profile post lists */
.search-summary { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0 1.2rem; }
.hits { list-style: none; padding: 0; margin: 0 0 1.4rem; }
.hits li {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
}
.hits li.empty { color: var(--muted); border-style: dashed; }
.hit-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.hit-title { font-weight: 600; }
.hit-meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.hit-meta a { color: var(--muted); text-decoration: underline; }
.where {
  font-size: 0.7rem; font-weight: 600; color: var(--accent);
  background: #eff6ff; border-radius: 999px; padding: 0.05rem 0.5rem;
}
.snippet { color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; overflow-wrap: anywhere; }
.snippet mark, mark {
  background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px;
}
.post.target { animation: post-flash 2s ease-out; }
@keyframes post-flash {
  from { box-shadow: 0 0 0 3px var(--accent); }
  to { box-shadow: var(--shadow); }
}

/* unlock gate (encrypted archives) */
.unlock {
  max-width: 420px; margin: 3rem auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.6rem 1.5rem; text-align: center;
}
.unlock h1 { margin: 0 0 0.5rem; }
.unlock p { color: var(--muted); margin: 0 0 1rem; }
.unlock-form { display: flex; gap: 0.5rem; }
.unlock-form input {
  flex: 1; padding: 0.5rem 0.7rem; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.95rem;
}
.unlock-form button {
  padding: 0.5rem 1rem; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.unlock-form button:disabled { opacity: 0.6; cursor: default; }
.unlock .error { margin: 0.9rem 0 0; }

/* footer */
.site-footer {
  max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem;
  color: var(--muted); font-size: 0.82rem; text-align: center;
}

@media (max-width: 620px) {
  .post { grid-template-columns: 1fr; }
  .post-author { display: flex; align-items: center; gap: 0.6rem; text-align: left; }
  .post-author-name, .post-author-meta { margin: 0; }
  .forum-stats { flex-direction: column; gap: 0.1rem; text-align: right; }
}
