:root {
  --tlsg-ink: #17342b;
  --tlsg-muted: #64766f;
  --tlsg-line: rgba(23, 52, 43, 0.14);
  --tlsg-panel: rgba(255, 255, 255, 0.92);
  --tlsg-subtle: #f3f8f4;
  --tlsg-accent: #147a52;
  --tlsg-accent-strong: #0d5f40;
  --tlsg-warn: #a15c00;
  --tlsg-danger: #b42318;
  --tlsg-radius: 18px;
}

.tlsg-host {
  position: relative;
  width: 100%;
  min-width: 0;
  margin: 20px 0;
  color: var(--tlsg-ink);
}

.tlsg-shell {
  overflow: hidden;
  border: 1px solid var(--tlsg-line);
  border-radius: var(--tlsg-radius);
  background:
    radial-gradient(circle at 92% 0%, rgba(20, 122, 82, 0.12), transparent 34%),
    var(--tlsg-panel);
  box-shadow: 0 18px 55px rgba(21, 52, 42, 0.1);
}

.tlsg-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--tlsg-line);
}

.tlsg-head-copy {
  min-width: 0;
}

.tlsg-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--tlsg-accent);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.tlsg-title {
  margin: 0;
  color: var(--tlsg-ink);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 850;
  letter-spacing: -0.02em;
}

.tlsg-lede {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--tlsg-muted);
  font-size: 12.5px;
  line-height: 1.65;
}

.tlsg-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(20, 122, 82, 0.2);
  border-radius: 999px;
  background: rgba(20, 122, 82, 0.09);
  color: var(--tlsg-accent-strong);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.tlsg-badge::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.tlsg-host[data-gis-status="loading"] .tlsg-badge::before,
.tlsg-host[data-gis-status="idle"] .tlsg-badge::before {
  animation: tlsg-pulse 1.1s ease-in-out infinite;
}

.tlsg-host[data-gis-status="partial"] .tlsg-badge {
  border-color: rgba(161, 92, 0, 0.22);
  background: rgba(161, 92, 0, 0.09);
  color: var(--tlsg-warn);
}

.tlsg-host[data-gis-status="unauthorized"] .tlsg-badge,
.tlsg-host[data-gis-status="error"] .tlsg-badge {
  border-color: rgba(180, 35, 24, 0.22);
  background: rgba(180, 35, 24, 0.08);
  color: var(--tlsg-danger);
}

@keyframes tlsg-pulse {
  0%,
  100% {
    opacity: 0.38;
    transform: scale(0.78);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.tlsg-body {
  padding: 18px 20px 20px;
}

.tlsg-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  gap: 16px;
  align-items: stretch;
}

.tlsg-map-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(20, 91, 62, 0.16);
  border-radius: 14px;
  background: #dfe9df;
}

.tlsg-map {
  width: 100%;
  min-height: 390px;
  background:
    linear-gradient(rgba(20, 122, 82, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 122, 82, 0.08) 1px, transparent 1px),
    #eaf0e7;
  background-size: 28px 28px;
}

.tlsg-map .leaflet-control-attribution {
  font-size: 9px;
}

.tlsg-map .leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(23, 52, 43, 0.18);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(23, 52, 43, 0.15);
}

.tlsg-map .leaflet-control-zoom a {
  color: var(--tlsg-ink);
}

.tlsg-map-meta {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 420;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 24px);
  pointer-events: none;
}

.tlsg-map-meta span {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 7px;
  background: rgba(18, 43, 34, 0.78);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(8px);
}

.tlsg-map-alert {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 430;
  padding: 9px 11px;
  border: 1px solid rgba(180, 35, 24, 0.25);
  border-radius: 9px;
  background: rgba(255, 249, 247, 0.95);
  color: var(--tlsg-danger);
  font-size: 11.5px;
  line-height: 1.5;
}

.tlsg-map-alert[hidden] {
  display: none;
}

