:root {
  color-scheme: light;
  --ink: #151922;
  --muted: #646b78;
  --panel: #ffffff;
  --bg: #f7f4ea;
  --shadow: 0 16px 42px rgba(24, 32, 51, 0.1);
  --soft-line: rgba(21, 25, 34, 0.12);
  --region-soft: color-mix(in srgb, var(--region-color) 28%, #fff);
  --region-faint: color-mix(in srgb, var(--region-color) 11%, #fff);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--region-color) 18%, transparent), transparent 42%),
    var(--bg);
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(18px, 4vw, 48px);
  border-bottom: 6px solid var(--region-color);
  background: #171b24;
  color: #fff;
}

.topbar-title {
  display: grid;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.brand-trail,
.language-switcher,
.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 0;
}

.brand-link {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 1000;
  line-height: 1.2;
  text-decoration: none;
}

.brand-link.region {
  color: #d7dde8;
}

.language-switcher {
  gap: 6px;
}

.language-option {
  display: inline-grid;
  place-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: transparent;
  color: #d7dde8;
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

.language-option[aria-current="page"] {
  background: #fff;
  color: #171b24;
}

.language-option[aria-disabled="true"] {
  opacity: 0.58;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  color: #d7dde8;
  font-size: 0.9rem;
  font-weight: 900;
}

.title-row {
  justify-content: space-between;
}

.topbar h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 3.4rem);
  line-height: 1.02;
}

.hub-link-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: #fff;
  color: #171b24;
  cursor: pointer;
  font: inherit;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.hub-mode .hub-link-button {
  display: none;
}

.shell,
.footer {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.shell {
  padding: 42px 0 56px;
}

.hero {
  max-width: 760px;
  margin-bottom: 24px;
}

.hero span,
.section-title span {
  color: var(--region-color);
  font-size: 0.8rem;
  font-weight: 1000;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 6px;
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  line-height: 0.98;
}

.hero p {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.45;
}

.panel {
  padding-top: 20px;
  border-top: 1px solid rgba(21, 25, 34, 0.14);
}

.section-title {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.section-title.compact {
  margin-bottom: 10px;
}

.section-title h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.section-title h3 {
  font-size: 1.05rem;
}

.line-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.line-card {
  display: grid;
  gap: 7px;
  min-height: 116px;
  padding: 18px;
  border: 1px solid var(--soft-line);
  border-left: 18px solid var(--line-color);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.line-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.line-card strong {
  font-size: 1.22rem;
}

.line-card small {
  color: var(--muted);
  font-weight: 800;
}

.line-card:hover,
.line-card:focus-visible {
  border-color: var(--line-color);
  box-shadow: 0 18px 46px rgba(24, 32, 51, 0.16);
  transform: translateY(-1px);
  outline: none;
}

.line-view {
  margin-top: 24px;
}

.detail-mode .hero {
  display: none;
}

.line-view-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.line-view-head .section-title {
  margin-bottom: 0;
}

.line-view-head h1 {
  max-width: 760px;
  font-size: clamp(1.75rem, 5vw, 3.4rem);
  line-height: 1.02;
}

.line-view-head small {
  color: var(--muted);
  font-weight: 900;
}

.hub-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--region-soft);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(24, 32, 51, 0.08);
}

.api-note,
.shortcut-panel,
.bottom-summary {
  margin: 0 0 16px;
  border-radius: 8px;
}

.api-note {
  padding: 12px 14px;
  border-left: 6px solid var(--region-color);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-weight: 900;
}

.shortcut-panel,
.bottom-summary {
  border: 1px solid var(--soft-line);
  background: #fff;
  box-shadow: var(--shadow);
}

.route-shortcuts {
  padding: 0;
}

.route-shortcuts details {
  overflow: hidden;
  border-radius: 8px;
}

.route-shortcuts summary {
  position: relative;
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 12px 44px 12px 16px;
  cursor: pointer;
  list-style: none;
}

.route-shortcuts summary::-webkit-details-marker {
  display: none;
}

.route-shortcuts summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 160ms ease;
}

.route-shortcuts details[open] summary::after {
  transform: translateY(-35%) rotate(225deg);
}

.route-shortcuts summary span {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 1000;
}

.route-shortcuts summary small {
  color: var(--muted);
  font-weight: 800;
}

.shortcut-list {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 16px,
      var(--region-soft) 16px 22px,
      transparent 22px 44px
    );
  background-clip: content-box;
}

