:root {
  --bg: #f5f7fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.1);
  --radius: 12px;
  --max: 760px;
  --detail-max: 860px;
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --spine: #cbd5e1;
  --dot: #2563eb;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}
.timeline-main .wrap,
main.wrap.timeline-main,
main.timeline-main {
  width: min(100% - 2rem, var(--max));
}

header.site {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
header.site .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  flex-wrap: wrap;
}
header.site.slim .bar { padding: 0.7rem 0; }
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand .title { font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand .title:hover { text-decoration: none; color: var(--accent); }
.brand .ticker {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.focus-fab {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  color: #b45309;
  background: var(--warn-soft);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
}
.focus-fab .count {
  display: inline-block;
  min-width: 1.2em;
  font-weight: 700;
  margin-left: 0.15rem;
}
.about-drop { position: relative; }
.about-drop > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
}
.about-drop > summary::-webkit-details-marker { display: none; }
.about-drop[open] > summary,
.about-drop > summary:hover {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}
.about-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  width: min(20rem, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  color: var(--muted);
  z-index: 30;
}
.about-panel p { margin: 0 0 0.5rem; }
.about-panel .muted { font-size: 0.78rem; }
.legacy-drop { margin-top: 0.5rem; }
.legacy-drop summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
}
.legacy-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.legacy-links a {
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

nav.main {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
nav.main a {
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
nav.main a:hover,
nav.main a.active {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

main { flex: 1; padding: 1.25rem 0 2.5rem; }

.hero { padding: 0.5rem 0 0.25rem; }
.hero.slim h1 { display: none; }
.hero h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 700;
}
.hero p.lead {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
  font-size: 0.92rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.85rem 0 1.25rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}
.chip.ok { color: #15803d; background: var(--ok-soft); border-color: rgba(22,163,74,0.3); }
.chip.warn { color: #b45309; background: var(--warn-soft); border-color: rgba(217,119,6,0.3); }
.chip.danger { color: #b91c1c; background: var(--danger-soft); border-color: rgba(220,38,38,0.3); }
.chip.info { color: #1d4ed8; background: var(--accent-soft); border-color: rgba(37,99,235,0.3); }
.chip.digest { color: #6d28d9; background: rgba(109,40,217,0.08); border-color: rgba(109,40,217,0.28); }

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 0.65rem; font-size: 1.05rem; }
.card h2 { font-size: 1.15rem; }
.card p { margin: 0.4rem 0; color: var(--muted); }
.card p strong, .card li strong { color: var(--text); }

.section-title {
  margin: 1.75rem 0 0.85rem;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

ul.clean {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}
ul.clean li { margin: 0.35rem 0; }
ul.clean li::marker { color: var(--accent); }

.alert {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  padding: 0.85rem 1rem;
  border-radius: 0 10px 10px 0;
  margin: 0.6rem 0;
  color: var(--text);
}
.alert.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.alert.info { border-left-color: var(--accent); background: var(--accent-soft); }
.alert .label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--warn);
  margin-bottom: 0.25rem;
}
.alert.danger .label { color: #b91c1c; }
.alert.info .label { color: #1d4ed8; }

.kv {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.92rem;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }
.blank {
  color: var(--warn);
  font-style: italic;
  border-bottom: 1px dashed rgba(217,119,6,0.5);
}
.note { font-size: 0.85rem; color: var(--muted); }

.links-list a {
  display: block;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.links-list a:last-child { border-bottom: 0; }
.links-list a span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; }

footer.site {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}
footer.site .wrap { display: flex; flex-direction: column; gap: 0.35rem; }

.digest-body {
  white-space: pre-wrap;
  font-size: 0.92rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-top: 0.6rem;
}

/* —— Vertical spine timeline —— */
.spine-wrap {
  position: relative;
  padding-left: 1.75rem;
}
.spine-line {
  position: absolute;
  left: 0.4rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--spine) 12%, var(--spine));
  border-radius: 2px;
}
ol.spine {
  list-style: none;
  margin: 0;
  padding: 0;
}
.spine-loading {
  color: var(--muted);
  padding: 1rem 0;
  font-size: 0.9rem;
}
.spine-node {
  position: relative;
  padding: 0 0 1.35rem 0;
}
.spine-node::before {
  content: "";
  position: absolute;
  left: -1.5rem;
  top: 1.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--dot);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  z-index: 1;
}
.spine-node.digest::before {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.spine-node:last-child { padding-bottom: 0.25rem; }

.node-card {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.15rem;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.node-card:hover {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}
.node-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.node-date {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}
.node-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.4;
}
.node-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.node-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* —— Full-window detail view (cards inside) —— */
.detail-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.detail-view.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.detail-topbar {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}
.detail-topbar-inner {
  width: min(100%, var(--detail-max));
  margin-inline: auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.detail-back,
.detail-close {
  flex-shrink: 0;
  margin-top: 0.15rem;
}
.detail-topbar-main {
  flex: 1;
  min-width: 0;
}
.detail-date {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.detail-title {
  margin: 0.2rem 0 0.45rem;
  font-size: clamp(1.1rem, 2.8vw, 1.35rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at top, rgba(37, 99, 235, 0.04), transparent 55%),
    var(--bg);
}
.detail-cards {
  width: min(100%, var(--detail-max));
  margin-inline: auto;
  padding: 1.1rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}
.detail-card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 600;
  text-transform: none;
}
.detail-card h2 .card-sub {
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0;
  display: block;
  margin-top: 0.25rem;
}
.detail-body {
  font-size: 0.92rem;
  color: var(--muted);
  user-select: text;
  -webkit-user-select: text;
}
.detail-body p { margin: 0.5rem 0; }
.detail-body strong { color: var(--text); }
.detail-body ::selection {
  background: rgba(37, 99, 235, 0.25);
  color: var(--text);
}
.detail-body > *:first-child { margin-top: 0; }
.detail-card .meta-row { margin: 0.35rem 0 0; }
.detail-card .empty-hint { margin: 0.35rem 0 0.65rem; }
.detail-card .anno-composer { margin-bottom: 0.75rem; }

/* Quote FAB + inline anno composer */
.quote-fab {
  position: fixed;
  z-index: 60;
  transform: translate(-50%, -120%);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}
.quote-fab:hover { filter: brightness(1.06); }

.anno-composer {
  margin: 0 0 0.85rem;
  padding: 0.85rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.quote-chip {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  color: #1e40af;
  font-size: 0.85rem;
  font-style: normal;
  max-height: 5.5rem;
  overflow-y: auto;
  white-space: pre-wrap;
}
.composer-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.anno-composer textarea {
  width: 100%;
  min-height: 4.2rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
}
.anno-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
mark.anno-sel {
  background: rgba(37, 99, 235, 0.2);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.05em;
}

.anno-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.anno-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.anno-list li:last-child { border-bottom: 0; }
.anno-quote {
  display: block;
  margin: 0 0 0.35rem;
  padding: 0.4rem 0.65rem;
  border-left: 3px solid rgba(37, 99, 235, 0.55);
  background: var(--accent-soft);
  color: #1e40af;
  font-size: 0.8rem;
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
}
.anno-text { color: var(--text); margin: 0 0 0.2rem; }
.anno-meta { color: var(--muted); font-size: 0.72rem; }

.focus-panel {
  position: fixed;
  top: 3.5rem;
  right: 1rem;
  width: min(360px, calc(100vw - 2rem));
  max-height: min(70vh, 480px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 35;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-lg);
}
.focus-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.topic-chip {
  cursor: pointer;
  font-size: 0.82rem;
  color: #1d4ed8;
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-family: inherit;
}
.interact-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.interact-form textarea {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-family: inherit;
  font-size: 0.92rem;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.btn {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  border-radius: 8px;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { color: var(--muted); background: transparent; }
.btn.ghost:hover { color: var(--text); background: var(--bg); }
.btn.danger-outline {
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--danger-soft);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.watch-list, .feedback-list, .timeline-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.watch-list li, .feedback-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.item-main { flex: 1; min-width: 0; }
.item-main .label { color: var(--text); font-weight: 600; }
.item-main .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }
.item-main .text { color: var(--muted); margin-top: 0.2rem; white-space: pre-wrap; }
.empty-hint { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0; }

.status-toast {
  font-size: 0.8rem;
  color: #15803d;
  min-height: 1.2em;
}
.status-toast.err { color: #b91c1c; }

.timeline-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.timeline-list .when {
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.timeline-list .t-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
}
.timeline-list .t-summary {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.custom-watch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.custom-watch-row input {
  flex: 1;
  min-width: 10rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-family: inherit;
  font-size: 0.88rem;
}

body.detail-open { overflow: hidden; }

@media (max-width: 560px) {
  .spine-wrap { padding-left: 1.35rem; }
  .spine-node::before { left: -1.2rem; }
  .detail-topbar-inner { padding: 0.75rem 1rem; }
  .detail-title { font-size: 1.05rem; }
  .detail-cards { padding: 0.85rem 1rem 2rem; gap: 0.85rem; }
  .detail-card { padding: 1rem 1.05rem; }
  .detail-close { display: none; }
}
