/* Widget fan panel — math-like styling without depth-toggle collapse */
.widget-math {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  margin: 0.75rem 0;
}

/* Chart containers */
.chart-container {
  margin: 2rem 0;
  position: relative;
}

.chart-container svg:not(.die-svg) {
  width: 100%;
  height: auto;
  display: block;
}

.chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.chart-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
  line-height: 1.4;
}

/* Tooltips */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 50;
  max-width: 260px;
  opacity: 0;
  transition: opacity 0.15s;
  font-family: var(--font-serif);
}

.chart-tooltip.visible {
  opacity: 1;
}

.chart-tooltip .tt-label {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.chart-tooltip .tt-value {
  color: var(--accent);
  font-weight: 600;
}

.dark .chart-tooltip {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Sliders */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
  flex-wrap: wrap;
}

.chart-controls label {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.chart-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  flex-shrink: 0;
}

.chart-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chart-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slider-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  min-width: 2.5em;
  font-weight: 600;
  display: inline-block;
  text-align: right;
}

/* Dropdowns */
.chart-select {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.chart-select:hover {
  border-color: var(--accent);
}

.chart-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light, rgba(243, 112, 33, 0.15));
}

/* Legend */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

.chart-legend-item.dimmed {
  opacity: 0.35;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Headline stats (inline summary boxes) */
.headline-stats {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.headline-stat {
  flex: 1;
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.5rem 0.25rem;
  text-align: center;
}

.headline-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.headline-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Stats panel (for risk-reward) */
.chart-stats-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
  font-size: 0.8rem;
}

.chart-stat {
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
}

.chart-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Buttons */
.chart-btn {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.chart-btn:hover {
  background: var(--accent-light);
}

.chart-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Mixture toggles */
.mixture-toggles {
  justify-content: flex-start;
}
.mixture-toggle-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.mixture-toggle-group label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 0.25rem;
}
.mixture-toggle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.mixture-toggle:hover {
  background: var(--accent-light);
}
.mixture-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Scenario cards (decision explorer) */
.scenario-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.scenario-nav button {
  font-size: 1.2rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scenario-nav button:hover {
  background: var(--accent-light);
}

.scenario-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dice-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  justify-content: center;
}

.die {
  width: 48px;
  height: 48px;
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Action table within decision explorer */
.action-table {
  width: 100%;
  font-size: 0.85rem;
}

.action-table td:first-child {
  font-weight: 600;
}

.action-table .best-action {
  background: var(--accent-light);
}

/* Equations (backward induction) */
.equation {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  margin: 0.4rem 0;
  background: var(--bg-alt);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
  line-height: 1.6;
}

/* Greedy vs Optimal comparison */
.gvo-comparison {
  display: flex;
  gap: 0;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.gvo-side {
  flex: 1;
  padding: 0.75rem 1rem;
}

.gvo-divider {
  width: 1px;
  background: var(--border);
}

.gvo-header {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.gvo-category {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  background: var(--bg-alt);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  text-align: center;
}

.gvo-category.gvo-diverge {
  border: 2px solid var(--accent);
}

.gvo-score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.15rem 0;
}

.gvo-score-label {
  color: var(--text-muted);
}

.gvo-score-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.gvo-progress {
  margin-top: 0.5rem;
}

.gvo-progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.gvo-progress-bar {
  height: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.gvo-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.gvo-diverge-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0.5rem 0;
}

.gvo-final {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  text-align: center;
}

.gvo-final-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.gvo-final-gap {
  font-size: 1.1rem;
  color: var(--accent);
}

/* Spray hint */
.spray-hint {
  font-size: 0.8em;
  opacity: 0.5;
  margin-top: 0.4em;
  font-style: italic;
}

/* Spray stats table */
.spray-stats {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-family: var(--font-serif);
}

.spray-stats table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.spray-stats th,
.spray-stats td {
  padding: 0.25rem 0.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  width: 14%;
}

.spray-stats th:first-child,
.spray-stats td:first-child {
  width: 30%;
}

.spray-stats th {
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.spray-stats td:first-child,
.spray-stats th:first-child {
  text-align: left;
}

.spray-stats .spray-stats-label {
  font-weight: 600;
}

.spray-stats .spray-stats-live {
  color: var(--accent);
}

/* Race-to-63 link blending */
.race-links { mix-blend-mode: screen; }
.dark .race-links { mix-blend-mode: lighten; }

/* Transition matrix (hover styles are inline in the chart module) */

/* Insight text (category landscape guided tour) */
.insight-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 0 4px 4px 0;
  box-sizing: border-box;
}

/* Heatmap cell hover */
.corr-cell:hover,
.fill-cell:hover {
  stroke: var(--text) !important;
  stroke-width: 1.5 !important;
}

/* Compact inline charts */
.chart-compact {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.chart-compact .chart-controls {
  justify-content: center;
}

/* Centered slider variant */
.chart-controls-center {
  justify-content: center;
}

/* Tail probability stats (risk-theta dual chart) */
.tail-stats {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.tail-stat {
  flex: 0 0 calc((100% - 2rem) / 5);
  min-height: 3.6rem;
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.35rem 0.2rem;
  text-align: center;
  overflow: hidden;
}

.tail-stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.3;
  height: 1.2em;
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.tail-stat-value sup {
  font-size: 0.6em;
  line-height: 0;
  vertical-align: baseline;
  position: relative;
  top: -0.5em;
}

.tail-stat-change {
  font-size: 0.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.3;
  height: 0.9em;
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.tail-stat-change sup {
  font-size: 0.6em;
  line-height: 0;
  vertical-align: baseline;
  position: relative;
  top: -0.5em;
}

.tail-stat-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
}

/* Responsive chart adjustments */
@media (max-width: 720px) {
  .chart-slider { width: 140px; }
  .chart-stats-panel { grid-template-columns: repeat(2, 1fr); }
  .die { width: 40px; height: 40px; font-size: 1.1rem; }
  .gvo-comparison { flex-direction: column; }
  .gvo-divider { width: 100%; height: 1px; }
  .equation { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
}
