:root, [data-theme="light"] {
  --bg: #F4F5F9; --card: #FFFFFF; --line: #E3E6EE; --ink: #0F1729; --muted: #5B6474; --on-ink: #FFFFFF;
  --acc: #4F46E5; --acc-soft: #EEEDFD; --seg: #E9EBF2; --hover: #F0F1F6;
  --rise: #067A52; --rise-soft: #E3F5EC; --fall: #C8293E; --fall-soft: #FBE7EA; --neu: #8A6A12; --neu-soft: #FBF3DE;
  --chart-rise: #0E9F6E; --chart-fall: #E5484D; --grid: #EEF0F5; --shadow: 0 1px 2px rgba(15,23,41,.06), 0 4px 16px rgba(15,23,41,.04);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0D1117; --card: #161B24; --line: #262D3A; --ink: #E8ECF3; --muted: #9AA4B5; --on-ink: #0D1117;
  --acc: #8B85FF; --acc-soft: #25234D; --seg: #1E2430; --hover: #1C222D;
  --rise: #3DD39A; --rise-soft: #12352A; --fall: #FF7A88; --fall-soft: #3D1C24; --neu: #EBC15A; --neu-soft: #3A3014;
  --chart-rise: #2EBD85; --chart-fall: #F6465D; --grid: #1E2430; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--acc); text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: 'Space Grotesk', Inter, sans-serif; letter-spacing: -0.01em; margin: 0; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.rise { color: var(--rise); } .fall { color: var(--fall); }
.hidden { display: none !important; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.mark { width: 30px; height: 30px; } .mark circle { fill: var(--ink); } .mark path { stroke: var(--bg); stroke-width: 9; stroke-linecap: round; }
.word { font-family: Sora, Inter, sans-serif; font-weight: 700; font-size: 22px; letter-spacing: -0.04em; }
.nav { display: flex; gap: 22px; } .nav a { color: var(--muted); font-weight: 500; } .nav a.on { color: var(--ink); }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.theme { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--seg); }
.theme button { width: 40px; height: 34px; border: 0; border-radius: 9px; background: transparent; display: grid; place-items: center; }
.theme button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.theme svg, .tabbar svg, .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme button { color: var(--muted); } .theme button.on { color: var(--ink); }

/* кнопки, поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; }
.btn:hover { background: var(--hover); }
.btn-ink { background: var(--ink); color: var(--on-ink); border-color: var(--ink); } .btn-ink:hover { background: var(--ink); opacity: .9; }
.btn-acc { background: var(--acc); color: #fff; border-color: var(--acc); } .btn-acc:hover { background: var(--acc); opacity: .92; }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: 15px; }
.field { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 48px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.field:focus-within { border-color: var(--acc); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.rise { background: var(--rise-soft); } .pill.fall { background: var(--fall-soft); } .pill.neu { color: var(--neu); background: var(--neu-soft); }
.seg { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--seg); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; min-height: 34px; padding: 0 12px; border-radius: 9px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

/* главная */
.hero { text-align: center; padding: 56px 0 28px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.hero h1 { font-size: clamp(36px, 6vw, 64px); line-height: 1.05; max-width: 860px; letter-spacing: -0.02em; }
.hero h1 span { color: var(--acc); }
.hero p { margin: 0; color: var(--muted); font-size: 18px; max-width: 600px; }
.search { width: 100%; max-width: 560px; position: relative; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 10; padding: 6px; text-align: left; max-height: 360px; overflow: auto; }
.suggest a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink); }
.suggest a:hover, .suggest a.act { background: var(--hover); }
.section { margin: 28px 0; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }
.section-h h2 { font-size: 22px; }
.coins { padding: 4px 16px; }
.coin-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.coin-row:last-child { border-bottom: 0; }
.coin-row .nm { font-weight: 600; } .coin-row .sub { font-size: 12px; color: var(--muted); }
.coin-row .px { text-align: right; } .coin-row .px b { display: block; font-weight: 600; }
.coin-row .sig { min-width: 112px; text-align: right; }
.dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; }

