/* ---------- Results grid & cards ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start; /* expanding one card must not stretch its neighbors */
  gap: 18px;
  margin-bottom: 20px;
}
.tf-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition:
    opacity 0.65s cubic-bezier(0.22,1,0.36,1),
    transform 0.65s cubic-bezier(0.22,1,0.36,1),
    filter 0.65s cubic-bezier(0.22,1,0.36,1),
    border-color 0.3s;
  overflow: hidden;
}
.tf-card.visible { opacity: 1; transform: translateY(0); filter: blur(0); }
.tf-card.settled { transition: transform 0.16s ease-out, border-color 0.3s; will-change: transform; }
.tf-card:hover { border-color: var(--border-hi); }
.tf-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(480px circle at var(--mx, 50%) var(--my, 0%), rgba(120,180,255,0.08), transparent 42%);
  opacity: 0; transition: opacity 0.35s; pointer-events: none;
}
.tf-card:hover::before { opacity: 1; }

.tf-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tf-label-text { font-family: var(--font-disp); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em;
  padding: 6px 12px; border-radius: 999px; text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-BULLISH { background: transparent; color: var(--bullish); border-color: rgba(52,211,153,0.35); }
.badge-BEARISH { background: transparent; color: var(--bearish); border-color: rgba(251,113,133,0.35); }
.badge-NEUTRAL { background: transparent; color: var(--neutral); border-color: rgba(251,191,36,0.3); }

.price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.price { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--muted-2); }
.change { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.change.up   { color: var(--bullish); }
.change.down { color: var(--bearish); }

/* sparkline + crosshair */
.spark-wrap { position: relative; margin: 2px 0 16px; height: 58px; cursor: crosshair; }
.spark-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { opacity: 0; transition: opacity 0.9s ease 0.5s; }
.spark-wrap.go .spark-area { opacity: 1; }
.spark-line { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.3s cubic-bezier(0.22,1,0.36,1) 0.15s; }
.spark-wrap.go .spark-line { stroke-dashoffset: 0; }
.cross-x {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(148,197,255,0.35); opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.cross-dot {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text);
  margin: -4px 0 0 -4px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.cross-tip {
  position: absolute; top: -26px; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  color: var(--text); background: rgba(10,14,24,0.92);
  border: 1px solid var(--border-hi); border-radius: 7px;
  padding: 3px 8px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.spark-wrap.tracking .cross-x, .spark-wrap.tracking .cross-dot, .spark-wrap.tracking .cross-tip { opacity: 1; }

/* candlestick variant — needs more vertical room than the sparkline for
   wicks/bodies to read clearly */
.spark-wrap.candles { height: 80px; }
.candle-svg { opacity: 0; transition: opacity 0.7s ease 0.15s; }
.spark-wrap.candles.go .candle-svg { opacity: 1; }

/* bipolar score bar */
.score-block { margin-bottom: 16px; }
.score-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.score-title { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.score-val { font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.bar-wrap { position: relative; height: 8px; background: rgba(255,255,255,0.05); border-radius: 999px; overflow: visible; }
.bar-center { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1.5px; background: rgba(255,255,255,0.18); }
.bar-fill {
  position: absolute; top: 0; height: 100%; border-radius: 999px;
  width: 0; transition: width 0.9s cubic-bezier(0.22,1,0.36,1) 0.35s, left 0.9s cubic-bezier(0.22,1,0.36,1) 0.35s;
}
.bar-fill.up   { background: var(--bullish); }
.bar-fill.down { background: var(--bearish); }

/* accuracy ring row */
.stats-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; margin-bottom: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ring-wrap { position: relative; width: 62px; height: 62px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: rgba(255,255,255,0.07); stroke-width: 5; }
.ring-fg  {
  fill: none; stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22,1,0.36,1) 0.4s;
}
.ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
}
.stats-text { flex: 1; }
.stats-title { font-size: 12.5px; font-weight: 600; color: var(--muted-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats-meta  { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.stats-meta b { color: var(--muted-2); font-family: var(--font-mono); font-weight: 600; }

/* reasons — collapsed by default, expand on tap */
.votes-toggle {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; padding: 6px 0;
  font-family: var(--font-body); -webkit-tap-highlight-color: transparent;
}
.votes-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); transition: color 0.25s;
}
.votes-toggle:hover .votes-title { color: var(--muted-2); }
.votes-counts { margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 600; display: inline-flex; gap: 9px; }
.votes-counts .up { color: var(--bullish); }
.votes-counts .down { color: var(--bearish); }
.votes-counts .flat { color: var(--muted); }
.chev { color: var(--muted); font-size: 11px; transition: transform 0.35s cubic-bezier(0.22,1,0.36,1); }
.votes-toggle.open .chev { transform: rotate(180deg); }
.votes-body {
  overflow: hidden; max-height: 0;
  transition: max-height 0.5s cubic-bezier(0.22,1,0.36,1);
}
.reasons { list-style: none; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
.reasons li {
  font-size: 12.5px; color: var(--muted-2); display: flex; gap: 9px; line-height: 1.55;
  opacity: 0; transform: translateX(-10px);
}
.votes-body.open .reasons li { animation: slideIn 0.5s cubic-bezier(0.22,1,0.36,1) forwards; }
@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
.vote { flex-shrink: 0; font-size: 11px; width: 14px; text-align: center; margin-top: 2px; font-weight: 700; }
.vote.up   { color: var(--bullish); }
.vote.down { color: var(--bearish); }
.vote.flat { color: var(--muted); }
.tf-error { font-size: 12.5px; color: var(--bearish); line-height: 1.6; }

/* ---------- Indicator contribution chart (diverging bars) ---------- */
.contrib-list { display: flex; flex-direction: column; gap: 11px; padding-top: 10px; }
.contrib-row {
  opacity: 0; transform: translateX(-10px);
}
.votes-body.open .contrib-row { animation: slideIn 0.5s cubic-bezier(0.22,1,0.36,1) forwards; }
.contrib-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.contrib-label {
  flex-shrink: 0; width: 72px; font-family: var(--font-mono); font-size: 10.5px;
  font-weight: 700; letter-spacing: 0.03em; color: var(--muted-2);
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.contrib-bar-wrap { position: relative; flex: 1; height: 8px; }
.contrib-bar-track { position: absolute; inset: 0; top: 3px; height: 2px; background: rgba(255,255,255,0.06); border-radius: 999px; }
.contrib-bar-zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1.5px; background: rgba(255,255,255,0.18); }
.contrib-bar-fill {
  position: absolute; top: 0; height: 8px; border-radius: 999px;
}
.contrib-bar-fill.up   { background: var(--bullish); }
.contrib-bar-fill.down { background: var(--bearish); }
.contrib-value {
  flex-shrink: 0; width: 44px; text-align: right;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; color: var(--muted-2);
}
.contrib-icon { display: inline-block; margin-right: 3px; }
.contrib-icon.up   { color: var(--bullish); }
.contrib-icon.down { color: var(--bearish); }
.contrib-icon.flat { color: var(--muted); }
.contrib-reason { font-size: 11.5px; color: var(--muted); line-height: 1.5; padding-left: 80px; }

/* ---------- Analysis scanner (loading state) ---------- */
.scanner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.5s cubic-bezier(0.22,1,0.36,1) both;
}
.scanner::before { /* faint chart grid */
  content: ""; position: absolute; inset: 58px 24px 36px;
  background-image:
    linear-gradient(rgba(148,197,255,0.05) 1px, transparent 1px);
  background-size: 100% 34px;
  pointer-events: none;
}
.scanner-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 14px; flex-wrap: wrap; margin-bottom: 12px;
}
.scan-status {
  font-size: 13.5px; font-weight: 600; color: var(--muted-2);
  display: inline-flex; align-items: center; gap: 10px;
}
.scan-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mkc, var(--accent));
  box-shadow: 0 0 12px var(--mkc, var(--accent));
  animation: breathe 1.6s ease-in-out infinite;
}
.scan-phase { transition: opacity 0.35s, transform 0.35s; }
.scan-phase.swap { opacity: 0; transform: translateY(7px); }
.scan-note { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.scan-chart {
  position: relative; height: 170px; overflow: hidden;
  border-bottom: 1px solid rgba(148,197,255,0.14);
  mask-image: linear-gradient(90deg, transparent, black 7%, black 93%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black 7%, black 93%, transparent);
}
.candle-track {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; gap: 6px; padding: 0 2px;
  will-change: transform;
}
.candle {
  position: relative; flex: 0 0 14px; border-radius: 3px;
  background: currentColor;
  animation: candleIn 0.4s cubic-bezier(0.22,1,0.36,1) both;
}
.candle.up   { color: #2fbf87; }
.candle.down { color: #e26377; }
.candle::before { /* wick */
  content: ""; position: absolute; left: 50%; width: 2px;
  transform: translateX(-50%);
  top: calc(-1 * var(--wt, 6px)); bottom: calc(-1 * var(--wb, 6px));
  background: currentColor; opacity: 0.65; border-radius: 2px;
}
@keyframes candleIn { from { transform: scaleY(0); opacity: 0; } }
.scan-beam {
  position: absolute; top: 0; bottom: 0; width: 70px; left: -10%;
  background: linear-gradient(90deg, transparent,
    color-mix(in srgb, var(--mkc, #38bdf8) 20%, transparent), transparent);
  animation: beamSweep 2.6s ease-in-out infinite alternate;
  pointer-events: none;
}
.scan-beam::after {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1.5px;
  background: var(--mkc, #38bdf8); opacity: 0.85;
  box-shadow: 0 0 16px var(--mkc, #38bdf8);
}
@keyframes beamSweep { from { left: -4%; } to { left: calc(100% - 66px); } }
.scanner .runner {
  position: absolute; bottom: 3px; left: 30px;
  transform: scale(0.5); transform-origin: bottom left;
  animation: none; opacity: 0.95; z-index: 2;
}
.scan-floater {
  position: absolute; bottom: 16px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  opacity: 0; pointer-events: none;
  animation: floatUp 2.8s linear forwards;
}
@keyframes floatUp {
  12%  { opacity: 0.75; }
  100% { transform: translateY(-130px); opacity: 0; }
}
.scan-progress {
  position: relative; height: 3px; margin-top: 14px;
  border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden;
}
.scan-progress::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 38%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--mkc, #38bdf8), transparent);
  animation: indet 1.5s ease-in-out infinite;
}
@keyframes indet { from { left: -38%; } to { left: 100%; } }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 70px 20px 50px;
  animation: rise 0.8s 0.18s cubic-bezier(0.22,1,0.36,1) both;
}
.empty-icon { font-size: 38px; margin-bottom: 16px; opacity: 0.85; }
.empty-title { font-family: var(--font-disp); font-size: 19px; font-weight: 700; margin-bottom: 8px; }
.empty-sub { font-size: 13px; color: var(--muted); line-height: 1.7; max-width: 420px; margin: 0 auto; }