.tlsg-side {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

.tlsg-card {
  padding: 12px 13px;
  border: 1px solid var(--tlsg-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.tlsg-card h3 {
  margin: 0 0 8px;
  color: var(--tlsg-ink);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.03em;
}

.tlsg-facts {
  display: grid;
  gap: 7px;
  margin: 0;
}

.tlsg-facts div {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.tlsg-facts dt,
.tlsg-facts dd {
  margin: 0;
}

.tlsg-facts dt {
  color: var(--tlsg-muted);
  font-size: 10.5px;
}

.tlsg-facts dd {
  max-width: 168px;
  color: var(--tlsg-ink);
  font-size: 11.5px;
  font-weight: 800;
  overflow-wrap: anywhere;
  text-align: right;
}

.tlsg-note {
  margin: 8px 0 0;
  color: var(--tlsg-muted);
  font-size: 10.5px;
  line-height: 1.55;
}

.tlsg-layer-list {
  display: grid;
  gap: 6px;
  max-height: 116px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.tlsg-layer-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 7px;
  border-radius: 7px;
  background: var(--tlsg-subtle);
  font-size: 10.5px;
}

.tlsg-layer-list b {
  min-width: 0;
  overflow: hidden;
  color: var(--tlsg-ink);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tlsg-layer-list span {
  flex: none;
  color: var(--tlsg-muted);
}

.tlsg-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: auto;
}

.tlsg-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
  border: 1px solid rgba(20, 122, 82, 0.2);
  border-radius: 9px;
  background: #fff;
  color: var(--tlsg-accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.tlsg-action.is-primary {
  border-color: var(--tlsg-accent);
  background: var(--tlsg-accent);
  color: #fff;
}

.tlsg-action:hover,
.tlsg-action:focus-visible {
  filter: brightness(1.06);
  outline: 2px solid rgba(20, 122, 82, 0.22);
  outline-offset: 2px;
}

/* 暗色：嵌入面板随平台主题切换，避免浅底浅字 */
html.dark {
  --tlsg-ink: #f2f4ef;
  --tlsg-muted: #b8c2be;
  --tlsg-line: rgba(255, 255, 255, 0.14);
  --tlsg-panel: rgba(18, 26, 20, 0.94);
  --tlsg-subtle: rgba(24, 36, 28, 0.92);
  --tlsg-accent: #63fe13;
  --tlsg-accent-strong: #9dff70;
  --tlsg-warn: #fde68a;
  --tlsg-danger: #fca5a5;
}

html.dark .tlsg-shell {
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.42);
}

html.dark .tlsg-action {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--tlsg-accent-strong) !important;
}

html.dark .tlsg-action.is-primary {
  border-color: var(--tlsg-accent);
  background: var(--tlsg-accent);
  color: #14210f !important;
}

html.dark .tlsg-failure {
  border-color: rgba(252, 165, 165, 0.32);
  background: rgba(180, 35, 24, 0.14);
}

html.dark .tlsg-map-card {
  border-color: rgba(255, 255, 255, 0.12);
  background: #0f1a13;
}

html.dark .tlsg-map {
  background:
    linear-gradient(rgba(99, 254, 19, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 254, 19, 0.08) 1px, transparent 1px),
    #0d1711;
  background-size: 28px 28px;
}

.tlsg-failure {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 28px;
  border: 1px dashed rgba(180, 35, 24, 0.26);
  border-radius: 14px;
  background: rgba(255, 249, 247, 0.7);
  text-align: center;
}

.tlsg-failure strong {
  display: block;
  margin-bottom: 8px;
  color: var(--tlsg-danger);
  font-size: 15px;
}

.tlsg-failure p {
  max-width: 600px;
  margin: 0 auto;
  color: var(--tlsg-muted);
  font-size: 12px;
  line-height: 1.65;
}

.tlsg-failure .tlsg-actions {
  width: min(100%, 340px);
  margin: 16px auto 0;
}

.tlsg-skeleton {
  min-height: 390px;
  border-radius: 14px;
  background:
    linear-gradient(105deg, rgba(20, 122, 82, 0.05) 20%, rgba(255, 255, 255, 0.55) 36%, rgba(20, 122, 82, 0.05) 52%),
    var(--tlsg-subtle);
  background-size: 220% 100%;
  animation: tlsg-shimmer 1.5s linear infinite;
}

@keyframes tlsg-shimmer {
  to {
    background-position: -220% 0;
  }
}

.tlsg-host .temporal-gis-summary {
  margin: 12px 20px 20px;
}

@media (max-width: 860px) {
  .tlsg-head {
    flex-direction: column;
  }

  .tlsg-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .tlsg-map {
    min-height: 320px;
  }

  .tlsg-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .tlsg-head,
  .tlsg-body {
    padding-right: 14px;
    padding-left: 14px;
  }

  .tlsg-map {
    min-height: 270px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tlsg-skeleton,
  .tlsg-badge::before {
    animation: none;
  }
}
