:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #171d2b;
  --line: #232b3d;
  --text: #e6e9f0;
  --muted: #8a93a6;
  --accent: #5b8cff;
  --bull: #16c784;
  --bear: #ea3943;
  --neut: #f0b90b;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#price, .sc-prob, .sc dd, .coin-list .px, .coin-list .ch, .stat strong { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: rgba(11,14,20,.9); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.header-row { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; }
.brand-mark { width: 32px; height: 32px; display: block; flex: none; }
.brand-name b { color: var(--accent); font-weight: 700; }
.tagline { color: var(--muted); margin: 0; font-size: 14px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); white-space: nowrap; }
.live-pill .dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background-color 200ms var(--ease-out); }
.live-pill .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--bull); opacity: 0; }
.live-pill.on .dot { background: var(--bull); }
.live-pill.on .dot::after { animation: ping 2s var(--ease-out) infinite; }
.live-pill.on { color: var(--text); }
@keyframes ping { 0% { transform: scale(1); opacity: .6; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

/* ticker */
.ticker { border-bottom: 1px solid var(--line); overflow: hidden; background: var(--panel); }
.ticker-track { display: flex; gap: 28px; padding: 8px 0; width: max-content; animation: scroll 120s linear infinite; font-size: 13px; }
.ticker-item { display: flex; gap: 8px; cursor: pointer; white-space: nowrap; font-family: var(--mono); }
.ticker-item b { font-family: Inter, sans-serif; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } }

/* layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 16px; align-items: start; padding-top: 8px; }
.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-title { font-size: 16px; }

/* coin list */
.coins { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; overflow: hidden; }
.coins-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.coins-head h2 { font-size: 15px; }
input[type=search] { width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
input[type=search]:focus, .coin-select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.coin-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.coin-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background-color 150ms var(--ease-out); }
.coin-list li.active { background: rgba(91,140,255,.14); }
.coin-list .sym { font-weight: 600; font-size: 14px; }
.coin-list .nm { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-list .px { font-family: var(--mono); font-size: 13px; text-align: right; }
.coin-list .ch { font-family: var(--mono); font-size: 12px; text-align: right; }
.up { color: var(--bull); } .down { color: var(--bear); }

/* asset header */
.asset { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.coin-select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-weight: 600; font-size: 16px; max-width: 260px; }
.asset-price { display: flex; align-items: baseline; gap: 10px; }
#price { font-family: var(--mono); font-size: 24px; font-weight: 500; transition: color .3s; }
#price.flash-up { color: var(--bull); } #price.flash-down { color: var(--bear); }
.chg { font-family: var(--mono); font-size: 14px; }
.intervals, .exchanges { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.intervals button, .exchanges button { background: transparent; border: 0; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.intervals button:active, .exchanges button:active, .btn:active, .coin-list li:active { transform: scale(0.97); }
.intervals button.active, .exchanges button.active { background: var(--accent); color: #fff; }

/* chart */
.chart-box { position: relative; height: 480px; }
.chart { position: absolute; inset: 0; }
.chart-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(18,23,34,.75); color: var(--muted); font-size: 14px; z-index: 5; text-align: center; padding: 16px; }
.chart-loading { transition: opacity 200ms var(--ease-out); }
.chart-loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.legend input { accent-color: var(--accent); }
.sw { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.bull { background: var(--bull); } .sw.neut { background: var(--neut); } .sw.bear { background: var(--bear); } .sw.med { background: #9aa6c0; }
.legend .meta { margin-left: auto; }

/* scenario cards */
.scenarios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.sc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out), border-color 200ms var(--ease-out); }
@starting-style { .sc { opacity: 0; transform: translateY(6px); } }
.sc:nth-child(2) { transition-delay: 40ms; } .sc:nth-child(3) { transition-delay: 80ms; }
.sc::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.sc.bullish { --c: var(--bull); } .sc.neutral { --c: var(--neut); } .sc.bearish { --c: var(--bear); }
.sc.dominant { border-color: var(--c); }
.sc-top { display: flex; justify-content: space-between; align-items: baseline; }
.sc-name { font-weight: 600; }
.sc-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c); }
.sc-prob { font-family: var(--mono); font-size: 32px; font-weight: 500; color: var(--c); margin: 6px 0 2px; }
.sc-bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.sc-bar span { display: block; height: 100%; background: var(--c); border-radius: 3px; transform-origin: left center; transition: transform 500ms var(--ease-out); }
@starting-style { .sc-bar span { transform: scaleX(0); } }
.sc dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.sc dt { color: var(--muted); white-space: nowrap; }
.sc dd { margin: 0; text-align: right; font-family: var(--mono); white-space: nowrap; }
.sc dl { font-size: 12.5px; }
.sc.skeleton { min-height: 170px; animation: breathe 1.4s var(--ease-in-out) infinite alternate; }
@keyframes breathe { from { opacity: .45; } to { opacity: 1; } }

.status-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 400ms var(--ease-out); }
.stat strong.fresh { color: var(--bull); transition-duration: 0ms; }

.tv-chart { height: 520px; border-radius: 8px; overflow: hidden; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.explain-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 12px; }
.explain h3 { font-size: 14px; margin-bottom: 4px; }
.explain p { color: var(--muted); font-size: 13px; margin: 0; }

/* ads */
.ad-slot { display: flex; align-items: center; justify-content: center; margin: 12px auto; overflow: hidden; }
.ad-slot ins { display: block; width: 100%; }
.ad-top, .ad-footer { max-width: 728px; min-height: 90px; }
.ad-incontent { width: 100%; min-height: 100px; margin: 0; }
.side-ads { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; }
.ad-side { width: 300px; min-height: 250px; margin: 0; }
.ad-side-tall { width: 300px; min-height: 600px; margin: 0; }
.ad-house { width: 100%; height: 100%; min-height: inherit; border: 1px dashed var(--line); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.015) 10px 20px); text-align: center; padding: 8px; }
.ad-house strong { color: var(--text); font-size: 13px; }
.ad-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* footer & cookie */
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
.disclaimer { max-width: 900px; }
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 720px; margin: 0 auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; gap: 16px; align-items: center; z-index: 50; box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: 13px; }
.cookie { transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out); }
@starting-style { .cookie { opacity: 0; transform: translateY(12px); } }
.cookie[hidden] { display: none; }
.cookie p { margin: 0; flex: 1; }
.cookie-actions { display: flex; gap: 8px; }
.btn { background: var(--accent); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color 150ms var(--ease-out), transform 120ms var(--ease-out); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }

