:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-muted: #dbeafe;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --transition: 150ms ease;
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { text-decoration: none; color: inherit; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────── */
.site-header {
  background: var(--primary);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.site-header .container {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-home {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-sep {
  color: rgba(255,255,255,0.35);
  font-size: 1.1rem;
}

.header-crumb {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Layout ──────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

main {
  padding: 40px 0 80px;
}

/* ── Section ─────────────────────── */
.section {
  margin-bottom: 48px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.section-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 20px;
}

/* ── Grid ────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Card ────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover,
a.card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.card-description {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ── Badge ───────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
}

.badge-neutral {
  background: #f1f5f9;
  color: var(--text-muted);
}

/* ── Meta ────────────────────────── */
.meta-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.meta-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Arrow ───────────────────────── */
.card-arrow {
  color: var(--text-light);
  font-size: 1rem;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

a.card:hover .card-arrow,
.card-clickable:hover .card-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

/* ── Back link ───────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 28px;
}

.back-link:hover {
  text-decoration: underline;
}

/* ── Page header ─────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.page-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.page-created {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* ── Description box ─────────────── */
.description-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 36px;
  box-shadow: var(--shadow);
}

.description-box p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.75;
  white-space: pre-wrap;
}

/* ── Plot card ───────────────────── */
.plot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.plot-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.plot-card-body {
  padding: 16px 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plot-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.plot-card-comment {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plot-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.plot-card-author {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.plot-card-author-icon {
  width: 18px;
  height: 18px;
  background: var(--primary-light);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.plot-card-date {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-left: auto;
}

/* ── Loading / Empty / Error ─────── */
.state-loading,
.state-empty,
.state-error {
  padding: 60px 20px;
  text-align: center;
}

.state-loading {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.state-loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.state-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.state-empty-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.state-error {
  background: #fef2f2;
  border-radius: var(--radius);
  border: 1px solid #fee2e2;
  color: #dc2626;
  font-size: 0.875rem;
  text-align: left;
  padding: 16px 20px;
}

/* ── Footer ──────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
}

/* ── Responsive ──────────────────── */
@media (max-width: 768px) {
  main { padding: 24px 0 60px; }
  .page-title { font-size: 1.4rem; }
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .card, .plot-card-body { padding: 14px 16px; }
}
