* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { width: 100%; height: 100%; overflow: hidden; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
#map { position: absolute; inset: 0; background: #0b1220; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 48px;
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: rgba(11,18,32,.85); color: #e5e7eb; z-index: 10;
  backdrop-filter: blur(6px);
}
#clock { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; }
#running { font-size: 13px; color: #9ca3af; }
#topbar button { background: #1f2937; color: #e5e7eb; border: 1px solid #374151; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
#topbar button:hover { background: #374151; }

#sidebar {
  position: absolute; top: 60px; right: 12px; width: 260px;
  background: rgba(17,24,39,.9); color: #e5e7eb; border-radius: 8px;
  padding: 12px; z-index: 10; font-size: 12px; backdrop-filter: blur(6px);
  /* 列车停站表可能很长：面板限高（给底部版权留出一行），内容区自己滚动，不撑破视口 */
  display: flex; flex-direction: column;
  max-height: calc(100vh - 60px - 86px);
}
#sidebar h3 { font-size: 13px; margin-bottom: 8px; color: #93c5fd; flex: none; }

/* ===== 线路信息（替换原“铁路榜单”）：停靠顺序 / 到站时刻 / 停留时长 ===== */
#lineInfo { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#lineInfo::-webkit-scrollbar { width: 4px; }
#lineInfo::-webkit-scrollbar-thumb { background: #374151; border-radius: 2px; }
#lineInfo::-webkit-scrollbar-track { background: transparent; }

.li-empty {
  color: #9ca3af; font-size: 11.5px; line-height: 1.75;
  padding: 2px 0 4px; word-break: break-word;
}
.li-head { display: flex; align-items: baseline; gap: 8px; }
.li-code {
  font-size: 19px; font-weight: 700; letter-spacing: .4px;
  color: #93c5fd; font-variant-numeric: tabular-nums; flex: none;
}
.li-route {
  font-size: 11.5px; color: #e5e7eb; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.li-meta { margin-top: 2px; font-size: 10.5px; color: #9ca3af; }
.li-meta .li-warn { color: #fbbf24; }

.li-cols, .li-stop {
  display: grid; gap: 4px; align-items: baseline;
  grid-template-columns: 16px minmax(0, 1fr) 46px 40px;
}
.li-cols {
  position: sticky; top: 0; z-index: 1;
  margin-top: 8px; padding: 0 0 4px;
  font-size: 10px; color: #6b7280;
  border-bottom: 1px solid #1f2937;
  background: rgba(17,24,39,.98);
}
.li-cols span:nth-child(1) { text-align: center; }
.li-cols span:nth-child(3), .li-cols span:nth-child(4) { text-align: right; }

.li-stops { list-style: none; }
.li-stop {
  padding: 5px 0; font-size: 11.5px; line-height: 1.35;
  border-bottom: 1px solid rgba(31,41,55,.7);
}
.li-stop:last-child { border-bottom: none; }
.li-stop.is-start, .li-stop.is-end { background: rgba(59,130,246,.09); }
.li-idx {
  font-size: 10px; color: #6b7280; text-align: center;
  font-variant-numeric: tabular-nums;
}
.li-name {
  color: #e5e7eb; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.li-stop.is-start .li-name, .li-stop.is-end .li-name { font-weight: 600; color: #f9fafb; }
.li-time {
  text-align: right; color: #cbd5e1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.li-time small { font-size: 9px; color: #6b7280; margin-left: 1px; }
.li-dwell {
  text-align: right; font-size: 10.5px; color: #9ca3af;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.li-stop.is-start .li-dwell, .li-stop.is-end .li-dwell { color: #93c5fd; }
.li-na { color: #6b7280; }

/* ===== 版权声明 ===== */
#copyright {
  position: absolute; right: 14px; bottom: 56px; z-index: 9;
  font-size: 10px; color: #6b7280; letter-spacing: .3px;
  pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.65);
}

#searchBox { position: absolute; top: 60px; left: 12px; z-index: 10; display: flex; gap: 6px; }
#searchBox input { background: #111827; color: #e5e7eb; border: 1px solid #374151; border-radius: 6px; padding: 6px 10px; width: 160px; }
#searchBox button { background: #1d4ed8; color: #fff; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; }

#legend {
  position: absolute; left: 12px; bottom: 70px; z-index: 10;
  background: rgba(17,24,39,.9); color: #e5e7eb; padding: 8px 10px; border-radius: 8px;
  font-size: 11px; line-height: 1.6;
}
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
/* 新增：图例里的铁路项——灰色细线，与列车圆点/车站菱形区分 */
#legend i.rail {
  width: 12px; height: 2px; border-radius: 1px;
  background: #8b95a7; margin: 0 6px 0 0;
}
/* 新增：图例里的车站图例项——空心菱形，与列车的实心圆点区分 */
#legend i.stn {
  width: 6px; height: 6px; border-radius: 0;
  background: transparent; border: 1.5px solid #dbe4f0;
  transform: rotate(45deg); margin: 0 8px 0 3px;
}

#timebar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 52px;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: rgba(11,18,32,.85); color: #e5e7eb; z-index: 10;
  backdrop-filter: blur(6px);
}
#timeSlider { flex: 1; accent-color: #3b82f6; }

