:root {
  --bg: #f5f1e8;
  --surface: rgba(255, 252, 246, 0.92);
  --surface-strong: #fffaf1;
  --text: #2a251f;
  --muted: #6f675d;
  --line: rgba(92, 79, 64, 0.14);
  --accent: #386641;
  --accent-soft: #dce8d5;
  --accent-strong: #27462d;
  --danger: #8d4b3f;
  --shadow: 0 18px 50px rgba(57, 43, 24, 0.08);
  --radius: 24px;
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 35%),
    linear-gradient(180deg, #f8f4eb 0%, #f0ebdf 100%);
  min-height: 100vh;
}

a { color: var(--accent-strong); text-decoration: none; }
button, input, textarea, select { font: inherit; }
input[type="radio"] { width: auto; margin: 0; }

.shell { max-width: 980px; margin: 0 auto; padding: 18px 14px 40px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 8px 4px 14px; }
.topbar-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.brand { display: inline-block; font-size: 1.25rem; font-weight: 700; color: var(--text); }
.tagline, .muted, .summary-meta, .keywords { color: var(--muted); }

.nav-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.nav-tabs a { padding: 12px 10px; background: rgba(255, 250, 241, 0.65); border: 1px solid var(--line); border-radius: 999px; text-align: center; }
.nav-tabs a.is-active { background: var(--accent-soft); color: var(--accent-strong); border-color: rgba(56, 102, 65, 0.24); }
.nav-tab-form { margin: 0; }
.nav-tab-button {
  padding: 12px 10px;
  background: rgba(255, 250, 241, 0.65);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  text-align: center;
  cursor: pointer;
}

.page, .stack-form, .entry-form, .timeline, .category-bars, .result-list, .admin-list { display: flex; flex-direction: column; }
.page, .stack-form, .entry-form, .timeline, .category-bars, .result-list, .admin-list { gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.card.inset { box-shadow: none; background: rgba(255, 250, 241, 0.75); }
.card-header, .hero, .topbar, .button-row, .weight-row, .timeline-actions, .inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.card-header, .hero { justify-content: space-between; }
.split { align-items: flex-start; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 1.75rem; }
h2 { margin-bottom: 6px; font-size: 1.15rem; }
.eyebrow { margin-bottom: 8px; color: var(--accent-strong); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.78rem; }

.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.score-pill, .badge { display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 0.92rem; }
.score-pill.quiet, .badge-muted { background: #ece5d8; color: #6e6150; }
.badge-live { background: #d9ecd9; color: #2d5a35; }
.weight-1 { background: #efe7d7; color: #8a6c3b; }
.weight-2 { background: #e3edd9; }
.weight-3 { background: #d4e8d4; font-weight: 700; }

.stats-grid, .grid.two, .grid.two-col-layout, .filter-grid, .mini-calendar { display: grid; gap: 14px; }
.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two, .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two-col-layout { grid-template-columns: 1.2fr 1fr; }

.stat { display: flex; flex-direction: column; gap: 8px; }
.stat strong { font-size: 1.8rem; }

label { display: flex; flex-direction: column; gap: 8px; font-size: 0.95rem; }
input, textarea, select { width: 100%; border: 1px solid rgba(73, 61, 47, 0.18); background: rgba(255, 252, 247, 0.96); border-radius: 16px; padding: 13px 14px; color: var(--text); }
textarea { resize: vertical; }

.primary-button, .ghost-button, .link-button { border: none; border-radius: 999px; padding: 12px 18px; cursor: pointer; text-align: center; }
.primary-button { background: var(--accent); color: #fffdf8; }
.primary-button.large { min-height: 52px; font-weight: 700; }
.ghost-button, .link-button { background: #ece4d8; color: var(--text); }
.link-button { padding: 0; background: transparent; color: var(--danger); }
.align-center { display: inline-flex; align-items: center; justify-content: center; }
.weight-row { gap: 8px 18px; }
.weight-row label { flex-direction: row; align-items: center; gap: 6px; padding: 0; }

.timeline-item { display: grid; grid-template-columns: 56px 1fr; gap: 12px; }
.timeline-time { color: var(--muted); font-size: 0.9rem; padding-top: 6px; }
.timeline-body { border-left: 2px solid rgba(56, 102, 65, 0.18); padding-left: 14px; }
.timeline-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline-top h3 { margin-bottom: 0; font-size: 1rem; }

.category-row { display: grid; grid-template-columns: 52px 1fr 30px; gap: 10px; align-items: center; }
.bar-track { height: 10px; background: #efe8db; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #8db38f 0%, #4e7c57 100%); border-radius: 999px; }

.summary-box { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--surface-strong); border: 1px dashed rgba(56, 102, 65, 0.24); }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.result-list.plain li { display: grid; grid-template-columns: 120px 1fr; align-items: center; }

.auth-card, .narrow { max-width: 560px; margin: 24px auto 0; }
.flash, .error, .empty-state { padding: 14px 16px; border-radius: 18px; }
.flash { background: #f0eadc; border: 1px solid var(--line); margin-bottom: 16px; }
.error { background: #f9e2de; color: #7a3f34; }
.empty-state { background: rgba(246, 241, 230, 0.8); color: var(--muted); }

.admin-row, .mini-calendar { display: grid; gap: 12px; }
.admin-row { grid-template-columns: 1fr auto; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mini-calendar { grid-template-columns: repeat(7, 1fr); margin-top: 16px; }
.mini-day { padding: 12px 8px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255, 250, 241, 0.78); text-align: center; display: flex; flex-direction: column; gap: 4px; }
.mini-day.filled.level-1 { background: #eef4e8; }
.mini-day.filled.level-2 { background: #ddebd6; }
.mini-day.filled.level-3 { background: #cadeca; }
.mini-day.filled.level-4 { background: #b7d1b5; }

.search-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.search-grid button { align-self: end; }
.result-scroll { max-height: 520px; overflow-y: auto; }
.result-list .note-text { font-size: 0.9rem; margin: 4px 0 0; }

code { padding: 2px 6px; background: rgba(255, 248, 237, 0.9); border-radius: 8px; }

@media (max-width: 760px) {
  .topbar, .hero, .card-header, .admin-row { flex-direction: column; align-items: stretch; }
  .stats-grid, .grid.two, .grid.two-col-layout, .filter-grid, .search-grid, .mini-calendar { grid-template-columns: 1fr; }
  .timeline-item, .category-row, .result-list.plain li { grid-template-columns: 1fr; }
  .timeline-body { padding-left: 10px; }
  .shell { padding: 14px 12px 32px; }
  .nav-tabs a,
  .nav-tab-button {
    width: auto;
    padding: 8px 12px;
    font-size: 0.94rem;
  }
}
