.station-card {
    min-width: 241px;
    width: 100%;
    max-width: 34rem;
    margin: 0;
    aspect-ratio: 3 / 4;
    position: relative;
    overflow: hidden;
}

.station-card::part(base) {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.station-card-body {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding: 0;
}

.station-card-names {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 0 0.75rem 0;
}

/* MTR Station Background & Tile Grid styles */
.station-card.station-card--has-colors::part(body) {
    background-color: color-mix(in srgb, var(--station-primary-color, #00888A) 70%, white);
    background-image: 
        /* Overhead soft glossy wall reflection */
        radial-gradient(ellipse at 50% 20%, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%),
        /* Vertical enamel depth tint */
        linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 0%, transparent 40%, rgba(0, 37, 76, 0.05) 100%);
}

.station-card.station-card--mosaic::part(body) {
    background-color: color-mix(in srgb, var(--station-primary-color, #00888A) 50%, white);
    background-image: 
        /* Subtle top & left light highlight */
        linear-gradient(to right, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
        /* Subtle bottom & right dark shadow */
        linear-gradient(to left, rgba(0, 37, 76, 0.12) 1px, transparent 1px),
        linear-gradient(to top, rgba(0, 37, 76, 0.12) 1px, transparent 1px),
        /* Very soft tile surface sheen */
        linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 60%, rgba(0, 37, 76, 0.025) 100%);
    background-size: 14px 14px;
}

.station-card.station-card--rainbow::part(body) {
    background: 
        /* Subtle top & left light highlight */
        linear-gradient(to right, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
        /* Subtle bottom & right dark shadow */
        linear-gradient(to left, rgba(0, 37, 76, 0.12) 1px, transparent 1px),
        linear-gradient(to top, rgba(0, 37, 76, 0.12) 1px, transparent 1px),
        /* Very soft tile surface sheen */
        linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 60%, rgba(0, 37, 76, 0.025) 100%),
        /* Rainbow line color stripes */
        linear-gradient(to bottom, 
            color-mix(in srgb, #E2231A 50%, white) 0%,
            color-mix(in srgb, #E2231A 50%, white) 16.66%,
            color-mix(in srgb, #F7943E 50%, white) 16.66%,
            color-mix(in srgb, #F7943E 50%, white) 33.33%,
            color-mix(in srgb, #D8C860 50%, white) 33.33%,
            color-mix(in srgb, #D8C860 50%, white) 50%,
            color-mix(in srgb, #00AB4E 50%, white) 50%,
            color-mix(in srgb, #00AB4E 50%, white) 66.66%,
            color-mix(in srgb, #007DC5 50%, white) 66.66%,
            color-mix(in srgb, #007DC5 50%, white) 83.33%,
            color-mix(in srgb, #7D499D 50%, white) 83.33%,
            color-mix(in srgb, #7D499D 50%, white) 100%
        );
    background-size: 14px 14px, 14px 14px, 14px 14px, 14px 14px, 14px 14px, 100% 100%;
}



.station-card::part(body) {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    position: relative;
    overflow: visible;
}

.station-card::part(footer) {
    border-top: none;
    padding-top: 1.25rem;
    position: relative;
    z-index: 1;
}

.station-card [slot='header'] {
    display: flex;
    justify-content: center;
}

.station-card [slot='footer'] {
    display: flex;
    justify-content: space-between;
}

.station-page-container {
    width: 100%;
    margin: 1rem 0 1rem;
    padding: 0 1rem;
    box-sizing: border-box;
}

.station-page-container .back-link {
    display: inline-block;
    margin-top: 0.75rem;
    opacity: 0.7;
    text-decoration: none;
    color: inherit;
    font-size: 0.9rem;
    transition: opacity 0.15s ease;
}

.station-page-container .back-link:hover {
    opacity: 1;
}

.station-item-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.station-story-card {
    width: 100%;
    background-color: #f9fbfd;
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    border: 1px solid rgba(0, 37, 76, 0.08);
    box-shadow: 0 2px 10px rgba(0, 37, 76, 0.03);
    box-sizing: border-box;
}

.station-story-card .story {
    line-height: 1.8;
    font-size: 1.05rem;
    color: #00254c;
}

.station-story-card .story h2 {
    font-size: 1.25rem;
    font-weight: 650;
    color: #00254c;
    margin: 1.5rem 0 0.6rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid rgba(0, 37, 76, 0.1);
}

.station-story-card .story blockquote {
    margin: 0 0 1.25rem 0;
    padding: 0.85rem 1.15rem;
    background: rgba(0, 136, 138, 0.06);
    border-left: 4px solid #00888A;
    border-radius: 0 8px 8px 0;
    font-size: 1.02rem;
    line-height: 1.65;
}

.station-story-card .story blockquote p {
    margin: 0;
}

.station-story-card .story table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.25rem 0;
    font-size: 0.95rem;
}

.station-story-card .story th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    background-color: rgba(0, 37, 76, 0.05);
    border-bottom: 2px solid rgba(0, 37, 76, 0.12);
    font-weight: 600;
}

.station-story-card .story td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(0, 37, 76, 0.07);
}

.station-story-card .story tr:nth-child(even) {
    background-color: rgba(0, 37, 76, 0.02);
}

.station-story-card .story ul,
.station-story-card .story ol {
    margin: 0.75rem 0 1rem 1.5rem;
    padding: 0;
}

.station-story-card .story li {
    margin-bottom: 0.4rem;
}

.station-story-card .story p:first-child {
    margin-top: 0;
}

.station-story-card .story p:last-child {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .station-item-wrapper {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 1.5rem;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }

    .station-card {
        flex: 0 0 28rem;
        max-width: 32rem;
    }

    .station-story-card {
        flex: 1;
        width: 100%;
        padding: 1.75rem 2.25rem;
    }
}

div.station-circle {
    width: 25px;
    height: 25px;
    background-color: white;
    border: 4px solid #00254c;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 6px rgba(0, 37, 76, 0.25);
    box-sizing: border-box;
}

div.line-drawing {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0;
    margin-bottom: -5px;
    position: relative;
    z-index: 10;
    filter: drop-shadow(0 2px 5px rgba(0, 37, 76, 0.25));
}

div.line-drawing--multi {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0;
    margin-bottom: 0;
    z-index: 10;
    filter: drop-shadow(0 2px 5px rgba(0, 37, 76, 0.25));
}

div.line-tracks {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

div.line-track {
    width: 100%;
    height: 14px;
}

div.station-circle--pill {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25px;
    height: calc(100% + 14px);
    background-color: white;
    border: 4px solid #00254c;
    border-radius: 13px;
    box-shadow: 0 2px 6px rgba(0, 37, 76, 0.25);
    box-sizing: border-box;
    z-index: 2;
}

.zh {
    font-family: "Noto Serif TC", sans-serif;
}

header.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 1rem;
    backdrop-filter: blur(6px);
}

header.site-header .site-title {
    margin: 0;
    line-height: 1.08;
    font-size: clamp(1.6rem, 3.8vw, 2.45rem);
}

header.site-header .site-title-link {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: inherit;
}

header.site-header .site-title-text {
    display: inline;
}

header.site-header .site-title-sep {
    display: inline;
}

header.site-header .site-title-en {
    display: inline;
}

@media (max-width: 600px) {
    header.site-header .site-title-text {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    header.site-header .site-title-sep {
        display: none;
    }
}

header.site-header .site-logo {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 37, 76, 0.15);
}

header.site-header section p {
    margin: 0.6rem 0 0;
}

p.zh-name {
    font-size: 3.2em;
    letter-spacing: 0.1em;
    font-weight: 650;
    font-family: "metrosung", "Noto Serif TC", sans-serif;
    margin: 0.2em auto -0.2em auto;
    text-shadow: 0 1px 3px rgba(0, 37, 76, 0.25);
}

p.en-transliteration {
    font-size: 1.75em;
    font-weight: 650;
    font-family: 'metrosung', Helvetica, sans-serif;
    text-transform: capitalize;
    margin: -0.2em auto 0.6em auto;
    text-shadow: 0 1px 3px rgba(0, 37, 76, 0.25);
}

span.en-name {
    font-size: 1em;
    color: grey;
    margin: auto 0;
}

div.zh-phonetics-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    gap: 0.3em;
    margin: auto 0;
}

span.jyutping {
    font-size: 0.9em;
    color: grey;
}

span.pinyin {
    font-size: 0.9em;
    color: grey;
}

span.card-title {
    color: grey;
    font-size: 0.9em;
}

.line-picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.line-picker-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.line-picker-button {
    white-space: normal;
}

.line-picker-button::part(base) {
    height: auto;
    min-height: 3.8rem;
    padding: 0.6rem 0.95rem;
}

.line-picker-button::part(label) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.15rem;
    text-align: left;
    white-space: normal;
}

.line-picker-button .en-line-name {
    font-size: 0.82em;
    font-weight: 400;
}

.pick-line-drawer .line-picker-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.35rem 0 0.6rem;
}

.pick-line-drawer .line-picker-item wa-badge {
    margin-left: 0.15rem;
}

#pick-line-button {
    margin: 1rem;
}

.line-picker-scroll {
    display: block;
}

.line-picker-scroll .line-picker-list {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 0.45rem 0.5rem 0.75rem;
    margin: 0.5rem 0 0.25rem;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 1.25rem;
    scrollbar-width: thin;
}

.line-picker-scroll .line-picker-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.line-picker-scroll .line-picker-item wa-badge {
    margin-left: 0.2rem;
}

/* Pick-line drawer/button disabled in favor of always-visible horizontal picker. */
/* #pick-line-button,
.pick-line-drawer {
    display: none;
} */

.line-picker-button[data-line="EAL"]::part(base) {
    color: #53B7E8;
    border-color: #53B7E8;
}

.line-picker-button[data-line="AEL"]::part(base) {
    color: #00888A;
    border-color: #00888A;
}

.line-picker-button[data-line="TCL"]::part(base) {
    color: #F7943E;
    border-color: #F7943E;
}

.line-picker-button[data-line="ISL"]::part(base) {
    color: #007DC5;
    border-color: #007DC5;
}

.line-picker-button[data-line="TKL"]::part(base) {
    color: #7D499D;
    border-color: #7D499D;
}

.line-picker-button[data-line="KTL"]::part(base) {
    color: #00AB4E;
    border-color: #00AB4E;
}

.line-picker-button[data-line="SIL"]::part(base) {
    color: #99cf16;
    border-color: #99cf16;
}

.line-picker-button[data-line="TWL"]::part(base) {
    color: #ED1D24;
    border-color: #ED1D24;
}

.line-picker-button[data-line="DRL"]::part(base) {
    color: #F173AC;
    border-color: #F173AC;
}

.line-picker-button[data-line="TML"]::part(base) {
    color: #923011;
    border-color: #923011;
}

/* Active state for line-picker-button tabs */
.line-picker-button.line-tab--active[data-line="EAL"]::part(base) {
    background-color: #53B7E8;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="AEL"]::part(base) {
    background-color: #00888A;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="TCL"]::part(base) {
    background-color: #F7943E;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="ISL"]::part(base) {
    background-color: #007DC5;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="TKL"]::part(base) {
    background-color: #7D499D;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="KTL"]::part(base) {
    background-color: #00AB4E;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="SIL"]::part(base) {
    background-color: #99cf16;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="TWL"]::part(base) {
    background-color: #ED1D24;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="DRL"]::part(base) {
    background-color: #F173AC;
    color: #ffffff;
}

.line-picker-button.line-tab--active[data-line="TML"]::part(base) {
    background-color: #923011;
    color: #ffffff;
}

.line-picker-button.line-tab--active .en-line-name {
    color: rgba(255, 255, 255, 0.9);
}

h3#current-line {
    border-top: 1px solid;
    border-bottom: 1px solid;
    padding-top: 3px;
    padding-bottom: 4px;
}

body {
    font-family: 'Source Sans 3', Helvetica, sans-serif;
    color: #00254c;
    background-color: #fff;
    color-scheme: light;
}

footer {
    font-size: 0.8em;
    text-align: center;
}

header.site-header {
    background-color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 37, 76, 0.2);
}

section#tagline {
    margin: 0 1rem;
    padding-top: 1rem;
}

/* ============================================
   Line Header — station strip navigation
   ============================================ */

.line-header {
    width: 100%;
    margin: 0 0 1rem;
    padding: 0 1rem;
    box-sizing: border-box;
}

.line-header__scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.line-header__title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem 0.25rem;
    margin: 0;
    font-weight: 600;
    color: #00254c;
}

.line-header__title .zh {
    font-size: 1.7rem;
}

.line-header__title-en {
    color: grey;
    font-size: 1.35rem;
}

.line-header__track {
    display: flex;
    align-items: flex-start;
    position: relative;
    min-width: max-content;
    padding: 0.75rem 0 0.25rem;
}

/* The coloured connecting line (drawn behind circles via a pseudo-element) */
.line-header__track::before {
    content: "";
    position: absolute;
    top: calc(0.75rem + 3px);       /* vertically center on the 20px circles for 14px height line */
    left: 10px;                        /* half the circle width */
    right: 10px;
    height: 14px;
    background: var(--line-color, #00888A);
    z-index: 0;
}

.line-header__stop {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
    min-width: 6rem;
    text-decoration: none;
    color: inherit;
    position: relative;
    z-index: 1;
    transition: opacity 0.15s ease;
}

.line-header__stop:hover {
    opacity: 0.7;
}

.line-header__circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #00254c;
    background: #fff;
    box-sizing: border-box;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.line-header__stop--current .line-header__circle {
    background: #FFF9C4;
    border-color: #00254c;
    box-shadow: 0 0 10px #FEF08A, 0 0 4px #FFF9C4;
}

.line-header__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0.4rem;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}

.line-header__label .zh {
    font-size: 0.9rem;
}

.line-header__label-en {
    font-size: 0.9rem;
    color: grey;
    margin-top: 0.15rem;
}

.line-header__stop--current .line-header__label {
    font-weight: 700;
}

@media (max-width: 480px) {
    .line-header__stop {
        min-width: 5rem;
    }
    .line-header__label {
        font-size: 0.7rem;
    }
}

/* ============================================
   Station Page Line Tabs & Panels
   ============================================ */

.line-header-panel--hidden {
    display: none !important;
}

/* ============================================
   Homepage Map Placeholder
   ============================================ */

.map-placeholder-container {
    width: 100%;
    margin: 1.5rem 0 2rem;
    padding: 0 1rem;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .map-placeholder-container {
        margin: 2rem 0 3rem;
        padding: 0 1rem;
    }
}

.map-placeholder-card {
    min-height: 48vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(244, 247, 250, 0.9) 0%, rgba(230, 236, 242, 0.6) 100%);
    border: 2px dashed rgba(0, 37, 76, 0.2);
    border-radius: 16px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #00254c;
    box-sizing: border-box;
}

.map-placeholder-icon {
    color: #00888A;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-placeholder-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: #00254c;
}

.map-placeholder-subtitle {
    font-size: 0.95rem;
    color: #556b82;
    max-width: 28rem;
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
}

.map-placeholder-status wa-badge {
    font-size: 0.85rem;
}

/* ── Tube Map ── */
.tube-map-container {
  max-width: 1450px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.tube-map-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.tube-map-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #00254c);
}

.tube-map-wrapper {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 37, 76, 0.08);
  border: 1px solid rgba(0, 37, 76, 0.12);
  background: #ffffff;
}

#tube-map {
  width: 100%;
  height: 70vh;
  min-height: 500px;
  max-height: 750px;
  background: #fafbfc;
  cursor: grab;
  user-select: none;
}

#tube-map:active {
  cursor: grabbing;
}

.line#Racecourse\ Spur {
  stroke-dasharray: 9 6; /* Dashed pattern: 10px line, 5px space */
}

