:root {
  --bg: #131722;
  --panel: #1E222D;
  --panel-2: #191D28;
  --hover: #2A2E39;
  --hover-2: #363A45;
  --border: #2A2E39;
  --text: #D1D4DC;
  --text-strong: #F0F3FA;
  --muted: #787B86;
  --accent: #2962FF;
  --accent-hover: #1E53E5;
  --up: #089981;
  --down: #F23645;
  --warn: #FF9800;
  --frame: 4px; /* spessore delle separazioni grigie tra i pannelli, come su TradingView */
  --font: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); }
body { overflow: hidden; }
/* niente zoom della pagina col pizzico o il doppio tocco (lo scorrimento resta) */
html, body { touch-action: pan-x pan-y; }
a { color: #5B8DEF; }
.hidden { display: none !important; }
/* l'attributo hidden deve vincere anche su regole come .form-grid { display: grid } */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.up { color: var(--up); font-style: normal; }
.down { color: var(--down); font-style: normal; }
.spacer { flex: 1; }
.grow { flex: 1; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
input[type=date], input[type=time], input[type=datetime-local] { color-scheme: dark; }
input[type=datetime-local]::-webkit-calendar-picker-indicator { cursor: pointer; }
input[type=color] { padding: 0; width: 26px; height: 22px; border: none; background: none; cursor: pointer; }
/* colori con opacità (data-alpha): il riquadro mostra la trasparenza su una scacchiera */
input[type=color][data-alpha]::-webkit-color-swatch-wrapper { background: repeating-conic-gradient(#888 0 25%, #ddd 0 50%) 0 0 / 8px 8px; padding: 0; margin: 3px 2px; border-radius: 3px; }
input[type=color][data-alpha]::-webkit-color-swatch { opacity: var(--cp-a, 1); border-radius: 3px; }
input[type=color][data-alpha]::-moz-color-swatch { opacity: var(--cp-a, 1); }

/* --------- pulsanti --------- */
.btn { background: var(--hover); border: 1px solid transparent; border-radius: 4px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover-2); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--down); color: var(--down); }
.btn.danger:hover { background: rgba(242,54,69,.12); }
.btn.link { background: none; color: #5B8DEF; padding: 4px; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 2px 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }

/* --------- logo --------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-strong); padding: 0 6px; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 4px; }
.logo { width: 22px; height: 22px; background: url("../assets/logo.svg") center/contain no-repeat; flex: none; }
.brand.big .logo { width: 30px; height: 30px; }

/* --------- login --------- */
.auth { position: fixed; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: radial-gradient(1200px 600px at 50% -10%, #1c2440 0%, var(--bg) 60%); }
.auth-card { width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.auth-card p { margin: 0 0 4px; text-align: center; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.auth-card input { padding: 9px 10px; }
.auth-error { color: var(--down); min-height: 1em; font-size: 12px; }

/* --------- layout --------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { height: 46px; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: var(--frame) solid var(--border); background: var(--bg); flex: none; }
.tb-btn { background: none; border: none; border-radius: 4px; padding: 6px 9px; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; gap: 6px; position: relative; white-space: nowrap; }
.tb-btn:hover { background: var(--hover); }
.tb-btn.icon { padding: 6px 8px; }
.tb-btn .fx { font-style: italic; font-family: Georgia, serif; }
.symbol-btn { font-weight: 700; color: var(--text-strong); flex: none; }
.symbol-btn::before { content: "⌕"; font-weight: 400; color: var(--muted); font-size: 15px; }
#symbolLabel { display: inline-flex; align-items: center; gap: 6px; }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.tb-select { background: none; border: none; cursor: pointer; padding: 6px; }
.tb-select:hover { background: var(--hover); }
.tb-select option { background: var(--panel); }
.tf-group { display: flex; gap: 1px; }
.tf-group button { background: none; border: none; color: var(--text); padding: 6px 7px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.tf-group button:hover { background: var(--hover); }
.tf-group button.active { color: #5B8DEF; font-weight: 600; }
.tf-group button:disabled { opacity: 0.35; cursor: default; background: none; }
.badge { position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; border-radius: 8px; background: var(--down); color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin: 0 8px; }
.status-dot.live { background: var(--up); box-shadow: 0 0 0 3px rgba(8,153,129,.2); }
.status-dot.error { background: var(--down); }

.main { flex: 1; display: flex; min-height: 0; }
.toolbar-left { width: 44px; flex: none; border-right: var(--frame) solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; }
/* su schermi bassi gli strumenti scorrono invece di finire fuori dallo schermo */
.toolbar-left { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.toolbar-left::-webkit-scrollbar { display: none; }
.toolbar-left > * { flex-shrink: 0; }
.toolbar-left button { width: 37px; height: 34px; border: none; background: none; border-radius: 4px; cursor: pointer; font-size: 15px; color: var(--text); display: grid; place-items: center; padding: 0; }
.toolbar-left svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.toolbar-left .tg { position: relative; }
.toolbar-left .tg.active .tg-main { color: #5B8DEF; background: rgba(41,98,255,.12); }
.toolbar-left .tg-more { position: absolute; right: -2px; bottom: 0; width: 10px; height: 12px; border-radius: 2px; }
.toolbar-left .tg-more::after { content: ""; position: absolute; right: 3px; bottom: 3px; border: 3px solid transparent; border-right-color: var(--muted); border-bottom-color: var(--muted); }
.toolbar-left .tg .tg-more { opacity: .55; }
.toolbar-left .tg:hover .tg-more, .toolbar-left .tg-more:hover { opacity: 1; }
.tl-sep { width: 26px; height: 1px; background: var(--border); margin: 4px 0; }
.tool-flyout { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px; min-width: 230px; max-height: 80vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.tool-flyout .tf-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 10px 4px; }
.tool-flyout button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.tool-flyout button:hover { background: var(--hover); }
.tool-flyout button.active { color: #5B8DEF; }
.price-plus { position: absolute; z-index: 4; width: 18px; height: 18px; padding: 0; line-height: 16px; font-size: 15px; text-align: center; border-radius: 3px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; }
.price-plus:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar-left button:hover { background: var(--hover); }
.toolbar-left button.active { color: #5B8DEF; background: rgba(41,98,255,.12); }
.toolbar-left input[type=color] { margin: 6px 0; }

.center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chart-wrap { flex: 1; position: relative; min-height: 120px; }
.chart { position: absolute; inset: 0; }
.chart.pane-max table { height: auto !important; } /* pannello ingrandito: fitMaxPane() in chart.js */
/* mirino sui pannelli come su TradingView; le scale di prezzo e tempo hanno il loro cursore in linea */
.chart table, .chart.drawing-mode { cursor: crosshair; }
.chart[data-hover=move] *, .chart[data-hover=pointer] * { cursor: pointer !important; }
.chart[data-hover=handle] * { cursor: crosshair !important; }
.chart[data-hover=grabbing] * { cursor: grabbing !important; }
.chart[data-hover=alert] * { cursor: ns-resize !important; }
.sel-toolbar { position: absolute; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.35); white-space: nowrap; }
.sel-toolbar .sb-name { font-size: 12px; color: var(--text-strong); padding: 0 6px 0 2px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.sel-toolbar button { background: none; border: none; color: var(--text); cursor: pointer; padding: 3px 7px; border-radius: 4px; font-size: 12px; }
.sel-toolbar button:hover { background: var(--hover); }
.sel-toolbar button.on { color: #5B8DEF; }
.sel-toolbar select { padding: 2px 4px; font-size: 12px; }
.chart-msg.loading { top: 50%; background: none; border: 0; padding: 0; pointer-events: none; }
.av-loader { position: relative; width: 52px; height: 52px; }
.av-loader i { position: absolute; inset: 0; border-radius: 50%; animation: av-spin .9s linear infinite;
  background: conic-gradient(from 0deg, transparent 0, var(--accent) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); }
.av-loader::after { content: ""; position: absolute; left: 50%; top: -1px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px 2px var(--accent); animation: av-spin .9s linear infinite; transform-origin: 50% 27px; }
@keyframes av-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .av-loader i, .av-loader::after { animation-duration: 4s; } }
.chart-msg { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--panel); border: 1px solid var(--border); padding: 14px 18px; border-radius: 8px; max-width: 460px; text-align: center; z-index: 5; }
.resizer { height: var(--frame); cursor: row-resize; touch-action: none; background: var(--border); flex: none; }
.resizer:hover, .resizer.drag { background: var(--accent); }
.bottom { height: 300px; flex: none; display: flex; flex-direction: column; background: var(--bg); min-height: 34px; }
.bottom.collapsed { height: 34px !important; }
.bottom.collapsed .tab-body { display: none !important; }
.tabs { height: 34px; flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--border); padding: 0 4px; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 0 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-strong); border-bottom-color: var(--accent); }
.tab-body { display: none; flex: 1; min-height: 0; }
.tab-body.active { display: flex; flex-direction: column; }

.right { width: 270px; flex: none; border-left: var(--frame) solid var(--border); display: flex; flex-direction: column; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); min-height: 38px; }
.footer { height: 24px; flex: none; display: flex; align-items: center; padding: 0 10px; border-top: var(--frame) solid var(--border); font-size: 11px; gap: 10px; }

/* --------- watchlist --------- */
.wl-header, .wl-row { display: grid; grid-template-columns: 1fr auto 62px; gap: 8px; padding: 4px 10px; align-items: center; }
.wl-header { font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }
.wl-header span:not(:first-child), .wl-row span:not(:first-child) { text-align: right; }
.watchlist { overflow-y: auto; flex: 1; }
/* scrollbar del pannello di destra e di quello in basso (Pine editor compreso): niente frecce, sfondo trasparente,
   stessa distanza dal bordo ai due capi */
:is(#rightPanel, #bottom) *::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-track { background: transparent; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-track:vertical { margin: 6px 0; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-track:horizontal { margin: 0 6px; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-corner { background: transparent; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-thumb { background: var(--hover-2); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
:is(#rightPanel, #bottom) *::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }
/* CodeMirror disegna le barre in elementi suoi, con lo sfondo bianco di sistema: trasparenti anche quelli */
:is(#rightPanel, #bottom) :is(.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler) { background: transparent; }
.wl-row { cursor: pointer; padding-top: 6px; padding-bottom: 6px; position: relative; }
.wl-row { border-bottom: 1px solid var(--border); }
.wl-row:hover { background: var(--hover); }
.wl-row.active { background: rgba(41,98,255,.12); }
.wl-row .sym { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row .sym small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; }
.wl-row .rm { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: none; background: var(--panel); border: none; color: var(--muted); cursor: pointer; border-radius: 3px; }
.wl-row:hover .rm { display: block; }
.wl-row .num { font-variant-numeric: tabular-nums; }
.wl-row .sym .coin, .wd-sym .coin, #ssRes .s .coin { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; }
.wl-row .sym .coin-fb, .wd-sym .coin-fb, #ssRes .s .coin-fb { font-size: 9px; line-height: 16px; }

/* --------- legenda e tabelle sul grafico --------- */
.legend { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.legend-pane { position: absolute; left: 8px; top: 4px; max-width: calc(100% - 90px); }
.legend-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 7px; font-size: 14px; min-height: 26px; white-space: nowrap; }
.legend-symbol { font-size: 16px; color: var(--text-strong); }
.legend-symbol b { font-weight: 600; }
/* icone delle crypto (coins.js): la moneta e, piccola in basso a destra, quella di quotazione */
.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none; vertical-align: middle; object-fit: contain; }
.coin-fb { color: #fff; font: 700 10px/18px -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, sans-serif; text-align: center; }
.coin-pair { position: relative; display: inline-flex; width: 23px; height: 20px; margin-right: 1px; }
.coin-pair > .coin:first-child { position: relative; z-index: 1; }
.coin-pair .coin-quote { position: absolute; left: 11px; top: 8px; width: 12px; height: 12px; font-size: 7px; line-height: 12px; box-shadow: 0 0 0 1.5px var(--bg, #131722); z-index: 2; }
.ohlc { display: inline-flex; flex-wrap: wrap; gap: 0 8px; margin-left: 6px; color: var(--muted); font-size: 13.5px; }
.ohlc i { font-style: normal; font-variant-numeric: tabular-nums; }
.legend-script { font-size: 13px; pointer-events: auto; padding: 1px 4px; margin-left: -4px; border-radius: 3px; border: 1px solid transparent; width: fit-content; }
.legend-script:hover { background: color-mix(in srgb, var(--bg) 85%, transparent); border-color: var(--border); }
.legend-script .lname { color: var(--text); }
.legend-script .lvals { display: inline-flex; flex-wrap: wrap; }
.legend-script .lvals i { font-style: normal; font-variant-numeric: tabular-nums; margin-right: 4px; }
.legend-script .lbtns { display: none; gap: 1px; }
.legend-script:hover .lbtns { display: inline-flex; }
.legend-script .lbtns button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 6px; font-size: 14px; line-height: 22px; min-width: 24px; border-radius: 3px; }
.legend-script .lbtns button:hover { background: var(--hover); color: var(--text); }
.legend-script.has-error .lbtns [data-act="reload"] { color: var(--text); }
button.spinning { animation: spin 0.8s linear infinite; cursor: progress; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend-script { cursor: pointer; }
.legend-script.selected { background: rgba(41,98,255,.14); border-color: rgba(41,98,255,.5); }
.legend-script.is-hidden .lname, .legend-script.is-hidden .lvals { opacity: .45; }
.legend-script .lerr { color: var(--down); font-size: 11px; }
/* calcolo in corso (chart.setPending): piccolo cerchio che gira accanto al nome */
.legend-script .lload { display: inline-block; width: 10px; height: 10px; margin-left: 6px; vertical-align: -1px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
.pine-tables { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
/* marchio sul grafico (chart.placeMark): bianco con il bordo scuro come il logo di TradingView, al contrario
   sugli sfondi chiari; il bordo è in px qualunque sia la grandezza (non-scaling-stroke) */
.chart-mark { position: absolute; z-index: 1; width: 34px; height: 45px; pointer-events: none; opacity: .6; }
.chart-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-mark path { fill: #FFFFFF; stroke: #131722; stroke-width: 2px; stroke-linejoin: round; paint-order: stroke; vector-effect: non-scaling-stroke; }
.chart-mark.light path { fill: #131722; stroke: #FFFFFF; }
.pine-table { border-collapse: collapse; font-size: 12px; pointer-events: auto; }
.pine-table td { padding: 3px 8px; }

/* --------- editor --------- */
.ed-toolbar { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ed-name { width: 240px; background: transparent; border-color: transparent; font-weight: 600; color: var(--text-strong); }
.ed-name:hover { border-color: var(--border); }
.ed-dirty { color: var(--warn); font-size: 14px; }
.ed-main { flex: 1; min-height: 0; position: relative; }
.editor, .editor .CodeMirror { position: absolute; inset: 0; height: 100%; }
.ed-console { flex: none; position: relative; display: flex; flex-direction: column; height: var(--con-h, 110px); min-height: 28px; max-height: 70%; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 12px; background: var(--panel-2); }
.ed-console.collapsed { height: auto !important; }
.ed-console.collapsed .ed-con-body, .ed-console.collapsed .ed-con-resize { display: none; }
.ed-console.collapsed .ed-con-caret { transform: rotate(-90deg); }
.ed-con-resize { position: absolute; left: 0; right: 0; top: -4px; height: 7px; cursor: ns-resize; z-index: 6; touch-action: none; }
.ed-con-resize:hover, .ed-con-resize.drag { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.ed-con-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 2px 6px 2px 4px; border-bottom: 1px solid var(--border); font-family: var(--font); font-size: 11px; min-height: 26px; }
.ed-console.collapsed .ed-con-head { border-bottom: 0; }
.ed-con-title { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 4px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.ed-con-caret { display: inline-block; transition: transform .12s; color: var(--muted); }
.ed-con-stats { display: flex; gap: 8px; color: var(--muted); }
.ed-con-stats b { font-weight: 600; }
.ed-con-stats .err { color: var(--down); }
.ed-con-stats .warn { color: var(--warn); }
.ed-con-stats .ok { color: var(--up); }
.ed-con-btn { background: none; border: 1px solid transparent; border-radius: 4px; color: var(--muted); font: inherit; padding: 2px 7px; cursor: pointer; }
.ed-con-btn:hover { color: var(--text); background: var(--hover); }
.ed-con-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 0 6px; overscroll-behavior: contain; }
#edConMsg > span.muted { display: block; padding: 0 10px; }
.ed-con-body.has-logs > #edConMsg { position: sticky; top: -4px; z-index: 1; background: var(--panel-2); padding-top: 4px; margin-top: -4px; max-height: 50%; overflow: auto; }
.ed-console .err { color: var(--down); }
.ed-console .ok { color: var(--up); }
.ed-console .warn { color: var(--warn); }
.ed-con-row { display: grid; grid-template-columns: 16px 1fr auto; gap: 6px; align-items: start; padding: 2px 10px; white-space: pre-wrap; word-break: break-word; }
.ed-con-row:hover { background: var(--hover); }
.ed-con-row.clickable { cursor: pointer; }
.ed-con-row .ic { text-align: center; }
.ed-con-row .msg { color: var(--text); }
.ed-con-row.err .msg { color: color-mix(in srgb, var(--down) 70%, var(--text)); }
.ed-con-row.warn .msg { color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.ed-con-line { background: var(--hover); border: 1px solid var(--border); border-radius: 4px; color: var(--accent); font: inherit; font-size: 11px; padding: 0 6px; cursor: pointer; white-space: nowrap; }
.ed-con-line:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-con-line.guess { color: var(--muted); border-style: dashed; }
.ed-con-snip { margin: 2px 10px 4px 32px; padding: 4px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow-x: auto; white-space: pre; color: var(--text); line-height: 1.45; }
.ed-con-snip .ln { color: var(--muted); user-select: none; }
.ed-con-snip .hl { background: rgba(242,54,69,.14); display: inline-block; min-width: 100%; }
.ed-con-snip .caret { color: var(--down); font-weight: 700; }
.ed-con-meta { padding: 1px 10px 1px 32px; color: var(--muted); font-family: var(--font); font-size: 11px; }

.CodeMirror.cm-s-anubiview, .editor .CodeMirror { background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.cm-s-anubiview .CodeMirror-gutters { background: var(--bg); border-right: 1px solid var(--border); }
.cm-s-anubiview .CodeMirror-linenumber { color: color-mix(in srgb, var(--muted) 70%, var(--bg)); }
.cm-s-anubiview .CodeMirror-cursor { border-left: 2px solid #5B8DEF; }
.cm-s-anubiview .CodeMirror-activeline-background { background: var(--panel-2); }
.cm-s-anubiview .CodeMirror-selected, .cm-s-anubiview.CodeMirror-focused .CodeMirror-selected { background: #264F78 !important; }
.cm-s-anubiview .CodeMirror-matchingbracket { color: var(--text-strong) !important; background: var(--hover-2); }
.cm-s-anubiview .cm-comment { color: #6A9955; font-style: italic; }
.cm-s-anubiview .cm-meta { color: #6A9955; }
.cm-s-anubiview .cm-string { color: #CE9178; }
.cm-s-anubiview .cm-number { color: #B5CEA8; }
.cm-s-anubiview .cm-keyword { color: #C586C0; }
.cm-s-anubiview .cm-atom { color: #569CD6; }
.cm-s-anubiview .cm-type { color: #4EC9B0; }
.cm-s-anubiview .cm-builtin { color: #4FC1FF; }
.cm-s-anubiview .cm-def { color: #DCDCAA; }
.cm-s-anubiview .cm-variable-2 { color: #9CDCFE; }
.cm-s-anubiview .cm-operator { color: #D4D4D4; }
.cm-error-line { background: rgba(242,54,69,.18); }
.CodeMirror-hints { background: var(--panel); border: 1px solid var(--border); font-family: var(--mono); font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 100; }
.CodeMirror-hint { color: var(--text); padding: 2px 8px; }
li.CodeMirror-hint-active { background: var(--accent); color: #fff; }

/* --------- strategy tester --------- */
.tester { flex: 1; overflow: auto; padding: 10px 12px; }
.tester .empty, .empty { color: var(--muted); padding: 20px; text-align: center; }
.tester-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tester-head h3 { margin: 0; font-size: 14px; color: var(--text-strong); }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; margin-bottom: 8px; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; }
.metric .k { font-size: 11px; color: var(--muted); }
.metric .v { font-size: 15px; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.metric .s { font-size: 11px; }
.tester-grid { display: grid; grid-template-columns: minmax(300px, 1.2fr) minmax(300px, 1fr); gap: 10px; }
.equity-box { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px; height: 220px; position: relative; }
.equity-box .eq-chart { position: absolute; inset: 26px 6px 6px 6px; }
.equity-box .eq-title { font-size: 11px; color: var(--muted); padding: 2px 4px; display: flex; gap: 12px; }
.trades-box { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; overflow: auto; max-height: 260px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data td { text-align: right; padding: 5px 8px; border-bottom: 1px solid #23272F; }
table.data th:first-child, table.data td:first-child, table.data td.l, table.data th.l { text-align: left; }
table.data tr:hover td { background: var(--hover); cursor: pointer; }

/* --------- alert --------- */
.alerts-pane { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; min-height: 0; }
.alerts-list, .alerts-log { display: flex; flex-direction: column; min-height: 0; }
.alerts-list { border-right: 1px solid var(--border); }
#alertsList, #eventsList { overflow: auto; flex: 1; }
.alert-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid #23272F; }
.alert-row .t { font-weight: 600; color: var(--text-strong); }
.alert-row .meta { font-size: 11px; color: var(--muted); }
.alert-row .meta .e { color: var(--down); }
.switch { position: relative; width: 32px; height: 18px; background: var(--hover-2); border-radius: 9px; cursor: pointer; border: none; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 16px; }
.event-row { padding: 7px 10px; border-bottom: 1px solid #23272F; }
.event-row .t { font-weight: 600; }
.event-row .m { color: var(--text); }
.event-row .d { font-size: 11px; color: var(--muted); }
.event-row.unseen { border-left: 2px solid var(--accent); }

/* --------- modali --------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; width: min(560px, 94vw); max-height: 86vh; max-height: 86dvh; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal.wide { width: min(820px, 96vw); }
.modal-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; color: var(--text-strong); }
.modal-head .x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 170px 1fr; gap: 10px 12px; align-items: center; }
.form-grid > label { color: var(--muted); font-size: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .group-title { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg button { background: none; border: none; padding: 5px 10px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--hover); color: var(--text-strong); }
.help { font-size: 12px; color: var(--muted); }
.code-inline { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 3px; }

/* ricerca simboli / libreria */
.search-input { width: 100%; padding: 10px 12px; font-size: 14px; }
.filter-row { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.filter-row .ss-src { margin-left: auto; max-width: 190px; }
.chip { background: var(--hover); border: none; border-radius: 14px; padding: 4px 12px; cursor: pointer; color: var(--text); font-size: 12px; }
.chip.active { background: var(--accent); color: #fff; }
.results { min-height: 200px; max-height: 52vh; overflow: auto; margin: 0 -16px; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 16px; cursor: pointer; align-items: center; border-bottom: 1px solid #23272F; }
.result:hover, .result.sel { background: var(--hover); }
.result .s { font-weight: 600; color: var(--text-strong); }
.result .n { color: var(--muted); font-size: 12px; }
.result .b { font-size: 11px; color: var(--muted); text-align: right; }
.tag { display: inline-block; font-size: 10px; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; background: var(--hover); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.tag.strategy { background: rgba(224,64,251,.15); color: #E040FB; }
.tag.indicator { background: rgba(41,98,255,.15); color: #5B8DEF; }
.tag.shared { background: rgba(8,153,129,.15); color: var(--up); }
.lib-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 16px; border-bottom: 1px solid #23272F; align-items: center; }
.lib-item:hover { background: var(--panel-2); }
.lib-item .s { font-weight: 600; color: var(--text-strong); }
.lib-item .d { font-size: 12px; color: var(--muted); }
.lib-item .acts { display: flex; gap: 4px; }

/* menu a tendina */
.menu { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px 0; min-width: 200px; z-index: 60; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 14px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.menu button:disabled { opacity: .4; cursor: default; background: none; }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.menu .label { padding: 6px 14px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; }

/* notifiche toast */
.toasts { position: fixed; right: 16px; bottom: 36px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; min-width: 260px; max-width: 380px; box-shadow: 0 12px 32px rgba(0,0,0,.45); animation: tin .2s ease-out; }
.toast.error { border-left-color: var(--down); }
.toast.busy { border-left-color: var(--accent); }
.toast.busy .busy-spin { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; vertical-align: -1px; animation: busyspin .8s linear infinite; }
.toast.busy .busy-dots { display: inline-block; min-width: 1.4em; }
.toast.busy .busy-msg { margin-top: 2px; color: var(--text); }
.toast.busy .busy-sub { margin-top: 4px; font-size: 11px; }
@keyframes busyspin { to { transform: rotate(360deg); } }
.toast.ok { border-left-color: var(--up); }
.toast .t { font-weight: 600; color: var(--text-strong); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }
/* nuova versione dell'app disponibile */
.update-bar { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 90; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 10px 8px 14px; box-shadow: 0 12px 32px rgba(0,0,0,.45); animation: tin .2s ease-out; }
.update-bar span { color: var(--text-strong); }
.update-bar .x { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 4px; }

@media (max-width: 900px) {
  .right { display: none; }
  .tf-group button:nth-child(n+7) { display: none; }
  .app-name { display: none; }
  .tester-grid, .alerts-pane { grid-template-columns: 1fr; }
}

/* --------- scheda Stile --------- */
.style-grid { display: grid; grid-template-columns: 22px 1fr auto auto auto; gap: 8px 10px; align-items: center; }
.style-grid .sg-title { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-grid .sg-title small { color: var(--muted); margin-left: 4px; }
.style-grid select { padding: 3px 6px; font-size: 12px; }
.style-grid .sg-colors { display: flex; flex-wrap: wrap; gap: 2px; max-width: 120px; justify-content: flex-end; }
.tester-warn { margin: 0 0 10px; padding: 8px 12px; border: 1px solid rgba(242,54,69,.45); background: rgba(242,54,69,.1); color: var(--text); border-radius: 6px; font-size: 12px; }
.deep-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -2px 0 10px; font-size: 12px; }
.deep-row input[type=date] { padding: 3px 6px; font-size: 12px; color-scheme: dark; }
.deep-status { font-size: 12px; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* volume dei suoni nelle impostazioni */
.vol-range { flex: 1; min-width: 120px; max-width: 260px; padding: 0; border: none; height: 6px; border-radius: 3px; -webkit-appearance: none; appearance: none; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) var(--fill, 80%), var(--border) var(--fill, 80%)); }
.vol-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.vol-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }

/* --------- tema chiaro (sfondo del grafico chiaro): colori della sintassi leggibili --------- */
.theme-light input[type=date], .theme-light input[type=time], .theme-light input[type=datetime-local], .theme-light .deep-row input[type=date] { color-scheme: light; }
.theme-light .cm-s-anubiview .CodeMirror-selected, .theme-light .cm-s-anubiview.CodeMirror-focused .CodeMirror-selected { background: #ADD6FF !important; }
.theme-light .cm-s-anubiview .cm-comment, .theme-light .cm-s-anubiview .cm-meta { color: #008000; }
.theme-light .cm-s-anubiview .cm-string { color: #A31515; }
.theme-light .cm-s-anubiview .cm-number { color: #098658; }
.theme-light .cm-s-anubiview .cm-keyword { color: #AF00DB; }
.theme-light .cm-s-anubiview .cm-atom { color: #0000FF; }
.theme-light .cm-s-anubiview .cm-type { color: #267F99; }
.theme-light .cm-s-anubiview .cm-builtin { color: #0070C1; }
.theme-light .cm-s-anubiview .cm-def { color: #795E26; }
.theme-light .cm-s-anubiview .cm-variable-2 { color: #001080; }
.theme-light .cm-s-anubiview .cm-operator { color: #2A2E39; }
.tb-btn:disabled { opacity: .35; cursor: default; background: none; }
.tag.protected { background: rgba(255,152,0,.15); color: var(--warn); }

/* --------- conto alla rovescia, scorciatoie, schermo intero --------- */
.bar-countdown { position: absolute; z-index: 3; height: 16px; line-height: 16px; font-size: 11px; text-align: center; color: #fff; font-variant-numeric: tabular-nums; pointer-events: none; border-radius: 0 0 2px 2px; opacity: .92; }
kbd { display: inline-block; font: 11px var(--mono); padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); color: var(--text); white-space: nowrap; }
.kb-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
body.focus-mode .right, body.focus-mode .bottom, body.focus-mode .resizer, body.focus-mode .footer { display: none !important; }
.pane-tools { pointer-events: auto; display: none; gap: 1px; margin-bottom: 2px; }
.legend-pane.pane-active .pane-tools { display: inline-flex; }
.pane-tools button { background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: 9px; line-height: 15px; min-width: 18px; padding: 0 4px; border-radius: 3px; cursor: pointer; }
.pane-tools button:hover:not(:disabled) { background: var(--hover); }
.pane-tools button:disabled { opacity: .3; cursor: default; }
/* touch: pulsanti della legenda grandi abbastanza per il dito */
@media (pointer: coarse) {
  .legend-script .lbtns button { font-size: 17px; line-height: 32px; min-width: 36px; padding: 0 8px; }
  .pane-tools { gap: 3px; }
  .pane-tools button { font-size: 10px; line-height: 17px; min-width: 23px; }
  .legend-fold { font-size: 15px; padding: 8px 12px; min-width: 40px; }
}
.cmp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.lvl-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }

/* --------- pannello di destra: schede e albero degli oggetti --------- */
.rp-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.rp-tab { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 0; cursor: pointer; color: var(--muted); font-weight: 600; }
.rp-tab.active { color: var(--text-strong); border-bottom-color: var(--accent); }
.rp-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.object-tree { overflow-y: auto; flex: 1; padding-bottom: 8px; }
.ot-head { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 10px 4px; }
.ot-head .btn { text-transform: none; letter-spacing: 0; padding: 2px 8px; }
.ot-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; cursor: pointer; font-size: 12px; }
.ot-row:hover { background: var(--hover); }
.ot-row.sel { background: rgba(41,98,255,.14); }
.ot-row.off .ot-name { opacity: .45; }
.ot-row .ot-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ot-row .ot-kind { width: 16px; text-align: center; color: var(--muted); font-style: italic; }
.ot-row button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 3px; font-size: 11px; opacity: 0; }
.ot-row:hover button, .ot-row.sel button { opacity: 1; }
.ot-row button:hover:not(:disabled) { color: var(--text); }
.ot-row button:disabled { opacity: .2 !important; cursor: default; }
.ot-empty { color: var(--muted); font-size: 12px; padding: 6px 10px; }

/* --------- strategy tester: schede, report e ottimizzatore --------- */
.tester-tabs { margin-bottom: 10px; }
.equity-box.wide { height: 300px; }
.trades-box.full { max-height: none; }
table.data.perf td, table.data.perf th { padding: 5px 10px; }
table.data.monthly td { text-align: center; font-variant-numeric: tabular-nums; min-width: 58px; }
table.data.monthly td:first-child { text-align: left; }
.opt-box { max-width: 1100px; }
.opt-params input[type=number] { width: 90px; padding: 3px 6px; }
.opt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; font-size: 12px; }
.opt-actions select, .opt-actions input { padding: 3px 6px; }
.opt-progress { height: 4px; background: var(--hover); border-radius: 2px; overflow: hidden; margin-bottom: 10px; }
.opt-progress > div { height: 100%; background: var(--accent); transition: width .2s; }

/* --------- griglia di più grafici e layout --------- */
.chart-wrap { display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr; }
.chart-wrap:not([data-grid="1"]) { gap: var(--frame); background: var(--border); }
.chart-wrap[data-grid="2v"] { grid-template-columns: 1fr 1fr; }
.chart-wrap[data-grid="2h"] { grid-template-rows: 1fr 1fr; }
.chart-wrap[data-grid="3v"] { grid-template-columns: 1fr 1fr 1fr; }
.chart-wrap[data-grid="3"], .chart-wrap[data-grid="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.chart-wrap[data-grid="3"] .chart-cell[data-cell="0"] { grid-row: span 2; }
.chart-cell { position: relative; min-width: 0; min-height: 0; background: var(--bg); overflow: hidden; }
.chart-cell iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.chart-cell.active::after { content: ''; position: absolute; inset: 0; border: 1px solid var(--accent); pointer-events: none; z-index: 6; }
.grid-ico { width: 18px; height: 14px; vertical-align: -2px; }
.grid-ico rect { fill: none; stroke: currentColor; stroke-width: 1.3; }
#layoutLabel { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.grid-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.grid-pick button { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; min-width: 86px; }
.grid-pick button .grid-ico { width: 30px; height: 23px; }
.grid-pick button.active, .grid-pick button:hover { color: var(--text-strong); border-color: var(--accent); }
.layout-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.layout-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.layout-row:last-child { border-bottom: none; }
.layout-row.current { background: rgba(41,98,255,.12); }
.layout-row .ln { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.dlg-sec:first-child { margin-top: 0; }

/* grafico secondario della griglia: niente pannelli laterali, editor e piè di pagina */
body.embed .right, body.embed .bottom, body.embed .resizer, body.embed .footer, body.embed .brand,
body.embed #userBtn, body.embed #bellBtn, body.embed #paletteBtn, body.embed #layoutBtn, body.embed #focusBtn, body.embed #hudBtn { display: none !important; }
body.embed .topbar { overflow-x: auto; scrollbar-width: none; }
body.embed .topbar::-webkit-scrollbar { display: none; }
/* su uno schermo grande l'iframe può essere più stretto di 641 px: barra in alto e strumenti come nella pagina principale */
body.cell-wide .toolbar-left { display: flex; }
body.cell-wide #drawToggle { display: none !important; }
/* griglia nel layout classico: barra in alto e strumenti della pagina principale dentro il primo grafico, come quelli
   degli iframe nei loro (allo stesso livello); il pannello di destra sale fino in cima. Posizione del primo grafico
   in --hud-fl/ft/fr/fb (horizon.js, placeFrame()). Non sul telefono: lì i grafici stanno uno sotto l'altro e la barra in basso */
@media (min-width: 641px) and (not ((pointer: coarse) and (orientation: landscape) and (max-height: 500px))) {
  body:not(.layout-hud, .embed):has(#chartGrid:not([data-grid="1"])) {
    .app, .main { position: relative; }
    .topbar { position: absolute; z-index: 30; top: var(--hud-ft, 0px); left: var(--hud-fl, 0px); right: var(--hud-fr, 0px); }
    #drawTools { position: absolute; z-index: 29; left: var(--hud-fl, 0px); top: calc(var(--hud-ft, 0px) + 46px); bottom: var(--hud-fb, 0px); }
    .chart-cell[data-cell="0"] > .chart { top: 46px; left: 44px; }
    .chart-cell[data-cell="0"] > .trade-btns { top: 52px; margin-left: 22px; }
  }
}

/* --------- editor: registro dei log e suggerimenti --------- */
.ed-logs { margin-top: 4px; border-top: 1px dashed var(--border); padding-top: 3px; }
.ed-logs-head { font-family: var(--font); font-size: 11px; padding: 0 10px 2px; }
.ed-logs .ed-con-row { padding-top: 0; padding-bottom: 0; }
.ed-logs .ed-con-row .t { color: var(--muted); }

/* --------- editor: cerca e sostituisci --------- */
.cm-find { position: absolute; top: 4px; right: 18px; z-index: 8; display: flex; flex-direction: column; gap: 4px; padding: 5px 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.35); font-size: 12px; max-width: calc(100% - 26px); }
.cm-find.hidden { display: none; }
.cm-find-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
.cm-find-rep, .cm-find-goto { display: none; }
.cm-find.replace .cm-find-rep { display: flex; }
.cm-find.goto .cm-find-row { display: none; }
.cm-find.goto .cm-find-goto { display: flex; }
.cm-find-field { display: flex; align-items: center; flex: 1; min-width: 0; width: 250px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding-right: 2px; }
.cm-find-field:focus-within { border-color: var(--accent); }
.cm-find-field.bad { border-color: var(--down); }
.cm-find-field input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font-family: var(--mono); font-size: 12px; padding: 4px 6px; height: 24px; box-shadow: none; }
.cm-find-opt, .cm-find-x { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--muted); font-family: var(--mono); font-size: 12px; cursor: pointer; }
.cm-find-opt:hover, .cm-find-x:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.cm-find-opt.on { background: color-mix(in srgb, var(--accent) 25%, transparent); border-color: var(--accent); color: var(--text-strong); }
.cm-find-x:disabled { opacity: .4; cursor: default; }
.cm-find-txt { font-family: var(--font); padding: 0 7px; border-color: var(--border); }
.cm-find-exp { width: 16px; min-width: 16px; padding: 0; font-family: var(--font); }
.cm-find-pad { width: 16px; flex: none; }
.cm-find-count { flex: none; min-width: 74px; text-align: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.cm-find-count.none { color: var(--down); }
.cm-find-hit { background: rgba(255,200,0,.22); border-radius: 2px; }
.cm-find-cur { background: rgba(255,150,0,.55); outline: 1px solid #FF9800; border-radius: 2px; }
.cm-find-scope { background: rgba(41,98,255,.10); }
.cm-find-sb { background: #FF9800; min-height: 2px; opacity: .8; }
.theme-light .cm-find-hit { background: rgba(255,200,0,.35); }
.theme-light .cm-find-cur { background: rgba(255,150,0,.5); }
@media (max-width: 640px) {
  .cm-find { left: 4px; right: 4px; max-width: none; }
  .cm-find-field { width: auto; }
  .cm-find-count { min-width: 44px; }
}
.pine-tip { position: fixed; z-index: 1000; max-width: 460px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 12px; color: var(--text); box-shadow: 0 6px 18px rgba(0,0,0,.35); pointer-events: none; }
.pine-tip .sig { font-family: var(--mono); color: var(--text-strong); margin-bottom: 3px; }
.pine-tip .sig b { color: var(--accent); }
.CodeMirror-hint .hint-sig { color: var(--muted); margin-left: 8px; font-size: 11px; }

/* --------- versioni degli script --------- */
.versions { display: grid; grid-template-columns: 220px 1fr; gap: 10px; height: 60vh; }
.ver-list { overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.ver-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; background: none; border: none; border-bottom: 1px solid var(--border); padding: 7px 10px; cursor: pointer; color: var(--text); text-align: left; }
.ver-item.active, .ver-item:hover { background: var(--hover); }
.ver-item .muted { font-size: 11px; }
.ver-view { display: flex; flex-direction: column; min-width: 0; }
.ver-legend { font-size: 11px; margin-bottom: 4px; }
.ver-diff { flex: 1; overflow: auto; margin: 0; padding: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; font: 12px/1.45 var(--mono); }
.ver-diff .del, .ver-legend .del { background: rgba(242,54,69,.16); color: var(--text); }
.ver-diff .add, .ver-legend .add { background: rgba(8,153,129,.18); color: var(--text); }
@media (max-width: 700px) { .versions { grid-template-columns: 1fr; height: auto; } .ver-list { max-height: 160px; } }

/* --------- alert: canali e opzioni --------- */
.alert-channels { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* --------- paper trading --------- */
.paper { height: 100%; overflow: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.paper-head { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-m { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; min-width: 110px; }
.pp-m .k { font-size: 11px; color: var(--muted); }
.pp-m .v { font-size: 14px; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.pp-m .v.up { color: var(--up); } .pp-m .v.down { color: var(--down); }
.pp-m .v.sm { font-size: 12px; font-weight: 400; color: var(--text); }
.paper-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.paper-body { flex: 1; min-height: 60px; }
.paper-body table.data td, .paper-body table.data th { padding: 5px 8px; }
.pp-act, .paper-body td.nowrap { white-space: nowrap; }
.pp-act .btn { margin-left: 4px; }
.pp-foot { margin-top: 6px; text-align: right; }
.trade-btns { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 7; display: flex; align-items: stretch; gap: 0; box-shadow: 0 2px 8px rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; }
.trade-btns button { border: none; cursor: pointer; color: #fff; padding: 3px 12px; display: flex; flex-direction: column; align-items: center; font-size: 10px; line-height: 1.2; min-width: 92px; }
.trade-btns button b { font-size: 13px; font-variant-numeric: tabular-nums; }
.trade-btns .tb-sell { background: #F23645; } .trade-btns .tb-sell:hover { background: #d92d3b; }
.trade-btns .tb-buy { background: #2962FF; } .trade-btns .tb-buy:hover { background: #1E53E5; }
.trade-btns input { width: 74px; border: none; border-radius: 0; text-align: center; background: var(--panel); color: var(--text-strong); font-size: 12px; padding: 0 4px; }

/* --------- community: libreria, commenti, idee --------- */
.lib-thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); flex: none; cursor: pointer; }
.lib-item .lib-main { flex: 1; min-width: 0; }
.sc-detail, .idea-detail { display: flex; flex-direction: column; gap: 8px; }
.sc-img { width: 100%; max-height: 380px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); }
.cm-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.cm { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
.cm-h { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 2px; }
.cm-h .x-sm { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; }
.cm-new { display: flex; gap: 6px; align-items: flex-end; }
.cm-new textarea { flex: 1; resize: vertical; }
.cm-empty { padding: 4px 0; }
.ac-users { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0; max-height: 240px; overflow-y: auto; }
.ac-users.disabled { opacity: .45; pointer-events: none; }
.ideas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; max-height: 62vh; overflow-y: auto; }
.idea-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.idea-card:hover { border-color: var(--accent); }
.idea-card img, .idea-noimg { width: 100%; height: 130px; object-fit: cover; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.ic-body { padding: 8px 10px; }
.ic-t { font-weight: 600; color: var(--text-strong); margin-bottom: 3px; }
.ic-m { font-size: 12px; }
.idea-text { white-space: normal; line-height: 1.5; }
.ip-img { max-width: 100%; max-height: 200px; border-radius: 6px; border: 1px solid var(--border); }
.lib-item:has(.lib-thumb) { grid-template-columns: auto 1fr auto; }

/* --------- accesso e sicurezza --------- */
.auth-info { color: var(--up); font-size: 12px; min-height: 0; }
.auth-info:empty { display: none; }
.tfa { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.tfa-qr svg { display: block; width: 200px; height: 200px; border-radius: 6px; }
.tfa-key { font-size: 13px; letter-spacing: 1px; word-break: break-all; }
.backup-codes { font: 15px/1.7 var(--mono); background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 16px; columns: 2; }
@media (max-width: 600px) { .tfa { grid-template-columns: 1fr; } .tfa-qr { justify-self: center; } }

/* --------- schermi piccoli e telefono --------- */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
  #panelToggle { display: inline-flex !important; }
  body.show-right .right { display: flex; position: fixed; right: 0; top: calc(46px + env(safe-area-inset-top)); bottom: env(safe-area-inset-bottom); width: min(300px, 86vw); z-index: 45; background: var(--bg); box-shadow: -8px 0 24px rgba(0,0,0,.45); }
}
@media (max-width: 640px) {
  #drawToggle { display: inline-flex !important; }
  .toolbar-left { display: none; }
  body.show-draw .toolbar-left { display: flex; position: fixed; left: 0; top: calc(46px + env(safe-area-inset-top)); bottom: env(safe-area-inset-bottom); z-index: 45; background: var(--bg); overflow-y: auto; box-shadow: 8px 0 24px rgba(0,0,0,.45); }
  .topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 4px; }
  .topbar::-webkit-scrollbar { display: none; }
  .brand, .footer { display: none; }
  .bottom { max-height: 50vh; max-height: 50dvh; }
  .modal-bg { place-items: end center; }
  .modal, .modal.wide { width: 100vw; max-height: 92vh; max-height: calc(100dvh - env(safe-area-inset-top) - 8px); border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .form-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .form-grid > label { margin-top: 6px; color: var(--muted); font-size: 12px; }
  .trade-btns button { min-width: 64px; padding: 2px 6px; }
  .trade-btns input { width: 52px; }
  .seg { flex-wrap: wrap; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .tabs .tab { padding-left: 8px; padding-right: 8px; }
  .ideas-grid { grid-template-columns: 1fr; }
  .lib-item { grid-template-columns: 1fr; }
  .lib-item:has(.lib-thumb) { grid-template-columns: auto 1fr; }
  .lib-item .acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
  /* griglia di grafici: uno sotto l'altro */
  .chart-wrap:not([data-grid="1"]) { grid-template-columns: 1fr !important; grid-template-rows: none !important; grid-auto-rows: minmax(0, 1fr); }
  .chart-wrap[data-grid="3"] .chart-cell[data-cell="0"] { grid-row: auto; }
  /* bersagli più grandi per le dita */
  .btn.sm { padding: 6px 10px; }
}
@media (hover: none) {
  .ot-row button { opacity: 1; }
}
/* telefono in orizzontale: poca altezza, il pannello in basso non deve schiacciare il grafico */
@media (max-height: 500px) {
  .bottom { max-height: 45vh; max-height: 45dvh; }
  .chart-wrap { min-height: 80px; }
  .footer { display: none; }
}

/* --------- watchlist: liste, sezioni, bandierine, colonne, dettagli --------- */
.wl-ui { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wl-head { gap: 2px; }
.wl-name { background: none; border: none; color: var(--text-strong); font-weight: 600; cursor: pointer; padding: 2px 4px; border-radius: 4px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-name:hover { background: var(--hover); }
.wl-grid { display: grid; grid-template-columns: minmax(64px, 1fr) 76px 62px 14px; align-items: center; gap: 4px; }
.wl-grid.c-abs { grid-template-columns: minmax(64px, 1fr) 66px 54px 54px 14px; }
.wl-grid.c-spark { grid-template-columns: minmax(64px, 1fr) 44px 68px 56px 14px; }
.wl-grid.c-abs.c-spark { grid-template-columns: minmax(64px, 1fr) 44px 64px 52px 52px 14px; }
.wl-row .spark svg { width: 44px; }
/* con le colonne in più il pannello si allarga */
.right:has(.wl-grid.c-abs), .right:has(.wl-grid.c-spark) { width: 320px; }
.right:has(.wl-grid.c-abs.c-spark) { width: 340px; }
.wl-grid.c-x { grid-template-columns: var(--wl-tpl); }
.right:has(.wl-grid.c-x) { width: var(--wl-w, 380px); }
.wl-perp { display: inline-block; margin-left: 4px; padding: 0 3px; border-radius: 3px; font-size: 9px; line-height: 13px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); vertical-align: 1px; }
.wl-mkt { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 5px; vertical-align: 2px; }
.wl-mkt[data-s=open] { background: var(--up); }
.wl-mkt[data-s=pre], .wl-mkt[data-s=post] { background: #FF9800; }
.wl-mkt[data-s=closed] { background: var(--muted); }
@keyframes wl-alert { 0%, 50% { background: rgba(255,152,0,.35); } 25%, 75%, 100% { background: transparent; } }
.wl-row.wl-alert { animation: wl-alert 1.5s ease 2; }
.wl-header [data-sort] { cursor: pointer; user-select: none; }
.wl-header [data-sort]:hover { color: var(--text); }
/* bandierina piena con una piccola tacca a destra: da lontano sembra un pallino, come su TradingView */
.wl-row .wl-flag { display: inline-block; width: 10px; height: 11px; border-radius: 3px 2px 2px 3px; clip-path: polygon(0 0, 100% 0, 78% 50%, 100% 100%, 0 100%); margin-right: 6px; vertical-align: -1px; background: transparent; cursor: pointer; flex: none; }
.wl-row:hover .wl-flag:not([style*=background]) { background: var(--hover-2); }
.wl-row.dragging { opacity: .4; }
.wl-row img, .wl-row svg { -webkit-user-drag: none; user-drag: none; }
.wl-row.drop-before, .wl-sec.drop-before { box-shadow: 0 -2px 0 var(--accent, #2962FF); }
.wl-row.drop-after { box-shadow: 0 2px 0 var(--accent, #2962FF); }
.wl-row .spark svg { display: block; }
.wl-sec { display: flex; align-items: center; gap: 6px; padding: 6px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: pointer; border-top: 1px solid var(--border); }
.wl-sec span { flex: 1; }
.wl-sec .rm { opacity: 0; background: none; border: none; color: var(--muted); cursor: pointer; }
.wl-sec:hover .rm { opacity: 1; }
.wl-detail { flex: none; border-top: 1px solid var(--border); padding: 9px 12px; font-size: 13px; max-height: 45%; overflow-y: auto; }
.wl-detail .wd-sym { font-weight: 600; color: var(--text-strong); font-size: 16px; }
.wl-detail .wd-sym .coin { width: 20px; height: 20px; }
.wl-detail .wd-desc { margin: 3px 0 5px; font-size: 13px; }
.wl-detail .wd-price b { font-size: 21px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.wl-detail .wd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 7px; }
.wl-detail .wd-derivs { border-top: 1px solid var(--border); padding-top: 6px; }
.wl-detail .wd-actions { margin-top: 8px; flex-wrap: wrap; }
.wl-detail .wd-stats div { display: flex; justify-content: space-between; gap: 6px; font-variant-numeric: tabular-nums; }

/* barre per ridimensionare elenco, tachimetro e dettagli (watchlist-ui.js, dragSplit): la maniglia è larga 7 px ma occupa solo il bordo (margini negativi) */
.wl-split { flex: none; height: 7px; margin: -3px 0; position: relative; z-index: 3; cursor: row-resize; touch-action: none; }
.wl-split::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 1px; background: transparent; transition: background .15s, height .15s, top .15s; }
.wl-split:hover::after, .wl-split.drag::after { top: 2px; height: 3px; border-radius: 2px; background: var(--accent); }
.wl-split[data-split="a"]:has(+ .wl-pulse:empty), .wl-split[data-split="a"]:has(+ .wl-pulse:not(:has(.sp-body))), .wl-split[data-split="b"]:has(+ .wl-detail:empty) { display: none; }
.wl-pulse.sized, .wl-detail.sized { max-height: 65%; }
.wl-detail.sized { min-height: 0 !important; } /* l'altezza scelta vince su quella stabile di renderDetail */
.wl-pulse.sized:not(:has(.sp-body)) { height: auto !important; }
.watchlist { min-height: 56px; }

/* tachimetro della strategia (strategy-pulse.js): tra l'elenco dei simboli e i dettagli */
.wl-pulse { flex: none; border-top: 1px solid var(--border); font-size: 12px; max-height: 46%; overflow-y: auto; }
.wl-pulse:empty { display: none; }
.sp-head { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; cursor: pointer; user-select: none; }
.sp-head:hover { background: var(--hover); }
.sp-title { flex: 1; min-width: 0; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.sp-mini { font-size: 10px; letter-spacing: .06em; padding: 1px 6px; border-radius: 9px; background: color-mix(in srgb, currentColor 14%, transparent); }
.sp-body { padding: 0 10px 8px; }
.sp-empty { padding: 4px 0 6px; line-height: 1.4; }
.sp-meter { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sp-side { min-width: 0; text-align: center; }
.sp-gauge { display: block; width: 70%; height: auto; overflow: visible; margin: 0 auto; }
.sp-gauge .sp-ticks line { stroke: var(--muted); stroke-opacity: .55; stroke-width: 1; }
.sp-gauge .sp-end { font-size: 12px; font-weight: 700; letter-spacing: .08em; fill: currentColor; }
.sp-gauge .sp-end.up { fill: var(--up); }
.sp-gauge .sp-end.down { fill: var(--down); }
.sp-gauge .sp-hub { fill: var(--panel, #1e222d); stroke: var(--muted); stroke-width: 1.2; }
.sp-needle { transform-origin: 100px 96px; transform-box: view-box; transition: transform 1.1s cubic-bezier(.34, 1.56, .64, 1); }
.sp-lit { animation: sp-pulse 2.4s ease-in-out infinite; }
@keyframes sp-pulse { 50% { opacity: .45; } }
.sp-read { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.sp-label { font-size: 16px; white-space: nowrap; font-weight: 800; letter-spacing: .08em; text-shadow: 0 0 12px color-mix(in srgb, currentColor 55%, transparent); }
.sp-label.flat, .sp-mini.flat { color: var(--muted); }
.sp-read .muted { font-size: 11px; }
.sp-accel { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; justify-content: center; margin-top: 6px; font-size: 11px; }
.sp-accel i { font-style: normal; font-size: 10px; }
.sp-accel.up { color: var(--up); }
.sp-accel.down { color: var(--down); }
.sp-accel.flat { color: var(--muted); }
.sp-bar { position: relative; width: 58px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--down), color-mix(in srgb, var(--muted) 40%, transparent) 50%, var(--up)); opacity: .9; }
.sp-bar span { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; border-radius: 1px; background: var(--text-strong); box-shadow: 0 0 6px var(--text-strong); transition: left .8s ease; }
.sp-tfs { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; margin-top: 6px; }
.sp-tf { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 2px 3px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; font: inherit; line-height: 1.15; transition: background .2s, border-color .2s, transform .15s; }
.sp-tf:hover { transform: translateY(-1px); }
.sp-tf .sp-tfl { font-size: 10px; color: var(--muted); }
.sp-tf b { font-size: 11px; letter-spacing: .04em; }
.sp-tf .sp-pl { font-size: 10px; font-variant-numeric: tabular-nums; min-height: 1em; }
.sp-tf.up { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); background: color-mix(in srgb, var(--up) 12%, transparent); }
.sp-tf.down { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); background: color-mix(in srgb, var(--down) 12%, transparent); }
.sp-tf.flat b { color: var(--muted); }
.sp-tf.err { color: var(--warn); }
.sp-tf.wait b { animation: sp-pulse 1.2s ease-in-out infinite; color: var(--muted); }
.sp-tf.cur { box-shadow: inset 0 0 0 1px var(--accent, #2962FF); cursor: default; }
.sp-tf.cur:hover { transform: none; }
.sp-hist { position: relative; margin-top: 8px; height: 34px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; overflow: hidden; }
.sp-hist:hover { background: var(--hover); }
.sp-hist .sp-histsvg { display: block; width: 100%; height: 100%; }
.sp-hist-l { position: absolute; right: 4px; top: 1px; font-size: 9px; }
.sp-histbig { width: 100%; height: 260px; border: 1px solid var(--border); border-radius: 6px; }
.sp-histbig .sp-histsvg { display: block; width: 100%; height: 100%; }
.sp-histrange { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.sp-ai { margin-top: 6px; padding: 4px 6px 6px; border-radius: 6px; border: 1px solid var(--border); }
.sp-ai-t { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.sp-ai-t span { flex: 1; }
.sp-ai-t .btn.icon { padding: 0 6px; line-height: 18px; opacity: .6; }
.sp-ai-t .btn.icon:hover { opacity: 1; }
.sp-ai-txt { margin-top: 4px; font-size: 12px; line-height: 1.45; user-select: text; }
.sp-ai-foot { margin-top: 4px; font-size: 10px; line-height: 1.3; }
.sp-sea { margin-top: 6px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); }
.sp-sea.open { padding-bottom: 4px; }
.sp-sea:hover { background: var(--hover); }
.sp-sea-t { display: flex; align-items: center; gap: 6px; cursor: pointer; min-height: 24px; user-select: none; }
.sp-sea-t .btn { padding: 0 6px; line-height: 18px; opacity: .6; }
.sp-sea-t .btn:hover { opacity: 1; }
.sp-sea-t span:first-child { flex: 1; }
.sp-sea-t b { font-variant-numeric: tabular-nums; }
.sp-sea-t .muted { font-size: 10px; }
.sp-sea-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 4px; align-items: end; }
.sp-sea-bars span { position: relative; height: 50px; }
.sp-sea-bars span::before { content: ''; position: absolute; left: 0; right: -2px; top: 19px; border-top: 1px solid var(--border); }
.sp-sea-bars i { position: absolute; left: 50%; transform: translateX(-50%); width: 70%; max-width: 12px; opacity: .55; }
.sp-sea-bars span.up i { bottom: 31px; background: var(--up); border-radius: 2px 2px 0 0; }
.sp-sea-bars span.down i { top: 19px; background: var(--down); border-radius: 0 0 2px 2px; }
.sp-sea-bars span.cur i { opacity: 1; box-shadow: 0 0 8px currentColor; }
.sp-sea-bars span.cur.up { color: var(--up); }
.sp-sea-bars span.cur.down { color: var(--down); }
.sp-sea-bars small { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 8px; color: var(--muted); }
.sp-sea-bars span.cur small { color: var(--text-strong); font-weight: 700; }

/* --------- screener e heatmap --------- */
.modal.xwide { width: min(1180px, 97vw); }
.scr-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scr-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 8px; font-size: 12px; }
.scr-filters .chip { cursor: pointer; }
.scr-table { max-height: 58vh; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.scr-table th { position: sticky; top: 0; background: var(--panel); cursor: pointer; white-space: nowrap; }
.scr-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.scr-table tbody tr { cursor: pointer; }
.heatmap { position: relative; height: 60vh; min-height: 300px; border-radius: 6px; overflow: hidden; }
.hm-cell { position: absolute; box-sizing: border-box; border: 1px solid var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: #fff; overflow: hidden; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.hm-cell b { font-size: 13px; }
.hm-cell span { font-size: 11px; }
.hm-cell:hover { outline: 2px solid var(--text-strong); outline-offset: -2px; z-index: 1; }

/* eventi del calendario economico sul grafico */
.econ-tip { position: absolute; z-index: 6; max-width: 300px; background: var(--panel, #1E222D); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.econ-tip .et-row + .et-row { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--border); }
.econ-tip .et-dot, .cal-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.econ-tip .et-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* calendario economico e notizie (pannello di destra) */
.rp-tab { font-size: 12px; padding: 8px 2px; }
.market-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.market-panel .empty { padding: 20px 12px; text-align: center; }
.cal-bar { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--border); flex: none; }
.cal-bar select { flex: 1; min-width: 0; font-size: 12px; padding: 4px 6px; }
.cal-bar .news-scope { flex: 1; font-weight: 600; color: var(--text-strong); }
.cal-next { padding: 6px 10px; font-size: 12px; background: var(--panel-2); border-bottom: 1px solid var(--border); flex: none; }
.cal-list { flex: 1; overflow-y: auto; min-height: 0; }
.cal-day { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; text-transform: capitalize; color: var(--muted); position: sticky; top: 0; background: var(--bg); }
.cal-row { display: grid; grid-template-columns: 38px 46px 1fr; gap: 4px; padding: 5px 10px; font-size: 12px; border-bottom: 1px solid var(--border); align-items: start; }
.cal-row.past { opacity: 0.5; }
.cal-row.next { background: rgba(41, 98, 255, 0.12); }
.cal-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-cur { font-weight: 600; white-space: nowrap; }
.cal-title small { display: block; color: var(--muted); font-size: 11px; }
.cal-foot { padding: 6px 10px; font-size: 11px; border-top: 1px solid var(--border); flex: none; }
.news-item { display: block; padding: 8px 10px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.news-item:hover { background: var(--hover); }
.news-title { font-weight: 600; color: var(--text-strong); font-size: 12.5px; line-height: 1.35; }
.news-sum { font-size: 12px; color: var(--text); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-meta { font-size: 11px; margin-top: 3px; }

/* barra in alto: sotto i 1600 px restano solo le icone (il nome è nel tooltip) */
.topbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
@media (max-width: 1600px) {
  .topbar .tb-lbl, .topbar .app-name { display: none; }
  .tf-group button { padding: 6px 4px; }
  #chartType { max-width: 104px; }
  .symbol-btn { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
}

/* albero degli oggetti / finestra dati */
.ot-switch { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--border); flex: none; }
.ot-switch button { flex: 1; background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); padding: 4px 0; cursor: pointer; font-size: 12px; }
.ot-switch button.active { color: var(--text-strong); border-color: var(--accent); }
.data-window { overflow-y: auto; flex: 1; padding-bottom: 8px; }
.dw-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.dw-row span:last-child { text-align: right; overflow-wrap: anywhere; }

/* timeframe: preferiti e menu ▾ */
.tf-group button.extra { font-style: italic; }
.tf-group .tf-more { padding: 6px 5px; color: var(--muted); }
.tf-menu { width: 300px; padding-bottom: 6px; }
.tf-menu .tf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 0 6px; }
.tf-menu .tf-item { display: flex; align-items: center; border-radius: 4px; }
.tf-menu .tf-item:hover { background: var(--hover); }
.tf-menu .tf-item.cur button[data-go] { color: var(--accent); font-weight: 600; }
.tf-menu .tf-item button { padding: 4px 6px; width: auto; }
.tf-menu .tf-item button[data-go] { flex: 1; text-align: left; }
.tf-menu .star { color: var(--muted); opacity: .5; }
.tf-menu .star.on { color: #F5B700; opacity: 1; }
.tf-menu .rm { color: var(--muted); }
.tf-menu .tf-new { display: flex; gap: 6px; padding: 4px 8px 0; }
.tf-menu .tf-new input { flex: 1; min-width: 0; }
.tf-menu .tf-new button { width: auto; flex: none; padding: 4px 10px; }
.data-window .dw-title { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text-strong); font-weight: 600; }

/* Bar Replay */
#replayBtn.active { color: var(--accent); background: rgba(41, 98, 255, .12); }
.replay-selecting { cursor: crosshair; }
.replay-shade { position: absolute; top: 0; bottom: 0; right: 0; background: rgba(41, 98, 255, .10); border-left: 2px solid var(--accent); pointer-events: none; z-index: 4; }
.replay-hint { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; padding: 6px 12px; font-size: 12px; z-index: 6; pointer-events: none; }
.replay-bar { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; z-index: 6; box-shadow: 0 4px 16px rgba(0,0,0,.4); font-size: 12px; white-space: nowrap; max-width: calc(100% - 90px); overflow-x: auto; scrollbar-width: none; }
.replay-bar button { background: none; border: 1px solid transparent; color: var(--text); border-radius: 4px; padding: 3px 7px; cursor: pointer; }
.replay-bar button:hover { background: var(--hover); }
.replay-bar select { font-size: 12px; padding: 2px 4px; }
.replay-bar input { width: 64px; font-size: 12px; padding: 2px 4px; }
.replay-bar .rp-badge { background: var(--accent); color: #fff; font-weight: 700; font-size: 10px; border-radius: 3px; padding: 2px 5px; letter-spacing: .05em; }
.replay-bar .rp-date { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.replay-bar .rp-sep { width: 1px; align-self: stretch; background: var(--border); }
.replay-bar .rp-buy { background: var(--up) !important; color: #fff; }
.replay-bar .rp-sell { background: var(--down) !important; color: #fff; }

/* libro ordini e Time & Sales */
.rp-tab { font-size: 11px; }
.ob-book { flex: none; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ob-head, .ts-head { display: grid; grid-template-columns: 1.2fr 1fr 1fr; padding: 3px 10px; font-size: 10.5px; color: var(--muted); }
.ob-head span:not(:first-of-type), .ts-head span:not(:first-of-type), .ob-row span:not(:first-of-type), .ts-row span:not(:first-of-type) { text-align: right; }
.ob-row { position: relative; display: grid; grid-template-columns: 1.2fr 1fr 1fr; padding: 1px 10px; }
.ob-row i { position: absolute; right: 0; top: 0; bottom: 0; opacity: .16; pointer-events: none; }
.ob-row span { position: relative; }
.ob-row.ask span:first-of-type { color: var(--down); }
.ob-row.bid span:first-of-type { color: var(--up); }
.ob-row.ask i { background: var(--down); }
.ob-row.bid i { background: var(--up); }
.ob-spread { padding: 4px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12px; }
.ts-list { flex: 1; overflow-y: auto; min-height: 0; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ts-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; padding: 1px 10px; }
.ts-row.buy span:nth-child(2) { color: var(--up); }
.ts-row.sell span:nth-child(2) { color: var(--down); }
.ts-row { position: relative; --c: 128, 128, 128; }
.ts-row.buy { --c: 8, 153, 129; }
.ts-row.sell { --c: 242, 54, 69; }
/* barra del valore da destra e lampo (--fl da 1 a 0) degli scambi grandi appena arrivati */
.ts-list .ts-row { background: linear-gradient(to left, rgba(var(--c), .22) var(--w, 0%), transparent var(--w, 0%)), rgba(var(--c), calc(var(--fl, 0) * .55)); }
.ts-row.big { font-weight: 700; }
.ts-row.big.t1 { background-color: rgba(var(--c), max(.14, calc(var(--fl, 0) * .55))); }
.ts-row.big.t2 { background-color: rgba(var(--c), max(.28, calc(var(--fl, 0) * .7))); color: var(--text-strong); }
.ts-row.big.t3 { background-color: rgba(var(--c), max(.45, calc(var(--fl, 0) * .9))); color: #fff; font-size: 12.5px; box-shadow: inset 3px 0 0 rgb(var(--c)); }
.ts-row.big.t3 span:nth-child(2) { color: #fff; }
@keyframes liq-new { 0%, 40% { background-color: rgba(var(--c), .7); } 100% { background-color: rgba(var(--c), .14); } }
.ts-row.liq-new { animation: liq-new 2s ease-out; }
.cal-bar label { font-size: 11px; }
#bookUi .cal-bar select { flex: none; width: auto; }
.liq-list { max-height: 120px; overflow-y: auto; font-size: 11.5px; font-variant-numeric: tabular-nums; flex: none; }
.liq-list .empty { padding: 8px 10px; text-align: left; }

/* screener Pine */
.ps-bar select#psScript { min-width: 240px; max-width: 360px; }
.ps-tfs .chip { cursor: pointer; }
.ps-table td.ps-cell { cursor: pointer; vertical-align: top; min-width: 90px; }
.ps-table td.ps-cell:hover { background: var(--hover); }
.ps-badges { display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; margin-top: 2px; }
.ps-b { font-size: 10px; border-radius: 3px; padding: 0 4px; background: var(--panel-2); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.ps-b.cond { background: rgba(255, 152, 0, .18); color: #FFB74D; }
.ps-b.sig { background: rgba(41, 98, 255, .18); color: #82A7FF; }
.ps-b.long { background: rgba(8, 153, 129, .2); color: var(--up); }
.ps-b.short { background: rgba(242, 54, 69, .2); color: var(--down); }

/* --------- selettore di colori (colorpicker.js) --------- */
.cpk { position: fixed; z-index: 120; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; width: 240px; box-shadow: 0 12px 32px rgba(0,0,0,.45); user-select: none; }
.cpk-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.cpk-main { margin: 6px 0; }
.cpk-sw { width: 100%; aspect-ratio: 1; border: 1px solid rgba(128,128,128,.25); border-radius: 3px; padding: 0; cursor: pointer; background: var(--c); }
.cpk-sw:hover { transform: scale(1.15); }
.cpk-sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.cpk-sep { border-top: 1px solid var(--border); margin: 8px 0; }
.cpk-recent { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; margin-bottom: 6px; }
.cpk-custom { display: flex; gap: 6px; align-items: center; }
.cpk-native { position: relative; width: 22px; height: 22px; flex: none; border: 1px dashed var(--border); border-radius: 3px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.cpk-native:hover { color: var(--text-strong); border-color: var(--accent); }
.cpk-native input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cpk-hex { flex: 1; min-width: 0; padding: 3px 6px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; }
.cpk-alpha { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; }
.cpk-range { flex: 1; min-width: 0; padding: 0; border: none; height: 14px; border-radius: 7px; -webkit-appearance: none; appearance: none;
  background: linear-gradient(90deg, transparent, var(--cur)), repeating-conic-gradient(#888 0 25%, #ddd 0 50%) 0 0 / 8px 8px; }
.cpk-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: pointer; }
.cpk-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: pointer; }
.cpk-pct { width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
/* quadratino del colore accanto ai colori nel codice Pine */
.cm-color-sw { display: inline-block; width: 10px; height: 10px; margin: 0 3px 0 1px; vertical-align: -1px; border: 1px solid rgba(128,128,128,.6); border-radius: 2px; cursor: pointer;
  background: linear-gradient(var(--c), var(--c)), repeating-conic-gradient(#888 0 25%, #ddd 0 50%) 0 0 / 6px 6px; }

/* telefono (anche in orizzontale): barra in basso come nell'app di TradingView; «⋯» la apre con tutti i comandi.
   Non nei grafici secondari della griglia su uno schermo grande (body.cell-wide): l'iframe è stretto, la finestra no */
@media (max-width: 640px), (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  body:not(.cell-wide) {
    .topbar { order: 2; border-bottom: none; border-top: 1px solid var(--border); height: 48px; }
    .topbar > :where(:not(#drawToggle, #symbolBtn, #tfGroup, #indicatorsBtn, #newAlertBtn, #moreBtn, #panelToggle)) { display: none; }
    #moreBtn { display: inline-flex !important; font-size: 18px; }
    .tf-group button:not(.active, .tf-more) { display: none; }
    .tf-group button.active, .tf-group button.tf-more { display: inline-block; }
    .tf-group .tf-more { font-size: 18px; line-height: 1; padding: 9px 10px; min-width: 36px; color: var(--text); } /* ▾: più facile da prendere col dito */
    &.show-right .right, &.show-draw .toolbar-left { top: env(safe-area-inset-top); bottom: calc(48px + env(safe-area-inset-bottom)); }
    &.tb-more .topbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: auto; max-height: 75dvh; overflow-y: auto; flex-wrap: wrap; gap: 6px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 32px rgba(0,0,0,.5); border-radius: 12px 12px 0 0; }
    &.tb-more .topbar > :not(.tb-sep, .spacer, .brand, .mobile-only) { display: inline-flex; }
    &.tb-more .topbar #moreBtn, &.tb-more .topbar #drawToggle, &.tb-more .topbar #panelToggle { display: inline-flex !important; }
    &.tb-more .topbar #tfGroup { flex-basis: 100%; flex-wrap: wrap; }
    &.tb-more .tf-group button { display: inline-block; }
    &.tb-more .topbar .tb-lbl { display: inline; margin-left: 4px; }
    &.tb-more .topbar #liveDot { display: inline-block; align-self: center; }
  }
}
/* telefono in orizzontale: il grafico prende tutto lo spazio, gli strumenti di disegno si aprono con ✎ */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  #drawToggle { display: inline-flex !important; }
  .toolbar-left { display: none; }
  body.show-draw .toolbar-left { display: flex; position: fixed; left: 0; z-index: 45; background: var(--bg); overflow-y: auto; box-shadow: 8px 0 24px rgba(0,0,0,.45); }
}

/* telefono: riga blu in fondo (come le strisce dell'Orizzonte sul desktop), un tocco nasconde o mostra le due barre in basso */
.mob-fold { display: none; }
@media (max-width: 640px), (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  body:not(.cell-wide, .embed, .focus-mode) .mob-fold { display: flex; order: 3; flex: none; align-items: center; justify-content: center; width: 100%; height: 16px; padding: 0; border: none; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .mob-fold i { display: block; width: min(160px, 40%); height: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); opacity: .75; }
  .mob-fold:active i { opacity: 1; }
  body.mob-bars-off:not(.cell-wide, .embed) :is(.topbar, .bottom, .resizer) { display: none !important; }
}

/* freccia della legenda: nasconde gli indicatori di tutti i pannelli */
.legend-fold { pointer-events: auto; background: color-mix(in srgb, var(--bg) 80%, transparent); border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font-size: 13px; line-height: 1; padding: 5px 9px; min-width: 28px; margin-top: 2px; cursor: pointer; }
.legend-fold:hover { color: var(--text-strong); }
.legend.folded .legend-script { display: none; }

/* --------- pannello di destra: larghezza trascinabile, si può nascondere (anche dal telefono in orizzontale) --------- */
.right { position: relative; }
.rp-resizer { position: absolute; left: calc(-1px - var(--frame)); top: 0; bottom: 0; width: calc(var(--frame) + 2px); cursor: col-resize; touch-action: none; z-index: 6; }
.rp-resizer:hover, .rp-resizer.drag { background: var(--accent); }
.right.rp-closing { opacity: .45; }
.rp-hide { flex: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 0 9px; font-size: 14px; }
.rp-hide:hover { color: var(--text-strong); background: var(--hover); }
.rp-show { display: none; flex: none; width: calc(16px + var(--frame)); padding: 0; border: none; border-left: var(--frame) solid var(--border); background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 12px; }
.rp-show:hover { color: var(--text-strong); background: var(--hover); }
body.right-hidden .right { display: none; }
body.right-hidden .rp-show { display: block; }
body.focus-mode .rp-show, body.embed .rp-show { display: none !important; }
body.rp-drag, body.rp-drag * { cursor: col-resize !important; user-select: none; }
body.rp-drag iframe { pointer-events: none; }
#panelToggle.active { color: var(--text-strong); }
/* fino a 900 px il pannello si apre sopra il grafico: la linguetta resta (in orizzontale il ☰ può finire fuori dalla barra) */
@media (max-width: 900px) { .rp-show { display: block; } body.show-right .rp-show { display: none; } }
@media (max-width: 640px) { .rp-show { display: none !important; } }
/* dita: bordo più largo da afferrare, con una maniglia visibile */
@media (pointer: coarse) {
  .rp-resizer { left: -10px; width: 20px; }
  .rp-resizer::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 44px; margin: -22px 0 0 -2px; border-radius: 2px; background: var(--muted); opacity: .55; }
  .rp-hide { padding: 0 12px; font-size: 16px; }
  .rp-show { width: 22px; font-size: 14px; }
}
.rp-hide svg, .rp-show svg { display: block; margin: auto; width: 14px; height: 14px; }

/* fasce del telefono: la zona della barra di stato, quella in basso e i lati (safe area) prendono --edge, nero di default */
html, body { background: var(--edge, #000); }
.app { background: var(--bg); background-clip: content-box; }

/* notifiche degli alert: restano finché non si chiudono, ✕ tenuta premuta le chiude tutte */
.toasts { max-height: calc(100dvh - 90px); overflow-y: auto; scrollbar-width: none; }
.alert-toast { padding: 8px 10px 10px 12px; }
.alert-toast .at-head { display: flex; align-items: center; gap: 6px; }
.alert-toast .at-sym { background: none; border: none; padding: 0; color: var(--text-strong); font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.alert-toast .at-sym:hover { color: var(--accent); text-decoration: underline; }
.alert-toast .at-time { font-size: 11px; }
.alert-toast .at-body { cursor: pointer; margin-top: 3px; }
.alert-toast .at-body .t { font-weight: 600; }
.alert-toast .at-body .m { color: var(--text); white-space: pre-line; word-break: break-word; }
.alert-toast .at-x { position: relative; flex: none; width: 26px; height: 26px; border-radius: 50%; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.alert-toast .at-x:hover { color: var(--text-strong); background: var(--hover); }
/* tenuta premuta: un anello si riempie in 1 secondo */
.alert-toast .at-x::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), transparent 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px)); opacity: 0; }
.alert-toast .at-x.holding::before { opacity: 1; animation: at-hold 1s linear forwards; }
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
@keyframes at-hold { from { --p: 0; } to { --p: 1; } }
@media (pointer: coarse) { .alert-toast .at-x { width: 34px; height: 34px; font-size: 15px; } }

/* barra in alto più larga della finestra: frecce per scorrerla, come su TradingView */
.tb-scroll { display: none; position: sticky; z-index: 3; flex: none; align-self: stretch; width: 28px; padding: 0; border: none; color: var(--text); cursor: pointer; align-items: center; justify-content: center; }
.tb-scroll:hover { color: var(--text-strong); }
.tb-scroll.show { display: flex; }
.tb-scroll.left { left: 0; margin: 0 -28px 0 0; justify-content: flex-start; padding-left: 4px; background: linear-gradient(to right, var(--bg) 65%, transparent); }
/* la freccia al centro in verticale: in un pulsante steso a tutta altezza il flex la lasciava in basso */
.tb-scroll svg { position: absolute; top: 50%; margin-top: -7px; }
.tb-scroll.left svg { left: 4px; }
.tb-scroll.right svg { right: 4px; }
.tb-scroll.right { right: 0; margin: 0 0 0 -28px; justify-content: flex-end; padding-right: 4px; background: linear-gradient(to left, var(--bg) 65%, transparent); }
body.tb-more .topbar .tb-scroll { display: none !important; }

/* vista Footprint 3D (footprint3d.js): copre il grafico, con intestazione, etichette HTML e tooltip */
.fp3d { position: absolute; inset: 0; z-index: 4; overflow: hidden; background: var(--bg); user-select: none; }
.fp3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.fp3d-canvas:active { cursor: grabbing; }
.fp3d-labels { position: absolute; inset: 0; pointer-events: none; }
.fp3d-l { position: absolute; left: 0; top: 0; margin: -8px 0 0 0; font-size: 12px; line-height: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; opacity: 0.85; }
.fp3d-l.time { margin-left: -24px; }
.fp3d-l.axis { margin-left: -30px; font-weight: 600; }
.fp3d-l.last { color: #fff; padding: 0 5px; border-radius: 3px; opacity: 1; font-weight: 600; }
.fp3d-head { position: absolute; left: 8px; right: 8px; top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; pointer-events: none; }
.fp3d-title { font-size: 13px; }
.fp3d-title .accent { color: var(--accent); font-weight: 600; }
.fp3d-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-left: auto; pointer-events: auto; font-size: 12px; }
.fp3d-ctrl select { padding: 2px 4px; font-size: 12px; }
.fp3d-views { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.fp3d-views button { background: var(--panel); border: 0; color: inherit; padding: 3px 9px; cursor: pointer; font-size: 12px; }
.fp3d-views button + button { border-left: 1px solid var(--border); }
.fp3d-views button.active { background: var(--accent); color: #fff; }
.fp3d-legend { flex-basis: 100%; font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; pointer-events: none; }
.fp3d .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 2px 0 8px; vertical-align: -1px; }
.fp3d-legend .sw:first-child { margin-left: 0; }
.fp3d .sw.buy { background: var(--fp-up, #089981); }
.fp3d .sw.sell { background: var(--fp-down, #F23645); }
.fp3d .sw.poc { background: #FFD54F; }
.fp3d-note, .fp3d-help { position: absolute; left: 8px; right: 8px; font-size: 11px; pointer-events: none; }
.fp3d-note { bottom: 22px; }
.fp3d-help { bottom: 6px; }
.fp3d-tip { position: absolute; left: 0; top: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 12px; line-height: 1.55; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,0.35); white-space: nowrap; z-index: 2; }
.fp3d-tip .sw { margin-left: 0; }
.fp3d-tip .up { color: var(--fp-up, #089981); }
.fp3d-tip .down { color: var(--fp-down, #F23645); }
.fp3d-msg { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--panel); border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; max-width: 460px; text-align: center; font-size: 13px; }
@media (max-width: 700px) { .fp3d-help, .fp3d-legend { display: none; } }
/* stagionalità e dati finanziari (research-ui.js) */
.sea-bar, .fin-bar { margin-bottom: 10px; flex-wrap: wrap; }
.sea-body, .fin-body { position: relative; }
.sea-svg, .fin-svg { display: block; }
.sea-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; min-width: 120px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.sea-tip div { display: flex; justify-content: space-between; gap: 12px; }
.sea-table { overflow-x: auto; margin: 6px 0; }
.sea-table table.data td, .sea-table table.data th { padding: 4px 6px; white-space: nowrap; }
.sea-table tfoot td { border-top: 1px solid var(--border); color: var(--muted); }
.fin-head { margin-bottom: 8px; line-height: 1.6; }
.fin-sum { margin-bottom: 10px; }
.fin-sum summary { cursor: pointer; color: var(--muted); }
.fin-sum p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 8px; }
.fin-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.fin-card .group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 4px; margin: 0 0 4px; }
.fin-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.fin-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.fin-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.fin-table td .sm { font-size: 11px; }

/* Guida (guide.js) e «?» delle finestre */
.modal-help { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: none; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.modal-help:hover { color: var(--text-strong); border-color: var(--muted); }
.modal-help + .x { margin-left: 10px; }
.guide-modal .modal-body { padding: 0; display: flex; min-height: 0; }
.guide { display: grid; grid-template-columns: 220px 1fr; width: 100%; height: min(72vh, 720px); height: min(72dvh, 720px); }
.guide-nav { border-right: 1px solid var(--border); overflow: auto; padding: 10px 8px 16px; background: var(--panel-2); }
.guide-q { width: 100%; margin-bottom: 6px; padding: 7px 9px; }
.guide-group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 8px 4px; }
.guide-nav a { display: block; padding: 5px 8px; border-radius: 4px; color: var(--text); text-decoration: none; font-size: 13px; }
.guide-nav a:hover { background: var(--hover); }
.guide-nav a.active { background: var(--hover-2); color: var(--text-strong); }
.guide-body { overflow: auto; padding: 16px 24px 28px; font-size: 13.5px; line-height: 1.6; max-width: 820px; }
.guide-body h2 { margin: 0 0 10px; font-size: 19px; color: var(--text-strong); }
.guide-body h4 { margin: 18px 0 6px; font-size: 14px; color: var(--text-strong); }
.guide-body p { margin: 0 0 10px; }
.guide-body ul { margin: 0 0 10px; padding-left: 20px; }
.guide-body li { margin: 3px 0; }
.guide-body code { font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
.guide-body .btn { margin: 4px 6px 0 0; }
.guide-table { border-collapse: collapse; margin: 6px 0 12px; width: 100%; }
.guide-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; }
.guide-table th, .guide-table td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.guide-table td:first-child { white-space: nowrap; color: var(--text-strong); }
.guide-hit { display: block; padding: 8px 10px; margin: 0 -10px 4px; border-radius: 6px; text-decoration: none; color: var(--text); }
.guide-hit:hover { background: var(--hover); }
.guide-hit b { display: block; color: var(--text-strong); }
.guide-hit span { font-size: 12px; color: var(--muted); }
@media (max-width: 700px) {
  .guide { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 80vh; height: 80dvh; }
  .guide-nav { border-right: none; border-bottom: 1px solid var(--border); display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; padding: 8px; align-items: center; }
  .guide-q { flex: 0 0 150px; margin: 0; }
  .guide-group { display: none; }
  .guide-nav a { white-space: nowrap; flex: none; }
  .guide-body { padding: 12px 16px 24px; }
  .guide-table td:first-child { white-space: normal; }
}

/* --------- layout «Orizzonte» (horizon.js): grafico a tutta finestra, barre e pannelli come isole di vetro --------- */
.hud-edge, .hud-pin, .hud-card { display: none; }
body:not(.layout-hud) #drawTools .hud-pin { display: none; } /* .toolbar-left button (display: grid) vince su .hud-pin: la puntina serve solo nell'Orizzonte */
body.layout-hud .hud-card.off { display: none; }
#hudBtn.active { color: var(--accent); text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }
@media (min-width: 641px) and (max-width: 900px) { #hudBtn { display: none !important; } } /* tra 641 e 900 px niente Orizzonte; sul telefono (≤ 640 px) c'è la versione compatta (layout-hudm), il pulsante sta nel menu «⋯» */
/* niente @media: la classe layout-hud la mette horizon.js solo da 901 px, e nei grafici della griglia (iframe più stretti)
   quando la pagina principale è in Orizzonte */
body.layout-hud {
  --hud-gap: 8px;
  --hud-top-h: 40px;   /* isole un po' più compatte delle barre del layout classico (46 e 44 px) */
  --hud-tools-w: 46px;
  --glass: color-mix(in srgb, var(--panel) 64%, transparent);
  --glass-line: color-mix(in srgb, var(--text) 14%, transparent);
}
body.layout-hud .app { position: relative; }
body.layout-hud .main { position: relative; }
body.layout-hud .footer, body.layout-hud .rp-show, body.layout-hud .rp-hide { display: none !important; }
body.layout-hud :is(.topbar, #drawTools, #rightPanel, #bottom) {
  position: absolute; border: 1px solid var(--glass-line); border-radius: 12px; background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 12px 40px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.05);
  transition: opacity .22s ease, transform .22s ease, visibility 0s;
}
/* filo di luce sul bordo superiore delle isole */
body.layout-hud :is(.topbar, #rightPanel, #bottom)::after {
  content: ''; position: absolute; left: 18px; right: 18px; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 75%, transparent), transparent); opacity: .7;
}
/* --hud-fl/ft/fr/fb (horizon.js, confine()): con la griglia barra e strumenti stanno dentro il primo grafico */
body.layout-hud .topbar { top: calc(var(--hud-ft, 0px) + var(--hud-gap)); left: calc(var(--hud-fl, 0px) + var(--hud-gap)); right: calc(var(--hud-fr, 0px) + var(--hud-gap)); z-index: 30; height: var(--hud-top-h); padding: 0 4px; gap: 0; border-radius: 10px; }
body.layout-hud .topbar .tb-btn { padding: 5px 7px; }
body.layout-hud .topbar .tb-btn.icon { padding: 5px 6px; }
body.layout-hud .topbar .tf-group button { padding: 5px 6px; }
body.layout-hud .topbar .tb-select { padding: 5px; }
body.layout-hud .topbar .tb-sep { height: 16px; margin: 0 3px; }
body.layout-hud .topbar .brand { padding: 0 2px; }
body.layout-hud #drawTools { left: calc(var(--hud-fl, 0px) + max(2px, var(--hud-gap) - 5px)); top: calc(var(--hud-ft, 0px) + (100% - var(--hud-ft, 0px) - (var(--hud-fb, 0px) + var(--hud-pin-b, 0px) + var(--hud-wide-b, 0px))) / 2); transform: translateY(-50%);
  max-height: calc(100% - var(--hud-ft, 0px) - (var(--hud-fb, 0px) + var(--hud-pin-b, 0px) + var(--hud-wide-b, 0px)) - 2 * var(--hud-gap)); z-index: 27; width: var(--hud-tools-w); padding: 3px 0; gap: 0; border-radius: 10px; }
body.layout-hud #drawTools button:not(.tg-more, .hud-pin) { width: 42px; height: 37px; }
body.layout-hud #drawTools .tl-sep { width: 24px; margin: 2px 0; }
body.layout-hud #drawTools input[type=color] { margin: 3px 0; width: 24px; }
body.layout-hud #drawTools .grow { display: none; }
body.layout-hud #rightPanel, body.layout-hud.right-hidden #rightPanel { display: flex; right: var(--hud-gap); top: calc(var(--hud-top-h) + 2 * var(--hud-gap)); bottom: var(--hud-gap); z-index: 26; overflow: hidden; }
/* barra in alto nascosta: il pannello di destra sale fino al bordo; con il pannello in basso visibile si ferma sopra di lui (--hud-bottom-h, da horizon.js) */
body.layout-hud.hud-off-top #rightPanel { top: var(--hud-gap); }
body.layout-hud #rightPanel { transition: top .22s ease, bottom .22s ease; bottom: calc(var(--hud-gap) + var(--hud-bottom-h, 0px)); }
/* pannelli di destra e in basso fissati: il grafico finisce dove iniziano loro (--hud-right-w e --hud-pin-b, da horizon.js): la scala del prezzo
   e quella delle date restano libere e le candele si adattano all'altezza rimasta, come con il doppio clic sulla scala */
body.layout-hud .main #chartGrid { margin-right: var(--hud-right-w, 0px); margin-bottom: var(--hud-pin-b, 0px); }
/* strumenti fissati: il grafico (sfondo, griglia, legenda, marchio e volume) parte dal bordo e l'isola gli sta sopra, niente banda vuota a sinistra */
body.layout-hud.hud-bottom-wide #bottom { left: var(--hud-gap); right: var(--hud-gap); }
body.layout-hud #bottom { left: calc(var(--hud-tools-w) + 3 * var(--hud-gap)); right: calc(var(--hud-tools-w) + 3 * var(--hud-gap)); bottom: var(--hud-gap); z-index: 24; overflow: hidden; transition: opacity .22s ease, transform .22s ease, visibility 0s, left .25s ease, right .25s ease; }
/* sfocatura solo sulle isole piccole: il browser la ricalcola sotto tutta l'isola a ogni ridisegno del grafico,
   sui pannelli grandi (watchlist, editor) costerebbe di più e quasi opachi non si vedrebbe comunque */
body.layout-hud #rightPanel { --glass: color-mix(in srgb, var(--panel) 82%, transparent); }
/* l'isola ha overflow: hidden: la maniglia del bordo sinistro (fuori dal pannello nel layout classico) qui sta dentro, larga abbastanza da afferrarla */
body.layout-hud #rightPanel .rp-resizer { left: 0; width: 10px; }
body.layout-hud #rightPanel .rp-resizer:hover, body.layout-hud #rightPanel .rp-resizer.drag { background: linear-gradient(to right, var(--accent) 0 3px, transparent 3px); }
body.layout-hud #bottom { --glass: color-mix(in srgb, var(--panel) 86%, transparent); }
body.layout-hud :is(#rightPanel, #bottom) { -webkit-backdrop-filter: none; backdrop-filter: none; }
body.layout-hud #bottom .CodeMirror, body.layout-hud #bottom .CodeMirror-gutters, body.layout-hud #bottom .ed-console { background: transparent; }
body.layout-hud .rp-tabs, body.layout-hud .tabs, body.layout-hud .pane-head { border-bottom-color: var(--glass-line); }
/* bordo trascinabile del pannello in basso: dentro l'isola, sul suo lato superiore */
body.layout-hud #bottom > .resizer { position: absolute; top: 0; left: 24px; right: 24px; height: 5px; background: transparent; border-radius: 3px; z-index: 3; }
body.layout-hud #bottom > .resizer:hover, body.layout-hud #bottom > .resizer.drag { background: var(--accent); }
/* isole ritirate verso il loro bordo */
body.layout-hud :is(.topbar, #drawTools, #rightPanel, #bottom).hud-off { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .22s ease, transform .22s ease, visibility 0s .22s; }
body.layout-hud .topbar.hud-off { transform: translateY(-14px); }
body.layout-hud #drawTools.hud-off { transform: translate(-14px, -50%); }
body.layout-hud #rightPanel.hud-off { transform: translateX(14px); }
body.layout-hud #bottom.hud-off { transform: translateY(14px); }
/* legenda fuori dalle isole visibili */
body.layout-hud .chart-cell[data-cell="0"] .legend-pane:first-child { transition: transform .22s ease; }
body.layout-hud:not(.hud-off-top) .chart-cell[data-cell="0"] .legend-pane:first-child { transform: translateY(calc(var(--hud-top-h) + var(--hud-gap) + var(--hud-legend-extra, 0px))); }
/* a sinistra la legenda sta al bordo: le righe che la barra degli strumenti coprirebbe si spostano da sole (Horizon.avoidTools) */

/* strisce sui bordi della finestra che richiamano le isole; un filo luminoso dice dov'è quella ritirata */
body.layout-hud .hud-edge { display: block; position: fixed; z-index: 29; pointer-events: none; } /* sopra il grafico e le isole di destra e basso, sotto barra in alto (30): la striscia più larga non la copre */
body.layout-hud.hud-off-top .hud-edge-top, body.layout-hud.hud-off-tools .hud-edge-tools,
body.layout-hud.hud-off-right .hud-edge-right, body.layout-hud.hud-off-bottom .hud-edge-bottom { pointer-events: auto; }
.hud-edge-top { left: var(--hud-fl, 0px); right: var(--hud-fr, 0px); top: var(--wco-h, 0px); height: 12px; }
.hud-edge-bottom { left: 0; right: 0; bottom: 0; height: 12px; }
.hud-edge-tools { left: 0; top: calc(var(--hud-ft, 0px) + var(--wco-h, 0px)); bottom: var(--hud-fb, 0px); width: 12px; }
.hud-edge-right { right: 0; top: var(--wco-h, 0px); bottom: 0; width: 12px; }
body.layout-hud .hud-edge::after { content: ''; position: absolute; border-radius: 2px; background: var(--accent); opacity: 0; transition: opacity .3s; box-shadow: 0 0 10px var(--accent); }
.hud-edge-top::after, .hud-edge-bottom::after { left: 50%; width: 90px; margin-left: -45px; height: 2px; }
.hud-edge-top::after { top: 3px; } .hud-edge-bottom::after { bottom: 3px; }
.hud-edge-tools::after, .hud-edge-right::after { top: 50%; height: 90px; margin-top: -45px; width: 2px; }
.hud-edge-tools::after { left: 3px; } .hud-edge-right::after { right: 3px; }
body.layout-hud.hud-off-top .hud-edge-top::after, body.layout-hud.hud-off-tools .hud-edge-tools::after,
body.layout-hud.hud-off-right .hud-edge-right::after, body.layout-hud.hud-off-bottom .hud-edge-bottom::after { opacity: .45; }
body.layout-hud .hud-edge:hover::after { opacity: 1; }

/* puntina: tiene l'isola sempre visibile */
body.layout-hud .hud-pin { display: grid; place-items: center; flex: none; width: 26px; height: 24px; margin: auto 4px; padding: 0; border: none; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; opacity: .55; }
body.layout-hud .hud-pin:hover { opacity: 1; background: var(--hover); color: var(--text-strong); }
body.layout-hud .hud-pin.on { opacity: 1; color: var(--accent); }
body.layout-hud .hud-pin.on:not(.hud-wide) svg { transform: rotate(-35deg); }
body.layout-hud #drawTools .hud-pin { margin: 3px auto 0; width: 30px; height: 22px; }
body.layout-hud #drawTools .hud-pin svg { width: 12px; height: 12px; }

/* pannello dei dati essenziali, accanto alla scala dei prezzi */
body.layout-hud .hud-card {
  display: block; position: absolute; top: var(--hud-gap); z-index: 5; min-width: 200px; padding: 8px 12px 9px; cursor: pointer; user-select: none;
  border: 1px solid var(--glass-line); border-radius: 12px; background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.35);
  font-size: 12px; font-variant-numeric: tabular-nums; transition: top .22s ease;
}
body.layout-hud:not(.hud-off-top) .hud-card { top: calc(var(--hud-top-h) + 2 * var(--hud-gap)); }
.hud-card .hc-title { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.hud-card .hc-price { margin: 1px 0 3px; color: var(--text-strong); }
.hud-card .hc-price b { font-size: 20px; font-weight: 600; margin-right: 4px; }
.hud-card .hc-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); line-height: 1.6; }
.hud-card .hc-row span:last-child { color: var(--text); }
.hud-card .up { color: var(--up) !important; } .hud-card .down { color: var(--down) !important; }
.hud-card.compact .hc-row { display: none; }
.hud-card.compact .hc-price { margin-bottom: 0; }
body.focus-mode .hud-card { top: var(--hud-gap) !important; }
/* chi chiede meno trasparenze (o ha un PC lento e lo imposta nel sistema): vetro pieno, senza sfocatura */
@media (prefers-reduced-transparency: reduce) {
  body.layout-hud { --glass: var(--panel); }
  body.layout-hud :is(.topbar, #drawTools, #rightPanel, #bottom, .hud-card) { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* comandi a voce (voice.js): pulsante del microfono e fumetto con quel che ha sentito */
#micBtn.active { color: var(--down); animation: micPulse 1.6s ease-in-out infinite; }
@keyframes micPulse { 50% { text-shadow: 0 0 10px var(--down); filter: drop-shadow(0 0 4px var(--down)); } }
body.embed #micBtn { display: none !important; }
.voice-bubble { position: fixed; left: 50%; bottom: 64px; transform: translate(-50%, 12px); z-index: 90; max-width: min(560px, calc(100vw - 32px));
  background: var(--panel); color: var(--text-strong); border: 1px solid var(--border); border-left: 3px solid var(--muted); border-radius: 18px;
  padding: 8px 16px; font-size: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.voice-bubble.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
/* telefono: in alto (le finestre si aprono dal basso) e pulsante del microfono sul grafico, una frase per tocco */
@media (pointer: coarse) { .voice-bubble { top: calc(52px + env(safe-area-inset-top)); bottom: auto; } }
.voice-fab { position: absolute; right: 72px; bottom: 36px; z-index: 2; /* sotto la legenda (z-index 3): non copre i pulsanti degli indicatori */ width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--text-strong); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.voice-fab.active { background: var(--down); color: #fff; border-color: transparent; }
.voice-fab svg { width: 22px; height: 22px; }
#micBtn, .voice-fab { -webkit-touch-callout: none; user-select: none; touch-action: manipulation; } /* pressione lunga: niente menu né selezione */
.voice-bubble[data-kind=ok] { border-left-color: var(--up); }
.voice-bubble[data-kind=err] { border-left-color: var(--down); }
.voice-bubble[data-kind=wait] { border-left-color: var(--accent); }

/* ricerca simboli (symbolSearch in app.js): finestra di vetro in alto, come una barra di comando */
.modal.sym-modal {
  --ss-glass: color-mix(in srgb, var(--panel) 52%, transparent);
  --ss-line: color-mix(in srgb, var(--text) 13%, transparent);
  width: min(640px, 94vw); border-radius: 16px; border: 1px solid var(--ss-line); background: var(--ss-glass);
  -webkit-backdrop-filter: blur(16px) saturate(170%); backdrop-filter: blur(16px) saturate(170%);
  box-shadow: 0 30px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.07);
  position: relative; overflow: hidden; animation: ssIn .16s cubic-bezier(.2,.9,.3,1.2);
}
.modal.sym-modal::before { /* filo di luce sul bordo superiore, come le isole dell'Orizzonte */
  content: ''; position: absolute; left: 24px; right: 24px; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 80%, transparent), transparent);
}
@keyframes ssIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
.modal-bg:has(> .sym-modal) { background: rgba(5,8,15,.38); }
@media (min-width: 641px) { .modal-bg:has(> .sym-modal) { place-items: start center; padding-top: 11vh; } }
.sym-modal .modal-head { display: none; }
.sym-modal .modal-body { padding: 12px 14px 0; display: flex; flex-direction: column; min-height: 0; }
.ss-box { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; border-radius: 11px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid var(--ss-line); transition: border-color .15s, box-shadow .15s; }
.ss-box:focus-within { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.ss-ico { color: var(--muted); flex: none; }
.ss-box:focus-within .ss-ico { color: var(--accent); }
.ss-field { position: relative; flex: 1; min-width: 0; }
.ss-field input, .ss-ghost { font: 500 17px/1.3 var(--font); letter-spacing: .01em; padding: 9px 0; }
.ss-field input { width: 100%; border: none; background: transparent; color: var(--text-strong); position: relative; z-index: 1; }
.ss-field input:focus { border: none; }
.ss-field input::placeholder { color: var(--muted); font-weight: 400; }
.ss-ghost { position: absolute; inset: 0; white-space: pre; overflow: hidden; pointer-events: none; }
.ss-ghost .ss-typed { color: transparent; }
.ss-ghost .ss-rest { color: color-mix(in srgb, var(--muted) 85%, transparent); }
.ss-tab { flex: none; opacity: 0; transition: opacity .12s; }
.ss-tab.on { opacity: 1; }
.sym-modal kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 5px; font: 600 10px/1.5 var(--font); text-align: center;
  color: var(--text); background: color-mix(in srgb, var(--text) 9%, transparent); border: 1px solid var(--ss-line); border-bottom-width: 2px; }
.ss-x { flex: none; width: 28px; height: 28px; border: none; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.ss-x:hover { background: var(--hover); color: var(--text-strong); }
.sym-modal .filter-row { margin: 10px 0 6px; }
.sym-modal .chip { background: color-mix(in srgb, var(--text) 7%, transparent); border: 1px solid transparent; transition: background .12s; }
.sym-modal .chip:hover { background: color-mix(in srgb, var(--text) 13%, transparent); }
.sym-modal .chip.active { background: color-mix(in srgb, var(--accent) 85%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, #fff 10%); }
.sym-modal .ss-src { background: color-mix(in srgb, var(--bg) 55%, transparent); border-color: var(--ss-line); border-radius: 8px; }
.sym-modal .results { margin: 0 -14px; padding: 0 8px 6px; max-height: 50vh; min-height: 120px; border-top: 1px solid var(--ss-line); }
.ss-group { position: sticky; top: 0; z-index: 1; padding: 9px 8px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  background: linear-gradient(var(--ss-glass), color-mix(in srgb, var(--panel) 0%, transparent)); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.ss-group span { color: #F7C948; }
.sym-modal .result { border: none; border-radius: 9px; padding: 7px 10px; margin: 1px 0; position: relative; transition: background .08s; }
.sym-modal .result:hover { background: transparent; }
.sym-modal .result.sel { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 24%, transparent), color-mix(in srgb, var(--accent) 6%, transparent)); }
.sym-modal .result.sel::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.ss-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ss-main > div { min-width: 0; }
.ss-main .coin { width: 24px; height: 24px; flex: none; }
.ss-main .coin.coin-fb { display: grid; place-items: center; font-size: 12px; }
.ss-dot { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-strong);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, var(--panel)), color-mix(in srgb, var(--text) 18%, var(--panel))); }
.sym-modal .result .s { font-size: 13.5px; letter-spacing: .01em; }
.sym-modal .result .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sym-modal .result .tag { font-weight: 500; opacity: .8; }
.sym-modal .result .b.q { font-variant-numeric: tabular-nums; font-size: 12px; line-height: 1.35; }
.sym-modal .result .b.q b { display: block; color: var(--text-strong); font-weight: 600; }
.ss-keys { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin: 0 -14px; padding: 8px 14px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--ss-line); background: color-mix(in srgb, var(--bg) 25%, transparent); }
.ss-keys kbd { margin-right: 2px; }
.ss-keys .ss-fmt { margin-left: auto; cursor: help; }
/* Orizzonte: più trasparente, il grafico si vede sotto */
body.layout-hud .modal.sym-modal { --ss-glass: color-mix(in srgb, var(--panel) 30%, transparent); -webkit-backdrop-filter: blur(18px) saturate(190%); backdrop-filter: blur(18px) saturate(190%); }
body.layout-hud .modal-bg:has(> .sym-modal) { background: rgba(5,8,15,.16); }
@media (max-width: 640px) {
  .modal.sym-modal { width: 100vw; border-radius: 16px 16px 0 0; }
  .ss-keys > span:not(.ss-fmt) { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  /* niente sfocatura, ma la ricerca resta un po' traslucida: il grafico si intravede */
  .modal.sym-modal, body.layout-hud .modal.sym-modal { --ss-glass: color-mix(in srgb, var(--panel) 80%, transparent); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* selettore dei temi (Impostazioni grafico → Temi) */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-grid[hidden] { display: none; }
.theme-card { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.theme-card:hover { border-color: var(--hover-2); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-card small { color: var(--muted); font-size: 11px; }
.theme-prev { display: flex; align-items: flex-end; gap: 4px; height: 52px; padding: 6px 8px; border-radius: 4px; border: 1px solid rgba(128,128,128,.25); }
.theme-prev i { flex: 1; border-radius: 1px; }
.shape-row { display: flex; flex-wrap: wrap; gap: 6px; }
.shape-chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; }
.shape-chip:hover { border-color: var(--hover-2); }
.shape-chip.active { border-color: var(--accent); color: var(--text-strong); box-shadow: 0 0 0 1px var(--accent); }

/* --------- barra del titolo della finestra installata (Window Controls Overlay, js/titlebar.js) ---------
   Visibile solo quando la finestra dell'app lascia disegnare alla pagina la barra del titolo (display_override nel manifest);
   i tre pulsanti di sistema stanno a destra, nell'area env(titlebar-area-*). Mai nei grafici secondari della griglia. */
.wco-titlebar { display: none; }
/* body.wt-on (titlebar.js): finestra con la sovrapposizione dei controlli, oppure la barra richiesta con Shift+T (anche a schermo intero e in «solo grafico») */
@media all {
  body.wt-on:not(.embed) { --wco-h: env(titlebar-area-height, 40px); }
  body.wt-on:not(.embed) .wco-titlebar {
    display: flex; align-items: flex-end; gap: 2px; flex: none; position: relative; z-index: 40; height: var(--wco-h);
    padding: 0 calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)) 0 env(titlebar-area-x, 0px);
    background: var(--bg); border-bottom: 1px solid var(--border);
    -webkit-app-region: drag; app-region: drag; user-select: none;
  }
  body.wt-on:not(.embed, .wt-force).focus-mode .wco-titlebar { display: none; }
  body.wt-on:not(.embed, .wt-force).focus-mode { --wco-h: 0px; }
  body.wt-on:not(.embed) .topbar .brand { display: none; }
  body.wt-on:not(.embed) .wco-titlebar > * { -webkit-app-region: no-drag; app-region: no-drag; }
  body.wt-on:not(.embed) .wco-titlebar > .wt-drag { flex: 1; align-self: stretch; min-width: 40px; -webkit-app-region: drag; app-region: drag; }
  .wt-brand { align-self: center; padding: 0 8px 0 10px; display: flex; }
  .wt-brand .logo { width: 18px; height: 18px; }
  .wt-tabs { display: flex; align-items: flex-end; gap: 2px; min-width: 0; overflow: hidden; height: calc(100% - 4px); }
  .wt-tab { display: flex; align-items: center; gap: 6px; height: 100%; padding: 0 8px 0 10px; min-width: 70px; max-width: 220px; flex: 0 1 auto; cursor: pointer; white-space: nowrap; overflow: hidden;
    border-radius: 8px 8px 0 0; color: var(--muted); font-size: 12.5px; font-weight: 600; border: 1px solid transparent; border-bottom: none; position: relative; }
  .wt-tab:hover { background: var(--hover); color: var(--text); }
  .wt-tab.active { background: color-mix(in srgb, var(--text) 9%, var(--bg)); color: var(--text-strong); border-color: var(--border); margin-bottom: -1px; height: calc(100% + 1px); }
  .wt-tab.dragging { opacity: .45; }
  .wt-ico .coin { width: 16px; height: 16px; font-size: 9px; vertical-align: middle; }
  .wt-sym { overflow: hidden; text-overflow: ellipsis; }
  .wt-tf { color: var(--muted); font-weight: 500; font-size: 11px; }
  .wt-price { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
  .wt-chg { font-weight: 500; font-size: 11px; font-variant-numeric: tabular-nums; }
  .wt-chg.up { color: var(--up); }
  .wt-chg.down { color: var(--down); }
  .wt-x { background: none; border: none; color: var(--muted); font-size: 15px; line-height: 1; width: 18px; height: 18px; border-radius: 4px; padding: 0; cursor: pointer; flex: none; }
  .wt-x:hover { background: color-mix(in srgb, var(--text) 16%, transparent); color: var(--text-strong); }
  .wt-add { align-self: center; background: none; border: none; color: var(--muted); font-size: 18px; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; flex: none; }
  .wt-add:hover:not(:disabled) { background: var(--hover); color: var(--text-strong); }
  .wt-add:disabled { opacity: .35; cursor: default; }
  .wt-hide { display: none; align-self: center; background: none; border: none; color: var(--muted); font-size: 13px; width: 30px; height: 26px; border-radius: 6px; cursor: pointer; flex: none; }
  .wt-hide:hover { background: var(--hover); color: var(--text-strong); }
  body.wt-force .wt-hide { display: block; }
  @media (max-width: 900px) { .wt-price, .wt-chg { display: none; } }
}
/* barra in alto assoluta (Orizzonte o griglia nel layout classico): sta sotto la barra del titolo, che occupa spazio nel flusso */
body.layout-hud .topbar { top: calc(var(--hud-ft, 0px) + var(--hud-gap) + var(--wco-h, 0px)); }
@media (min-width: 641px) and (not ((pointer: coarse) and (orientation: landscape) and (max-height: 500px))) {
  body:not(.layout-hud, .embed):has(#chartGrid:not([data-grid="1"])) .topbar { top: calc(var(--hud-ft, 0px) + var(--wco-h, 0px)); }
}

/* --------- Orizzonte sul telefono (≤ 640 px, anche con tocco in orizzontale): layout-hudm, la classe la mette horizon.js ---------
   Il grafico prende tutto lo schermo; la barra in basso diventa un'isola di vetro fluttuante e il pannello degli editor una scheda
   sopra di lei. La riga in fondo (.mob-fold) nasconde e mostra le due isole (body.mob-bars-off, già nel layout del telefono).
   Cassetti di strumenti e watchlist, e il menu «⋯», restano quelli del telefono. */
@media (max-width: 640px), (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  body.layout-hudm:not(.cell-wide, .embed, .focus-mode) {
    --glass: color-mix(in srgb, var(--panel) 70%, transparent);
    --glass-line: color-mix(in srgb, var(--text) 14%, transparent);
    --hudm-bar: 46px;
    --hudm-gap: calc(20px + env(safe-area-inset-bottom));
    .app { position: relative; }
    .main { position: absolute; inset: 0; }
    .footer, .resizer { display: none; }
    &:not(.tb-more) .topbar { position: fixed; left: 8px; right: 8px; bottom: var(--hudm-gap); order: 0; height: var(--hudm-bar); z-index: 40; border: 1px solid var(--glass-line); border-radius: 16px; background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
    .bottom { position: fixed; left: 8px; right: 8px; bottom: calc(var(--hudm-gap) + var(--hudm-bar) + 8px); height: min(300px, 42dvh); z-index: 39; border: 1px solid var(--glass-line); border-radius: 16px; background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); box-shadow: 0 10px 30px rgba(0,0,0,.4); overflow: hidden; }
    .bottom.collapsed { height: 34px !important; }
    .bottom :is(.tabs, .ed-toolbar, .ed-console, .tester, .alerts-pane, .ed-main) { background: transparent; border-color: var(--glass-line); }
    .mob-fold { position: fixed; left: 0; right: 0; bottom: env(safe-area-inset-bottom); order: 0; height: 20px; z-index: 41; }
    &.show-right .right, &.show-draw .toolbar-left { bottom: calc(var(--hudm-gap) + var(--hudm-bar) + 8px); }
    &.mob-bars-off .main { bottom: 0; }
  }
}
