/* ==========================================================================
   Hat Yai Transit — map page (map.html)
   Malaysia Transit's map shell (footer bar, popovers, help modal, Route Viewer,
   stop sheet, planner drawer) re-skinned from purple to Lake Teal + Temple Gold.
   Tokens come from /css/hyt.css.
   ========================================================================== */

html, body { height: 100%; overflow: hidden; background: #dfe9ea; }
#map { position: fixed; inset: 0; }
.leaflet-container { font-family: var(--font); }

/* ── Footer bar (bottom-left) ─────────────────────────────────────────── */
.footer {
  position: fixed; bottom: 10px; left: 10px; z-index: 1000;
  background: rgba(255, 255, 255, 0.96); padding: 10px 14px; border-radius: 10px;
  font-size: 12px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); border: 1px solid rgba(0, 0, 0, 0.08);
  max-width: min(560px, calc(100vw - 20px));
}
.footer-brand { display: inline-block; margin-right: 10px; font-weight: 800; font-size: 15px; color: var(--brand-dark); vertical-align: middle; }
.footer-brand .hy { color: var(--accent-dark); }
.map-help-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-right: 8px;
  border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; vertical-align: middle; transition: background 0.2s;
}
.map-help-btn:hover { background: var(--brand-dark); }
.footer-actions { display: inline-flex; align-items: center; gap: 6px; position: relative; vertical-align: middle; }
.menu-switch {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; border-radius: 6px;
  background: var(--brand); color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 3px rgba(11, 110, 121, 0.35); line-height: 1.2;
}
.menu-switch:hover { background: var(--brand-dark); }
.menu-switch:focus-visible, .lang-switch:focus-visible, .map-help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-switch-caret, .lang-switch-caret { font-size: 9px; transition: transform 0.2s; }
.menu-switch[aria-expanded="true"] .menu-switch-caret, .lang-switch[aria-expanded="true"] .lang-switch-caret { transform: rotate(180deg); }
.menu-icon { font-size: 14px; line-height: 1; }
.lang-switch {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 6px;
  background: var(--brand-tint); color: var(--brand-dark); border: 1px solid rgba(11, 110, 121, 0.2);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.2;
}
.lang-switch:hover { background: #cde9e7; }
.menu-popover, .lang-popover {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 1100;
  display: flex; flex-direction: column; gap: 2px; padding: 4px; min-width: 190px;
  background: #fff; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); border: 1px solid rgba(0, 0, 0, 0.08);
}
.lang-popover { left: auto; right: 0; min-width: 150px; }
.menu-popover[hidden], .lang-popover[hidden] { display: none; }
.footer .menu-option, .lang-option {
  display: block; padding: 8px 12px; border: 0; border-radius: 4px; background: transparent; text-align: left;
  font: inherit; font-size: 13px; color: #1f2937; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.footer .menu-option:hover, .lang-option:hover { background: var(--brand-tint); color: var(--brand-dark); }
.lang-option.active { background: var(--brand); color: #fff; font-weight: 700; }
.menu-divider { height: 1px; margin: 4px 2px; background: rgba(0, 0, 0, 0.08); }
.footer .credits { display: block; margin-top: 5px; color: #4a5568; }
.footer .credits a { color: var(--brand-dark); font-weight: 700; }

@media (max-width: 768px) {
  .footer { left: 5px; bottom: 5px; padding: 8px 10px; font-size: 10px; max-width: calc(100vw - 10px); text-align: center; }
  .footer-brand { display: block; margin: 0 0 5px; font-size: 13px; }
  .footer-actions { display: flex; justify-content: center; margin-bottom: 4px; }
  .menu-switch, .lang-switch { font-size: 12px; padding: 6px 10px; }
  .footer .credits { font-size: 10px; }
  .menu-popover { left: 0; }
  .map-help-btn {
    position: fixed; left: 10px; top: calc(env(safe-area-inset-top, 0px) + 128px); z-index: 1002;
    width: 34px; height: 34px; margin: 0; font-size: 17px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  }
}

/* ── Leaflet extras ───────────────────────────────────────────────────── */
.hyt-locate-btn { width: 34px; height: 34px; background: #fff; border: 0; cursor: pointer; font-size: 16px; line-height: 34px; padding: 0; }
.hyt-locate-btn:hover { background: var(--brand-tint); }
.endpoint-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 800; font-size: 11px; }
.endpoint-label::before { display: none; }

/* ── Banners (time zone, load error) ──────────────────────────────────── */
.map-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1500;
  width: min(520px, calc(100vw - 120px)); display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px 8px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.4;
  background: var(--warn-bg); color: var(--warn-text); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.map-banner[hidden] { display: none; }
.map-banner.error { background: var(--danger-bg); color: var(--danger); }
.map-banner span { flex: 1; }
.map-banner button { border: 0; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; color: inherit; }
@media (max-width: 768px) { .map-banner { top: 70px; left: 54px; right: 10px; width: auto; transform: none; } }

/* ── Unofficial notice (one time) ─────────────────────────────────────── */
.unofficial-notice {
  position: fixed; z-index: 1600; left: 50%; bottom: 120px; transform: translateX(-50%);
  width: min(460px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 14px;
  background: #fff; border-top: 5px solid var(--accent); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
  font-size: 13px; line-height: 1.5; color: #374151;
}
.unofficial-notice[hidden] { display: none; }
.unofficial-notice h2 { margin: 0 0 6px; font-size: 15px; color: var(--brand-dark); }
.unofficial-notice p { margin: 0 0 10px; }
.unofficial-notice-actions { display: flex; gap: 8px; justify-content: flex-end; }
.unofficial-notice-actions button { border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; }
#notice-ok { background: var(--brand); color: #fff; }
#notice-sources { background: var(--brand-tint); color: var(--brand-dark); }

/* ── Route Viewer (top-right) ─────────────────────────────────────────── */
#route-control-panel {
  position: fixed; top: 14px; right: 14px; z-index: 1000; width: 300px; max-height: calc(100vh - 140px);
  display: flex; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
#route-control-panel.minimized { width: auto; min-width: 170px; }
#route-control-panel.minimized .collapsible-content { display: none; }
.control-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px;
  font-weight: 800; font-size: 14px; color: #fff; cursor: pointer; user-select: none;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); border: 0; width: 100%; text-align: left; font-family: inherit;
}
.control-header .toggle-icon { transition: transform 0.3s; }
#route-control-panel.minimized .toggle-icon { transform: rotate(-90deg); }
.control-body { padding: 12px 14px 14px; overflow-y: auto; overscroll-behavior: contain; }
.control-body select { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; margin-bottom: 8px; background: #fff; }
#clear-route-btn { width: 100%; padding: 7px; border: 1px solid #fda4af; border-radius: 8px; background: #fff1f2; color: #be123c; font-weight: 700; cursor: pointer; }
#clear-route-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.rv-title { margin: 12px 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.rv-dirs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rv-dir { border: 1px solid var(--brand-2); background: #fff; color: var(--brand-dark); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.rv-dir.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.rv-facts { font-size: 12.5px; display: grid; gap: 3px; margin-bottom: 8px; }
.rv-stops summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--brand-dark); padding: 4px 0; }
.rv-stops ol { margin: 4px 0 8px; padding-left: 22px; font-size: 12.5px; }
.rv-stops li { margin: 2px 0; }
.rv-stop { border: 0; background: transparent; text-align: left; padding: 3px 4px; cursor: pointer; width: 100%; border-radius: 6px; font: inherit; }
.rv-stop-list { list-style: none; padding: 0 !important; }
.rv-stop-list .rv-stop { display: flex; align-items: flex-start; gap: 8px; }
.rv-stop-list .seq-pin { margin-top: 1px; }
.rv-stop-names { display: flex; flex-direction: column; min-width: 0; }
.rv-stop-extra { font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.rv-stop:hover { background: var(--brand-tint); }
.rv-timetable-btn { width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--accent); background: var(--accent-tint); color: #5b4300; border-radius: 8px; font-weight: 700; cursor: pointer; }
.rv-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 5px; margin-top: 6px; }
.rv-time { padding: 5px 6px; border: 1px solid transparent; border-radius: 6px; background: #f8fafc; font-size: 12.5px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rv-time.past { opacity: 0.45; }
.rv-time.next { background: #dcfce7; border-color: #86efac; }
.rv-tts { text-decoration: none; }
@media (max-width: 768px) {
  #route-control-panel { top: 10px; right: 10px; width: min(300px, calc(100vw - 70px)); max-height: 55vh; }
}

/* ── Stop sheet ───────────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(13, 59, 64, 0.35); }
.modal.show { display: flex; align-items: flex-start; justify-content: center; }
.modal-content {
  position: relative; width: min(500px, 92vw); max-height: 82vh; margin-top: 6vh; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 14px; padding: 18px 18px 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.close-btn { position: absolute; top: 8px; right: 10px; border: 0; background: transparent; font-size: 28px; line-height: 1; color: #94a3b8; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; }
.close-btn:hover { color: #1f2937; background: #f1f5f9; }
.modal-content h2 { margin: 0 34px 0 0; font-size: 19px; color: var(--brand-dark); }
.stop-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }
.stop-code { color: #94a3b8; font-size: 11px; margin-top: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.stop-info-section { margin: 14px 0 0; }
.stop-info-section h3 { font-size: 14px; margin: 0 0 8px; color: #334155; }
.stop-planner-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.stop-planner-actions button { border: 1px solid var(--brand-2); background: var(--brand-tint); color: var(--brand-dark); border-radius: 9px; padding: 9px; cursor: pointer; font-weight: 700; font: inherit; font-weight: 700; }
.stop-planner-actions button:hover { background: #cde9e7; }
.stop-approx { margin-top: 8px; padding: 6px 9px; border-radius: 7px; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; }
.stop-approx[hidden] { display: none; }
.dep-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 10px; padding: 9px 11px; margin: 6px 0; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; font-size: 13px; }
.dep-row.past { opacity: 0.5; }
.dep-row.dep-hours { background: #f8fafc; }
.dep-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dep-dir { color: #334155; font-weight: 600; }
.dep-time { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.dep-countdown { color: var(--brand-dark); font-weight: 700; }
.dep-mytime { color: var(--text-secondary); font-size: 12px; }
.stop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stop-action { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: #334155; font-size: 12.5px; font-weight: 600; text-decoration: none; }
.stop-action:hover { background: #f1f5f9; color: #1f2937; }
.stop-action.action-live { background: #dcfce7; border-color: #86efac; color: #166534; }
.stop-action.action-ticket { background: var(--accent-tint); border-color: #f3d18a; color: #5b4300; }
/* Padang Besar (Malaysia): "Carrying on into Malaysia?" card, in Malaysia Transit purple, with the hibiscus (Malaysia's national flower) like the dialog ribbon */
.stop-beyond { padding: 12px; border-radius: 10px; background: #f5f3ff; border: 1px solid #ddd6fe; }
.stop-beyond-head { display: flex; align-items: center; gap: 8px; }
.stop-beyond-head h3 { margin: 0; color: #4c1d95; }
.stop-beyond-flag { font-size: 18px; line-height: 1; }
.stop-beyond p { margin: 6px 0 10px; font-size: 13px; line-height: 1.5; color: #3f3f46; }
.stop-beyond-btn { padding: 8px 14px; border: 0; border-radius: 8px; background: #5b4bd8; color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.stop-beyond-btn:hover { background: #4636c0; }
/* One row: KTM Komuter (main) on the left, Malaysia Transit (smaller) on the right */
.stop-beyond-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stop-beyond-ktm { padding: 9px 16px; font-size: 14px; white-space: nowrap; }
.stop-beyond-ktm[hidden] { display: none; }
.stop-beyond-mt { padding: 6px 12px; border: 1px solid #c4b5fd; background: #fff; color: #4c1d95; font-size: 12.5px; white-space: nowrap; }
.stop-beyond-mt:hover { background: #ede9fe; }
.stop-beyond-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.beyond-area-note { margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; background: #ede9fe; color: #4c1d95; font-size: 12.5px; font-weight: 600; }
.stop-ticket { margin-top: 6px; padding: 7px 9px; border-radius: 7px; background: var(--brand-tint); color: var(--brand-dark); font-size: 12.5px; line-height: 1.45; }
.stop-ticket-action { margin-top: 7px; }
.stop-route-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin: 4px 0; padding: 7px 8px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; cursor: pointer; text-align: left; font: inherit; font-size: 13px; }
.stop-route-btn:hover { border-color: var(--brand-2); background: var(--brand-tint); }
.stop-mytime-note[hidden] { display: none; }
@media (max-width: 768px) {
  .modal.show { align-items: flex-end; }
  .modal-content { width: 100%; max-height: 78vh; margin: 0; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Help modal ───────────────────────────────────────────────────────── */
.help-modal { display: none; position: fixed; inset: 0; z-index: 5000; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); }
.help-modal.show { display: flex; }
.help-modal-content { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.help-modal-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; color: #fff; position: relative; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); }
.help-modal-header h3 { flex: 1; margin: 0; font-size: 16px; }
.help-modal-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, 0.9); font-size: 18px; cursor: pointer; }
.help-modal-close:hover { background: rgba(255, 255, 255, 0.2); }
.help-modal-body { padding: 18px 20px 20px; }
.help-modal-body ul { list-style: none; margin: 0 0 14px; padding: 0; }
.help-modal-body li { padding: 6px 0; font-size: 13.5px; color: #374151; line-height: 1.45; }
.help-legend li { display: flex; align-items: center; gap: 10px; }
.legend-line { display: inline-block; width: 26px; height: 5px; border-radius: 3px; flex-shrink: 0; }
.legend-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; }
.help-modal-pagination { display: flex; justify-content: center; gap: 6px; margin: 4px 0 14px; }
.help-page-dot { width: 7px; height: 7px; border-radius: 50%; background: #d0d0d0; }
.help-page-dot.active { background: var(--brand); }
.help-modal-nav { display: flex; gap: 8px; }
.help-modal-back { padding: 11px 16px; border: 1px solid #b2dfdb; border-radius: 8px; background: transparent; color: var(--brand); cursor: pointer; font: inherit; }
.help-modal-ok { flex: 1; padding: 11px 16px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.help-modal-ok:hover { background: var(--brand-dark); }

/* Sources modal (uses .hyt-modal from hyt.css) */
.sources-service { margin: 16px 0 8px; font-size: 14px; color: var(--brand-dark); }
.sources-service:first-child { margin-top: 4px; }
.sources-modal-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ── Planner drawer (from Malaysia Transit, re-skinned) ───────────────── */
.transit-tool-drawer {
  position: fixed; z-index: 5200; top: 14px; right: 14px; bottom: 76px;
  width: min(430px, calc(100vw - 28px)); display: flex; flex-direction: column;
  background: #fff; border-radius: 16px; box-shadow: 0 12px 44px rgba(15, 23, 42, 0.28);
  transform: translateX(calc(100% + 30px)); transition: transform 0.22s ease; overflow: hidden; visibility: hidden;
}
.transit-tool-drawer.open { transform: translateX(0); visibility: visible; }
.transit-tool-header { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; background: linear-gradient(135deg, var(--brand-tint) 0%, #ffffff 72%); border-bottom: 1px solid #c8e6e3; }
.transit-tool-header h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; color: var(--brand-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transit-tool-header-actions { display: flex; align-items: center; gap: 4px; }
.transit-tool-minimize, .transit-tool-expand, .transit-tool-close { min-width: 36px; min-height: 36px; border: 0; border-radius: 8px; background: transparent; line-height: 1; cursor: pointer; font-size: 22px; }
.transit-tool-minimize, .transit-tool-expand { color: var(--brand); }
.transit-tool-close { color: #be123c; }
.transit-tool-minimize:hover, .transit-tool-expand:hover { background: var(--brand-tint); }
.transit-tool-close:hover { background: #ffe4e6; }
.transit-tool-expand { display: none; font-size: 17px; font-weight: 750; }
.transit-tool-body { padding: 0 16px 20px; overflow-y: auto; overscroll-behavior: contain; }
.transit-tool-drawer.minimized { top: auto; bottom: 76px; height: 56px; width: min(360px, calc(100vw - 28px)); border-radius: 14px; }
.transit-tool-drawer.minimized .transit-tool-body { display: none; }
.transit-tool-drawer.minimized .transit-tool-header { height: 56px; padding: 8px 10px 8px 14px; }
.transit-tool-drawer.minimized .transit-tool-header h2 { font-size: 15px; }
.transit-tool-drawer.minimized .transit-tool-minimize { display: none; }
.transit-tool-drawer.minimized .transit-tool-expand { display: inline-flex; align-items: center; justify-content: center; }
.transit-field { position: relative; margin: 12px 0 9px; }
.transit-field-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 12px; font-weight: 700; color: #475569; }
/* 16px stops iOS Safari zooming into focused inputs */
.transit-field input { width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 9px; font-size: 16px; font-family: inherit; transition: border-color 0.16s, box-shadow 0.16s; }
.transit-field input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(18, 147, 154, 0.18); }
.transit-field-tools { display: flex; gap: 5px; margin-top: 5px; }
.transit-field-tools button, .transit-swap, .transit-secondary-btn { border: 1px solid #cbd5e1; background: #fff; border-radius: 7px; padding: 6px 8px; color: #334155; cursor: pointer; font-size: 12px; font-weight: 650; font-family: inherit; }
.transit-field-tools button:active, .transit-swap:active, .transit-secondary-btn:active { transform: translateY(1px); }
#map-origin-current, #map-destination-current { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
#map-origin-pick, #map-destination-pick { background: var(--accent-tint); border-color: #f3d18a; color: #7a5200; }
.transit-swap { width: 100%; margin: 0 0 4px; background: var(--brand-tint); border-color: #8fd0cc; color: var(--brand-dark); }
.transit-place-suggestions { position: absolute; z-index: 3; left: 0; right: 0; top: calc(100% - 26px); max-height: 240px; overflow-y: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18); }
.transit-place-suggestions[hidden] { display: none; }
.transit-place-suggestion { display: block; width: 100%; padding: 9px 10px; border: 0; border-bottom: 1px solid #eef2f7; background: #fff; text-align: left; cursor: pointer; font-family: inherit; }
.transit-place-suggestion:hover, .transit-place-suggestion:focus { background: var(--brand-tint); }
.transit-place-suggestion strong, .transit-place-suggestion small { display: block; }
.transit-place-suggestion small { margin-top: 2px; color: #64748b; }
.transit-options { border: 0; padding: 0; margin: 10px 0; }
.transit-options legend { margin-bottom: 5px; font-size: 12px; font-weight: 700; color: #475569; }
.transit-mode-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.transit-mode-grid label { display: flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; background: #f1f5f9; color: #334155; font-size: 12px; cursor: pointer; }
#map-mode-bus { accent-color: var(--brand-2); }
#map-mode-rail { accent-color: #C8102E; }
#map-show-rm { accent-color: var(--accent-dark); }
.transit-plan-btn { width: 100%; padding: 11px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; font-weight: 800; font-family: inherit; font-size: 14px; cursor: pointer; box-shadow: 0 5px 14px rgba(11, 110, 121, 0.25); }
.transit-plan-btn:hover { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.transit-plan-btn:disabled { opacity: 0.55; cursor: wait; }
.fares-glance { margin-top: 12px; border: 1px solid #f3d18a; border-radius: 10px; background: #fffdf6; }
.fares-glance summary { padding: 9px 12px; cursor: pointer; font-weight: 800; font-size: 13px; color: #5b4300; }
.fares-glance-body { padding: 0 12px 12px; font-size: 12.5px; }
.fares-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.fares-table td { padding: 6px 4px; border-bottom: 1px solid #f1e6c8; vertical-align: top; }
.fares-table td:nth-child(2) { white-space: nowrap; }
.transit-results-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.transit-results-toolbar[hidden] { display: none; }
.transit-results-toolbar label { font-size: 12px; font-weight: 700; color: #475569; }
.transit-results-toolbar select { flex: 1; min-width: 0; padding: 7px; border: 1px solid #cbd5e1; border-radius: 7px; font-family: inherit; }
#map-share-journey { background: var(--brand-tint); border-color: #8fd0cc; color: var(--brand-dark); }
#map-close-itinerary { background: var(--accent-tint); border-color: #f3d18a; color: #7a5200; }
#map-clear-journey { background: #fff1f2; border-color: #fda4af; color: #be123c; }
.transit-results { margin-top: 10px; }
.transit-result-card { margin-bottom: 9px; padding: 11px; border: 1px solid #d9e1ec; border-radius: 11px; background: #fff; cursor: pointer; }
.transit-result-card.active { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(18, 147, 154, 0.18); }
.transit-result-summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.transit-result-routes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; font-weight: 700; }
.transit-result-time { font-weight: 800; color: #1f2937; font-size: 15px; }
.transit-result-times { color: #334155; font-size: 12.5px; margin-top: 2px; }
.transit-result-meta { margin-top: 3px; color: #64748b; font-size: 12px; }
.transit-result-fare { font-weight: 800; color: #047857; white-space: nowrap; }
.transit-leg { display: grid; grid-template-columns: 26px 1fr; gap: 7px; padding: 9px 0; border-top: 1px solid #eef2f7; font-size: 12.5px; }
.transit-leg:first-of-type { margin-top: 8px; }
.transit-leg-title { font-weight: 700; color: #334155; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.transit-leg-detail, .transit-leg-fare, .transit-leg-time { margin-top: 3px; color: #64748b; }
.transit-leg-detail small { color: #94a3b8; }
.transit-leg-time strong { color: #1f2937; }
.transit-countdown { color: var(--brand-dark); font-weight: 700; }
.transit-leg details { margin-top: 5px; }
.transit-leg details summary { width: fit-content; padding: 4px 7px; border-radius: 6px; background: #f1f5f9; color: #475569; cursor: pointer; font-weight: 650; }
.transit-leg details[open] summary { background: var(--brand-tint); color: var(--brand-dark); }
.transit-leg details small { color: #94a3b8; }
.transit-warning { margin-top: 5px; padding: 6px 8px; border-radius: 7px; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; line-height: 1.4; }
.transit-warning.high { background: var(--danger-bg); color: var(--danger); }
.transit-warning.low { background: #f1f5f9; color: #475569; }
.transit-ticket { margin-top: 5px; padding: 6px 8px; border-radius: 7px; background: var(--brand-tint); color: var(--brand-dark); font-size: 12px; line-height: 1.4; }
.transit-leg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.leg-action { display: inline-flex; align-items: center; gap: 3px; padding: 5px 8px; border: 1px solid #b8c4d4; border-radius: 6px; background: #f8fafc; color: #334155; font-size: 11.5px; font-weight: 650; text-decoration: none; cursor: pointer; font-family: inherit; }
.leg-action:hover { background: #eef2f7; }
.leg-action.action-live { background: #dcfce7; border-color: #86efac; color: #166534; }
.leg-action.action-ticket { background: var(--accent-tint); border-color: #f3d18a; color: #5b4300; }
.journey-transfer-leaflet-icon { background: transparent; border: 0; }
.journey-transfer-marker { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; border-radius: 50%; background: var(--accent); color: #3b2500; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.42); font-size: 12px; font-weight: 850; line-height: 1; }
.transit-message { padding: 10px; border-radius: 8px; background: #f1f5f9; color: #475569; font-size: 13px; line-height: 1.45; }
.transit-message.error { background: #fff1f2; color: #9f1239; }
.transit-message.info { margin-bottom: 9px; background: var(--accent-tint); color: #5b4300; }
.transit-message-links { margin-top: 6px; }
.transit-message-links a { font-weight: 700; }
.map-pick-bar { position: fixed; z-index: 6000; top: 12px; left: 50%; transform: translateX(-50%); width: min(530px, calc(100vw - 24px)); display: none; padding: 10px 12px; border-radius: 12px; background: #0d3b40; color: #fff; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3); }
.map-pick-bar.open { display: flex; align-items: center; gap: 8px; }
.map-pick-label { flex: 1; font-size: 12px; line-height: 1.35; }
.map-pick-bar button { border: 0; border-radius: 7px; padding: 7px 10px; cursor: pointer; font-weight: 700; font-family: inherit; }
.map-pick-confirm { background: var(--accent); color: #2b1d00; }
.map-pick-confirm:disabled { opacity: 0.5; }
.map-pick-cancel { background: #fff; color: #334155; }

/* Small centred dialogs (departures info, explorer navigation, schedule, handoff, going beyond) */
.map-info-dialog { position: fixed; inset: 0; z-index: 6100; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(13, 59, 64, 0.5); }
.map-info-dialog.show { display: flex; }
.map-info-dialog-card { max-width: 400px; width: 100%; background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 18px 55px rgba(0, 0, 0, 0.3); }
.map-info-dialog-card h2 { margin: 0 0 8px; font-size: 18px; color: var(--brand-dark); }
.map-info-dialog-card p { color: #475569; line-height: 1.5; font-size: 14px; }
.map-info-dialog-card > button, .map-info-dialog-actions button, .map-info-dialog-card .dialog-btn {
  display: block; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer; text-align: center; text-decoration: none;
}
.map-info-dialog-card > button:hover, .map-info-dialog-actions button:hover, .map-info-dialog-card .dialog-btn:hover { background: var(--brand-dark); color: #fff; }
.map-info-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.map-info-dialog-card .map-info-dialog-cancel, .map-info-dialog-card .dialog-btn.secondary { background: #e2e8f0; color: #334155; }
.map-info-dialog-card .map-info-dialog-cancel:hover, .map-info-dialog-card .dialog-btn.secondary:hover { background: #cbd5e1; color: #1f2937; }
.map-info-dialog-card .dialog-btn.gold { background: var(--accent); color: #2b1d00; }
.handoff-actions { display: grid; gap: 8px; margin-top: 14px; }
.handoff-actions [hidden] { display: none; }
.journey-schedule-card { width: min(430px, 100%); max-height: min(720px, 88vh); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.journey-schedule-header { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid #e2e8f0; }
.journey-schedule-heading { flex: 1; min-width: 0; }
.journey-schedule-heading h2 { margin: 0; overflow-wrap: anywhere; }
.journey-schedule-meta { margin-top: 4px; color: #64748b; font-size: 12px; }
.map-info-dialog-card .journey-schedule-close { width: 36px; min-width: 36px; height: 36px; padding: 0; background: var(--brand-tint); color: #334155; font-size: 22px; }
.journey-schedule-timezone { margin: 10px 18px 0; padding: 7px 9px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; }
.journey-schedule-timezone[hidden] { display: none; }
.journey-schedule-body { padding: 12px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
.journey-schedule-empty { padding: 18px 8px; color: #64748b; text-align: center; }
.journey-schedule-rows { display: grid; gap: 6px; }
.journey-schedule-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 11px; border: 1px solid transparent; border-radius: 8px; background: #f8fafc; color: #475569; font-size: 13px; }
.journey-schedule-primary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.journey-schedule-row strong { color: #1f2937; }
.journey-schedule-row.next { background: #dcfce7; border-color: #86efac; }

@media (max-width: 768px) {
  .transit-tool-drawer { top: auto; right: 0; bottom: 0; width: 100%; max-height: 86vh; border-radius: 18px 18px 0 0; transform: translateY(calc(100% + 20px)); }
  .transit-tool-drawer.open { transform: translateY(0); }
  .transit-tool-header { padding-top: 14px; }
  .transit-tool-header::before { content: ''; position: absolute; top: 6px; left: 50%; width: 44px; height: 4px; border-radius: 4px; transform: translateX(-50%); background: #cbd5e1; }
  .transit-tool-drawer.open.minimized {
    left: 50%; right: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + var(--planner-dock-bottom, 120px));
    width: min(330px, calc(100vw - 24px)); height: 54px; max-height: 54px; transform: translateX(-50%); border-radius: 14px;
  }
  .transit-tool-drawer.minimized .transit-tool-header { height: 54px; }
  .transit-tool-drawer.minimized .transit-tool-header::before { display: none; }
}

/* ── "Going beyond Hat Yai?" popup. The hero, route ribbon and app cards are shared with the homepage (hyt.css) ── */
.map-info-dialog-card.beyond-card { max-width: 780px; max-height: min(92vh, 900px); padding: 0; overflow-y: auto; }
/* The dialog text styles above (.map-info-dialog-card h2 / p) would otherwise beat the shared hero and card styles in hyt.css */
.beyond-card .beyond-hero h2 { margin: 2px 0 6px; font-size: 22px; color: #fff; }
.beyond-card .beyond-hero p { max-width: 560px; margin: 0 auto; color: rgba(255, 255, 255, 0.88); font-size: 14px; line-height: 1.5; }
.beyond-card .beyond-app-body p { margin: 0 0 10px; color: #475569; font-size: 13.5px; line-height: 1.5; }
.beyond-x {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 8px;
  background: transparent; color: rgba(255, 255, 255, 0.85); font-size: 24px; line-height: 1; cursor: pointer;
}
.beyond-x:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }
.beyond-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.beyond-app-body .dialog-btn { margin-top: auto; }
.map-info-dialog-card .beyond-app.mt .dialog-btn { background: #5b4bd8; }
.map-info-dialog-card .beyond-app.mt .dialog-btn:hover { background: #4636c0; }
.map-info-dialog-card .beyond-app.sg .dialog-btn { background: #1e3a8a; color: #fff; }
.map-info-dialog-card .beyond-app.sg .dialog-btn:hover { background: #172e6e; }
.beyond-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 16px; }
.beyond-foot p { margin: 0; color: #64748b; }
.map-info-dialog-card .beyond-foot .dialog-btn { width: auto; min-width: 120px; }
@media (max-width: 680px) {
  .beyond-card .beyond-apps { padding: 14px; }
  .beyond-card .beyond-hero { padding: 20px 18px 16px; }
  .beyond-foot { flex-direction: column; align-items: stretch; text-align: center; }
  .map-info-dialog-card .beyond-foot .dialog-btn { width: 100%; }
}
