:root {
  --bg: #f5f4ef;
  --card: #fffef9;
  --text: #222;
  --muted: #888;
  --line: #e5e0d4;
  --line-soft: #efebe3;
  --accent: #2e8b57;
  --accent-hover: #247048;
  --accent-soft: #eef7f1;
  --douban: #072;
  --danger: #b33;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-hover); }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 12px; }

.top {
  background: #2c2c2c;
  color: #f5f5f5;
  padding: 14px 0 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--accent);
}
.top h1 { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: .02em; }
.top h1 a { color: inherit; text-decoration: none; }
.sub { margin: 3px 0 0; color: #aaa; font-size: .8rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.hidden { display: none !important; }
.section-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* Group picker — compact rows */
.group-list { display: flex; flex-direction: column; gap: 0; margin: -4px -14px; }
.group-btn {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  padding: 11px 14px;
  border: none; border-bottom: 1px solid var(--line-soft);
  background: transparent;
  cursor: pointer; font: inherit; color: inherit;
}
.group-btn:last-child { border-bottom: none; }
.group-btn:hover { background: var(--accent-soft); }
.group-btn strong { font-weight: 600; color: var(--douban); }
.group-btn span { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* Toolbar + search */
.toolbar { padding: 10px 12px; }
.toolbar-simple { padding: 8px 12px; }
.toolbar-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.list-heading {
  margin: 0; flex: 1; font-size: 1rem; font-weight: 600;
  color: var(--text);
}
.linkish {
  background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 0; font-size: .88rem;
}
.linkish:hover { color: var(--accent-hover); text-decoration: underline; }

.search {
  display: flex; gap: 6px; align-items: stretch; width: 100%;
}
.search select {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
  max-width: 7.5em;
}
.search input {
  flex: 1; min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .92rem;
  background: #fff;
}
.search input:focus, .search select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(46,139,87,.15);
}
.search button, .pager button {
  padding: 7px 14px; border: none; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer; font-size: .88rem;
  white-space: nowrap;
}
.search button:hover { background: var(--accent-hover); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button.ghost {
  background: #f0eee8; color: var(--text);
}
.pager button.ghost:hover:not(:disabled) { background: #e5e2d8; }

/* Topic list — dense forum rows */
.topic-list, .reply-list, .list {
  padding: 0; overflow: hidden;
}
.topic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  align-items: baseline;
  width: 100%; text-align: left;
  padding: 9px 14px;
  border: none; border-bottom: 1px solid var(--line-soft);
  background: transparent; cursor: pointer;
  font: inherit; color: inherit;
}
.topic-row:last-child { border-bottom: none; }
.topic-row:hover { background: #faf8f2; }
.topic-row:hover .row-title { color: var(--accent); }

.row-main { min-width: 0; grid-column: 1; }
.row-title {
  font-weight: 500;
  font-size: .95rem;
  line-height: 1.4;
  margin: 0;
  color: #1a1a1a;
  /* keep long titles readable without huge blocks */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.35;
}
.row-side {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  text-align: right;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.35;
  white-space: nowrap;
}
.row-side .rc {
  display: block;
  color: #666;
  font-variant-numeric: tabular-nums;
}
.row-side .rc em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}
.row-side .tm { display: block; margin-top: 1px; }

.badge {
  display: inline-block; padding: 0 5px; border-radius: 3px;
  background: #eee; font-size: .68rem; margin-left: 5px;
  vertical-align: middle; font-weight: 400; color: #666;
}
.badge.del { background: #fde8e8; color: var(--danger); }
.badge.reply-hit { background: var(--accent-soft); color: var(--accent); }

.topic h2 { margin: 0 0 6px; font-size: 1.15rem; font-weight: 600; }
.topic .body {
  white-space: pre-wrap; word-break: break-word;
  margin: 12px 0; font-size: .95rem; line-height: 1.65;
}
.meta { color: var(--muted); font-size: .8rem; }
.imgs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.imgs img {
  max-width: 100%; max-height: 280px; border-radius: 6px;
  border: 1px solid var(--line);
}
.replies-h {
  margin: 6px 2px 4px; font-size: .9rem;
  color: var(--muted); font-weight: 500;
}
.reply {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.reply:last-child { border-bottom: none; }
.reply .text {
  white-space: pre-wrap; word-break: break-word;
  margin: 5px 0 0; font-size: .92rem; line-height: 1.55;
}

.pager {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  justify-content: center; margin: 6px 0 22px;
  color: var(--muted); font-size: .85rem;
}
.error {
  background: #fde8e8; color: var(--danger);
  padding: 10px 14px; border-radius: 6px;
}
.foot { color: var(--muted); padding: 4px 12px 24px; font-size: .8rem; }
.empty { color: var(--muted); padding: 18px; text-align: center; font-size: .9rem; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .topic-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 12px;
  }
  .row-side {
    grid-column: 1;
    grid-row: auto;
    text-align: left;
    white-space: normal;
  }
  .row-side .rc, .row-side .tm { display: inline; }
  .row-side .rc::after { content: " · "; }
  .row-title { -webkit-line-clamp: 3; font-size: .92rem; }
  .search { flex-wrap: wrap; }
  .search select { flex: 0 0 auto; }
  .search input { flex: 1 1 140px; }
  .search button { flex: 0 0 auto; }
  .group-btn { flex-direction: column; align-items: flex-start; gap: 2px; }
}