.page .prose { max-width: 760px; padding-top: 32px; padding-bottom: 48px; }
.prose h1 { margin: 16px 0; } .prose h2 { margin: 24px 0 8px; font-size: 18px; } .prose p, .prose li { color: #c4c9d4; }

/* responsive */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .side-ads { grid-column: 1 / -1; position: static; flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .ad-side-tall { min-height: 250px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .coins { display: none; }
  .scenarios { grid-template-columns: 1fr; }
  .status-row { grid-template-columns: repeat(2, 1fr); }
  .explain-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-box { height: 380px; }
  .tv-chart { height: 420px; }
  .tagline { display: none; }
  .header-row { justify-content: space-between; }
  .ad-top, .ad-footer { min-height: 60px; }
}
@media (min-width: 901px) { .coin-select { display: none; } }
@media (max-width: 520px) {
  .explain-grid { grid-template-columns: 1fr; }
  .cookie { flex-direction: column; align-items: stretch; }
  .legend .meta { margin-left: 0; width: 100%; }
  #price { font-size: 20px; }
  .ad-side, .ad-side-tall { width: 100%; }
}

/* hover solo su dispositivi con puntatore preciso */
@media (hover: hover) and (pointer: fine) {
  .coin-list li:hover { background: var(--panel-2); }
  .intervals button:hover, .exchanges button:hover { color: var(--text); }
  .intervals button.active:hover, .exchanges button.active:hover { color: #fff; }
  .btn:hover { background: #6f9bff; }
  .btn.ghost:hover { background: var(--panel); }
  .ticker:hover .ticker-track { animation-play-state: paused; }
  .ticker-item:hover b { color: var(--accent); }
}
/* movimento ridotto: niente spostamenti, restano le dissolvenze */
@media (prefers-reduced-motion: reduce) {
  .live-pill.on .dot::after, .sc.skeleton { animation: none; }
  .sc, .cookie { transition-property: opacity, border-color; }
  @starting-style { .sc, .cookie { transform: none; } }
  .sc-bar span { transition: none; }
  .intervals button:active, .exchanges button:active, .btn:active, .coin-list li:active { transform: none; }
}
