:root {
  --paper: #f3efe6;
  --ink: #1c1915;
  --muted: #5e574c;
  --line: #d8d0c2;
  --accent: #8a3b2f;
  --accent-soft: #f3e4df;
  --chip: #e8e1d4;
  --card: #faf7f1;
  --serif: "Palatino Linotype", Palatino, "Songti SC", "Noto Serif SC", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}

a { color: var(--accent); }

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px 40px 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; }

.site-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.nav { display: flex; gap: 8px; flex-wrap: wrap; }

.nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
}

.nav a.active,
.nav a:hover {
  border-color: var(--line);
  background: var(--card);
}

main { padding: 28px 40px 64px; max-width: 1180px; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px 40px 28px;
  color: var(--muted);
  font-size: 13px;
}

.lead { max-width: 720px; font-size: 17px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.stat, .card, .entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stat { padding: 16px 18px; }
.stat b { display: block; font-family: var(--serif); font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }

.upcoming {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card { padding: 16px 18px; }
.card h3 { margin: 0 0 6px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); }

.tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 0.5fr 0.5fr 0.7fr;
  gap: 10px;
  margin-bottom: 16px;
}

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

input, textarea, select {
  font: inherit;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.meta-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

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

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.fav {
  flex: none;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
}

.fav.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.fav-filters { grid-template-columns: minmax(0, 360px); }

.entry-actions { display: flex; gap: 8px; flex: none; }

.upload-box {
  margin: 28px 0 22px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.upload-box h3 { margin: 0 0 6px; }
.upload-box p { margin: 0 0 12px; color: var(--muted); }

.upload-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }

.file-btn input { margin-top: 4px; }

.upload-box .upload-status { min-height: 1.2em; color: var(--accent); margin-bottom: 8px; }

.upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr 0.5fr;
  gap: 10px;
  margin-top: 8px;
}

.upload-form .wide { grid-column: 1 / -1; }

.upload-form textarea {
  font: inherit;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.upload-form button {
  justify-self: start;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
}

.entry { padding: 16px 18px 14px; }
.entry h3 { margin: 8px 0 2px; font-size: 20px; }
.en { margin: 0 0 8px; color: var(--muted); font-style: italic; }
.abs { margin: 8px 0; }
.fields { margin: 0; color: var(--muted); font-size: 13px; }
.empty {
  padding: 28px 8px;
  color: var(--muted);
}

.entry h3 a {
  color: inherit;
  text-decoration: none;
}

.entry h3 a:hover { color: var(--accent); }

.back { margin: 0 0 8px; }

.note { max-width: 820px; }
.note h1, .note h2, .note h3, .note h4 { margin: 1.3em 0 0.4em; }
.note h1 { font-size: 28px; }
.note h2 { font-size: 22px; }
.note h3 { font-size: 18px; }
.note p { margin: 0.5em 0; }
.note ul, .note ol { margin: 0.4em 0 0.8em; padding-left: 1.3em; }
.note li { margin: 0.25em 0; }
.note hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.note table { width: 100%; border-collapse: collapse; font-size: 14px; }
.note th, .note td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; text-align: left; }
.note th { background: var(--chip); }
.table-wrap { overflow-x: auto; margin: 0.8em 0 1.2em; }
.note img { max-width: 100%; height: auto; }
.note code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92em; }

body.view-map main { max-width: 1240px; }

.map-lead { max-width: 820px; }

.map-source { display: flex; gap: 8px; margin: 0 0 12px; }
.map-source button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px;
}
.map-source button.is-on { background: var(--ink); color: var(--paper); }

.map-board-wrap { overflow-x: auto; margin: 8px 0 20px; }

.map-board {
  position: relative;
  height: 800px;
  min-width: 980px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-lines line {
  stroke: #9aa3ad;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.map-lines line.is-hot { stroke: #1f8a38; stroke-width: 2.4; }

.map-bubble {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  font-size: 13px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: #e7eef5;
  color: var(--ink);
  font: inherit;
  line-height: 1.25;
  cursor: pointer;
  z-index: 1;
}

.map-bubble.hub {
  width: 116px;
  height: 116px;
  background: #2fa84a;
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
}

.map-bubble small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.map-bubble.hub small { color: rgba(255, 255, 255, 0.85); }

.map-bubble.is-on {
  box-shadow: 0 0 0 3px #1c1915;
}

.map-bubble:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.map-models {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.map-models h3 { margin: 0 0 6px; font-size: 16px; }
.map-models p { margin: 0; color: var(--muted); font-size: 14px; }

.map-detail h2 { margin-bottom: 8px; }
.map-actions { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; }
.map-actions button, .heat button, .blank-chip {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 10px;
}

.map-papers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.map-paper { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.map-paper a { font-family: var(--serif); font-size: 18px; text-decoration: none; }
.map-paper a:hover { text-decoration: underline; }

.blank-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.blank-chip.is-empty { border-style: dashed; }

.matrix-wrap { overflow-x: auto; }
.map-matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.map-matrix th, .map-matrix td { border: 1px solid var(--line); padding: 4px; text-align: center; vertical-align: middle; }
.map-matrix th { background: var(--chip); font-weight: 600; }
.heat button { width: 100%; min-width: 72px; min-height: 40px; border-radius: 8px; }
.heat button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px #1c1915; }
.heat-0 button { background: transparent; border-style: dashed; color: var(--muted); }
.heat-hot button { background: #d9f2df; }

.edit-btn {
  flex: none;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
}

.back-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  width: 52px;
  height: 52px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(138, 59, 47, 0.35);
}

.back-top.is-bounce {
  animation: back-bounce 0.45s ease;
}

@keyframes back-bounce {
  0% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  70% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

@media (max-width: 860px) {
  .site-header, main, .site-footer { padding-left: 16px; padding-right: 16px; }
  .site-header { flex-direction: column; align-items: flex-start; }
  .stats, .upcoming, .filters, .map-models, .upload-form { grid-template-columns: 1fr; }
}
