/* RailVision · 自绘深色主题 */
:root {
  --bg: #080d12;
  --panel-bg: rgba(12, 19, 26, .90);
  --border: rgba(255, 150, 60, .25);
  --accent: #ffab5e;
  --accent-bright: #ffc078;
  --text: #d8e2ea;
  --text-dim: #7f929f;
  --hs-color: #ffb054;
  --normal-color: #9ab4c8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
#map { position: absolute; inset: 0; }

.panel {
  position: absolute;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  z-index: 10;
}

/* 品牌 HUD */
#hud { top: 18px; left: 18px; padding: 16px 18px; min-width: 250px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 9px;
  background: linear-gradient(135deg, #ff9a3c, #ff6b1a);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #1a0e05;
  box-shadow: 0 0 20px rgba(255, 140, 40, .4);
}
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: .5px; color: var(--accent); }
.brand-title span { font-size: 13px; font-weight: 500; color: var(--text-dim); margin-left: 4px; }
.brand-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.divider { height: 1px; background: rgba(255, 255, 255, .08); margin: 13px 0; }
.stats .stat { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.stats .stat span { color: var(--text-dim); }
.stats .stat b { font-variant-numeric: tabular-nums; font-weight: 600; }
.attribution { font-size: 10px; color: var(--text-dim); line-height: 1.5; }

/* 搜索 */
#search-panel { top: 18px; left: 50%; transform: translateX(-50%); width: min(440px, 46vw); padding: 10px; }
.search-box { display: flex; gap: 8px; }
.search-box input {
  flex: 1; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 7px; padding: 9px 12px; color: var(--text); font-size: 13px; outline: none;
  transition: border-color .2s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: #5c6b76; }
.search-box button {
  width: 38px; background: linear-gradient(135deg, #ff9a3c, #ff6b1a); border: none;
  border-radius: 7px; color: #1a0e05; font-size: 20px; cursor: pointer; font-weight: 700;
}
.search-results { max-height: 260px; overflow-y: auto; margin-top: 8px; display: none; }
.search-results.show { display: block; }
.result-item {
  padding: 8px 11px; border-radius: 6px; cursor: pointer; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.result-item:hover { background: rgba(255, 150, 60, .12); }
.result-item .rname { color: var(--accent-bright); font-weight: 500; }
.result-item .rcount { color: var(--text-dim); font-size: 11px; }
.search-empty { padding: 14px; text-align: center; color: var(--text-dim); font-size: 12px; }

/* 图层控制 */
#layers { top: 18px; right: 18px; padding: 12px 14px; min-width: 150px; }
.layer-title { font-size: 11px; color: var(--text-dim); margin-bottom: 9px; letter-spacing: 1px; }
.switch-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; cursor: pointer; font-size: 12px; }
.switch-row input { display: none; }
.switch {
  width: 30px; height: 17px; border-radius: 9px; background: #3a4550;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: #b8c4ce; top: 2px; left: 2px; transition: transform .2s, background .2s;
}
.switch-row input:checked + .switch { background: rgba(255, 140, 40, .5); }
.switch-row input:checked + .switch::after { transform: translateX(13px); background: var(--accent); }

/* 图例 */
#legend { bottom: 18px; left: 18px; padding: 11px 14px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: 11px; color: var(--text-dim); }
.line-sample { width: 22px; height: 3px; border-radius: 2px; }
.line-sample.hs { background: var(--hs-color); box-shadow: 0 0 8px var(--hs-color); }
.line-sample.normal { background: var(--normal-color); }
.node-sample { width: 10px; height: 10px; border-radius: 50%; background: #fff2cc; box-shadow: 0 0 10px #ff9a3c; }

/* 弹窗 */
.popup {
  position: absolute; display: none; z-index: 20; min-width: 210px; max-width: 280px;
  background: rgba(12, 19, 26, .95); border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px; color: var(--text); font-size: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .6); backdrop-filter: blur(10px);
}
.popup .p-title { color: var(--accent-bright); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.popup .p-row { display: flex; justify-content: space-between; padding: 2px 0; gap: 14px; }
.popup .p-row span:first-child { color: var(--text-dim); }
.popup .p-close { position: absolute; top: 8px; right: 10px; cursor: pointer; color: var(--text-dim); font-size: 16px; }

/* MapLibre 弹窗覆盖 */
.maplibregl-popup-content { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.maplibregl-popup-tip { display: none !important; }

/* 加载遮罩 */
#loading {
  position: absolute; inset: 0; z-index: 100; background: #080d12;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .5s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loader-ring {
  width: 48px; height: 48px; border: 3px solid rgba(255, 150, 60, .15);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { margin-top: 18px; color: var(--accent); font-size: 14px; letter-spacing: 1px; }
.loader-sub { margin-top: 6px; color: var(--text-dim); font-size: 11px; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 150, 60, .3); border-radius: 3px; }

/* 移动端适配 */
@media (max-width: 720px) {
  #hud { min-width: 0; width: 200px; padding: 12px; }
  .brand-title { font-size: 14px; }
  #search-panel { width: 92vw; top: 140px; }
  #layers, #legend { display: none; }
}
