:root {
  --bg: #edf3fb;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --line: #d9e5f6;
  --text: #1c2b44;
  --muted: #64748c;
  --accent: #2d6cdf;
  --accent-deep: #17479d;
  --shadow: 0 18px 48px rgba(44, 86, 160, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Sans SC", sans-serif;
  background:
    linear-gradient(180deg, rgba(45, 108, 223, 0.08), rgba(45, 108, 223, 0) 180px),
    linear-gradient(180deg, #f5f8fd, #edf3fb);
}

a {
  color: inherit;
  text-decoration: none;
}

.forum-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.logo {
  font-family: "Noto Serif SC", serif;
  font-size: 28px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 18px;
}

.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: #eaf1ff;
  color: var(--accent-deep);
}

.home-layout,
.page-layout,
.detail-layout {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

.home-layout {
  grid-template-columns: 1fr;
}

.page-layout,
.detail-layout {
  grid-template-columns: 1fr;
}

.hero-card,
.overview-card,
.latest-card,
.feed-page,
.detail-card,
.comments-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 30px;
}

.hero-kicker,
.mini-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-card h1,
.page-title {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.15;
}

.hero-copy {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.primary-link,
.ghost-link,
.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
}

.primary-link,
.refresh-button {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.ghost-link {
  border: 1px solid var(--line);
  background: #f7faff;
  color: var(--accent-deep);
}

.overview-card,
.latest-card,
.feed-page,
.detail-card,
.comments-card {
  padding: 24px;
}

.overview-card h2,
.latest-card h2,
.comments-card h2 {
  margin: 0 0 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head a,
.back-link {
  color: var(--accent-deep);
  font-weight: 700;
}

.detail-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.back-link.secondary {
  color: var(--muted);
  font-weight: 600;
}

.back-link[hidden] {
  display: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.sort-tabs {
  display: flex;
  gap: 10px;
}

.sort-tab {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sort-tab.active {
  border-color: #bfd2f1;
  background: #eaf1ff;
  color: var(--accent-deep);
}

.paging-summary,
.feed-status {
  color: var(--muted);
  font-size: 13px;
}

.feed-status {
  min-height: 20px;
  margin-top: 14px;
  text-align: center;
}

.feed-sentinel {
  height: 1px;
}

.stats-grid,
.post-grid,
.thread-list,
.comments-list {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card,
.post-card,
.thread-row,
.comment-row {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.stat-card {
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 28px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.post-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-card,
.thread-row {
  display: block;
  padding: 18px;
}

.post-title,
.thread-row h2,
.detail-title {
  margin: 8px 0 10px;
  font-size: 24px;
  line-height: 1.35;
}

/* Posts list visual fixes */
.thread-list { grid-template-columns: 1fr; }
.thread-row h2 a { color: var(--text); text-decoration: none; }
.thread-row h2 a:hover { color: var(--accent-deep); text-decoration: underline; }
.thread-row h2 { word-break: break-word; overflow-wrap: anywhere; }
.thread-row { transition: background 0.15s ease, border-color 0.15s ease; }
.thread-row:hover { border-color: #bfd2f1; background: #f7fbff; }
.thread-row .meta { margin: 0 0 8px; }
.thread-excerpt { overflow-wrap: anywhere; word-break: break-word; }
.author-link { color: var(--accent-deep); text-decoration: underline; }

/* Active author filter banner */
.active-filter[hidden] { display: none; }
.active-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
  padding: 14px 16px;
  border: 1px solid #cfe0fb;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
  color: var(--accent-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.active-filter .filter-copy { display: grid; gap: 4px; }
.active-filter .filter-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(40, 84, 145, 0.1);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.active-filter .filter-text { font-weight: 600; }
.active-filter .filter-id { color: var(--muted); font-size: 12px; margin-left: 6px; }
.clear-filter {
  padding: 9px 14px;
  border: 1px solid #cdddff;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.clear-filter::before { content: "← "; }
@media (max-width: 720px) {
  .active-filter {
    flex-direction: column;
    align-items: flex-start;
  }

  .clear-filter {
    width: 100%;
    justify-content: center;
  }
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.excerpt,
.thread-excerpt {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.reply-count {
  color: var(--muted);
  font-size: 13px;
}

.detail-main {
  min-width: 0;
}

.detail-title {
  font-family: "Noto Serif SC", serif;
}

.markdown-body {
  color: var(--text);
  line-height: 1.85;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 0.85em 0 0.45em;
}

.markdown-body p,
.markdown-body ul,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0.7em 0;
}

.markdown-body ul {
  padding-left: 1.4em;
}

.markdown-body blockquote {
  padding-left: 14px;
  border-left: 3px solid #bfd2f1;
  color: var(--muted);
}

.markdown-body code {
  padding: 0.14em 0.35em;
  border-radius: 6px;
  background: #e9f1ff;
  color: var(--accent-deep);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.markdown-body pre {
  overflow: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: #1e293b;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: #eef4ff;
}

.markdown-body a {
  color: var(--accent-deep);
}

.markdown-body img,
.inline-image {
  display: block;
  width: auto;
  max-width: min(100%, 720px);
  height: auto;
  max-height: 520px;
  min-height: 0;
  margin: 1em 0;
  padding: 14px;
  border: 1px solid #cdddff;
  border-radius: 20px;
  background:
    linear-gradient(45deg, rgba(210, 223, 248, 0.55) 25%, transparent 25%, transparent 75%, rgba(210, 223, 248, 0.55) 75%),
    linear-gradient(45deg, rgba(210, 223, 248, 0.55) 25%, transparent 25%, transparent 75%, rgba(210, 223, 248, 0.55) 75%),
    linear-gradient(180deg, #fbfdff, #eef4ff);
  background-position: 0 0, 12px 12px, 0 0;
  background-size: 24px 24px, 24px 24px, 100% 100%;
  box-shadow:
    0 16px 32px rgba(38, 74, 138, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: zoom-in;
  margin-inline: auto;
}

.image-lightbox {
  width: min(92vw, 1200px);
  max-width: none;
  padding: 20px;
  border: none;
  border-radius: 28px;
  background: rgba(247, 251, 255, 0.98);
  box-shadow: 0 28px 80px rgba(10, 26, 61, 0.35);
}

.image-lightbox::backdrop {
  background: rgba(9, 22, 49, 0.7);
  backdrop-filter: blur(8px);
}

.lightbox-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid #cdddff;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.lightbox-image {
  display: block;
  width: 100%;
  max-height: calc(90vh - 88px);
  object-fit: contain;
  border-radius: 20px;
  background:
    linear-gradient(45deg, rgba(210, 223, 248, 0.45) 25%, transparent 25%, transparent 75%, rgba(210, 223, 248, 0.45) 75%),
    linear-gradient(45deg, rgba(210, 223, 248, 0.45) 25%, transparent 25%, transparent 75%, rgba(210, 223, 248, 0.45) 75%),
    linear-gradient(180deg, #fbfdff, #eef4ff);
  background-position: 0 0, 12px 12px, 0 0;
  background-size: 24px 24px, 24px 24px, 100% 100%;
}

.comment-row {
  padding: 16px;
}

.comment-row[data-depth="1"] {
  margin-left: 18px;
}

.comment-row[data-depth="2"] {
  margin-left: 36px;
}

.comment-row[data-depth="3"] {
  margin-left: 54px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fafcff;
}

@media (max-width: 1180px) {
  .home-layout,
  .page-layout,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .post-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
