:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface2: #efe9dd;
  --border: #e2dbcd;
  --text: #2b2925;
  --muted: #726b5f;
  --brand: #8a5a2b;
  --brand-weak: #f2e5d4;
  --star: #b8860b;
  --shadow: 0 1px 0 rgba(43, 41, 37, 0.04);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #191816;
  --surface: #211f1c;
  --surface2: #2a2723;
  --border: #3a362f;
  --text: #eae4d8;
  --muted: #a59c8d;
  --brand: #d0a06a;
  --brand-weak: #33291e;
  --star: #d9b24a;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, "STSong", "华文宋体", "SimSun", "宋体", serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.top {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 18px 0 10px;
}

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

.brand {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.mark {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--brand);
  font-size: 20px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.kicker {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
  font-weight: 400;
}

.sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}

.actions {
  flex: none;
  display: flex;
  gap: 6px;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

#q {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}

#q:focus { border-color: var(--brand); }

.seg {
  flex: none;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button.active {
  background: var(--brand-weak);
  color: var(--brand);
  font-weight: 600;
}

.filters {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.filters summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  list-style: none;
}

.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "▸ "; }
.filters[open] summary::before { content: "▾ "; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.chips::before {
  content: attr(data-label);
  flex: none;
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.85;
  margin-right: 2px;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-weak);
  color: var(--brand);
  font-weight: 600;
}

.chip .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}

.toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.toggles label { cursor: pointer; user-select: none; }
.toggles input { accent-color: var(--brand); }

.link-btn {
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}

main { padding-top: 14px; padding-bottom: 30px; }

.track {
  margin-top: 18px;
}

.track-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 2px solid var(--border);
}

.track-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.track-name .tag {
  font-size: 10.5px;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 4px;
  padding: 0 4px;
  margin-right: 6px;
  vertical-align: 2px;
  font-weight: 500;
}

.track-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.era-strip {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: thin;
}

.era-chip {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 3px 7px;
  cursor: pointer;
  white-space: nowrap;
}

.era-chip b {
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.era-chip .n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.era {
  margin-top: 10px;
  scroll-margin-top: 8px;
}

.era-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0 5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.era-name {
  font-size: 13px;
  font-weight: 700;
}

.era-range {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.era-n {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row {
  display: grid;
  grid-template-columns: 104px 24px minmax(0, 1fr);
  column-gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.row:first-of-type { border-top: 0; }

.year-cell {
  text-align: right;
  align-self: start;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.dy {
  font-family: "STSong", "华文宋体", "SimSun", "宋体", serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--brand);
  word-break: break-word;
}

.year {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
}

.axis {
  position: relative;
  align-self: stretch;
}

.axis::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: -11px;
  left: 50%;
  width: 1px;
  background: var(--border);
}

.axis .dot {
  position: absolute;
  top: 15px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--cat, var(--brand));
}

.axis .dot[data-milestone="true"] {
  background: var(--cat, var(--brand));
  box-shadow: 0 0 0 3px var(--brand-weak);
}

.body { min-width: 0; }

.ev-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.ev-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.ev-en {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}

.star { color: var(--star); font-size: 12px; }

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.meta .cat { color: var(--cat, var(--muted)); }

.meta .cat i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cat, var(--brand));
  margin-right: 4px;
  vertical-align: 1px;
}

.tags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tags span {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10.5px;
  color: var(--muted);
}

.review-line {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--brand);
  font-size: 12.5px;
  color: var(--muted);
}

.detail {
  display: none;
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
}

.row.open .detail { display: block; }

.detail p { margin: 0 0 6px; }
.detail .sig { color: var(--brand); font-weight: 600; }
.detail .sig-label { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-right: 4px; }
.detail .tags { margin-top: 4px; }

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

.foot {
  padding: 14px 20px 28px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .wrap { padding: 0 13px; }
  .top { padding: 13px 0 8px; }
  h1 { font-size: 17px; }
  .search-row { flex-wrap: wrap; }
  #q { flex: 1 1 100%; }
  .seg { width: 100%; }
  .seg button { flex: 1 1 auto; text-align: center; }
  .row { grid-template-columns: 88px 18px minmax(0, 1fr); column-gap: 7px; padding: 9px 0; }
  .dy { font-size: 18px; }
  .ev-title { font-size: 14.5px; }
  .ev-en { display: none; }
  .detail { padding: 8px 9px; }
  .track { margin-top: 14px; }
  .toggles { gap: 10px; }
  .link-btn { margin-left: 0; }
}
