:root {
  --bg: #0b0907; --card: #16120b; --card2: #1f1910; --line: #2b2316;
  --fg: #f3ead4; --muted: #9a8c70; --gold: #f2c14e; --gold-ink: #261c05;
  --up: #4ecb71; --down: #ef5b5b; --blue: #6ea8ff; --violet: #c78bff;
  --radius: 16px; --tab-h: 62px;
  --safe-top: calc(env(safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
}
:root[data-theme="light"] {
  --bg: #f6f1e6; --card: #ffffff; --card2: #f1e9d6; --line: #e6dcc4;
  --fg: #2a2214; --muted: #8a7c5e; --gold: #b9831a; --gold-ink: #fff;
  --up: #1e9e4a; --down: #d03a3a; --blue: #2f6fd1; --violet: #8a45c9;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 16px calc(var(--tab-h) + 24px + var(--safe-bottom)); }
#view { padding-top: calc(14px + var(--safe-top)); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h1 { font-size: 26px; margin: 0; letter-spacing: -.3px; }
h2 { font-size: 13px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); } .gold { color: var(--gold); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.gold { background: linear-gradient(160deg, var(--card2), var(--card)); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
.hero-price { font-size: 38px; font-weight: 700; letter-spacing: -1px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--card2); }
.chip.up { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.chip.down { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); }
.chip.gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }

.gauge { position: relative; width: 112px; height: 112px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .bg { stroke: var(--line); } .gauge .fg { stroke: var(--gold); transition: stroke-dashoffset .8s ease; }
.gauge .t { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge .t b { font-size: 24px; } .gauge .t span { font-size: 11px; color: var(--muted); }

.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600; width: 100%;
  background: var(--gold); color: var(--gold-ink); cursor: pointer; transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.98); } .btn[disabled] { opacity: .5; }
.btn.ghost { background: var(--card2); color: var(--fg); }
.btn.danger { background: color-mix(in srgb, var(--down) 20%, transparent); color: var(--down); }
.btn.sm { width: auto; padding: 7px 12px; font-size: 13px; }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 7px 0; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--gold); color: var(--gold-ink); }

.list > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list > div:first-child { border-top: 0; }
.list .k { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .k { color: var(--muted); font-size: 12px; } .stat .v { font-size: 19px; font-weight: 700; margin-top: 2px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.bull { background: var(--up); } .dot.bear { background: var(--down); }
.bar { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.mood { display: flex; height: 9px; border-radius: 99px; overflow: hidden; background: var(--line); }
.mood i:first-child { background: var(--up); } .mood i:last-child { background: var(--down); }

.chartbox { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 6px 4px; margin: 12px 0; }
canvas { width: 100%; display: block; touch-action: pan-y; }
.tip { position: absolute; top: 8px; left: 10px; font-size: 12px; background: color-mix(in srgb, var(--card) 85%, transparent);
  padding: 4px 8px; border-radius: 8px; pointer-events: none; display: none; line-height: 1.35; backdrop-filter: blur(4px); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 2px 8px 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; color: var(--fg); font: inherit; margin-bottom: 8px; text-align: left; }
.menu .ic { font-size: 20px; width: 28px; text-align: center; } .menu .go { margin-left: auto; color: var(--muted); }

input[type=number], input[type=text] { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  color: var(--fg); font: inherit; outline: none; } input:focus { border-color: var(--gold); }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--gold); } .switch input:checked + i::after { transform: translateX(18px); }
.step { display: flex; align-items: center; gap: 8px; } .step button { width: 32px; height: 32px; border-radius: 10px; border: 0;
  background: var(--card2); color: var(--fg); font-size: 18px; } .step b { min-width: 52px; text-align: center; }

a { color: var(--gold); text-decoration: none; }
.news a { color: var(--fg); display: block; } .news small { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; }
.skeleton { height: 90px; border-radius: var(--radius); margin-bottom: 12px; background: linear-gradient(90deg, var(--card), var(--card2), var(--card)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.note { font-size: 12px; color: var(--muted); text-align: center; margin: 18px 6px; }

#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 0;
  padding: 6px 8px calc(6px + var(--safe-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 5; }
#tabs button { flex: 1; max-width: 110px; border: 0; background: none; color: var(--muted); display: grid; justify-items: center; gap: 2px;
  font: inherit; font-size: 11px; padding: 4px 0; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--gold); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 22px + var(--safe-bottom)); transform: translate(-50%, 20px); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 9; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.seg.scroll { overflow-x: auto; scrollbar-width: none; } .seg.scroll::-webkit-scrollbar { display: none; } .seg.scroll button { flex: none; padding: 7px 12px; white-space: nowrap; }
.rowbtn { cursor: pointer; } .rowbtn:active { opacity: .6; }
details.card summary { cursor: pointer; list-style: none; } details.card[open] summary { margin-bottom: 8px; }

/* ---- тёмный премиальный стиль ---- */
body { background: radial-gradient(1100px 520px at 50% -120px, rgba(242,193,78,.16), transparent 62%), var(--bg); background-attachment: fixed; }
.card { background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,0)), var(--card); box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35); }
.card.gold { background: radial-gradient(420px 160px at 20% 0%, rgba(242,193,78,.14), transparent 70%), linear-gradient(160deg, var(--card2), var(--card)); box-shadow: 0 0 0 1px rgba(242,193,78,.12) inset, 0 10px 30px rgba(0,0,0,.45); }
.hero-price { background: linear-gradient(180deg, #fff1c9, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn { box-shadow: 0 6px 18px rgba(242,193,78,.22); } .btn.ghost, .btn.danger { box-shadow: none; }
#tabs { background: rgba(11,9,7,.82); }
.stat { background: linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--card); }
.gauge .fg { filter: drop-shadow(0 0 6px rgba(242,193,78,.55)); }

.spark { width: 60px; height: 22px; flex: none; margin: 0 8px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; } .grid3 b { font-size: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; } .tile { border-radius: 12px; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; border: 1px solid var(--line); } .tile b { font-size: 13px; } .tile span { font-size: 12px; opacity: .9; } .tile:active { opacity: .6; }
