:root {
  --bg: #0b0f13;
  --panel: rgba(16, 21, 27, 0.92);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e8eef5;
  --muted: #8c9bad;
  --online: #34d399;
  --offline: #94a3b8;
  --danger: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  background: #0b0f13;
}

/* ------------------------------------------------------------ 顶栏 */
.topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.14);
}

.brand-text {
  font-size: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}

.conn--ok {
  color: var(--online);
  border-color: rgba(52, 211, 153, 0.35);
}

.conn--error {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ------------------------------------------------------------ 设备面板 */
.panel {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 1000;
  width: 290px;
  max-height: min(52vh, 460px);
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.panel-head h2 span {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.device-item:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--panel-border);
}

.device-item.is-offline {
  opacity: 0.62;
}

.device-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.device-main {
  min-width: 0;
}

.device-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.device-state {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.device-state--online {
  color: var(--online);
  background: rgba(52, 211, 153, 0.12);
}

.device-state--offline {
  color: var(--offline);
  background: rgba(148, 163, 184, 0.14);
}

.empty-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.panel-foot {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

/* ------------------------------------------------------------ 地图标记 */
.family-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease;
}

.family-marker svg {
  width: 18px;
  height: 18px;
  fill: #fff;
  display: block;
}

.family-marker.is-offline {
  filter: grayscale(1);
  opacity: 0.7;
}

.family-marker.is-offline::after {
  content: "离线";
  position: absolute;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.88);
  color: #e2e8f0;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
}

.family-marker:hover {
  transform: scale(1.08);
}

.marker-wrap {
  background: transparent;
  border: 0;
}

.leaflet-popup-content-wrapper {
  background: #111820;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.leaflet-popup-tip {
  background: #111820;
  border: 1px solid var(--panel-border);
}

.popup-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-line {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

.popup-online {
  color: var(--online);
}

.popup-offline {
  color: var(--offline);
}

/* ------------------------------------------------------------ 署名 */
.attribution {
  position: fixed;
  right: 12px;
  bottom: 8px;
  z-index: 900;
  font-size: 11px;
  color: #cfd8e3;
  background: rgba(11, 15, 19, 0.72);
  padding: 3px 8px;
  border-radius: 6px;
}

.attribution a {
  color: #9ecbff;
  text-decoration: none;
}

.attribution a:hover {
  text-decoration: underline;
}

/* 小屏（手机浏览器看大屏）时把面板收窄 */
@media (max-width: 560px) {
  .panel {
    width: calc(100% - 28px);
    max-height: 38vh;
  }

  .brand-text {
    font-size: 14px;
  }
}
