/* vendor/leaflet-1.9.4/leaflet.css */
/* required styles */

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
	position: absolute;
	left: 0;
	top: 0;
	}
.leaflet-container {
	overflow: hidden;
	}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
	-webkit-user-select: none;
	   -moz-user-select: none;
	        user-select: none;
	  -webkit-user-drag: none;
	}
/* Prevents IE11 from highlighting tiles in blue */
.leaflet-tile::selection {
	background: transparent;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
	image-rendering: -webkit-optimize-contrast;
	}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
	width: 1600px;
	height: 1600px;
	-webkit-transform-origin: 0 0;
	}
.leaflet-marker-icon,
.leaflet-marker-shadow {
	display: block;
	}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg {
	max-width: none !important;
	max-height: none !important;
	}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
	max-width: none !important;
	max-height: none !important;
	width: auto;
	padding: 0;
	}

.leaflet-container img.leaflet-tile {
	/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
	mix-blend-mode: plus-lighter;
}

.leaflet-container.leaflet-touch-zoom {
	-ms-touch-action: pan-x pan-y;
	touch-action: pan-x pan-y;
	}
.leaflet-container.leaflet-touch-drag {
	-ms-touch-action: pinch-zoom;
	/* Fallback for FF which doesn't support pinch-zoom */
	touch-action: none;
	touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
	-ms-touch-action: none;
	touch-action: none;
}
.leaflet-container {
	-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
	-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
	filter: inherit;
	visibility: hidden;
	}
.leaflet-tile-loaded {
	visibility: inherit;
	}
.leaflet-zoom-box {
	width: 0;
	height: 0;
	-moz-box-sizing: border-box;
	     box-sizing: border-box;
	z-index: 800;
	}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
	-moz-user-select: none;
	}

.leaflet-pane         { z-index: 400; }

.leaflet-tile-pane    { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane  { z-index: 500; }
.leaflet-marker-pane  { z-index: 600; }
.leaflet-tooltip-pane   { z-index: 650; }
.leaflet-popup-pane   { z-index: 700; }

.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg    { z-index: 200; }

.leaflet-vml-shape {
	width: 1px;
	height: 1px;
	}
.lvml {
	behavior: url(#default#VML);
	display: inline-block;
	position: absolute;
	}


/* control positioning */

.leaflet-control {
	position: relative;
	z-index: 800;
	pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
	pointer-events: auto;
	}
.leaflet-top,
.leaflet-bottom {
	position: absolute;
	z-index: 1000;
	pointer-events: none;
	}
.leaflet-top {
	top: 0;
	}
.leaflet-right {
	right: 0;
	}
.leaflet-bottom {
	bottom: 0;
	}
.leaflet-left {
	left: 0;
	}
.leaflet-control {
	float: left;
	clear: both;
	}
.leaflet-right .leaflet-control {
	float: right;
	}
.leaflet-top .leaflet-control {
	margin-top: 10px;
	}
.leaflet-bottom .leaflet-control {
	margin-bottom: 10px;
	}
.leaflet-left .leaflet-control {
	margin-left: 10px;
	}
.leaflet-right .leaflet-control {
	margin-right: 10px;
	}


/* zoom and fade animations */

.leaflet-fade-anim .leaflet-popup {
	opacity: 0;
	-webkit-transition: opacity 0.2s linear;
	   -moz-transition: opacity 0.2s linear;
	        transition: opacity 0.2s linear;
	}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
	opacity: 1;
	}
.leaflet-zoom-animated {
	-webkit-transform-origin: 0 0;
	    -ms-transform-origin: 0 0;
	        transform-origin: 0 0;
	}
svg.leaflet-zoom-animated {
	will-change: transform;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
	-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
	   -moz-transition:    -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
	        transition:         transform 0.25s cubic-bezier(0,0,0.25,1);
	}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
	-webkit-transition: none;
	   -moz-transition: none;
	        transition: none;
	}

.leaflet-zoom-anim .leaflet-zoom-hide {
	visibility: hidden;
	}


/* cursors */

.leaflet-interactive {
	cursor: pointer;
	}
.leaflet-grab {
	cursor: -webkit-grab;
	cursor:    -moz-grab;
	cursor:         grab;
	}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
	cursor: crosshair;
	}
.leaflet-popup-pane,
.leaflet-control {
	cursor: auto;
	}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
	cursor: move;
	cursor: -webkit-grabbing;
	cursor:    -moz-grabbing;
	cursor:         grabbing;
	}

/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
	pointer-events: none;
	}

.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
	pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
	pointer-events: auto;
	}

/* visual tweaks */

.leaflet-container {
	background: #ddd;
	outline-offset: 1px;
	}
.leaflet-container a {
	color: #0078A8;
	}
.leaflet-zoom-box {
	border: 2px dotted #38f;
	background: rgba(255,255,255,0.5);
	}


/* general typography */
.leaflet-container {
	font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-size: 0.75rem;
	line-height: 1.5;
	}


/* general toolbar styles */

.leaflet-bar {
	box-shadow: 0 1px 5px rgba(0,0,0,0.65);
	border-radius: 4px;
	}
.leaflet-bar a {
	background-color: #fff;
	border-bottom: 1px solid #ccc;
	width: 26px;
	height: 26px;
	line-height: 26px;
	display: block;
	text-align: center;
	text-decoration: none;
	color: black;
	}
.leaflet-bar a,
.leaflet-control-layers-toggle {
	background-position: 50% 50%;
	background-repeat: no-repeat;
	display: block;
	}
.leaflet-bar a:hover,
.leaflet-bar a:focus {
	background-color: #f4f4f4;
	}
.leaflet-bar a:first-child {
	border-top-left-radius: 4px;
	border-top-right-radius: 4px;
	}
.leaflet-bar a:last-child {
	border-bottom-left-radius: 4px;
	border-bottom-right-radius: 4px;
	border-bottom: none;
	}
.leaflet-bar a.leaflet-disabled {
	cursor: default;
	background-color: #f4f4f4;
	color: #bbb;
	}

.leaflet-touch .leaflet-bar a {
	width: 30px;
	height: 30px;
	line-height: 30px;
	}
.leaflet-touch .leaflet-bar a:first-child {
	border-top-left-radius: 2px;
	border-top-right-radius: 2px;
	}
.leaflet-touch .leaflet-bar a:last-child {
	border-bottom-left-radius: 2px;
	border-bottom-right-radius: 2px;
	}

/* zoom control */

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
	font: bold 18px 'Lucida Console', Monaco, monospace;
	text-indent: 1px;
	}

.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out  {
	font-size: 22px;
	}


/* layers control */

.leaflet-control-layers {
	box-shadow: 0 1px 5px rgba(0,0,0,0.4);
	background: #fff;
	border-radius: 5px;
	}
.leaflet-control-layers-toggle {
	background-image: url(../vendor/leaflet-1.9.4/images/layers.png);
	width: 36px;
	height: 36px;
	}
.leaflet-retina .leaflet-control-layers-toggle {
	background-image: url(../vendor/leaflet-1.9.4/images/layers-2x.png);
	background-size: 26px 26px;
	}
.leaflet-touch .leaflet-control-layers-toggle {
	width: 44px;
	height: 44px;
	}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
	display: none;
	}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
	display: block;
	position: relative;
	}
.leaflet-control-layers-expanded {
	padding: 6px 10px 6px 6px;
	color: #333;
	background: #fff;
	}
.leaflet-control-layers-scrollbar {
	overflow-y: scroll;
	overflow-x: hidden;
	padding-right: 5px;
	}
.leaflet-control-layers-selector {
	margin-top: 2px;
	position: relative;
	top: 1px;
	}
.leaflet-control-layers label {
	display: block;
	font-size: 13px;
	font-size: 1.08333em;
	}
.leaflet-control-layers-separator {
	height: 0;
	border-top: 1px solid #ddd;
	margin: 5px -10px 5px -6px;
	}

/* Default icon URLs */
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
	background-image: url(../vendor/leaflet-1.9.4/images/marker-icon.png);
	}


/* attribution and scale controls */

.leaflet-container .leaflet-control-attribution {
	background: #fff;
	background: rgba(255, 255, 255, 0.8);
	margin: 0;
	}
.leaflet-control-attribution,
.leaflet-control-scale-line {
	padding: 0 5px;
	color: #333;
	line-height: 1.4;
	}
.leaflet-control-attribution a {
	text-decoration: none;
	}
.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus {
	text-decoration: underline;
	}
.leaflet-attribution-flag {
	display: inline !important;
	vertical-align: baseline !important;
	width: 1em;
	height: 0.6669em;
	}
.leaflet-left .leaflet-control-scale {
	margin-left: 5px;
	}
.leaflet-bottom .leaflet-control-scale {
	margin-bottom: 5px;
	}
.leaflet-control-scale-line {
	border: 2px solid #777;
	border-top: none;
	line-height: 1.1;
	padding: 2px 5px 1px;
	white-space: nowrap;
	-moz-box-sizing: border-box;
	     box-sizing: border-box;
	background: rgba(255, 255, 255, 0.8);
	text-shadow: 1px 1px #fff;
	}
.leaflet-control-scale-line:not(:first-child) {
	border-top: 2px solid #777;
	border-bottom: none;
	margin-top: -2px;
	}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
	border-bottom: 2px solid #777;
	}

.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
	box-shadow: none;
	}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
	border: 2px solid rgba(0,0,0,0.2);
	background-clip: padding-box;
	}


/* popup */

.leaflet-popup {
	position: absolute;
	text-align: center;
	margin-bottom: 20px;
	}
.leaflet-popup-content-wrapper {
	padding: 1px;
	text-align: left;
	border-radius: 12px;
	}
.leaflet-popup-content {
	margin: 13px 24px 13px 20px;
	line-height: 1.3;
	font-size: 13px;
	font-size: 1.08333em;
	min-height: 1px;
	}
.leaflet-popup-content p {
	margin: 17px 0;
	margin: 1.3em 0;
	}
.leaflet-popup-tip-container {
	width: 40px;
	height: 20px;
	position: absolute;
	left: 50%;
	margin-top: -1px;
	margin-left: -20px;
	overflow: hidden;
	pointer-events: none;
	}
.leaflet-popup-tip {
	width: 17px;
	height: 17px;
	padding: 1px;

	margin: -10px auto 0;
	pointer-events: auto;

	-webkit-transform: rotate(45deg);
	   -moz-transform: rotate(45deg);
	    -ms-transform: rotate(45deg);
	        transform: rotate(45deg);
	}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
	background: white;
	color: #333;
	box-shadow: 0 3px 14px rgba(0,0,0,0.4);
	}
.leaflet-container a.leaflet-popup-close-button {
	position: absolute;
	top: 0;
	right: 0;
	border: none;
	text-align: center;
	width: 24px;
	height: 24px;
	font: 16px/24px Tahoma, Verdana, sans-serif;
	color: #757575;
	text-decoration: none;
	background: transparent;
	}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
	color: #585858;
	}
.leaflet-popup-scrolled {
	overflow: auto;
	}

.leaflet-oldie .leaflet-popup-content-wrapper {
	-ms-zoom: 1;
	}
.leaflet-oldie .leaflet-popup-tip {
	width: 24px;
	margin: 0 auto;

	-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
	filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
	}

.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
	border: 1px solid #999;
	}


/* div icon */

.leaflet-div-icon {
	background: #fff;
	border: 1px solid #666;
	}


/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
	position: absolute;
	padding: 6px;
	background-color: #fff;
	border: 1px solid #fff;
	border-radius: 3px;
	color: #222;
	white-space: nowrap;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;
	box-shadow: 0 1px 3px rgba(0,0,0,0.4);
	}
.leaflet-tooltip.leaflet-interactive {
	cursor: pointer;
	pointer-events: auto;
	}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
	position: absolute;
	pointer-events: none;
	border: 6px solid transparent;
	background: transparent;
	content: "";
	}

/* Directions */

.leaflet-tooltip-bottom {
	margin-top: 6px;
}
.leaflet-tooltip-top {
	margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
	left: 50%;
	margin-left: -6px;
	}
.leaflet-tooltip-top:before {
	bottom: 0;
	margin-bottom: -12px;
	border-top-color: #fff;
	}
.leaflet-tooltip-bottom:before {
	top: 0;
	margin-top: -12px;
	margin-left: -6px;
	border-bottom-color: #fff;
	}
.leaflet-tooltip-left {
	margin-left: -6px;
}
.leaflet-tooltip-right {
	margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
	top: 50%;
	margin-top: -6px;
	}
.leaflet-tooltip-left:before {
	right: 0;
	margin-right: -12px;
	border-left-color: #fff;
	}
.leaflet-tooltip-right:before {
	left: 0;
	margin-left: -12px;
	border-right-color: #fff;
	}

/* Printing */

@media print {
	/* Prevent printers from removing background-images of controls. */
	.leaflet-control {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
		}
	}

/* css/app.css */
/* เรดาร์รถไฟ — สไตล์หลัก (ธีมเรดาร์มืดเป็นค่าเริ่มต้น + ธีมสว่าง) */

/* ---------- tokens ---------- */
:root {
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", menlo, monospace;
  --radius: 16px;
  --panel-w: 384px;
  --detail-w: 408px;
  --peek: 244px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --bg: #0b1220;
  --panel: rgb(13 20 34 / 90%);
  --panel-solid: #0f1727;
  --card: rgb(148 163 184 / 7%);
  --card-hover: rgb(148 163 184 / 13%);
  --line: rgb(148 163 184 / 17%);
  --text: #e8eef7;
  --muted: #8fa0b6;
  --accent: #38bdf8;
  --accent-ink: #04202f;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --idle: #94a3b8;
  --ok-t: #4ade80;
  --warn-t: #fbbf24;
  --bad-t: #f87171;
  --rail: #36557a;
  --halo: #0b1220;
  --cargo: #a47551;
  --cargo-t: #d9ad83;
  --shadow: 0 12px 32px rgb(0 0 0 / 38%), 0 2px 8px rgb(0 0 0 / 24%);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #e9eef5;
  --panel: rgb(255 255 255 / 92%);
  --panel-solid: #fff;
  --card: rgb(15 23 42 / 4%);
  --card-hover: rgb(15 23 42 / 8%);
  --line: rgb(15 23 42 / 11%);
  --text: #0f172a;
  --muted: #5b6b82;

  /* #0369a1: ≥ 4.5:1 ทั้งเป็นตัวอักษรบนพื้นขาว/การ์ด และพื้นหลังของตัวอักษรขาว (#0284c7 ได้แค่ 4.1) */
  --accent: #0369a1;
  --accent-ink: #fff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --idle: #64748b;
  --ok-t: #15803d;
  --warn-t: #b45309;
  --bad-t: #b91c1c;
  --rail: #6f86a6;
  --halo: #fff;
  --cargo: #9a6a44;
  --cargo-t: #7c4f24;
  --shadow: 0 12px 30px rgb(15 23 42 / 14%), 0 2px 6px rgb(15 23 42 / 8%);

  color-scheme: light;
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

/* ไอคอนใช้ --i แต่ SVG ของ Leaflet ต้องใช้ขนาด renderer ไม่ใช่ 20×20 px */
svg:where(:not(.leaflet-pane > svg)) {
  flex: none;
  width: var(--i, 20px);
  height: var(--i, 20px);
}

button {
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.pad {
  padding: 16px;
}

.noscript {
  position: fixed;
  inset: 40% 16px auto;
  z-index: 2000;
  padding: 16px;
  text-align: center;
  background: var(--panel-solid);
  border-radius: 12px;
}

/* สีตามระดับความตรงเวลา: --c = สีหลัก, --ct = สีตัวอักษร */
.lv0 {
  --c: var(--ok);
  --ct: var(--ok-t);
}

.lv1 {
  --c: var(--warn);
  --ct: var(--warn-t);
}

.lv2 {
  --c: var(--bad);
  --ct: var(--bad-t);
}

.idle {
  --c: var(--idle);
  --ct: var(--muted);
}

.cargo {
  --c: var(--cargo);
  --ct: var(--cargo-t);
}

/* ซ่อนจากสายตา แต่โปรแกรมอ่านหน้าจอยังอ่านได้ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
  border: 0;
}

/* ลิงก์ข้ามไปช่องค้นหา (คีย์บอร์ด): ซ่อนจนกว่าจะได้โฟกัส — ไม่ต้องกด Tab ผ่านหมุดขบวนทุกหมุดบนแผนที่ */
.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 1400;
  padding: 10px 18px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -160%);
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

/* ---------- แผนที่ ---------- */
.map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}

.leaflet-container {
  font-family: var(--font);
  background: var(--bg);
}

/* ซูมทศนิยมทำให้เห็นรอยต่อ tile → ขยาย tile ครึ่งพิกเซลให้ซ้อนกัน
   และปิด plus-lighter ของ Leaflet (ส่วนที่ซ้อนจะบวกสีกลายเป็นเส้นสว่าง) */
.leaflet-container img.leaflet-tile {
  width: 256.5px !important;
  height: 256.5px !important;
  mix-blend-mode: normal;
}

/* แผนที่พื้นสีเทา → โทนน้ำเงินเรดาร์ */
:root[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(1.25) contrast(0.92) sepia(0.45) hue-rotate(178deg) saturate(1.9);
}

.leaflet-control-attribution {
  max-width: min(660px, 60vw);
  padding: 2px 8px !important;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted) !important;
  background: color-mix(in srgb, var(--panel-solid) 80%, transparent) !important;
  border-radius: 8px 0 0;
}

.leaflet-control-attribution a {
  color: var(--muted);
}

.leaflet-tooltip {
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.leaflet-tooltip-top::before {
  border-top-color: var(--panel-solid);
}

.st-tip b {
  display: block;
  font-weight: 600;
}

.st-tip small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.tm-tip small {
  color: var(--muted);
}

.tm-tip .lv0,
.tm-tip .lv1,
.tm-tip .lv2 {
  font-weight: 600;
  color: var(--ct);
}

.tm-tip .tip-stale {
  font-weight: 600;
  color: var(--muted);
}

/* หมุดขบวนรถ — ขนาดตามซูม: .zs จุดเล็ก, .zm กลาง, .zl เต็ม (ขบวนที่เลือกเต็มเสมอ) */
.tm-icon {
  outline: none;
}

.tx .tm-icon {
  transition: transform 1s linear;
}

.tm {
  --c: var(--ok);
  --s: 26px;

  position: absolute;
  top: calc(var(--s) / -2);
  left: calc(var(--s) / -2);
  width: var(--s);
  height: var(--s);
  transition: opacity 0.25s;
}

.tm.lv1 {
  --c: var(--warn);
}

.tm.lv2 {
  --c: var(--bad);
}

.tm.is-idle {
  --c: var(--idle);
}

.tm.is-cargo {
  --c: var(--cargo);
}

/* ตำแหน่งโดยประมาณ: วงประรอบหมุด (is-ahead = ≈ วิ่งต่อเลยสถานีถัดไป ยังไม่มีรายงาน) */
.tm.is-rough::after, .tm.is-ahead::after {
  position: absolute;
  inset: -5px;
  content: "";
  border: 1.5px dashed color-mix(in srgb, var(--c) 70%, #fff);
  border-radius: 9px;
  pointer-events: none;
}

.zs .tm.is-rough::after, .zs .tm.is-ahead::after {
  inset: -3px;
  border-radius: 5px;
}

.zm .tm {
  --s: 20px;
}

.zs .tm {
  --s: 16px;
}

.zs .tm.is-sel,
.zm .tm.is-sel {
  --s: 26px;
}

.tm-puck {
  --i: 14px;

  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--c);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 32%, transparent), 0 0 14px color-mix(in srgb, var(--c) 70%, transparent), 0 2px 6px rgb(0 0 0 / 45%);
  transition: transform 0.25s var(--ease);
}

.zm .tm-puck {
  --i: 11px;
}

.zs .tm-puck {
  --i: 0;

  border-width: 1.5px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent), 0 1px 3px rgb(0 0 0 / 55%);
}

.tm.is-cargo .tm-puck {
  background: linear-gradient(160deg, color-mix(in srgb, var(--cargo) 80%, #fff), var(--cargo));
  border-radius: 7px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cargo) 30%, transparent), 0 2px 6px rgb(0 0 0 / 45%);
}

.tm-icon:focus-visible .tm-puck {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.tm.is-stop .tm-puck {
  color: var(--c);
  background: #fff;
  border: 3px solid var(--c);
}

.tm.is-sel .tm-puck {
  --i: 14px;

  border-width: 2px;
  transform: scale(1.3);
}

/* ขาดการรายงาน: เทา โปร่ง เส้นประ ไม่มีลูกศร (ไม่รู้ว่าอยู่ไหน/ไปทางไหนแล้ว) */
.tm.is-stale {
  --c: var(--idle);
}

.tm.is-stale .tm-puck {
  color: var(--idle);
  background: color-mix(in srgb, var(--panel-solid) 72%, transparent);
  border: 2px dashed var(--idle);
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
}

.zs .tm.is-stop .tm-puck {
  border-width: 3px;
}

.zs .tm.is-cargo .tm-puck {
  border-radius: 3px;
}

.tm-arrow {
  position: absolute;
  z-index: 3;
  inset: -13px;
  pointer-events: none;
  transform: rotate(var(--h, 0deg));
}

/* หมุดที่เลือกขยาย 1.3 เท่า → ลูกศรถอยออกตาม ไม่จมใต้หมุด */
.tm.is-sel .tm-arrow {
  inset: -17px;
}

.tm-heading-svg {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 18px;
  height: 15px;
  overflow: visible;
  transform: translateX(-50%);
  filter: drop-shadow(0 0 1px #0f172a) drop-shadow(0 1px 1px rgb(0 0 0 / 35%));
}

.tm-heading-shape {
  fill: var(--c);
  stroke: #fff;
  stroke-width: 2.5px;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

.tm.planned-heading .tm-heading-shape {
  fill: #fff;
  stroke: var(--c);
  stroke-width: 2.5px;
  paint-order: normal;
}

.tm:not(.has-heading) .tm-arrow, .tm.is-stale.is-rough::after {
  display: none;
}

.zs .tm:not(.is-sel) .tm-arrow {
  inset: -10px;
}

.zs .tm:not(.is-sel) .tm-heading-svg {
  top: -4px;
  width: 15px;
  height: 13px;
}

.tm-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 3px);
  padding: 3px 6px;
  font: 600 11.5px/1 var(--mono);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  background: rgb(8 13 24 / 86%);
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 35%);
  transform: translateY(-50%);
}

.tm.heading-east .tm-label {
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
}

.tm.is-sel .tm-label {
  left: calc(100% + 8px);
  font-size: 13px;
  color: #04202f;
  background: #fff;
}

.zm .tm:not(.is-sel, .is-fav) .tm-label,
.zs .tm:not(.is-sel) .tm-label {
  display: none;
}

.tm-star {
  display: none;
  margin-left: 3px;
  font-size: 10px;
  color: #fcd34d;
}

.tm.is-fav .tm-star {
  display: inline;
}

.tm.is-sel::before {
  position: absolute;
  inset: -10px;
  content: "";
  border: 2px solid var(--c);
  border-radius: 50%;
  animation: halo 1.6s ease-out infinite;
}

.has-sel .tm:not(.is-sel) {
  opacity: 0.5;
}

/* กลุ่มหมุดที่ทับกัน (map.js regroup): ฟองตัวเลข + วงแหวนสัดส่วนตรงเวลา/ช้า/สินค้า · หมุดในกลุ่มซ่อนไว้ */
.tm-icon.is-grp,
.tg-icon.is-off {
  display: none;
}

.tg-icon {
  outline: none;
}

.tx .tg-icon {
  transition: transform 1s linear;
}

.tg {
  --s: 30px;

  position: absolute;
  top: calc(var(--s) / -2);
  left: calc(var(--s) / -2);
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  cursor: pointer;
  background: var(--ring, var(--idle));
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgb(255 255 255 / 85%), 0 2px 8px rgb(0 0 0 / 45%);
  transition: transform 0.2s var(--ease), opacity 0.25s;
}

.tg::before {
  position: absolute;
  inset: 4px;
  content: "";
  background: var(--panel-solid);
  border-radius: 50%;
}

/* ขนาดฟอง (--s) ตั้งจาก map.js ตามจำนวนขบวนและระดับซูม */
.tg-n {
  position: relative;
  font: 700 13px/1 var(--mono);
  color: var(--text);
}

.zs .tg-n {
  font-size: 11.5px;
}

.zs .tg::before {
  inset: 3px;
}

.tg.l .tg-n {
  font-size: 14px;
}

.has-sel .tg {
  opacity: 0.55;
}

.tg-icon:hover .tg {
  transform: scale(1.12);
}

.tg-icon:focus-visible .tg {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}


/* จอสัมผัส: พื้นที่แตะรอบฟอง ≥ 44 px (วงล่องหน ภาพเท่าเดิม) — ฟองเล็ก (--s 22 px) ขยายมากกว่าฟองใหญ่
   ฟองที่อยู่ชิดกัน วงล่องหนซ้อนกันได้ ตัวบนสุดได้การแตะ (ไม่ดันฟองให้ห่าง) */
@media (pointer: coarse) {
  .tg::after {
    position: absolute;
    inset: min(-8px, calc((44px - var(--s)) / -2));
    content: "";
    border-radius: 50%;
  }
}

/* รายชื่อขบวนในกลุ่ม (ซูมแยกไม่ได้แล้ว / จอดสถานีเดียวกัน) */
.tg-pop {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 750;
  display: flex;
  flex-direction: column;
  width: 280px;
  max-height: min(360px, 55vh);
  overflow: hidden;
  font: 14px/1.4 var(--font);
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.tg-pop-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 6px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}

.tg-pop-list {
  padding: 4px;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.tg-pop-row {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 6px 8px;
  text-align: left;
  border-radius: 10px;
}

.tg-pop-row:hover {
  background: var(--card-hover);
}

.tg-pop-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tg-pop-main b,
.tg-pop-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tg-pop-main b {
  font-weight: 600;
}

.tg-pop-main small {
  font-size: 12px;
  color: var(--muted);
}

/* ป้ายชื่อสถานีบนแผนที่ */
.st-label-icon {
  pointer-events: none;
}

.st-label {
  position: absolute;
  top: -9px;
  left: 7px;
  font: 500 11.5px/18px var(--font);
  color: var(--muted);
  white-space: nowrap;
  text-shadow: 0 0 2px var(--halo), 0 0 3px var(--halo), 0 0 5px var(--halo);
}

.st-label.t1 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.st-hl {
  position: absolute;
  top: -17px;
  left: -17px;
  width: 34px;
  height: 34px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent), 0 0 18px var(--accent);
  animation: ring 1.8s ease-out infinite;
}

.me-dot {
  position: absolute;
  top: -9px;
  left: -9px;
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgb(59 130 246 / 55%);
  animation: me-pulse 2s ease-out infinite;
}

/* ---------- ส่วนประกอบทั่วไป ---------- */
.icon-btn {
  --i: 20px;

  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
  border-radius: 12px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--card-hover);
}

.icon-btn.sm {
  --i: 16px;

  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.pill {
  flex: none;
  max-width: 96px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ct, var(--muted));
  text-align: center;
  background: color-mix(in srgb, var(--c, var(--idle)) 16%, transparent);
  border-radius: 10px;
}

.pill.none {
  --c: var(--idle);
  --ct: var(--muted);
}

.pill.stale-pill {
  max-width: 112px;
  border: 1px dashed color-mix(in srgb, var(--idle) 60%, transparent);
}

.pill.cargo-pill {
  --c: var(--cargo);
  --ct: var(--cargo-t);
  --i: 13px;

  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.badge {
  --bs: 21px;

  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 52px;
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
  border-radius: 12px;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%), 0 1px 3px rgb(0 0 0 / 25%);
}

.badge.long {
  --bs: 17px;
}

.badge.xl {
  --bs: 13px;
}

.badge.sm {
  --bs: 15px;

  width: 46px;
  height: 34px;
  border-radius: 9px;
}

.badge.ghost {
  color: var(--muted);
  background: var(--card-hover);
  box-shadow: none;
}

.badge b {
  font: 600 var(--bs)/1 var(--mono);
}

