@font-face {
  font-family: "Oswald";
  src: url("./assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3ecd9;
  --paper-light: #fffaf0;
  --paper-deep: #e7dcc0;
  --ink: #18201c;
  --muted: #5e665f;
  --tomato: #e5411f;
  --cobalt: #234ec7;
  --acid: #d9f45b;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --display: "Oswald", "Arial Narrow", Impact, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background-color: #ded2b6;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(24, 32, 28, 0.18) 1px, transparent 0);
  background-size: 6px 6px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body:has(dialog[open]) {
  overflow: hidden;
}

::selection {
  color: var(--ink);
  background: var(--acid);
}

img,
svg {
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--cobalt);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  color: var(--paper-light);
  background: var(--ink);
  border: 2px solid var(--paper-light);
  font-family: var(--mono);
  font-size: 12px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-frame {
  width: min(100%, 1520px);
  margin: 0 auto;
  background: var(--paper);
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  box-shadow: 0 0 0 8px rgba(24, 32, 28, 0.08);
}

/* ---------- Masthead ---------- */

.masthead {
  position: relative;
  padding: clamp(18px, 2.6vw, 34px) clamp(18px, 3.4vw, 48px) 0;
  overflow: hidden;
}

.masthead::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -100px;
  width: 330px;
  height: 330px;
  border: 2px solid rgba(24, 32, 28, 0.16);
  border-radius: 50%;
  pointer-events: none;
}

.masthead::after {
  content: "";
  position: absolute;
  top: 28px;
  right: 56px;
  width: 160px;
  height: 160px;
  border: 1px dashed rgba(24, 32, 28, 0.22);
  border-radius: 50%;
  pointer-events: none;
}

.masthead-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}

.kicker,
.edition {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker::before {
  content: "● ";
  color: var(--tomato);
}

.edition {
  color: var(--muted);
  white-space: nowrap;
}

.title-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: clamp(20px, 4vw, 60px);
  align-items: end;
  padding: clamp(16px, 2.2vw, 28px) 0 clamp(20px, 2.6vw, 36px);
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 0.77;
  letter-spacing: -0.035em;
}

.wordmark-one,
.wordmark-two {
  display: block;
}

.wordmark-one {
  font-size: clamp(74px, 12.4vw, 184px);
  color: var(--ink);
}

.wordmark-two {
  position: relative;
  width: fit-content;
  padding-right: 0.08em;
  font-size: clamp(86px, 14.2vw, 210px);
  color: var(--tomato);
  text-shadow: 0.035em 0.035em 0 var(--cobalt);
}

.wordmark-star {
  position: relative;
  top: -0.52em;
  display: inline-block;
  margin-left: 0.04em;
  color: var(--acid);
  font-family: var(--sans);
  font-size: 0.22em;
  letter-spacing: 0;
  -webkit-text-stroke: 1px var(--ink);
  text-shadow: none;
  transform: rotate(14deg);
}

.masthead-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 8px;
}

.masthead-deck {
  max-width: 27ch;
  margin: 0;
  font-size: clamp(17px, 1.4vw, 21px);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.015em;
}

.roundel {
  display: grid;
  place-content: center;
  width: 142px;
  height: 142px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: var(--mono);
  text-align: center;
  text-transform: uppercase;
  transform: rotate(7deg);
}

