:root {
  --pink: #d81b78;
  --pink-dark: #9f1058;
  --pink-soft: #ffe4f1;
  --teal: #007f82;
  --teal-bright: #0aa3a5;
  --teal-soft: #d9f4f1;
  --ink: #25202a;
  --muted: #6f6672;
  --paper: #fffafc;
  --white: #ffffff;
  --line: #eadde5;
  --shadow: 0 14px 40px rgba(85, 22, 58, .10);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 3%, rgba(10,163,165,.16), transparent 23rem),
    linear-gradient(180deg, #fff 0, var(--paper) 27rem, #fff 100%);
  font-family: "Chiron GoRound TC", "Noto Sans TC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.feedback-bar {
  display: flex;
  justify-content: center;
  padding: 10px 20px;
  color: white;
  background: var(--pink);
}
.feedback-bar a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}
.feedback-bar a:hover, .feedback-bar a:focus-visible { text-decoration: underline; }

.masthead {
  max-width: 1180px;
  min-height: 330px;
  margin: 0 auto;
  padding: 64px 32px 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 30px;
}
.teacher-profile {
  width: 190px;
  margin: 0;
  padding: 9px 9px 11px;
  background: var(--white);
  border: 3px solid var(--pink);
  border-radius: 26px;
  box-shadow: 11px 11px 0 var(--teal);
  transform: rotate(-2deg);
}
.teacher-profile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  object-fit: cover;
  object-position: 50% 28%;
  border-radius: 17px;
}
.teacher-profile figcaption {
  margin-top: 9px;
  color: var(--pink-dark);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}
.eyebrow, .kicker { margin: 0 0 6px; color: var(--pink-dark); font-weight: 700; letter-spacing: .12em; }
.title-row { display: flex; align-items: center; gap: 22px; }
h1 { margin: 0; font-size: clamp(3rem, 8vw, 6.4rem); line-height: .98; letter-spacing: -.06em; color: var(--pink); }
.guide-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 10px 17px;
  color: white;
  background: var(--teal);
  border: 2px solid var(--teal);
  border-radius: 999px;
  box-shadow: 0 7px 18px rgba(0,127,130,.18);
  font-weight: 700;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.guide-button:hover, .guide-button:focus-visible {
  color: var(--teal);
  background: white;
  outline: none;
  transform: translateY(-2px);
}
.lede { margin: 18px 0 0; color: var(--muted); font-size: clamp(1.05rem, 2.2vw, 1.35rem); }
.route-badge { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 0 7px; min-width: 150px; padding: 19px 22px; color: white; background: var(--teal); border-radius: 16px; box-shadow: var(--shadow); transform: rotate(2deg); }
.route-badge strong { font-size: 2rem; line-height: 1; }
.route-badge span { font-weight: 700; }
.route-badge i { grid-column: 1 / -1; height: 1px; margin: 10px 0; background: rgba(255,255,255,.45); }

