/* ===== Trading Cards Theme (dark) ===== */
:root{
  --bg:#0b0f1a;
  --panel:#0f1625;
  --edge:#141c2e;
  --text:#e6eefc;
  --muted:#9db0d1;
  --bull:#16c784;
  --bear:#ea3943;
  --neu:#5b6b86;
  --accent:royalblue;
}

/* Container */
.ai-trade-container{
  background: radial-gradient(1200px 600px at 10% -20%, #11203a, transparent),
              radial-gradient(1000px 500px at 100% 0%, #092136, transparent),
              var(--bg);
  border:1px solid var(--edge);
  border-radius:16px;
  padding:18px;
  color:var(--text);
  box-shadow: 0 6px 30px rgba(0,0,0,.35);
}

.ai-trade-title{display:flex;align-items:center;gap:10px;font-weight:700;}
.ai-trade-title svg{width:40px;height:40px;filter:drop-shadow(0 0 6px rgba(45,212,255,.4))}
.ai-trade-sub{color:var(--muted);font-size:12px}
.ai-chip{
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  border:1px solid var(--edge);border-radius:10px;padding:4px 10px;font-size:12px;color:var(--muted);
}

/* ===== Filter panel (clean, single source) ===== */
.ai-filters{
  display:grid; gap:12px;
  padding:14px; margin:8px 0 14px;
  border:1px solid var(--edge); border-radius:12px;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
}
.flt-group{
  border:1px solid var(--edge); border-radius:10px;
  padding:10px; background:rgba(0,0,0,.05);
}
.flt-group > h4{
  margin:0 0 8px; font-weight:700; font-size:12px;
  color:var(--muted); letter-spacing:.3px; text-transform:uppercase;
}
.flt-group .row{
  display:grid; gap:10px;
  grid-template-columns: repeat(1, minmax(0,1fr));
}
.flt-group .cell{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.flt-group .cell > span{ color:var(--muted); font-size:12px; white-space:nowrap; }
.flt-group input, .flt-group select{
  width:100%; background:var(--panel); color:steelblue;
  border:1px solid var(--edge); border-radius:10px;
  padding:8px 12px; font-size:13px;
}
.flt-actions{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end;
  border-top:1px solid var(--edge); padding-top:10px; margin-top:2px;
}
/* Optional: make filters stay visible when scrolling */
/* .ai-filters{ position:sticky; top:8px; z-index:10; } */

/* Buttons */
/* Busy state + micro spinner on primary buttons */
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-btn.busy{
  position: relative;
  opacity: .85;
  cursor: default;
  padding-right: 34px; /* make room for spinner */
}
.ai-btn.busy::after{
  content:"\25bc";
  position:absolute; right:10px; top:30%; transform:translateY(-50%);
  width:14px; height:14px; border-radius:50%;
  animation: ai-spin .7s linear infinite;
  opacity:.9;
}

.ai-btn{
  border:1px solid var(--edge);
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color:var(--text); font-weight:700; padding:9px 14px; border-radius:10px; cursor:pointer;
  transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ai-btn:hover{ transform:translateY(-1px); box-shadow:0 6px 16px rgba(0,0,0,.25); }
.ai-btn.primary{
  border-color: rgba(45,212,255,.45);
  background:linear-gradient(180deg, rgba(45,212,255,.22), rgba(45,212,255,.08));
  color:royalblue;
}
.ai-btn.ghost{ opacity:.95; }

/* Custom select (with arrow) */
.ai-select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  background-image: linear-gradient(45deg,transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
                    linear-gradient(to right, transparent, transparent);
  background-position: calc(100% - 18px) calc(50% - 5px), calc(100% - 12px) calc(50% - 5px), 0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
  padding-right: 34px;
  white-space: nowrap;
}

/* Range slider + value bubble */
.range{ display:flex; align-items:center; gap:10px; }
.range input[type="range"]{
  -webkit-appearance:none; appearance:none; width:100%; height:6px; border-radius:999px;
  background: rgba(255,255,255,.1); outline:none; border:1px solid var(--edge);
}
.range input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:16px; height:16px; border-radius:50%;
  background: var(--accent); box-shadow:0 0 8px rgba(45,212,255,.5);
  border:1px solid rgba(45,212,255,.6); cursor:pointer;
}
.range input[type="range"]::-moz-range-thumb{
  width:16px; height:16px; border-radius:50%; background: var(--accent);
  border:1px solid rgba(45,212,255,.6); cursor:pointer;
}
.range .bubble{
  min-width:48px; text-align:center; font-size:12px; color:var(--text);
  border:1px solid var(--edge); border-radius:10px; padding:4px 8px;
  background:rgba(255,255,255,.05);
}

/* Switches (iOS-style) */
.switch{ display:inline-flex; align-items:center; gap:8px; margin-right:14px; user-select:none; white-space:nowrap; }
.switch > input{ display:none; }
.switch > i{
  width:38px; height:22px; border-radius:999px; position:relative; display:inline-block;
  background:rgba(255,255,255,.1); border:1px solid var(--edge); transition:background .2s ease, border-color .2s ease;
}
.switch > i::after{
  content:""; position:absolute; top:50%; left:3px; transform:translateY(-50%);
  width:16px; height:16px; border-radius:50%; background:#9db0d1; transition:left .2s ease, background .2s ease, box-shadow .2s ease;
}
.switch > input:checked + i{ background:rgba(22,199,132,.25); border-color:rgba(22,199,132,.45); }
.switch > input:checked + i::after{ left:19px; background:#16c784; box-shadow:0 0 8px rgba(22,199,132,.5); }
.switch > span{ color:var(--muted); font-size:12px; }

/* Responsive filters */
@media (min-width:720px){
  .flt-group .row{ grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (min-width:1040px){
  .flt-group .row{ grid-template-columns: repeat(4, minmax(0,1fr)); }
  .switches{ grid-column: span 2; }
}

/* ===== Cards grid ===== */
.ai-grid{
  display:grid;gap:14px;
  grid-template-columns: repeat(1, minmax(0,1fr));
}
@media (min-width:600px){ .ai-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (min-width:960px){ .ai-grid{ grid-template-columns: repeat(3, minmax(0,1fr)); } }

/* Card */
.ai-card{
  position:relative; overflow:hidden;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  border:1px solid var(--edge); border-radius:14px; padding:14px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.ai-card:hover{
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  border-color: rgba(45,212,255,.35);
}
/* subtle animated edge glow */
.ai-card::before{
  content:""; position:absolute; inset:-2px;
  background: radial-gradient(600px 200px at -10% -10%, rgba(45,212,255,.12), transparent 40%),
              radial-gradient(600px 200px at 110% 110%, rgba(45,212,255,.12), transparent 40%);
  pointer-events:none; opacity:.6;
}
.card-bull{ background:linear-gradient(180deg, rgba(22,199,132,.10), rgba(255,255,255,0)); }
.card-bear{ background:linear-gradient(180deg, rgba(234,57,67,.10), rgba(255,255,255,0)); }
.card-neu { background:linear-gradient(180deg, rgba(91,107,134,.08), rgba(255,255,255,0)); }

.ai-card-head{ display:flex; align-items:center; gap:10px; }
.ai-coin{
  width:40px;height:40px;border-radius:50%;display:grid;place-items:center;
  font-weight:800; font-size:12px; letter-spacing:.3px; color:#05151c;
  background: radial-gradient(circle at 30% 30%, #2dd4ff, royalblue);
  box-shadow: 0 0 10px rgba(45,212,255,.5) inset;
}
.ai-head-meta{ display:flex; flex-direction:column; line-height:1.1; }
.ai-symbol{ font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.ai-market{ color:var(--muted); font-size:12px; }
.ai-head-badge{ margin-left:auto; }

.ai-badge{
  display:inline-flex;align-items:center;gap:6px;
  padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700;
  border:1px solid var(--edge); background:rgba(255,255,255,.03);
}
.ai-bullish{ color:mediumspringgreen;background:linear-gradient(180deg, rgba(22,199,132,.25), rgba(22,199,132,.08)); border-color:rgba(22,199,132,.35); }
.ai-bearish{ color:darkred;background:linear-gradient(180deg, rgba(234,57,67,.28), rgba(234,57,67,.08)); border-color:rgba(234,57,67,.35); }
.ai-neutral{ color:royalblue;background:linear-gradient(180deg, rgba(91,107,134,.25), rgba(91,107,134,.08)); border-color:rgba(91,107,134,.35); }

.ai-conf{ display:flex;align-items:center;gap:10px; margin:10px 0 8px; }
.ai-bar{
  position:relative; flex:1; height:10px; border-radius:999px; overflow:hidden;
  background:rgba(255,255,255,.06); border:1px solid var(--edge);
}
.ai-bar > span{
  position:absolute;left:0;top:0;height:100%;width:0%;
  background:linear-gradient(90deg, var(--accent), rgba(45,212,255,.1));
  box-shadow: 0 0 12px rgba(45,212,255,.45);
  transition:width .6s ease;
}
.pct{ font-size:12px;color:var(--muted); min-width:36px; text-align:right; }

.ai-tagrow{ display:flex; gap:8px; flex-wrap:wrap; margin:8px 0; }
.ai-features{ display:flex;gap:8px;flex-wrap:wrap;color:var(--muted);font-size:12px; }
.ai-pill{
  border:1px solid var(--edge); border-radius:8px; padding:4px 8px;
  background:rgba(255,255,255,.04); font-size:12px; color:var(--muted);
}
.ai-pill.warn{ border-color: rgba(234,57,67,.45); color:#32070a; background:linear-gradient(180deg, rgba(234,57,67,.22), rgba(234,57,67,.06)); }
.ai-pill.good{ border-color: rgba(22,199,132,.45); color:mediumspringgreen; background:linear-gradient(180deg, rgba(22,199,132,.22), rgba(22,199,132,.06)); }

/* Skeletons */
.ai-skel{ 
  background:linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.12), rgba(255,255,255,.05));
  background-size:200% 100%; animation: shimmer 1.1s infinite;
  border-radius:6px;
}
.ai-skel-card{ animation: floaty .8s ease alternate infinite; }
@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
@keyframes floaty{0%{transform:translateY(0)}100%{transform:translateY(-2px)}}
.pop-in{ opacity:0; transform: translateY(6px) scale(.98); animation: pop .45s forwards ease; }
@keyframes pop{ to{ opacity:1; transform: translateY(0) scale(1);} }

/* Sparkline area */
.ai-spark-wrap{
  margin:10px 0 6px;
  padding:6px 8px;
  border:1px solid var(--edge);
  border-radius:10px;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
}
.ai-spark{ display:block; width:100%; height:auto; }

/* Notes & info chips */
.ai-note{ margin:6px 0 10px; color:var(--muted); font-size:12px; display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.ai-chip.info{
  border:1px solid rgba(45,212,255,.45);
  background:linear-gradient(180deg, rgba(45,212,255,.16), rgba(45,212,255,.06));
  color:steelblue;
}

/* Ensure inline chips/badges don't clip */
.ai-badge, .ai-pill, .ai-card-head, .ai-spark-wrap, .ai-tagrow, .ai-conf{
  overflow: visible; position: relative; z-index: 1;
}

/* Muted/nudge reason pill */
.ai-pill.muted {
  border: 1px dashed #d8dde6;
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, .04);
  font-size: 12px;
  color: var #9db0d1 (--muted);
}

/* ===== Tooltip Portal (renders at <body>, escapes overflow) ===== */
#ai-tip {
  position: fixed;
  left: 0; top: 0;
  transform: translate(-9999px, -9999px);
  pointer-events: none;
  z-index: 100000; /* above WP admin bars, etc. */
}

#ai-tip .bubble {
  display: inline-block;            /* so background hugs text */
  max-width: 340px;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    var(--panel);
  color: var(--text);
  white-space: pre-wrap;            /* show \n from data-tip */
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.02);
  opacity: 0;
  transition: opacity .12s ease, transform .12s ease;
}

#ai-tip.show .bubble { opacity: 1; }

/* Arrow */
#ai-tip::after {
  content: "";
  position: absolute;
  width: 0; height: 0;
  border: 6px solid transparent;
  border-top-color: var(--edge); /* default arrow up */
  opacity: 0;
  transition: opacity .12s ease;
}
#ai-tip.show::after { opacity: 0; }

/* Flip below when near the top edge */
#ai-tip.bottom .bubble { transform: translateY(14px); }
#ai-tip.bottom::after {
  border-top-color: transparent;
  border-bottom-color: var(--edge);
}

/* Disable old pseudo-element tips (prevents double tooltips) */
.ai-tip[data-tip]::before,
.ai-tip[data-tip]::after { display: none !important; }

/* ===== Inline Help Notes (shown when Help is ON) ===== */
.ai-helpnote{
  display:none;
  margin:8px 0 0;
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--edge);
  border-radius:10px;
  padding:8px 10px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  line-height:1.35;
}
.ai-trade-container.help-on .ai-helpnote{ display:block; }

/* When inside a filters grid cell, keep spacing tidy */
.flt-group .cell .ai-helpnote{ margin-top:6px; }

/* While help is ON, disable hover tips completely */
.ai-trade-container.help-on #ai-tip{ display:none !important; }

/* ===== Inline card help (shown when Help is ON) ===== */
.ai-card-help{
  display:none;
  margin-top:8px;
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--edge);
  border-radius:10px;
  padding:8px 10px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  line-height:1.35;
}
.ai-card-help h5{
  margin:0 0 6px;
  font-weight:700;
  font-size:12px;
  letter-spacing:.3px;
  text-transform:uppercase;
  color:var(--muted);
}
.ai-card-help ul{ margin:0; padding-left:16px; }
.ai-card-help li{ margin:4px 0; }

/* Show all inline help blocks when Help is ON */
.ai-trade-container.help-on .ai-card-help{ display:block; }

/* While Help is ON, keep hover tips off (you already hide #ai-tip) */
.ai-trade-container.help-on #ai-tip{ display:none !important; }

.ai-ibtn{
  border:1px solid var(--edge);
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color:var(--text);
  border-radius:10px;
  padding:6px 8px;
  font-size:13px;
  line-height:1;
  cursor:pointer;
}
.ai-ibtn:hover{ box-shadow:0 6px 14px rgba(0,0,0,.25); transform:translateY(-1px); }

/* flash styles for per-card message chip */
.ai-chip.ok{
  border-color: rgba(22,199,132,.5);
  background: linear-gradient(180deg, rgba(22,199,132,.22), rgba(22,199,132,.06));
  color:mediumspringgreen;
}
.ai-chip.err{
  border-color: rgba(234,57,67,.5);
  background: linear-gradient(180deg, rgba(234,57,67,.22), rgba(234,57,67,.06));
  color:darkred;
}
.ai-chip.pop{
  animation: flash-pop .25s ease;
}
@keyframes flash-pop{
  from{ transform: scale(.96); opacity:.75 }
  to  { transform: scale(1);    opacity:1 }
}

/* Title and toolbar flex behavior */
.ai-trade-header .ai-trade-title{ flex: 1 1 auto; min-width: 200px; }
.ai-trade-header .ai-toolbar    { margin-left:auto; display:flex; align-items:center; gap:5px; flex: 0 1 auto; min-width: 260px; flex-wrap:wrap; }

/* Keep chips and controls from shrinking to unreadable */
.ai-trade-header .ai-chip,
.ai-trade-header .currency-control { flex: 0 0 auto; }
.ai-trade-header .ai-divider { flex: 0 0 1px; height: 24px; background: royalblue; width:1px; }

/* Header layout: push toolbar (Universe + Currency) to the right */
.ai-trade-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;         /* allow wrapping instead of mashing on small screens */
}
.ai-trade-header .ai-trade-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-toolbar {
  margin-left: auto;         /* right-align */
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Divider */
.ai-divider {
  width: 1px;
  height: 18px;
  background: var(--ai-border, #22304a);
  opacity: 0.5;
}

/* Currency control */
.currency-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ai-text, #d7e3ff);
}

.currency-control .select-wrap {
  position: relative;
  display: inline-block;
}

.currency-control select.ai-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--ai-surface-2, #0e1726);
  border: 1px solid var(--ai-border, #22304a);
  color: var(--ai-text, #05151c);
  padding: 6px 28px 6px 10px;
  border-radius: 10px;
  line-height: 1.2;
  font-size: 13px;
}

.currency-control .chev {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.7;
}

/* Hover/focus states */
.currency-control select.ai-select:hover {
  border-color: #2dd4ff;
}
.currency-control select.ai-select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}

/* Tighten on mobile */
@media (max-width: 640px) {
  .currency-control .label { display: none; }
  .ai-toolbar { gap: 8px; }
}

.cur-chip{
  display:flex;
  align-items:left;
  gap:8px;
}

.ai-cur-badge {
  padding: 0px 2px;
  color: var(--ai-text, #d7e3ff);
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.9;
}

.ai-chip.warn { background: #ffe7e7; color: #9b1c1c; border-color: #f8caca; }
.ai-cur-badge { font-weight:700; }

#tracked { margin-bottom: 15px; }

.ai-note-log { float: right; margin-top: -8px; }

.ai-card.is-tracked{
  box-shadow: 0 0 4px 0 royalblue;
}

.ai-card.is-tracked .ai-head-badge .ai-badge{
  box-shadow: 0 0 0 2px rgba(45,212,255, .25) inset;
  border-radius: 8px;
}

.ai-btn.saved-ok{
  border-color: rgba(45, 212, 255, .45);
}

/* Learning chip states */
.ai-chip.learn-ok   { border-color:#10b981; color:#10b981; background:rgba(16,185,129,.12); }
.ai-chip.learn-warn { border-color:#f59e0b; color:#f59e0b; background:rgba(245,158,11,.12); }
.ai-chip.learn-err  { border-color:#ef4444; color:#ef4444; background:rgba(239,68,68,.14); }

/* Pulse animation when an event hits the learner */
@keyframes learnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.28); }
  100% { box-shadow: 0 0 0 16px rgba(16,185,129,0); }
}
.ai-chip.learn-pulse { animation: learnPulse 1s ease-out 1; }

/* Inline info icons beside top-section labels (hover shows tooltip) */
.ai-filters .tip-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px; height:18px;
  border-radius:50%;
  border:1px solid var(--accent);
  color:var(--accent);
  background: rgba(65,105,225,.14); /* royalblue-ish */
  box-shadow: 0 0 0 2px rgba(65,105,225,.12) inset, 0 0 8px rgba(65,105,225,.15);
  vertical-align:middle;
  cursor: help;          /* hover-only; no click/sticky */
}

.ai-filters .tip-icon:hover{
  background: rgba(65,105,225,.22);
  color:#fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(65,105,225,.18) inset, 0 0 10px rgba(65,105,225,.28);
}

.ai-filters .tip-icon svg{
  width:18px; height:18px; pointer-events:none;
}

/* Ensure icon sits neatly with label text */
.flt-group > h4,
.flt-group .cell > span{
  display:inline-flex;
  align-items:center;
  gap:8px;
}

/* Make Trend ✓ bolder and more pronounced (cards only) */
.ai-pill.pill-trend .pill-icon{
  width:16px;   /* was 12px */
  height:16px;  /* was 12px */
  /* optional subtle focus glow for dark themes */
  filter: drop-shadow(0 0 2px color-mix(in srgb, currentColor 35%, transparent));
}

.ai-pill.pill-trend .pill-icon.ok path{
  stroke-width:4;           /* was 2 */
  stroke-linecap:round;       /* ensure rounded ends */
  stroke-linejoin:round;      /* ensure rounded corner */
  shape-rendering:geometricPrecision;
}

/* Trend chip icon styling */
.ai-pill.pill-trend{
  display:inline-flex;
  align-items:center;
  gap:6px; /* space between text and icon */
}

/* Base size for any inline icon used in pills */
.ai-pill .pill-icon{
  display:inline-block;
  vertical-align:middle;
}

/* Colors for Trend ✓ / ✖ */
.ai-pill.pill-trend .pill-icon.ok{  color: var(--bull); } /* green */
.ai-pill.pill-trend .pill-icon.bad{ color: var(--bear); } /* red */

/* ========== Tablet-ish (<= 900px) ========== */
@media (max-width: 900px){
  .ai-trade-header{ gap: 10px; }
  .ai-trade-header .ai-trade-title > svg{ width:18px; height:18px; }
  .ai-trade-title .ai-trade-sub{ font-size:11px; }
  .ai-trade-header .ai-toolbar{ gap:8px; }
  .ai-trade-header .ai-divider{ display:none; }  /* save space */
}

/* ========== Narrow phones (<= 640px) ========== */
@media (max-width: 640px){
  /* Stack the title full-width on its own row */
  .ai-trade-header .ai-trade-title{
    flex: 1 1 100%;
    min-width: 0;
  }

  /* Toolbar becomes a wrapping row */
  .ai-trade-header .ai-toolbar{
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 8px 10px;
  }

  /* Trim visual noise */
  .ai-trade-title > svg{ display:none; }                 /* hide the left icon */
  .ai-trade-title .ai-trade-sub{ display:none; }         /* hide subtitle on phones */

  /* Make chips compact but readable */
  .ai-trade-header .ai-chip{
    font-size:12px;
    padding:4px 8px;
    white-space:nowrap;
  }

  /* Currency control: hide label text, keep the selector */
  .ai-trade-header .currency-control .label{ display:none; }
  .ai-trade-header .currency-control .select-wrap{ width:auto; }
  .ai-trade-header .currency-control select.ai-select{
    min-width: 120px;
    padding:6px 26px 6px 10px;
    font-size:12px;
  }
}

/* ========== Extra small (<= 420px) ========== */
@media (max-width: 420px){
  /* Turn toolbar into a simple 2-col grid */
  .ai-trade-header .ai-toolbar{
    display:grid;
    grid-template-columns: 1fr 1fr;
    width:100%;
  }

  /* Put chips on row 1, currency on row 2 full width */
  .ai-trade-header #learnChip { grid-column: 1 / 2; }
  .ai-trade-header #ai-universe{ grid-column: 2 / 3; }
  .ai-trade-header .currency-control{ grid-column: 1 / -1; justify-self: start; }

  /* Tighter chip padding on very small screens */
  .ai-trade-header .ai-chip{ padding:3px 7px; }
}

@media (max-width: 640px){
  .ai-filters .tip-icon{
    width:20px; height:20px;
    margin-left:6px;
  }
}

#wlChip { white-space: nowrap; }

/* --- MTF chip styling (compact, subtle) --- */
.ai-pill.pill-mtf{
  border:1px solid var(--edge); border-radius:8px; padding:4px 8px;
  background:rgba(255,255,255,.04); font-size:12px; color:var(--muted);
}

/* header win-rate spark */
#wlSpark{ vertical-align: middle; margin-left: 6px; opacity: 0.9; }

#wrChip canvas { display:inline-block; vertical-align:middle; }

/* Header grid: coin • meta • badge */
.ai-card .ai-card-head{
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px 12px;
  align-items: center;
  min-width: 0; /* critical for text truncation */
}

/* Prevent meta from pushing badge off */
.ai-card .ai-head-meta{
  min-width: 0; /* allow text to shrink + ellipsis */
}

/* FIRST LINE: ticker • nice name (link) */
.ai-card .ai-head-meta .ai-symbol a{
  --title-lines: 1;               /* default: single line on wide screens */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: var(--title-lines);
          line-clamp: var(--title-lines);
  font-weight: 600;
  letter-spacing: .2px;
  color: #e7f6ff;
  text-decoration: none;
  cursor: pointer;
  word-break: normal;
  overflow-wrap: normal;           /* keep tokens intact (BTC/USDT etc.) */
}
.ai-card .ai-head-meta .ai-symbol a:hover{
  text-decoration: none;
  color: #30cdfc;
  display: block;
}

/* SECOND LINE: compact market label */
.ai-card .ai-head-meta .ai-market{
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.25;
  opacity: .78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep badge aligned and non-wrapping */
.ai-card .ai-head-badge{
  white-space: nowrap;
}

/* Small screens: allow the title to use up to 2 lines, then ellipsis */
@media (max-width: 640px){
  .ai-card .ai-card-head{
    grid-template-columns: 34px 1fr auto;
    gap: 6px 10px;
  }
  .ai-card .ai-head-meta .ai-symbol a{
    --title-lines: 2;              /* clamp to two lines on mobile */
  }
}

/* Ultra-narrow cards: if your grid collapses to 1 column, tighten spacing */
@media (max-width: 420px){
  .ai-card .ai-card-head{ gap: 6px 8px; }
}

/* --- Improve symbol/title wrapping & spacing --- */
.ai-card-head {
  gap: 10px; /* keep some breathing room */
}

.ai-head-meta {
  min-width: 0; /* allow inner ellipsis */
}

.ai-head-meta .ai-symbol a {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* long tickers don't smash layout */
  vertical-align: bottom;
}

.ai-head-meta .ai-market {
  color: var(--ai-text-dim, #93a4b1);
  font-size: 12px;
  line-height: 1.25;
}

/* make the coin circle a bit tighter next to text */
.ai-coin { margin-right: 2px; }

/* === Calibration panel layout & look === */
#calibrationPanel,
.calib-wrap {
  border: 1px solid var(--edge);
  border-radius: 12px;
  width: 100%;
  display: block;
  /* ensure it sits on its own row, not crammed near the toolbar */
  margin: 12px 0 18px;
}

/* make the card itself full-width */
.calib-panel.card {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
}

/* header: title + meta on one line, wraps nicely on small screens */
.calib-panel .card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.calib-panel .card-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0;
}

.calib-panel .card-subtitle {
  font-size: 13px;
  opacity: .9;
}

/* body grid: single column on mobile, two columns on desktop */
.calib-panel .card-body {
  grid-template-columns: 1fr;
  gap: 12px;
}

.calib-bins {
  margin-top: 15px;
}

@media (min-width: 900px) {
  .calib-panel .card-body {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  /* put the line readout in the left column, bins (or note) on the right */
  .calib-panel .calib-line { order: 1; }
  .calib-panel .calib-ece { order: 1; }
}

/* ECE row: compact, readable badges */
.calib-panel .calib-ece {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 2px 0 6px;
}

.calib-panel .badge {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.calib-panel .badge.excellent { background:#e6ffed; color:#067d2b; }
.calib-panel .badge.good      { background:#eef7ff; color:#0b5cad; }
.calib-panel .badge.fair      { background:#fff7e6; color:#9a6b00; }
.calib-panel .badge.needs-work{ background:#ffecec; color:#b00020; }
.calib-panel .badge.ghost     { background:rgba(255,255,255,.08); color:inherit; }

/* calibration line: monospace pill, easy to scan */
.calib-panel .calib-line code {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

/* notes & empty-state message */
.calib-panel .ai-note { margin: 6px 0; }

/* table polish */
.calib-table {
  width: 100%;
  border-collapse: collapse;
}
.calib-table th,
.calib-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
  font-size: 13px;
}

/* ensure the panel isn’t influenced by the header’s internal flex */
.ai-trade-header + #calibrationPanel { margin-top: 10px; }

/* Auto toggle visuals */
.ai-switch .ai-slider {
  width: 40px; height: 22px;
  border-radius: 999px;
  display: inline-block; position: relative;
  background: rgba(255,255,255,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
  transition: background .2s, box-shadow .2s;
}
.ai-switch .ai-slider i {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 999px;
  background: #fff; display: block; transition: left .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.ai-switch.on .ai-slider {
  background: linear-gradient(180deg,#27c27a,#17a862);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.ai-switch.on .ai-slider i { left: 21px; }
.ai-explain { width: 100%; }
.ai-auto-toggle { margin-top: 7px; }

/* small chips + helpers remain */
.ai-hidden { display: none !important; }
.ai-disabled { opacity: .5; pointer-events: none; }

/* Tooltips show instantly, avoid transition delays */
.ai-tip[data-tip]:hover::after {
  transition: none !important;
  opacity: 1 !important;
}

.ai-chip.sl { 
    border: 1px solid rgba(255, 122, 0, .28);
    background: linear-gradient(180deg, rgba(29, 100, 43, .22), rgba(22, 100, 37, .06));
    color: orangered;
}

/* ---- Add-ons row (compact) ---- */
.ai-addons-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ai-addons-row .ai-chip.info {
  background: rgba(59,130,246,.15);
  color: #9ec5ff;
  border: 1px solid rgba(59,130,246,.35);
}

/* === Unified toggle (matches .switch tones & motion) === */
.ai-switch2{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  cursor: pointer;
  line-height: 1;
}
.ai-switch2 input{
  position:absolute; opacity:0; pointer-events:none;
}

/* track (same size/feel as .switch > i) */
.ai-switch2 .track{
  width:38px; height:22px; border-radius:999px;
  display:inline-block; position:relative;
  background: rgba(255,255,255,.10);
  border:1px solid var(--edge);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

/* thumb (same size/feel as .switch > i::after) */
.ai-switch2 .thumb{
  position:absolute; top:3px; left:3px;
  width:16px; height:16px; border-radius:50%;
  background: #9db0d1;               /* muted OFF color (same as filters) */
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: left .2s ease, background .2s ease, box-shadow .2s ease;
}

/* ON state (identical tones to .switch > input:checked + i / ::after) */
.ai-switch2 input:checked + .track{
  background: rgba(22,199,132,.25);
  border-color: rgba(22,199,132,.45);
}
.ai-switch2 input:checked + .track + .thumb{
  left: 19px;
  background: #16c784;
  box-shadow: 0 0 8px rgba(22,199,132,.5);
}

/* label + muted helper, same scale as filter labels */
.ai-switch2 .label{
  font-size: 12px;
  color: var(--muted);
}
.ai-switch2 .muted{
  font-size: 12px;
  color: rgba(255,255,255,.5);
}

/* Focus ring for accessibility (subtle, matches theme) */
.ai-switch2:focus-within .track{
  box-shadow: 0 0 0 3px rgba(96,165,250,.15);
}

/* Disabled visual */
.ai-switch2[data-disabled="1"],
.ai-switch2 input:disabled + .track + .thumb,
.ai-switch2 input:disabled + .track{
  opacity:.6; cursor:not-allowed;
}

/* Compact variant used by Precision Mode */
.ai-switch2.small .track{
  width:36px; height:20px;
}
.ai-switch2.small .thumb{
  width:16px; height:16px; top:2px; left:2px;
}
.ai-switch2.small input:checked + .track + .thumb{ left:18px; }

/* Add-ons pill shouldn’t be clickable */
.ai-addons-row .ai-chip.info{ pointer-events:none; }

.tpp {
  background: rgba(22, 199, 132, .12) !important;
  color: #16c784 !important;
  border: 1px solid rgba(22, 199, 132, .28) !important;
}

.sll {
  background: rgba(255, 122, 0, .12) !important;
  color: #ff7a00 !important;
  border: 1px solid rgba(255, 122, 0, .28) !important;
}

.ai-chip.toggle.active{
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(59, 130, 246, .15);
  color: #9ec5ff;
  border: 1px solid rgba(59, 130, 246, .35);
}

/* ⛳️ PATCH[ASKAI_BTN_AFFORDANCE] — optional polish */
#askAIModal .ai-btn.primary.ai-disabled { cursor: progress; }

/* ⛳️ PATCH[MOBILE_SAFE_AREA] — mobile breathing room */
@supports (padding: max(0px)){
  #ai-trade-app .ai-trade-content{
    padding-bottom: max(env(safe-area-inset-bottom), 64px);
  }
}
@media (min-width: 860px){
  #ai-trade-app .ai-trade-content{ padding-bottom: 0; }
}

/* ⛳️ PATCH[HEADER_RESP_TIDY] — keep header readable on phones */
@media (max-width: 640px){
  .ai-trade-header{ gap:8px; }
  .ai-toolbar{ gap:8px; }
  .currency-control .label{ display:none; }
}

/* ⛳ PATCH[MOBILE_TOOLBAR_WRAP_FIX] — wrap & contain long toolbar content on phones */
@media (max-width: 640px){
  .ai-trade-header .ai-toolbar{
    min-width: 0;              /* allow shrinking within row */
    width: 100%;
  }
  .ai-trade-header .ai-chip{
    white-space: normal !important;  /* allow wrapping inside the chip */
    overflow-wrap: anywhere;         /* break long tokens like “EV ≥ 0.30 · WLB ≥ 0.55 …” */
    max-width: 100%;
  }
}
/* ⛳ PATCH[CLIFF_STINGER] — quick neon sweep when cards appear */
.ai-card { position: relative; overflow: hidden; }
.ai-card.pop-in::after{
  content:"";
  position:absolute;
  top:0; left:-30%;
  width:30%; height:3px;
  background: linear-gradient(90deg, transparent, #60a5fa, transparent);
  filter: drop-shadow(0 0 8px rgba(96,165,250,.65));
  animation: ai-stinger 900ms cubic-bezier(.22,.61,.36,1) 1;
}
@keyframes ai-stinger {
  0%   { transform: translateX(0);    opacity:.9; }
  100% { transform: translateX(430%); opacity:0;  }
}

/* ⛳ PATCH[MOBILE_TOOLBAR_WRAP] */
@media (max-width: 640px){
  /* let the long precision pill wrap instead of overflowing */
  #tunerChip{ white-space: normal; line-height: 1.25; }
  /* prevent min-width constraints from pushing outside on narrow phones */
  .ai-trade-header .ai-toolbar{ min-width: 0; }
}
@media (max-width: 420px){
  /* stack toolbar items one-per-row on the narrowest phones */
  .ai-trade-header .ai-toolbar{
    display: grid;
    grid-template-columns: 1fr; /* was 1fr 1fr */
    gap: 8px 10px;
  }
}

/* ⛳ PATCH[SUSPENSE_ANIM] */
@keyframes cliffPulse {
  0% { box-shadow: 0 0 0 rgba(45,212,191,0); transform: translateZ(0); }
  50%{ box-shadow: 0 0 24px rgba(45,212,191,.35); }
  100%{ box-shadow: 0 0 0 rgba(45,212,191,0); }
}
.ai-chip.cliff{
  animation: cliffPulse 1.2s ease-in-out 1;
  will-change: box-shadow;
}

/* === LOGIN SPLASH (gates plugin behind login) === */
#ai-trade-app { position: relative; }

#ai-login-splash {
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 18, 0.92);
  backdrop-filter: blur(2px) saturate(1.05);
}

#ai-login-splash .ai-splash-card {
  max-width: 520px;
  margin: 0 16px;
  padding: 28px 24px;
  border-radius: 18px;
  background: #0f1720;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  color: #e7eef9;
  text-align: center;
}

#ai-login-splash .ai-splash-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

#ai-login-splash .ai-splash-copy {
  opacity: 0.9;
  margin: 0 0 16px 0;
}

#ai-login-splash .ai-splash-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#ai-login-splash .ai-btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  background: #192231;
  color: #cfe1ff;
  border: 1px solid rgba(255,255,255,0.08);
}
#ai-login-splash .ai-btn.primary {
  background: #2563eb;
  color: #fff;
  border: none;
}

/* Dim/disable underlying UI while gated */
.ai-trade-container.ai-gated .ai-trade-content {
  filter: blur(1.5px) saturate(0.85);
  pointer-events: none;
  user-select: none;
}

/* === ANCHOR[TIPSTER_CSS_V1] === */
.ai-tipster .ai-row { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:.5rem; }
.ai-tipster .ai-input, .ai-tipster .ai-select { padding:.5rem .6rem; border:1px solid var(--ai-border,#333); border-radius:.5rem; background:var(--ai-bg,#111); color:inherit; }
.ai-trade { border:1px solid var(--ai-border,#333); border-radius:.75rem; padding:.75rem; background:rgba(255,255,255,0.02); }
.ai-trade-head { display:flex; gap:.5rem; align-items:center; margin-bottom:.5rem; }
.ai-sym { font-weight:700; letter-spacing:.3px; }
.ai-badge { font-size:.8rem; padding:.15rem .4rem; border-radius:.4rem; border:1px solid var(--ai-border,#333); opacity:.9; }
.ai-badge.ai-up { border-color:#1f7a1f; }
.ai-badge.ai-dn { border-color:#7a1f1f; }
@media (max-width: 640px){ .ai-grid{ grid-template-columns: repeat(2,minmax(0,1fr)); } }
.ai-btn.ai-copy { margin-top:.5rem; }

/* PATCH[TIPSTER_TITLE_WRAP_FIX] */
.ai-card.ai-tipster .ai-card-head{ flex-wrap: wrap; gap: 8px; }
.ai-card.ai-tipster .ai-card-head .ai-title{ white-space: nowrap; font-weight: 700; }
.ai-card.ai-tipster .ai-card-head .ai-sub{ opacity: .8; }

/* already in your stack, shown here for reference only */
.ai-pill.bull { color: var(--bull); border-color: var(--bull); background: color-mix(in srgb, var(--bull) 14%, transparent); }
.ai-pill.bear { color: var(--bear); border-color: var(--bear); background: color-mix(in srgb, var(--bear) 14%, transparent); }

/* ⛳ PATCH[TIPSTER_CHIPS_CSS] — make popular tickers look like your pills */
.tip-popular, #tipPopular { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.tip-popular .ai-chip, #tipPopular .ai-chip { cursor:pointer; }
.tip-popular .ai-chip:hover, #tipPopular .ai-chip:hover { filter:brightness(1.1); }

