:root {
  --bg: oklch(0.98 0.004 250);
  --paper: oklch(1 0 0);
  --panel: oklch(0.958 0.011 250);
  --panel-strong: oklch(0.91 0.025 250);
  --ink: oklch(0.18 0.026 250);
  --muted: oklch(0.42 0.028 250);
  --line: oklch(0.8 0.022 250);
  --primary: oklch(0.54 0.15 250);
  --primary-dark: oklch(0.37 0.13 250);
  --accent: oklch(0.66 0.15 28);
  --amber: oklch(0.74 0.14 78);
  --rain: oklch(0.62 0.12 215);
  --green: oklch(0.58 0.12 156);
  --shadow: 0 6px 14px oklch(0.18 0.03 250 / 0.12);
  --radius: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-body: "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", "Microsoft YaHei UI", serif;
}

* { box-sizing: border-box; }

html,
body {
  max-width: 100%;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(115deg, oklch(0.94 0.018 250), oklch(1 0 0) 44%, oklch(0.96 0.018 28)),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

button, a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(520px, 1fr) 340px;
  gap: 14px;
  min-height: 100vh;
  max-width: 100vw;
  width: 100%;
  padding: 14px;
}

.route-rail,
.detail-dock,
.workspace > section,
.mission-board {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.route-rail,
.detail-dock {
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  overflow: auto;
}

.route-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-weight: 950;
  letter-spacing: 0;
}

.meta-line,
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.panel-label {
  display: block;
  margin-bottom: 6px;
}

h1, h2, h3, p { text-wrap: pretty; }

h1,
h2,
h3,
p,
strong,
span,
li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.16;
  font-weight: 900;
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1.22;
  font-weight: 900;
}

h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
}

.day-switcher {
  display: grid;
  gap: 8px;
}

.day-tab {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}

.day-tab:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.day-tab[aria-selected="true"] {
  background: oklch(0.92 0.045 250);
  border-color: var(--primary);
}

.date-chip {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--primary-dark);
  font-weight: 950;
}

.day-tab small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.day-tab > span:nth-child(2) {
  min-width: 0;
}

.weather-pill {
  padding: 4px 7px;
  border-radius: 999px;
  background: oklch(0.94 0.05 78);
  color: oklch(0.38 0.09 78);
  font-size: 0.75rem;
  font-weight: 850;
}

.weather-pill.rain {
  background: oklch(0.91 0.045 215);
  color: oklch(0.28 0.08 215);
}

.route-map,
.rail-note {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.map-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.map-canvas {
  position: relative;
  height: 300px;
  margin-top: 10px;
  overflow: visible;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, oklch(0.98 0.006 250), oklch(0.94 0.018 250)),
    var(--panel);
}

.map-canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.route-shadow,
.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-shadow {
  stroke: oklch(0.2 0.03 250 / 0.12);
  stroke-width: 12;
}

.route-line {
  stroke: var(--primary);
  stroke-width: 5;
  stroke-dasharray: 720;
  stroke-dashoffset: 720;
  animation: drawRoute 620ms var(--ease) forwards;
}

.map-nodes {
  position: absolute;
  inset: 0;
}

.map-node {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 950;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}

.map-node:hover,
.map-node.active {
  transform: translate(-50%, -50%) scale(1.12);
  background: var(--accent);
}

.map-node.active::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px solid oklch(0.66 0.15 28 / 0.34);
  border-radius: 50%;
  animation: pulse 1300ms var(--ease) infinite;
}

.rail-note p {
  margin: 0;
  color: var(--ink);
}

.workspace {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.mission-board {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  min-height: 108px;
  background:
    linear-gradient(118deg, oklch(1 0 0), oklch(0.95 0.018 250) 72%),
    var(--paper);
}

.mission-board > div:first-child {
  min-width: 0;
}

.mission-board h2 {
  margin-top: 5px;
  font-size: 2.48rem;
}

.mission-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.status-token {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 820;
}

.now-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 18px;
  background:
    linear-gradient(120deg, oklch(0.9 0.052 250), oklch(0.99 0.003 250) 64%),
    var(--paper);
  overflow: hidden;
}

.now-copy,
.now-stats {
  min-width: 0;
}

.progress-shell {
  margin-top: 16px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 820;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: oklch(0.82 0.025 250);
}

.progress-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(var(--progress-scale, 0));
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: transform 260ms var(--ease);
}

.now-copy h2 {
  margin-top: 5px;
  font-size: 3rem;
}

