/* ScBoom Science — clean minimal UI */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e5e5e2;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
  --max: 1100px;
}

html[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2a2f3a;
  --accent: #6b9fff;
  --accent-soft: #1a2336;
  --ok: #4ade80;
  --ok-bg: #14261c;
  --warn: #fbbf24;
  --warn-bg: #2a2110;
  --danger: #f87171;
  --danger-bg: #2a1515;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  text-decoration: none;
}
.logo span.mark {
  display: inline-flex;
  width: 28px; height: 28px;
  align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  font-size: 0.85rem;
}
.nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex: 1;
}
.nav a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.92rem;
  text-decoration: none;
}
.nav a:hover, .nav a.active {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.header-stats {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.theme-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover { border-color: var(--accent); }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .header-inner { flex-wrap: wrap; }
  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    order: 10;
    gap: 0.15rem;
    padding-bottom: 0.5rem;
  }
  .nav.open { display: flex; }
  .nav a { padding: 0.55rem 0.75rem; }
  .header-stats { display: none; }
  .header-right { margin-left: auto; }
}

/* Main */
main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* Hero */
.hero {
  margin-bottom: 2rem;
}
.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}

/* Stats strip */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat-card .num {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.stat-card .label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Filters */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  align-items: center;
}
.search-box {
  flex: 1;
  min-width: 180px;
  display: flex;
  gap: 0.4rem;
}
input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
textarea { min-height: 120px; resize: vertical; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
}
.chip:hover, .chip.active {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: var(--accent);
  text-decoration: none;
}

/* Cards grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
a.card { color: inherit; text-decoration: none; }
a.card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 2px 8px rgba(29,78,216,.08);
  text-decoration: none;
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}
.card-icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  background: var(--bg);
}
.card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}
.card .en {
  font-size: 0.78rem;
  color: var(--muted);
}
.card .desc {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.35rem;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .3s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Section */
.section {
  margin-top: 2.25rem;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  gap: 1rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}
.section-head a.more {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Field detail */
.field-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.breadcrumb {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.field-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}
.field-title .big-icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: var(--bg);
}
.field-title h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.field-title .en { color: var(--muted); font-size: 0.95rem; }
.prose {
  color: var(--text);
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-ok { background: var(--ok); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* Forms */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  max-width: 640px;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 550;
  margin-bottom: 0.35rem;
}
.form-group .hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.tabs a, .tabs button {
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}
.tabs a.active, .tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 550;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }
.alert-err { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

/* Milestone / list items */
.list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.list-item h4 {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
}
.list-item .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.list-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
}
.list-item .row-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.year-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  background: var(--bg);
  border-radius: 5px;
  color: var(--muted);
  margin-right: 0.35rem;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border);
  margin-left: 0.5rem;
}
.tl-item {
  position: relative;
  padding: 0 0 1.5rem 1.25rem;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -1.6rem;
  top: 0.35rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--border);
}
.tl-year {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.tl-item h4 { margin: 0.15rem 0; font-size: 0.98rem; }
.tl-item p { margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* Tree explore */
.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border);
}
.tree > ul { padding-left: 0; border-left: none; }
.tree li {
  margin: 0.35rem 0;
}
.tree .node {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
}
.tree .node:hover { background: var(--accent-soft); text-decoration: none; }
.tree .bar {
  display: inline-block;
  width: 48px;
  height: 4px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}
.tree .bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.pct {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
}

/* Review pending badge */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-weight: 550;
}
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-no { background: var(--danger-bg); color: var(--danger); }

/* Empty */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Two column layout */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .header-stats { display: none; }
}

.note-input {
  flex: 1;
  min-width: 140px;
}

.section-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.hint-inline {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Markdown body */
.prose-md {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}
.prose-md p { margin: 0.4rem 0; }
.prose-md p:first-child { margin-top: 0; }
.prose-md p:last-child { margin-bottom: 0; }
.prose-md ul, .prose-md ol { margin: 0.4rem 0; padding-left: 1.35rem; }
.prose-md code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.prose-md pre {
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.prose-md pre code { background: none; padding: 0; }
.prose-md a { color: var(--accent); }
.prose-md h1, .prose-md h2, .prose-md h3, .prose-md h4 {
  margin: 0.8rem 0 0.4rem;
  font-size: 1.05rem;
}
.prose-md blockquote {
  margin: 0.5rem 0;
  padding: 0.35rem 0.85rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

#flash { transition: opacity .4s; }

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}
.bucket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.bucket-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.bucket-bar-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.bucket-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  min-width: 2px;
}
.bucket-num {
  font-size: 0.8rem;
  color: var(--muted);
}
.delta-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}
a.list-link {
  color: inherit;
  text-decoration: none;
  display: block;
}
a.list-link:hover {
  border-color: #c7d2fe;
  text-decoration: none;
}
html[data-theme="dark"] a.list-link:hover {
  border-color: #3b4a6b;
}
html[data-theme="dark"] .logo .mark {
  background: var(--accent);
  color: #0f1115;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .btn-ghost {
  background: var(--surface);
  color: var(--text);
}