.shortcut-chip {
  position: relative;
  z-index: 1;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(24, 32, 51, 0.08);
}

.shortcut-chip:hover,
.shortcut-chip:focus-visible {
  border-color: var(--region-color);
  background: var(--region-faint);
  outline: none;
}

.muted {
  color: var(--muted);
}

.error-text {
  color: #b42318;
}

.estimate-summary {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.estimate-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7f4ea;
}

.estimate-summary dt,
.estimate-summary dd {
  margin: 0;
  font-weight: 900;
}

.estimate-summary dt {
  color: var(--muted);
}

.schedule-preview {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.schedule-preview li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(21, 25, 34, 0.1);
  border-radius: 8px;
}

.schedule-preview span {
  color: var(--muted);
  font-weight: 800;
}

.station-list {
  position: relative;
  display: grid;
  gap: 0;
  padding: 14px 0 18px;
  --station-link-length: calc(clamp(10px, 3vw, 22px) + clamp(46px, 8vw, 74px));
}

.line-empty-state {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--region-soft);
  border-radius: 8px;
  background: linear-gradient(0deg, var(--region-faint), var(--region-faint)), #fff;
  box-shadow: 0 10px 24px rgba(24, 32, 51, 0.08);
}

.line-empty-state strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 1000;
}

.line-empty-state span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}

.station-list::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  width: 10px;
  border-radius: 999px;
  background: var(--region-color);
  transform: translateX(-50%);
  opacity: 0.82;
}

.station-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(106px, 148px) minmax(0, 1fr);
  gap: clamp(10px, 3vw, 22px);
  align-items: center;
  min-height: 92px;
  padding: 10px 0;
}

.station-row.is-highlighted::before {
  content: "";
  position: absolute;
  inset: 4px -10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--region-color) 18%, transparent);
  animation: stationHighlight 2s ease-out forwards;
  pointer-events: none;
}

.direction-column {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 1px;
}

.direction-column::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 22px;
  background: color-mix(in srgb, var(--region-color) 58%, #fff);
  opacity: 0.34;
  pointer-events: none;
  z-index: 0;
}

.down-column::before {
  right: -2px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='28' viewBox='0 0 22 28'%3E%3Cpath d='M11 24 3 8h16L11 24Z' fill='black'/%3E%3C/svg%3E") repeat-y;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='28' viewBox='0 0 22 28'%3E%3Cpath d='M11 24 3 8h16L11 24Z' fill='black'/%3E%3C/svg%3E") repeat-y;
  -webkit-mask-size: 22px 28px;
  mask-size: 22px 28px;
  animation: directionGuideDown 3.2s linear infinite;
}

.up-column::before {
  left: -2px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='28' viewBox='0 0 22 28'%3E%3Cpath d='M11 4 19 20H3L11 4Z' fill='black'/%3E%3C/svg%3E") repeat-y;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='28' viewBox='0 0 22 28'%3E%3Cpath d='M11 4 19 20H3L11 4Z' fill='black'/%3E%3C/svg%3E") repeat-y;
  -webkit-mask-size: 22px 28px;
  mask-size: 22px 28px;
  animation: directionGuideUp 3.2s linear infinite;
}

.down-column {
  justify-items: end;
}

.up-column {
  justify-items: start;
}

.station-axis {
  position: relative;
  display: grid;
  justify-items: center;
  z-index: 1;
}

.station-marker {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 22px;
  height: 22px;
  border: 5px solid #fff;
  border-radius: 999px;
  background: var(--region-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--region-color) 55%, #000 0%);
  transform: translate(-50%, -50%);
  z-index: -1;
}

.station-name {
  display: grid;
  gap: 2px;
  min-width: 104px;
  max-width: 148px;
  padding: 9px 12px;
  border: 2px solid var(--region-soft);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: center;
  box-shadow: 0 10px 22px rgba(24, 32, 51, 0.12);
}

.station-name-main {
  font-size: 1.08rem;
  font-weight: 1000;
  line-height: 1.15;
}

.station-name-sub {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}

.train-card {
  position: relative;
  display: grid;
  gap: 7px;
  width: min(190px, 100%);
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(24, 32, 51, 0.1);
  z-index: 2;
}

