/* PLANNER — trip page shell + plan tab + planner sheets. Prefix .pl-
   Design v2: clean white cards on --bg, violet→blue accents, glass only for floating chrome.
   Tokens only (dark mode follows). Every text-holding flex/grid child has min-width:0. */

/* ======================= SHELL: split / map ======================= */
.pl-split { min-height: 0; }
.pl-mapbox { background: var(--bg-2); }
.pl-map { z-index: 0; }

@media (max-width: 899.98px) {
  .pl-split .split-map { height: clamp(200px, 38dvh, 440px); }
}
/* phones in landscape: side by side so the panel isn't squeezed to a sliver */
@media (max-width: 899.98px) and (orientation: landscape) and (max-height: 560px) {
  .pl-split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .pl-split .split-map, .pl-split.map-tall .split-map {
    height: auto; order: 2; margin: 8px max(8px, var(--safe-right)) 8px 0;
    border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-2);
  }
  .pl-split .split-panel { margin-top: 0; border-radius: 0; box-shadow: none; }
  .pl-split.map-collapsed { grid-template-columns: minmax(0, 1fr); }
  .pl-split.map-collapsed .split-map { display: none; }
  .pl-mapbtns [data-act="mapexpand"] { display: none; }
}

/* floating glass chrome over the map */
.pl-route-pill {
  position: absolute; z-index: 5;
  top: calc(var(--sp-3) + var(--safe-top)); left: max(var(--sp-3), var(--safe-left));
  max-width: calc(100% - 84px);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 40px; padding: 6px 14px 6px 12px;
  border-radius: var(--r-pill);
  color: var(--ink); font-size: var(--fs-sm); font-weight: 700; line-height: 1.3;
  animation: pl-rise 240ms var(--ease);
}
.pl-route-pill > span:not(.spinner) { min-width: 0; overflow-wrap: anywhere; }
.pl-route-pill .spinner { width: 16px; height: 16px; border-width: 2.5px; }
.pl-route-pill.err { color: var(--danger); padding-right: 4px; }
.pl-route-pill.err > svg { flex: 0 0 auto; }
.pl-pill-btn {
  flex: 0 0 auto; min-height: 34px; padding: 4px 14px;
  border: 0; border-radius: var(--r-pill);
  background: var(--danger); color: var(--ink-inverse); font-weight: 700; font-size: var(--fs-sm);
}
@media (min-width: 900px) { .pl-route-pill { top: var(--sp-3); } }

.pl-mapbtns {
  position: absolute; z-index: 5;
  left: max(var(--sp-3), var(--safe-left)); bottom: calc(24px + var(--sp-3));
  display: flex; gap: var(--sp-2);
}
.pl-mapbtn.btn.icon { width: 42px; min-width: 42px; height: 42px; min-height: 42px; color: var(--ink); }
.pl-mapbtn[data-act="mapexpand"][aria-pressed="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 80%, transparent); }
.pl-split.map-collapsed .pl-mapbtns { display: none; }
/* narrow maps: while the map credits are spelled out (before they fold into the ⓘ button) sit above them */
@media (max-width: 599.98px) {
  .pl-mapbtns { transition: bottom 220ms var(--ease); }
  .pl-mapbox:has(.maplibregl-ctrl-attrib.maplibregl-compact-show) .pl-mapbtns,
  .pl-mapbox:has(.maplibregl-ctrl-attrib:not(.maplibregl-compact)) .pl-mapbtns { bottom: calc(24px + 6px + 22px + var(--sp-2)); }
}
@media (min-width: 900px) { .pl-mapbtns { display: none; } }
@media (max-width: 899.98px) and (orientation: landscape) and (max-height: 560px) { .pl-mapbtns { bottom: var(--sp-3); } }

.pl-map-fallback {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + 24px); text-align: center;
  background: var(--bg-2); color: var(--ink);
}
.pl-map-fallback .ico-tile { --tile-fg: var(--ink-2); --tile-bg: var(--surface); box-shadow: var(--shadow-1); margin-bottom: 4px; }

@keyframes pl-rise { from { opacity: 0; transform: translateY(-4px); } }

