/* ============================================================
   LCB Route Time + Class Controls (route-time-controls.js)
   ============================================================ */

/* Shared variables — available everywhere (controls bar + details panel) */
:root {
  --rtc-open: #1f6e43;
  --rtc-closed: #b3261e;
  --rtc-standby: #FF6319;
  --rtc-na: #a9a59a;
  /* Hero state semantic colors (use the same primitives but stronger for the big numbers) */
  --rtc-hero-open: #0d4a2b;
  --rtc-hero-closed: #911a13;
  --rtc-hero-standby: #c44a00;
}
:root.rtc--cb, .rtc--cb {
  --rtc-open: #0072B2;
  --rtc-closed: #D55E00;
  --rtc-standby: #E69F00;
  --rtc-na: #999999;
  --rtc-hero-open: #003f6e;
  --rtc-hero-closed: #8a3500;
  --rtc-hero-standby: #8a5a00;
}
:root.rtc--hc, .rtc--hc {
  --rtc-open: #000;
  --rtc-closed: #b3261e;
  --rtc-standby: #FF6319;
  --rtc-na: #6f6c63;
  --rtc-hero-open: #000;
  --rtc-hero-closed: #000;
  --rtc-hero-standby: #000;
}

.rtc {
  --rtc-bg: #fff;
  --rtc-border: var(--line, #ebe6d8);
  --rtc-ink: var(--ink, #191712);
  --rtc-ink-2: var(--ink-2, #6f6c63);
  --rtc-ink-3: var(--ink-3, #a9a59a);
  --rtc-line: var(--line-2, #d6d1c4);
  --rtc-line-2: var(--paper, #faf9f7);
  background: var(--rtc-bg);
  border: 1px solid var(--rtc-border);
  border-radius: 6px;
  padding: 5px 8px;
  margin: 0;
  font-family: 'Sarabun', 'IBM Plex Sans Thai', sans-serif;
  font-size: 12px;
  color: var(--rtc-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.rtc--hc {
  --rtc-border: #000;
  --rtc-line: #000;
}
@media (prefers-reduced-motion: reduce) {
  .rtc *, .rtc { animation: none !important; transition: none !important; }
}
.rtc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  flex-wrap: wrap;
}
.rtc-row + .rtc-row { border-top: 1px dashed var(--rtc-line); margin-top: 1px; padding-top: 4px; }

/* ====== COMPACT main row (chips + day + clock + tools) ====== */
.rtc-row-main {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}
.rtc-row-main .rtc-class-chips { gap: 3px; flex: none; }
.rtc-row-main .rtc-weekday { gap: 2px; flex: none; }
.rtc-row-main .rtc-clock { min-width: 70px; }
.rtc-row-main .rtc-toolbar { gap: 2px; flex: none; }

.rtc-row-scrub {
  display: block;
  padding: 0;
  margin-top: 2px !important;
  border-top: 0 !important;
}
.rtc-row-scrub .rtc-scrub-ticks {
  display: none; /* compact: hide tick labels, the slider itself is enough */
}
.rtc-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg,
    var(--rtc-open) 0% 25%,
    var(--rtc-line) 25% 100%);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.rtc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rtc-ink);
  cursor: grab;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--rtc-ink);
  min-width: 14px; min-height: 14px;
}
.rtc-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--rtc-ink);
  cursor: grab;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--rtc-ink);
  min-width: 14px; min-height: 14px;
}

/* ====== HERO STATE — the answer at a glance ======
   Big, semantic, color-coded numbers showing the route status.
   This is the most important visual on the page. */
