@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+SC:wght@300;400;600;700&family=ZCOOL+XiaoWei&display=swap');

:root {
  color-scheme: light;
  --bg: #f5efe3;
  --bg-2: #efe4d1;
  --ink: #1f1a16;
  --muted: #6c5f52;
  --accent: #d85f3d;
  --accent-2: #2f6f7e;
  --accent-3: #bc9b5f;
  --panel: #fffaf2;
  --card: #ffffff;
  --border: #eadcc8;
  --shadow: 0 12px 30px rgba(32, 23, 12, 0.12);
  --radius: 18px;
  --mono: "IBM Plex Mono", "JetBrains Mono", monospace;
  --sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", sans-serif;
  --serif: "ZCOOL XiaoWei", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #fff7ea 0%, var(--bg) 45%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.18;
  mix-blend-mode: multiply;
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 1fr);
  gap: 32px;
  padding: 48px 6vw 32px;
}

.brand {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent-2);
  font-family: var(--mono);
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 52px);
  margin: 16px 0 12px;
}

.subtitle {
  color: var(--muted);
  line-height: 1.6;
  max-width: 480px;
}

.mono {
  font-family: var(--mono);
  font-size: 0.95em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin-top: 20px;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transform: translateY(0);
  animation: floatIn 0.6s ease both;
}

.stat-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.stat-value {
  font-size: 22px;
  margin-top: 6px;
  font-family: var(--mono);
}

.grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  padding: 0 6vw 64px;
}

.mode-banner {
  margin: 0 6vw 24px;
  padding: 12px 16px;
  background: #fff6e8;
  border: 1px dashed var(--accent-3);
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.mode-banner.hidden {
  display: none;
}

.mode-text {
  font-family: var(--mono);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding-right: 6px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title.posts-title {
  align-items: center;
}

.post-search {
  min-width: 220px;
  max-width: 320px;
  width: 100%;
}

.post-search input {
  width: 100%;
}

.panel-title h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
}

.panel-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.schema-list {
  display: grid;
  gap: 12px;
}

.schema-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.schema-name {
  font-family: var(--mono);
  font-weight: 600;
}

.schema-type {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.schema-comment {
  font-size: 12px;
  color: var(--accent-2);
  margin-top: 6px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.filter-group label {
  font-size: 12px;
  color: var(--muted);
}

input[type="search"],
input[type="date"],
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fffdf7;
  font-family: var(--mono);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filter-row {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  background: #fffdf7;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.trend canvas {
  width: 100%;
  height: auto;
}

.trend-legend {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  animation: rise 0.5s ease both;
}

.post-card.is-reply {
  border-left: 4px solid var(--accent-3);
}

.post-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #f4ecde;
  font-family: var(--mono);
}

.badge.accent {
  background: var(--accent);
  color: #fff;
}

.badge.teal {
  background: var(--accent-2);
  color: #fff;
}

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

.post-title {
  font-family: var(--serif);
  font-size: 18px;
  margin: 12px 0 8px;
}

.clickable {
  cursor: pointer;
}

.clickable:hover {
  color: var(--accent-2);
}

.post-content {
  font-size: 14px;
  line-height: 1.7;
  color: #2d2722;
  white-space: pre-wrap;
}

.post-content.collapsed {
  max-height: 140px;
  overflow: hidden;
  position: relative;
}

.post-content.collapsed::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9));
}

.content-toggle {
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent-2);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.attachments img {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  max-height: 180px;
}

.reply-toggle {
  margin-top: 12px;
}

.reply-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reply-item {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffdf7;
}

.focused {
  animation: focusPulse 1.5s ease;
  box-shadow: 0 0 0 3px rgba(216, 95, 61, 0.2), var(--shadow);
  border-color: rgba(216, 95, 61, 0.6);
}

.reply-item .post-content {
  font-size: 13px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.page-info {
  font-family: var(--mono);
  color: var(--muted);
}

.btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(216, 95, 61, 0.25);
}

.btn.ghost {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loading {
  position: fixed;
  inset: 0;
  background: rgba(245, 239, 227, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading.hidden {
  display: none;
}

.loading-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 360px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 16px;
  font-family: var(--mono);
}

.loading-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 12px 0;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes focusPulse {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-2px) scale(1.01);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .side {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 720px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
