/* ── TSP Graph v3.0 ── */
.tspgraph-card {
  background: #0d1117;
  border: 1px solid #1a2535;
  border-radius: 16px;
  padding: 20px 24px 16px;
  color: #e2eaf4;
  position: relative;
  margin: 0 0 24px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ── Top bar ── */
.tspgraph-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tspgraph-title {
  font-size: .9rem;
  font-weight: 800;
  color: #c8daf0;
  letter-spacing: .02em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.tspgraph-asof {
  font-size: .72rem;
  font-weight: 500;
  color: #2a3d5a;
  letter-spacing: .01em;
}

/* ── Range pills ── */
.tspgraph-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tspgraph-pill {
  border: 1px solid #1a2535;
  background: #111827;
  color: #4b6280;
  font-weight: 700;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: .72rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: all .15s;
  font-family: inherit;
}
.tspgraph-pill:hover:not(.active) {
  border-color: #2a3d5a;
  color: #6a8aaa;
}
.tspgraph-pill.active {
  background: #1a2a4a;
  border-color: #2563eb;
  color: #e2eaf4;
}

/* ── Canvas wrapper ── */
.tspgraph-canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #080d14;
  border: 1px solid #1a2535;
}
.tspgraph-canvas {
  position: relative;
  width: 100%;
}
.tspgraph-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Loading state ── */
.tspgraph-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: #2a3d5a;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 700;
  background: #080d14;
  border-radius: 10px;
  z-index: 5;
}
.tspgraph-loading.is-visible {
  display: flex;
}
@keyframes tspg-blink {
  0%,100%{opacity:.4} 50%{opacity:1}
}
.tspgraph-loading span {
  animation: tspg-blink 1.4s ease-in-out infinite;
}

/* ── Legend ── */
.tspgraph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.tspgraph-key {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #1a2535;
  background: #111827;
  color: #c8daf0;
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  transition: all .15s;
  font-family: inherit;
}
.tspgraph-key:hover {
  border-color: #2a3d5a;
  background: #141e2e;
}
.tspgraph-key .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.tspgraph-key[aria-pressed="false"] {
  opacity: .4;
  border-color: #111827;
}
.tspgraph-key[aria-pressed="false"]:hover {
  opacity: .7;
}

/* ── Hint text ── */
.tspgraph-hint {
  font-size: .68rem;
  color: #1e3a5a;
  margin-top: 10px;
  line-height: 1.5;
  text-align: center;
}

/* ── Error / debug ── */
.tspgraph-error {
  margin-top: 10px;
  background: rgba(255,90,90,.07);
  border: 1px solid rgba(255,90,90,.25);
  color: #ff8a8a;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .8rem;
}
.tspgraph-debug {
  margin-top: 8px;
  color: #2a3d5a;
  font-size: .7rem;
  font-family: monospace;
}

/* ── Responsive heights ── */
@media (max-width: 480px)  { .tspgraph-canvas { height: 220px; } }
@media (min-width: 481px) and (max-width: 768px)  { .tspgraph-canvas { height: 280px; } }
@media (min-width: 769px) and (max-width: 1024px) { .tspgraph-canvas { height: 340px; } }
@media (min-width: 1025px) { .tspgraph-canvas { height: 400px; } }

@media (max-width: 600px) {
  .tspgraph-card { padding: 14px 14px 12px; }
  .tspgraph-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tspgraph-title { font-size: .82rem; }
  .tspgraph-pill { padding: 4px 10px; font-size: .68rem; }
  .tspgraph-key { font-size: .68rem; padding: 4px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .tspgraph-loading span { animation: none; }
}