/* монета */
.coin-head { display: flex; align-items: center; gap: 14px; padding: 24px 0 16px; flex-wrap: wrap; }
.coin-head h1 { font-size: 28px; } .coin-head .px { margin-left: auto; text-align: right; }
.coin-head .px b { font-size: 26px; display: block; }
.star { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--muted); }
.star.on { color: #E8A317; } .star svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; } .star.on svg { fill: currentColor; }
.grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.grid > .main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.grid > .side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 16px; }
.chart-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chart-bar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggles button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 5px 11px; }
.toggles button.on { color: var(--acc); border-color: var(--acc); background: var(--acc-soft); }
#chart { height: 420px; } #rsiChart { height: 120px; }
.lbl { font-size: 12px; color: var(--muted); }
.brief { background: var(--acc-soft); border-radius: 18px; padding: 16px 18px; display: flex; gap: 12px; line-height: 1.6; }
.brief svg { flex: none; width: 22px; height: 22px; stroke: var(--acc); fill: none; stroke-width: 1.8; stroke-linecap: round; margin-top: 2px; }
.gauge-card { padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge-card .t { align-self: stretch; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.gauge-card .lab { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 700; }
.list-card { padding: 6px 16px 8px; } .list-card h3 { font-size: 17px; padding: 12px 0 4px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row:last-child { border-bottom: 0; } .row .grow { flex: 1; min-width: 0; color: var(--muted); }
.lvl-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--seg), var(--hover), var(--seg)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* модалка, тост */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,8,15,.5); display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { position: relative; width: 100%; max-width: 420px; background: var(--card); border-radius: 22px; padding: 26px; border: 1px solid var(--line); }
.modal-box h2 { font-size: 22px; margin-bottom: 8px; }
.modal-x { position: absolute; right: 12px; top: 10px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 26px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; }

/* низ */
.foot { border-top: 1px solid var(--line); margin-top: 48px; }
.foot-in { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 22px 20px; font-size: 13px; color: var(--muted); }
.tabbar { display: none; }

/* телефон и Telegram */
@media (max-width: 720px) {
  .nav, #foot { display: none; }
  .hero { padding: 28px 0 12px; } .hero p { font-size: 16px; }
  #chart { height: 320px; }
  .coin-row { grid-template-columns: 40px minmax(0, 1fr) auto; } .coin-row .sig { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding: 4px 8px calc(10px + env(safe-area-inset-bottom)); }
  body { padding-bottom: 84px; }
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar a.on { color: var(--acc); } .tabbar svg { width: 22px; height: 22px; }
body.tg .top, body.tg #foot, body.tg .hero-site { display: none; }
body.tg .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding: 4px 8px calc(10px + env(safe-area-inset-bottom)); }
body.tg { padding-bottom: 84px; }

/* ===== v2: рабочая область, рисование, индикаторы ===== */
.work { display: flex; gap: 8px; align-items: stretch; }
.charts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.tools { display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 12px; background: var(--seg); align-self: flex-start; }
.tools button { width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.tools button:hover { background: var(--card); color: var(--ink); }
.tools button.on { background: var(--acc-soft); color: var(--acc); }
.tools button:disabled { opacity: .35; cursor: default; }
.tools .ico, .toggles .ico { width: 18px; height: 18px; }
.tools-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.toggles button { display: inline-flex; align-items: center; gap: 6px; }
#chart { position: relative; }
#chart.drawing { cursor: crosshair; }
.draw-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#oscChart { height: 130px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); min-height: 16px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.pane-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seg-sm button { min-height: 28px; padding: 0 9px; font-size: 12px; }
.seg-wrap { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.seg-wrap button { white-space: nowrap; }
.ind-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.ind-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 12px; cursor: pointer; font-size: 14px; }
.ind-row:hover { background: var(--hover); }
.ind-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--acc); flex: none; }
body.fs .chart-card { position: fixed; inset: 0; z-index: 40; border-radius: 0; overflow: auto; }
body.fs #chart { height: calc(100vh - 290px); min-height: 300px; }

/* настроение, идеи, сканер */
.mood { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.mood-lab { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 700; }
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.idea { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.idea:hover { border-color: var(--acc); }
.idea-h { display: flex; align-items: center; gap: 10px; }
.idea-h .dot { font-size: 9px !important; }
.idea-t { display: flex; gap: 6px; flex-wrap: wrap; }
.lock { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 18px 20px; flex-wrap: wrap; background: var(--acc-soft); border-color: transparent; }
.lock > div:nth-child(2) { flex: 1; min-width: 200px; }

/* Premium */
.prem-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 0; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.plan { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.plan h3 { font-size: 20px; }
.plan .price { font-family: 'Space Grotesk', sans-serif; font-size: 34px; font-weight: 700; }
.plan ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.plan-pro { border: 2px solid var(--acc); }

@media (max-width: 720px) {
  .work { flex-direction: column; }
  .tools { flex-direction: row; overflow-x: auto; max-width: 100%; align-self: stretch; scrollbar-width: none; }
  .tools button { flex: none; width: 40px; height: 40px; }
  .tools-sep { width: 1px; height: auto; margin: 6px 4px; }
  #oscChart { height: 110px; }
  .mood { padding: 12px 14px; gap: 10px; } .mood svg { width: 96px; height: auto; }
}

/* ===== v3: график TradingView ===== */
.mode-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tf-wrap { display: flex; align-items: center; gap: 8px; }
.tv-card { padding: 6px; overflow: hidden; }
.tv-box { height: 560px; }
.tv-box .tradingview-widget-copyright { font-size: 11px; text-align: right; padding: 4px 6px 0; }
.tv-box .tradingview-widget-copyright a { color: var(--muted); }
@media (max-width: 720px) {
  .tv-box { height: 470px; }
  .mode-bar .seg button { padding: 0 10px; }
  .tf-wrap { width: 100%; } .tf-wrap .seg { flex: 1; } .tf-wrap .seg button { flex: 1; }
}