#loading {
  position: absolute; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: #0b1220; color: #e5e7eb; transition: opacity .4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

#infoModal { position: absolute; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
#infoModal[hidden] { display: none; }
.modal-content { background: #111827; color: #e5e7eb; padding: 20px; border-radius: 10px; max-width: 420px; }

/* ===== 新增：被点选车次的编号卡片 ===== */
#trainCard {
  position: absolute; left: 12px; top: 104px; z-index: 12;
  min-width: 148px; max-width: 240px;
  padding: 10px 36px 10px 12px;
  background: rgba(17,24,39,.92); color: #e5e7eb;
  border: 1px solid #1d4ed8; border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
}
#trainCard[hidden] { display: none; }
#trainCardCode {
  font-size: 22px; font-weight: 700; letter-spacing: .5px;
  color: #93c5fd; font-variant-numeric: tabular-nums; line-height: 1.15;
}
#trainCardMeta {
  margin-top: 3px; font-size: 12px; color: #9ca3af;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#trainCardClose {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: #1f2937; color: #9ca3af; border: 1px solid #374151;
  border-radius: 7px; cursor: pointer; font-size: 15px; line-height: 1;
  padding: 0;
}
#trainCardClose:hover { background: #374151; color: #e5e7eb; }

/* ===== 新增：定位面板（文字格式展示当前位置） ===== */
#locPanel {
  position: absolute; left: 12px; top: 190px; z-index: 12; width: 252px;
  background: rgba(17,24,39,.92); color: #e5e7eb;
  border: 1px solid #4b5563; border-radius: 10px;
  padding: 9px 11px 6px; font-size: 11px; line-height: 1.55;
  box-shadow: 0 8px 22px rgba(0,0,0,.45); backdrop-filter: blur(6px);
}
#locPanel[hidden] { display: none; }
.loc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px;
}
.loc-head > span:first-child {
  font-size: 12px; font-weight: 600; color: #f9a8d4; letter-spacing: .5px;
}
.loc-state { font-size: 10px; color: #9ca3af; }
.loc-state.ok { color: #34d399; }
.loc-state.err { color: #f87171; }
.loc-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 2px 0; border-top: 1px solid rgba(55,65,81,.55);
}
.loc-row > span { color: #9ca3af; flex: none; }
.loc-row > b {
  font-weight: 500; color: #e5e7eb; font-variant-numeric: tabular-nums;
  text-align: right; word-break: break-all;
}
#locBtn.active { background: #831843; border-color: #ff5ec4; color: #ffd1ec; }

/* ===== 新增：时间跳转面板 ===== */
#timeJumpBtn {
  background: #1f2937; color: #e5e7eb; border: 1px solid #374151;
  border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px;
}
#timeJumpBtn:hover, #timeJumpBtn.active { background: #374151; }
#timeJumpPanel {
  position: absolute; right: 12px; bottom: 64px; z-index: 13;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(17,24,39,.95); border: 1px solid #374151; border-radius: 10px;
  padding: 9px 11px; box-shadow: 0 8px 22px rgba(0,0,0,.45); backdrop-filter: blur(6px);
}
#timeJumpPanel[hidden] { display: none; }
.jump-line { display: flex; gap: 6px; align-items: center; }
#timeJumpInput {
  width: 92px; background: #111827; color: #e5e7eb; border: 1px solid #374151;
  border-radius: 6px; padding: 5px 8px; font-size: 13px; font-variant-numeric: tabular-nums;
}
#timeJumpInput:focus { outline: none; border-color: #3b82f6; }
#timeJumpGo {
  background: #1d4ed8; color: #fff; border: none; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font-size: 12px;
}
#timeJumpGo:hover { background: #2563eb; }
#timeJumpMsg { font-size: 10px; color: #9ca3af; }
#timeJumpMsg.err { color: #f87171; }