.roundel-top,
.roundel-bottom {
  font-size: 9px;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

.roundel-mid {
  font-family: var(--display);
  font-size: 48px;
  font-weight: 600;
  line-height: 0.9;
}

.ticker {
  margin: 0 calc(clamp(18px, 3.4vw, 48px) * -1);
  overflow: hidden;
  color: var(--paper-light);
  background: var(--ink);
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.ticker-track {
  display: flex;
  width: max-content;
  gap: 28px;
  align-items: center;
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: ticker-scroll 38s linear infinite;
}

.ticker-track b {
  color: var(--acid);
  font-weight: 400;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- Controls ---------- */

.control-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(160px, 0.7fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px clamp(18px, 3.4vw, 48px) 18px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 8px 0 rgba(24, 32, 28, 0.06);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.input-wrap,
.select-wrap {
  position: relative;
  min-width: 0;
}

.input-prefix {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  font-size: 20px;
  line-height: 1;
  transform: translateY(-52%);
  pointer-events: none;
}

input[type="search"],
select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 0;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
}

input[type="search"] {
  padding-left: 42px;
}

input[type="search"]::placeholder {
  color: #797f77;
  opacity: 1;
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

select {
  padding-right: 42px;
  appearance: none;
  cursor: pointer;
}

.select-wrap::after {
  content: "↓";
  position: absolute;
  top: 50%;
  right: 15px;
  font-family: var(--mono);
  font-size: 16px;
  transform: translateY(-54%);
  pointer-events: none;
}

input[type="search"]:hover,
select:hover {
  background: #fffdf8;
}

.saved-toggle,
.surprise-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 15px;
  border: 2px solid var(--ink);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.saved-toggle {
  background: var(--paper-light);
}

.saved-toggle-icon {
  color: var(--tomato);
  font-size: 15px;
}

.saved-toggle-count {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--paper);
  font-size: 9px;
}

.saved-toggle:hover {
  background: var(--acid);
}

.saved-toggle[aria-pressed="true"] {
  background: var(--acid);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.saved-toggle[aria-pressed="true"] .saved-toggle-icon {
  color: var(--ink);
}

.saved-toggle[aria-pressed="true"] .saved-toggle-count {
  color: var(--paper-light);
  background: var(--ink);
}

.surprise-button {
  color: var(--paper-light);
  background: var(--ink);
}

.surprise-button span {
  color: var(--acid);
  font-size: 17px;
}

.surprise-button:hover {
  color: var(--ink);
  background: var(--tomato);
  transform: translate(-1px, -1px);
}

.surprise-button:hover span {
  color: var(--ink);
}

/* ---------- Main layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 60px);
  align-items: start;
  padding: clamp(24px, 3.6vw, 48px) clamp(18px, 3.4vw, 48px) 72px;
}

.map-panel {
  position: sticky;
  top: 104px;
  min-width: 0;
}

.map-card {
  background: var(--paper-light);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

.map-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  color: var(--paper-light);
  background: var(--ink);
}

.map-card-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.map-card-head span {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.07em;
  text-align: right;
}

.map-stage {
  position: relative;
  aspect-ratio: 600 / 520;
  margin: 10px 10px 0;
  border: 1px solid rgba(24, 32, 28, 0.25);
  overflow: hidden;
}

.map-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.map-grid-lines path {
  fill: none;
  stroke: rgba(24, 32, 28, 0.11);
  stroke-width: 1;
}

.route-underlay {
  fill: none;
  stroke: var(--paper-light);
  stroke-width: 15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-line {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-saturday .route-line {
  stroke: var(--tomato);
}

.route-sunday .route-line {
  stroke: var(--cobalt);
}

.map-type text {
  font-family: var(--mono);
  letter-spacing: 0.08em;
}

.map-line-label {
  font-size: 12px;
  font-weight: 700;
}

.sunday-label {
  fill: var(--cobalt);
}

.saturday-label {
  fill: var(--tomato);
}

.map-arrow {
  font-size: 24px;
  font-weight: 700;
}

.map-note {
  fill: var(--ink);
  font-size: 8px;
  opacity: 0.55;
}

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

.map-stop {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(29px, 3vw, 37px);
  height: clamp(29px, 3vw, 37px);
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-light);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--mono);
  font-size: clamp(9px, 0.85vw, 11px);
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -50%);
  transition: transform 150ms ease, background-color 150ms ease, color 150ms ease;
}

.map-stop.saturday {
  color: var(--tomato);
  border-color: var(--tomato);
}

.map-stop.sunday {
  color: var(--cobalt);
  border-color: var(--cobalt);
}

.map-stop:hover,
.map-stop:focus-visible {
  z-index: 4;
  color: var(--paper-light);
  background: var(--ink);
  border-color: var(--ink);
  transform: translate(-50%, -50%) scale(1.15);
}

.map-stop.is-saved {
  color: var(--ink);
  background: var(--acid);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink), inset 0 0 0 2px var(--paper-light);
}

.map-stop.is-saved::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--tomato);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 15px;
  padding: 11px 13px;
  border-top: 1px dashed rgba(24, 32, 28, 0.45);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 2px;
}

.legend-line.saturday {
  background: var(--tomato);
}

.legend-line.sunday {
  background: var(--cobalt);
}

.legend-punch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
}

.pocket-strip {
  padding: 12px 13px 14px;
  border-top: 2px solid var(--ink);
  background:
    linear-gradient(90deg, transparent 0 14px, rgba(24, 32, 28, 0.09) 14px 15px, transparent 15px) 0 0 / 15px 100%;
}

.pocket-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
}

.pocket-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pocket-head span {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.pocket-list {
  display: grid;
  gap: 5px;
}

.pocket-empty {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.pocket-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 7px;
  border: 1px solid rgba(24, 32, 28, 0.35);
  background: var(--paper-light);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.25;
  text-align: left;
  text-transform: uppercase;
  transition: background-color 120ms ease;
}

.pocket-item:hover {
  background: var(--acid);
}

.pocket-item-num {
  display: grid;
  place-items: center;
  flex: 0 0 21px;
  width: 21px;
  height: 21px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  font-size: 8px;
  font-weight: 700;
}

.map-aside {
  margin: 22px 0 0;
  padding-left: 13px;
  border-left: 3px solid var(--tomato);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  text-transform: uppercase;
}

/* ---------- Timetable ---------- */

.timetable {
  min-width: 0;
}

.timetable-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--ink);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--tomato);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.timetable-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(38px, 4.2vw, 62px);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.result-count {
  margin: 0 0 5px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.day-group {
  margin-top: 28px;
}

.day-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 0;
  border-bottom: 2px solid var(--ink);
}

.day-badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--paper-light);
  background: var(--line);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.day-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.day-date {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.day-count {
  padding: 3px 7px;
  border: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  white-space: nowrap;
}

.day-items {
  position: relative;
}

.day-items::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 2px;
  background: var(--line);
  opacity: 0.75;
}

.stop {
  position: relative;
  padding: 18px 10px 20px 60px;
  border-bottom: 1px dashed rgba(24, 32, 28, 0.42);
  transition: background-color 140ms ease;
}

.stop:hover {
  background: rgba(217, 244, 91, 0.17);
}

.stop-marker {
  position: absolute;
  top: 17px;
  left: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--line);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.stop.is-saved .stop-marker {
  color: var(--ink);
  background: var(--acid);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink), inset 0 0 0 2px var(--paper-light);
}