/* d3-tube-map station labels */
#tube-map svg text {
  fill: #00254c;
}

/* Chinese station name (top line) */
#tube-map svg text tspan:nth-child(1) {
  font-size: 1.5rem !important;
  font-family: 'Noto Serif TC', serif;
  font-weight: 500;
}

/* English transliteration (bottom line) */
#tube-map svg text tspan:nth-child(2) {
  font-size: 1.25rem !important;
  font-weight: 500;
  text-transform: capitalize;
}

/* Clickable station markers & labels */
#tube-map svg .station,
#tube-map svg .interchange,
#tube-map svg .label {
  cursor: pointer;
  transition: opacity 0.2s ease;
}

#tube-map svg path.interchange {
  stroke-width: 0.25rem !important;
}

#tube-map svg .station:hover,
#tube-map svg .interchange:hover {
  opacity: 0.8;
}

/* Floating Map Controls */
.tube-map-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  font-size: 1rem;
  gap: 0.5rem;
  z-index: 10;
}

.map-control-btn {
  width: 48px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0, 37, 76, 0.15);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #00254c;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 37, 76, 0.08);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  background: #ffffff;
  border-color: rgba(0, 37, 76, 0.3);
  transform: translateY(-1px);
}

.map-control-btn:active {
  transform: translateY(0);
}

/* Floating Map Legend */
.tube-map-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 37, 76, 0.12);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 37, 76, 0.08);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #00254c;
}

.legend-color-pill {
  width: 14px;
  height: 6px;
  border-radius: 3px;
  display: inline-block;
}

.river-pill {
  height: 8px;
  border-radius: 4px;
}

.interchange-symbol {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #000;
  background: #fff;
  display: inline-block;
}