/* เรดาร์รถไฟ — "สถานีของฉัน": การ์ดในแผงหลัก (แท็บขบวนรถ + โปรด) + ปุ่มปักหมุดบนป้ายสถานี (ใช้ตัวแปรสีเดียวกับ 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;
  }
}