main { max-width: 1180px; margin: 0 auto; padding: 0 32px 80px; }
.controls { position: sticky; z-index: 20; top: 14px; padding: 18px; background: rgba(255,255,255,.9); border: 1px solid rgba(216,27,120,.12); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.search-box { position: relative; display: block; }
.search-icon { position: absolute; left: 18px; top: 50%; transform: translateY(-54%); color: var(--teal); font-size: 1.8rem; }
.search-box input { width: 100%; min-height: 56px; padding: 12px 54px; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 15px; font-size: 1rem; outline: none; transition: .2s ease; }
.search-box input:focus { border-color: var(--teal-bright); box-shadow: 0 0 0 4px var(--teal-soft); }
#clearSearch { position: absolute; right: 12px; top: 50%; width: 36px; height: 36px; transform: translateY(-50%); color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 1.5rem; }
#clearSearch:hover { background: var(--pink-soft); color: var(--pink); }
.filter-row { display: flex; gap: 8px; margin-top: 14px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: thin; }
.filter-chip { flex: 0 0 auto; padding: 8px 13px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; }
.filter-chip:hover, .filter-chip:focus-visible { color: var(--pink-dark); border-color: var(--pink); }
.filter-chip.active { color: #fff; background: var(--pink); border-color: var(--pink); }
.result-status { min-height: 1.6em; margin: 8px 4px -7px; color: var(--muted); font-size: .9rem; }

.route-overview { padding: 72px 0 56px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.section-heading h2, .transfer-card h2 { margin: 0; font-size: clamp(1.7rem, 3.6vw, 2.6rem); line-height: 1.2; }
.metro-map { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 22px 8px; padding: 24px 12px; }
.metro-map::before { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--pink), #e84c94 44%, var(--teal-bright)); transform: translateY(-50%); }
.map-stop { position: relative; z-index: 1; min-width: 0; padding: 0; background: transparent; border: 0; text-align: center; }
.map-stop:nth-child(n+7) { grid-row: 2; }
.map-stop:nth-child(7) { grid-column: 6; }
.map-stop:nth-child(8) { grid-column: 5; }
.map-stop:nth-child(9) { grid-column: 4; }
.map-stop:nth-child(10) { grid-column: 3; }
.map-stop:nth-child(11) { grid-column: 2; }
.map-stop:nth-child(-n+6) .map-label { margin-bottom: 11px; }
.map-stop:nth-child(n+7) .map-label { margin-top: 11px; }
.map-stop:nth-child(n+7) { display: flex; flex-direction: column-reverse; align-items: center; }
.map-node { display: block; width: 25px; height: 25px; margin: 0 auto; background: #fff; border: 7px solid var(--pink); border-radius: 50%; box-shadow: 0 0 0 3px #fff; transition: transform .2s ease; }
.map-stop:nth-child(n+7) .map-node { border-color: var(--teal); }
.map-stop:hover .map-node, .map-stop:focus-visible .map-node { transform: scale(1.3); }
.map-label { display: block; color: var(--ink); font-size: .86rem; font-weight: 700; line-height: 1.25; }

.article-route { position: relative; }
.station-section { display: grid; grid-template-columns: 54px minmax(0, 1fr); }
.station-rail { position: relative; display: flex; justify-content: center; }
.station-rail::before { content: ""; position: absolute; inset: 0 auto; width: 8px; background: var(--pink); }
.station-section:nth-child(n+7) .station-rail::before { background: var(--teal); }
.station-dot { position: sticky; top: 155px; z-index: 2; width: 30px; height: 30px; margin-top: 22px; background: white; border: 8px solid var(--pink); border-radius: 50%; box-shadow: 0 0 0 5px var(--paper); }
.station-section:nth-child(n+7) .station-dot { border-color: var(--teal); }
.station-content { padding: 10px 0 62px 24px; }
.station-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.station-number { margin: 0; color: var(--pink); font-weight: 700; }
.station-section:nth-child(n+7) .station-number { color: var(--teal); }
.station-name { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.25; }
.article-count { margin-left: auto; color: var(--muted); white-space: nowrap; }
.article-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.article-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 82px; padding: 15px 16px; text-decoration: none; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 5px 18px rgba(85,22,58,.045); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.article-card:hover, .article-card:focus-visible { transform: translateY(-3px); border-color: var(--pink); box-shadow: 0 12px 24px rgba(140,19,84,.11); outline: none; }
.article-no { display: grid; place-items: center; min-width: 45px; height: 36px; padding: 0 8px; color: var(--pink-dark); background: var(--pink-soft); border-radius: 10px; font-weight: 700; }
.article-title { font-weight: 600; line-height: 1.45; }
.article-arrow { color: var(--teal); font-size: 1.15rem; }
mark { color: inherit; background: #ffdf62; border-radius: 3px; }
.empty-state { padding: 70px 20px; text-align: center; border: 2px dashed var(--line); border-radius: var(--radius); }
.empty-state strong { display: block; margin-bottom: 8px; font-size: 1.3rem; }

.transfer-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; margin-top: 12px; padding: 30px; color: white; background: var(--teal); border-radius: var(--radius); box-shadow: var(--shadow); }
.transfer-card .kicker { color: #bffcf8; }
.transfer-card p:last-child { max-width: 680px; margin: 10px 0 0; }
.transfer-symbol { display: grid; place-items: center; width: 64px; height: 64px; color: var(--pink); background: white; border-radius: 50%; font-size: 2rem; }
.text-button { padding: 11px 16px; color: white; background: transparent; border: 1px solid rgba(255,255,255,.7); border-radius: 999px; white-space: nowrap; }
.text-button:hover, .text-button:focus-visible { color: var(--teal); background: white; outline: none; }

footer { display: flex; justify-content: center; gap: 20px; max-width: 1180px; margin: 0 auto; padding: 30px 32px 48px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; }
footer p { margin: 0; }

@media (max-width: 800px) {
  .masthead { min-height: auto; padding-top: 38px; grid-template-columns: auto 1fr; gap: 22px; }
  .teacher-profile { width: 138px; padding: 7px 7px 9px; border-radius: 20px; box-shadow: 7px 7px 0 var(--teal); }
  .teacher-profile img { border-radius: 13px; }
  .teacher-profile figcaption { font-size: .75rem; }
  .title-row { align-items: flex-start; flex-direction: column; gap: 14px; }
  .guide-button { padding: 8px 14px; }
  .route-badge { grid-column: 1 / -1; display: flex; justify-content: center; min-width: 0; transform: none; }
  .route-badge i { width: 1px; height: 28px; margin: 0 8px; }
  main { padding-inline: 18px; }
  .controls { top: 8px; padding: 12px; }
  .route-overview { padding: 52px 0 36px; }
  .metro-map { display: flex; gap: 0; padding: 8px 8px 16px; overflow-x: auto; scroll-snap-type: x proximity; }
  .metro-map::before { left: 34px; right: 34px; top: 26px; transform: none; }
  .map-stop, .map-stop:nth-child(n+7) { display: flex; flex-direction: column; flex: 0 0 115px; grid-row: auto; grid-column: auto; align-items: center; scroll-snap-align: center; }
  .map-stop .map-label, .map-stop:nth-child(n+7) .map-label { order: 2; margin: 14px 0 0; }
  .article-grid { grid-template-columns: 1fr; }
  .station-section { grid-template-columns: 38px minmax(0, 1fr); }
  .station-content { padding-left: 13px; }
  .station-rail::before { width: 6px; }
  .station-dot { width: 25px; height: 25px; border-width: 7px; }
  .station-header { align-items: flex-start; flex-wrap: wrap; gap: 3px 10px; }
  .station-number { flex-basis: 100%; }
  .article-count { margin-left: 0; }
  .transfer-card { grid-template-columns: auto 1fr; padding: 24px 20px; }
  .transfer-card .text-button { grid-column: 1 / -1; justify-self: start; }
  footer { flex-direction: column; padding-inline: 20px; }
}

@media (max-width: 480px) {
  .masthead { padding-inline: 20px; }
  .teacher-profile { width: 112px; }
  .teacher-profile figcaption { font-size: .75rem; line-height: 1.35; }
  .eyebrow { font-size: .84rem; }
  .title-row { gap: 11px; }
  .lede { margin-top: 11px; }
  .search-box input { padding-left: 46px; font-size: .94rem; }
  .section-heading { display: block; }
  .article-card { grid-template-columns: auto 1fr; gap: 10px; padding: 13px; }
  .article-arrow { display: none; }
  .transfer-symbol { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