.rtc-hero {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  align-items: stretch;
  margin-top: 4px;
  padding: 0;
  font-family: 'Sarabun', sans-serif;
}
.rtc-hero-num {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  padding: 3px 8px 3px 9px;
  border-radius: 4px;
  border: 1px solid;
  background: #fff;
  min-height: 32px;
  position: relative;
  overflow: hidden;
}
.rtc-hero-num::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: currentColor;
}
.rtc-hero-num--open {
  color: var(--rtc-hero-open, #0d4a2b);
  border-color: #c8e3d2;
  background: linear-gradient(90deg, #ecf6ef 0%, #fff 80%);
}
.rtc-hero-num--closed {
  color: var(--rtc-hero-closed, #911a13);
  border-color: #f4cfca;
  background: linear-gradient(90deg, #fdebeb 0%, #fff 80%);
}
.rtc-hero-num--standby {
  color: var(--rtc-hero-standby, #c44a00);
  border-color: #f9d6b8;
  background: linear-gradient(90deg, #fff5e8 0%, #fff 80%);
}
.rtc-hero-v {
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: currentColor;
}
.rtc-hero-k {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: currentColor;
  opacity: 0.85;
  font-family: 'Sarabun', sans-serif;
  line-height: 1;
}
.rtc-hero-num[hidden] { display: none; }

.rtc-hero-detail {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 0;
  font-size: 10px;
  color: var(--rtc-ink-3, #a9a59a);
  border-top: 1px dashed var(--rtc-line, #ebe6d8);
  margin-top: 2px;
  line-height: 1.2;
}
.rtc-hero-class { font-weight: 600; color: var(--rtc-ink, #191712); }
.rtc-hero-when { font-weight: 500; }
.rtc-hero-when b { color: var(--rtc-open, #1f6e43); }
.rtc-hero-when i { color: var(--rtc-standby, #FF6319); font-style: normal; }
/* Legacy label class — not used in compact layout, kept for back-compat */
.rtc-label { display: none; }
.rtc-label--small { display: none; }

.rtc-class-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.rtc-class-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px 2px 5px;
  background: var(--rtc-line-2);
  border: 1px solid var(--rtc-line);
  border-radius: 12px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--rtc-ink);
  cursor: pointer;
  min-height: 22px;
  line-height: 1.2;
  transition: all 0.15s;
  white-space: nowrap;
}
.rtc-class-chip:hover { background: #fff; border-color: var(--rtc-ink); }
.rtc-class-chip.is-on {
  background: var(--rtc-ink);
  color: var(--rtc-bg);
  border-color: var(--rtc-ink);
}
/* Semantic accent per truck class — color stripe on left of chip */
.rtc-class-chip[data-class="any"] { border-left: 3px solid var(--rtc-ink, #191712); }
.rtc-class-chip[data-class="1"]   { border-left: 3px solid #00853F; }
.rtc-class-chip[data-class="2"]   { border-left: 3px solid #B933AD; }
.rtc-class-chip[data-class="3"]   { border-left: 3px solid #FCCC0A; }
.rtc-class-chip[data-class="4"]   { border-left: 3px solid #FF6319; }
.rtc-class-chip.is-on[data-class="1"]   { background: #00853F; border-color: #00853F; }
.rtc-class-chip.is-on[data-class="2"]   { background: #B933AD; border-color: #B933AD; }
.rtc-class-chip.is-on[data-class="3"]   { background: #b6930c; border-color: #b6930c; }
.rtc-class-chip.is-on[data-class="4"]   { background: #FF6319; border-color: #FF6319; }
.rtc-class-ic { font-size: 12px; line-height: 1; }
.rtc-class-th { font-size: 11px; }
.rtc-class-chip:focus-visible { outline: 2px solid var(--rtc-open); outline-offset: 2px; }

.rtc-weekday {
  display: flex;
  gap: 3px;
}
.rtc-day {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rtc-line-2);
  border: 1px solid var(--rtc-line);
  border-radius: 50%;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--rtc-ink);
  cursor: pointer;
  min-width: 22px;
  min-height: 22px;
  line-height: 1;
}
.rtc-day:hover { background: #fff; border-color: var(--rtc-ink); }
.rtc-day.is-on {
  background: var(--rtc-ink);
  color: var(--rtc-bg);
  border-color: var(--rtc-ink);
}
.rtc-day:focus-visible { outline: 2px solid var(--rtc-open); outline-offset: 2px; }

.rtc-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
  flex: 1;
  min-width: 140px;
}
.rtc-clock-time {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: var(--rtc-ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.rtc-clock-meta {
  font-size: 9px;
  color: var(--rtc-ink-3);
  margin-top: 0;
  text-align: right;
  font-family: 'Sarabun', sans-serif;
  line-height: 1.2;
}
.rtc-clock-meta b { color: var(--rtc-open); }
.rtc-clock-meta i { color: var(--rtc-standby); font-style: normal; }

.rtc-now {
  padding: 2px 6px;
  background: var(--rtc-line-2);
  border: 1px solid var(--rtc-line);
  border-radius: 4px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--rtc-ink);
  cursor: pointer;
  min-height: 22px;
  line-height: 1.2;
}
.rtc-now:hover { background: #fff; border-color: var(--rtc-ink); }
.rtc-now:focus-visible { outline: 2px solid var(--rtc-open); outline-offset: 2px; }

.rtc-scrub-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.rtc-scrub-wrap input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--rtc-line);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.rtc-scrub-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--rtc-ink);
  cursor: grab;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--rtc-ink);
  min-width: 22px; min-height: 22px;
}
.rtc-scrub-wrap input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--rtc-ink);
  cursor: grab;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--rtc-ink);
  min-width: 22px; min-height: 22px;
}
.rtc-scrub-ticks {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: var(--rtc-ink-3);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.rtc-toolbar { gap: 4px; }
.rtc-tb {
  padding: 2px 6px;
  background: var(--rtc-line-2);
  border: 1px solid var(--rtc-line);
  border-radius: 4px;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  color: var(--rtc-ink);
  cursor: pointer;
  min-height: 22px;
  line-height: 1.2;
}
.rtc-tb:hover { background: #fff; border-color: var(--rtc-ink); }
.rtc-tb[aria-pressed="true"] {
  background: var(--rtc-ink);
  color: var(--rtc-bg);
  border-color: var(--rtc-ink);
}
.rtc-tb:focus-visible { outline: 2px solid var(--rtc-open); outline-offset: 2px; }

.rtc-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--rtc-line);
  font-size: 12px;
}
.rtc-sum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.rtc-sum-class {
  font-weight: 600;
  font-size: 12px;
  color: var(--rtc-ink);
}
.rtc-sum-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.rtc-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.rtc-count--open    { background: var(--rtc-open); color: #fff; }
.rtc-count--closed  { background: var(--rtc-closed); color: #fff; }
.rtc-count--standby { background: var(--rtc-standby); color: #fff; }
.rtc-sum-warn {
  margin-top: 6px;
  font-size: 11px;
  color: var(--rtc-standby);
  font-weight: 600;
}

/* Legend modal */
.rtc-legend-veil {
  position: fixed;
  inset: 0;
  background: rgba(25, 23, 18, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 99999;
}
.rtc-legend {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  max-width: 380px;
  width: 100%;
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
}
.rtc-legend h3 {
  font-size: 14px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rtc-line);
}
.rtc-legend ul {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rtc-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
}
.rtc-legend li i {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex: none;
}
.rtc-legend-tip {
  font-size: 11px;
  color: var(--rtc-ink-2);
  background: var(--rtc-line-2);
  padding: 6px 10px;
  border-radius: 5px;
  margin: 0 0 14px;
}
.rtc-legend-close {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--rtc-ink);
  color: #fff;
  border: 0;
  border-radius: 5px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

/* ============================================================
   LCB Route Details Panel (route-details.js)
   ============================================================ */

.rdp-veil {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99998;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: rdpVeilIn 0.18s ease-out;
}
@keyframes rdpVeilIn { from { opacity: 0; } to { opacity: 1; } }

.rdp {
  background: #fff;
  width: 480px;
  max-width: 100%;
  height: 100vh;
  overflow-y: auto;
  font-family: 'Sarabun', 'IBM Plex Sans Thai', sans-serif;
  color: var(--ink, #191712);
  display: flex;
  flex-direction: column;
  animation: rdpSlideIn 0.2s var(--ease-spring, cubic-bezier(.22,1,.36,1));
}
@keyframes rdpSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.rdp[data-fam="1"] { border-top: 5px solid #00853F; }
.rdp[data-fam="2"] { border-top: 5px solid #B933AD; }
.rdp[data-fam="3"] { border-top: 5px solid #FCCC0A; }
.rdp[data-fam="4"] { border-top: 5px solid #FF6319; }

.rdp-h {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--line, #ebe6d8);
  padding: 16px 20px;
  z-index: 2;
}
.rdp-id {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.rdp-fam-tag {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
}
.rdp-fam-tag.fam-1 { background: #00853F; }
.rdp-fam-tag.fam-2 { background: #B933AD; }
.rdp-fam-tag.fam-3 { background: #FCCC0A; color: #191712; }
.rdp-fam-tag.fam-4 { background: #FF6319; }
.rdp-id-num {
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-3, #a9a59a);
  font-weight: 600;
}
.rdp-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
  color: var(--ink, #191712);
}
.rdp-sub {
  font-size: 12px;
  color: var(--ink-2, #6f6c63);
  line-height: 1.5;
}
.rdp-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: var(--paper, #faf9f7);
  border: 1px solid var(--line-2, #d6d1c4);
  border-radius: 50%;
  font: inherit;
  font-size: 22px;
  color: var(--ink, #191712);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.rdp-close:hover { background: var(--ink); color: #fff; }
.rdp-close:focus-visible { outline: 2px solid var(--accent, #1f6e43); outline-offset: 2px; }

.rdp-now {
  padding: 14px 20px;
  background: var(--paper, #faf9f7);
  border-bottom: 1px solid var(--line, #ebe6d8);
}
.rdp-now-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3, #a9a59a);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rdp-now-time {
  font-size: 18px;
  font-weight: 700;
  font-family: ui-monospace, 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 12px;
  color: var(--ink, #191712);
}
.rdp-now-status { width: 100%; }

.rdp-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rdp-matrix th, .rdp-matrix td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line, #ebe6d8);
  vertical-align: middle;
}
.rdp-matrix th {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3, #a9a59a);
  text-transform: uppercase;
}
.rdp-matrix th[scope="col"] { text-align: center; }
.rdp-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.rdp-status--open    { background: var(--rtc-open); }
.rdp-status--closed  { background: var(--rtc-closed); }
.rdp-status--standby { background: var(--rtc-standby); }
.rdp-status-label { font-size: 11px; color: var(--ink, #191712); margin-left: 4px; }
.rdp-why { font-size: 11px; color: var(--ink-2, #6f6c63); line-height: 1.4; }

.rdp-grid {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.rdp-section {
  border: 1px solid var(--line, #ebe6d8);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}
.rdp-section h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3, #a9a59a);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}
.rdp-hint {
  font-size: 10px;
  color: var(--ink-3, #a9a59a);
  margin: 6px 0 0;
  line-height: 1.4;
}

.rdp-24h {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.rdp-hour {
  padding: 4px 0;
  background: var(--paper, #faf9f7);
  border: 1px solid var(--line, #ebe6d8);
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  min-height: 32px;
  text-align: center;
  transition: all 0.12s;
}
.rdp-hour:hover { transform: scale(1.05); z-index: 1; }
.rdp-hour:focus-visible { outline: 2px solid var(--accent, #1f6e43); outline-offset: 1px; z-index: 2; }
.rdp-hour--open   { background: var(--rtc-open); color: #fff; border-color: var(--rtc-open); }
.rdp-hour--closed { background: var(--rtc-closed); color: #fff; border-color: var(--rtc-closed); }
.rdp-hour--now { box-shadow: 0 0 0 2px var(--ink, #191712); transform: scale(1.08); z-index: 2; }
.rdp-hour-n { font-size: 9px; font-family: ui-monospace, 'IBM Plex Mono', monospace; font-weight: 600; }

.rdp-week { display: flex; flex-direction: column; gap: 4px; }
.rdp-week-day {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line, #ebe6d8);
}
.rdp-week-day:last-child { border-bottom: 0; }
.rdp-week-day--now { background: #fefbe6; padding: 4px 6px; margin: 0 -6px; border-radius: 4px; }
.rdp-week-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  color: var(--ink, #191712);
}
.rdp-week-label span { font-size: 8px; color: var(--ink-3, #a9a59a); font-weight: 400; }
.rdp-week-cells {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 1px;
}
.rdp-week-cell {
  height: 14px;
  border-radius: 1px;
}
.rdp-week-cell--open   { background: var(--rtc-open); }
.rdp-week-cell--closed { background: var(--rtc-closed); }

.rdp-limits {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rdp-limits th, .rdp-limits td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line, #ebe6d8);
}
.rdp-limits th {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3, #a9a59a);
  text-transform: uppercase;
  width: 50%;
}
.rdp-limits td { color: var(--ink, #191712); }

.rdp-rule {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink, #191712);
  background: var(--paper, #faf9f7);
  border-left: 3px solid var(--accent, #1f6e43);
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  margin: 0 0 12px;
}
.rdp-when {
  display: flex;
  gap: 10px;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line, #ebe6d8);
}
.rdp-when:last-child { border-bottom: 0; }
.rdp-when-k {
  flex: none;
  width: 110px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3, #a9a59a);
  text-transform: uppercase;
}
.rdp-when-v { color: var(--ink, #191712); }

/* Mobile: bottom sheet instead of side panel */
@media (max-width: 720px) {
  .rdp-veil {
    align-items: flex-end;
  }
  .rdp {
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 14px 14px 0 0;
    animation: rdpSheetIn 0.22s var(--ease-spring, cubic-bezier(.22,1,.36,1));
  }
  @keyframes rdpSheetIn {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .rdp-24h {
    grid-template-columns: repeat(12, 1fr);
  }
  .rtc { padding: 10px 12px; }
  .rtc-row { gap: 6px; }
  .rtc-class-chip {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    min-height: 44px;
    justify-content: center;
  }
  .rtc-class-chips { gap: 4px; }
  .rtc-tb, .rtc-now, .rtc-day { min-height: 44px; }
  .rtc-day { width: 38px; min-width: 38px; }
  .rtc-clock { min-width: 100px; }
  .rtc-clock-time { font-size: 18px; }
  .rtc-scrub-wrap { min-width: 100%; }
  .rtc-scrub-wrap input[type=range]::-webkit-slider-thumb {
    width: 28px; height: 28px; min-width: 28px; min-height: 28px;
  }
  .rts-alert { padding: 6px 10px; font-size: 11.5px; }
  .rts-ic { font-size: 16px; width: 22px; }
  #routeAlertsBar { margin: 0 4px 6px; }
  #routeControlsBar { margin: 0 4px 6px; }
}

/* ============================================================
   Map top strip — floats over the map (alerts + controls)
   The map itself is the hero; the chrome floats on top.
   ============================================================ */
.map-topstrip {
  position: absolute;
  top: 6px; left: 6px; right: 6px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none; /* clicks pass through except on children */
}
.map-topstrip > * { pointer-events: auto; }
.map-topstrip-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.map-topstrip-controls {
  display: block;
  max-width: 720px;
}
@media (max-width: 720px) {
  .map-topstrip { top: 4px; left: 4px; right: 4px; gap: 3px; }
  .map-topstrip-controls { max-width: 100%; }
  .rtc { padding: 4px 6px; }
  .rtc-row-main { gap: 5px; }
  .rtc-hero-v { font-size: 17px; }
  .rtc-hero-num { padding: 2px 6px 2px 7px; min-height: 28px; }
  .rtc-hero-k { font-size: 9px; }
  .rtc-day { width: 20px; height: 20px; min-width: 20px; min-height: 20px; font-size: 10px; }
  .rtc-class-chip { min-height: 20px; padding: 1px 5px 1px 4px; font-size: 10.5px; }
}

/* ============================================================
   LCB Route Alerts (route-alerts.js)
   ============================================================ */

/* COMPACT MODE — single horizontal row of pills at the top of the map
   so the map is the hero. Each alert is a pill, not a stacked card. */
.rts-alerts {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.rts-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 7px;
  border: 1px solid;
  border-left-width: 3px;
  border-radius: 999px;
  background: #fff;
  font-family: 'Sarabun', 'IBM Plex Sans Thai', sans-serif;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  cursor: default;
}
.rts-alert--critical {
  border-color: #b3261e;
  background: linear-gradient(90deg, #fdebeb 0%, #fff 60%);
  color: #b3261e;
}
.rts-alert--warning {
  border-color: #FF6319;
  background: linear-gradient(90deg, #fff5e8 0%, #fff 60%);
  color: #c44900;
}
.rts-alert--info {
  border-color: #b6930c;
  background: linear-gradient(90deg, #fefbe6 0%, #fff 60%);
  color: #6b5600;
}
.rts-alert--ok {
  border-color: #1f6e43;
  background: linear-gradient(90deg, #ecf6ef 0%, #fff 60%);
  color: #1f6e43;
}
.rts-ic {
  font-size: 12px;
  line-height: 1;
  flex: none;
}
.rts-alert--critical .rts-ic { animation: rtsPulse 1.6s ease-in-out infinite; }
@keyframes rtsPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.rts-body { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; }
.rts-th { font-weight: 700; color: var(--ink, #191712); font-size: 11px; }
.rts-en { color: var(--ink-3, #a9a59a); font-size: 10px; font-weight: 500; }
.rts-detail { display: none; } /* hidden in compact mode */
.rts-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px dashed var(--line, #ebe6d8);
  border-radius: 999px;
  background: transparent;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3, #a9a59a);
  cursor: pointer;
  line-height: 1.2;
}
.rts-more:hover { background: #fff; color: var(--ink, #191712); border-color: var(--ink, #191712); }

/* Legend popover for full alert details */
.rts-popover {
  position: fixed;
  top: 60px; right: 16px;
  width: 380px;
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line, #ebe6d8);
  border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18);
  padding: 14px;
  z-index: 99999;
  font-family: 'Sarabun', sans-serif;
  font-size: 12.5px;
}
.rts-popover h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.rts-popover .rts-alert { margin-bottom: 6px; max-width: 100%; white-space: normal; }
.rts-popover .rts-detail { display: block; margin-top: 2px; }
.rts-popover .rts-en { display: block; }
.rts-popover-close {
  float: right;
  background: none; border: 0;
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--ink-3);
}

@media (prefers-reduced-motion: reduce) {
  .rts-alert--critical .rts-ic { animation: none; }
}

/* ============================================================
   Map: route status colors + popup restyle
   ============================================================ */

/* Make route lines always interactive (was disabled) */
.leaflet-interactive.ri-line {
  cursor: pointer !important;
  transition: filter 0.15s, opacity 0.15s;
}
.leaflet-interactive.ri-line:hover { filter: brightness(1.15); }
.leaflet-interactive.ri-line.is-selected {
  filter: drop-shadow(0 0 0 #0039A6) brightness(1.2);
}

/* Class-aware popup arrow */
.popup-class-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.popup-class-row .mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}
.popup-class-row .mini-pill--open    { background: var(--rtc-open, #1f6e43); }
.popup-class-row .mini-pill--closed  { background: var(--rtc-closed, #b3261e); }
.popup-class-row .mini-pill--standby { background: var(--rtc-standby, #FF6319); }
.popup-class-row .mini-pill--not_relevant { background: var(--rtc-na, #a9a59a); }
