:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --line: #e5e7eb;
  --ink: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #e7f5f2;
  --shadow: 0 10px 30px rgba(17, 24, 39, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0, var(--bg) 280px);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
button, input, select { font: inherit; }

.schedule-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 18px 42px;
}
.schedule-shell.compact {
  padding-top: 12px;
}
.compact-stats {
  margin-bottom: 12px;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 22px;
  align-items: end;
  padding: 10px 0 18px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.12; }
.topbar p:not(.eyebrow), .panel-head p { margin-top: 8px; color: var(--muted); }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 3px; font-size: 19px; }

.controls,
.trend-panel,
.timeline-shell,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.controls { padding: 14px; display: grid; gap: 12px; }
.type-row { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}
.type-chip.active {
  border-color: var(--chip);
  background: color-mix(in srgb, var(--chip) 12%, #fff);
  color: var(--chip);
  font-weight: 800;
}
.filter-row {
  display: grid;
  grid-template-columns: 140px 140px minmax(200px, 1fr);
  gap: 10px;
  align-items: end;
}
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
select, input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.trend-panel {
  margin-top: 14px;
  padding: 16px 18px 10px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 8px;
}
.panel-head h2 { font-size: 20px; }
.panel-head strong { color: var(--accent); font-size: 28px; }
.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.trend-zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}
.trend-zoom button {
  min-width: 32px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}
.trend-zoom .zoom-reset {
  min-width: 54px;
  padding: 0 10px;
  color: var(--accent);
}
.trend-zoom button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}
.trend-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scrollbar-gutter: stable;
}
.trend-scroll::-webkit-scrollbar { height: 10px; }
.trend-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}
.trend-chart {
  min-width: 100%;
  height: auto;
  max-height: 440px;
  display: block;
}
.grid-line { stroke: #eef0f3; stroke-width: 1; }
.axis-line { stroke: #cbd5e1; stroke-width: 2; }
.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 4px 0 8px;
}
.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.trend-legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--legend, var(--muted));
}
.trend-points circle {
  fill: #fff;
  stroke: var(--series);
  stroke-width: 2.5;
}
.trend-points circle:hover {
  fill: var(--series);
}
.type-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.trend-range rect {
  fill: color-mix(in srgb, var(--range) 34%, #fff);
  stroke: var(--range);
  stroke-width: 2.2;
}
.trend-range text {
  fill: var(--ink);
  font-weight: 800;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3.4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.year-label { fill: var(--muted); font-size: 13px; }

.workspace {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.timeline-shell {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.timeline-head span { color: var(--muted); font-size: 13px; }
.timeline-head strong,
.timeline-head > div span { display: block; }
.jump-label {
  width: 118px;
  flex: 0 0 118px;
}
.jump-label span {
  margin-bottom: 5px;
  font-size: 11px;
}
.jump-label select {
  height: 34px;
  padding: 0 8px;
}
.timeline-scroller {
  overflow: auto;
  padding: 10px 12px 18px;
  scroll-snap-type: y proximity;
}
.timeline-scroller::after {
  content: "";
  display: block;
  height: 62vh;
  min-height: 260px;
}
.time-node {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 7px;
  width: 100%;
  min-height: 48px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  scroll-snap-align: start;
}
.year-node { cursor: pointer; }
.year-block + .year-block { margin-top: 2px; }
.day-node-list {
  display: grid;
  gap: 1px;
  margin-left: 18px;
  padding-left: 10px;
}
.year-block:not(.expanded) .day-node-list { display: none; }
.day-node {
  grid-template-columns: 14px minmax(0, 1fr);
  min-height: 38px;
}
.time-node::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: -14px;
  width: 2px;
  background: var(--line);
}
.time-node:last-child::before { display: none; }
.year-block:not(.expanded) .year-node::before { display: none; }
.day-node::before {
  left: 6px;
  top: 16px;
  bottom: -12px;
}
.node-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  margin-top: 8px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #cbd5e1;
  box-shadow: 0 0 0 1px var(--line);
}
.day-node .node-dot {
  width: 12px;
  height: 12px;
  margin-top: 8px;
  border-width: 2px;
}
.node-main {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 9px;
}
.node-main time { display: block; font-size: 18px; font-weight: 900; line-height: 1.1; }
.node-main span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.day-node .node-main { padding: 6px 8px; }
.day-node .node-main time { font-size: 13px; }
.day-node .node-main span { margin-top: 1px; font-size: 11px; }
.time-node.active .node-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.time-node.active .node-main {
  border-color: #b7ded7;
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-panel { min-height: calc(100vh - 32px); padding: 18px; }
.event-list { display: grid; gap: 12px; }
.event-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--event);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}
.event-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.event-card-head time {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
}
.event-type {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--event);
  background: color-mix(in srgb, var(--event) 10%, #fff);
  font-size: 12px;
  font-weight: 800;
}
.event-card h3 { margin-top: 10px; font-size: 20px; line-height: 1.35; }
.event-meta, .tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.event-meta span, .tag-row span {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
}
.empty {
  padding: 36px 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 900px) {
  .schedule-shell { padding: 16px 12px 30px; }
  .topbar { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 28px; }
  .panel-head {
    display: grid;
    gap: 10px;
  }
  .panel-actions {
    justify-content: space-between;
  }
  .type-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .type-chip {
    flex: 0 0 auto;
  }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .search-label { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; }
  .timeline-shell {
    position: relative;
    top: auto;
    height: 240px;
  }
  .detail-panel { min-height: auto; }
}

@media (max-width: 520px) {
  .schedule-shell {
    padding: 10px 8px 24px;
  }

  .compact-stats,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px;
  }

  .stat strong {
    font-size: 17px;
  }

  .controls,
  .trend-panel,
  .timeline-shell,
  .detail-panel {
    border-radius: 7px;
  }

  .controls {
    padding: 10px;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .trend-panel {
    padding: 12px 10px 8px;
  }

  .trend-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .trend-legend span {
    flex: 0 0 auto;
  }

  .trend-zoom button {
    min-width: 34px;
  }

  .trend-zoom .zoom-reset {
    min-width: 56px;
  }

  .trend-chart {
    max-height: 360px;
  }

  .workspace {
    gap: 10px;
  }

  .timeline-head {
    padding: 12px;
  }

  .timeline-shell {
    height: 220px;
  }

  .timeline-scroller {
    padding: 8px 10px 14px;
  }

  .node-main {
    padding: 6px 8px;
  }

  .node-main time {
    font-size: 17px;
  }

  .day-node .node-main time {
    font-size: 13px;
  }

  .detail-panel {
    padding: 12px;
  }

  .event-card {
    padding: 13px;
  }

  .event-card h3 {
    font-size: 17px;
  }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  .search-label { grid-column: auto; }
  .trend-panel { padding: 14px 12px 8px; }
  .trend-chart { height: 190px; }
  .event-card h3 { font-size: 18px; }
}
