:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #15181e;
  --muted: #5f6673;
  --border: #e3e6eb;
  --accent: #2563eb;
  --up: #0f8a5f;
  --down: #c73a3a;
  --warn: #b7791f;
  --radius: 10px;
  --fng-xfear: #c73a3a;
  --fng-fear: #e07b39;
  --fng-neutral: #c9a400;
  --fng-greed: #6aa84f;
  --fng-xgreed: #0f8a5f;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --text: #e8eaee;
    --muted: #98a0ad;
    --border: #262c35;
    --accent: #6ea0ff;
    --up: #3ecf8e;
    --down: #ff6b6b;
    --warn: #f0b44c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.search { position: relative; flex: 1; max-width: 360px; }
.search input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.suggest { position: absolute; z-index: 10; top: 40px; left: 0; right: 0; margin: 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.suggest a { display: block; padding: 8px 12px; color: var(--text); }
.suggest li.active a, .suggest a:hover { background: var(--bg); text-decoration: none; }
.logo { font-weight: 800; letter-spacing: 0.08em; color: var(--text); }
.nav { display: flex; gap: 20px; font-size: 15px; }
.nav a { color: var(--muted); }

/* .wrap задаёт боковые поля; отступы сверху и снизу задаём отдельно, чтобы .wrap их не перебил */
main.wrap { padding-top: 24px; padding-bottom: 48px; }
h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 4px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.cards, .fx { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card, .fx-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.card-label, .fx-label { color: var(--muted); font-size: 13px; }
.card-value, .fx-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.prices { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.prices th, .prices td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.prices th { color: var(--muted); font-weight: 500; font-size: 13px; }
.prices th a { color: inherit; }
.prices th.sorted a { color: var(--text); }
.prices tbody tr:hover { background: var(--bg); }
.spark-cell { padding-top: 4px; padding-bottom: 4px; }
.spark { display: block; }
.spark.up { color: var(--up); }
.spark.down { color: var(--down); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: 6px 14px; color: var(--muted); font-size: 14px; }
.segmented a.active { background: var(--surface); color: var(--text); font-weight: 600; }
.segmented a:hover { text-decoration: none; color: var(--text); }

.pager { display: flex; gap: 6px; justify-content: center; margin: 16px 0 4px; }
.pager a, .pager span { min-width: 36px; padding: 6px 10px; text-align: center; border: 1px solid var(--border); border-radius: 8px; }
.pager .current { background: var(--surface); font-weight: 600; }
.prices tbody tr:last-child td { border-bottom: 0; }
.prices .num { text-align: right; }
.coin-name { font-weight: 600; }
/* Длинные названия обрезаются многоточием, тикер виден всегда, полное имя в подсказке */
.coin-link { color: var(--text); display: inline-flex; align-items: center; gap: 8px; max-width: 280px; vertical-align: middle; }
.coin-link .coin-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-link .coin-sym { flex: none; }
.fav { vertical-align: middle; }
.coin-link:hover { text-decoration: none; }
.coin-link:hover .coin-name { text-decoration: underline; }
.logo { border-radius: 50%; flex: none; }
.fav { background: none; border: 0; padding: 0 6px 0 0; font-size: 15px; line-height: 1; color: var(--border); cursor: pointer; }
.fav:hover { color: var(--muted); }
.fav.on { color: #f5b301; }
.fav-lg { font-size: 26px; margin-left: auto; }
.segmented button { padding: 6px 12px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.coin-head { display: flex; align-items: center; gap: 12px; }
.coin-head h1 { margin: 0; }
.logo-lg { border-radius: 50%; flex: none; }
.price-block { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; margin: 16px 0 20px; font-variant-numeric: tabular-nums; }
.price-main { font-size: 34px; font-weight: 700; }
.price-rub { font-size: 20px; color: var(--muted); }
.price-change { font-size: 17px; font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 18px; margin: 0 0 12px; }
.chart { height: 380px; }
.coin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.coin-grid .panel { margin-bottom: 0; }
.coin-grid + .panel { margin-top: 16px; }
.converter { display: grid; gap: 10px; }
.converter label { display: flex; gap: 8px; align-items: center; }
.converter input, .converter select { height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.converter input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.converter label > span { width: 130px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.converter select { width: 130px; flex: none; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-variant-numeric: tabular-nums; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; }
.about p { max-width: 72ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 0; list-style: none; }

/* --- Сеть Биткоин, индекс страха и жадности, сравнение, конвертер --- */
.card-link { color: var(--text); }
.card-link:hover { text-decoration: none; border-color: var(--accent); }
.toolbar h2 { margin: 0; }
.fng-xfear { color: var(--fng-xfear); stroke: var(--fng-xfear); }
.fng-fear { color: var(--fng-fear); stroke: var(--fng-fear); }
.fng-neutral { color: var(--fng-neutral); stroke: var(--fng-neutral); }
.fng-greed { color: var(--fng-greed); stroke: var(--fng-greed); }
.fng-xgreed { color: var(--fng-xgreed); stroke: var(--fng-xgreed); }
.fng-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: currentColor; margin-right: 8px; vertical-align: 1px; }
.gauge-box { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.gauge { max-width: 100%; height: auto; }
.gauge-needle { stroke: var(--text); }
.gauge-hub { fill: var(--text); }
.gauge-value { font-size: 44px; font-weight: 700; line-height: 1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.gauge-label { font-size: 18px; font-weight: 600; margin-top: 4px; }
.bar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: center; }
.countdown div { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 4px; }
.countdown span { display: block; font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown small { color: var(--muted); font-size: 13px; }
table.kv { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.kv th, .kv td { padding: 7px 0; border-bottom: 1px solid var(--border); text-align: left; }
.kv th { color: var(--muted); font-weight: 500; font-size: 13px; }
.kv .num { text-align: right; padding-left: 12px; }
.kv tbody tr:last-child td { border-bottom: 0; }
tr.next td { font-weight: 600; }
.table-scroll.flat { border: 0; border-radius: 0; background: none; }
.vs-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.vs-title a { color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.prices.compare td:first-child { color: var(--muted); }
.legend { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-left: 6px; }
.swatch.accent { background: var(--accent); }
.swatch.warn { background: var(--warn); }
.compare-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.compare-form select { height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; flex: 1 1 200px; min-width: 0; }
.btn { height: 40px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.links.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.more-links { margin: 16px 0 0; }
.halving-mini p { margin: 0; }

/* --- Калькуляторы --- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-card { color: var(--text); margin: 0; }
.tool-card:hover { text-decoration: none; border-color: var(--accent); }
.tool-card p { margin: 0; font-size: 14px; }
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tool .panel { margin-bottom: 0; }
.tool + .panel { margin-top: 16px; }
.tool-form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field-label { color: var(--muted); font-size: 13px; }
.field-input { display: flex; align-items: center; gap: 8px; }
.field input, .field select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; min-width: 0; }
.field input { font-variant-numeric: tabular-nums; }
.field-suffix { color: var(--muted); white-space: nowrap; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-ghost { background: none; color: var(--accent); border: 1px solid var(--border); }
.tool-answer { font-size: 22px; line-height: 1.3; margin-bottom: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tool-sub { margin: 0 0 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tool-result .stats { margin-bottom: 12px; }
.tool-errors { margin: 0 0 12px; padding: 10px 14px 10px 28px; border: 1px solid var(--down); border-radius: 8px; color: var(--down); }
.prices th .small { font-weight: 400; }
.prices.wrap-first td:first-child { white-space: normal; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.presets .tag { font-size: 13px; padding: 4px 10px; }
.screener-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.screener-form .tool-actions, .screener-form .check { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.heatmap-box { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #1f2937; }
.heatmap { display: block; width: 100%; height: auto; }
.heatmap rect { stroke: #111827; stroke-width: 1.5; }
.heatmap a:hover rect { opacity: 0.85; }
.heatmap text { fill: #fff; text-anchor: middle; font-family: inherit; pointer-events: none; }
.heatmap-tall { display: none; }
.swatch-box { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.account-link { font-size: 15px; white-space: nowrap; }
.flashes { margin-bottom: 16px; }
.reminder { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 16px; padding: 10px 14px; border: 1px solid var(--warn); border-radius: 8px; background: var(--surface); font-size: 14px; }
.reminder span { flex: 1 1 320px; }
.reminder-btn { font-size: 14px; color: var(--accent); }
.flashes p { margin: 0 0 8px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); }
.auth { max-width: 460px; margin: 0 auto; }
.auth h1 { margin-bottom: 16px; }
.auth .lead { margin-top: -8px; }
.auth .panel + .panel { margin-top: 16px; }
.auth-form { display: grid; gap: 12px; }
.auth-form h2 { margin: 0; }
.auth-form p { margin: 0; }
.auth .field input, .auth-form .field input, .inline-form .field input { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.inline-form .field { flex: 1 1 220px; }
.btn-danger { background: var(--down); }
.check span { flex: 1; }
.legal h2 { font-size: 18px; margin: 20px 0 8px; }
.legal mark { background: #fde68a; color: #111; padding: 0 4px; border-radius: 4px; }
.alloc-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--bg); }
.alloc-bar span { display: block; height: 100%; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 12px 0 0; list-style: none; font-size: 14px; }
.alloc-legend .swatch-box { margin-left: 0; }
.tx-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.tx-form .field select, .tx-form .field input { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; min-width: 0; }
.tx-form .tx-note { grid-column: span 2; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.link-btn:hover { color: var(--down); }
.alert-off { opacity: 0.6; }
form.inline { display: inline; }
.nowrap { white-space: nowrap; }
.channels { border: 0; padding: 0; margin: 0; min-width: 0; }
.channel-boxes { display: flex; gap: 16px; height: 40px; align-items: center; }
.news-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.news-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.news-title { font-weight: 600; font-size: 17px; color: var(--text); }
.news-summary { margin: 6px 0 4px; }
.news-meta { margin: 0; }
.news-mini { padding-left: 18px; margin: 0 0 8px; }
.news-mini li { margin-bottom: 6px; }
.tag-on { border-color: var(--accent); color: var(--accent); }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.letters a { min-width: 32px; padding: 4px 8px; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.glossary-letter { margin: 0; }
.glossary dl { margin: 0; }
.glossary dt { font-weight: 600; margin-top: 10px; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 2px 0 0; font-size: 14px; }
.article { max-width: 820px; }
.article h2 { font-size: 21px; margin: 24px 0 8px; }
.article table { border-collapse: collapse; margin: 12px 0; font-size: 15px; }
.article th, .article td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.article li { margin-bottom: 4px; }
.faq details { border-top: 1px solid var(--border); padding: 10px 0; }
.faq details:first-of-type { border-top: 0; padding-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; max-width: 72ch; }
.rebalance-rows { display: grid; gap: 8px; }
.rebalance-head, .rebalance-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 8px; }
.rebalance-head { color: var(--muted); font-size: 13px; }
.rebalance-row select, .rebalance-row input { width: 100%; height: 40px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; min-width: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; white-space: normal; }
.up { color: var(--up); }
.down { color: var(--down); }

.meta { color: var(--muted); font-size: 13px; margin: 10px 2px; }
.meta.stale, .stale { color: var(--warn); }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; border: 1px solid currentColor; }
.badge.ok { color: var(--up); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--down); }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 20px 0 32px; }
.site-footer p { margin: 4px 0; }

@media (max-width: 900px) {
  .hide-md { display: none; }
  .coin-link { max-width: 220px; }
  .coin-grid { grid-template-columns: 1fr; }
  .tool { grid-template-columns: 1fr; }
  .chart { height: 300px; }
}

@media (max-width: 640px) {
  .header-row { gap: 10px; }
  .nav { display: none; }
  h1 { font-size: 24px; }
  .hide-sm { display: none; }
  .coin-link { max-width: 140px; gap: 6px; }
  .fav { padding-right: 2px; }
  .prices th, .prices td { padding: 10px 8px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card-value { font-size: 17px; }
  .table-scroll.flat .prices th, .table-scroll.flat .prices td { padding: 10px 6px; }
  .countdown { gap: 6px; }
  .heatmap-wide { display: none; }
  .heatmap-tall { display: block; }
  .tx-form .tx-note { grid-column: auto; }
  .countdown span { font-size: 26px; }
  .nav { gap: 12px; }
}