/* ======================= SHELL: panel header ======================= */
.pl-panel { position: relative; container: plpanel / inline-size; }  /* relative: abs children (e.g. .sr-only) stay inside the scroller */
.pl-head {
  position: sticky;
  top: calc(-1 * var(--pl-top-h, 0px));   /* phones: title part scrolls away, the tab bar stays */
  z-index: 12;
  padding: var(--sp-3) max(var(--gutter), var(--safe-right)) var(--sp-2) max(var(--gutter), var(--safe-left));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
/* soft scroll-edge instead of a hard divider */
.pl-head::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--bg) 70%, transparent), transparent);
}
@media (max-width: 899.98px) {
  .pl-split.map-collapsed .pl-head { padding-top: calc(var(--sp-3) + var(--safe-top)); }
}
@media (min-width: 900px) {
  .pl-head { top: 0; padding-top: calc(var(--sp-4) + var(--safe-top)); background: color-mix(in srgb, var(--bg) 78%, transparent); }
}

.pl-head-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "bar tools" "title cta" "meta meta";
  align-items: center;
  column-gap: var(--sp-3); row-gap: 2px;
  padding-bottom: var(--sp-3);
  min-width: 0;
}
.pl-bar { grid-area: bar; display: flex; align-items: center; gap: 6px; min-width: 0; margin-left: -8px; }
.pl-back.btn { color: var(--ink); flex: 0 0 auto; }
.pl-eyebrow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); letter-spacing: 0; font-weight: 700; color: var(--ink-3); }
.pl-status { flex: 0 0 auto; display: inline-flex; }
.pl-tools { grid-area: tools; display: flex; align-items: center; gap: 6px; justify-self: end; }
.pl-tool.btn { color: var(--ink); }
.pl-maptoggle.btn { display: none; }
@media (max-width: 899.98px) {
  .pl-split.map-collapsed .pl-maptoggle.btn { display: inline-flex; }
}
@media (max-width: 899.98px) and (orientation: landscape) and (max-height: 560px) {
  .pl-maptoggle.btn { display: inline-flex; }
  .pl-maptoggle[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
}
.pl-title {
  grid-area: title; min-width: 0;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -0.015em;
  margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.pl-navbtn.btn { grid-area: cta; justify-self: end; align-self: center; padding-inline: 14px 16px; }
.pl-navbtn svg { width: 17px; height: 17px; }
.pl-meta {
  grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px;
  margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); min-width: 0;
}
.pl-meta-i { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.pl-meta-i > svg { color: var(--ink-3); }
.pl-meta-i > span { overflow-wrap: anywhere; }

/* tab bar (iOS segmented). Labels adapt: full → short → active tab only (trip.js measures) */
.pl-tabs { margin: 0; }
.pl-tabs a { gap: 5px; padding: 6px 7px; min-height: 40px; font-size: 0.8125rem; }
.pl-tab-ico { display: inline-grid; place-items: center; flex: 0 0 auto; }
.pl-tab-ico > span { display: inline-grid; place-items: center; }
.pl-tab-f { display: none !important; }
.pl-tabs a[aria-selected="true"] .pl-tab-o:has(+ .pl-tab-f > .ico-fill) { display: none; }
.pl-tabs a[aria-selected="true"] .pl-tab-f:has(> .ico-fill) { display: inline-grid !important; }
.pl-tabs a[aria-selected="true"] .pl-tab-ico { color: var(--primary); }
.pl-tab-l { min-width: 0; white-space: nowrap; }
.pl-tab-short { display: none; }
.pl-tabs[data-fit="short"] .pl-tab-full { display: none; }
.pl-tabs[data-fit="short"] .pl-tab-short { display: inline; }
.pl-tabs[data-fit="active"] a { padding-inline: 6px; }
.pl-tabs[data-fit="active"] a:not([aria-selected="true"]) .pl-tab-l { display: none; }
.pl-tabs[data-fit="active"] a[aria-selected="true"] { flex-grow: 2.4; padding-inline: 10px; }
.pl-tabs[data-fit="active"] a[aria-selected="true"] .pl-tab-full { display: none; }
.pl-tabs[data-fit="active"] a[aria-selected="true"] .pl-tab-short { display: inline; }
.pl-tabs a:focus-visible { box-shadow: var(--focus-ring); }

.pl-tabarea { outline: none; min-width: 0; }
.pl-tabhost { min-width: 0; }
.pl-building { padding: var(--sp-8) var(--sp-4); }
.pl-building .ico-tile, .pl-notfound .ico-tile, .pl-empty-tile { --tile-fg: var(--ink-2); --tile-bg: var(--surface-sunk); margin-bottom: var(--sp-2); }
.pl-notfound { min-height: 60dvh; justify-content: center; }

/* more-menu sheet: iOS grouped rows */
.pl-menu-wrap { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.pl-menu-head { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; padding: 0 2px 2px; }
.pl-menu-titles { display: flex; flex-direction: column; min-width: 0; }
.pl-menu-name { font-family: var(--font-display); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.pl-menu {
  list-style: none; margin: 0; padding: 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.pl-menu:empty { display: none; }
.pl-menu li + li { border-top: 1px solid var(--line); }
.pl-menu-item {
  width: 100%; min-height: 60px; display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 14px; border: 0; background: transparent; color: inherit; text-align: left;
  transition: background var(--dur) var(--ease);
}
.pl-menu-item:hover { background: var(--surface-2); }
.pl-menu-item:active { background: var(--surface-sunk); }
.pl-menu-item:focus-visible { border-radius: 0; box-shadow: inset var(--focus-ring); }
.pl-menu-item .li-body { flex: 1 1 auto; min-width: 0; }
.pl-menu-item .li-title, .pl-menu-item .li-sub { display: block; }
.pl-menu-item .li-title { font-weight: 700; overflow-wrap: anywhere; }
.pl-menu-item .li-sub { color: var(--ink-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.pl-menu-item .pl-menu-ico { --tile-fg: var(--ink-2); --tile-bg: var(--surface-sunk); }
.pl-menu-item.danger .pl-menu-ico { --tile-fg: var(--danger); --tile-bg: var(--danger-soft); }
.pl-menu-item.danger .li-title { color: var(--danger); }
.pl-menu-chev { color: var(--ink-3); flex: 0 0 auto; display: inline-grid; }

/* ======================= PLAN TAB ======================= */
.pl-plan { min-width: 0; }
.pl-plan > * + * { margin-top: var(--sp-4); }
.pl-chips44 .chip { min-height: 42px; padding: 8px 14px; }
.pl-chips44 .chip svg { width: 17px; height: 17px; }
.pl-plan .chips.scroll { position: relative; }

.pl-sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--sp-3); margin-bottom: var(--sp-2); min-width: 0; }
.pl-sec-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; min-width: 0; }
.pl-sec-hint { min-width: 0; font-size: var(--fs-xs); color: var(--ink-3); overflow-wrap: anywhere; }
.pl-hint { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-xs); color: var(--ink-3); min-width: 0; }
.pl-hint > svg { flex: 0 0 auto; margin-top: 1px; }
.pl-hint > span { min-width: 0; overflow-wrap: anywhere; }

/* travel prefs card */
.pl-prefs { display: flex; flex-direction: column; gap: var(--sp-4); }
.pl-prefs-row { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.pl-prefs-label { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); }
.pl-prefs .chips.scroll { margin-inline: calc(-1 * var(--sp-4)); padding-inline: var(--sp-4); scroll-padding-inline: var(--sp-4); }
.pl-style-desc { font-size: var(--fs-xs); color: var(--ink-2); overflow-wrap: anywhere; }

/* segmented with icons (vehicle): measured label fit — see fitSegmented() in plantab.js */
.pl-seg button { gap: 6px; padding: 6px 10px; }
.pl-seg button svg { width: 19px; height: 19px; flex: 0 0 auto; }
.pl-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.pl-seg button[aria-pressed="true"] svg { color: var(--primary); }
.pl-seg-l { min-width: 0; white-space: nowrap; }
.pl-seg-s { display: none; min-width: 0; white-space: nowrap; }
.pl-seg:is([data-fit="active"], [data-fit="short"], [data-fit="icons"]) button { padding-inline: 6px; }
.pl-seg:is([data-fit="active"], [data-fit="short"]) button:not([aria-pressed="true"]) .pl-seg-l,
.pl-seg[data-fit="short"] .pl-seg-l, .pl-seg[data-fit="icons"] .pl-seg-l { display: none; }
.pl-seg[data-fit="short"] button[aria-pressed="true"] .pl-seg-s { display: inline; }
.pl-seg:is([data-fit="active"], [data-fit="short"]) button[aria-pressed="true"] { flex-grow: 2.6; padding-inline: 12px; }
.pl-seg button:focus-visible { box-shadow: var(--focus-ring); }

/* header card: the shared v3 map card (css/base.css .hero, data-hero="plan") with light stat tiles */
.pl-hero { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.pl-hero .hero-title { font-size: var(--fs-lg); overflow-wrap: break-word; line-break: auto; text-wrap: balance; }
.pl-hero-arrow { display: inline-block; margin-inline: 2px; color: var(--hero-on-2); font-weight: 400; }
.pl-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
@container plpanel (min-width: 620px) { .pl-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pl-stat { display: flex; flex-direction: column; gap: 2px; border-radius: var(--r-md); }
.pl-hero .pl-stat { padding: var(--sp-3); color: var(--hero-on); }
.pl-stat .stat-label { color: var(--hero-on); font-weight: 700; }
.pl-stat-ico { display: inline-grid; flex: 0 0 auto; }
.pl-stat .stat-value { font-weight: 700; font-size: 1.375rem; letter-spacing: -0.02em; margin-top: 2px; color: var(--hero-on); }
.pl-stat .stat-unit { margin-left: 3px; font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 400; color: var(--hero-on-2); letter-spacing: 0; }
.pl-stat-sub { font-size: var(--fs-xs); color: var(--hero-on-2); line-height: 1.35; overflow-wrap: anywhere; }

/* callouts: line icon tinted by tone */
.pl-plan .callout, .pl-callout { border-radius: var(--r-md); }
.pl-callout > svg, .pl-fuel > svg { color: var(--info); flex: 0 0 auto; }
.pl-callout.warn > svg, .pl-fuel.warn > svg { color: var(--warn); }
.pl-callout.danger > svg, .pl-fuel.danger > svg { color: var(--danger); }
.pl-callout.ok > svg { color: var(--ok); }
.pl-callout .spinner { width: 18px; height: 18px; border-width: 2.5px; }
.pl-callout-btn, .pl-fuel-btn { margin-top: var(--sp-2); }
.pl-callout-btn.btn, .pl-fuel-btn.btn { --btn-bg: var(--surface); }
.pl-fuel-list { margin: 4px 0 2px; padding-left: 1.1rem; }
.pl-fuel-list li { overflow-wrap: anywhere; }

/* suggestions bar */
.pl-suggest { min-width: 0; }
.pl-suggest-chips .chip { min-height: 40px; color: var(--ink); }
.pl-sg-ico { display: inline-grid; }

/* ---------- stops timeline: one white card per day ---------- */
.pl-tl-wrap { min-width: 0; }
.pl-day {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin: var(--sp-4) 4px var(--sp-2); min-width: 0;
}
.pl-wx-note + .pl-day, .pl-sec-head + .pl-day { margin-top: var(--sp-2); }
.pl-day-t { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.pl-day-date { color: var(--ink-2); font-weight: 400; }
.pl-day-depart { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.pl-day-depart svg { color: var(--ink-3); }

.pl-daycard {
  display: flex; flex-direction: column; min-width: 0;
  padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.pl-stop { position: relative; min-width: 0; }
.pl-stop-btn {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: start; gap: var(--sp-3);
  width: 100%; min-height: 64px; padding: 10px 10px 10px 8px;
  text-align: left; color: inherit;
  background: transparent; border: 0; border-radius: calc(var(--r-lg) - 6px);
  transition: background var(--dur) var(--ease), transform 110ms var(--ease);
}
.pl-stop-btn:hover { background: var(--surface-2); }
.pl-stop-btn:active { background: var(--surface-sunk); transform: scale(.99); }
.pl-stop-btn:focus-visible { border-radius: calc(var(--r-lg) - 6px); box-shadow: var(--focus-ring); }
.pl-stop-tile { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.pl-stop.done .pl-stop-tile .ico-tile { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mint) 55%, transparent); }
.pl-num {
  position: absolute; right: -6px; bottom: -5px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--pin, var(--primary)); color: var(--ink-inverse);
  border: 2px solid var(--surface);
  font-size: 10.5px; font-weight: 700; line-height: 1; letter-spacing: 0;
}
.pl-stop-body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.pl-stop-name { font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.pl-stop-meta { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.pl-clock { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pl-clock.late { color: var(--danger); font-weight: 700; }
.pl-dot { color: var(--ink-3); }
.pl-open { font-weight: 700; }
.pl-open.is-open { color: var(--ok); }
.pl-open.is-closing, .pl-open.is-opening { color: var(--warn); }
.pl-open.is-closed { color: var(--danger); }
.pl-stop-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; min-width: 0; }
.pl-stop-badges .badge { white-space: normal; overflow-wrap: anywhere; }
.pl-stop-note {
  display: flex; align-items: flex-start; gap: 5px; margin-top: 4px;
  font-size: var(--fs-xs); color: var(--ink-3); min-width: 0;
}
.pl-stop-note > svg { flex: 0 0 auto; margin-top: 2px; }
.pl-stop-note > span { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pl-stop-aside { display: flex; align-items: center; justify-content: flex-end; min-width: 0; max-width: 118px; min-height: 44px; }
.pl-stop-aside .tm-wxchip { font-size: 0.75rem; }
.pl-stop-aside .tm-wxchip.is-skel { width: 64px; height: 24px; border-radius: var(--r-pill); }

.pl-flash .pl-stop-btn { animation: pl-flash 1.5s var(--ease) var(--pl-flash-delay, 0ms) both; }
@keyframes pl-flash {
  0%, 55% { background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--primary) 45%, transparent); }
  100% { }
}

/* "ออกจาก ที่พัก" row at the top of day 2+ */
.pl-cont-btn {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 44px; padding: 6px 10px 6px 8px;
  border: 0; border-radius: calc(var(--r-lg) - 6px); background: transparent; color: var(--ink-2);
  text-align: left; font-size: var(--fs-sm);
}
.pl-cont-btn:hover { background: var(--surface-2); }
.pl-cont-dot {
  flex: 0 0 auto; width: 44px; height: 30px; display: grid; place-items: center; color: var(--grape);
}
.pl-cont-txt { min-width: 0; overflow-wrap: anywhere; }
.pl-cont-txt b { color: var(--ink); font-weight: 700; }

/* leg connector: dashed rail centred under the stop tiles + vehicle icon + numbers + style badge */
.pl-leg {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3);
  padding: 0 4px 0 8px; min-width: 0;
}
.pl-leg-rail {
  justify-self: center; align-self: stretch;
  width: 0; min-height: 40px;
  border-left: 2px dashed var(--line-strong);
}
.pl-leg.error .pl-leg-rail { border-left-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.pl-leg-btn {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  width: 100%; min-width: 0; min-height: 44px;
  padding: 6px 8px; margin-left: -8px;
  text-align: left; color: var(--ink-2); font-size: 0.8125rem;
  background: transparent; border: 0; border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.pl-leg-btn:hover { background: var(--surface-2); }
.pl-leg-btn:active { background: var(--surface-sunk); }
.pl-leg-btn:focus-visible { border-radius: var(--r-sm); }
.pl-leg-ico { display: inline-grid; place-items: center; color: var(--ink-3); flex: 0 0 auto; }
.pl-leg-nums { font-weight: 400; min-width: 0; overflow-wrap: anywhere; }
.pl-leg-btn .badge { white-space: normal; }
.pl-leg.error .pl-leg-btn { color: var(--danger); }
.pl-leg.error .pl-leg-ico { color: var(--danger); }
.pl-leg-add.btn { color: var(--ink-3); }
.pl-leg-add.btn:hover { color: var(--primary); background: var(--primary-soft); }
.pl-mini-spin { width: 14px; height: 14px; border-width: 2px; }

/* "+ เพิ่มจุดแวะ" ghost row at the end of the last day */
.pl-add-end {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 60px; margin-top: 2px;
  padding: 8px 10px 8px 8px;
  text-align: left; color: var(--primary);
  background: transparent; border: 0; border-top: 1px solid var(--line);
  border-radius: 0 0 calc(var(--r-lg) - 6px) calc(var(--r-lg) - 6px);
  transition: background var(--dur) var(--ease);
}
.pl-add-end:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.pl-add-plus {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.pl-add-text { display: flex; flex-direction: column; min-width: 0; }
.pl-add-t { font-weight: 700; }
.pl-add-s { font-size: var(--fs-xs); color: var(--ink-3); overflow-wrap: anywhere; }

/* notes + hand-off cards */
.pl-card-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-weight: 700; font-size: var(--fs-sm); }
.pl-card-head > svg { color: var(--ink-3); flex: 0 0 auto; }
.pl-card-head > span { flex: 1 1 auto; min-width: 0; }
.pl-notes, .pl-handoff { display: flex; flex-direction: column; gap: var(--sp-2); }
.pl-notes-edit.btn { flex: 0 0 auto; margin: -6px -8px -6px 0; }
.pl-notes-text { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.pl-handoff-btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pl-handoff-btns .btn { flex: 1 1 140px; }
.pl-handoff-btns .btn svg, .pl-ls-links .btn svg, .pl-sg-ext .btn svg { color: var(--ink-3); }

/* start card (fewer than 2 stops) */
.pl-start { display: flex; flex-direction: column; gap: var(--sp-4); }
.pl-start-hero { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.pl-start-title { font-size: var(--fs-lg); }
.pl-od {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface-sunk); border-radius: var(--r-md); overflow: hidden;
}
.pl-od-field {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 60px; padding: 8px 14px 8px 10px;
  text-align: left; color: var(--ink);
  background: transparent; border: 0;
  transition: background var(--dur) var(--ease);
}
.pl-od-field + .pl-od-field { border-top: 1px solid var(--line); }
.pl-od-field:hover { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.pl-od-field:focus-visible { border-radius: 0; box-shadow: inset var(--focus-ring); }
.pl-od-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.pl-od-label { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); }
.pl-od-value { font-weight: 700; overflow-wrap: anywhere; line-height: 1.35; }
.pl-od-value.ph { color: var(--ink-3); font-weight: 400; }
.pl-od-ico { flex: 0 0 auto; color: var(--ink-3); display: inline-grid; }
.pl-start-here.btn { align-self: flex-start; color: var(--primary); padding-inline: 10px; margin: -6px 0 -6px -10px; }

/* ======================= SHEETS (in #overlayRoot; media queries, not container) ======================= */
/* kind picker grid (stop sheet + long-press sheet) */
.pl-kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.pl-kind {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  min-height: 78px; min-width: 0; padding: 10px 4px 8px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 400; line-height: 1.25; text-align: center;
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur), transform 90ms var(--ease);
}
.pl-kind:active { transform: scale(.96); }
.pl-kind > span:not(.ico-tile) { overflow-wrap: anywhere; max-width: 100%; }
.pl-kind[aria-checked="true"] {
  border-color: transparent; background: var(--primary-soft); color: var(--ink); font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--primary);
}
.pl-kind:focus-visible { border-radius: var(--r-md); }

/* sheet title tile (stop sheet) */
.pl-sheet-tile { margin-right: 10px; vertical-align: middle; display: inline-grid; }
.sheet-head h2 .pl-sheet-tile .ico-tile { width: 34px; height: 34px; border-radius: 11px; }

/* stop sheet */
.pl-ss { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.pl-ss-pos { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); min-width: 0; }
.pl-ss-do { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.pl-ss-do .btn { padding-inline: 10px; }
.pl-ss-tally { text-align: center; font-size: var(--fs-xs); color: var(--ink-2); margin-top: calc(-1 * var(--sp-2)); }
.pl-ss-tally:empty { display: none; }
.pl-ss-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
@media (min-width: 640px) { .pl-ss-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pl-ss .stepper button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); }
.pl-ss .stepper .val { min-width: 5.5em; }
.pl-ss-presets { gap: 6px; }
.pl-ss-presets .chip { min-height: 40px; padding: 6px 12px; }
.pl-ss-arrive { gap: var(--sp-2); }
.pl-ss-arrive .input { flex: 1 1 auto; min-width: 0; }
.pl-ss-arrive .btn { flex: 0 0 auto; }
.pl-ss-sec { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.pl-ss-sec .row .btn { flex: 1 1 auto; }
.pl-ss-sec .row .btn svg { color: var(--ink-3); }

/* grouped rows inside sheets (details link, overnight switch) */
.pl-group {
  list-style: none; margin: 0; padding: 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.pl-group > * + * { border-top: 1px solid var(--line); }
.pl-row {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 58px; padding: 10px 14px;
  border: 0; background: transparent; color: inherit; text-align: left; font: inherit;
}
button.pl-row:hover { background: var(--surface-2); }
button.pl-row:active { background: var(--surface-sunk); }
.pl-row:focus-visible { border-radius: 0; box-shadow: inset var(--focus-ring); }
.pl-row-body { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.pl-row-t { font-weight: 700; overflow-wrap: anywhere; }
.pl-row-s { font-size: var(--fs-xs); color: var(--ink-2); overflow-wrap: anywhere; }
.pl-row-chev { flex: 0 0 auto; color: var(--ink-3); display: inline-grid; }
.pl-row .switch { flex: 0 0 auto; }
.pl-row.switch-row { cursor: pointer; }

/* trip sheet */
.pl-ts { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.pl-ts-preview {
  display: flex; align-items: center; gap: var(--sp-3); min-width: 0;
  padding: var(--sp-3); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
}
.pl-ts-pv-text { display: flex; flex-direction: column; min-width: 0; }
.pl-ts-pv-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; overflow-wrap: anywhere; }
.pl-ts-pv-sub { font-size: var(--fs-xs); color: var(--ink-2); overflow-wrap: anywhere; }
.pl-ts-row1 { display: flex; align-items: flex-end; gap: var(--sp-3); min-width: 0; }
.pl-ts-no { flex: 0 0 92px; }
.pl-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.pl-icon-opt {
  height: 48px; min-width: 0; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-2);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur), transform 90ms var(--ease);
}
.pl-icon-opt:active { transform: scale(.95); }
.pl-icon-opt svg { width: 22px; height: 22px; }
.pl-icon-opt[aria-checked="true"] {
  border-color: transparent; background: var(--pick-soft, var(--primary-soft)); color: var(--pick, var(--primary));
  box-shadow: inset 0 0 0 1.5px var(--pick, var(--primary));
}
.pl-icon-opt:focus-visible { border-radius: var(--r-sm); }
/* one row of 8 colours on any phone (circles shrink a little below ~400px) */
.pl-swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 44px)); justify-content: space-between; gap: 6px; }
.pl-swatch {
  width: 100%; height: auto; aspect-ratio: 1; padding: 0; border-radius: 50%;
  background: var(--sw); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: box-shadow var(--dur), transform 120ms var(--ease);
}
.pl-swatch[aria-checked="true"] { box-shadow: 0 0 0 2.5px var(--sw); }
.pl-swatch:focus-visible { border-radius: 50%; box-shadow: 0 0 0 2.5px var(--sw), var(--focus-ring); }
.pl-ts-days { margin-top: calc(-1 * var(--sp-2)); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--fs-xs); color: var(--ink-2); }
.pl-ts-days > svg { color: var(--ink-3); }
.pl-ts-days:empty { display: none; }
.pl-ts-warn { color: var(--sun-ink); font-weight: 700; }
.pl-ts .pl-seg { align-self: stretch; }
.pl-riders { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.pl-riders:empty { display: none; }
.pl-rider { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 8px 8px 12px; min-width: 0; }
.pl-rider + .pl-rider { border-top: 1px solid var(--line); }
.pl-avatar {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--av-soft, var(--primary-soft)); color: var(--av, var(--primary));
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); line-height: 1;
}
.pl-avatar svg { width: 18px; height: 18px; }
.pl-rider-name.input { flex: 1 1 auto; min-height: 44px; background: transparent; padding-inline: 4px; }
.pl-rider-name.input:focus { background: var(--surface-sunk); padding-inline: 10px; }
.pl-rider-me { flex: 0 0 auto; margin-right: 8px; }
.pl-rider .btn.icon { color: var(--ink-3); }
.pl-rider-add.btn { align-self: flex-start; }

/* leg sheet */
.pl-ls { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.pl-ls-od {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.pl-ls-pt { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; font-weight: 700; font-size: var(--fs-sm); line-height: 1.3; }
.pl-ls-name { overflow-wrap: anywhere; min-width: 0; }
.pl-ls-arrow { flex: 0 0 auto; color: var(--ink-3); display: inline-grid; }
.pl-ls .chips.scroll, .pl-sg-cats.chips.scroll { margin-inline: calc(-1 * var(--sp-5)); padding-inline: var(--sp-5); scroll-padding-inline: var(--sp-5); }
.pl-ls-options { min-width: 0; }
.pl-ls-options:empty { display: none; }
.pl-ls-skel { height: 76px; border-radius: var(--r-md); }
.pl-ls-links { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pl-ls-links .btn { flex: 1 1 auto; }
[data-role="status"]:empty, [data-role="links"]:empty { display: none; }
.pl-opts { display: flex; flex-direction: column; gap: var(--sp-2); }
.pl-opt {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 64px; padding: 12px;
  text-align: left; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.pl-opt[aria-checked="true"] { border-color: transparent; background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px var(--primary); }
.pl-opt-radio { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
.pl-opt[aria-checked="true"] .pl-opt-radio { border: 7px solid var(--primary); }
.pl-opt-body { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.pl-opt-body > span { overflow-wrap: anywhere; }
.pl-opt-warn { color: var(--warn); display: inline-flex; gap: 4px; align-items: center; }
.pl-opt-nums { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.pl-opt-nums b { font-family: var(--font-num); font-weight: 700; }

/* long-press sheet */
.pl-here { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.pl-here-where { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); min-width: 0; }
.pl-here-where > svg { flex: 0 0 auto; color: var(--primary); margin-top: 2px; }
.pl-here-where > span { min-width: 0; overflow-wrap: anywhere; }
.pl-here-where b { color: var(--ink); font-weight: 700; }
.pl-here-geo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.pl-here-geo > svg { color: var(--ok); flex: 0 0 auto; }
.pl-here-geo > span { min-width: 0; }

/* suggestions sheet */
.pl-sg { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.pl-sg-cats .chip { min-height: 42px; }
.pl-sg-note { font-size: var(--fs-xs); color: var(--ink-3); }
.pl-sg-note:empty { display: none; }
.pl-sg-results { min-width: 0; }
.pl-sg-count { margin: 0 4px var(--sp-2); font-size: var(--fs-xs); color: var(--ink-2); }
.pl-sg-wait { margin-top: var(--sp-3); text-align: center; font-size: var(--fs-xs); color: var(--ink-3); }
.pl-sg-list.grouped { gap: 0; }
.pl-sg-list:not(.grouped) .list-item { border-color: var(--line); }
.pl-sg-item { padding: 6px 10px 6px 6px; gap: 6px; transition: background var(--dur); }
.pl-sg-item.active { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.pl-sg-main {
  flex: 1 1 auto; min-width: 0; min-height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 4px; border: 0; border-radius: var(--r-sm);
  background: none; color: inherit; text-align: left;
}
.pl-sg-main .li-body { display: flex; flex-direction: column; min-width: 0; }
.pl-sg-add.btn { flex: 0 0 auto; }
.pl-sg-done.btn { --btn-bg: var(--mint-soft); --btn-ink: var(--mint); border-color: transparent; box-shadow: none; }
.pl-sg-done.btn:disabled { opacity: 1; }
.pl-sg-empty { padding: var(--sp-6) var(--sp-3); }
.pl-sg-scope { align-self: stretch; max-width: 100%; }
.pl-sg-scope button { min-height: 40px; }
.pl-sg-scope button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.pl-sg-ext { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-2); }
.pl-sg-ext > span { flex-basis: 100%; text-align: center; }

/* ======================= WEATHER (plan tab) ======================= */
/* chip itself: .tm-wxchip in css/features/time.css (shared with the time tab + place page) */
.pl-wx-note {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 8px;
  margin: 0 4px var(--sp-2);
  font-size: var(--fs-xs); color: var(--ink-2); min-width: 0;
}
.pl-wx-note > svg { flex: 0 0 auto; margin-top: 1px; color: var(--ink-3); }
.pl-wx-note > span { flex: 1 1 12em; min-width: 0; overflow-wrap: anywhere; }
.pl-wx-note > .pl-wx-retry { margin-top: -8px; }
.pl-wx-retry.btn { min-height: 36px; padding: 4px 12px; }
.pl-rain b { font-weight: 700; }
.pl-rain-list { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pl-rain-list li { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.pl-rain-list li > svg { flex: 0 0 auto; margin-top: 2px; color: var(--info); }
.pl-rain-list li > span { min-width: 0; overflow-wrap: anywhere; }
.pl-rain-src { margin-top: 2px; overflow-wrap: anywhere; }
.pl-rain.is-dry > div { overflow-wrap: anywhere; }

/* touch: keep 44px targets where rows are compact */
@media (pointer: coarse) {
  .pl-leg-add.btn.icon.sm { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .pl-mapbtn.btn.icon { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .pl-chips44 .chip, .pl-suggest-chips .chip, .pl-sg-cats .chip { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .pl-route-pill { animation: none; }
}

/* touch: the trip tabs and the vehicle segments keep 44px targets (the compact rules above override base.css) */
@media (pointer: coarse) {
  .pl-tabs a { min-height: 44px; }
  .pl-seg button { min-height: 44px; min-width: 44px; }
  /* icons-only segments stay 44 wide: the selected one (icon + label) gives way, its label ellipsizes */
  .pl-seg:is([data-fit="active"], [data-fit="short"]) button[aria-pressed="true"] { flex: 1 1 auto; min-width: 0; padding-inline: 10px; }
  /* trip sheet (tripsheet.js) only measures full/active; plantab.js steps on to short/icons, so no label is cut there */
  .pl-seg[data-fit="active"] button[aria-pressed="true"] .pl-seg-l { overflow: hidden; text-overflow: ellipsis; }
}