.train-card::before {
  content: "";
  position: absolute;
  top: 50%;
  z-index: -1;
  width: var(--station-link-length);
  height: 4px;
  border-radius: 999px;
  background: var(--region-soft);
  transform: translateY(-50%);
}

.train-card.moving {
  --motion-start: 0;
  --motion-end: 0.96;
  --motion-duration: 60s;
  --station-travel-distance: 82px;
  will-change: transform;
  animation-duration: var(--motion-duration);
  animation-fill-mode: forwards;
  animation-iteration-count: 1;
  animation-timing-function: linear;
}

.down-column .train-card.moving {
  animation-name: trainMoveDown;
}

.up-column .train-card.moving {
  animation-name: trainMoveUp;
}

.down-column .train-card {
  border-right: 5px solid var(--region-color);
  text-align: right;
}

.down-column .train-card::before {
  right: calc(var(--station-link-length) * -1);
}

.up-column .train-card {
  border-left: 5px solid var(--region-color);
}

.up-column .train-card::before {
  left: calc(var(--station-link-length) * -1);
}

.train-card.fallback {
  border-style: dashed;
}

.train-terminal,
.train-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.train-terminal span:last-child {
  font-weight: 900;
}

.train-terminal-name,
.train-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-terminal-name {
  flex: 1 1 auto;
}

.train-direction-label {
  flex: 0 0 auto;
  min-width: max-content;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--region-faint);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 1000;
}

.bottom-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 18px;
  overflow: hidden;
}

.bottom-summary div {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-left: 1px solid var(--soft-line);
}

.bottom-summary div:first-child {
  border-left: 0;
}

.bottom-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-summary strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 1000;
}

.seo-intro {
  margin: 18px 0 0;
  padding: 16px;
  border-top: 1px solid var(--soft-line);
  color: var(--muted);
}

.seo-intro p {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.6;
}

.floating-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 1000;
  box-shadow: 0 14px 34px rgba(24, 32, 51, 0.18);
}

.floating-top:hover,
.floating-top:focus-visible {
  border-color: var(--region-color);
  outline: none;
}

@keyframes stationHighlight {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes trainMoveDown {
  from {
    transform: translateY(calc(var(--station-travel-distance) * var(--motion-start)));
  }
  to {
    transform: translateY(calc(var(--station-travel-distance) * var(--motion-end)));
  }
}

@keyframes trainMoveUp {
  from {
    transform: translateY(calc(var(--station-travel-distance) * var(--motion-start) * -1));
  }
  to {
    transform: translateY(calc(var(--station-travel-distance) * var(--motion-end) * -1));
  }
}

@keyframes directionGuideDown {
  from {
    -webkit-mask-position: 0 0;
    mask-position: 0 0;
  }
  to {
    -webkit-mask-position: 0 28px;
    mask-position: 0 28px;
  }
}

@keyframes directionGuideUp {
  from {
    -webkit-mask-position: 0 0;
    mask-position: 0 0;
  }
  to {
    -webkit-mask-position: 0 -28px;
    mask-position: 0 -28px;
  }
}

.train-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.train-meta strong {
  color: var(--ink);
}

.footer {
  padding: 0 0 38px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.footer p {
  margin: 6px 0 0;
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .language-switcher {
    width: 100%;
  }

  .language-option {
    flex: 1 1 0;
    padding: 0 6px;
    text-align: center;
  }

  .shell {
    padding-top: 30px;
  }

  .line-grid {
    grid-template-columns: 1fr;
  }

  .station-row {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 122px) minmax(0, 1fr);
    gap: 8px;
  }

  .line-view-head {
    display: grid;
  }

  .hub-button {
    justify-self: start;
  }

  .station-name {
    min-width: 92px;
    max-width: 122px;
    padding: 7px 8px;
  }

  .station-name-main {
    font-size: 0.92rem;
  }

  .station-name-sub {
    font-size: 0.66rem;
  }

  .train-card {
    padding: 8px;
  }

  .bottom-summary {
    grid-template-columns: 1fr;
  }

  .bottom-summary div,
  .bottom-summary div:first-child {
    border-left: 0;
    border-top: 1px solid var(--soft-line);
  }

  .bottom-summary div:first-child {
    border-top: 0;
  }
}