.now-copy p {
  max-width: 65ch;
  margin: 10px 0 0;
  color: var(--muted);
}

.now-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-box {
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: oklch(1 0 0 / 0.82);
}

.stat-box strong {
  display: block;
  font-size: 1.22rem;
  line-height: 1.18;
}

.stat-box span {
  color: var(--muted);
  font-size: 0.82rem;
}

.timeline-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-head p {
  max-width: 54ch;
  margin: 0;
  color: var(--muted);
}

.timeline {
  position: relative;
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-left: 16px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--primary), oklch(0.75 0.06 250), var(--accent));
}

.time-row {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 170px;
  gap: 14px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  transform: translateY(0);
  opacity: 1;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease);
  animation: rowIn 360ms var(--ease) both;
  animation-delay: calc(var(--i) * 35ms);
}

.time-row::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 18px;
  width: 13px;
  height: 13px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--line);
}

.time-row:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.time-row.active {
  background: oklch(0.95 0.026 250);
  border-color: var(--primary);
}

.time-row.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 6px oklch(0.66 0.15 28 / 0.16);
}

.time-cell {
  color: var(--primary-dark);
  font-weight: 950;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.stop-main p {
  margin: 6px 0 0;
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 820;
}

.tag.food { background: oklch(0.94 0.052 28); color: oklch(0.39 0.09 28); }
.tag.cost { background: oklch(0.94 0.052 160); color: oklch(0.34 0.08 160); }
.tag.warn { background: oklch(0.95 0.06 78); color: oklch(0.38 0.09 72); }

.commute-cell {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.mini-map-link,
.map-button {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--paper);
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.matrix-zone {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.info-panel,
.source-panel {
  padding: 18px;
}

.mini-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.mini-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-list strong {
  font-size: 0.95rem;
}

.mini-list span {
  color: var(--muted);
  font-size: 0.88rem;
}

.source-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.source-panel li + li { margin-top: 7px; }

.detail-dock {
  padding: 16px;
}

.dock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.dock-body {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  animation: dockIn 220ms var(--ease) both;
}

.detail-title {
  display: grid;
  gap: 6px;
}

.detail-title h2 {
  font-size: 2.08rem;
}

.detail-title p {
  margin: 0;
  color: var(--muted);
}

.detail-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.detail-block strong {
  display: block;
  margin-bottom: 6px;
}

.detail-block p {
  margin: 0;
  color: var(--muted);
}

.hidden { display: none; }

@keyframes drawRoute {
  to { stroke-dashoffset: 0; }
}

@keyframes pulse {
  from { opacity: 0.9; transform: scale(0.88); }
  to { opacity: 0; transform: scale(1.55); }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dockIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .detail-dock {
    position: static;
    grid-column: 1 / -1;
    height: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
    max-width: 100%;
  }
  .route-rail {
    position: static;
    height: auto;
  }
  .route-map {
    display: none;
  }
  .mission-board,
  .now-card,
  .section-head {
    display: grid;
    grid-template-columns: 1fr;
  }
  .mission-status {
    justify-content: flex-start;
  }
  .status-token {
    max-width: 100%;
    min-height: 30px;
    padding: 6px 9px;
    font-size: 0.84rem;
  }
  .now-stats,
  .matrix-zone {
    grid-template-columns: 1fr;
  }
  .time-row {
    grid-template-columns: 1fr;
  }
  .timeline {
    padding-left: 12px;
  }
  .time-row::before {
    left: -20px;
  }
  .route-rail,
  .detail-dock,
  .workspace > section,
  .mission-board {
    border-radius: var(--radius);
  }
}

@media (max-width: 520px) {
  body { font-size: 14px; }
  .app-shell {
    width: 100%;
    max-width: 100%;
    padding: 10px;
  }
  .route-rail,
  .detail-dock,
  .workspace > section,
  .mission-board {
    width: 100%;
  }
  .mission-board h2,
  .now-copy h2 {
    max-width: 100%;
    font-size: 1.58rem;
    line-height: 1.28;
    word-break: auto-phrase;
    overflow-wrap: anywhere;
  }
  .mission-board h2 {
    display: block;
  }
  .mission-status {
    max-width: 100%;
  }
  .mission-board,
  .now-card,
  .timeline-panel,
  .info-panel,
  .source-panel,
  .detail-dock {
    padding: 14px;
  }
  .day-tab {
    grid-template-columns: auto 1fr;
  }
  .weather-pill {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
