:root {
  --blue: #0756c9;
  --blue-dark: #0645a2;
  --blue-soft: #eaf2ff;
  --ink: #152238;
  --muted: #62728a;
  --line: #dbe3ee;
  --line-soft: #e9eef5;
  --panel: #ffffff;
  --canvas: #fbfcfe;
  --sidebar: #f7f9fc;
  --gold: #d99000;
  --topbar-h: 60px;
  --sidebar-w: 262px;
  --detail-w: 354px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
.material-symbols-rounded { font-size: 19px; line-height: 1; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; }
.sr-only { width: 1px; height: 1px; position: absolute; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.mobile-only { display: none !important; }

.app { min-height: 100vh; }
.topbar { height: var(--topbar-h); position: sticky; z-index: 50; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 18px 0 20px; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(22,34,56,.03); }
.brand, .top-actions { min-width: 0; display: flex; align-items: center; }
.brand { gap: 13px; white-space: nowrap; }
.brand h1 { margin: 0; font-family: "Songti SC", "Noto Serif SC", Georgia, serif; font-size: 20px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.brand p strong { color: var(--blue); font-size: 16px; }
.top-divider { width: 1px; height: 24px; background: var(--line); }
.representative-badge { display: inline-flex; align-items: center; gap: 3px; padding: 4px 7px; color: #345277; background: #f2f6fb; border: 1px solid #e3eaf3; border-radius: 4px; font-size: 11px; }
.representative-badge .material-symbols-rounded { color: var(--gold); font-size: 14px; font-variation-settings: "FILL" 1; }
.representative-badge b { color: inherit; }
.top-actions { gap: 10px; justify-content: flex-end; }
.search-field { width: min(320px, 24vw); height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; background: #f8fafd; border: 1px solid var(--line); border-radius: 5px; }
.search-field:focus-within { border-color: #80a9e8; box-shadow: 0 0 0 3px rgba(7,86,201,.1); }
.search-field .material-symbols-rounded { flex: 0 0 auto; color: #60738d; font-size: 18px; }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 12px; }
.search-field kbd { padding: 2px 5px; color: #8491a4; background: #fff; border: 1px solid var(--line); border-radius: 3px; font-family: inherit; font-size: 9px; white-space: nowrap; }
.year-control { height: 36px; display: flex; align-items: center; gap: 7px; padding: 0 10px; background: #f8fafd; border: 1px solid var(--line); border-radius: 5px; }
.year-control output { min-width: 29px; color: #59708e; font-size: 11px; text-align: center; }
.dual-range { width: 82px; height: 18px; position: relative; }
.dual-range::before { content: ""; height: 3px; position: absolute; inset: 8px 0 auto; background: #cdd9ea; border-radius: 3px; }
.dual-range input { width: 100%; height: 18px; position: absolute; inset: 0; margin: 0; pointer-events: none; appearance: none; background: transparent; }
.dual-range input::-webkit-slider-thumb { width: 12px; height: 12px; pointer-events: auto; appearance: none; background: #1870e8; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #1870e8; cursor: ew-resize; }
.toolbar-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.toolbar-button { height: 36px; gap: 6px; padding: 0 12px; font-size: 12px; white-space: nowrap; }
.icon-button { width: 36px; height: 36px; padding: 0; }
.toolbar-button:hover, .icon-button:hover { color: var(--blue); background: #f7faff; border-color: #aac6ed; }
.export-menu { position: relative; }
.menu { width: 150px; position: absolute; z-index: 80; top: calc(100% + 7px); right: 0; padding: 5px; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 12px 30px rgba(24,42,70,.16); }
.menu button, .menu a { width: 100%; min-height: 34px; display: flex; align-items: center; padding: 0 10px; color: var(--ink); background: transparent; border-radius: 4px; text-decoration: none; font-size: 12px; cursor: pointer; }
.menu button:hover, .menu a:hover { color: var(--blue); background: var(--blue-soft); }

.workspace { min-height: calc(100vh - var(--topbar-h)); display: grid; grid-template-columns: var(--sidebar-w) minmax(480px, 1fr) var(--detail-w); }
.sidebar, .detail-panel { min-height: calc(100vh - var(--topbar-h)); position: sticky; z-index: 20; top: var(--topbar-h); align-self: start; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; background: var(--sidebar); }
.sidebar { border-right: 1px solid var(--line); }
.profile { min-height: 80px; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.profile .avatar { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #0966e3, #074aaf); border-radius: 50%; font-family: "Songti SC", serif; font-size: 18px; box-shadow: 0 4px 10px rgba(7,86,201,.18); }
.profile strong, .profile span { display: block; }
.profile strong { margin-bottom: 4px; font-family: "Songti SC", Georgia, serif; font-size: 15px; }
.profile span { color: var(--muted); font-size: 11px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.stat-grid div { min-width: 0; padding: 9px 4px; text-align: center; background: #edf1f6; border: 1px solid #e1e7ef; border-radius: 5px; }
.stat-grid strong, .stat-grid span { display: block; }
.stat-grid strong { margin-bottom: 4px; font-family: Georgia, "Songti SC", serif; font-size: 17px; font-weight: 500; }
.stat-grid span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.primary-filters { display: grid; gap: 2px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.nav-filter { min-height: 36px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 7px; padding: 0 10px; color: #35465d; background: transparent; border-radius: 5px; text-align: left; text-decoration: none; font-size: 12px; cursor: pointer; }
.nav-filter:hover, .nav-filter.active { color: var(--blue); background: #e9edf2; }
.nav-filter b { min-width: 23px; padding: 2px 5px; color: #667994; background: #e4eaf2; border-radius: 10px; text-align: center; font-size: 9px; }
.nav-filter.active b { color: var(--blue); background: #dce9fb; }
.accent-star { color: var(--gold); font-variation-settings: "FILL" 1; }
.filter-section { padding: 16px 15px 10px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 10px; }
.section-title h2 { margin: 0; color: #51657e; font-family: "Songti SC", Georgia, serif; font-size: 15px; font-weight: 500; }
.section-title button { padding: 3px 0; color: #7b8aa0; background: transparent; font-size: 9px; cursor: pointer; }
.section-title button:hover { color: var(--blue); }
.direction-list { display: grid; gap: 4px; }
.direction-filter { width: 100%; min-height: 40px; display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 9px; padding: 0 10px; color: #40536b; background: transparent; border: 1px solid transparent; border-radius: 5px; text-align: left; font-size: 11px; cursor: pointer; }
.direction-filter i { width: 7px; height: 7px; background: var(--direction-color); border-radius: 50%; }
.direction-filter b { min-width: 25px; padding: 2px 5px; color: #6d7e93; background: #eef2f6; border-radius: 8px; text-align: center; font-size: 9px; }
.direction-filter:hover { background: #f0f4f9; }
.direction-filter.active { color: var(--direction-color); background: color-mix(in srgb, var(--direction-color) 9%, white); border-color: color-mix(in srgb, var(--direction-color) 27%, white); font-weight: 600; }
.direction-filter:not(.active) { opacity: .52; }
.type-list { display: flex; flex-wrap: wrap; gap: 6px; }
.type-filter { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; color: #617188; background: #eef2f6; border: 1px solid transparent; border-radius: 4px; font-size: 10px; cursor: pointer; }
.type-filter.active { color: var(--blue); background: var(--blue-soft); border-color: #bfd4f3; }
.sidebar-legend { display: flex; flex-wrap: wrap; gap: 10px 12px; padding: 14px 20px 20px; color: #62728a; font-size: 9px; }
.sidebar-legend span { display: flex; align-items: center; gap: 5px; }
.shape { width: 9px; height: 9px; display: inline-block; background: #60748d; }
.shape.theory { border-radius: 50%; }
.shape.algorithm { border-radius: 1px; }
.shape.extension { transform: rotate(45deg) scale(.8); }
.shape.application { border-radius: 50% 50% 2px 2px; }
.representative-ring { width: 11px; height: 11px; display: inline-block; border: 2px solid var(--gold); border-radius: 50%; }

.main-view { min-width: 0; background: #fff; }
.timeline-shell { height: calc(100vh - var(--topbar-h)); min-height: 660px; position: relative; display: grid; grid-template-rows: 70px minmax(0, 1fr) 42px; background: var(--canvas); border-bottom: 1px solid var(--line); }
.timeline-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.timeline-meta h2 { margin: 0 0 3px; font-family: "Songti SC", Georgia, serif; font-size: 16px; }
.timeline-meta p { margin: 0; color: var(--muted); font-size: 10px; }
.stage-band { height: 36px; display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.stage-pill { min-width: 112px; display: grid; place-items: center; padding: 0 10px; color: #61748e; background: #f8fafc; border-right: 1px solid var(--line); text-align: center; font-size: 9px; }
.stage-pill:last-child { border-right: 0; }
.stage-pill strong { display: block; color: #30435b; font-size: 10px; font-weight: 600; }
.timeline-scroll { min-width: 0; min-height: 0; position: relative; overflow: hidden auto; background-color: #fbfcfe; background-image: radial-gradient(#dfe6ef 0.6px, transparent 0.6px); background-size: 14px 14px; cursor: grab; }
.timeline-scroll.dragging { cursor: grabbing; }
#timeline { width: 100%; min-width: 760px; display: block; user-select: none; }
.lane-background { fill: rgba(255,255,255,.88); }
.lane-background.alt { fill: rgba(247,249,252,.9); }
.lane-divider { stroke: #dce4ee; stroke-width: 1; }
.lane-center { stroke: #e4eaf2; stroke-width: 1; stroke-dasharray: 2 4; }
.year-line { stroke: #e2e8f0; stroke-width: 1; }
.year-line.major { stroke: #c4d0de; }
.year-label { fill: #60738d; font-size: 10px; }
.lane-label { font-family: "Songti SC", Georgia, serif; font-size: 12px; font-weight: 600; }
.lane-count { fill: #7a8ba1; font-size: 9px; }
.relation-path { fill: none; stroke: #9babc0; stroke-width: 1.15; opacity: .46; marker-end: url(#arrow); }
.relation-path.cross { stroke: #b67756; stroke-dasharray: 4 4; }
.relation-path.related { stroke: var(--blue); stroke-width: 1.8; opacity: .9; }
.relation-path.dimmed { opacity: .08; }
.paper-node { cursor: pointer; outline: none; }
.paper-node .node-shape { stroke-width: 1.8; transition: opacity .15s, filter .15s; }
.paper-node:hover .node-shape, .paper-node:focus .node-shape { filter: brightness(.92); }
.paper-node.dimmed { opacity: .18; }
.paper-node.selected .selection-halo { opacity: 1; }
.selection-halo { fill: none; stroke: var(--blue); stroke-width: 2; opacity: 0; }
.representative-halo { fill: none; stroke: #d99a18; stroke-width: 1.4; }
.node-card { filter: drop-shadow(0 1px 2px rgba(31,50,77,.12)); }
.node-card-bg { fill: #fff; stroke: #e3e9f0; stroke-width: 1; }
.node-card.representative .node-card-bg { fill: #fffdf7; stroke: #edd9ac; }
.node-card-title { fill: #26374d; font-size: 9.5px; pointer-events: none; }
.node-card-meta { fill: #7a8ba0; font-size: 8px; pointer-events: none; }
.cluster-badge { fill: #fff7f2; stroke: #c55e35; stroke-width: 1.2; }
.cluster-text { fill: #a44827; font-size: 9px; font-weight: 700; pointer-events: none; }
.canvas-tools { width: 42px; position: sticky; z-index: 10; left: 20px; bottom: 18px; margin: -244px 0 18px 20px; display: grid; padding: 4px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 5px 16px rgba(25,44,72,.14); }
.canvas-tools button { width: 32px; height: 36px; display: grid; place-items: center; color: #32475f; background: transparent; border-radius: 4px; cursor: pointer; }
.canvas-tools button:hover, .canvas-tools button.active { color: var(--blue); background: var(--blue-soft); }
.tool-divider { height: 1px; margin: 3px 2px; background: var(--line); }
.density-navigator { min-width: 0; position: relative; display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 8px; padding: 0 20px; color: #61748e; background: #fff; border-top: 1px solid var(--line); font-size: 9px; }
.density-navigator > span:last-of-type { text-align: right; }
.density-strip { height: 24px; display: flex; align-items: end; gap: 2px; cursor: crosshair; }
.density-strip i { min-width: 3px; flex: 1; display: block; background: #9cabbf; opacity: .62; border-radius: 1px 1px 0 0; }
#viewport-window { height: 30px; position: absolute; z-index: 2; top: 6px; left: 66px; background: rgba(7,86,201,.08); border: 1px solid rgba(7,86,201,.55); border-radius: 2px; pointer-events: none; }
.tooltip { width: min(330px, calc(100vw - 28px)); position: fixed; z-index: 90; padding: 11px 12px; color: #eaf1fa; background: rgba(17,31,51,.97); border: 1px solid #334963; border-top: 2px solid #5d9cef; border-radius: 5px; box-shadow: 0 10px 28px rgba(15,28,48,.25); pointer-events: none; font-size: 10px; line-height: 1.55; }
.tooltip strong { display: block; margin-bottom: 5px; color: #fff; font-family: "Songti SC", Georgia, serif; font-size: 12px; line-height: 1.45; }
.tooltip span { color: #aebfd3; }
.empty-state { position: absolute; inset: 0; place-items: center; align-content: center; color: #718199; text-align: center; }
.empty-state:not([hidden]) { display: grid; }
.empty-state .material-symbols-rounded { margin-bottom: 9px; font-size: 34px; }
.empty-state strong { color: #43566e; font-size: 13px; }
.empty-state p { margin: 5px 0; font-size: 10px; }

.detail-panel { background: #f8fafc; border-left: 1px solid var(--line); }
.detail-header { height: 51px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px 0 20px; background: #fff; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 0; font-family: "Songti SC", Georgia, serif; font-size: 15px; font-weight: 600; }
.detail-header .icon-button { width: 30px; height: 30px; border: 0; background: transparent; }
.detail-empty { min-height: 420px; display: grid; place-items: center; align-content: center; padding: 30px; color: #75859b; text-align: center; }
.detail-empty .material-symbols-rounded { margin-bottom: 12px; color: #96a8bd; font-size: 36px; }
.detail-empty strong { color: #4c6078; font-size: 13px; }
.detail-empty p { max-width: 230px; margin: 7px 0 0; font-size: 10px; line-height: 1.6; }
.detail-content { padding: 22px 25px 32px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 15px; }
.detail-tag { padding: 4px 7px; color: #5b6d83; background: #e8edf3; border-radius: 4px; font-size: 9px; }
.detail-tag.representative { color: #8a6100; background: #fff1c9; }
.detail-content h3 { margin: 0 0 16px; font-family: "Songti SC", "Noto Serif SC", Georgia, serif; font-size: 20px; font-weight: 500; line-height: 1.45; }
.detail-meta { display: grid; grid-template-columns: 42px 1fr; gap: 6px 8px; margin: 0; color: #455973; font-size: 11px; line-height: 1.5; }
.detail-meta dt { color: #687b94; font-weight: 600; }
.detail-meta dd { margin: 0; overflow-wrap: anywhere; }
.detail-meta a { color: var(--blue); text-decoration: none; }
.detail-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-section h4 { margin: 0 0 10px; font-family: "Songti SC", Georgia, serif; font-size: 13px; font-weight: 600; }
.detail-section p { margin: 0; color: #3e526c; font-family: "Songti SC", Georgia, serif; font-size: 12px; line-height: 1.85; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 5px; }
.keyword-list span { padding: 4px 7px; color: #526a85; background: #edf2f7; border: 1px solid #e0e7ef; border-radius: 10px; font-size: 9px; }
.relation-list { display: grid; gap: 7px; }
.relation-item { display: grid; grid-template-columns: 22px 1fr; gap: 7px; align-items: start; padding: 8px; color: #415872; background: #fff; border: 1px solid var(--line); border-radius: 5px; text-align: left; font-size: 10px; cursor: pointer; }
.relation-item:hover { color: var(--blue); border-color: #adc8ed; }
.relation-item .material-symbols-rounded { margin-top: 1px; color: #7a8ca4; font-size: 15px; }
.detail-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 22px; }
.primary-link, .secondary-action { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 5px; text-decoration: none; font-size: 11px; }
.primary-link { color: #fff; background: var(--blue); }
.primary-link:hover { background: var(--blue-dark); }
.secondary-action { width: 40px; color: #536a85; background: #fff; border: 1px solid var(--line); }

.stage-summary { background: #fff; }
.summary-heading { display: flex; align-items: end; justify-content: space-between; padding: 26px 28px 18px; border-bottom: 1px solid var(--line); }
.summary-heading span { color: #718198; font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.summary-heading h2 { margin: 4px 0 0; font-family: "Songti SC", Georgia, serif; font-size: 20px; }
.summary-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.stage-cards { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.stage-card { min-height: 104px; padding: 17px 19px; border-right: 1px solid var(--line); }
.stage-card:last-child { border-right: 0; }
.stage-card span { color: #73839a; font-size: 9px; }
.stage-card strong { display: block; margin: 5px 0 6px; color: var(--blue); font-family: Georgia, "Songti SC", serif; font-size: 20px; font-weight: 500; }
.stage-card p { margin: 0; color: #52657c; font-size: 10px; line-height: 1.5; }
.summary-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th, td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
th { color: #61738a; background: #fafbfd; font-size: 9px; white-space: nowrap; }
td:first-child { min-width: 130px; font-weight: 600; }
.summary-direction { display: inline-flex; align-items: center; gap: 7px; }
.summary-direction i { width: 7px; height: 7px; border-radius: 50%; }
.scrim { position: fixed; z-index: 55; inset: var(--topbar-h) 0 0; background: rgba(20,34,55,.28); }

@media (max-width: 1320px) {
  :root { --sidebar-w: 232px; --detail-w: 320px; }
  .brand .representative-badge { display: none; }
  .search-field { width: 220px; }
  .stage-pill { min-width: 96px; }
}

@media (max-width: 1120px) {
  .workspace { grid-template-columns: var(--sidebar-w) minmax(480px, 1fr); }
  .detail-panel { width: min(390px, calc(100vw - 40px)); position: fixed; z-index: 60; top: var(--topbar-h); right: 0; transform: translateX(102%); transition: transform .22s ease; box-shadow: -12px 0 30px rgba(24,42,70,.14); }
  .detail-panel.open { transform: translateX(0); }
  .brand p, .top-divider { display: none; }
  .year-control { display: none; }
}

@media (max-width: 840px) {
  .mobile-only { display: inline-flex !important; }
  .topbar { height: 56px; padding: 0 10px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 16px; }
  .brand .mobile-only { width: 34px; height: 34px; }
  .top-actions { gap: 6px; }
  .top-actions .toolbar-button { width: 34px; padding: 0; font-size: 0; }
  .top-actions .toolbar-button .material-symbols-rounded { font-size: 18px; }
  .search-field { width: min(300px, 40vw); }
  .search-field kbd { display: none; }
  .workspace { display: block; }
  .sidebar { width: min(300px, calc(100vw - 42px)); position: fixed; z-index: 60; top: 56px; left: 0; max-height: calc(100vh - 56px); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 30px rgba(24,42,70,.14); }
  .sidebar.open { transform: translateX(0); }
  .profile .mobile-only { margin-left: auto; }
  .timeline-shell { height: calc(100vh - 56px); min-height: 600px; }
  .timeline-meta { padding: 9px 14px; }
  .stage-band { display: none; }
  .detail-panel { top: 56px; max-height: calc(100vh - 56px); }
  .summary-heading { padding: 22px 18px 15px; }
  .stage-cards { grid-template-columns: repeat(2, 1fr); }
  .stage-card:nth-child(2) { border-right: 0; }
}

@media (max-width: 560px) {
  .brand h1 { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .search-field { width: 38px; padding: 0 9px; }
  .search-field input { width: 0; opacity: 0; }
  .search-field:focus-within { width: calc(100vw - 164px); position: absolute; z-index: 70; right: 92px; background: #fff; }
  .search-field:focus-within input { width: auto; opacity: 1; }
  #reset-all { display: none; }
  .detail-panel { width: 100vw; }
  .timeline-meta h2 { font-size: 14px; }
  .timeline-meta p { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .density-navigator { padding: 0 10px; }
  .summary-heading { align-items: start; flex-direction: column; gap: 7px; }
  .stage-cards { grid-template-columns: 1fr; }
  .stage-card { border-right: 0; }
}

@media print {
  .topbar, .sidebar, .detail-panel, .canvas-tools, .density-navigator, .stage-summary { display: none !important; }
  .workspace { display: block; }
  .timeline-shell { height: auto; min-height: 700px; }
}