.badge small {
  max-width: 56px;
  overflow: hidden;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-star {
  --i: 17px;

  position: absolute;
  top: -6px;
  right: -6px;
  color: #fcd34d;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 55%));
}

.empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-ico {
  --i: 32px;

  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 6px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 50%;
}

.empty b {
  font-size: 16px;
  color: var(--text);
}

.empty p {
  max-width: 290px;
  margin: 0;
  font-size: 13.5px;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  background: var(--card);
  border-radius: 10px;
}

.hint {
  margin: 6px 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- แผงหลัก ---------- */
.panel {
  position: fixed;
  top: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: var(--panel-w);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}

.panel-grip,
.grip-down {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 12px 12px 16px;
}

.brand-logo {
  --i: 22px;

  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 46px;
  overflow: hidden;
  color: var(--accent);
  background:
    radial-gradient(circle at center, transparent 0 33%, color-mix(in srgb, var(--accent) 32%, transparent) 34% 36%, transparent 37% 63%, color-mix(in srgb, var(--accent) 32%, transparent) 64% 66%, transparent 67%),
    color-mix(in srgb, var(--accent) 12%, var(--panel-solid));
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 28%, transparent);
}

.brand-logo::before {
  position: absolute;
  inset: 0;
  content: "";
  background: conic-gradient(from 0deg, transparent 70%, color-mix(in srgb, var(--accent) 70%, transparent));
  border-radius: 50%;
  animation: sweep 3.2s linear infinite;
}

.brand-logo > svg {
  position: relative;
}

.brand-text {
  flex: 1;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
}

/* ปุ่มสลับภาษา TH/EN — ตัวที่ใช้อยู่ไฮไลต์ตาม <html lang> */
.lang-btn {
  display: inline-flex;
  flex: none;
  gap: 1px;
  align-items: center;
  padding: 2px;
  font: 600 11.5px/1 var(--mono);
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s;
}

.lang-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.lang-btn span {
  padding: 7px 8px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

html[lang="th"] .lang-th,
html[lang="en"] .lang-en {
  color: var(--accent-ink);
  background: var(--accent);
}

.live {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* วันที่ปัจจุบันหน้าป้ายอัปเดต: ตัวหนาสีเข้ม + เส้นคั่นบางๆ */
.live-date {
  flex: none;
  padding-right: 7px;
  font-weight: 600;
  color: var(--text);
  border-right: 1px solid var(--line);
}

.live-date:empty {
  display: none;
}

.live-dot {
  --c: var(--ok);

  position: relative;
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--c);
  border-radius: 50%;
}

.live-dot::after {
  position: absolute;
  inset: 0;
  content: "";
  background: inherit;
  border-radius: 50%;
  animation: ping 1.8s ease-out infinite;
}

.live.wait {
  --c: var(--idle);
}

.live.warn {
  --c: var(--warn);

  color: var(--warn-t);
}

.live.bad {
  --c: var(--bad);

  color: var(--bad-t);
}

/* --c ต้องตั้งที่ตัวจุดเอง (.live-dot ตั้ง --c: ok ไว้ ค่าจากแม่ส่งลงมาไม่ถึง) */
.live.wait .live-dot {
  --c: var(--idle);
}

.live.warn .live-dot {
  --c: var(--warn);
}

.live.bad .live-dot {
  --c: var(--bad);
}

.live.bad .live-dot::after,
.live.wait .live-dot::after {
  animation: none;
}

/* ค้นหา */
.search {
  --i: 19px;

  position: relative;
  margin: 0 16px;
}

.search > svg {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.search input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 42px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.search input::placeholder {
  color: var(--muted);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search input:where(:focus) {
  background: var(--panel-solid);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.search .icon-btn {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
}

.search-results {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  z-index: 30;
  max-height: min(470px, 62vh);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.sr-sec {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.sr-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 7px 8px;
  cursor: pointer;
  border-radius: 10px;
}

.sr-item[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.sr-item:hover {
  background: var(--card-hover);
}

.sr-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.sr-main b {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-main small {
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-ico {
  --i: 20px;

  display: grid;
  flex: none;
  place-items: center;
  width: 46px;
  height: 34px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border-radius: 9px;
}

.sr-none {
  padding: 16px 12px;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}

/* ตัวเลขสรุป */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 16px 0;
}

.stat {
  --c: var(--accent);
  --ct: var(--accent);

  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  min-width: 0;
  padding: 8px 10px 7px;
  text-align: left;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.stat.ok {
  --c: var(--ok);
  --ct: var(--ok-t);
}

.stat.warn {
  --c: var(--warn);
  --ct: var(--warn-t);
}

.stat.bad {
  --c: var(--bad);
  --ct: var(--bad-t);
}

.stat b {
  font: 600 23px/1.15 var(--mono);
  color: var(--ct);
}

.stat span {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat:hover {
  background: var(--card-hover);
}

.stat[aria-pressed="true"] {
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border-color: var(--c);
}

/* ปุ่มลัด 2–4 ปุ่ม: ตาราง 2 คอลัมน์ (ปุ่มสุดท้ายที่เหลือเดี่ยวยืดเต็มแถว) */
.quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 16px 0;
}

.quick > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.chip-btn {
  --i: 19px;

  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  overflow: hidden;
  font-size: 14px;
  white-space: nowrap;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.1s;
}

.chip-btn > svg {
  color: var(--accent);
}

.chip-btn:hover {
  background: var(--card-hover);
}

.chip-btn:active {
  transform: scale(0.97);
}

.chip-btn:where(.is-busy) > svg {
  animation: spin 1s linear infinite;
}

/* แท็บ */
.tabs {
  display: flex;
  gap: 3px;
  margin: 12px 12px 0;
  padding: 4px;
  background: var(--card);
  border-radius: 14px;
}

.tab {
  --i: 16px;

  position: relative;
  display: inline-flex;
  flex: 1 1 auto;
  gap: 5px;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--text);
  background: var(--panel-solid);
  box-shadow: 0 1px 4px rgb(0 0 0 / 22%);
}

.tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font: 600 11px/18px var(--mono);
  color: #fff;
  text-align: center;
  background: #dc2626;
  border-radius: 9px;
}

.views {
  flex: 1;
  min-height: 0;
  margin-top: 6px;
  padding: 0 8px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
}

/* ตัวกรองประเภท */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px 8px;
}

.fchip {
  --n: var(--muted);

  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  touch-action: manipulation;
  transition: background 0.15s;
}

.fchip i {
  width: 9px;
  height: 9px;
  background: var(--c);
  border-radius: 50%;
}

.fchip span {
  font: 500 11.5px var(--mono);
  color: var(--n);
}

.fchip:hover {
  background: var(--card-hover);
}

.fchip[aria-pressed="true"] {
  --n: var(--accent-ink);

  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.list-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 2px 8px 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.switches {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: flex-end;
}

.switch {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: relative;
  flex: none;
  width: 36px;
  height: 22px;
  margin: 0;
  cursor: pointer;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s;
  appearance: none;
}

.switch input::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  content: "";
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 35%);
  transition: transform 0.2s var(--ease);
}

.switch input:where(:checked) {
  background: var(--accent);
}

.switch input:checked::before {
  transform: translateX(14px);
}

/* รายการขบวน: แบ่งกลุ่ม (หัวกลุ่มติดบน) + แถวกระชับ ~52px · กลุ่มยาวแสดง 8 แถวแรก */
.train-list {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 5px 8px;
  text-align: left;
  border-radius: 12px;
  transition: background 0.15s;
}

.row:hover {
  background: var(--card-hover);
}

.row.is-sel {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.row.is-done {
  opacity: 0.62;
}

.row.is-stale {
  opacity: 0.78;
}

.row.is-ghost {
  cursor: default;
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row-route {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-route i {
  font-style: normal;
  color: var(--muted);
}

/* ภาษาอังกฤษ: ชื่อสถานียาว ("Bangkok (Krung Thep Aphiwat)") → ขึ้นได้ 2 บรรทัด ให้เห็นปลายทางเสมอ */
html[lang="en"] .row-route {
  display: -webkit-box;
  line-height: 1.3;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-where {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warn-text {
  font-weight: 600;
  color: var(--warn-t);
}

.ico-alert {
  --i: 13px;

  margin-right: 3px;
  color: var(--warn-t);
  vertical-align: -2px;
}

/* ---------- สถานะเดินรถ ---------- */
.status-body {
  padding: 6px 6px 8px;
}

.sec {
  margin-bottom: 18px;
}

.sec-title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 4px;
  font-size: 14.5px;
  font-weight: 700;
}

.count {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font: 600 11px/18px var(--mono);
  color: #fff;
  text-align: center;
  background: var(--bad);
  border-radius: 9px;
}

.zones,
.incs,
.cxls {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.zone {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  background: var(--card);
  border-radius: 12px;
}

/* สายที่มีปัญหาในแท็บสถานะ = ปุ่ม แตะดูรายละเอียด */
.zone-btn {
  width: 100%;
  min-height: 52px;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  border: 1px solid var(--line);
}

.zone-btn:hover {
  border-color: var(--accent);
}

.zone-go {
  flex: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
}

.zdot {
  flex: none;
  width: 12px;
  height: 12px;
  background: var(--c);
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent);
}

.zone-main,
.cxl-main,
.inc-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.zone-main b,
.cxl-main b {
  font-size: 14px;
  font-weight: 600;
}

.zone-main small,
.inc-main small {
  font-size: 12px;
  color: var(--muted);
}

.cxl-main small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ct);
}

.inc {
  --tone: var(--warn);
  --tone-t: var(--warn-t);

  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--tone) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
  border-radius: 12px;
  transition: background 0.15s;
}

.inc:hover {
  background: color-mix(in srgb, var(--tone) 17%, transparent);
}

.inc.is-resolved {
  --tone: var(--idle);
  --tone-t: var(--ok-t);

  border-color: transparent;
  opacity: 0.78;
}

.inc-ico {
  --i: 18px;

  margin-top: 2px;
  color: var(--tone-t);
}

.inc-main b {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
}

.inc-ext {
  --i: 16px;

  margin-top: 3px;
  color: var(--muted);
}

.incs-done {
  margin-top: 8px;
}

.incs-done summary {
  padding: 6px 4px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.cxl {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  background: var(--card);
  border-radius: 12px;
}

.cxl-no {
  --tbg: var(--card-hover);
  --tfg: var(--text);
}

.credit {
  margin: 20px 6px 6px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
}

.credit a {
  color: var(--accent);
}

/* ---------- แผงรายละเอียด ---------- */
.detail {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  width: var(--detail-w);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  animation: detail-in 0.28s var(--ease);
}

.dt-head {
  position: relative;
  flex: none;
  padding: 12px 16px 16px;
}

.train-head {
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
}

.dt-grip {
  display: none;
}

.dt-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dt-sp {
  flex: 1;
}

.dt-btn {
  --i: 20px;

  display: inline-flex;
  flex: none;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  background: color-mix(in srgb, currentcolor 15%, transparent);
  border-radius: 12px;
  transition: background 0.15s, transform 0.1s;
}

.dt-btn:hover {
  background: color-mix(in srgb, currentcolor 24%, transparent);
}

.dt-btn:active {
  transform: scale(0.95);
}

.dt-btn.wide {
  padding: 0 14px;
}

.dt-btn[aria-pressed="true"] {
  color: var(--tbg, #1968ab);
  background: var(--tfg, #fff);
}

.dt-btn:disabled {
  opacity: 0.45;
}

.dt-kicker {
  margin: 12px 0 2px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.88;
}

.dt-title {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

.dt-no {
  flex: none;
  max-width: 62%;
  overflow: hidden;
  font: 600 54px/1 var(--mono);
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
}

.dt-no.long {
  font-size: 42px;
}

.dt-route {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dt-route b {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}

.dt-route i {
  font-style: normal;
  opacity: 0.85;
}

.dt-route small {
  font-size: 12px;
  line-height: 1.4;
  opacity: 0.92;
}

/* การ์ดสรุป (ขบวน: อยู่ใน .dt-body เลื่อนไปพร้อมตารางเวลา) */
.dt-summary {
  flex: none;
  padding: 12px 14px 0;
}

.dt-body > .dt-summary,
.dt-body > .dt-stock {
  padding: 0;
}

/* ขบวน: ไม่ใช้ขอบจางด้านบน (แถบสรุปเล็กติดอยู่ตรงนั้น) */
.tr-body {
  mask-image: none;
}

/* แถบสรุปเล็ก: ติดบนสุดตอนเลื่อนพ้นการ์ดสรุป · ไม่กินที่ (margin ลบเท่าความสูง) · แตะ = กลับขึ้นไปดูสรุป */
.dt-mini {
  position: sticky;
  top: -12px;
  z-index: 4;
  display: grid;
  flex: none;
  gap: 1px;
  align-content: center;
  height: 52px;
  margin: -12px -14px -52px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  text-align: start;
  cursor: pointer;
  visibility: hidden;
  background: var(--panel-solid);
  border: 0;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.dt-mini.is-on {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.dt-mini > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-st {
  font-size: 14px;
  font-weight: 700;
  color: var(--ct, var(--text));
}

.mini-next {
  font-size: 13px;
  color: var(--muted);
}

.mini-next b {
  font-weight: 700;
  color: var(--text);
}

.mini-next [data-tick] {
  font-weight: 600;
  color: var(--accent);
}

.dt-summary:empty {
  display: none;
}

.dt-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 12px 14px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px);
}

.dt-note:empty {
  display: none;
}

/* ข้อมูลไม่อัปเดต (ออฟไลน์/ต้นทางล่ม) — อยู่ใต้หัวแผงเสมอ ไม่เลื่อนหาย */
.dt-stale {
  flex: none;
  margin: 10px 14px 0;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 13%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 12px;
}

.loc-body .dt-stale {
  margin: 0;
}

.empty-act {
  display: flex;
  justify-content: center;
  margin: -12px 0 16px;
}

.empty-act .chip-btn {
  padding: 0 18px;
  color: var(--accent);
  font-weight: 600;
}

.card {
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sum-card {
  padding: 12px 16px 10px;
  overflow: hidden; /* แถบคืบหน้าเลื่อนด้วย transform เกินขอบขวา → ไม่ให้แผงเลื่อนออกด้านข้าง */
  background: var(--panel-solid);
}

.st-big {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ct, var(--text));
}

.st-sub {
  margin: 1px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.alert {
  --i: 20px;

  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: 12px;
}

.alert > svg {
  margin-top: 2px;
}

.alert b {
  font-weight: 700;
}

.alert p {
  margin: 1px 0 0;
  font-size: 13px;
  color: var(--text);
}

.info {
  --i: 18px;

  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  background: color-mix(in srgb, var(--cargo) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--cargo) 32%, transparent);
  border-radius: 12px;
}

.info > svg {
  margin-top: 2px;
  color: var(--cargo-t);
}

.info p {
  margin: 0;
}

.st-big.stale {
  --ct: var(--muted);
}

.info.stale-info {
  background: color-mix(in srgb, var(--idle) 12%, transparent);
  border: 1px dashed color-mix(in srgb, var(--idle) 45%, transparent);
}

.info.stale-info > svg {
  color: var(--muted);
}

.sum-next {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.next-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.k {
  font-size: 12px;
  color: var(--muted);
}

.next-name {
  overflow: hidden;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-time {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: flex-end;
  max-width: 52%;
  text-align: right;
}

.next-time b {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--accent);
}

.next-time span {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

.prog {
  margin-top: 12px;
}

.prog-bar {
  --i: 15px;

  position: relative;
  height: 8px;
  margin: 12px 14px 8px;
  background: var(--line);
  border-radius: 999px;
}

.prog-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 35%, transparent), var(--accent));
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 1s linear;
}

/* รางของไอคอนขบวน: เลื่อนทั้งรางด้วย translateX(%) = สัดส่วนของความยาวแถบ */
.prog-track {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: transform 1s linear;
}

.prog.no-anim .prog-fill,
.prog.no-anim .prog-track {
  transition: none;
}

.prog-train {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent), 0 3px 10px rgb(0 0 0 / 30%);
}

.prog-ends {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.prog-ends span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prog-ends b {
  font-weight: 600;
  color: var(--accent);
}

.prog-ends span:where(:last-child) {
  text-align: right;
}

.prog.is-unknown .prog-fill,
.prog.is-unknown .prog-track {
  display: none;
}

/* ไทม์ไลน์ (แบบกะทัดรัด: ชานชาลา/ประตูอยู่บรรทัดเดียวกับชื่อสถานี · ย่อสถานีก่อนหน้า/ไกลข้างหน้า) */
.tl-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.tl-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.switch.sm {
  font-size: 12px;
}

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

.tl-row {
  --tb: 14px;
  --tbw: 600;

  display: grid;
  grid-template-columns: 46px 22px minmax(0, 1fr);
  column-gap: 8px;
  min-height: 38px;
  border-radius: 10px;
}

.tl-row.is-through {
  --tb: 12.5px;
  --tbw: 500;
  --ct: var(--muted);
}

/* ผ่านมาแล้ว: เวลาตัวบางลง (สีตามความตรงเวลาเดิม) */
.tl-row.is-passed {
  --tbw: 500;
}

/* สถานีถัดไป/ที่จอดอยู่: พื้นจางให้หาเจอเร็ว */
.tl-row.is-next,
.tl-row.is-cur {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tl-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 8px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.tl-time b {
  font-size: var(--tb);
  font-weight: var(--tbw);
  color: var(--ct, var(--text));
}

/* เวลาตามตาราง (ขีดฆ่า) ตัวเล็กเหนือเวลาจริง */
.tl-time s {
  font-size: 10.5px;
  color: var(--muted);
}

.tl-rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.tl-rail::before {
  position: absolute;
  inset: 0 auto 0 50%;
  width: 4px;
  margin-left: -2px;
  content: "";
  background: var(--line);
}

.tl-row.is-first .tl-rail::before {
  top: 16px;
}

.tl-row.is-last .tl-rail::before {
  bottom: calc(100% - 16px);
}

.tl-row.is-passed .tl-rail::before {
  background: var(--accent);
}

.tl-row.tl-train .tl-rail::before {
  background: linear-gradient(var(--accent), var(--line));
}

.tl-dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin-top: 11px;
  background: var(--panel-solid);
  border: 3px solid var(--muted);
  border-radius: 50%;
}

.tl-row.is-passed .tl-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.tl-row.is-next .tl-dot {
  border-color: var(--accent);
}

.tl-row.is-first .tl-dot,
.tl-row.is-last .tl-dot {
  width: 16px;
  height: 16px;
  margin-top: 9px;
  border-radius: 4px;
}

.tl-row.is-through .tl-dot {
  width: 8px;
  height: 8px;
  margin-top: 13px;
  border-width: 2px;
}

.tl-row.is-cur .tl-dot {
  width: 18px;
  height: 18px;
  margin-top: 8px;
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent), 0 0 14px var(--accent);
}

/* ชื่อ + ชานชาลา/ประตูบรรทัดเดียวกัน (จอแคบขึ้นบรรทัดใหม่เอง) */
.tl-info {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  align-items: center;
  align-content: flex-start;
  min-width: 0;
  padding: 7px 4px 7px 0;
}

.tl-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tl-row.is-passed .tl-name {
  font-weight: 500;
  color: var(--muted);
}

.tl-row.is-through .tl-name {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.tl-row.is-cur .tl-name,
.tl-row.is-next .tl-name {
  font-size: 15px;
  font-weight: 700;
}

.tl-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.pf {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  background: var(--card-hover);
  border-radius: 5px;
}

.pf.gate {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.tl-status {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ct, var(--muted));
}

.tl-tag {
  padding: 0 5px;
  font-size: 10.5px;
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
  border: 1px dashed var(--line);
  border-radius: 5px;
}

.tl-tag.cur {
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* สาเหตุ (เฉพาะสถานีถัดไป/ที่จอด) ขึ้นบรรทัดใหม่เต็มความกว้าง */
.tl-cause {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--warn-t);
}

.tl-bob {
  --i: 14px;

  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 6px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent), 0 3px 10px rgb(0 0 0 / 28%);
  animation: bob 1.4s ease-in-out infinite;
}

.tl-row.tl-train .tl-info {
  flex-direction: column;
  gap: 0;
  align-items: flex-start;
  padding: 6px 0;
}

.tl-now {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
}

.tl-train small {
  font-size: 12px;
  color: var(--muted);
}

/* ส่วนที่ย่อไว้ (ก่อนหน้า/ข้างหน้า): รางเส้นประ + ปุ่มกาง */
.tl-row.tl-fold {
  min-height: 44px;
}

.tl-row.tl-fold .tl-rail::before {
  background: repeating-linear-gradient(var(--line) 0 5px, transparent 5px 9px);
}

.tl-row.tl-fold[data-fold="tl-done"] .tl-rail::before {
  background: repeating-linear-gradient(var(--accent) 0 5px, transparent 5px 9px);
}

.tl-row.tl-fold .tl-info {
  padding: 4px 0;
}

.tl-fold-btn {
  min-height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
}

.tl-fold-btn:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ป้ายสถานี */
.station-head {
  color: #fff;
  background: linear-gradient(160deg, #173b66, #0b1f3a);
}

.dt-chip {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  background: rgb(0 0 0 / 22%);
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 999px;
}

.sign {
  position: relative;
  margin: 12px 18px 14px;
  padding: 8px 16px 10px;
  font-size: inherit;
  font-weight: inherit;
  color: #0f172a;
  text-align: center;
  background: #fff;
  border-top: 8px solid #1968ab;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgb(0 0 0 / 35%);
}

.sign::before,
.sign::after {
  position: absolute;
  bottom: -16px;
  width: 6px;
  height: 16px;
  content: "";
  background: #c8d3e3;
  border-radius: 0 0 2px 2px;
}

.sign::before {
  left: 22%;
}

.sign::after {
  right: 22%;
}

.sign-th {
  display: block;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.35;
}

.sign-en {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
}

.sign-abbr {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.board {
  --bd-cols: 64px 60px minmax(0, 1fr) 46px;

  padding: 4px 4px 6px;
  color: #e8eef7;
  background: #05080f;
  border: 1px solid #1a2436;
  border-radius: 14px;
  box-shadow: inset 0 0 30px rgb(0 0 0 / 60%);
}

.bd-head {
  display: grid;
  grid-template-columns: var(--bd-cols);
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: #7c8aa0;
  white-space: nowrap;
  border-bottom: 1px solid #1a2436;
}

.bd-head span:where(:last-child) {
  text-align: right;
}

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

.bd-list li + li {
  border-top: 1px dashed #1a2436;
}

.bd-row {
  display: grid;
  grid-template-columns: var(--bd-cols);
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s;
}

.bd-row:hover {
  background: rgb(255 194 51 / 7%);
}

.bd-time {
  --led: #ffc233;
  --glow: rgb(255 194 51 / 45%);

  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  line-height: 1.2;
}

.bd-time b {
  font-size: 17px;
  font-weight: 600;
  color: var(--led);
  text-shadow: 0 0 8px var(--glow);
}

.bd-time s {
  font-size: 11px;
  color: #6b7a90;
}

/* จอดนานกว่า 1 นาที: เวลาออกใต้เวลาถึง */
.bd-time .bd-dep {
  font-size: 11px;
  color: #9aa7ba;
  white-space: nowrap;
}

/* เส้นคั่น "พรุ่งนี้" ก่อนแถวของวันถัดไป */
.bd-list li.bd-day {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 10px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #ffc233;
  border-top: 0;
}

.bd-list li.bd-day::before,
.bd-list li.bd-day::after {
  flex: 1;
  height: 1px;
  content: "";
  background: #3a4a66;
}

.bd-list li.bd-day + li {
  border-top: 0;
}

.bd-train {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  min-width: 0;
}

.bd-pill {
  padding: 3px 7px;
  font: normal 600 14px/1.1 var(--mono);
  color: var(--tfg);
  background: var(--tbg);
  border-radius: 6px;
}

.bd-train small {
  max-width: 100%;
  overflow: hidden;
  font-size: 10.5px;
  color: #9aa7ba;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bd-dest {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

/* ชื่อปลายทางยาว (เช่นภาษาอังกฤษ "Ubon Ratchathani") ขึ้นบรรทัดใหม่ได้ 2 บรรทัด ไม่ตัดทิ้ง */
.bd-dest b {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  color: #f1f5f9;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.bd-dest small {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ป้าย LED มืดเสมอ → ใช้สีสว่างคงที่ไม่ขึ้นกับธีม */
.board .lv0 {
  --led: #ffc233;

  color: #4ade80;
}

.board .lv1 {
  --led: #ff9f1a;
  --glow: rgb(255 159 26 / 45%);

  color: #fbbf24;
}

.board .lv2 {
  --led: #ff5a4f;
  --glow: rgb(255 90 79 / 45%);

  color: #f87171;
}

.bd-pf {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 34px;
  height: 30px;
  font: 600 15px var(--mono);
  color: #ffc233;
  background: #101a2a;
  border: 1px solid #25324a;
  border-radius: 6px;
}

/* ป้ายสำรอง: ชานชาลาที่ใช้ปกติ (ไม่ใช่ข้อมูลของเที่ยวนี้) — กรอบเส้นประ สีจาง */
.bd-pf.is-usual {
  color: #c9a24a;
  border-style: dashed;
}

/* ป้ายสำรอง: ขบวนตามตาราง (ยังไม่มีรายงานการเดินรถ) สีกลาง ไม่ใช่สีตรงเวลา */
.bd-dest small.bd-plan {
  color: #a9b6cc;
}

/* ป้ายสำรอง: ขบวนที่เพิ่งถึง/ออกไปแล้ว */
.bd-row.is-done {
  opacity: .7;
}

.bd-row.is-cxl .bd-dest b {
  text-decoration: line-through;
}

.board-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- แผนที่: ปุ่ม/คำอธิบาย/แจ้งเตือน ---------- */
.map-ctl {
  --ctl-gap: 8px;

  position: fixed;
  right: 16px;
  bottom: 30px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: var(--ctl-gap);
  align-items: flex-end;
  touch-action: manipulation;
  transition: right 0.28s var(--ease);
}

.fab {
  width: 44px;
  height: 44px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.map-ctl .zoom-btn {
  --i: 22px;

  width: 52px;
  height: 44px;
  color: var(--text);
}

.map-ctl .zoom-btn:focus-visible {
  position: relative;
  z-index: 1;
}

.map-ctl #zoomIn {
  border-radius: 14px 14px 0 0;
}

.map-ctl #zoomOut {
  margin-top: calc(-1 * var(--ctl-gap));
  border-top-width: 0;
  border-radius: 0 0 14px 14px;
}

.legend {
  position: fixed;
  bottom: 22px;
  left: calc(32px + var(--panel-w));
  z-index: 900;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 16px;
  font-size: 12.5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.legend span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}


.legend em {
  font-style: normal;
}

.lg-short {
  display: none;
}

.dot {
  --c: var(--ok);

  width: 12px;
  height: 12px;
  margin-right: 7px;
  background: var(--c);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 25%), 0 0 6px var(--c);
}

.dot.warn {
  --c: var(--warn);
}

.dot.bad {
  --c: var(--bad);
}

.dot.idle,
.dot.hollow {
  --c: var(--idle);

  background: #fff;
  border: 3px solid var(--c);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 25%);
}

.dot.hollow {
  --c: var(--ok);
}

.dot.cargo {
  --c: var(--cargo);

  border-radius: 3px;
}

.dot.stale {
  --c: var(--idle);

  background: transparent;
  border: 2px dashed var(--idle);
  box-shadow: none;
}

/* วงประรอบหมุด = ตำแหน่งประมาณ (map.js is-ahead / is-rough) */
.dot.approx {
  background: var(--ok);
  outline: 1.5px dashed var(--ok);
  outline-offset: 2px;
  box-shadow: none;
}

/* คำอธิบาย "ขาดรายงาน" เฉพาะจอกว้างที่มีที่ (จอเล็ก: อธิบายใน tooltip/รายละเอียดขบวนแทน) */
.legend .lg-wide {
  display: none;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 1300;
  max-width: min(92vw, 460px);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* แชร์ไม่ได้/คัดลอกไม่ได้ → ให้เลือกข้อความลิงก์คัดลอกเองได้ */
.toast.is-select {
  overflow-wrap: anywhere;
  pointer-events: auto;
  user-select: text;
}

/* ---------- desktop: ขยับปุ่มเมื่อเปิดรายละเอียด ---------- */
@media (min-width: 900px) {
  .has-detail .map-ctl {
    right: calc(32px + var(--detail-w));
  }

  .has-detail .leaflet-bottom.leaflet-right {
    right: calc(32px + var(--detail-w));
  }
}

/* จอกลาง + แผงขวาเปิด: คำอธิบายหมุดชนปุ่มแผนที่ (ภาษาอังกฤษแบบสั้นยังชนถึง ~1310 px) → ซ่อน (อยู่ในวิธีใช้ ?) */
@media (min-width: 900px) and (max-width: 1319px) {
  .has-detail .legend,
  .has-locate .legend {
    display: none;
  }
}

/* จอเตี้ย (เช่น 1280×720): ย่อหัวรายละเอียดให้ไทม์ไลน์มีที่ */
@media (min-width: 900px) and (max-height: 780px) {
  .dt-no {
    font-size: 44px;
  }

  .dt-kicker {
    margin-top: 6px;
  }

  .dt-head {
    padding-bottom: 12px;
  }

  .sign-th {
    font-size: 26px;
  }
}

/* ---------- มือถือ/แท็บเล็ต: แผ่นเลื่อนด้านล่าง ---------- */
@media (max-width: 899px) {
  body {
    font-size: 14.5px;
  }

  .panel {
    inset: auto 0 0;
    width: auto;
    height: calc(100dvh - 48px);
    padding-bottom: env(safe-area-inset-bottom);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom)));
    transition: transform 0.34s var(--ease);
  }

  .panel[data-snap="half"] {
    transform: translateY(calc(44dvh - 48px));
  }

  .panel[data-snap="full"] {
    transform: none;
  }

  .panel[data-snap="half"] .views {
    padding-bottom: calc(44dvh - 32px);
  }

  .panel.is-dragging,
  .detail.is-dragging {
    transition: none;
  }

  .panel-grip {
    display: flex;
    flex: none;
    justify-content: center;
    min-height: 32px;
    align-items: center;
    padding: 6px 0;
    cursor: grab;
    touch-action: none;
  }

  /* ที่จับแผ่น = ปุ่มลูกศร: ^ แตะขยาย · ขยายเต็มแล้วเป็น v แตะย่อ (ยังลากได้เหมือนเดิม) */
  .panel-grip span,
  .dt-grip span,
  .grip-down span {
    display: grid;
    place-items: center;
    width: 48px;
    height: 22px;
    background: color-mix(in srgb, var(--grip, var(--muted)) 16%, transparent);
    border-radius: 11px;
  }

  .panel-grip span::before,
  .dt-grip span::before,
  .grip-down span::before {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    content: "";
    border-top: 2.5px solid var(--grip, var(--muted));
    border-left: 2.5px solid var(--grip, var(--muted));
    border-radius: 1px;
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease), margin 0.25s var(--ease);
  }

  /* data-dir ตั้งที่ตัว grip เอง (app.js syncGrips) — ไม่พึ่ง selector ของแผ่นแม่อย่างเดียว · #gripDown = v เสมอ */
  .grip-down span::before,
  .panel-grip[data-dir="down"] span::before,
  .dt-grip[data-dir="down"] span::before {
    margin-top: -5px;
    transform: rotate(225deg);
  }

  .panel[data-snap="full"] .panel-grip span::before,
  .detail[data-snap="full"] .dt-grip span::before {
    margin-top: -5px;
    transform: rotate(225deg);
  }

  /* แผงครึ่งจอ: 2 ปุ่มข้างกัน — ^ (ที่จับเดิม ลูกศรเลื่อนไปซ้าย) ขยายเต็ม · v (#gripDown, app.js) ย่อลงสุด
     แถวสูง 44 px = พื้นที่แตะ ≥ 44 ทั้งคู่ · กลางแถวยังเป็นที่จับ (แตะ = ขยาย, ลากได้เหมือนเดิม) */
  .panel[data-snap="half"] #grip {
    min-height: 44px;
    padding: 0 64px 0 0;
  }

  .grip-down {
    position: absolute;
    top: 0;
    left: calc(50% + 6px);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 44px;
    min-height: 0;
    padding: 0;
    margin: 0;
    color: inherit;
    cursor: pointer;
    background: none;
    border: 0;
    border-radius: 12px;
    touch-action: manipulation;
  }

  .grip-down[hidden] {
    display: none;
  }

  /* โฟกัสจากคีย์บอร์ด: วงรอบลูกศร (ไม่ใช่ทั้งแถวกว้างเต็มจอ) */
  .panel-grip:focus-visible,
  .grip-down:focus-visible {
    outline: none;
  }

  .panel-grip:focus-visible span,
  .grip-down:focus-visible span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .brand {
    padding: 2px 10px 10px 16px;
    touch-action: none;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .search input {
    height: 44px;
    font-size: 16px;
  }

  .stats {
    gap: 6px;
    margin-top: 10px;
  }

  .stat {
    padding: 6px 8px;
  }

  .stat b {
    font-size: 20px;
  }

  .fchip {
    height: 36px;
  }

  .detail {
    inset: auto 0 0;
    width: auto;
    height: calc(100dvh - 48px);
    background: var(--panel-solid);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    transform: translateY(calc(42dvh - 48px));
    transition: transform 0.3s var(--ease);
    animation: sheet-in 0.32s var(--ease);
  }

  .detail[data-snap="full"] {
    transform: none;
  }


  .dt-head {
    padding: 0 14px 12px;
    touch-action: none;
  }

  .dt-grip {
    display: flex;
    justify-content: center;
    padding: 9px 0 7px;
    cursor: grab;
  }

  .train-head .dt-grip {
    --grip: currentcolor;
  }

  .station-head .dt-grip {
    --grip: #fff;
  }

  .dt-kicker {
    margin-top: 6px;
    font-size: 13px;
  }

  .dt-no {
    font-size: 42px;
  }

  .dt-route b {
    font-size: 15.5px;
  }

  .dt-summary {
    padding: 10px 12px 0;
  }

  .dt-mini {
    top: -10px;
    margin: -10px -12px -52px;
    padding: 0 12px;
  }

  .dt-body {
    padding: 10px 12px 20px;
  }

  .detail[data-snap="half"] .dt-body {
    padding-bottom: calc(42dvh - 24px);
  }

  .sign-th {
    font-size: 24px;
  }

  /* ปุ่มซูมแนวตั้ง [+ / −] ชิดขวาใต้ "ตัวฉัน" คอลัมน์เดียวกับปุ่มแผนที่บน (กว้าง 52 px ไม่ยื่นซ้ายไปบังเส้นทางรถไฟ) */
  .map-ctl {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    bottom: auto;
  }

  .map-ctl #zoomIn {
    order: 1;
  }

  .map-ctl #zoomOut {
    order: 2;
  }

  /* จอเตี้ยแนวตั้ง (เช่น iPhone SE 548–568 px): กระชับระยะคอลัมน์ไม่ให้ปุ่ม − ชนปุ่ม i เครดิตแผนที่ · ตอนเปิดแผ่นครึ่งจอซ่อนซูมไว้จนปิดแผ่น */
  @media (max-height: 599px) and (orientation: portrait) {
    .map-ctl {
      --ctl-gap: 4px;

      top: calc(6px + env(safe-area-inset-top));
    }

    .map-ctl .fab.lbl {
      height: 44px;
    }
  }

  @media (max-height: 669px) and (orientation: portrait) {
    .has-detail .map-ctl .zoom-btn,
    .has-locate .map-ctl .zoom-btn,
    .has-kidcard .map-ctl .zoom-btn,
    .has-kidplay .map-ctl .zoom-btn {
      display: none;
    }
  }

  /* ไม่ทับปุ่มดูทั้งประเทศ (ขวาบน 44px) — ข้อความยาว (อังกฤษ/จอแคบ) ขึ้น 2 แถวแทน */
  .legend {
    top: calc(10px + env(safe-area-inset-top));
    bottom: auto;
    left: 10px;
    flex-wrap: wrap;
    gap: 2px 10px;
    max-width: calc(100vw - 72px);
    min-height: 44px;
    padding: 5px 12px;
    font-size: 11.5px;
    border-radius: 22px;
  }

  /* แผ่นเลื่อนเต็มจอ: ซ่อนคำอธิบายหมุด/ปุ่มแผนที่ที่โผล่เหนือแผ่น (ไม่ทับขอบแผ่น และแตะผิดไม่ได้) */
  .panel[data-snap="full"] ~ .legend,
  .panel[data-snap="full"] ~ .map-ctl,
  .detail:not([hidden])[data-snap="full"] ~ .legend,
  .detail:not([hidden])[data-snap="full"] ~ .map-ctl {
    visibility: hidden;
  }


  .legend .lg-long {
    display: none;
  }

  .legend .lg-short {
    display: inline;
  }

  .dot {
    width: 10px;
    height: 10px;
    margin-right: 5px;
  }

  .toast {
    top: calc(64px + env(safe-area-inset-top));
  }

  /* เครดิตแผนที่: ย่อเป็นปุ่ม ⓘ เหนือแผ่นเลื่อน แตะเพื่อขยาย */
  .leaflet-bottom.leaflet-right {
    bottom: var(--peek);
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 20px);
    margin: 0 8px 6px 0 !important;
    font-size: 10px;
    border-radius: 10px;
  }

  .leaflet-control-attribution:not(.is-open) {
    position: relative;
    width: 26px;
    height: 26px;
    padding: 0 !important;
    overflow: hidden;
    color: transparent !important;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 50%;
  }

  .leaflet-control-attribution:not(.is-open) > * {
    visibility: hidden;
  }

  .leaflet-control-attribution:not(.is-open)::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font: italic 700 14px/1 Georgia, serif;
    color: var(--text);
    content: "i";
  }
}

/* แท็บเล็ตแนวตั้ง: แผ่นเลื่อนไม่กว้างเต็มจอ */
@media (min-width: 640px) and (max-width: 899px) {
  .panel,
  .detail {
    max-width: 620px;
    margin-inline: auto;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 380px) {
  .legend {
    gap: 2px 8px;
    padding: 5px 10px;
    font-size: 11px;
  }

  .stat span {
    font-size: 10.5px;
  }

  .tab {
    --i: 0;

    gap: 3px;
  }
}

/* ---------- มือถือแนวนอน / จอเตี้ย: แผ่นด้านซ้ายที่เลื่อนได้ทั้งแผ่น แผนที่อยู่ด้านขวา ----------
   (แผ่นเลื่อนด้านล่างสูงไม่พอ: รายการ/แท็บ/ตารางเวลาหลุดจอ) — ตรงกับ LAND_MQ ใน util.js */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  :root {
    --side-w: clamp(280px, 46vw, 380px);
    --side-l: calc(8px + env(safe-area-inset-left));
  }

  .panel,
  .panel[data-snap] {
    inset: 8px auto 8px var(--side-l);
    width: var(--side-w);
    max-width: none;
    height: auto;
    margin: 0;
    padding-bottom: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 18px;
    transform: none;
    transition: none;
    scrollbar-color: var(--line) transparent;
    scrollbar-width: thin;
  }

  /* ย่อ = การ์ดมุมบนซ้าย (ยังเลื่อนดูต่อได้) · แตะ grip = เต็มความสูง */
  .panel[data-snap="peek"] {
    bottom: auto;
    max-height: min(var(--peek), calc(100dvh - 16px));
  }

  .panel .views,
  .panel[data-snap="half"] .views {
    flex: none;
    padding-bottom: 8px;
    overflow: visible;
  }

  .panel-grip {
    padding: 6px 0 2px;
  }

  .brand {
    padding: 2px 10px 6px 14px;
    touch-action: auto;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .search input {
    height: 40px;
  }

  .stats {
    margin-top: 8px;
  }

  .stat {
    padding: 4px 8px;
  }

  .stat b {
    font-size: 18px;
  }

  .quick {
    gap: 6px;
    margin-top: 8px;
  }

  .chip-btn {
    height: 38px;
    font-size: 13px;
  }

  .tabs {
    margin-top: 8px;
  }

  /* รายละเอียดขบวน/สถานี: ทับแผงหลักด้านซ้าย เลื่อนทั้งแผ่น (หัว + สรุป + ตารางเวลา) */
  .detail,
  .detail[data-snap] {
    display: block;
    inset: 8px auto 8px var(--side-l);
    width: var(--side-w);
    max-width: none;
    height: auto;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 18px;
    transform: none;
    transition: none;
    animation: detail-in 0.28s var(--ease);
    scrollbar-color: var(--line) transparent;
    scrollbar-width: thin;
  }

  .detail .dt-body,
  .detail[data-snap="half"] .dt-body {
    padding-bottom: 16px;
    overflow: visible;
    mask-image: none;
  }

  .dt-grip {
    display: none;
  }

  .dt-head {
    padding-top: 10px;
    touch-action: auto;
  }

  .dt-kicker {
    margin-top: 4px;
  }

  .dt-no {
    font-size: 34px;
  }

  /* คำอธิบายหมุด/ปุ่ม อยู่บนแผนที่ด้านขวาของแผ่น (ไม่ซ่อนตอนแผ่นเต็มความสูง) */
  .legend {
    top: calc(8px + env(safe-area-inset-top));
    left: calc(var(--side-l) + var(--side-w) + 8px);
    max-width: calc(100vw - var(--side-l) - var(--side-w) - 72px);
    min-height: 36px;
    padding: 4px 10px;
  }

  .map-ctl {
    --ctl-gap: 5px;

    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
  }

  .map-ctl .fab.lbl {
    height: 46px;
  }

  .panel[data-snap="full"] ~ .legend,
  .panel[data-snap="full"] ~ .map-ctl,
  .detail:not([hidden])[data-snap="full"] ~ .legend,
  .detail:not([hidden])[data-snap="full"] ~ .map-ctl {
    visibility: visible;
  }

  .toast {
    top: 56px;
    left: calc(var(--side-l) + var(--side-w) + (100vw - var(--side-l) - var(--side-w)) / 2);
    max-width: calc(100vw - var(--side-l) - var(--side-w) - 24px);
  }

  .leaflet-bottom.leaflet-right {
    bottom: 0;
  }
}

/* ---------- จอแคบ (≤ 380 px) + แผ่นด้านซ้ายของมือถือแนวนอน (~340 px) ---------- */
@media (max-width: 380px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .stat {
    padding-inline: 6px;
  }

  /* ป้ายยาว (เช่น "Slightly late") ขึ้น 2 บรรทัดแทนการตัด … */
  .stat span {
    line-height: 1.2;
    white-space: normal;
  }

  /* ป้ายสถานี: คอลัมน์เวลา/ขบวน/ชานชาลาแคบลง ให้ชื่อปลายทางมีที่ (ไม่ตัดกลางคำ "กรุงเทพอภิ|วัฒน์") */
  .board {
    --bd-cols: 54px 52px minmax(0, 1fr) 36px;
  }

  .bd-head,
  .bd-row {
    gap: 6px;
    padding-inline: 8px;
  }

  .bd-time b {
    font-size: 15.5px;
  }
}

/* 320 px (iPhone SE รุ่นแรก): บีบคอลัมน์ป้ายสถานีอีกนิด ชื่อ "ไป กรุงเทพอภิวัฒน์" อยู่บรรทัดเดียว */
@media (max-width: 340px) {
  .board {
    --bd-cols: 48px 48px minmax(0, 1fr) 34px;
  }

  .bd-time b {
    font-size: 14.5px;
  }

  .bd-time .bd-dep {
    font-size: 10px;
  }

  /* ปุ่มลัด "Meet Thai trains" ไม่ถูกตัดขอบขวา */
  .chip-btn {
    gap: 4px;
    padding-inline: 6px;
  }
}

/* ---------- จอสัมผัส: พื้นที่แตะอย่างน้อย ~40px (ขยายด้วย pseudo-element ภาพเท่าเดิม) ---------- */
@media (pointer: coarse) {
  /* .brand .icon-btn (? / ธีม): อยู่เหนือพื้นที่แตะล่องหนของที่จับแผ่นที่ยื่นลงมา 14 px (nav.css .panel-grip::after)
     — แตะขอบบนของปุ่ม ? ต้องได้วิธีใช้ ไม่ใช่ขยายแผง (ที่จับยังแตะได้ ~41 px ตรงส่วนที่ไม่มีปุ่ม) */
  :where(.icon-btn.sm),
  .lang-btn,
  .fchip,
  .page-links a,
  .ask-dialog .ask-chip,
  .brand .icon-btn {
    position: relative;
  }

  .icon-btn.sm:not(#searchClear)::after,
  .lang-btn::after,
  .fchip::after,
  #searchClear::after,
  .page-links a::after,
  .ask-dialog .ask-chip::after {
    position: absolute;
    inset: -6px -2px;
    content: "";
  }

  .icon-btn.sm:not(#searchClear)::after {
    inset: -6px;
  }

  /* ชิปกรองประเภท / ชิป "ลองถาม" สูง 36 → 42 (แถวห่างกัน 6 px วงล่องหนไม่ทับแถวข้างเคียง) */
  .fchip::after,
  .ask-dialog .ask-chip::after {
    inset: -3px 0;
  }

  /* ปุ่มล้างคำค้น 32 → 40 */
  #searchClear::after {
    inset: -4px;
    border-radius: 12px;
  }

  /* ลิงก์ "ขบวนรถทั้งหมด (หน้าเว็บ)" ตัวหนังสือสูง ~19 px → พื้นที่แตะ ~41 px (ขยายลงในระยะห่างรอบแถว ไม่ดันเลย์เอาต์) */
  .page-links a::after {
    inset: -11px -7px;
  }

  .switch {
    min-height: 40px;
  }

  .tab {
    height: 40px;
  }

  /* หมุดขบวนที่ซูมไกลเป็นจุดเล็ก → ขยายพื้นที่แตะรอบจุด (ไม่เปลี่ยนภาพ) */
  .tm-puck::after {
    position: absolute;
    inset: -12px;
    content: "";
    border-radius: 50%;
  }

  .zs .tm-puck::after {
    inset: -14px;
  }

  .leaflet-control-attribution:not(.is-open) {
    width: 32px;
    height: 32px;
  }
}

/* ---------- animations ---------- */
@keyframes sweep {
  to {
    transform: rotate(1turn);
  }
}

@keyframes ping {
  from {
    opacity: 0.7;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(2.8);
  }
}

@keyframes halo {
  from {
    opacity: 0.9;
    transform: scale(0.6);
  }

  to {
    opacity: 0;
    transform: scale(1.7);
  }
}

@keyframes ring {
  0% {
    transform: scale(0.85);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(0.85);
  }
}

@keyframes me-pulse {
  0% {
    box-shadow: 0 0 0 0 rgb(59 130 246 / 55%);
  }

  100% {
    box-shadow: 0 0 0 18px rgb(59 130 246 / 0%);
  }
}

@keyframes bob {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-logo::before,
  .live-dot::after,
  .tm.is-sel::before,
  .st-hl,
  .me-dot,
  .tl-bob {
    animation: none;
  }

  .tx .tm-icon,
  .prog-fill,
  .prog-track {
    transition: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ภาษาอังกฤษ: คำอธิบายหมุดยาวกว่าไทย → ตอนเปิดแผงรายละเอียดบนจอกว้าง ใช้แบบสั้น (ไม่ทับแผง) */
@media (min-width: 1300px) {
  .legend .lg-wide {
    display: inline-flex;
  }

  .has-detail .legend .lg-wide,
  .has-locate .legend .lg-wide {
    display: none;
  }

  html[lang="en"] .has-detail .legend .lg-long,
  html[lang="en"] .has-locate .legend .lg-long {
    display: none;
  }

  html[lang="en"] .has-detail .legend .lg-short,
  html[lang="en"] .has-locate .legend .lg-short {
    display: inline;
  }
}

/* 1300–1599 px เปิดแผงขวา: คำอธิบายหมุดภาษาไทยแบบเต็มยาวถึงปุ่มแผนที่ (ตัวฉัน) → ใช้แบบสั้นเหมือนภาษาอังกฤษ */
@media (min-width: 1300px) and (max-width: 1599px) {
  .has-detail .legend .lg-long,
  .has-locate .legend .lg-long {
    display: none;
  }

  .has-detail .legend .lg-short,
  .has-locate .legend .lg-short {
    display: inline;
  }
}

/* ปุ่มซื้อตั๋วกับ รฟท. (ลิงก์ทางการ) + กล่องข้อมูล/เว็บทางการ */
.quick .ticket-btn {
  min-height: 44px;
  font-weight: 700;
  color: var(--accent-ink);
  text-decoration: none;
  background: var(--accent);
  border-color: var(--accent);
}

.official-hint {
  margin: 12px 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.official-hint a {
  font-weight: 600;
  color: var(--accent);
}

.official-info {
  margin: 12px 0;
  padding: 0 4px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.official-info summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.official-info a {
  color: var(--accent);
}

.info-links {
  flex: none;
  margin: 4px 16px;
  font-size: 12px;
}

/* ทิศทางไปทางขวา: เลขขบวนอยู่ใต้หมุด ไม่ทับหัวลูกศรหรือวงเลือก */
.tm.is-sel.heading-east .tm-label {
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
}

.quick .ticket-btn:hover {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 90%, #000);
}

.tm.planned-heading .tm-label::after {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  width: max-content;
  padding: 3px 5px;
  font: 600 11px/1.3 var(--font);
  color: var(--text);
  content: attr(data-direction-note);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.quick .ticket-btn > svg {
  color: inherit;
}

/* css/list.css */
/* รายการขบวนแบบแบ่งกลุ่ม (panels.trainListHtml): หัวกลุ่มติดบน + ปุ่ม "ดูอีก N ขบวน" + ป้ายเลขขบวนเล็กลง
   แยกไฟล์จาก app.css (โหลดต่อจาก app.css จึงทับ .row/.badge ได้) */
.list-sec {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin: 8px -2px 2px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
}

.list-sec:first-child {
  margin-top: 0;
}

.list-sec-t {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.list-sec-dot {
  --c: var(--idle);

  width: 8px;
  height: 8px;
  background: var(--c);
  border-radius: 50%;
}

.list-sec-t.lv0 .list-sec-dot {
  --c: var(--ok);
}

.list-sec-t.lv1 .list-sec-dot {
  --c: var(--warn);
}

.list-sec-t.lv2 .list-sec-dot {
  --c: var(--bad);
}

.list-sec-t.cargo .list-sec-dot {
  --c: var(--cargo);

  border-radius: 2px;
}

.list-sec-star {
  --i: 14px;

  color: #f59e0b;
}

.list-sec-n {
  min-width: 26px;
  padding: 1px 8px;
  font: 600 11.5px/1.5 var(--mono);
  color: var(--muted);
  text-align: center;
  background: var(--card);
  border-radius: 999px;
}

.list-more {
  display: flex;
  justify-content: center;
  padding: 2px 0 6px;
}

.list-more-btn {
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
}

.list-more-btn:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

/* เลขขบวนในรายการ: ป้ายเล็กลง (เดิม 60×52) · โหมดเด็กคงขนาดเดิม */
html:not(.kid) .row .badge {
  --bs: 17px;

  gap: 2px;
  width: 48px;
  height: 42px;
  border-radius: 10px;
}

html:not(.kid) .row .badge.long {
  --bs: 14px;
}

html:not(.kid) .row .badge.xl {
  --bs: 11px;
}

html:not(.kid) .row .badge small {
  max-width: 44px;
  font-size: 9.5px;
}

html:not(.kid) .row .badge-star {
  --i: 14px;

  top: -5px;
  right: -5px;
}

html:not(.kid) .row .pill {
  padding: 3px 8px;
  font-size: 11.5px;
}

/* css/locate.css */
/* เรดาร์รถไฟ — "รถไฟผ่านใกล้ฉัน" + "ฉันอยู่บนรถไฟ" (ใช้ตัวแปรสีเดียวกับ app.css) */

/* ---------- แผง (ต่อยอดจาก .detail) ---------- */
@media (min-width: 900px) {
  .locate {
    bottom: auto;
    max-height: calc(100dvh - 32px);
  }

  .has-locate .map-ctl,
  .has-locate .leaflet-bottom.leaflet-right {
    right: calc(32px + var(--detail-w));
  }
}

.locate .dt-body {
  gap: 12px;
}

.loc-head {
  --grip: currentcolor;

  overflow: hidden;
}

.loc-head.is-nearby {
  padding-bottom: 22px;
  color: #1c1406;
  background: linear-gradient(135deg, #fcd34d, #f59e0b 70%, #ea8a0b);
}

.loc-head.is-detect {
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #1d4ed8);
}

.loc-head.is-train {
  color: var(--tfg, #fff);
  background: linear-gradient(135deg, var(--tbg, #1968ab), color-mix(in srgb, var(--tbg, #1968ab) 60%, #000));
}

.loc-title {
  --i: 26px;

  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.loc-title h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
}

.loc-title-ico {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #dc2626;
  background: #fff;
  border: 3px solid #dc2626;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgb(0 0 0 / 22%);
}

.is-detect .loc-title-ico,
.is-train .loc-title-ico {
  color: #1d4ed8;
  border-color: #fff;
}

.loc-place {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0.9;
}

/* แถบไม้กั้นทางรถไฟ แดง-ขาว */
.loc-stripes {
  position: absolute;
  inset: auto 0 0;
  height: 7px;
  background: repeating-linear-gradient(-45deg, #dc2626 0 12px, #fff 12px 24px);
}

/* ---------- ฮีโร่: ขบวนต่อไป ---------- */
.loc-hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 16px 14px 14px;
  text-align: center;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--tbg, #1968ab) 30%, transparent), transparent 70%),
    var(--card);
  border: 2px solid color-mix(in srgb, var(--tbg, #1968ab) 60%, var(--line));
  border-radius: 20px;
  transition: transform 0.12s, background 0.15s;
}

.loc-hero:hover {
  background-color: var(--card-hover);
}

.loc-hero:active {
  transform: scale(0.98);
}

.loc-hero-k {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.loc-count {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
  letter-spacing: -0.01em;
}

/* คำเตือนความปลอดภัย (ต้องเห็นเสมอใต้ตัวนับถอยหลัง / ใต้การ์ดว่าง) */
.loc-safety {
  display: block;
  max-width: 34em;
  margin: 2px auto 4px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--warn-t);
  text-align: center;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  border-radius: 10px;
}

p.loc-safety {
  margin: 10px 0 4px;
}

.loc-count.is-now {
  color: #f97316;
  animation: loc-pulse 0.9s ease-in-out infinite;
}

.loc-hero-train {
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 100%;
  text-align: left;
}

.loc-hero-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.loc-hero-txt b {
  font-size: 18px;
  line-height: 1.3;
}

.loc-hero-txt small {
  font-size: 13px;
  color: var(--muted);
}

.loc-hero-dir {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 14px;
  font-size: 15px;
  background: var(--card-hover);
  border-radius: 999px;
}

.loc-hero-meta {
  font-size: 12.5px;
  color: var(--muted);
}

.loc-arrow {
  --i: 18px;

  display: inline-grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  transform: rotate(var(--r, 0deg));
}

.loc-arrow.sm {
  --i: 12px;

  width: 18px;
  height: 18px;
  margin-right: 6px;
  vertical-align: -3px;
}

.loc-approx {
  display: inline-block;
  padding: 0 7px;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  line-height: 18px;
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border-radius: 999px;
}

/* ---------- รายการ ---------- */
.loc-h {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 4px 0;
  font-size: 15px;
  font-weight: 700;
}

.loc-count-n {
  padding: 0 8px;
  font-size: 12px;
  line-height: 20px;
  color: var(--muted);
  background: var(--card-hover);
  border-radius: 999px;
}

.loc-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loc-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  text-align: left;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 14px;
  transition: background 0.15s;
}

.loc-row:hover {
  background: var(--card-hover);
  border-color: var(--line);
}

.loc-row.is-passed {
  opacity: 0.62;
}

.loc-row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.loc-row-main b {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-row-main small {
  overflow: hidden;
  font-size: 12.5px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-row-time {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 1px;
  align-items: flex-end;
}

.loc-row-time b {
  font-size: 17px;
  font-weight: 600;
}

.loc-row-time small {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.loc-none {
  padding: 14px;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- สถานะรอ/ผิดพลาด/ว่าง ---------- */
.loc-wait,
.loc-empty,
.loc-end {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 22px 14px;
  text-align: center;
}

.loc-wait b,
.loc-empty b,
.loc-end b {
  font-size: 17px;
  line-height: 1.4;
}

.loc-wait p,
.loc-empty p,
.loc-end p {
  max-width: 320px;
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

.loc-empty > span,
.loc-end > span {
  font-size: 46px;
  line-height: 1.1;
}

.loc-radar {
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
}

.loc-radar::before {
  position: absolute;
  inset: 0;
  content: "";
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 55%, transparent), transparent 30%);
  border-radius: 50%;
  animation: loc-spin 1.6s linear infinite;
}

.loc-radar i {
  position: absolute;
  inset: 32px;
  background: var(--accent);
  border-radius: 50%;
}

.loc-err-ico {
  --i: 30px;

  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  border-radius: 50%;
}

.loc-dots {
  display: inline-flex;
  gap: 5px;
  margin-left: 4px;
  vertical-align: middle;
}

.loc-dots i {
  width: 9px;
  height: 9px;
  background: var(--line);
  border-radius: 50%;
}

.loc-dots i.on {
  background: var(--ok);
}

.loc-far {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: 14px;
}

.loc-far > span {
  font-size: 30px;
  line-height: 1.1;
}

.loc-far b {
  font-size: 15.5px;
}

.loc-far p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.loc-note {
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border-radius: 10px;
}

.loc-foot {
  margin: 4px 6px 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

/* ---------- ปุ่ม/สวิตช์ ---------- */
.loc-ctl {
  display: grid;
  gap: 12px;
}

.loc-tog {
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
}

.loc-tog > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.loc-tog b {
  font-size: 14.5px;
  font-weight: 600;
}

.loc-tog small {
  font-size: 12px;
  color: var(--muted);
}

.loc-tog input {
  position: relative;
  flex: none;
  order: 2;
  width: 46px;
  height: 28px;
  margin: 0 0 0 auto;
  cursor: pointer;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s;
  appearance: none;
}

.loc-tog input::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  content: "";
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 35%);
  transition: transform 0.2s var(--ease);
}

.loc-tog input:checked {
  background: var(--ok);
}

.loc-tog input:checked::before {
  transform: translateX(18px);
}

.loc-horn,
.loc-ghost {
  justify-self: start;
  height: 38px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--card-hover);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.loc-cta {
  width: 100%;
  min-height: 46px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 14px;
  transition: transform 0.1s, background 0.15s;
}

.loc-wait .loc-cta,
.loc-end .loc-cta {
  width: auto;
  min-width: 160px;
  margin-top: 6px;
}

.loc-horn:active,
.loc-ghost:active,
.loc-cta:active {
  transform: scale(0.97);
}

.loc-cta.is-on {
  color: #fff;
  background: var(--ok);
}

.loc-cta.big {
  min-height: 56px;
  font-size: 18px;
}

.loc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ---------- หาขบวน ---------- */
.loc-cands {
  gap: 8px;
}

.loc-cand {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 18px;
  transition: background 0.15s, transform 0.1s;
}

.loc-cand:hover {
  background: var(--card-hover);
}

.loc-cand:active {
  transform: scale(0.98);
}

.loc-cand.is-top {
  padding: 16px 14px;
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--tbg, #1968ab) 26%, transparent), transparent 70%),
    var(--card);
  border-color: color-mix(in srgb, var(--tbg, #1968ab) 70%, var(--line));
}

.loc-cand-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.loc-cand-q {
  font-size: 14.5px;
  line-height: 1.45;
}

.loc-cand-q b {
  margin-right: 4px;
  font-weight: 700;
}

.is-top .loc-cand-q {
  font-size: 16px;
}

.loc-cand-main small {
  font-size: 12px;
  color: var(--muted);
}

.loc-cand-yes {
  flex: none;
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: var(--ok);
  border-radius: 999px;
}

.loc-manual {
  display: grid;
  gap: 8px;
}

.loc-lbl {
  margin: 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.loc-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font: 600 16px var(--mono);
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}

.loc-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ---------- บนขบวน ---------- */
.loc-gps {
  margin: 0;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border-radius: 10px;
}

.loc-gps.is-ok {
  color: var(--ok-t);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.loc-gps.is-warn {
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
}

.loc-gps.is-bad {
  color: var(--bad-t);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.loc-gps-chip {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ok-t);
  background: color-mix(in srgb, var(--ok) 13%, transparent);
  border-radius: 999px;
}

.loc-speed {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 14px;
}

.loc-gauge {
  width: 220px;
  max-width: 100%;
  height: auto;
}

.loc-gauge-bg,
.loc-gauge-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.loc-gauge-bg {
  stroke: var(--line);
}

.loc-gauge-fg {
  stroke: var(--accent);
  transition: stroke-dasharray 0.8s var(--ease);
}

.loc-speed-n {
  margin-top: -64px;
  font-size: 54px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.loc-speed-u {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.loc-speed-k {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.loc-next {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.loc-next > div:first-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.loc-k {
  font-size: 12.5px;
  color: var(--muted);
}

.loc-next-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.loc-next small {
  font-size: 13px;
  color: var(--muted);
}

.loc-next-time {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
}

.loc-next-time b {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--accent);
}

.loc-next-time span {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 600;
}

.loc-prog-ends {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.loc-prog {
  position: relative;
  height: 10px;
  margin: 18px 14px 12px;
  background: var(--line);
  border-radius: 999px;
}

.loc-prog-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 35%, transparent), var(--accent));
  border-radius: inherit;
  transition: width 1s linear;
}

.loc-prog-train {
  --i: 16px;

  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(0 0 0 / 30%);
  transition: left 1s linear;
}

.loc-dest-txt {
  margin: 0;
  font-size: 13.5px;
  text-align: center;
}

.loc-stops {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loc-stops li {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  font-size: 14px;
  border-radius: 10px;
}

.loc-stops li:nth-child(odd) {
  background: var(--card);
}

.loc-stops li.is-next {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.loc-stops .mono {
  font-size: 13.5px;
  color: var(--muted);
}

.loc-stops b {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-stops small {
  font-size: 12px;
  color: var(--muted);
}

.loc-alarm-card {
  display: grid;
  gap: 10px;
}

.loc-alarm-card .loc-h {
  margin: 0;
}

.loc-alarm-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 8px;
}

.loc-sel {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.loc-sel span {
  font-size: 12px;
  color: var(--muted);
}

.loc-sel select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* ---------- ปุ่มลอยเมื่อย่อ ---------- */
.loc-pill {
  position: fixed;
  bottom: 102px;
  left: calc(32px + var(--panel-w));
  z-index: 1150;
  max-width: min(460px, calc(100vw - var(--panel-w) - 48px));
  padding: 10px 18px;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--panel-solid);
  border: 2px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: loc-pill-in 0.3s var(--ease);
}

.loc-pill:hover {
  background: var(--card-hover);
}

/* ---------- หน้าต่างปลุก ---------- */
.loc-alarm {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(2 6 23 / 62%);
  backdrop-filter: blur(4px);
}

.loc-alarm-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: min(380px, 100%);
  padding: 26px 22px 22px;
  text-align: center;
  background: var(--panel-solid);
  border: 2px solid var(--warn);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.loc-alarm-ico {
  font-size: 64px;
  line-height: 1;
  animation: loc-shake 0.5s ease-in-out infinite;
}

.loc-alarm-box h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
}

.loc-alarm-box p {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- หมุดบนแผนที่ ---------- */
.loc-x-icon,
.loc-gps-icon {
  background: none;
  border: 0;
}

.loc-x {
  position: absolute;
  top: -22px;
  left: -22px;
  width: 44px;
  height: 44px;
  cursor: grab;
  pointer-events: auto;
}

.loc-x:active {
  cursor: grabbing;
}

.loc-x-ring {
  position: absolute;
  inset: 0;
  border: 3px solid #facc15;
  border-radius: 50%;
  animation: loc-ring 1.8s ease-out infinite;
}

.loc-x-sign {
  --i: 22px;

  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  color: #dc2626;
  background: #fff;
  border: 3px solid #dc2626;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(0 0 0 / 45%);
}

.loc-gpsm {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

.loc-gpsm-ring {
  position: absolute;
  inset: -8px;
  border: 3px solid #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 14px rgb(34 197 94 / 70%);
  animation: loc-ring 2s ease-out infinite;
}

.loc-gpsm-puck {
  --i: 20px;

  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgb(0 0 0 / 50%);
}

.loc-gpsm-label {
  position: absolute;
  top: 46px;
  left: 50%;
  padding: 1px 8px;
  font: 600 12px/18px var(--mono);
  color: #fff;
  white-space: nowrap;
  background: #15803d;
  border-radius: 999px;
  transform: translateX(-50%);
}

.is-sched .loc-gpsm-ring {
  border-color: var(--idle, #94a3b8);
  border-style: dashed;
  box-shadow: none;
  animation: none;
}

.is-sched .loc-gpsm-label {
  background: #475569;
}

/* หมุดประมาณการของขบวนที่เรานั่งอยู่ (ใช้หมุด GPS แทน) */
.leaflet-marker-icon.loc-hidden {
  display: none;
}

/* ---------- มือถือ: แผ่นเลื่อนด้านล่าง ---------- */
@media (max-width: 899px) {
  .locate {
    transform: translateY(calc(48dvh - 48px));
  }

  .locate[data-snap="full"] {
    transform: none;
  }

  .locate[data-snap="half"] .dt-body {
    padding-bottom: calc(48dvh - 24px);
  }

  .loc-head {
    padding-top: 0;
  }

  .loc-title {
    margin-top: 6px;
  }

  .loc-title h2 {
    font-size: 21px;
  }

  .loc-title-ico {
    width: 38px;
    height: 38px;
  }

  /* เลื่อนรายการลง → หัวแผงส้มย่อเหลือแถวปุ่ม (locate.js .is-compact) — เดิมกินจอ iPhone SE ~40% ตลอดการเลื่อน
     ชื่อยังอยู่ให้โปรแกรมอ่านจอ (มองไม่เห็นเท่านั้น) · คำเตือนความปลอดภัยอยู่ในเนื้อหา ไม่กระทบ */
  .loc-head.is-nearby .loc-title,
  .loc-head.is-nearby .loc-place {
    max-height: 120px;
  }

  .loc-head.is-nearby.is-compact {
    padding-bottom: 14px;
  }

  .loc-head.is-nearby.is-compact .loc-title,
  .loc-head.is-nearby.is-compact .loc-place {
    min-height: 0;
    max-height: 0;
    margin: 0;
    overflow: hidden;
    opacity: 0;
  }

  .loc-count {
    font-size: 42px;
  }

  .loc-speed {
    padding: 8px 12px 10px;
  }

  .loc-gauge {
    width: 170px;
  }

  .loc-speed-n {
    margin-top: -50px;
    font-size: 46px;
  }

  .loc-speed-k {
    margin-top: 2px;
  }

  .loc-head.is-train .dt-kicker {
    margin-top: 2px;
  }

  .loc-pill {
    inset: calc(10px + env(safe-area-inset-top)) 62px auto 10px;
    max-width: none;
    padding: 10px 14px;
    font-size: 14px;
    text-align: center;
  }

  .has-locpill .legend {
    visibility: hidden;
  }
}

/* หัวแผงย่อ/กาง ค่อยๆ เลื่อน (ปิดเมื่อผู้ใช้ขอลดการเคลื่อนไหว) */
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  .loc-head.is-nearby,
  .loc-head.is-nearby .loc-title,
  .loc-head.is-nearby .loc-place {
    transition: max-height 0.2s var(--ease), margin 0.2s var(--ease), padding 0.2s var(--ease), opacity 0.15s;
  }
}

/* มือถือแนวนอน: แผงอยู่ซ้ายสูงตามเนื้อหา เลื่อนทั้งแผ่น (app.css) · ปุ่มลอยอยู่บนแผนที่ด้านขวา */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .locate,
  .locate[data-snap] {
    bottom: auto;
    max-height: calc(100dvh - 16px);
    transform: none;
  }

  .locate[data-snap="half"] .dt-body {
    padding-bottom: 16px;
  }

  .loc-count {
    font-size: 34px;
  }

  .loc-pill {
    inset: calc(8px + env(safe-area-inset-top)) 62px auto calc(var(--side-l) + var(--side-w) + 8px);
  }
}

@media (max-width: 380px) {
  .loc-count {
    font-size: 38px;
  }

  .loc-hero-txt b {
    font-size: 16px;
  }

  .loc-speed-n {
    font-size: 42px;
  }

  .loc-next-name {
    font-size: 19px;
  }
}

/* ---------- animations ---------- */
@keyframes loc-pulse {
  50% {
    opacity: 0.75;
    transform: scale(1.08);
  }
}

@keyframes loc-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes loc-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.8);
  }

  100% {
    opacity: 0;
    transform: scale(1.7);
  }
}

@keyframes loc-shake {
  25% {
    transform: rotate(-12deg);
  }

  75% {
    transform: rotate(12deg);
  }
}

@keyframes loc-pill-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- ใกล้ฉัน: หัวข้อส่วน · สถานะพิเศษ · สถานีใกล้คุณ · ปุ่ม "ฉันอยู่บนรถไฟ" ---------- */
.loc-h > svg {
  --i: 17px;

  flex: none;
  width: var(--i);
  height: var(--i);
  color: var(--accent);
}

.loc-h.sub {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--muted);
}

.loc-hero-state {
  padding: 5px 12px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 10px;
}

/* เลยเวลาคาด / ตามตาราง: ไม่ใช่ตัวเลขนับถอยหลังใหญ่สีสด */
.loc-hero.is-overdue .loc-count,
.loc-count.is-overdue,
.loc-count.is-sched {
  font-size: 22px;
  line-height: 1.35;
  color: var(--warn-t);
  animation: none;
}

.loc-link {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
}

.loc-sts {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.loc-st {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.loc-st-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.loc-st-name {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.loc-st-name b {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-st-name small {
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
}

.loc-st-board {
  --i: 15px;

  display: inline-flex;
  flex: none;
  gap: 5px;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 10px;
}

.loc-st-board svg {
  width: var(--i);
  height: var(--i);
}

.loc-st-none {
  margin: 8px 0 2px;
  font-size: 13px;
  color: var(--muted);
}

.loc-arrs {
  display: grid;
  gap: 2px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.loc-arr {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 4px 6px;
  text-align: left;
  border-radius: 10px;
}

.loc-arr:hover {
  background: var(--card-hover);
}

.loc-arr-time {
  flex: none;
  min-width: 52px;
  font-size: 15px;
  font-weight: 600;
}

.loc-arr-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loc-arr-cd {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.loc-st .si-act {
  margin-top: 8px;
}

.loc-st .si-btn {
  min-height: 42px;
  font-size: 13.5px;
}

.loc-st .si-none {
  margin-top: 6px;
}

.loc-ob-cta {
  --i: 22px;

  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  text-align: left;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 16px;
}

.loc-ob-cta > svg {
  flex: none;
  width: var(--i);
  height: var(--i);
  color: var(--accent);
}

.loc-ob-cta span {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.loc-ob-cta b {
  font-size: 15.5px;
}

.loc-ob-cta small {
  font-size: 12.5px;
  color: var(--muted);
}

.loc-ob-cta i {
  font-size: 22px;
  font-style: normal;
  opacity: 0.6;
}

.loc-row.is-overdue .loc-row-time small {
  color: var(--warn-t);
}

.loc-row-time small .is-sched {
  color: var(--muted);
}

.loc-arr-cd small.is-overdue {
  display: block;
  max-width: 150px;
  color: var(--warn-t);
  text-align: right;
  white-space: normal;
}

.loc-pin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin: -4px 4px 2px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.loc-pin-bar.is-custom {
  padding: 6px 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: 10px;
}

.loc-pin-reset {
  flex: none;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 999px;
}

/* ---------- จอสัมผัส: พื้นที่แตะ ≥ 40 px ---------- */
@media (pointer: coarse) {
  .loc-horn,
  .loc-ghost,
  .loc-st-board,
  .loc-pin-reset {
    min-height: 40px;
  }
}



/* css/rolling.css */
/* รู้จักรถไฟ — ภาพหัวรถจักรในแผงขบวน (สไตล์ FlightRadar) + แกลเลอรี "รู้จักรถไฟไทย"
   ใช้ตัวแปรสีจาก app.css (ธีมมืด/สว่าง) */

/* ---------- แถบภาพใต้หัวแผงขบวน ---------- */
.dt-stock {
  flex: none;
  padding: 12px 14px 0;
}

.dt-stock:empty,
.dt-stock-info:empty {
  display: none;
}

.stk-hero {
  position: relative;
  height: clamp(132px, 19vh, 168px);
  margin: 0;
  overflow: hidden;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgb(0 0 0 / 14%);
  transition: height 0.25s var(--ease);
}

/* แผงขบวน: ภาพเป็นแถบเต็มกว้างต่อจากหัวแผงสี (ไม่มีช่องว่าง) มุมล่างโค้ง — ชดเชย padding ของ .dt-body */
.dt-body > .dt-stock > .stk-hero:not(.is-none, .big) {
  margin: -12px -14px 0;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 12px 22px -10px rgb(0 0 0 / 45%);
}

/* ขอบบนเข้มนิดๆ ให้ภาพกลืนกับหัวแผง */
.dt-body > .dt-stock > .stk-hero:not(.is-none, .big)::after {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 18px;
  pointer-events: none;
  content: "";
  background: linear-gradient(rgb(0 0 0 / 28%), transparent);
}

.stk-img,
.stk-noimg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 55%;
}

.stk-noimg {
  background: linear-gradient(135deg, var(--card-hover), var(--card));
}

.stk-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 10px 9px;
  color: #fff;
  text-decoration: none;
  background:
    linear-gradient(to top, rgb(3 7 18 / 82%) 0%, rgb(3 7 18 / 38%) 42%, transparent 64%),
    linear-gradient(to bottom, rgb(3 7 18 / 42%), transparent 34%);
  border-radius: inherit;
  transition: background-color 0.15s;
}

.stk-hit:hover {
  background-color: rgb(255 255 255 / 6%);
}

.stk-hit:focus-visible {
  outline-offset: -3px;
}

.stk-chip {
  display: inline-flex;
  flex: none;
  gap: 6px;
  align-items: center;
  align-self: flex-start;
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 999px;
}

.stk-chip::before {
  width: 7px;
  height: 7px;
  content: "";
  background: currentcolor;
  border-radius: 50%;
}

.stk-hit .stk-chip {
  color: #fff;
  background: rgb(3 7 18 / 62%);
  border: 1px solid rgb(255 255 255 / 22%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.stk-hit .stk-chip.conf-high::before {
  background: #4ade80;
}

.stk-hit .stk-chip.conf-medium::before {
  background: #38bdf8;
}

.stk-hit .stk-chip.conf-low::before {
  background: #fbbf24;
}

.stk-cap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-shadow: 0 1px 3px rgb(0 0 0 / 60%);
}

.stk-cap small {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0.88;
}

.stk-cap b {
  display: flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
}

.stk-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ชิปรหัสหดก่อนชื่อ (flex-shrink สูงกว่ามาก) จนเหลือ ~3.5em แล้วชื่อค่อยหด */
.stk-cap b i {
  flex: 0 100 auto;
  min-width: 3.5em;
  max-width: 48%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stk-cap b i,
.stk-codes {
  padding: 1px 7px;
  font: 600 12px/1.5 var(--mono);
  font-style: normal;
  background: rgb(255 255 255 / 18%);
  border-radius: 6px;
  text-shadow: none;
}

.stk-cap em {
  overflow: hidden;
  font-size: 12.5px;
  font-style: normal;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.92;
}

/* เครดิตภาพ: มุมขวาบนของภาพเสมอ */
.stk-hero figcaption {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  max-width: 52%;
}

.stk-credit {
  display: block;
  overflow: hidden;
  padding: 2px 7px;
  font-size: 10.5px;
  line-height: 1.5;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: rgb(3 7 18 / 68%);
  border-radius: 6px;
}

.stk-credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgb(255 255 255 / 45%);
  text-underline-offset: 2px;
}

/* ปุ่มขยายแถบภาพ ใช้เฉพาะมือถือ */
.stk-toggle {
  display: none;
}

/* ---------- การ์ดข้อมูลในแผงขบวน ---------- */
.stk-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stk-info-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}

.stk-info-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.stk-info .stk-chip.conf-high,
.stk-body .stk-chip.conf-high {
  color: var(--ok-t);
  background: color-mix(in srgb, var(--ok) 15%, transparent);
}

.stk-info .stk-chip.conf-medium {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.stk-info .stk-chip.conf-low {
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 15%, transparent);
}

.stk-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stk-specs > div {
  min-width: 0;
  padding: 7px 10px 8px;
  background: var(--panel-solid);
}

.stk-specs > div:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.stk-specs dt {
  font-size: 11.5px;
  color: var(--muted);
}

.stk-specs dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.stk-fact {
  margin: 0;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.6;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
}

.stk-fact b {
  color: var(--accent);
}

.stk-note a,
.stk-ref a {
  color: var(--accent);
}

.stk-note-main {
  display: block;
  color: var(--text);
}

.stk-alt {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.stk-alt a {
  padding: 3px 9px;
  font: 600 12px/1.5 var(--mono);
  color: var(--text);
  text-decoration: none;
  background: var(--card-hover);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stk-alt a:hover {
  border-color: var(--accent);
}

.stk-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.stk-more {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background 0.15s, transform 0.1s;
}

.stk-more:hover {
  background: var(--card-hover);
}

.stk-more:active {
  transform: scale(0.98);
}

/* ---------- ทางเข้าแกลเลอรีในแท็บโปรด ---------- */
.stk-entry {
  --i: 22px;

  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 4px 8px;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  background: linear-gradient(135deg, color-mix(in srgb, #0f766e 22%, var(--card)), var(--card));
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background 0.15s, transform 0.1s;
}

.stk-entry:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.stk-entry:active {
  transform: scale(0.98);
}

.stk-entry-ico {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: linear-gradient(150deg, #14b8a6, #0f766e);
  border-radius: 12px;
}

.stk-entry-txt {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.stk-entry-txt b {
  font-size: 15px;
}

.stk-entry-txt small {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.stk-entry-go {
  flex: none;
  font-size: 18px;
  color: var(--accent);
}

/* ---------- แกลเลอรี "รู้จักรถไฟไทย" ---------- */
.stk-head {
  color: #fff;
  background: linear-gradient(150deg, #0f766e, #0b1f3a 78%);
}

.stk-head a.dt-btn {
  color: inherit;
}

.stk-title {
  margin: 12px 0 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

.stk-sub {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.94;
}

.stk-sec .sec-title {
  margin-top: 4px;
}

.stk-sec .count {
  color: var(--muted);
  background: var(--card-hover);
}

.stk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stk-tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: transform 0.15s var(--ease), box-shadow 0.15s, border-color 0.15s;
}

.stk-tile:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stk-tile:active {
  transform: scale(0.98);
}

.stk-tile-img {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--card-hover);
}

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

.stk-tile-txt {
  display: flex;
  flex-direction: column;
  padding: 7px 10px 9px;
}

.stk-tile-txt b {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.stk-tile-txt em {
  margin-top: 2px;
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}

/* หน้ารายละเอียดรถแต่ละแบบ (ลูกของ flex column ห้ามหด) */
.stk-body > * {
  flex: none;
}

.stk-hero.big {
  height: auto;
  aspect-ratio: 16 / 9;
}

.stk-hero.big .stk-codes {
  position: absolute;
  top: 10px;
  left: 10px;
  color: #fff;
  background: rgb(3 7 18 / 62%);
}

.stk-hero.big figcaption {
  top: auto;
  bottom: 8px;
  max-width: calc(100% - 16px);
}

.stk-hero.big .stk-credit {
  white-space: normal;
}

.stk-live h3 {
  margin: 0 0 2px;
  font-size: 14.5px;
  font-weight: 700;
}

.stk-live-hint {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.stk-live ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stk-run {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 6px 8px;
  color: var(--text);
  text-decoration: none;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stk-run:hover {
  border-color: var(--accent);
}

.stk-run b {
  flex: none;
  min-width: 38px;
  padding: 1px 6px;
  font: 600 13px/1.6 var(--mono);
  color: var(--accent-ink);
  text-align: center;
  background: var(--accent);
  border-radius: 7px;
}

.stk-run small {
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stk-en {
  margin: -4px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.stk-duty h3,
.stk-facts h3 {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 700;
}

.stk-duty p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.stk-facts {
  background: color-mix(in srgb, var(--accent) 7%, var(--card));
}

.stk-facts h3 {
  color: var(--accent);
}

.stk-facts ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stk-facts li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.stk-facts li::before {
  position: absolute;
  top: 0.62em;
  left: 3px;
  width: 7px;
  height: 7px;
  content: "";
  background: var(--accent);
  border-radius: 50%;
}

.stk-ref {
  margin: 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}

@media (min-width: 900px) and (max-height: 780px) {
  .stk-hero {
    height: 120px;
  }
}

@media (max-width: 899px) {
  .dt-stock {
    padding: 10px 12px 0;
  }

  /* มือถือ: แถบภาพเตี้ย (เห็นการ์ดสรุปตอนแผ่นครึ่งจอ) · "ดูรูปใหญ่" ขยายสูงขึ้น (จำค่าไว้) */
  .stk-hero {
    height: 118px;
  }

  .stk-hero.is-open {
    height: 210px;
  }

  .dt-body > .dt-stock > .stk-hero:not(.is-none, .big) {
    margin: -10px -12px 0;
    border-radius: 0 0 18px 18px;
  }

  .stk-hit {
    padding: 8px 12px 9px;
  }

  .stk-hero:not(.big) .stk-hit {
    padding-right: 112px;
  }

  .stk-cap b {
    font-size: 17px;
  }

  .stk-hero:not(.is-open, .big) .stk-cap small {
    display: none;
  }

  .stk-toggle {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    background: rgb(3 7 18 / 62%);
    border: 1px solid rgb(255 255 255 / 25%);
    border-radius: 999px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }

  .stk-toggle::before {
    order: 2;
    font-size: 10px;
    content: "▲";
  }

  .stk-hero:not(.is-open, .big) .stk-toggle::before {
    content: "▼";
  }

  .stk-toggle::after {
    position: absolute;
    inset: -8px;
    content: "";
  }

  .stk-head .dt-grip {
    --grip: #fff;
  }

  .stk-title {
    margin-top: 6px;
    font-size: 21px;
  }
}

/* มือถือจอแคบ/แนวนอน: แถบเตี้ยไม่มีที่พอทั้งชื่อรุ่นและชิปรหัส → ซ่อนชิป (รหัสอยู่ในภาพขยายและการ์ดข้อมูลด้านล่าง)
   ชื่อรุ่นไม่ถูกตัดเหลือ "Da…" */
@media (max-width: 480px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .stk-hero:not(.is-open, .big) .stk-cap b i {
    display: none;
  }
}

@media (max-width: 380px) {
  .stk-hero:not(.big) .stk-hit {
    padding-right: 100px;
  }

  .stk-hero:not(.is-open, .big) .stk-cap em {
    display: none;
  }

  .stk-toggle {
    padding: 0 10px;
  }
}

/* มือถือจอเตี้ย (iPhone SE ฯลฯ): แถบภาพบาง 66px (ป้าย "ใช้เป็นประจำ" + ชื่อรุ่น + เครดิต + ดูรูปใหญ่ ครบ)
   แผ่นครึ่งจอเห็นบรรทัดสถานะของการ์ดสรุปทันที (เจ้าของขอ 2 ต.ค.) · แตะ "ดูรูปใหญ่" ขยายได้ */
@media (max-width: 899px) and (max-height: 700px) and (orientation: portrait) {
  .stk-hero {
    height: 66px;
  }

  .stk-hero.is-open {
    height: 180px;
  }

  .stk-hero:not(.is-open, .big) .stk-hit {
    padding: 5px 96px 6px 10px;
  }

  .stk-hero:not(.is-open, .big) .stk-chip {
    height: 20px;
    padding: 0 7px;
    font-size: 10.5px;
  }

  .stk-hero:not(.is-open, .big) .stk-cap em {
    display: none;
  }

  .stk-hero:not(.is-open, .big) .stk-cap b {
    font-size: 15px;
  }

  .stk-hero:not(.is-open, .big) .stk-toggle {
    bottom: 7px;
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* จอเตี้ย + แผ่นขบวนครึ่งจอ: แถบภาพบางลงอีก 66 → 52 px ให้บรรทัด "กำลังวิ่ง · ช้า N นาที" เห็นทันทีโดยไม่ต้องลากขึ้น
   (เจ้าของสั่ง: รูปอยู่บนสุดเหมือนเดิม ห้ามย้ายลำดับ — แค่เตี้ยลง) · ชิป "ใช้เป็นประจำ" + เครดิตภาพ + ดูรูปใหญ่ ยังอยู่ครบ
   ลากแผ่นขึ้นเต็มจอ = กลับเป็น 66 px · แตะ "ดูรูปใหญ่" = ขยายตามเดิม */
@media (max-width: 899px) and (max-height: 700px) and (orientation: portrait) {
  .detail:not([data-snap="full"]) .dt-stock > .stk-hero:not(.is-open, .big) {
    height: 52px;
  }

  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) .stk-hit {
    padding: 4px 92px 5px 10px;
  }

  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) .stk-chip {
    height: 19px;
    font-size: 10.5px;
  }

  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) .stk-cap b {
    font-size: 14px;
    line-height: 1.2;
  }

  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) figcaption {
    top: 4px;
  }

  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) .stk-credit {
    padding-block: 0;
  }

  /* ปุ่มดูรูปใหญ่สูงเท่าเดิม (28) อยู่ใต้เครดิตภาพพอดี ไม่ทับกัน */
  .detail:not([data-snap="full"]) .stk-hero:not(.is-open, .big) .stk-toggle {
    bottom: 4px;
  }

  /* ระยะห่างภาพ ↔ การ์ดสรุป ชิดขึ้นเล็กน้อย */
  .detail:not([data-snap="full"]) .dt-body > .dt-stock + .dt-summary {
    margin-top: -4px;
  }
}

@media (min-width: 560px) and (max-width: 899px) {
  .stk-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* มือถือแนวนอน: แผงแคบ (แผ่นด้านซ้าย) → แกลเลอรี 2 คอลัมน์ ภาพหัวรถจักรเตี้ยลง */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .stk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stk-hero {
    height: 120px;
  }

  .stk-hero.is-open {
    height: 170px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stk-hero,
  .stk-tile,
  .stk-more {
    transition: none;
  }

  .stk-tile:hover {
    transform: none;
  }
}

/* ไม่รู้รุ่นรถของขบวนนี้ (ความมั่นใจต่ำ): แถบข้อความเล็ก ไม่มีภาพ/ชื่อรุ่น */
.stk-hero.is-none {
  height: auto;
  box-shadow: none;
}

.stk-hero.is-none .stk-hit {
  position: static;
  gap: 2px;
  padding: 10px 12px;
  color: var(--text);
  background: none;
}

.stk-hero.is-none .stk-cap b {
  font-size: 14.5px;
  font-weight: 600;
}

.stk-hero.is-none .stk-cap small {
  color: var(--accent);
}

.stk-hero.is-none .stk-cap {
  text-shadow: none;
}

/* css/kidmode.css */
/* โหมดเด็ก 🧒 (public/js/kidmode.js) — ทุกกฎอยู่ใต้ html.kid ยกเว้นปุ่มเปิด/ปิด การ์ด แถบเกม และฉลอง
   หมุดหน้ารถไฟยิ้มสีตามข้อมูล รฟท. (--tbg/--tfg ตั้งโดย map.js) · ใช้ได้ทั้งโหมดมืด/สว่าง */

/* ---------- ปุ่ม 🧒 โหมดเด็ก (ต่อจากปุ่มหลักของผู้ใหญ่ เห็นในจอแรกไม่ต้องเลื่อน · ตอนเปิดโหมดเด็กกางเต็มแถวล่างสุด) ---------- */
.kid-toggle {
  background: color-mix(in srgb, #f472b6 8%, var(--card));
  border-color: color-mix(in srgb, #f472b6 32%, var(--line));
}

/* มือถือโหมดรายการ (แถวปัดซ้าย-ขวา): ให้ "ถามได้เลย · ซื้อตั๋ว · 🧒 โหมดเด็ก" เรียงกัน 3 ปุ่มแรก เห็นในจอแรกทันทีโดยไม่แย่งปุ่มผู้ใหญ่ */
@media (max-width: 899px) {
  html:not(.kid) .panel[data-mode="list"] .quick > #askBtn {
    order: 1;
  }

  html:not(.kid) .panel[data-mode="list"] .quick > #ticketBtn {
    order: 2;
  }

  html:not(.kid) .panel[data-mode="list"] .quick > #kidBtn {
    order: 3;
  }

  html:not(.kid) .panel[data-mode="list"] .quick > :not(#askBtn, #ticketBtn, #kidBtn) {
    order: 4;
  }
}

.kid .kid-toggle {
  grid-column: 1 / -1;
}

.kid-toggle .kid-emo {
  font-size: 19px;
  line-height: 1;
}

.kid-toggle[aria-pressed="true"] {
  color: #3b0764;
  background: linear-gradient(135deg, #fde68a, #f9a8d4);
  border-color: #fff;
}

.kid-only {
  display: none;
}

/* ---------- แผงหลักแบบเรียบง่าย ---------- */
.kid .kid-only {
  display: inline-flex;
}

/* #ticketBtn = ลิงก์ออกไปเว็บซื้อตั๋ว รฟท. · .si-btn.nav = นำทาง Google Maps (ป้ายสถานี/ใกล้ฉัน)
   — โหมดเด็กไม่มีลิงก์ออกนอกเว็บ (kidmode.js กันการแตะ → เดิมเห็นปุ่มแต่แตะแล้วไม่มีอะไรเกิด เหมือนหน้าค้าง) */
.kid .stats,
.kid #typeFilters,
.kid .list-head,
.kid .tabs,
.kid .legend,
.kid #nearBtn,
.kid #onboardBtn,
.kid #ticketBtn,
.kid #askBtn,
.kid #fbBtn,
.kid .si-btn.nav,
.kid .page-links,
.kid .si-act,
.kid .si-note a,
.kid .si-src a,
.kid .loc-st-call,
.kid .stk-ref,
.kid .stk-contribute,
.kid .ms-wrap,
.kid .pwa-chip,
.kid .row .pill {
  display: none;
}

.kid .panel {
  border-radius: 28px;
}

.kid .panel,
.kid .detail,
.kid .map-ctl .fab {
  background: var(--panel-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.kid-game,
.kid-card-actions button,
.kid-acts button,
.kid-play button,
.kid .quick button {
  touch-action: manipulation;
}

.kid-card,
.kid-play {
  touch-action: pan-y;
}

.kid .brand h1 {
  font-size: 22px;
}

.kid .quick {
  gap: 10px;
  margin-top: 12px;
}

.kid .quick .chip-btn {
  --i: 22px;

  gap: 6px;
  height: 58px;
  padding: 0 8px;
  font-size: 16px;
  font-weight: 700;
  border-width: 2px;
  border-radius: 20px;
}

.kid .kid-emo {
  font-size: 22px;
  line-height: 1;
}

/* ลำดับปุ่ม: ตามหารถไฟ · สุ่ม · รู้จักรถไฟ · รถไฟผ่านใกล้ฉัน · ออกจากโหมดเด็ก (เต็มแถว ล่างสุด) */
.kid #kidGameBtn {
  order: 1;
  background: color-mix(in srgb, #facc15 20%, var(--panel-solid));
  border-color: color-mix(in srgb, #facc15 65%, transparent);
}

.kid #randomBtn {
  order: 2;
  background: color-mix(in srgb, #38bdf8 16%, var(--panel-solid));
  border-color: color-mix(in srgb, #38bdf8 55%, transparent);
}

.kid #kidGalleryBtn {
  order: 3;
  background: color-mix(in srgb, #f472b6 15%, var(--panel-solid));
  border-color: color-mix(in srgb, #f472b6 55%, transparent);
}

/* ปุ่มในแถวมี 5 ปุ่ม (ซ่อนปุ่มซื้อตั๋วแล้ว) → "ใกล้ฉัน" เต็มแถว ไม่เหลือช่องว่างข้างๆ */
.kid #nearbyBtn {
  order: 4;
  grid-column: 1 / -1;
  background: color-mix(in srgb, #4ade80 14%, var(--panel-solid));
  border-color: color-mix(in srgb, #4ade80 50%, transparent);
}

.kid #kidBtn {
  order: 5;
  height: 48px;
  font-size: 15px;
}

.kid-star-n {
  min-width: 26px;
  padding: 2px 7px;
  font: 700 14px/1.3 var(--mono);
  color: #422006;
  background: #fde047;
  border-radius: 999px;
}

.kid .views {
  margin-top: 6px;
}

.kid .row {
  gap: 14px;
  padding: 10px;
  border-radius: 20px;
}

.kid .row-route {
  font-size: 16px;
  font-weight: 700;
}

.kid .badge {
  border-radius: 16px;
}

/* ลิงก์ออกนอกเว็บ (เครดิต/แหล่งข้อมูล) แสดงเป็นข้อความธรรมดา */
.kid a[target="_blank"],
.kid .leaflet-control-attribution a {
  color: inherit;
  text-decoration: none;
  pointer-events: none;
}

/* ---------- หมุดหน้ารถไฟยิ้ม ---------- */

/* เกม: ขบวนอื่นจางลง ให้ขบวนเป้าหมายเด่น */
.has-kidhunt .map .tm:not(.is-target) {
  opacity: 0.45;
}

:root.kid .map .tm {
  --s: 40px;
  --c: var(--tbg, #1968ab);
}

:root.kid .map.zm .tm {
  --s: 36px;
}

:root.kid .map.zs .tm {
  --s: 32px;
}

:root.kid .map .tm.is-sel {
  --s: 46px;
}

:root.kid .map .tm .tm-puck {
  inset: -3px -1px;
  display: block;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  transition: transform 0.25s var(--ease);

  /* เงาใต้หน้ารถวาดในสัญลักษณ์ #k-face เอง (--ksh = ความเข้มเงา) — ห้ามใช้ filter: drop-shadow กับหมุด/ฟองบนแผนที่:
     WebKit (iPhone) วาด drop-shadow ด้วย CPU ทุกครั้งที่วาดหมุดใหม่ × หมุดเป็นร้อย → แผนที่เลื่อน/flyTo ค้างหลายวินาที
     การ์ดเด็กที่เพิ่งเปิดยังเลื่อนขึ้นมาไม่ได้ (เด็กแตะซ้ำๆ = "หน้าเว็บค้าง") · วัดใน WebKit: flyTo ค้าง 2.5–4 วิ → < 0.1 วิ */
  --ksh: 0.3;
}

.tm-face {
  width: 100%;
  height: 100%;
}

:root.kid .map .tm .tm-arrow {
  inset: -12px;
}

/* ลูกศรทิศทาง: ไม่ใช้เงา filter ของ app.css ในโหมดเด็ก (เหตุผลเดียวกับหมุด — ขอบขาวของลูกศรพอให้เห็นบนแผนที่) */
:root.kid .map .tm-heading-svg {
  filter: none;
}

:root.kid .map .tm.is-rough::after, :root.kid .map .tm.is-ahead::after {
  display: none;
}

:root.kid .map .tm.is-stale .tm-puck {
  --tbg: #64748b;

  opacity: 0.45;
  color: #64748b;
}

/* เลขขบวนใต้หน้ารถ (เห็นเสมอ) สีเดียวกับขบวน */
:root.kid .map .tm .tm-label {
  top: calc(100% + 1px);
  left: 50%;
  display: block;
  padding: 3px 7px;
  font: 700 12.5px/1 var(--mono);
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
  border: 1.5px solid #fff;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
  transform: translateX(-50%);
}

:root.kid .map.zs .tm:not(.is-sel) .tm-label {
  font-size: 11px;
}

/* ขบวนสินค้า: ป้ายชนิดสินค้าที่มุม (คอนเทนเนอร์/น้ำมัน/ก๊าซ/ปูน/พัสดุ) */
.tm-kind {
  --i: 12px;

  position: absolute;
  right: -6px;
  bottom: 3px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #7c4f24;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgb(0 0 0 / 45%);
}

/* เกม: ขบวนเป้าหมายกระโดด + วงแสง */
:root.kid .map .tm.is-target::after {
  position: absolute;
  inset: -10px;
  content: "";
  border: 3px solid #facc15;
  border-radius: 50%;
  box-shadow: 0 0 16px #facc15;
}

/* กลุ่มหมุดในโหมดเด็ก: หน้ารถไฟสีที่มีมากที่สุด ซ้อนกับคันสีถัดไป + ป้ายจำนวน (สีจาก map.js) */
.tg-face {
  display: none;
}

:root.kid .tg {
  background: none;
  box-shadow: none;
}

:root.kid .tg::before,
:root.kid .zs .tg::before {
  inset: 10% -16% 12% 26%;
  background: var(--tbg2, #1968ab);
  border: 2px solid #fff;
  border-radius: 32%;
  box-shadow: 0 2px 4px rgb(0 0 0 / 35%);
}

:root.kid .tg-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;

  /* เงาในสัญลักษณ์ (ไม่ใช้ filter — ดูหมุดด้านบน) */
  --ksh: 0.3;
}

:root.kid .tg-n,
:root.kid .zs .tg-n {
  position: absolute;
  top: -9px;
  right: -14px;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  font: 700 14.5px/1 var(--font);
  color: #1e293b;
  background: #fff;
  border: 2.5px solid var(--tbg, #1968ab);
  border-radius: 13px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 40%);
}

/* ---------- การ์ดเด็ก ---------- */
.kid-card {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1150;
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden auto;
  overscroll-behavior: contain;
  font-family: var(--font);
  color: var(--text);
  background: var(--panel-solid);
  border: 4px solid var(--tbg, #1968ab);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.kid-photo {
  position: relative;
  margin: 0;
  background: color-mix(in srgb, var(--tbg, #1968ab) 22%, var(--panel-solid));
}

.kid-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.kid-photo.is-face {
  display: grid;
  place-items: center;
  height: 170px;
}

.kid-face {
  width: 118px;
  height: 128px;
  filter: drop-shadow(0 4px 6px rgb(0 0 0 / 35%));
}

.kid-no {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 14px;
  font: 700 26px/1 var(--mono);
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
  border: 3px solid #fff;
  border-radius: 16px;
  box-shadow: 0 3px 10px rgb(0 0 0 / 35%);
}

.kid-photo figcaption {
  padding: 6px 18px 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  background: var(--panel-solid);
}

.kid-x {
  --i: 20px;

  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  height: 46px;
  padding: 0 16px 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  background: rgb(255 255 255 / 92%);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 30%);
}

.kid-body {
  padding: 12px 20px 20px;
}

.kid-title {
  margin: 0 0 12px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.3;
}

.kid-lines {
  display: grid;
  gap: 8px;
}

.kid-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}

.kid-line.kid-next {
  color: var(--ok-t);
}

.kid-fact {
  padding: 12px 14px;
  margin: 14px 0 0;
  font-size: 15.5px;
  line-height: 1.55;
  background: color-mix(in srgb, #facc15 14%, var(--panel-solid));
  border-radius: 18px;
}

.kid-fact b {
  display: block;
  margin-bottom: 2px;
  color: var(--warn-t);
}

.kid-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.kid-sound {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  height: 64px;
  padding: 0 28px;
  font-size: 21px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #22c55e, #15803d);
  border-radius: 999px;
  box-shadow: 0 6px 0 #166534, 0 10px 20px rgb(0 0 0 / 25%);
  transition: transform 0.1s, box-shadow 0.1s;
}

.kid-sound .kid-emo {
  font-size: 28px;
}

.kid-sound:active {
  box-shadow: 0 2px 0 #166534, 0 4px 10px rgb(0 0 0 / 25%);
  transform: translateY(4px);
}

.kid-more {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.kid-more .kid-emo {
  font-size: 17px;
}

.kid-more:hover {
  background: var(--card-hover);
}

/* ---------- แถบเกม "ตามหารถไฟ" ---------- */
.kid-game {
  position: fixed;
  top: 16px;
  left: calc((100vw + var(--panel-w) + 16px) / 2);
  z-index: 1120;
  display: flex;
  gap: 12px;
  align-items: center;
  width: max-content;
  max-width: min(560px, calc(100vw - var(--panel-w) - 64px));
  padding: 8px 8px 8px 12px;
  font-family: var(--font);
  color: var(--text);
  background: var(--panel-solid);
  border: 3px solid #facc15;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.kid-swatch {
  flex: none;
  width: 42px;
  height: 42px;
  background: var(--c);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--c), 0 2px 6px rgb(0 0 0 / 30%);
}

.kid-game-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.kid-game-main b {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
}

.kid-game-main small {
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.kid-game.is-nope .kid-game-main small {
  font-weight: 600;
  color: var(--warn-t);
}

.kid-stars {
  flex: none;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.kid-game-acts {
  display: flex;
  flex: none;
  gap: 8px;
  align-items: center;
}

.kid-game-x {
  --i: 16px;

  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 42px;
  padding: 0 14px 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.kid-reset {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 42px;
  padding: 0 12px 0 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 999px;
}

.kid-reset .kid-emo {
  font-size: 15px;
}

.kid-again {
  display: inline-flex;
  flex: none;
  gap: 6px;
  align-items: center;
  height: 46px;
  padding: 0 18px 0 14px;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 700;
  color: #422006;
  background: #facc15;
  border-radius: 999px;
  box-shadow: 0 4px 0 #ca8a04;
}

.kid-win {
  flex: none;
  font-size: 34px;
  line-height: 1;
}

/* ---------- ฉลองขบวนถึงปลายทาง / ได้ดาว ---------- */
.party-icon {
  pointer-events: none;
}

.party {
  position: absolute;
  top: 0;
  left: 0;
}

.party b {
  position: absolute;
  top: -64px;
  left: 0;
  padding: 6px 14px;
  font: 700 16px/1.2 var(--font);
  color: #422006;
  white-space: nowrap;
  background: #fde047;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgb(0 0 0 / 35%);
  transform: translateX(-50%);
}

.party i {
  position: absolute;
  top: -9px;
  left: -9px;
  width: 18px;
  height: 18px;
  background: #facc15;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  opacity: 0;
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 899px) {
  :root.kid {
    --peek: 260px;
  }

  .kid-card {
    inset: auto 0 0;
    width: auto;
    max-height: 84dvh;
    padding-bottom: env(safe-area-inset-bottom);
    border-width: 4px 0 0;
    border-radius: 28px 28px 0 0;
  }

  .kid-photo img {
    aspect-ratio: 2 / 1;
  }

  .kid-title {
    font-size: 21px;
  }

  .kid-line {
    font-size: 17.5px;
  }

  .kid-fact {
    font-size: 14.5px;
  }

  .kid-game {
    top: calc(10px + env(safe-area-inset-top));
    right: 64px;
    left: 10px;
    flex-wrap: wrap;
    row-gap: 6px;
    width: auto;
    max-width: none;
    padding: 8px 8px 8px 10px;
    border-radius: 24px;
    transform: none;
  }

  .kid-game-main {
    flex: 1 1 60%;
  }

  /* แผ่นเลื่อนเต็มจอ: ซ่อนแถบเกมไว้ก่อน (ไม่บังขอบแผ่น) */
  .panel[data-snap="full"] ~ .kid-game {
    visibility: hidden;
  }

  .kid-game-acts {
    margin-left: auto;
  }

  .kid-game-main b {
    font-size: 17px;
  }

  .kid-game-main small {
    font-size: 12px;
  }

  .kid-swatch {
    width: 34px;
    height: 34px;
  }

  .kid .quick .chip-btn {
    gap: 6px;
    height: 52px;
    padding: 0 8px;
    font-size: 15.5px;
  }

  .kid .panel[data-snap="peek"] .quick {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 2px 4px 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .kid .panel[data-snap="peek"] .quick::-webkit-scrollbar {
    display: none;
  }

  .kid .panel[data-snap="peek"] .quick .chip-btn {
    flex: none;
    height: 48px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .kid .panel[data-snap="peek"] #kidPlayBtn {
    order: 1;
  }

  .kid .panel[data-snap="peek"] #kidGameBtn {
    order: 2;
  }

  .kid .panel[data-snap="peek"] #kidBtn {
    order: 3;
    grid-column: auto;
  }

  .kid .panel[data-snap="peek"] #randomBtn {
    order: 4;
  }

  .kid .panel[data-snap="peek"] #nearbyBtn {
    order: 5;
    grid-column: auto;
  }

  .kid .panel[data-snap="peek"] #kidGalleryBtn {
    order: 6;
  }
}

/* จอแคบ 360 px: ตัวอักษรปุ่มเล็กลงนิด ไม่ให้อีโมจิ/ตัวเลขดาวโดนตัด */
@media (max-width: 380px) {
  .kid .quick .chip-btn {
    font-size: 14.5px;
  }

  .kid .quick .kid-emo {
    font-size: 19px;
  }

  .kid-star-n {
    min-width: 22px;
    padding: 1px 6px;
    font-size: 12.5px;
  }
}

/* จอ ≤ 360 px (iPhone SE 320, Fold 344, Android 360): ชื่อเว็บโหมดเด็ก 22px ยาวกว่าช่อง → ซ้อนปุ่ม ? · เล็กลงให้อยู่บรรทัดเดียว
   (ภาษาอังกฤษใช้ขนาดจาก nav.css ที่มาทีหลัง) */
@media (max-width: 360px) {
  .kid .brand h1 {
    font-size: 20px;
  }
}

/* แนวนอนมือถือ: วางการ์ดทับคอลัมน์ซ้าย แถบเกมอยู่ด้านขวา */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .kid .brand {
    gap: 6px;
  }

  .kid .brand h1 {
    font-size: 16px;
  }

  .kid-card {
    inset: 8px auto 8px var(--side-l);
    width: var(--side-w);
    max-height: calc(100dvh - 16px);
    border-width: 3px;
    border-radius: 22px;
  }

  .kid-game {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(68px + env(safe-area-inset-right));
    left: calc(var(--side-l) + var(--side-w) + 8px);
    width: auto;
    max-width: none;
    transform: none;
  }
}

/* จอเตี้ยแนวตั้ง: จำกัดความสูงการ์ด และซ่อนปุ่มซูมหลังการ์ด */
@media (max-width: 899px) and (max-height: 700px) and (orientation: portrait) {
  .kid-card {
    max-height: 62dvh;
  }

  .kid-photo img {
    aspect-ratio: 16 / 8;
  }

  .has-kidcard .map-ctl .zoom-btn,
  .has-kidplay .map-ctl .zoom-btn {
    display: none;
  }
}

/* Desktop: ขยับปุ่มแผนที่เมื่อเปิดการ์ดเด็ก */
@media (min-width: 900px) {
  .has-kidcard .map-ctl,
  .has-kidplay .map-ctl {
    right: calc(32px + 400px);
  }
}

/* ---------- ภาพเคลื่อนไหว (ปิดเมื่อผู้ใช้ขอลดการเคลื่อนไหว) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .kid-card:not([hidden]) {
    animation: kid-pop 0.35s var(--ease);
  }

  .kid-game:not([hidden]) {
    animation: kid-drop 0.35s var(--ease);
  }

  .kid-game.is-nope {
    animation: kid-shake 0.45s ease;
  }

  .kid-win {
    animation: kid-spin 0.9s var(--ease);
  }

  .kid-sound.is-playing .kid-emo {
    animation: kid-wiggle 0.35s ease-in-out 5;
  }

  :root.kid .map .tm.is-target .tm-puck {
    animation: kid-hop 0.8s ease-in-out infinite;
  }

  :root.kid .map .tm.is-target::after {
    animation: kid-glow 1.2s ease-out infinite;
  }

  .party b {
    animation: kid-rise 3.2s var(--ease) forwards;
  }

  .party i {
    animation: kid-burst 1.3s ease-out forwards;
  }

  .party i:nth-child(1) {
    --dx: 0;
    --dy: -58px;
  }

  .party i:nth-child(2) {
    --dx: 42px;
    --dy: -42px;

    background: #f472b6;
  }

  .party i:nth-child(3) {
    --dx: 58px;
    --dy: 0;

    background: #38bdf8;
  }

  .party i:nth-child(4) {
    --dx: 42px;
    --dy: 42px;

    background: #4ade80;
  }

  .party i:nth-child(5) {
    --dx: 0;
    --dy: 58px;

    background: #fb923c;
  }

  .party i:nth-child(6) {
    --dx: -42px;
    --dy: 42px;

    background: #a78bfa;
  }

  .party i:nth-child(7) {
    --dx: -58px;
    --dy: 0;

    background: #f87171;
  }

  .party i:nth-child(8) {
    --dx: -42px;
    --dy: -42px;

    background: #fde047;
  }

  @media (max-width: 899px) {
    .kid-card:not([hidden]) {
      animation: kid-up 0.35s var(--ease);
    }
  }

  @media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
    .kid-card:not([hidden]) {
      animation: kid-pop 0.35s var(--ease);
    }
  }
}

@keyframes kid-pop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
}

@keyframes kid-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes kid-drop {
  from {
    opacity: 0;
    translate: 0 -16px;
  }
}

@keyframes kid-shake {
  20%,
  60% {
    translate: -8px 0;
  }

  40%,
  80% {
    translate: 8px 0;
  }
}

@keyframes kid-spin {
  from {
    transform: scale(0.2) rotate(-200deg);
  }
}

@keyframes kid-wiggle {
  50% {
    transform: rotate(-14deg) scale(1.15);
  }
}

@keyframes kid-hop {
  50% {
    transform: translateY(-7px);
  }
}

@keyframes kid-glow {
  from {
    opacity: 1;
    transform: scale(0.85);
  }

  to {
    opacity: 0;
    transform: scale(1.5);
  }
}

@keyframes kid-rise {
  0% {
    opacity: 0;
    translate: 0 12px;
  }

  12%,
  80% {
    opacity: 1;
    translate: 0 0;
  }

  100% {
    opacity: 0;
    translate: 0 -10px;
  }
}

@keyframes kid-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.4) rotate(0);
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(180deg);
  }
}

/* css/kidgames.css */
/* เมนูเกมโหมดเด็ก 🎮 (public/js/kidgames.js) — หน้าต่างเกม: เมนู / คำถาม 3 ตัวเลือก / สมุดสติกเกอร์
   จอใหญ่ = กล่องมุมขวาบนแบบการ์ดเด็ก · มือถือ = แผ่นล่าง (เกมที่ใช้แผนที่เตี้ยลงให้เห็นรถไฟ) · ใช้ตัวแปรสีของธีม → มืด/สว่าง */

/* ---------- ปุ่ม 🎮 เกม ในแถวปุ่มลัด (เต็มแถว บนสุด) ---------- */
.kid #kidPlayBtn {
  order: 0;
  grid-column: 1 / -1;
  background: linear-gradient(135deg, color-mix(in srgb, #a78bfa 26%, var(--panel-solid)), color-mix(in srgb, #f472b6 22%, var(--panel-solid)));
  border-color: color-mix(in srgb, #a78bfa 65%, transparent);
}

/* ---------- หน้าต่างเกม ---------- */
.kid-play {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1160;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 12px 16px 18px;
  overflow: hidden auto;
  overscroll-behavior: contain;
  font-family: var(--font);
  color: var(--text);
  touch-action: pan-y;
  background: var(--panel-solid);
  border: 4px solid #a78bfa;
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.kp-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.kp-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}

.kp-head .kid-stars {
  margin-left: auto;
}

.kp-x,
.kp-back {
  --i: 18px;

  display: inline-flex;
  flex: none;
  gap: 6px;
  align-items: center;
  height: 46px;
  padding: 0 14px 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.kp-back .kid-emo {
  font-size: 20px;
}

.kp-hint {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- เมนู ---------- */
.kp-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kp-game {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 10px 8px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  text-align: center;
  background: color-mix(in srgb, var(--kc, #38bdf8) 16%, var(--panel-solid));
  border: 2px solid color-mix(in srgb, var(--kc, #38bdf8) 60%, transparent);
  border-radius: 22px;
  transition: transform 0.1s;
}

.kp-game .kid-emo {
  font-size: 34px;
}

.kp-game small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.kp-game:active {
  transform: scale(0.97);
}

.kp-g-hunt {
  --kc: #facc15;
}

.kp-g-name {
  --kc: #f472b6;
}

.kp-g-count {
  --kc: #38bdf8;
}

.kp-g-dest {
  --kc: #4ade80;
}

.kp-g-stickers {
  --kc: #a78bfa;

  grid-column: 1 / -1;
  flex-direction: row;
  min-height: 72px;
}

.kp-reset {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 16px;
  transition: background 0.15s, color 0.15s;
}

.kp-reset:hover {
  color: var(--text);
  background: var(--card-hover);
}

.kp-reset .kid-emo {
  font-size: 16px;
}

/* ---------- คำถาม ---------- */
.kp-photo {
  margin: 0 0 10px;
  overflow: hidden;
  background: var(--card);
  border-radius: 20px;
}

.kp-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.kp-photo figcaption {
  padding: 5px 12px 6px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.kp-train {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  margin: 2px 0 8px;
}

.kp-face {
  flex: none;
  width: 48px;
  height: 52px;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 35%));
}

.kp-train b {
  padding: 5px 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--tfg, #fff);
  background: var(--tbg, #1968ab);
  border: 2px solid #fff;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 25%);
}

.kp-train small {
  font-size: 14px;
  color: var(--muted);
}

.kp-q {
  margin: 4px 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.kp-msg {
  min-height: 1.45em;
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--muted);
}

.kp-msg.is-wrong {
  color: var(--warn-t);
}

.kp-msg.is-right {
  color: var(--ok-t);
}

.kp-choices {
  display: grid;
  gap: 10px;
}

.kp-choice {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 8px 16px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  text-align: left;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--line) 80%, transparent);
  transition: transform 0.1s, box-shadow 0.1s;
}

.kp-choice .kid-emo {
  flex: none;
  font-size: 28px;
}

.kp-choice small {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.kp-choice:active {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 80%, transparent);
  transform: translateY(3px);
}

.kp-choice.is-wrong {
  opacity: 0.5;
  border-style: dashed;
  box-shadow: none;
}

.kp-choice.is-off {
  opacity: 0.45;
  box-shadow: none;
}

.kp-choice.is-right {
  background: color-mix(in srgb, #22c55e 20%, var(--panel-solid));
  border-color: #22c55e;
  box-shadow: 0 4px 0 #15803d;
}

.kp-next {
  justify-content: center;
  width: 100%;
  height: 56px;
  margin-top: 14px;
  font-size: 18px;
}

.kp-count .kp-choices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kp-count .kp-choice {
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  padding: 8px 4px;
  text-align: center;
}

/* ---------- สมุดสติกเกอร์ ---------- */
.kp-stickers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.kp-sticker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 10px 6px;
  text-align: center;
  background: var(--card);
  border: 3px dashed var(--line);
  border-radius: 20px;
}

.kp-st-emo {
  font-size: 34px;
  line-height: 1.1;
  filter: grayscale(1);
  opacity: 0.55;
}

.kp-st-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.kp-sticker small {
  font-size: 12px;
  color: var(--muted);
}

.kp-sticker.is-got {
  background: color-mix(in srgb, var(--c) 16%, var(--panel-solid));
  border-style: solid;
  border-color: var(--c);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 70%, #000);
}

.kp-sticker.is-got .kp-st-emo {
  filter: none;
  opacity: 1;
}

/* ---------- จอเล็ก: แผ่นล่าง ---------- */
@media (max-width: 899px) {
  .kid-play {
    inset: auto 0 0;
    width: auto;
    max-height: 84dvh;
    padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
    border-width: 4px 0 0;
    border-radius: 28px 28px 0 0;
  }

  .kp-head h2 {
    font-size: 20px;
  }

  .kp-q {
    font-size: 20px;
  }

  .kp-photo img {
    aspect-ratio: 2 / 1;
  }
}

/* จอแคบ (Fold 344 px, iPhone SE): ปุ่มเล็กลงนิดให้ข้อความไม่ตัด */
@media (max-width: 380px) {
  .kp-x,
  .kp-back {
    height: 42px;
    padding: 0 10px 0 8px;
    font-size: 14px;
  }

  .kp-game {
    min-height: 84px;
    font-size: 15.5px;
  }

  .kp-game .kid-emo {
    font-size: 30px;
  }

  .kp-choice {
    gap: 8px;
    padding: 8px 10px;
    font-size: 17px;
  }

  .kp-choice .kid-emo {
    font-size: 24px;
  }

  .kp-stickers {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }
}

/* มือถือ เกมที่ใช้แผนที่ (นับรถไฟ / รถไฟจะไปไหน): แผ่นเตี้ยลงให้เห็นรถไฟที่กระโดด */
@media (max-width: 899px) {
  .kid-play.is-map {
    max-height: 56dvh;
  }

  .kid-play.is-map .kp-q {
    font-size: 19px;
  }

  .kid-play.is-map .kp-msg {
    margin-bottom: 8px;
    font-size: 14.5px;
  }

  .kid-play.is-map .kp-choices {
    gap: 8px;
  }

  .kid-play.is-map .kp-choice {
    min-height: 54px;
    font-size: 17px;
  }

  .kid-play.is-map .kp-next {
    height: 50px;
    margin-top: 10px;
  }
}

/* แนวนอนมือถือ: วางหน้าต่างเกมทับคอลัมน์ซ้าย */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .kid-play {
    inset: 8px auto 8px var(--side-l);
    width: var(--side-w);
    max-height: calc(100dvh - 16px);
    border-width: 3px;
    border-radius: 22px;
  }
}

/* จอเตี้ยแนวตั้ง: จำกัดความสูงหน้าต่างเกม */
@media (max-width: 899px) and (max-height: 700px) and (orientation: portrait) {
  .kid-play {
    max-height: 62dvh;
  }

  .kid-play.is-map {
    max-height: 52dvh;
  }
}

/* ---------- ภาพเคลื่อนไหว (ปิดเมื่อผู้ใช้ขอลดการเคลื่อนไหว) — keyframes อยู่ใน kidmode.css ---------- */
@media (prefers-reduced-motion: no-preference) {
  .kid-play:not([hidden]) {
    animation: kid-pop 0.35s var(--ease);
  }

  @media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
    .kid-play:not([hidden]) {
      animation: kid-pop 0.35s var(--ease);
    }
  }

  .kp-choice.is-shake {
    animation: kid-shake 0.45s ease;
  }

  .kid-play.is-won .kp-msg .kid-emo {
    display: inline-block;
    animation: kid-spin 0.9s var(--ease);
  }
}

/* css/mystation.css */
/* เรดาร์รถไฟ — "สถานีของฉัน": การ์ดในแผงหลัก (แท็บขบวนรถ + โปรด) + ปุ่มปักหมุดบนป้ายสถานี (ใช้ตัวแปรสีเดียวกับ app.css) */

.ms-wrap {
  margin: 4px 0 10px;
}

.ms-wrap:empty {
  display: none;
}

/* ย่ออยู่ = การ์ดเล็กติดหัวรายการขณะเลื่อน (เห็นรถคันถัดไปของสถานีตลอด) */
.ms-wrap.is-sticky {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 0 -8px 8px;
  padding: 4px 8px 6px;
  background: var(--panel-solid);
  box-shadow: 0 8px 10px -8px rgb(0 0 0 / 30%);
}

.ms-card {
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 6%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: 14px;
}

.ms-head {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 4px 6px 4px 4px;
}

.ms-toggle {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  text-align: left;
  border-radius: 10px;
}

.ms-toggle:hover {
  background: var(--card-hover);
}

.ms-ico {
  --i: 19px;

  display: grid;
  color: var(--accent);
}

.ms-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.ms-chev {
  --i: 18px;

  color: var(--muted);
  transition: transform 0.2s var(--ease);
}

.ms-card.is-open .ms-chev {
  transform: rotate(180deg);
}

.ms-quiet {
  color: var(--accent);
}

.ms-quiet[aria-pressed="true"] {
  color: var(--muted);
}

/* ไม่เตือนเพราะข้อมูลไม่สด / การเตือนล่าสุด */
.ms-why,
.ms-last {
  margin: 0 8px 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  border-radius: 10px;
}

.ms-why {
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
}

.ms-last {
  font-weight: 600;
  background: color-mix(in srgb, var(--ok) 15%, transparent);
}

/* ---------- สถานี ---------- */
.ms-st {
  padding: 2px 6px 6px;
  border-top: 1px solid var(--line);
}

.ms-st-head {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: 4px;
}

.ms-st-name {
  --i: 16px;

  display: inline-flex;
  flex: 1;
  gap: 6px;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  padding: 0 6px;
  font-size: 15px;
  text-align: left;
  border-radius: 10px;
}

.ms-st-name:hover {
  background: var(--card-hover);
}

.ms-st-name svg {
  color: var(--accent);
}

.ms-st-name b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-chip {
  --i: 14px;

  display: inline-flex;
  flex: none;
  gap: 5px;
  align-items: center;
  max-width: 56%;
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.15s;
}

.ms-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-chip:hover {
  background: var(--card-hover);
}

.ms-chip.is-on {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.ms-chip.is-paused {
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.ms-chip[aria-expanded="true"] {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.ms-unpin {
  color: var(--muted);
}

/* ---------- ย่อ: บรรทัดเดียวต่อสถานี ---------- */
.ms-mini {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0 6px 6px;
  list-style: none;
}

.ms-mini-b {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 2px 8px;
  font-size: 13px;
  text-align: left;
  border-radius: 10px;
}

.ms-mini-b:hover {
  background: var(--card-hover);
}

.ms-mini-st {
  --i: 14px;

  display: inline-flex;
  flex: 1;
  gap: 5px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-mini-st svg {
  color: var(--accent);
}

.ms-mini-no {
  padding: 1px 6px;
  font: 600 12px/1.5 var(--mono);
  background: var(--card-hover);
  border-radius: 6px;
}

.ms-mini-b b {
  font: 600 14px var(--mono);
}

.ms-mini-b small {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- รถที่กำลังมา ---------- */
.ms-rows {
  display: grid;
  gap: 2px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.ms-row {
  display: flex;
  gap: 2px;
  align-items: center;
  border-radius: 12px;
}

.ms-row.is-wait {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}

.ms-go {
  display: grid;
  flex: 1;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 6px;
  text-align: left;
  border-radius: 12px;
}

.ms-go:hover {
  background: var(--card-hover);
}

.ms-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ms-main b {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-main b i {
  font-style: normal;
  color: var(--muted);
}

.ms-main small {
  overflow: hidden;
  min-height: 1.4em;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-main small.lv1,
.ms-main small.lv2 {
  font-weight: 600;
  color: var(--ct);
}

.ms-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.ms-time b {
  font: 600 16px/1.25 var(--mono);
}

.ms-time b i {
  margin-right: 1px;
  font-style: normal;
  color: var(--muted);
}

.ms-time small {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
}

.ms-row.is-here .ms-time small {
  font-weight: 700;
  color: var(--ok-t);
}

.ms-row.is-cancelled {
  opacity: 0.75;
}

.ms-row.is-cancelled .ms-time b {
  text-decoration: line-through;
}

.ms-row.is-cancelled .ms-time small {
  font-weight: 600;
  color: var(--bad-t);
}

.ms-wait {
  color: var(--muted);
}

.ms-wait[aria-pressed="true"] {
  color: var(--accent);
}

.ms-empty,
.ms-stale {
  margin: 4px 8px 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.ms-stale {
  color: var(--warn-t);
}

.ms-legend {
  margin: 0;
  padding: 7px 12px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ---------- ตั้งเตือน ---------- */
.ms-set {
  display: grid;
  gap: 8px;
  margin: 6px 2px 8px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ms-set-l {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.ms-seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.ms-seg-b {
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.15s;
}

.ms-seg-b:hover {
  background: var(--card-hover);
}

.ms-seg-b[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.ms-prev {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.ms-which {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.ms-which select {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  font: inherit;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ms-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.ms-ask {
  --i: 16px;

  min-height: 36px;
}

/* แท็บโปรด: ยังไม่ได้ปักหมุด → บอกวิธี */
.ms-hint {
  --i: 18px;

  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 8px 6px 4px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.ms-hint svg {
  margin-top: 1px;
  color: var(--accent);
}

/* ---------- ปุ่มปักหมุดบนหัวป้ายสถานี ---------- */
.ms-pin {
  --i: 18px;
}

@media (max-width: 380px) {
  .ms-pin {
    padding: 0 10px;
  }

  .ms-pin span {
    display: none;
  }
}

@media (pointer: coarse) {
  .ms-seg-b,
  .ms-which select {
    height: 40px;
  }

  .ms-mini-b {
    min-height: 40px;
  }

  .ms-chip {
    height: 36px;
  }
}

/* css/pwa.css */
/* PWA — ปุ่มติดตั้งแอป, toast เวอร์ชันใหม่, คำแนะนำ iOS, ขอบจอเมื่อเปิดแบบแอป (public/js/pwa.js) */

/* ---------- ปุ่ม "ติดตั้งแอป" ต่อท้ายแถวปุ่มลัด (หน้าตาเดียวกับ .chip-btn, ปิดได้ จำไว้) ---------- */
.pwa-chip {
  position: relative;
  display: flex;
  min-width: 0;
  animation: pwa-fade 0.3s var(--ease);
}

.pwa-chip .chip-btn {
  flex: 1;
  padding: 0 44px 0 10px;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.pwa-chip .chip-btn > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-chip-x {
  --i: 14px;

  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
  border-radius: 9px;
}

.pwa-chip-x:hover {
  color: var(--text);
  background: var(--card-hover);
}

/* ---------- มีเวอร์ชันใหม่ แตะเพื่อโหลดใหม่ ---------- */
.pwa-update {
  --i: 18px;

  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  z-index: 1350;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  width: max-content;
  max-width: min(92vw, 440px);
  min-height: 44px;
  padding: 8px 18px 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}

.pwa-update.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* มือถือ: คำอธิบายหมุดอยู่บนสุด → ลงมาใต้แถบนั้น */
@media (max-width: 899px) {
  .pwa-update {
    top: calc(64px + env(safe-area-inset-top));
  }
}

.pwa-update:disabled {
  cursor: progress;
  opacity: 0.8;
}

/* ---------- คำแนะนำ iOS: แชร์ → เพิ่มไปยังหน้าจอโฮม ---------- */
.pwa-ios {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 1400;
  width: min(calc(100vw - 20px), 400px);
  padding: 16px 16px 14px;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 24px);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}

.pwa-ios.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.pwa-ios-x {
  --i: 16px;

  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
  border-radius: 12px;
}

.pwa-ios-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-right: 38px;
}

.pwa-ios-head img {
  flex: none;
  border-radius: 12px;
}

.pwa-ios-head b {
  display: block;
  font-size: 15.5px;
  line-height: 1.35;
}

.pwa-ios-head small {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.pwa-ios-steps {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 14px 0 12px;
  list-style: none;
  counter-reset: pwa;
}

.pwa-ios-steps li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--card);
  border-radius: 12px;
  counter-increment: pwa;
}

.pwa-ios-steps li::before {
  flex: none;
  width: 20px;
  font: 600 13px/1 var(--mono);
  color: var(--muted);
  text-align: center;
  content: counter(pwa);
}

.pwa-ios-steps i {
  --i: 22px;

  display: grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 36px;
  font-style: normal;
  color: #0a84ff;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.pwa-ios-steps .pwa-ios-add {
  font-size: 13px;
  font-weight: 700;
}

.pwa-ios-steps small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.pwa-ios-ok {
  width: 100%;
  min-height: 44px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 12px;
}

@keyframes pwa-fade {
  from {
    opacity: 0;
  }
}

/* ---------- เปิดแบบแอป (standalone): ขอบจอ/รอยบาก/แถบโฮม ---------- */

/* แถบสถานะของ iOS (black-translucent) ลอยอยู่บนแผนที่ → ฉากทึบบางๆ ให้ตัวอักษรขาวอ่านได้ทั้งธีมมืด/สว่าง */
.is-standalone body::before {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1500;
  height: env(safe-area-inset-top);
  pointer-events: none;
  content: "";
  background: rgb(11 18 32 / 55%);
}

.is-standalone .toast {
  top: calc(20px + env(safe-area-inset-top));
}

/* มือถือแนวตั้ง (แนวนอนเป็นแผงด้านข้าง สูงตามเนื้อหา — app.css จัดขอบซ้ายตามรอยบากแล้ว) */
@media (max-width: 899px) and (min-height: 501px), (max-width: 899px) and (max-aspect-ratio: 4/3) {
  /* แผ่นเลื่อนเต็มความสูงไม่ขึ้นไปอยู่ใต้รอยบาก/แถบสถานะ */
  .is-standalone .panel,
  .is-standalone .detail {
    height: calc(100dvh - 48px - env(safe-area-inset-top));
  }

  /* เนื้อหาแผงรายละเอียดตอนเต็มจอไม่จมใต้แถบโฮม */
  .is-standalone .detail[data-snap="full"] {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-chip,
  .pwa-update,
  .pwa-ios {
    transition: none;
    animation: none;
  }
}

/* css/nav.css */
/* เรดาร์รถไฟ — เมนูล่าง (มือถือ), แท็บสถานี, ลิงก์หน้าเว็บ, ป้ายอัปเดตแบบกดได้, คำแนะนำครั้งแรก, ข้อมูลสถานี
   ใช้ตัวแปรสีเดียวกับ app.css · แนวนอน = LAND_MQ ใน util.js */

:root {
  --bnav-h: 0px;
}

/* ---------- หัวแผง: โลโก้ · ชื่อ · ? · ภาษา · ธีม / แถวสอง = ป้ายอัปเดต (ข้อความยาวไม่โดนตัดบนจอแคบ) ---------- */
.brand {
  display: grid;
  grid-template-areas:
    "logo title help lang theme"
    "logo live live live live";
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 0 8px;
}

.brand-logo {
  grid-area: logo;
  margin-right: 4px;
}

.brand-text {
  grid-area: title;
  align-self: center;
}

#helpBtn {
  grid-area: help;
}

.brand .lang-btn {
  grid-area: lang;
  align-self: center;
}

#themeBtn {
  grid-area: theme;
}

.brand .live {
  grid-area: live;
  justify-self: start;
  margin: -4px 0 0;
}

/* ---------- ป้าย "อัปเดตเมื่อ …" (ปุ่ม: แตะ = อัปเดตทันที) ---------- */
button.live {
  max-width: 100%;
  min-height: 24px;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 6px;
}

#liveLabel {
  overflow: hidden;
  text-overflow: ellipsis;
}

button.live:hover #liveLabel {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

button.live:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.live.is-busy .live-dot {
  animation: live-spin 0.8s linear infinite;
}

@keyframes live-spin {
  50% {
    transform: scale(0.5);
  }
}

/* ---------- ปุ่มลัด: ลิงก์หน้าตาเหมือนปุ่ม ---------- */
a.chip-btn {
  color: inherit;
  text-decoration: none;
}

/* ---------- ปุ่มแผนที่ที่มีข้อความกำกับ (ไอคอน + ข้อความ) ---------- */
.fab.lbl {
  --i: 19px;

  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  line-height: 1;
}

.fab.lbl span {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- ลิงก์หน้าเว็บ (SSR) ---------- */
.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  margin: 14px 8px 6px;
  font-size: 13px;
}

.page-links a,
.page-link a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.page-link {
  margin: 12px 4px 0;
  font-size: 13.5px;
}

.page-link a {
  --i: 15px;

  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 32px;
}

.page-link svg {
  flex: none;
  width: var(--i);
  height: var(--i);
}

/* ---------- เวลาที่ รฟท. รายงานขบวนนี้ล่าสุด ---------- */
.sum-report {
  margin: 4px 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.sum-report:empty {
  display: none;
}

/* ---------- การ์ดสรุปขบวน: ออกจากต้นทาง / ถึงปลายทาง ---------- */
.sum-trip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.trip-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.trip-cell.end {
  align-items: flex-end;
  text-align: right;
}

.trip-cell b {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
}

.trip-cell b.lv1 {
  color: var(--warn-t);
}

.trip-cell b.lv2 {
  color: var(--bad-t);
}

.trip-cell small {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.trip-cell [data-tick="dest"] {
  font-weight: 600;
  color: var(--accent);
}

/* ---------- แท็บสถานี ---------- */
.stations-body {
  padding: 2px 0 8px;
}

.st-near {
  display: flex;
  gap: 12px;
  align-items: center;
  width: calc(100% - 8px);
  min-height: 60px;
  margin: 4px 4px 8px;
  padding: 10px 12px;
  color: #1c1406;
  text-align: left;
  background: linear-gradient(135deg, #fcd34d, #f59e0b 80%);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgb(245 158 11 / 25%);
}

.st-near-ico {
  --i: 22px;

  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  background: rgb(255 255 255 / 45%);
  border-radius: 50%;
}

.st-near-txt {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.st-near-txt b {
  font-size: 15.5px;
}

.st-near-txt small {
  font-size: 12.5px;
  opacity: 0.85;
}

.st-go {
  flex: none;
  font-size: 22px;
  line-height: 1;
  opacity: 0.6;
}

.st-group .count {
  color: var(--muted);
  background: var(--card-hover);
}

.st-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.st-row {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 6px 10px;
  text-align: left;
  border-radius: 12px;
  transition: background 0.15s;
}

.st-row:hover {
  background: var(--card-hover);
}

.st-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.st-name b {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-name small {
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-tel {
  --i: 15px;

  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ok-t);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border-radius: 50%;
}

/* ---------- ข้อมูลสถานี (โทร/นำทาง/สิ่งอำนวยความสะดวก) ---------- */
.dt-info:empty {
  display: none;
}

.si-card {
  margin-top: 12px;
}

.si-h {
  margin: 0 0 10px;
  font-size: 15px;
}

.si-act {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.si-btn {
  --i: 17px;

  display: inline-flex;
  flex: 1 1 auto;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 46px;
  padding: 6px 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent-ink);
  text-decoration: none;
  background: var(--accent);
  border-radius: 12px;
}

.si-btn svg {
  flex: none;
  width: var(--i);
  height: var(--i);
}

.si-btn.alt,
.si-btn.nav {
  color: var(--text);
  background: var(--card-hover);
  border: 1px solid var(--line);
}

.si-note,
.si-none {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.si-note a {
  color: var(--accent);
}

.si-list {
  margin: 12px 0 0;
}

.si-row {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.si-row dt {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.si-row dd {
  margin: 2px 0 0;
  font-size: 13.5px;
}

.si-row ul {
  margin: 0;
  padding-left: 18px;
}

.si-src {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.si-src a {
  display: inline-block;
  min-width: 24px;
  min-height: 24px;
  color: var(--accent);
  text-align: center;
}

/* ---------- คำแนะนำครั้งแรก (dialog) ---------- */
.guide {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(3 7 18 / 62%);
  animation: guide-fade 0.2s ease-out;
}

.guide[hidden] {
  display: none;
}

.guide-card {
  width: min(400px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px 20px 16px;
  text-align: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  animation: guide-in 0.28s var(--ease);
}

.guide-k {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.guide-ico {
  --i: 34px;

  display: inline-grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 12px 0 4px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 50%;
}

.guide-ico svg {
  width: var(--i);
  height: var(--i);
}

.guide-card h2 {
  margin: 6px 0;
  font-size: 20px;
}

.guide-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
}

.guide-legend {
  margin: 12px 0 0;
  padding: 10px 12px;
  text-align: left;
  background: var(--card);
  border-radius: 14px;
}

.guide-legend b {
  font-size: 13px;
}

.guide-legend ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  margin: 6px 0 0;
  padding: 0;
  font-size: 12.5px;
  list-style: none;
}

.guide-legend li {
  display: flex;
  align-items: center;
  min-width: 0;
}

.guide-legend li.wide {
  grid-column: 1 / -1;
}

.lg-seg {
  flex: none;
  width: 22px;
  height: 0;
  margin-right: 7px;
  border-top: 3px dashed var(--bad);
}

.lg-seg.warn {
  border-top-color: var(--warn);
}

.guide-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 14px 0;
}

.guide-dots i {
  width: 8px;
  height: 8px;
  background: var(--line);
  border-radius: 50%;
}

.guide-dots i.on {
  width: 22px;
  background: var(--accent);
  border-radius: 4px;
}

.guide-act {
  display: flex;
  gap: 10px;
}

.guide-btn {
  flex: 1;
  min-height: 48px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 14px;
}

.guide-btn.ghost {
  color: var(--text);
  background: var(--card-hover);
}

@keyframes guide-fade {
  from {
    opacity: 0;
  }
}

@keyframes guide-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

/* ---------- เมนูล่าง: ซ่อนบนจอใหญ่ (ใช้แท็บ/ปุ่มลัดในแผงซ้าย) ---------- */
.bnav {
  display: none;
}

@media (max-width: 899px) {
  .bnav {
    position: fixed;
    z-index: 1200;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    background: var(--panel-solid);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgb(0 0 0 / 18%);
  }

  .bnav-btn {
    --i: 22px;

    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    border-radius: 12px;
    transition: color 0.15s;
  }

  .bnav-btn svg {
    width: var(--i);
    height: var(--i);
  }

  .bnav-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ส่วนที่กำลังดู: ไอคอนมีพื้นหลังแคปซูล + ตัวหนังสือสีหลัก */
  .bnav-btn::before {
    position: absolute;
    top: 5px;
    left: 50%;
    width: 52px;
    height: 28px;
    content: "";
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-radius: 14px;
    opacity: 0;
    transform: translateX(-50%) scaleX(0.6);
    transition: opacity 0.2s, transform 0.2s var(--ease);
  }

  .bnav-btn[aria-current="page"] {
    color: var(--accent);
  }

  .bnav-btn[aria-current="page"]::before {
    opacity: 1;
    transform: translateX(-50%);
  }

  .bnav-btn svg,
  .bnav-btn span {
    position: relative;
  }

  .bnav-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  /* ปุ่ม "ใกล้ฉัน" ในแถวปุ่มลัด → อยู่ในเมนูล่างแล้ว (โหมดเด็กยังใช้ในแถว) */
  html:not(.kid) .quick #nearbyBtn {
    display: none;
  }

  /* โหมดเด็ก: ไม่มีเมนูล่าง (ปุ่มใหญ่ในแผงแทน) */
  .kid {
    --bnav-h: 0px;
  }

  .kid .bnav {
    display: none;
  }

  /* คำอธิบายหมุดไม่ทับปุ่มแผนที่ที่มีข้อความ (กว้าง 52px) */
  .legend {
    max-width: calc(100vw - 84px);
  }

  /* แถวปุ่มลัดบนมือถือ (ไม่มี "ใกล้ฉัน"): ฉันอยู่บนรถไฟ · รู้จักรถไฟไทย / สุ่มขบวน · โหมดเด็ก */
  html:not(.kid) .quick > #kidBtn {
    grid-column: auto;
  }
}

.kid #galleryBtn {
  display: none;
}

/* ---------- มือถือแนวตั้ง: เมนูเต็มความกว้างล่างสุด · แผ่นเลื่อนทุกแผ่นวางเหนือเมนู ---------- */
@media (max-width: 899px) and (min-height: 501px), (max-width: 899px) and (max-aspect-ratio: 4/3) {
  :root {
    --bnav-h: calc(58px + env(safe-area-inset-bottom));

    /* แผ่นย่อ = ปุ่ม ^ + หัวแผง + ช่องค้นหา + แถวตัวเลขเต็มแถว (เดิม 188 ตัดตัวเลขครึ่งช่อง) */
    --peek: 206px;
  }

  /* หัวแผงกระชับ: แผ่นย่อเห็นตัวเลขครบโดยกินแผนที่เพิ่มน้อยที่สุด */
  html:not(.kid) .panel-grip {
    min-height: 0;
    padding: 4px 0 0;
  }

  html:not(.kid) .brand {
    padding-bottom: 4px;
  }

  html:not(.kid) .stats {
    margin-top: 8px;
  }

  html:not(.kid) .stat {
    padding-block: 4px;
  }

  html:not(.kid) .stat b {
    font-size: 21px;
  }

  .bnav {
    inset: auto 0 0;
    height: var(--bnav-h);
    padding: 3px 4px env(safe-area-inset-bottom);
  }

  .panel {
    bottom: var(--bnav-h);
    height: calc(100dvh - 48px - var(--bnav-h));
    padding-bottom: 0;
    transform: translateY(calc(100% - var(--peek)));
  }

  .detail {
    bottom: var(--bnav-h);
    height: calc(100dvh - 48px - var(--bnav-h));
  }

  .leaflet-bottom.leaflet-right {
    bottom: calc(var(--peek) + var(--bnav-h));
  }

  .pwa-ios {
    bottom: calc(var(--bnav-h) + 10px);
  }

  /* โหมดเด็ก: แผงกลับไปชิดขอบล่างตามเดิม */
  .kid .panel {
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom)));
  }

  .kid .panel[data-snap="half"] {
    transform: translateY(calc(44dvh - 48px));
  }

  .kid .panel[data-snap="full"] {
    transform: none;
  }
}

/* ---------- คีย์บอร์ดขึ้น (viewport.js): แผ่นที่กางเต็มพอดีส่วนที่มองเห็น ช่องพิมพ์อยู่เหนือคีย์บอร์ด ---------- */
@media (max-width: 899px) {
  html.kb-open {
    --bnav-h: 0px;
  }

  html.kb-open .bnav {
    display: none;
  }

  html.kb-open .panel[data-snap="full"],
  html.kb-open .locate[data-snap="full"] {
    top: calc(var(--vvt, 0px) + 6px);
    bottom: auto;
    height: calc(var(--vvh, 100dvh) - 12px);
    transform: none;
    transition: none;
  }
}

/* ---------- มือถือแนวนอน: เมนูเป็นแถบใต้แผ่นด้านซ้าย ---------- */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  :root {
    --bnav-h: 50px;
  }

  .brand {
    gap: 0 4px;
  }

  .brand-text {
    white-space: nowrap;
  }

  .bnav {
    bottom: calc(6px + env(safe-area-inset-bottom));
    left: var(--side-l);
    width: var(--side-w);
    height: var(--bnav-h);
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .bnav-btn {
    --i: 17px;

    gap: 1px;
    min-height: 44px;
    padding: 2px;
    font-size: 10.5px;
  }

  .bnav-btn::before {
    top: 2px;
    width: 40px;
    height: 22px;
  }

  html:not(.kid) .panel,
  html:not(.kid) .panel[data-snap],
  html:not(.kid) .detail:not(.locate),
  html:not(.kid) .detail:not(.locate)[data-snap] {
    bottom: calc(12px + var(--bnav-h) + env(safe-area-inset-bottom));
  }

  html:not(.kid) .panel[data-snap="peek"] {
    bottom: auto;
    max-height: min(var(--peek), calc(100dvh - 26px - var(--bnav-h)));
  }

  html:not(.kid) .locate,
  html:not(.kid) .locate[data-snap] {
    max-height: calc(100dvh - 26px - var(--bnav-h));
  }
}

@media (min-width: 640px) and (max-width: 899px) and (min-height: 501px) {
  .bnav {
    padding-inline: max(4px, calc((100vw - 620px) / 2));
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide,
  .guide-card,
  .bnav-btn::before {
    transition: none;
    animation: none;
  }
}

/* ---------- เที่ยวของขบวนเลขซ้ำ · งดบางช่วง "วิ่งเฉพาะ" · ชานชาลาคำยาว ---------- */
.run-chip {
  display: inline-block;
  margin: 0 6px 0 0;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  color: var(--accent);
  white-space: nowrap;
  vertical-align: 1px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 999px;
}

.sr-main b .run-chip {
  margin: 0 0 0 6px;
}

.cut-run {
  --i: 15px;

  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn-t);
}

.cut-run svg {
  flex: none;
  width: var(--i);
  height: var(--i);
}

.bd-pf.long {
  width: auto;
  min-width: 34px;
  padding: 0 3px;
  font-size: 10.5px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.fab.is-busy svg {
  animation: spin 1s linear infinite;
}

/* ---------- แบบแผนที่ (layers.js): มืด / สว่าง / ดาวเทียม + คำอธิบายสี ---------- */
.lyr-pop {
  position: fixed;
  right: 84px;
  bottom: 30px;
  z-index: 1250;
  width: min(320px, calc(100vw - 100px));
  max-height: calc(100dvh - 60px);
  padding: 12px 14px 14px;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.lyr-pop[hidden] {
  display: none;
}

.lyr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lyr-head h3 {
  margin: 0;
  font-size: 15px;
}

.lyr-opts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.lyr-opt {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding: 4px 4px 6px;
  font-size: 12.5px;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 12px;
}

.lyr-opt img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--card);
  border-radius: 8px;
}

.lyr-opt[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

.lyr-note {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--muted);
}

.lyr-pop .guide-legend {
  margin-top: 10px;
}

/* ดาวเทียม: ภาพถ่ายสีจริง (ไม่ใส่ฟิลเตอร์โทนเรดาร์ของธีมมืด) */
:root[data-theme] .base-sat .leaflet-tile-pane {
  filter: none;
}

/* ดาวเทียม: หมุดขบวน/สถานีมีขอบให้อ่านออกบนภาพถ่าย · ป้ายชื่อสถานีมีเงา */
.base-sat .tm-puck {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgb(0 0 0 / 55%), 0 2px 8px rgb(0 0 0 / 50%);
}

.base-sat .st-label {
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 6px #000;
}

@media (max-width: 899px) {
  .lyr-pop {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(72px + env(safe-area-inset-right));
    bottom: auto;
    width: min(320px, calc(100vw - 88px));
  }
}

/* ---------- รูปสถานี (stationphoto.js) — เตี้ยพอไม่ดันตารางเวลาหลุดจอ ---------- */
.dt-photo:empty {
  display: none;
}

.st-photo {
  position: relative;
  margin: 0 0 12px;
}

/* ภาพเก็บถาวร (ไม่ใช่ภาพปัจจุบัน) ป้ายมุมภาพ */
.st-photo-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgb(15 23 42 / 82%);
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 999px;
}

.st-photo img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--card);
  border-radius: 14px;
}

.st-photo figcaption {
  margin: 5px 2px 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

.st-photo figcaption a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 899px) {
  .st-photo img {
    height: 128px;
  }
}

/* สถานีไม่มีรูปที่ใช้ได้: ภาพประกอบ SVG (ไม่ใช่รูปจริง) */
.st-ill {
  display: grid;
  place-items: end center;
  height: 150px;
  padding: 18px 12px 8px;
  background: var(--card);
  border-radius: 14px;
}

.st-ill-svg {
  width: 100%;
  max-width: 360px;
  height: 100%;
}

.st-ill-svg .ill-bld {
  fill: #243247;
  stroke: #8fa0b6;
}

.st-ill-svg .ill-win {
  fill: none;
  stroke: #8fa0b6;
}

.st-ill-svg .ill-door {
  fill: #111827;
}

.st-ill-svg .ill-plat {
  fill: #526174;
}

.st-ill-svg .ill-rail {
  fill: none;
  stroke: #718198;
}

.st-ill-svg .ill-acc {
  fill: #b84a3a;
}

:root[data-theme="light"] .st-ill-svg .ill-bld {
  fill: #e4dccb;
  stroke: #596577;
}

:root[data-theme="light"] .st-ill-svg .ill-win {
  stroke: #596577;
}

:root[data-theme="light"] .st-ill-svg .ill-door {
  fill: #738094;
}

:root[data-theme="light"] .st-ill-svg .ill-plat {
  fill: #c2c9d2;
}

:root[data-theme="light"] .st-ill-svg .ill-rail {
  stroke: #7c8797;
}

.st-photo-send {
  margin: -4px 0 12px;
}

@media (max-width: 899px) {
  .st-ill {
    height: 96px;
    padding-top: 12px;
  }
}

.tl-legend {
  margin: 0 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

/* ---------- จอสัมผัส: พื้นที่แตะ ≥ 40 px (ภาพเท่าเดิม ขยายด้วย padding/pseudo-element) ---------- */
@media (pointer: coarse) {
  /* ป้าย "อัปเดต N วินาทีก่อน" (แตะ = อัปเดต): สูง 40 px แต่ตำแหน่งตัวหนังสือเดิม */
  .brand .live {
    min-height: 40px;
    margin: -12px 0 -8px;
  }

  /* ที่จับแผ่นเลื่อน: ขยายพื้นที่แตะลงไปด้านล่างโดยไม่ดันเนื้อหา */
  .panel-grip,
  .dt-grip {
    position: relative;
  }

  .panel-grip::after,
  .dt-grip::after {
    position: absolute;
    inset: -4px 0 -14px;
    content: "";
  }

  .si-src a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
  }
}

/* จอแคบ (≤ 360 px: iPhone SE 320, Fold 344, Android 360): หัวแผงกระชับ — ชื่อเว็บมีที่พอให้อยู่บรรทัดเดียว
   ทั้งไทย อังกฤษ และโหมดเด็ก (kidmode.css) ไม่ซ้อนปุ่ม ? · ปุ่มยังกว้าง 40 px เท่าเดิม */
@media (max-width: 360px) {
  .brand {
    gap: 0 6px;
    padding-left: 12px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    margin-right: 0;
  }

  .brand h1 {
    white-space: nowrap;
  }
}

/* จอแคบมาก (iPhone SE 320 px) */
@media (max-width: 340px) {
  .brand {
    gap: 0 5px;
    padding-right: 8px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
  }

  .brand h1 {
    font-size: 17px;
  }
}

/* ภาษาอังกฤษ "Rotfai Radar" ยาวกว่า "เรดาร์รถไฟ": จอแนวตั้งแคบ ตัวเล็กลงนิดให้อยู่บรรทัดเดียว (เดิมขึ้น 2 บรรทัด) */
@media (max-width: 380px) {
  html[lang="en"] .brand h1 {
    font-size: 16px;
    white-space: nowrap;
  }
}

/* แนวนอน: แผ่นด้านซ้ายแคบ (~280–340 px) → ภาษาอังกฤษขึ้น 2 บรรทัดแบบชิด (ไม่ทับปุ่ม ?) */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  html[lang="en"] .brand h1 {
    font-size: 17px;
    line-height: 1.1;
    white-space: normal;
  }
}

/* css/linestatus.css */
/* เรดาร์รถไฟ — สถานะเส้นทางบนแผนที่ (แถบบนสุด, เส้นประบนราง, แผ่นรายละเอียดโซน) · ข้อมูล รฟท. เท่านั้น */

/* ---------- แถบสถานะ (บนสุดของแผนที่) ---------- */
.lstat {
  position: fixed;
  top: 16px;
  right: 84px;
  left: calc(32px + var(--panel-w));
  z-index: 900;
  display: grid;
  gap: 4px;
  padding: 8px;
  pointer-events: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
}

.lstat[hidden] {
  display: none;
}

.lstat-main {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.lstat-summary {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding-left: 6px;
}

.lstat-summary span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lstat-summary b {
  font-size: 13px;
}

.lstat-summary small {
  font-size: 12px;
  color: var(--muted);
}

.lstat-summary .bad {
  --c: var(--bad);
}

.lstat-summary .warn {
  --c: var(--warn);
}

.lstat-all, .lstat-step {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* "ดูทั้งหมด" = ลิงก์เบาๆ (ตัวอักษรสีหลัก + ›) ไม่ใช่ปุ่มทึบ — ไม่แย่งสายตาจากชิปแจ้งเตือน · พื้นที่แตะยัง 44 px */
.lstat-all {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  padding: 0 6px 0 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  cursor: pointer;
  background: var(--panel-solid);
  border-color: transparent;
}

.lstat-all::after {
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  content: "›";
}

.lstat-all:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-solid));
}

.lstat-step {
  font-size: 22px;
  color: var(--text);
  background: var(--panel-solid);
}

.lstat-step:disabled {
  opacity: 0.3;
  cursor: default;
}

.lstat-rail {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 6px;
  min-width: 0;
}

.lstat-scroll {
  display: flex;
  gap: 6px;
  min-width: 0;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.lstat-scroll::-webkit-scrollbar {
  display: none;
}

.status-dialog {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100% - 32px));
  max-height: 85dvh;
  padding: 0;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 30%);
}

.status-dialog:not([open]) {
  display: none;
}

.status-dialog::backdrop {
  background: rgb(0 0 0 / 40%);
}

.status-dialog header {
  display: flex;
  flex: none;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.status-dialog h2 {
  margin: 0;
  font-size: 20px;
}

.status-dialog .icon-btn {
  min-width: 44px;
  min-height: 44px;
}

.status-dialog-hint {
  flex: none;
  margin: 12px 18px 0;
  font-size: 13px;
  color: var(--muted);
}

.status-dialog-body {
  min-height: 0;
  padding: 0 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ls-chip {
  --c: var(--ok);

  display: inline-flex;
  flex: none;
  gap: 7px;
  align-items: center;
  max-width: 280px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background: var(--panel-solid);
  border: 1px solid color-mix(in srgb, var(--c) 55%, var(--line));
  border-radius: 999px;

  /* เงาเล็ก (กล่องเลื่อนตัดเงาใหญ่เป็นแถบสี่เหลี่ยม) */
  box-shadow: 0 2px 6px rgb(0 0 0 / 28%);
}

.lstat-all:focus-visible, .lstat-step:focus-visible, .lstat-scroll:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.lstat-scroll .ls-chip {
  max-width: min(280px, 100%);
  min-height: 44px;
  border-radius: 10px;
  box-shadow: none;
  scroll-snap-align: start;
}

.ls-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ชิปเขตที่มีปัญหา 2 บรรทัด: ชื่อสาย (ยาว → ตัด … เฉพาะชื่อ) / "งดเดิน 20 ขบวน · ประกาศ 1"
   ตัวเลขต้องเห็นเต็มเสมอ (เคยเห็น "งดเดิน 2" แทน 20 บนจอ 360px) และไม่ขึ้นบรรทัดที่ 3 (แถบสูงขึ้นกินแผนที่)
   → ชิปที่มีหลายเรื่องกว้างกว่าแถบได้ ปัดดูต่อในแถบเลื่อน · ชื่อเต็ม + ตัวเลขอยู่ใน aria-label */
.lstat-scroll .ls-chip.ls-zone {
  gap: 8px;
  max-width: none;
  padding: 3px 12px 3px 10px;
}

.ls-txt {
  display: grid;
  min-width: 0;
  line-height: 1.22;
  text-align: left;
}

.ls-chip .ls-name {
  max-width: 230px;
  font-weight: 700;
  white-space: nowrap;
}

.ls-chip .ls-lead {
  display: none;
}

.ls-chip .ls-bits {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ls-chip.bad {
  --c: var(--bad);
}

.ls-chip.warn {
  --c: var(--warn);
}

.ls-dot {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--c, var(--ok));
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--ok)) 25%, transparent);
}

.ls-chip:hover {
  background: var(--panel-solid);
}

.ls-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* รายละเอียดเปิดอยู่ (จอใหญ่) → ไม่ทับแผงขวา */
@media (min-width: 900px) {
  .has-detail .lstat,
  .has-locate .lstat {
    right: calc(32px + var(--detail-w));
  }
}

/* ---------- ช่วงรางที่มีปัญหา: เส้นประเคลื่อนไหว + ป้ายกลางช่วง ---------- */
.seg-line {
  stroke-dasharray: 9 7;
  animation: seg-march 1.1s linear infinite;
}

@keyframes seg-march {
  to {
    stroke-dashoffset: -32;
  }
}

.seg-lbl {
  --c: var(--bad);

  position: absolute;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  max-width: 220px;
  padding: 3px 9px 3px 6px;
  font: 600 11.5px/1.3 var(--font);
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  background: color-mix(in srgb, var(--c) 88%, #000);
  border: 1.5px solid #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
  transform: translate(-50%, -50%);
}

.seg-lbl.warn {
  --c: #b45309;
}

.seg-lbl span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-lbl:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ป้ายย่อ "⚠ งดเดิน" อยู่ใต้หมุดขบวน (map.js zIndexOffset ติดลบ) — ชี้เมาส์/โฟกัสคีย์บอร์ด → ชื่อช่วงเต็ม ยกขึ้นบนสุด
   จอสัมผัสไม่กางค้าง (hover ค้างหลังแตะบน iOS) · แตะ = แผ่นรายละเอียดของโซน */
.seg-lbl .seg-full {
  display: none;
}

.seg-lbl:focus-visible .seg-short {
  display: none;
}

.seg-lbl:focus-visible .seg-full {
  display: inline;
}

.seg-lbl-icon:has(.seg-lbl:focus-visible) {
  z-index: 100000 !important;
}

@media (hover: hover) {
  .seg-lbl:hover .seg-short {
    display: none;
  }

  .seg-lbl:hover .seg-full {
    display: inline;
  }

  .seg-lbl-icon:hover {
    z-index: 100000 !important;
  }
}

/* ---------- แผ่นรายละเอียดโซน ---------- */
.ls-head {
  --c: var(--ok);

  border-bottom: 3px solid var(--c);
}

.ls-head.bad {
  --c: var(--bad);
}

.ls-head.warn {
  --c: var(--warn);
}

.ls-title {
  margin: 2px 0 4px;
  font-size: 21px;
}

.ls-state {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  font-weight: 600;
}

.ls-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ls-h {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  font-size: 14.5px;
}

.ls-segs,
.ls-cxls,
.ls-incs {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ls-seg {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.ls-seg i {
  flex: none;
  width: 22px;
  height: 0;
  border-top: 3px dashed var(--bad);
}

.ls-seg.warn i {
  border-top-color: var(--warn);
}

.ls-cxls li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13.5px;
}

.ls-cxls b {
  flex: none;
  min-width: 42px;
}

.ls-cxls span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ls-cxls small {
  font-size: 12px;
}

.ls-incs a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.ls-incs b {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
}

.ls-incs small,
.ls-src {
  font-size: 12px;
  color: var(--muted);
}

.ls-src {
  margin: 0 4px;
}

.ls-all {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
}

/* ข้อมูลอ่อนไหว (งดเดิน/ล่าช้า/เวลาถึง) → ตรวจสอบกับเว็บไซต์ รฟท. อีกครั้ง (panels.verifyHtml) */
.verify {
  --i: 16px;

  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--warn-t);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: 12px;
}

.verify > svg {
  flex: none;
  margin-top: 2px;
}

.verify span {
  color: var(--text);
}

.verify a {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.verify.pad {
  margin: 12px 0 0;
}

.verify.in-card {
  margin-top: 8px;
}

/* ---------- หน้าต่าง "ดูทั้งหมด": แตะสายเพื่อกางรายละเอียด ---------- */
.sd-zones {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.sd-zone,
.sd-ok {
  --c: var(--ok);

  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sd-zone.bad {
  --c: var(--bad);

  border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
}

.sd-zone.warn {
  --c: var(--warn);

  border-color: color-mix(in srgb, var(--warn) 40%, var(--line));
}

.sd-zone summary,
.sd-ok summary {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 8px 12px;
  list-style: none;
  cursor: pointer;
  border-radius: 14px;
}

.sd-zone summary::-webkit-details-marker,
.sd-ok summary::-webkit-details-marker {
  display: none;
}

.sd-zone summary:focus-visible,
.sd-ok summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.sd-zone .ls-dot,
.sd-ok .ls-dot {
  flex: none;
}

.sd-main {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.sd-main b {
  font-size: 14.5px;
}

.sd-main small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c);
}

.sd-ok summary b {
  flex: 1;
  font-size: 14px;
}

/* ลูกศร ˅ บอกว่ากางได้ · กางแล้วหมุนขึ้น */
.sd-more {
  flex: none;
  width: 9px;
  height: 9px;
  margin: 0 6px 4px;
  border-right: 2.5px solid var(--muted);
  border-bottom: 2.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
}

details[open] > summary .sd-more {
  margin: 4px 6px 0;
  transform: rotate(225deg);
}

.sd-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.sd-body .card {
  padding: 10px 12px;
  background: var(--panel-solid);
}

.sd-map {
  justify-self: start;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 600;
}

.sd-ok {
  margin-top: 8px;
}

.sd-oklist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
}

.sd-oklist li {
  padding: 4px 10px;
  font-size: 12.5px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.status-dialog-body .ls-src {
  margin: 14px 4px 4px;
}

.status-dialog-body .page-link {
  margin: 6px 4px 0;
}

/* ซูมไกล (ทั้งประเทศ): ไม่มีป้าย เหลือเส้นประบนราง (แถบสถานะด้านบนเป็นทางเข้า) · ป้ายที่ทับกันซ่อน */
.zs .seg-lbl,
.seg-lbl.is-off {
  visibility: hidden;
}

/* จอสัมผัส: ป้ายช่วงรางสูง ≥ 32 px + พื้นที่แตะรอบป้าย ≥ 44 px */
@media (pointer: coarse) {
  .seg-lbl {
    min-height: 32px;
    padding: 5px 11px 5px 8px;
    font-size: 12.5px;
  }

  .seg-lbl::after {
    position: absolute;
    inset: -6px -4px;
    content: "";
  }
}

/* ---------- มือถือ: แถบอยู่บนสุดซ้าย ไม่ทับปุ่มแผนที่ (ขวาบน 52px) และรอยบาก ---------- */
@media (max-width: 899px) {
  /* แถวเดียว (ชิปปัดได้ + ดูทั้งหมด) — แถบสูง 2 แถวกินแผนที่จนซูมไทยเล็กลง · สรุปจำนวนอยู่ในหน้าต่างดูทั้งหมด */
  .lstat {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(72px + env(safe-area-inset-right));
    left: calc(8px + env(safe-area-inset-left));
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    padding: 3px;
  }

  .lstat-main {
    display: contents;
  }

  .lstat-summary {
    display: none;
  }

  .lstat-rail {
    order: -1;
    grid-template-columns: minmax(0, 1fr);
  }

  .lstat-scroll {
    padding-inline-end: 12px;
    mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  }

  .lstat-step {
    display: none;
  }

  /* มือถือ: ต่อท้ายแถวชิป คั่นด้วยเส้นบางๆ */
  .lstat-all {
    padding: 0 4px 0 10px;
    font-size: 13px;
    border-left-color: var(--line);
    border-radius: 0 10px 10px 0;
  }

  .status-dialog {
    inset: auto 0 0;
    width: 100%;
    max-height: 78dvh;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 20px 20px 0 0;
  }

  .ls-chip {
    min-height: 44px;
    font-size: 12.5px;
  }

  /* จอแคบ: ชื่อสั้นของเขต (กทม./ตะวันออก — data-short) แทนชื่อเต็ม · iPhone SE เคยเห็น "กรุงเ… · งดเดิน 20" อ่านไม่ออก */
  .lstat-scroll .ls-chip.ls-zone {
    gap: 7px;
    padding: 3px 11px 3px 10px;
  }

  .ls-chip .ls-name[data-short]::before {
    content: attr(data-short);
  }

  .ls-chip .ls-name[data-short] .ls-full {
    display: none;
  }

  /* คำอธิบายสีหมุดย้ายไปอยู่ในวิธีใช้ (?) — บนสุดของแผนที่เป็นของสถานะเส้นทาง */
  .legend {
    display: none;
  }

  .has-locpill .lstat {
    visibility: hidden;
    pointer-events: none;
  }

  .panel[data-snap="full"] ~ .lstat,
  .detail:not([hidden])[data-snap="full"] ~ .lstat {
    visibility: hidden;
  }
}

@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .lstat {
    top: calc(8px + env(safe-area-inset-top));
    left: calc(var(--side-l) + var(--side-w) + 8px);
  }
}

.kid .lstat {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .seg-line {
    animation: none;
  }
}

/* หน้าต่าง "ดูทั้งหมด": อธิบายคำว่างดเดิน/ประกาศ + เลขบนแท็บ */
.ls-legend {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* วิธีใช้ (guide.js legendHtml): ป้าย "ช้า N นาที" (รฟท. รายงาน) ≠ "เลยเวลา N นาที" (ยังไม่มีรายงาน) ในรายการขบวน */
.guide-legend li.lg-def {
  gap: 6px;
  align-items: baseline;
}

.lg-pill {
  flex: none;
  padding: 1px 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ct, var(--muted));
  white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--idle)) 16%, transparent);
  border-radius: 8px;
}

/* css/ask.css */
.ask-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  opacity: 1;
  transform: none;

  /* เปิด/ปิด: จางเข้า + ลอยขึ้นเล็กน้อย (ดู @starting-style ท้ายไฟล์) */
  transition: opacity 0.2s ease-out, transform 0.2s ease-out, overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}

.ask-dialog::backdrop {
  background: rgb(0 0 0 / 65%);
  transition: background-color 0.2s, overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}

.ask-dialog header {
  box-shadow: 0 -20px 0 var(--bg);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ask-dialog h2 {
  margin: 0;
  font-size: 1.25rem;
}

.ask-dialog p { line-height: 1.6; }

.ask-dialog label {
  display: block;
  margin-bottom: 8px;
}

.ask-dialog textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 10px;
  resize: vertical;
}

.ask-dialog button {
  min-width: 44px;
  min-height: 44px;
}

.ask-dialog [type="submit"] { margin-top: 10px; }
.ask-dialog a { overflow-wrap: anywhere; }

.ask-dialog :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

#askAnswer {
  overflow-wrap: anywhere;
  margin-top: 16px;
}


/* ตัวอย่างคำถาม (แตะแล้วถามเลย) */
.ask-chips {
  display: grid;
  gap: 6px;
  margin: 4px 0 14px;
}

.ask-chips-label {
  font-size: 13px;
  color: var(--muted);
}

.ask-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ask-dialog .ask-chip {
  min-height: 36px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--accent);
  text-align: start;
  cursor: pointer;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  animation: ask-in 0.25s ease-out both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.ask-dialog .ask-chip:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
}

/* คำตอบ: ประโยคหลักตัวหนา → รายการ → หมายเหตุ → ลิงก์เปิดบนแผนที่ → แหล่งข้อมูล */
#askAnswer .ask-main {
  margin: 0 0 8px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.55;
}

#askAnswer .ask-list {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
  padding-left: 20px;
  line-height: 1.5;
}

#askAnswer .ask-note {
  margin: 6px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

#askAnswer .ask-go {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: var(--accent);
}

#askAnswer .ask-src {
  margin: 4px 0 0;
  font-size: 12px;
}

/* ---------- ช่องพิมพ์ + ปุ่มส่ง ---------- */
.ask-send-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}

.ask-dialog .ask-send-row [type="submit"] {
  margin-top: 0;
}

.ask-kbd {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

/* จอสัมผัส: แป้นพิมพ์มีปุ่ม "ส่ง" เอง ไม่ต้องบอกคีย์ลัด */
@media (pointer: coarse) {
  .ask-kbd {
    display: none;
  }
}

.ask-dialog .ask-send {
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.ask-dialog .ask-send svg {
  width: 18px;
  height: 18px;

  /* .chip-btn > svg ใช้สี accent = สีเดียวกับพื้นปุ่ม → ไอคอนหาย · ใช้สีตัวอักษรของปุ่ม */
  color: inherit;
}

.ask-dialog .ask-send:disabled {
  opacity: 0.6;
}

/* ---------- กำลังหาคำตอบ: จุดกระพริบ ---------- */
.ask-loading {
  display: flex;
  gap: 2px;
  align-items: baseline;
  margin: 0;
  color: var(--muted);
}

.ask-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.ask-dots i {
  width: 5px;
  height: 5px;
  background: currentcolor;
  border-radius: 50%;
  animation: ask-dot 1.2s infinite ease-in-out;
}

.ask-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.ask-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ask-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ---------- การ์ดคำตอบ ---------- */
#askAnswer .ask-card {
  padding: 14px 16px;
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
  border: 1px solid var(--line);
  border-radius: 14px;
  animation: ask-in 0.25s ease-out both;
}

#askAnswer[data-kind="msg"] {
  padding: 12px 14px;
  line-height: 1.6;
  background: var(--card);
  border-radius: 12px;
  animation: ask-in 0.2s ease-out both;
}

@keyframes ask-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- เปิด/ปิดหน้าต่าง: จางเข้า + ลอยขึ้นเล็กน้อย (มือถือ = แผ่นเลื่อนขึ้นจากขอบล่าง) ----------
   ปิด: element ปิดทันที (open = false) ส่วนภาพค่อยๆ จางด้วย transition แบบ allow-discrete
   เบราว์เซอร์ที่ไม่รองรับ = เปิด/ปิดทันทีเหมือนเดิม */
.ask-dialog:not([open]) {
  opacity: 0;
  transform: translateY(12px);
}

@starting-style {
  .ask-dialog[open] {
    opacity: 0;
    transform: translateY(12px);
  }
}

@starting-style {
  .ask-dialog[open]::backdrop {
    background-color: rgb(0 0 0 / 0%);
  }
}

@media (max-width: 640px) {
  .ask-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    margin: auto 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    transition-duration: 0.28s;
  }

  .ask-dialog:not([open]) {
    transform: translateY(100%);
  }

  @starting-style {
    .ask-dialog[open] {
      transform: translateY(100%);
    }
  }
}

/* ---------- คีย์บอร์ดขึ้น (viewport.js: html.kb-open + --vvt/--vvh = ส่วนที่มองเห็นจริง) ----------
   iOS Safari: คีย์บอร์ดย่อแค่ visual viewport — 88dvh และขอบล่างของ layout viewport อยู่ใต้คีย์บอร์ด
   → กล่องพอดีส่วนที่มองเห็น · ซ่อนคำอธิบาย/ท้ายกล่อง · ตัวอย่างคำถามเหลือแถวเดียวเลื่อนข้าง
   · ช่องพิมพ์ + ปุ่มส่งแถวเดียวกัน อยู่เหนือคีย์บอร์ดเสมอ · คำตอบเลื่อนในกรอบของตัวเอง */
@media (max-width: 899px) {
  html.kb-open .ask-dialog[open] {
    display: flex;
    flex-direction: column;
    gap: 10px;
    top: calc(var(--vvt, 0px) + 8px);
    bottom: auto;
    max-height: calc(var(--vvh, 100dvh) - 16px);
    margin: 0 auto;
    padding: 12px 16px;
    transition: none;
  }

  html.kb-open .ask-dialog > * {
    flex: none;
  }

  html.kb-open .ask-dialog h2 {
    font-size: 1.1rem;
  }

  html.kb-open #askHint,
  html.kb-open #askAnswer ~ p {
    display: none;
  }

  html.kb-open .ask-chips {
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
  }

  html.kb-open .ask-chips-label,
  html.kb-open .ask-dialog form label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
  }

  html.kb-open .ask-chip-list {
    flex-wrap: nowrap;
    min-width: 0;
    margin: 0 -16px;
    padding: 0 16px;
    overflow: auto hidden;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 16px;
    scrollbar-width: none;
  }

  html.kb-open .ask-chip-list::-webkit-scrollbar {
    display: none;
  }

  html.kb-open .ask-dialog .ask-chip {
    flex: none;
    white-space: nowrap;
    animation: none;
  }

  html.kb-open .ask-dialog form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
  }

  html.kb-open .ask-dialog textarea {
    height: 56px;
    min-height: 44px;
    resize: none;

    /* กล่องเตี้ยมาก (แนวนอน) ต้องเลื่อน: ช่องพิมพ์ไม่มุดใต้หัวกล่องที่ปักไว้ */
    scroll-margin-top: 64px;
  }

  html.kb-open .ask-send-row {
    margin-top: 0;
  }

  html.kb-open .ask-dialog .ask-send {
    padding: 0 14px;
    white-space: nowrap;
  }

  html.kb-open #askAnswer {
    flex: 0 1 auto;
    min-height: 0;
    margin-top: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  html.kb-open #askAnswer:empty {
    display: none;
  }
}

/* มือถือ (แผ่นจากขอบล่าง): แผ่นยาวถึงขอบบนคีย์บอร์ดพอดี */
@media (max-width: 640px) {
  html.kb-open .ask-dialog[open] {
    height: calc(var(--vvh, 100dvh) - 8px);
    max-height: none;
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ask-dialog,
  .ask-dialog::backdrop {
    transition: none;
  }

  .ask-dots i,
  .ask-dialog .ask-chip,
  #askAnswer .ask-card,
  #askAnswer[data-kind="msg"] {
    animation: none;
  }
}

/* css/feedback.css */
/* ติดต่อ / แจ้งปัญหา / เสนอแนะ (js/feedback.js) — จอคอม = กล่องกลางจอ · มือถือ = แผ่นจากขอบล่าง */
.fb-dialog {
  box-sizing: border-box;
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0 20px 20px;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 30%);
}

.fb-dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

.fb-dialog header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  margin: 0 -20px;
  padding: 8px 12px 8px 20px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
}

.fb-dialog h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.fb-dialog .icon-btn {
  flex: none;
  min-width: 44px;
  min-height: 44px;
}

.fb-intro {
  margin: 14px 0 10px;
  font-size: 14px;
  line-height: 1.6;
}

.fb-cats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.fb-cats legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

/* ยังไม่เลือกหมวด: ข้อความแจ้งใต้หัวข้อ เห็นพร้อมหมวดที่ต้องเลือก (feedback.js showError) */
.fb-err {
  grid-column: 1 / -1;
  margin: -4px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--bad-t, var(--bad));
}

.fb-err:empty {
  display: none;
}

/* เลื่อนหาช่องที่ผิด/ข้อความแจ้ง: เว้นหัวกล่องที่ปักไว้ด้านบน (ชื่อ 2 บรรทัดบนจอแคบ) */
.fb-cats,
.fb-dialog textarea,
.fb-consent,
.fb-status {
  scroll-margin: 88px 0 16px;
}

.fb-cats label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.fb-cats label:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-solid));
  border-color: var(--accent);
}

.fb-cats input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.fb-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.fb-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  font: inherit;

  /* 16px กัน iOS ซูมเข้าเองตอนแตะช่องพิมพ์ */
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.fb-count {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* กับดักบอต — ซ่อนจากคนทั้งตาและโปรแกรมอ่านจอ */
.fb-photo {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px dashed var(--muted);
  border-radius: 10px;
}

.fb-photo[hidden] {
  display: none;
}

.fb-photo-hint {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.fb-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.45;
}

.fb-consent input {
  margin-top: 3px;
}

.fb-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.fb-dialog .fb-send {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.fb-dialog .fb-send > svg {
  /* .chip-btn > svg ใช้สี accent = สีเดียวกับพื้นปุ่ม → ไอคอนหาย */
  color: inherit;
}

.fb-dialog .fb-send:disabled {
  cursor: progress;
  opacity: 0.7;
}

.fb-status {
  /* อยู่เหนือปุ่มส่ง · จองที่ไว้ 1 บรรทัด ปุ่มไม่กระโดดตอนข้อความขึ้น */
  min-height: 1.5em;
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.fb-status[data-kind="ok"] {
  color: var(--ok-t, var(--ok));
}

.fb-status[data-kind="error"] {
  color: var(--bad-t, var(--bad));
}

.fb-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.fb-note a,
.fb-privacy {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.fb-dialog :focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ปุ่มเปิดในแผงหลัก (ใต้ "ข้อมูลและเว็บไซต์ทางการ") */

/* ปุ่มในแถวปุ่มหลัก: คู่กับโหมดเด็ก (โหมดเด็กเลิกกินเต็มแถว) · โหมดเด็กซ่อน */
.quick .kid-toggle {
  grid-column: auto;
}

.quick .fb-quick {
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.quick .fb-quick > svg {
  color: inherit;
}

.kid .quick .fb-quick {
  display: none;
}

/* โหมดเด็ก: ปุ่มออกจากโหมดเด็กเต็มแถวเหมือนเดิม (ปุ่มติชมซ่อน) */
.kid .quick .kid-toggle {
  grid-column: 1 / -1;
}

/* มือถือ: "ใกล้ฉัน" ย้ายไปเมนูล่าง → ปุ่มเหลือคี่ ปุ่มติชมเต็มแถวสุดท้าย (ไม่เหลือครึ่งแถวโดดๆ) */
@media (max-width: 899px) {
  html:not(.kid) .quick .fb-quick {
    grid-column: 1 / -1;
  }
}

@media (max-width: 899px) {
  .fb-dialog {
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
}

@media (max-width: 359px) {
  .fb-cats {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- คีย์บอร์ดขึ้น (viewport.js: html.kb-open + --vvt/--vvh) ----------
   iOS: แผ่น 88dvh ชิดขอบล่าง layout viewport จมใต้คีย์บอร์ด → แผ่นพอดีส่วนที่มองเห็น
   ซ่อนคำอธิบาย/ท้ายกล่อง · ช่องพิมพ์เลื่อนเข้าจอเอง (viewport.js) · ปุ่มส่งปักขอบล่างเหนือคีย์บอร์ด */
@media (max-width: 899px) {
  html.kb-open .fb-dialog[open] {
    top: calc(var(--vvt, 0px) + 8px);
    bottom: auto;
    height: calc(var(--vvh, 100dvh) - 8px);
    max-height: none;
    padding-bottom: 8px;
  }

  html.kb-open .fb-intro,
  html.kb-open .fb-note,
  html.kb-open .fb-privacy {
    display: none;
  }

  html.kb-open .fb-cats {
    margin-top: 12px;
  }

  html.kb-open .fb-dialog textarea {
    height: 80px;
    min-height: 0;
    resize: none;

    /* เว้นหัวกล่อง + ป้าย "รายละเอียด" ด้านบน และปุ่มส่งที่ปักไว้ด้านล่าง (iPhone SE เห็นครบ ~250px) */
    scroll-margin: 92px 0 72px;
  }

  html.kb-open .fb-status {
    scroll-margin-bottom: 64px;
  }

  html.kb-open .fb-dialog .fb-send {
    position: sticky;
    bottom: 8px;
    z-index: 1;
    box-shadow: 0 8px 0 8px var(--panel-solid);
  }
}

/* มือถือแนวนอน + คีย์บอร์ด: เหลือที่ ~130px → หัวกล่องไม่ปัก (เลื่อนพ้นไป) ช่องพิมพ์เตี้ยลง ให้ช่องพิมพ์ + ปุ่มส่งพอดี */
@media (max-width: 899px) and (max-height: 500px) {
  html.kb-open .fb-dialog header {
    position: static;
  }

  html.kb-open .fb-dialog textarea {
    height: 56px;
    scroll-margin: 8px 0 62px;
  }
}

/* css/locosearch.css */
/* ค้นหาจากหัวรถจักร/รุ่นรถ (locosearch.js) — แถบตัวกรองเหนือชิปประเภท + ปุ่มในแกลเลอรี */
.loco-bar {
  margin: 6px 8px 0;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 14px;
}

.loco-bar[hidden] {
  display: none;
}

.loco-bar-main {
  --i: 22px;

  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--accent);
}

.loco-bar-main > svg {
  flex: none;
  width: var(--i);
  height: var(--i);
}

.loco-bar-main p {
  display: grid;
  flex: 1;
  gap: 1px;
  min-width: 0;
  margin: 0;
  color: var(--text);
}

.loco-bar-main b {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.loco-bar-main span {
  font-size: 12.5px;
  color: var(--muted);
}

.loco-clear {
  --i: 16px;

  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
}

.loco-note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.loco-note a {
  font-weight: 600;
  color: var(--accent);
}

/* แกลเลอรี: ดูทุกขบวนที่ปกติใช้รุ่นนี้บนแผนที่ */
.stk-live .loco-show {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.stk-live .loco-show > svg {
  color: inherit;
}

/* css/sharecard.css */
/* แชร์เป็นรูป (js/sharecard.js) — จอคอม = กล่องกลางจอ · มือถือแนวตั้ง = แผ่นจากขอบล่าง วางเหนือเมนูล่าง (--bnav-h)
   มือถือแนวนอน = รูปซ้าย ปุ่มขวา */
.sc-dialog {
  box-sizing: border-box;
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0 20px 18px;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 30%);
}

.sc-dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

.sc-dialog header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin: 0 -20px;
  padding: 6px 10px 6px 20px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
}

.sc-dialog h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.sc-dialog .icon-btn {
  flex: none;
  min-width: 44px;
  min-height: 44px;
}

/* พรีวิว: รูปทั้งใบ (4:5) ไม่ครอป · ระหว่างสร้างเป็นกรอบว่าง + ข้อความ */
.sc-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 0;
}

.sc-preview[aria-busy="true"] {
  min-height: min(44dvh, 360px);
  background: var(--card);
  border-radius: 14px;
}

.sc-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(58dvh, 620px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 22px rgb(0 0 0 / 18%);
}

.sc-preview img[hidden],
.sc-making[hidden] {
  display: none;
}

.sc-making {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.sc-hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

/* ปุ่ม: แชร์รูปเต็มแถว (ปุ่มหลัก) · บันทึกรูป + คัดลอกลิงก์ครึ่งแถว */
.sc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.sc-actions .chip-btn {
  height: 46px;
  font-weight: 600;
}

.sc-actions .chip-btn[hidden] {
  display: none;
}

.sc-actions .chip-btn:disabled {
  cursor: progress;
  opacity: 0.5;
}

.sc-actions .sc-primary {
  grid-column: 1 / -1;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.sc-actions .sc-primary > svg {
  /* .chip-btn > svg ใช้สี accent = สีเดียวกับพื้นปุ่ม → ไอคอนหาย */
  color: inherit;
}

.sc-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sc-status[data-kind="ok"] {
  color: var(--ok-t, var(--ok));
}

.sc-status[data-kind="error"] {
  color: var(--bad-t, var(--bad));
}

.sc-dialog :focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ปุ่ม "รูป" ในหัวแผงขบวน (ข้างปุ่มแชร์ลิงก์) · ที่ไม่พอจริงๆ ข้อความในปุ่มย่อเป็น … (ไม่ดันแถวล้น) */
.train-head .dt-btn.sc-open {
  flex: 0 1 auto;
  gap: 5px;
  min-width: 40px;
  padding: 0 10px;
  overflow: hidden;
}

.train-head .dt-btn.sc-open > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* จอแคบ (Fold 344 / iPhone SE) และแผ่นด้านข้างของมือถือแนวนอน: ปุ่มในแถวชิดกันขึ้นเล็กน้อยให้พอดีแถวเดียว */
@media (max-width: 379px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .train-head .dt-bar {
    gap: 4px;
  }

  .train-head .dt-btn.wide {
    gap: 5px;
    padding: 0 9px;
  }

  .train-head .dt-btn.sc-open {
    padding: 0 8px;
  }
}

/* แถวปุ่มแคบกว่า ~310px (จอ 320 · แผ่นด้านข้างของมือถือแนวนอนจอเล็ก เช่น 667×375): ข้อความไว้ใต้ไอคอน
   แบบปุ่มบนแผนที่ (ทั้งไทย/แบบแผนที่) — ยังมีทั้งไอคอนและข้อความ ไม่ถูกตัด */
@media (max-width: 341px), (max-width: 759px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .train-head .dt-btn.sc-open {
    --i: 17px;

    flex-direction: column;
    flex-shrink: 0;
    gap: 1px;
    min-width: 44px;
    padding: 0 5px;
    font-size: 11px;
    line-height: 1.15;
  }
}

/* มือถือแนวตั้ง: แผ่นจากขอบล่าง เหนือเมนูล่าง */
@media (max-width: 899px) and (min-height: 501px), (max-width: 899px) and (max-aspect-ratio: 4/3) {
  .sc-dialog {
    inset: auto 0 var(--bnav-h);
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--bnav-h) - 24px);
    margin: 0;
    padding: 0 16px 16px;
    border-radius: 20px 20px 0 0;
  }

  .sc-dialog::backdrop {
    bottom: var(--bnav-h);
  }

  .sc-dialog header {
    margin: 0 -16px;
    padding-left: 16px;
  }

  .sc-preview img {
    max-height: calc(100dvh - var(--bnav-h) - 280px);
  }

  /* มีปุ่มแชร์รูป (แถวปุ่มเพิ่ม 1 แถว) → รูปเล็กลงอีกนิด ปุ่มทั้งหมดยังเห็นโดยไม่ต้องเลื่อน */
  .sc-dialog:has(.sc-primary:not([hidden])) .sc-preview img {
    max-height: calc(100dvh - var(--bnav-h) - 336px);
  }

  /* จอเตี้ย (iPhone SE + แถบเบราว์เซอร์): ซ่อนคำอธิบาย ให้รูปใหญ่ขึ้น */
  @media (max-height: 620px) {
    .sc-hint {
      display: none;
    }

    .sc-preview img {
      max-height: calc(100dvh - var(--bnav-h) - 226px);
    }

    .sc-dialog:has(.sc-primary:not([hidden])) .sc-preview img {
      max-height: calc(100dvh - var(--bnav-h) - 282px);
    }
  }

  /* โหมดเด็ก/คีย์บอร์ด: ไม่มีเมนูล่าง → เว้นขอบล่างของ iPhone เอง */
  .kid .sc-dialog,
  html.kb-open .sc-dialog {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

/* มือถือแนวนอน: รูปซ้าย ปุ่มขวา (จอเตี้ย รูปเรียงต่อกันจะเล็กเกินไป) */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .sc-dialog {
    width: min(760px, calc(100% - 24px));
    max-height: calc(100dvh - 16px);
  }

  .sc-dialog[open] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: 16px;
    align-content: start;
  }

  .sc-dialog header {
    grid-column: 1 / -1;
  }

  .sc-preview {
    grid-row: 2 / span 4;
    margin-bottom: 4px;
  }

  .sc-preview[aria-busy="true"] {
    width: 200px;
    min-height: 250px;
  }

  .sc-preview img {
    max-height: calc(100dvh - 100px);
  }

  .sc-hint,
  .sc-actions {
    margin-top: 14px;
  }

  .sc-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* css/mlist.css */
/* เรดาร์รถไฟ — โหมดรายการบนมือถือ (เจ้าของ 3 ต.ค. 2569: กด "ขบวน" ที่เมนูล่างแล้วรายการเริ่มเกือบล่างจอ ต้องเลื่อนผ่านหัวแผง/ปุ่มลัด/แท็บ)
   app.js syncPanelMode(): แผงที่กางขึ้น (เมนูล่าง/ที่จับ/ลาก) = #panel[data-mode="list"] เสมอ · ย่อ (peek) = หน้าแรก
   (3 ต.ค.: เจ้าของลากแผงขึ้นเองแล้วรายการยังอยู่ล่างจอ) · ปุ่มลัดเหลือแถวเดียวปัดได้ · สถานะเดินรถเข้าจากแถบสถานะบนแผนที่ (แท็บครบ)
   แนวตั้ง: ช่องค้นหา + ชิปสรุปอยู่นอกส่วนที่เลื่อน (.views) จึงติดบนเสมอ · แนวนอน: เลื่อนทั้งแผ่นเหมือนเดิม (จอเตี้ย ติดบนแล้วรายการเหลือนิดเดียว)
   จอใหญ่ (≥ 900 px) และโหมดเด็ก (ไม่มีเมนูล่าง) ไม่เปลี่ยน */
@media (max-width: 899px) {
  /* เมนูล่างทำหน้าที่แทนแท็บ · ปุ่มลัด/ลิงก์หน้าเว็บ/ปุ่ม ? ภาษา ธีม อยู่หน้าแรกของแผง */
  html:not(.kid) .panel[data-mode="list"] .tabs,
  html:not(.kid) .panel[data-mode="list"] .page-links,
  html:not(.kid) .panel[data-mode="list"] .brand-logo,
  html:not(.kid) .panel[data-mode="list"] #helpBtn,
  html:not(.kid) .panel[data-mode="list"] .lang-btn,
  html:not(.kid) .panel[data-mode="list"] #themeBtn {
    display: none;
  }

  /* ปุ่มลัดแถวเดียว ปัดซ้าย-ขวาได้ (3 ต.ค.: แผงที่ลากขึ้นเองก็เป็นโหมดรายการแล้ว ปุ่มลัดต้องยังอยู่ครบ ไม่ซ่อน) */
  html:not(.kid) .panel[data-mode="list"] .quick {
    display: flex;
    gap: 6px;
    margin: 6px 0 0;
    padding: 0 16px 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  html:not(.kid) .panel[data-mode="list"] .quick::-webkit-scrollbar {
    display: none;
  }

  html:not(.kid) .panel[data-mode="list"] .quick > .chip-btn {
    flex: 0 0 auto;
    height: 40px;
    padding: 0 12px;
  }

  /* หัวแผงแถวเดียว 40 px: ชื่อเว็บ · ที่จับ v (กลางแถว) · ป้ายอัปเดต — ต่างคนต่างมีพื้นที่แตะ 40 px ไม่ทับกัน
     (เดิมที่จับอยู่แถวบนของตัวเอง + พื้นที่แตะยื่นลงมาทับแถวถัดไป) · แตะชื่อเว็บ = เหมือนแตะที่จับ (sheetDrag) */
  html:not(.kid) .panel[data-mode="list"] .panel-grip {
    position: absolute;
    top: 4px;
    left: calc(50% - 32px);
    z-index: 3;
    width: 64px;
    height: 40px;
    min-height: 0;
    padding: 0;
  }

  html:not(.kid) .panel[data-mode="list"] .panel-grip::after {
    inset: 0;
  }

  html:not(.kid) .panel[data-mode="list"] .brand {
    grid-template-areas: "title . live";
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    gap: 0 6px;
    align-items: center;
    min-height: 48px;
    padding: 4px 16px;
  }

  html:not(.kid) .panel[data-mode="list"] .brand h1 {
    font-size: 16px;
    line-height: 1.2;
  }

  /* ป้ายอัปเดต (แตะ = อัปเดต) ชิดขวา สูง 40 px · วันที่อยู่หน้าแรก · ข้อความยาว (ล่าช้า/ลองใหม่) ขึ้น 2 บรรทัดแทนการตัด */
  html:not(.kid) .panel[data-mode="list"] .brand .live {
    justify-self: end;
    min-height: 40px;
    margin: 0;
    white-space: normal;
  }

  html:not(.kid) .panel[data-mode="list"] .live-date {
    display: none;
  }

  html:not(.kid) .panel[data-mode="list"] #liveLabel {
    line-height: 1.2;
    text-overflow: clip;
  }

  /* ตัวเลขสรุป → ชิปแถวเดียว "45 กำลังวิ่ง" (ปุ่มเดิม แตะกรองได้เหมือนเดิม) · ไม่พอจริงๆ ขึ้นแถวสอง ไม่ตัดข้อความ */
  html:not(.kid) .panel[data-mode="list"] .stats {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
  }

  html:not(.kid) .panel[data-mode="list"] .stat {
    flex: 1 1 auto;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 7px;
    border-radius: 999px;
  }

  html:not(.kid) .panel[data-mode="list"] .stat b {
    font-size: 16px;
    line-height: 1;
  }

  html:not(.kid) .panel[data-mode="list"] .stat span {
    overflow: visible;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  /* ตัวกรองประเภท: แถวเดียวปัดซ้ายขวา (เดิมขึ้น 2–3 แถว ดันรายการลง) */
  html:not(.kid) .panel[data-mode="list"] .views {
    margin-top: 4px;
  }

  html:not(.kid) .panel[data-mode="list"] .filters {
    flex-wrap: nowrap;
    padding: 3px 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  html:not(.kid) .panel[data-mode="list"] .filters::-webkit-scrollbar {
    display: none;
  }

  html:not(.kid) .panel[data-mode="list"] .fchip {
    flex: none;
  }

  /* จำนวน + สวิตช์ แถวเดียว: ป้ายสวิตช์ยาวขึ้น 2 บรรทัดแทนการซ้อนสวิตช์ 2 แถว */
  html:not(.kid) .panel[data-mode="list"] .list-head {
    padding: 0 8px;
  }

  html:not(.kid) .panel[data-mode="list"] .switches {
    flex-wrap: nowrap;
    gap: 12px;
  }

  html:not(.kid) .panel[data-mode="list"] .switch {
    gap: 6px;
    line-height: 1.2;
  }
}

/* จอแคบ (ไทย < 375 px · อังกฤษ < 410 px) + แผ่นด้านซ้ายแนวนอน: ชิปแถวเดียวไม่พอ → 4 ช่องเท่ากัน ตัวเลขบน ป้ายล่าง (สูง 40 px) */
@media (max-width: 374px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  html:not(.kid) .panel[data-mode="list"] .stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  html:not(.kid) .panel[data-mode="list"] .stat {
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
  }

  html:not(.kid) .panel[data-mode="list"] .stat span {
    font-size: 11px;
    white-space: normal;
  }
}

@media (max-width: 409px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  html[lang="en"]:not(.kid) .panel[data-mode="list"] .stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  html[lang="en"]:not(.kid) .panel[data-mode="list"] .stat {
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
  }

  html[lang="en"]:not(.kid) .panel[data-mode="list"] .stat span {
    font-size: 11px;
    white-space: normal;
  }
}

/* css/presence.css */
/* จำนวนคนดู (presence.js) — ตัวเลขจาก server · ไม่มีข้อมูล = ซ่อน */

/* หัวแผง: ให้ .pr-site กินความกว้างคอลัมน์ 2–5 เต็มแถว (เหมือน .live) ไม่ให้โดนปุ่ม ? / TH-EN / ธีม เบียดจนข้อความขาด */
.brand:has(> .pr-site:not([hidden])) {
  grid-template-areas:
    "logo title help lang theme"
    "logo pr pr pr pr"
    "logo live live live live";
}

.pr-site {
  grid-area: pr;
  margin: -2px 0 2px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
}

.pr-site[hidden] {
  display: none;
}

/* มือถือ แผงกางเป็นรายการ: หัวแผงมีที่จับตรงกลาง ("title . live") → ให้ .pr-site อยู่แถวสองเต็มความกว้าง ไม่ชนที่จับ */
@media (max-width: 899px) {
  html:not(.kid) .panel[data-mode="list"] .brand:has(> .pr-site:not([hidden])) {
    grid-template-areas:
      "title . live"
      "pr pr pr";
  }

  html:not(.kid) .panel[data-mode="list"] .pr-site {
    margin: -4px 0 2px;
    font-size: 11px;
  }
}

/* หัวแผงขบวน: "🔥 N คนกำลังดูขบวนนี้" + "⭐ ขบวนยอดนิยม" (สีตามสีขบวน --tfg/--tbg) */
.pr-train {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.pr-train span {
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  background: color-mix(in srgb, currentcolor 14%, transparent);
  border: 1px solid color-mix(in srgb, currentcolor 28%, transparent);
  border-radius: 999px;
}

/* การ์ดเด็ก: "มีเพื่อนอีก N คนดูรถไฟขบวนนี้กับหนูอยู่นะ" */
.kid-friends {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  margin: 12px 0 0;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.4;
  background: color-mix(in srgb, #38bdf8 14%, var(--panel-solid));
  border-radius: 18px;
}

/* หมุดขบวนยอดนิยม: วงทองเรืองแสง + ⭐ หน้าเลขขบวน */
.tm.is-popular .tm-puck {
  box-shadow: 0 0 0 3px color-mix(in srgb, #fbbf24 70%, transparent), 0 0 16px color-mix(in srgb, #fbbf24 75%, transparent), 0 2px 6px rgb(0 0 0 / 45%);
}

.tm.is-popular .tm-label::before {
  margin-right: 3px;
  content: "⭐";
}

@media (prefers-reduced-motion: no-preference) {
  .tm.is-popular .tm-puck {
    animation: pr-glow 2.4s ease-in-out infinite;
  }
}

@keyframes pr-glow {
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, #fbbf24 45%, transparent), 0 0 24px color-mix(in srgb, #fbbf24 90%, transparent), 0 2px 6px rgb(0 0 0 / 45%);
  }
}

/* แถบขบวนกำลังฮิต (Most Tracked แบบ Flightradar24) — แถบเรดาร์โปร่งแสงไร้กรอบซ้อน กลมกลืนกับแผนที่ */
.pr-top {
  position: fixed;
  bottom: 58px;
  left: calc(32px + var(--panel-w));
  z-index: 890;
  display: flex;
  gap: 2px;
  align-items: center;
  max-width: calc(100vw - 120px - var(--panel-w));
  height: 36px;
  padding: 3px 6px 3px 12px;
  overflow: hidden;
  pointer-events: auto;
  background: color-mix(in srgb, var(--panel-solid) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 28%), inset 0 1px 0 rgb(255 255 255 / 8%);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}

.pr-top[hidden],
.kid .pr-top {
  display: none;
}

:root[data-theme="light"] .pr-top {
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  border-color: rgb(15 23 42 / 10%);
  box-shadow: 0 6px 20px rgb(15 23 42 / 12%), inset 0 1px 0 rgb(255 255 255 / 70%);
}

/* บนภาพดาวเทียม: ธีมมืดใช้พื้นกระจกเข้ม ธีมสว่างใช้พื้นขาวทึบกลมกลืนกับ legend */
:root[data-theme] .map.base-sat ~ .pr-top {
  color: #f8fafc;
  background: rgb(11 18 32 / 86%);
  border-color: rgb(255 255 255 / 18%);
  box-shadow: 0 8px 26px rgb(0 0 0 / 50%), inset 0 1px 0 rgb(255 255 255 / 12%);
}

:root[data-theme="light"] .map.base-sat ~ .pr-top {
  color: #0f172a;
  background: rgb(255 255 255 / 94%);
  border-color: rgb(15 23 42 / 12%);
  box-shadow: 0 8px 26px rgb(0 0 0 / 22%), inset 0 1px 0 rgb(255 255 255 / 80%);
}

@media (min-width: 900px) {
  .has-detail .pr-top,
  .has-locate .pr-top {
    max-width: calc(100vw - 120px - var(--panel-w) - var(--detail-w));
  }
}

@media (min-width: 900px) and (max-width: 1319px) {
  .has-detail .pr-top,
  .has-locate .pr-top {
    display: none;
  }
}

.pr-top-lbl {
  display: inline-flex;
  flex: none;
  gap: 6px;
  align-items: center;
  padding-right: 8px;
  margin-right: 2px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
  border-right: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
}

:root[data-theme] .map.base-sat ~ .pr-top .pr-top-lbl {
  color: #f8fafc;
  border-right-color: rgb(255 255 255 / 20%);
}

:root[data-theme="light"] .map.base-sat ~ .pr-top .pr-top-lbl {
  color: #0f172a;
  border-right-color: rgb(15 23 42 / 14%);
}

.pr-top-dot {
  flex: none;
  width: 7px;
  height: 7px;
  background: #f59e0b;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgb(245 158 11 / 25%), 0 0 8px #f59e0b;
}

.pr-top-list {
  display: flex;
  flex: 1;
  gap: 2px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.pr-top-list::-webkit-scrollbar {
  display: none;
}

.pr-top-chip {
  position: relative;
  display: inline-flex;
  flex: none;
  gap: 5px;
  align-items: center;
  height: 28px;
  padding: 0 8px 0 6px;
  font-size: 12px;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 999px;
  transition: background 0.15s, transform 0.1s;
}

.pr-top-chip + .pr-top-chip::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: -1px;
  width: 1px;
  content: "";
  background: color-mix(in srgb, currentcolor 14%, transparent);
}

.pr-top-chip:hover {
  background: color-mix(in srgb, currentcolor 10%, transparent);
}

.pr-top-chip:active {
  transform: scale(0.97);
}

.pr-top-no {
  padding: 2px 6px;
  font: 700 11px/1.15 var(--mono);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 22%);
}

.pr-top-to {
  max-width: 76px;
  overflow: hidden;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme] .map.base-sat ~ .pr-top .pr-top-to {
  color: #f8fafc;
}

:root[data-theme="light"] .map.base-sat ~ .pr-top .pr-top-to {
  color: #0f172a;
}

.pr-top-n {
  display: inline-flex;
  gap: 2.5px;
  align-items: center;
  font: 600 11px/1 var(--mono);
  color: var(--muted);
}

:root[data-theme] .map.base-sat ~ .pr-top .pr-top-n {
  color: #cbd5e1;
}

:root[data-theme="light"] .map.base-sat ~ .pr-top .pr-top-n {
  color: #64748b;
}

.pr-top-eye {
  flex: none;
  width: 12px;
  height: 12px;
  opacity: 0.78;
}

/* มือถือ: ลอยอยู่บนแผนที่ เหนือแผ่นย่อ (peek) · เว้นขวาไม่ชนปุ่ม i และซ่อนอัตโนมัติเมื่อกดเปิดเครดิตแผนที่ (i) */
@media (max-width: 899px) {
  .pr-top {
    right: auto;
    bottom: calc(var(--peek) + var(--bnav-h) + 6px);
    left: calc(10px + env(safe-area-inset-left));
    max-width: calc(100vw - 54px - env(safe-area-inset-left) - env(safe-area-inset-right));
    height: 34px;
    padding: 3px 6px 3px 10px;
  }

  .pr-top-chip {
    position: relative;
    height: 26px;
    padding: 0 7px 0 5px;
    font-size: 11.5px;
  }

  .pr-top-chip::after {
    position: absolute;
    inset: -5px -2px;
    content: "";
  }

  .pr-top-to {
    max-width: 96px;
  }

  .panel:not([data-snap="peek"]) ~ .pr-top,
  .detail:not([hidden]) ~ .pr-top,
  .map:has(.leaflet-control-attribution.is-open) ~ .pr-top {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
  }
}

@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .pr-top {
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: calc(var(--side-l) + var(--side-w) + 8px);
    max-width: calc(100vw - var(--side-l) - var(--side-w) - 54px);
  }

  .panel:not([data-snap="peek"]) ~ .pr-top {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
  }

  .map:has(.leaflet-control-attribution.is-open) ~ .pr-top {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
  }
}

@media (max-width: 380px) {
  html[lang="en"] .pr-top-lbl {
    font-size: 10.5px;
  }
}


/* css/gesture.css */
/* ป้ายบอกท่าทางบนมือถือ (public/js/gesturehint.js · เจ้าของ 18 ต.ค. 2569: ลูกศรเข้าใจยาก อยากรู้ว่าปัดซ้าย/ขึ้น/ลงได้)
   1) แถวที่ปัดซ้าย-ขวาได้: ขอบจาง + ปุ่ม › ‹ (โชว์เฉพาะตอนยังเลื่อนไปทางนั้นได้จริง) · เด้งสะกิด
   2) ที่จับแผง: ปุ่มสีฟ้าชัดขึ้น · ย่อ = "︿ ดูรายการ" · ครึ่งจอ = ปุ่มคู่ [︿ | ﹀] · เต็ม = ﹀ · ลูกศรเด้งไปทางที่แผงจะไป
   3) กันแตะทะลุตอนแผ่นเลื่อน (.is-settling) */

/* ---------- 1) แถวที่ปัดซ้าย-ขวาได้ ---------- */
.sh-wrap {
  position: relative;
  flex: none;
  min-width: 0;
}

/* ทั้งแถบจางไม่รับการแตะ (ชิปใต้ขอบจางยังกดได้) · รับเฉพาะปุ่มกลม */
.sh-btn {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  width: 34px;
  padding: 0 3px;
  margin: 0;
  color: var(--accent);
  pointer-events: none;
  cursor: pointer;
  background: none;
  border: 0;
  opacity: 0;
  transition: opacity 0.25s var(--ease, ease);
}

.sh-r {
  right: 0;
  justify-content: flex-end;
  background: linear-gradient(to right, transparent, var(--panel-solid) 72%);
}

.sh-l {
  left: 0;
  justify-content: flex-start;
  background: linear-gradient(to left, transparent, var(--panel-solid) 72%);
}

.sh-wrap.can-r .sh-r,
.sh-wrap.can-l .sh-l {
  opacity: 1;
}

.sh-wrap.can-r .sh-row,
.sh-wrap.can-r > :first-child {
  padding-inline-end: 34px;
}

.sh-btn span {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgb(0 0 0 / 22%);
}

.sh-btn:active span {
  scale: 0.9;
}

.sh-wrap.can-r .sh-r span,
.sh-wrap.can-l .sh-l span {
  pointer-events: auto;
}

/* พื้นที่แตะกว้างกว่าวงกลม 8 px รอบด้าน (วง 28 px → แตะได้ 44 px) */
.sh-btn span::after {
  position: absolute;
  inset: -8px;
  content: "";
}

/* ลูกศร › (ขวา) ‹ (ซ้าย) วาดด้วยเส้นขอบ — สีตามธีม */
.sh-btn span::before {
  width: 7px;
  height: 7px;
  margin-left: -3px;
  content: "";
  border-top: 2px solid currentcolor;
  border-right: 2px solid currentcolor;
  transform: rotate(45deg);
}

.sh-l span::before {
  margin-left: 3px;
  transform: rotate(-135deg);
}

/* ---------- 2) ที่จับแผง (มือถือแนวตั้ง — แนวนอน/คอมไม่เปลี่ยน) ---------- */
@media (max-width: 899px) and (min-height: 501px), (max-width: 899px) and (max-aspect-ratio: 4/3) {
  html:not(.kid) .panel {
    --grip: var(--accent);
  }

  html:not(.kid) .panel-grip span,
  html:not(.kid) .grip-down span {
    width: 52px;
    height: 28px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 14px;
  }

  /* โฟกัสคีย์บอร์ดของปุ่มคู่: วงรอบเฉพาะครึ่งที่โฟกัส */
  html:not(.kid) .panel-grip:focus-visible span,
  html:not(.kid) .grip-down:focus-visible span {
    outline-offset: 1px;
  }

  /* แผงย่อ: "︿ ดูรายการ" — คำอยู่ในปุ่มเดียวกับลูกศร (สูงเท่าเดิม ไม่กินแผนที่เพิ่ม) */
  html:not(.kid) .panel[data-snap="peek"] .panel-grip span[data-hint] {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    width: auto;
    padding: 0 13px 0 12px;
  }

  html:not(.kid) .panel[data-snap="peek"] .panel-grip span[data-hint]::after {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    color: var(--accent);
    white-space: nowrap;
    content: attr(data-hint);
  }

  /* ครึ่งจอ: ปุ่มคู่ติดกันกลางจอ [︿ เต็มจอ | ﹀ ย่อ] — ซ้าย = ที่จับเดิม (#grip) ขวา = #gripDown */
  html:not(.kid) .panel[data-snap="half"] #grip {
    padding: 0 46px 0 0;
  }

  html:not(.kid) .panel[data-snap="half"] .grip-down span {
    width: 46px;
    border-radius: 0 14px 14px 0;
    box-shadow: inset 1px 0 0 color-mix(in srgb, var(--accent) 30%, transparent);
  }

  html:not(.kid) .panel[data-snap="half"] #grip span {
    width: 46px;
    border-right-width: 0;
    border-radius: 14px 0 0 14px;
  }

  html:not(.kid) .panel[data-snap="half"] .grip-down {
    left: 50%;
    width: 46px;
  }

  /* โหมดรายการ (หัวแผงแถวเดียว): ช่องกลางกว้างพอปุ่มคู่ 92 px · ที่จับกินแค่ครึ่งซ้าย ไม่ทับปุ่ม ﹀ */
  html:not(.kid) .panel[data-mode="list"][data-snap="half"] .brand {
    grid-template-columns: minmax(0, 1fr) 92px minmax(0, 1fr);
  }

  html:not(.kid) .panel[data-mode="list"][data-snap="half"] #grip {
    left: calc(50% - 46px);
    width: 46px;
    padding: 0;
  }

  /* ที่จับ (min-height 44 ของครึ่งจอ) เริ่มที่ 4 px → ปุ่ม ﹀ ต้องเริ่มที่เดียวกัน ไม่งั้นปุ่มคู่เหลื่อมกัน 2 px */
  html:not(.kid) .panel[data-mode="list"][data-snap="half"] .grip-down {
    top: 4px;
  }
}

/* ---------- 3) กันแตะทะลุตอนแผ่นเลื่อน (gesturehint.js ใส่ .is-settling 450 ms หลังแผ่นเปลี่ยนขั้น/เพิ่งเปิด) ----------
   ลูกพี่ 20 ต.ค. 2569: แตะ ︿ แล้วเด้งไปเว็บซื้อตั๋ว (ปุ่มเลื่อนผ่านใต้นิ้ว) · การแตะตกที่ตัวแผ่นเอง = ไม่มีอะไรเกิด
   กล่องเลื่อน (รายการขบวน/ตารางเวลา) ยังรับนิ้ว → ปัดเลื่อนได้ทันที แต่แตะแถว/ปุ่มข้างในไม่ติด */
@media (max-width: 899px) {
  .is-settling * {
    pointer-events: none !important;
  }

  .is-settling :is(.views, .dt-body) {
    pointer-events: auto !important;
  }

  /* ลิงก์ออกนอกเว็บ (ซื้อตั๋ว/เว็บ รฟท.) กันนานกว่า 1.2 วิ: แตะซ้ำช้าๆ เพราะนึกว่าครั้งแรกไม่ติดก็ไม่หลุดออกจากเว็บ */
  .is-settling-out a[target="_blank"] {
    pointer-events: none !important;
  }
}

/* ---------- ลูกเล่น (ปิดเมื่อผู้ใช้ตั้งลดการเคลื่อนไหว) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* ปุ่ม › เด้งไปทางขวาตอนแถวโผล่ครั้งแรก/ตอนสะกิด */
  .sh-wrap.can-r .sh-r span::before {
    animation: gh-right 1.3s ease-in-out 0.8s 3;
  }

  .sh-wrap.is-nudging .sh-r span {
    animation: gh-pulse 0.9s ease-out 2;
  }

  /* ลูกศรที่จับเด้งไปทางที่แผงจะไป 3 ครั้ง หลังเปลี่ยนขั้นแผง/เปิดเว็บ (gesturehint.js ใส่ .is-hinting) */
  .panel.is-hinting .grip-down span::before,
  .panel.is-hinting .panel-grip[data-dir="down"] span::before {
    animation: gh-down 0.75s ease-in-out 3;
  }

  .panel.is-hinting .panel-grip[data-dir="up"] span::before {
    animation: gh-up 0.75s ease-in-out 3;
  }
}

@keyframes gh-up {
  50% {
    translate: 0 -4px;
  }
}

@keyframes gh-down {
  50% {
    translate: 0 4px;
  }
}

@keyframes gh-right {
  50% {
    translate: 4px 0;
  }
}

@keyframes gh-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  }

  100% {
    box-shadow: 0 0 0 10px transparent;
  }
}


/* lib/assets.js: CSS ครบแล้ว แสดงหน้า (คู่กับ <style> ที่ซ่อน body ไว้ในหน้า) */
body {
  visibility: visible;
  animation: none;
}