.stop-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stop-time {
  font-weight: 700;
}

.stop-category {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stop-category::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.stop-saved-badge {
  display: none;
  padding: 2px 5px;
  border: 1px solid var(--ink);
  background: var(--acid);
  font-size: 8px;
}

.stop.is-saved .stop-saved-badge {
  display: inline-block;
}

.stop-price {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--ink);
  background: var(--paper-light);
  font-weight: 700;
  white-space: nowrap;
}

.stop-title {
  margin: 7px 0 5px;
  font-size: clamp(21px, 2vw, 30px);
  font-weight: 600;
  line-height: 1.03;
  letter-spacing: -0.03em;
}

.open-item {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: text-decoration-color 140ms ease, color 140ms ease;
}

.open-item::after {
  content: " ↗";
  display: inline-block;
  color: var(--tomato);
  font-family: var(--mono);
  font-size: 0.5em;
  font-weight: 400;
  vertical-align: 0.45em;
  letter-spacing: 0;
  opacity: 0.5;
  transform: translateX(0);
  transition: opacity 140ms ease, transform 140ms ease;
}

.stop:hover .open-item,
.open-item:hover,
.open-item:focus-visible {
  color: var(--tomato);
  text-decoration-color: var(--tomato);
}

.stop:hover .open-item::after,
.open-item:hover::after,
.open-item:focus-visible::after {
  opacity: 1;
  transform: translateX(0);
}

.stop-summary {
  max-width: 69ch;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.stop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 13px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.stop-meta span + span::before {
  content: "/";
  margin-right: 13px;
  color: rgba(24, 32, 28, 0.4);
}

/* ---------- Empty state ---------- */

.empty-state {
  margin-top: 30px;
  padding: clamp(28px, 5vw, 64px) 24px;
  border: 2px dashed var(--ink);
  background:
    repeating-linear-gradient(-45deg, rgba(24, 32, 28, 0.035) 0 8px, transparent 8px 16px);
  text-align: center;
}

.empty-mark {
  margin: 0;
  color: var(--tomato);
  font-family: var(--display);
  font-size: clamp(64px, 10vw, 110px);
  line-height: 0.8;
}

.empty-state h2 {
  margin: 8px 0 8px;
  font-family: var(--display);
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
}

.empty-state p {
  max-width: 48ch;
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: 15px;
}

.clear-button {
  min-height: 46px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  background: var(--acid);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--ink);
}

.clear-button:hover {
  background: var(--tomato);
  color: var(--paper-light);
}

/* ---------- Footer ---------- */

.site-footer {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 20px clamp(18px, 3.4vw, 48px) 30px;
  border-top: 2px solid var(--ink);
  background: var(--paper-deep);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0;
}

.footer-aside {
  color: var(--tomato);
  text-align: right;
}

/* ---------- Detail dialog ---------- */