/* ===== 新增：移动端适配（只在小屏覆盖，桌面端不受影响） ===== */
@media (max-width: 720px) {
  /* 小屏下图例让位给地图；线路信息面板保留，改成搜索框下方的通栏浮层 */
  #legend { display: none; }

  #sidebar {
    top: 96px; left: 8px; right: 8px; width: auto;
    max-height: 32vh; padding: 10px 11px;
  }
  #sidebar h3 { font-size: 12px; margin-bottom: 6px; }
  .li-code { font-size: 17px; }
  .li-empty { font-size: 11px; line-height: 1.65; }
  .li-cols, .li-stop { grid-template-columns: 16px minmax(0, 1fr) 48px 42px; }
  .li-stop { font-size: 12px; padding: 6px 0; }
  /* 定位面板与线路信息面板位置重叠：打开定位时先让出这一块 */
  body.loc-open #sidebar { display: none; }
  /* 手机端底部会被车次卡片占满，版权移到时间轴内的右下角，避免被卡片压住 */
  #copyright {
    right: 8px; bottom: 4px; z-index: 14;
    font-size: 9px; line-height: 12px; color: #5f6a7a;
    background: rgba(11,18,32,.85); padding: 1px 4px; border-radius: 3px;
  }

  #topbar { height: 44px; gap: 10px; padding: 0 10px; }
  #clock { font-size: 16px; }
  #running { font-size: 12px; }
  #topbar button { padding: 6px 10px; }

  #searchBox { left: 8px; right: 8px; top: 52px; gap: 8px; }
  #searchBox input { flex: 1; width: auto; min-width: 0; font-size: 16px; padding: 8px 10px; }
  #searchBox button { padding: 8px 12px; font-size: 13px; }

  /* 编号卡片改为底部浮层，避开手指与安全区 */
  #trainCard {
    left: 8px; right: 8px; top: auto;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    max-width: none; min-width: 0;
    padding: 10px 40px 10px 12px;
  }
  #trainCardCode { font-size: 20px; }
  #trainCardMeta { font-size: 12px; }

  #timebar { height: 52px; padding: 0 10px 0 10px; gap: 8px; }

  /* 定位面板铺在搜索框下方，通栏显示 */
  #locPanel { left: 8px; right: 8px; top: 100px; width: auto; }
  /* 时间跳转面板贴住时间轴上方，输入框 16px 防 iOS 聚焦缩放 */
  #timeJumpPanel { right: 8px; left: 8px; bottom: 60px; }
  #timeJumpInput { flex: 1; width: auto; font-size: 16px; padding: 7px 9px; }
  #timeJumpBtn { padding: 6px 9px; font-size: 12px; }
  #locBtn { padding: 6px 8px; }
}