:root {
  --accent: #cc0000;
  --accent-dark: #990000;
  --ink: #181818;
  --muted: #666;
  --line: #dedede;
  --soft: #f6f6f6;
  --white: #fff;
  font-family: Ubuntu, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--white);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--white);
}

body.player-open {
  padding-bottom: 126px;
}

button,
input,
audio {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
.station-card:focus-visible {
  outline: 3px solid rgba(204, 0, 0, 0.24);
  outline-offset: 2px;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--white);
}

.primary-action:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-dot {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  background: var(--white);
}

.status-dot.is-on {
  border-color: rgba(204, 0, 0, 0.32);
  color: var(--accent);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(320px, 0.55fr);
  grid-template-rows: minmax(440px, calc(100vh - 340px)) auto;
  grid-template-areas:
    "media map list"
    "detail detail list";
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 48px) 30px;
}

.media-area {
  grid-area: media;
  min-width: 0;
  min-height: 0;
}

.map-area {
  grid-area: map;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.map-frame {
  position: relative;
  flex: 1;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #edf2f0;
}

#routeMap {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 380px;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.map-empty[hidden] {
  display: none;
}

.leaflet-container {
  position: relative;
  overflow: hidden;
  font: inherit;
  background: #edf2f0;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container img.leaflet-tile,
.leaflet-container .leaflet-marker-icon,
.leaflet-container .leaflet-marker-shadow {
  max-width: none;
  max-height: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  user-select: none;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-control-container {
  font: inherit;
}

.station-map-marker {
  width: 32px;
  height: 32px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--white);
  color: var(--accent);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.24);
}

.station-map-marker span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.station-map-marker.is-active {
  background: var(--accent);
  color: var(--white);
}

.guide-panel {
  grid-area: list;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

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

.station-list {
  display: grid;
  gap: 10px;
}

.station-card {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
  text-align: left;
  white-space: normal;
}

.station-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.station-number {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--white);
  font-weight: 700;
}

.station-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  letter-spacing: 0;
  line-height: 1.25;
}

.station-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.station-card small {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-panel {
  grid-area: detail;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  gap: 10px;
  align-items: start;
  align-content: start;
  overflow: hidden;
}

.station-figure {
  position: relative;
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
  touch-action: pan-y;
}

.station-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

.gallery-dot {
  width: 9px;
  height: 9px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
}

.gallery-dot.is-active {
  background: var(--accent);
}

.detail-copy {
  width: 100%;
  max-width: none;
}

.station-route-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 12px 0 4px;
}

.station-route-nav[hidden] {
  display: none;
}

.station-route-link {
  min-width: 0;
  min-height: 78px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  display: grid;
  gap: 7px;
  align-content: center;
  text-align: left;
  white-space: normal;
  overflow: hidden;
}

.station-route-link:hover,
.station-route-link:focus-visible {
  border-color: var(--accent);
  background: rgba(183, 33, 43, 0.08);
}

.station-route-link.is-next {
  text-align: right;
}

.station-route-distance {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
}

.station-route-main {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.station-route-link.is-next .station-route-main {
  grid-template-columns: minmax(0, 1fr) auto;
}

.station-route-title {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.2;
  font-size: 0.9rem;
  font-weight: 700;
}

.station-route-link.is-next .station-route-arrow {
  grid-column: 2;
  grid-row: 1;
}

.station-route-link.is-next .station-route-title {
  grid-column: 1;
  grid-row: 1;
}

.station-route-arrow {
  flex: 0 0 auto;
  font-size: 1.25rem;
  line-height: 1;
}

.detail-copy p:not(.eyebrow),
.audio-hint {
  color: var(--muted);
  line-height: 1.5;
}

.detail-copy p:not(.eyebrow) {
  width: 100%;
  max-width: none;
  margin: 8px 0 0;
}

.audio-box {
  min-width: 0;
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding: 2px 0 10px;
}

.start-audio-btn {
  min-width: 190px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--white);
  font-weight: 700;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.audio-hint {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.bottom-player {
  position: fixed;
  z-index: 1200;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.16);
  padding: 12px clamp(16px, 4vw, 48px);
}

.bottom-player[hidden] {
  display: none;
}

.bottom-player-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(180px, 0.32fr) minmax(260px, 1fr) 44px;
  gap: 14px;
  align-items: center;
}

.player-copy {
  min-width: 0;
}

.player-copy h2 {
  font-size: 1rem;
}

.app-audio-player {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.player-toggle {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border-color: var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--white);
  display: grid;
  place-items: center;
}

.player-toggle .play-icon {
  margin-left: 3px;
}

.pause-icon {
  width: 14px;
  height: 18px;
  border-left: 5px solid currentColor;
  border-right: 5px solid currentColor;
}

.player-timeline {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.player-progress {
  width: 100%;
  accent-color: var(--accent);
}

.player-time {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

#audioPlayer {
  display: none;
}

.player-close {
  width: 44px;
  min-width: 44px;
  padding: 0;
  border-color: var(--accent);
  color: var(--accent);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}

@media (max-width: 940px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-row {
    justify-content: flex-start;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "map"
      "media"
      "detail"
      "list";
  }

  .map-frame,
  #routeMap {
    height: min(58vh, 520px);
    min-height: 360px;
    max-height: 520px;
  }

  .guide-panel {
    border-left: 0;
    padding-left: 0;
  }

  .detail-panel {
    grid-template-columns: 1fr;
  }

  .station-figure {
    aspect-ratio: 4 / 3;
    height: auto;
    min-height: 0;
    max-height: 360px;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding-top: 16px;
  }

  .shell {
    padding-inline: 12px;
  }

  .map-toolbar,
  .panel-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .bottom-player {
    padding: 10px 12px;
  }

  .bottom-player-inner {
    grid-template-columns: 1fr 44px;
    gap: 8px;
  }

  .app-audio-player {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .player-close {
    grid-column: 2;
    grid-row: 1;
    width: 44px;
  }

  .station-card {
    grid-template-columns: 36px minmax(0, 1fr);
  }
}