.detail-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.detail-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-dialog::backdrop {
  background: rgba(24, 32, 28, 0.72);
  backdrop-filter: blur(2px);
}

.detail-card {
  position: relative;
  width: min(790px, calc(100vw - 64px));
  max-height: min(90dvh, 960px);
  margin: 0;
  overflow: auto;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 12px 12px 0 var(--tomato);
  animation: detail-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.detail-close {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  min-height: 42px;
  padding: 9px 18px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper-light);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  transition: background-color 140ms ease;
}

.detail-close span {
  color: var(--acid);
  font-size: 14px;
}

.detail-close:hover {
  background: var(--tomato);
  color: #fff;
}

.detail-close:hover span {
  color: #fff;
}

.detail-grid {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
}

.detail-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 10px;
  border-right: 1px dashed rgba(24, 32, 28, 0.5);
  background: var(--paper-deep);
}

.detail-stop-number {
  font-family: var(--display);
  font-size: 46px;
  font-weight: 600;
  line-height: 0.9;
}

.detail-rail-line {
  flex: 1;
  width: 5px;
  min-height: 60px;
  background: var(--line, var(--tomato));
}

.detail-rail-text {
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.detail-content {
  padding: clamp(24px, 4vw, 46px) clamp(22px, 4.5vw, 52px) 42px;
}

.detail-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-category {
  padding: 4px 8px;
  border: 1px solid var(--ink);
  background: var(--acid);
  font-weight: 700;
}

.detail-line-name {
  color: var(--line, var(--tomato));
  font-weight: 700;
}

.detail-title {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(40px, 5.6vw, 72px);
  font-weight: 500;
  line-height: 0.93;
  letter-spacing: -0.015em;
}

.detail-summary {
  max-width: 55ch;
  margin: 0 0 26px;
  font-size: clamp(16px, 1.6vw, 19px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 30px;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}

.fact {
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 10px 11px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: rgba(255, 250, 240, 0.5);
}

.fact-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.fact-value {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.section-label {
  margin: 0 0 8px;
  color: var(--tomato);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.detail-body-wrap {
  margin-bottom: 28px;
}

.detail-body {
  max-width: 62ch;
  font-size: 16px;
  line-height: 1.62;
}

.detail-body p {
  margin: 0 0 14px;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.detail-body p:first-child::first-letter {
  float: left;
  margin: 4px 8px 0 0;
  color: var(--tomato);
  font-family: var(--display);
  font-size: 3.2em;
  font-weight: 600;
  line-height: 0.72;
}

.detail-access {
  max-width: 62ch;
  margin-bottom: 30px;
  padding: 13px 15px;
  border: 1px solid var(--ink);
  background: rgba(217, 244, 91, 0.42);
}

.detail-access p:last-child {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.save-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 76px;
  padding: 14px 20px;
  overflow: hidden;
  border: 2px dashed var(--ink);
  background: var(--paper-light);
  text-align: left;
  transition: background-color 150ms ease, transform 150ms ease;
}

.save-button:hover {
  background: var(--acid);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

.save-button[aria-pressed="true"] {
  border-style: solid;
  background: var(--acid);
}

.save-icon {
  display: grid;
  place-items: center;
  flex: 0 0 39px;
  width: 39px;
  height: 39px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--tomato);
  font-size: 22px;
  line-height: 1;
}

.save-button[aria-pressed="true"] .save-icon {
  color: var(--paper-light);
  background: var(--tomato);
}

.save-copy {
  display: grid;
  gap: 2px;
}

.save-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.save-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.save-button[aria-pressed="true"] .save-sub {
  color: var(--ink);
}

.save-ticket-edge {
  position: absolute;
  top: 50%;
  right: -8px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  transform: translateY(-50%);
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .title-row {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .layout {
    grid-template-columns: minmax(290px, 350px) minmax(0, 1fr);
    gap: 32px;
  }

  .masthead-note {
    gap: 12px;
  }

  .roundel {
    width: 112px;
    height: 112px;
    padding: 12px;
  }

  .roundel-mid {
    font-size: 38px;
  }
}

@media (max-width: 900px) {
  .page-frame {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .title-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .wordmark-one {
    font-size: clamp(76px, 17vw, 150px);
  }

  .wordmark-two {
    font-size: clamp(88px, 19vw, 168px);
  }

  .masthead-note {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .masthead-deck {
    max-width: 38ch;
  }

  .roundel {
    flex: 0 0 auto;
    width: 104px;
    height: 104px;
  }

  .control-bar {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr) auto;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .surprise-button {
    grid-column: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 34px;
    padding-bottom: 60px;
  }

  .map-panel {
    position: static;
  }

  .map-card {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
    align-items: stretch;
  }

  .map-card-head {
    grid-column: 1 / -1;
  }

  .map-stage {
    grid-row: 2 / span 2;
    align-self: start;
    margin: 10px;
  }

  .map-legend {
    align-content: start;
    padding-top: 16px;
    border-top: 0;
    border-left: 1px dashed rgba(24, 32, 28, 0.45);
  }

  .pocket-strip {
    align-self: start;
    min-height: 100%;
    border-top: 1px dashed rgba(24, 32, 28, 0.45);
    border-left: 2px solid var(--ink);
  }

  .map-aside {
    max-width: 70ch;
  }

  .site-footer {
    grid-template-columns: 1fr 1fr;
  }

  .footer-aside {
    grid-column: 1 / -1;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .masthead {
    padding-top: 16px;
  }

  .masthead-top {
    display: grid;
    gap: 4px;
  }

  .edition {
    white-space: normal;
  }

  .title-row {
    padding-top: 18px;
    padding-bottom: 22px;
  }

  .wordmark-one {
    font-size: clamp(68px, 21vw, 100px);
  }

  .wordmark-two {
    font-size: clamp(82px, 23.5vw, 112px);
  }

  .masthead-note {
    align-items: flex-start;
  }

  .masthead-deck {
    max-width: 25ch;
    font-size: 16px;
  }

  .roundel {
    display: none;
  }

  .ticker {
    margin-left: -18px;
    margin-right: -18px;
  }

  .control-bar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 12px 16px 15px;
  }

  .search-field,
  .surprise-button {
    grid-column: 1 / -1;
  }

  .saved-toggle,
  .surprise-button {
    padding: 0 10px;
    font-size: 9px;
  }

  .saved-toggle {
    min-width: 0;
  }

  .saved-toggle-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .layout {
    padding: 24px 16px 48px;
  }

  .map-card {
    display: block;
    box-shadow: 5px 5px 0 var(--ink);
  }

  .map-stage {
    margin: 9px 9px 0;
  }

  .map-legend {
    border-left: 0;
    border-top: 1px dashed rgba(24, 32, 28, 0.45);
  }

  .pocket-strip {
    min-height: 0;
    border-left: 0;
    border-top: 2px solid var(--ink);
  }

  .map-aside {
    margin-top: 16px;
  }

  .timetable-head {
    gap: 10px;
  }

  .timetable-head h2 {
    font-size: 39px;
  }

  .day-head {
    gap: 8px;
  }

  .day-head h3 {
    font-size: 22px;
  }

  .day-date {
    font-size: 8px;
  }

  .day-count {
    font-size: 8px;
  }

  .stop {
    padding: 16px 4px 18px 49px;
  }

  .day-items::before {
    left: 16px;
  }

  .stop-marker {
    top: 15px;
    width: 34px;
    height: 34px;
    font-size: 9px;
  }

  .stop-top {
    font-size: 9px;
    gap: 6px 8px;
  }

  .stop-price {
    order: 5;
    margin-left: 0;
  }

  .stop-title {
    font-size: 23px;
  }

  .stop-summary {
    font-size: 13px;
  }

  .stop-meta {
    gap: 3px 8px;
    font-size: 9px;
  }

  .stop-meta span + span::before {
    margin-right: 8px;
  }

  .site-footer {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px 16px 24px;
  }

  .footer-aside {
    grid-column: auto;
  }

  .detail-dialog {
    width: 100vw;
    height: 100dvh;
  }

  .detail-card {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

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

  .detail-rail {
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 18px;
    border-right: 0;
    border-bottom: 1px dashed rgba(24, 32, 28, 0.5);
  }

  .detail-stop-number {
    font-size: 31px;
  }

  .detail-rail-line {
    flex: 0 0 auto;
    width: 38px;
    min-height: 4px;
    height: 4px;
  }

  .detail-rail-text {
    font-size: 7px;
    line-height: 1.2;
    text-align: left;
  }

  .detail-content {
    padding: 20px 18px 30px;
  }

  .detail-title {
    font-size: clamp(37px, 11.5vw, 52px);
  }

  .detail-summary {
    margin-bottom: 20px;
    font-size: 16px;
  }

  .detail-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 24px;
  }

  .fact {
    min-height: 62px;
  }

  .detail-body {
    font-size: 15px;
  }

  .save-button {
    min-height: 72px;
    padding: 12px 14px;
  }
}

@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;
  }

  .ticker-track {
    animation: none;
  }
}
