/* ── Reset & base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f2ee;
  --surface:  #ffffff;
  --border:   #ddd8ce;
  --primary:  #5a3e28;
  --accent:   #a06030;
  --text:     #2c2218;
  --muted:    #7a6a58;
  --link:     #a06030;
  --link-h:   #7a4a20;
  --cat-bg:   #3b2a1a;
  --cat-fg:   #f4ede4;
  --shadow:   0 1px 3px rgba(0,0,0,.10);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Header ────────────────────────────────────── */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: .75rem 0;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.site-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
}
.site-title:hover { color: #ffe8cc; text-decoration: none; }
.site-sub {
  font-size: .85rem;
  color: rgba(255,255,255,.6);
  flex: 1;
}
.logout-link {
  font-size: .8rem;
  color: rgba(255,255,255,.5);
  padding: .25rem .6rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px;
}
.logout-link:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
  text-decoration: none;
}

/* ── Main ──────────────────────────────────────── */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* ── Footer ────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Breadcrumb ────────────────────────────────── */
.breadcrumb {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

/* ── Page header ───────────────────────────────── */
.page-header {
  margin-bottom: 1.25rem;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .25rem;
}
.count-info {
  font-size: .85rem;
  color: var(--muted);
}

/* ── Index page ────────────────────────────────── */
.category {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cat-title {
  background: var(--cat-bg);
  color: var(--cat-fg);
  font-size: .95rem;
  font-weight: 600;
  padding: .55rem 1rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.forum-list { background: var(--surface); }
.forum-row {
  display: flex;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.forum-row:last-child { border-bottom: none; }
.forum-info { flex: 1; min-width: 0; }
.forum-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.forum-name:hover { color: var(--accent); }
.forum-desc {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .15rem;
}
.forum-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  gap: .1rem;
}

/* ── Topic table ───────────────────────────────── */
.topic-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.topic-table thead {
  background: #ede8e0;
}
.topic-table th {
  padding: .55rem .8rem;
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.topic-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.topic-row:last-child td { border-bottom: none; }
.topic-row:hover { background: #faf7f2; }
.col-title { width: 60%; }
.col-author { width: 18%; font-size: .85rem; color: var(--muted); }
.col-num { width: 11%; text-align: center; font-size: .85rem; color: var(--muted); }
.col-title a { color: var(--text); font-weight: 500; }
.col-title a:hover { color: var(--accent); }
.badge-locked { font-size: .8rem; }
.topic-locked .col-title a { color: var(--muted); }

/* ── Posts ─────────────────────────────────────── */
.posts { display: flex; flex-direction: column; gap: .75rem; }

.post {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.post-author {
  width: 130px;
  min-width: 130px;
  background: #f7f3ee;
  border-right: 1px solid var(--border);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  text-align: center;
}
.avatar, .avatar-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: #e8e0d5;
  color: var(--muted);
}
.author-name {
  font-weight: 600;
  font-size: .85rem;
  color: var(--text);
  word-break: break-word;
}
.author-name:hover { color: var(--accent); }
.post-count {
  font-size: .75rem;
  color: var(--muted);
}
.post-content { flex: 1; min-width: 0; padding: .75rem 1rem; }
.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .6rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.post-link { color: var(--muted); }
.post-link:hover { color: var(--accent); }
.post-subject {
  font-weight: 600;
  margin-bottom: .5rem;
  color: var(--primary);
}
.post-body {
  font-size: .92rem;
  line-height: 1.65;
  overflow-wrap: break-word;
  word-break: break-word;
}
.post-body blockquote {
  border-left: 3px solid var(--accent);
  background: #f7f3ee;
  padding: .5rem .75rem;
  margin: .5rem 0;
  font-size: .88rem;
  color: var(--muted);
  border-radius: 0 4px 4px 0;
}
.post-body blockquote cite {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: .8rem;
  color: var(--accent);
  margin-bottom: .3rem;
}
.post-body pre {
  background: #f0ece6;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .6rem .8rem;
  overflow-x: auto;
  font-size: .85rem;
  margin: .5rem 0;
}
.post-body .post-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: .25rem 0;
}

/* ── Member page ───────────────────────────────── */
.member-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  font-size: 2.5rem;
}
.member-info h1 { font-size: 1.3rem; color: var(--primary); }
.member-info p { font-size: .88rem; color: var(--muted); margin-top: .2rem; }

.member-sig {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.member-sig h3 { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }

.recent-posts h2 { font-size: 1rem; margin-bottom: .75rem; color: var(--primary); }
.recent-post-row {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.recent-post-row:last-child { border-bottom: none; }
.rp-date { color: var(--muted); white-space: nowrap; font-size: .8rem; min-width: 130px; }
.rp-title { color: var(--text); }
.rp-title:hover { color: var(--accent); }

/* ── Pagination ────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: 1.25rem;
  font-size: .88rem;
}
.pagination-top { margin-top: 0; margin-bottom: .75rem; }
.page-btn {
  padding: .35rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: .85rem;
}
.page-btn:hover {
  background: #ede8e0;
  text-decoration: none;
  color: var(--primary);
}
.page-info { color: var(--muted); }

.empty { color: var(--muted); font-style: italic; padding: 1rem 0; }

/* ── Login page ────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.login-title {
  font-size: 1.4rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: .2rem;
}
.login-sub {
  font-size: .82rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.login-form label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}
.login-form input {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button {
  margin-top: .6rem;
  padding: .6rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.login-form button:hover { background: var(--accent); }
.login-error {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  padding: .5rem .75rem;
  font-size: .88rem;
  margin-bottom: .4rem;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 600px) {
  .post { flex-direction: column; }
  .post-author {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: .6rem 1rem;
    justify-content: flex-start;
    gap: .75rem;
  }
  .avatar, .avatar-placeholder { width: 40px; height: 40px; font-size: 1.2rem; }
  .forum-stats { display: none; }
  .col-author, .col-num { display: none; }
  .col-title { width: 100%; }
  .member-card { flex-direction: column; align-items: flex-start; }
}
