/* ============================================================
   CoinsCompare — тёмная тема (GitHub Dark), адаптив 360px → desktop
   Палитра по ТЗ:
     фон #0d1117 · поверхности #161b22/#1c2128 · границы #30363d
     текст #c9d1d9 / #8b949e · акцент #58a6ff
     зелёный #16c784 (покупка) · красный #ea3943 (продажа)
   ============================================================ */

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2128;
    --border: #30363d;
    --border-soft: #21262d;
    --text: #c9d1d9;
    --muted: #8b949e;
    --accent: #58a6ff;
    --accent-soft: rgba(88, 166, 255, .14);
    --up: #16c784;
    --up-soft: rgba(22, 199, 132, .12);
    --down: #ea3943;
    --down-soft: rgba(234, 57, 67, .12);
    --warn: #d29922;
    --warn-soft: rgba(210, 153, 34, .12);
    --radius: 10px;
    --radius-sm: 8px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; color: var(--accent); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }

/* Плавное появление блоков */
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fade-in .25s ease both; }

/* ---------- Шапка ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    background: rgba(13, 17, 23, .88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 58px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 16.5px;
    white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo b { color: var(--accent); }
.logo small { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .06em; margin-top: -2px; }

.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
    color: var(--muted);
    font-weight: 500;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(88, 166, 255, .35); }

.header-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
}
.header-search svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.header-search input {
    width: 200px;
    padding: 8px 12px 8px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, width .2s;
}
.header-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); width: 240px; }
.header-search input::placeholder { color: var(--muted); }

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.lang-link { padding: 6px 8px; border-radius: var(--radius-sm); color: var(--muted); line-height: 1; }
.lang-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.lang-link.is-active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(88, 166, 255, .35); }
.lang-sep { color: var(--border); }
.lang-select {
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.lang-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Основное ---------- */
main { flex: 1; padding: 24px 20px 44px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { margin: 0; font-size: clamp(21px, 3vw, 27px); font-weight: 700; letter-spacing: -.02em; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 720px; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 18px;
    margin-bottom: 14px;
    padding: 6px 13px;
    font-size: 13px;
}

/* ---------- Карточки и статистика ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 17px;
}
.stat-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-size: clamp(19px, 2.4vw, 24px); font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-extra { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat-extra a, .stat-link { color: var(--accent); }
.stat-link:hover { text-decoration: underline; }

.card-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.toolbar-spacer { flex: 1; }

.result-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- Формы ---------- */
.input, .select {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }

.search-field { position: relative; }
.search-field svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field .input { padding-left: 33px; width: 250px; }

.select option { background: var(--surface); color: var(--text); }

input[type="date"].input { color-scheme: dark; }

.field-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.field-group { display: flex; flex-direction: column; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted); }
.switch input { display: none; }
.slider { width: 34px; height: 19px; border-radius: 999px; background: var(--border); position: relative; flex: none; transition: background .2s; }
.slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(15px); }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: #262c36; border-color: #3f4753; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary { background: #1f6feb; border-color: #1f6feb; color: #fff; font-weight: 600; }
.btn-primary:hover { background: #2b7bff; border-color: #2b7bff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.icon-btn { padding: 8px 10px; }
.icon-btn.spin svg { animation: rotate .8s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 345px); min-height: 120px; -webkit-overflow-scrolling: touch; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface-2);
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); background: #232932; }
.tbl th .arr { font-size: 9px; margin-left: 4px; opacity: .95; }

.tbl tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.tbl tbody tr:nth-child(even) { background: rgba(255, 255, 255, .015); } /* зебра */
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr:hover { background: var(--accent-soft); }

.cell-main { display: flex; align-items: center; gap: 9px; }
.price-ticker { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.price-venues { display: flex; flex-direction: column; gap: 4px; }
.exchange-description { display: block; max-width: 420px; line-height: 1.45; color: var(--text-muted); }
.price-venue { white-space: nowrap; }
.coin-dot {
    width: 26px; height: 26px;
    border-radius: 50%;
    flex: none;
    display: grid;
    place-items: center;
    font-size: 9.5px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #1f6feb, #8957e5);
}
.ticker-name { font-weight: 700; font-family: var(--mono); letter-spacing: .02em; }
.sub-name { color: var(--muted); font-size: 12px; }

.exchange-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chart-mini {
    margin-left: 8px;
    font-size: 12px;
    line-height: 1;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 7px;
    white-space: nowrap;
}
.chart-mini:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.best-flag {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .05em;
    padding: 1.5px 6px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
}
.flag-buy  { color: #fff; background: var(--up); }
.flag-sell { color: #fff; background: var(--down); }

.time-cell { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.spread-chip {
    display: inline-block;
    padding: 2.5px 10px;
    border-radius: 999px;
    font-weight: 650;
    font-size: 12.5px;
    border: 1px solid transparent;
}
.chip-high { background: var(--up-soft); color: var(--up); border-color: rgba(22, 199, 132, .4); }
.chip-mid  { background: var(--warn-soft); color: var(--warn); border-color: rgba(210, 153, 34, .35); }
.chip-low  { background: rgba(139, 148, 158, .1); color: var(--muted); border-color: var(--border); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.status-pill .pdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-enabled { background: var(--up-soft); color: var(--up); border-color: rgba(22, 199, 132, .35); }
.st-disabled { background: var(--down-soft); color: var(--down); border-color: rgba(234, 57, 67, .35); }
.st-none { background: rgba(139, 148, 158, .1); color: var(--muted); border-color: var(--border); }

.load-more { display: flex; justify-content: center; padding: 14px; border-top: 1px solid var(--border); }

/* ---------- Вкладки ---------- */
.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    margin-bottom: 14px;
}
.tabs button {
    padding: 6px 15px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: #1f6feb; color: #fff; }

/* ---------- Страница тикера ---------- */
.coin-info { min-height: 0; margin-bottom: 14px; }
.coin-info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.coin-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -.01em;
}
.coin-desc {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.65;
}

.best-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 20px; }
.best-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.best-card .icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex: none;
}
.best-card.sell .icon { background: var(--down-soft); color: var(--down); }
.best-card.buy  .icon { background: var(--up-soft); color: var(--up); }
.best-price { font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }
.best-ex { font-size: 13px; color: var(--muted); }

.summary-strip {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.summary-item .stat-label { font-size: 10.5px; }
.summary-item .stat-value { font-size: 16.5px; margin-top: 2px; }

/* ---------- График ---------- */
.chart-controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.chart-box { position: relative; height: 480px; }
#chart { position: absolute; inset: 0; }

.chart-legend {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 5;
    pointer-events: none;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--muted);
    background: rgba(13, 17, 23, .82);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 11px;
    opacity: 0;
    transition: opacity .12s;
}
.chart-legend.show { opacity: 1; }
.chart-legend b { color: var(--text); font-size: 12.5px; }

.chart-msg {
    height: 100%;
    display: grid;
    place-items: center;
    color: var(--muted);
}

/* ---------- Состояния ---------- */
.spinner {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.state-block { padding: 64px 20px; text-align: center; color: var(--muted); }
.state-block .spinner { margin: 0 auto 14px; }
.state-block.compact { padding: 34px 20px; }

.skeleton-row td { color: transparent !important; border-color: transparent !important; }
.skeleton-row {
    background: linear-gradient(90deg, rgba(255,255,255,.02) 25%, rgba(255,255,255,.06) 50%, rgba(255,255,255,.02) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.25s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.error-banner {
    max-width: 640px;
    margin: 44px auto;
    padding: 22px 26px;
    border-radius: var(--radius);
    background: var(--down-soft);
    border: 1px solid rgba(234, 57, 67, .4);
    text-align: center;
}
.error-banner h3 { margin: 0 0 8px; color: var(--down); font-size: 16px; }
.error-banner p { color: var(--muted); margin: 0 0 16px; word-break: break-word; font-size: 13.5px; }
.error-banner code { color: var(--text); }

.empty-hint { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* Информационная карточка биржи */
.provider-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; padding: 18px; }
.provider-head { display: flex; align-items: center; gap: 14px; }
.provider-logo {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #1f6feb, #8957e5);
    flex: none;
}
.info-item .stat-label { margin-bottom: 2px; }
.info-item div.val { font-weight: 550; word-break: break-all; }

/* ---------- Подвал ---------- */
.footer {
    margin-top: 15px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 40px 0 18px;
    font-size: 12.5px;
    color: var(--muted);
}
.footer-inner { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-item { display: inline-flex; align-items: center; gap: 8px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--up); box-shadow: 0 0 7px rgba(22, 199, 132, .9); }
.dot.bad { background: var(--down); box-shadow: 0 0 7px rgba(234, 57, 67, .9); }

/* ---------- О проекте ---------- */

.about-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 22px;
}
.about-title { margin: 0 0 10px; font-size: 18px; font-weight: 700; }
.about-body  { margin: 0; color: var(--muted); line-height: 1.7; font-size: 14px; }

/* ---------- Подвал ---------- */

.footer-desc {
    width: 100%;
    margin: 0 0 6px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}
.footer-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* ---------- Модальное окно обратной связи ---------- */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    padding: 18px;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; max-width: 480px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: #fff; }
.modal .field-group { margin-bottom: 14px; }
.modal .field-label { margin-bottom: 5px; }
.modal .input { width: 100%; box-sizing: border-box; }
.feedback-result { font-size: 13px; margin: 0 0 10px; line-height: 1.5; }
.feedback-result[data-kind="ok"]   { color: var(--up); }
.feedback-result[data-kind="fail"] { color: var(--down); }
.modal .btn { width: 100%; margin-top: 4px; }
.modal .btn:disabled { opacity: .55; cursor: default; }

/* ---------- Страница статей ---------- */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.article-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}
.article-card:hover {
    border-color: var(--accent);
    background: var(--surface-2);
    text-decoration: none;
}

.article-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 22px;
    flex: none;
    background: var(--accent-soft);
}

.article-body {
    flex: 1;
    min-width: 0;
}

.article-title {
    font-size: 16px;
    font-weight: 650;
    margin-bottom: 4px;
    line-height: 1.3;
}

.article-brief {
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-date {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

@media (max-width: 720px) {
    .article-card { padding: 14px 14px; gap: 12px; }
    .article-icon { width: 40px; height: 40px; font-size: 18px; }
    .article-card .article-icon.img { width: 140px; height: 70px; }
    .article-title { font-size: 14.5px; }
}

/* ---------- Страница отдельной статьи ---------- */
.article-page {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 30px;
    margin-bottom: 20px;
}
.article-page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}
.article-page-head .page-title { margin: 0; flex: 1; }
.article-icon.lg {
    width: 54px; height: 54px;
    font-size: 26px;
    margin-top: 2px;
}
.article-icon.img { padding: 0; overflow: hidden; }
.article-icon.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article-card .article-icon.img { width: 200px; height: 100px; }
.article-brief.full {
    font-size: 15px;
    color: var(--text);
    line-height: 1.6;
    -webkit-line-clamp: none;
    display: block;
    overflow: visible;
}
.article-body-html {
    margin-top: 10px;
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--text);
    word-wrap: break-word;
}
.article-body-html h1, .article-body-html h2, .article-body-html h3, .article-body-html h4 {
    margin: 1.2em 0 .5em;
    line-height: 1.3;
}
.article-body-html h1:first-child, .article-body-html h2:first-child, .article-body-html h3:first-child, .article-body-html h4:first-child { margin-top: 0; }
.article-body-html p, .article-body-html ul, .article-body-html ol { margin: 0 0 1em; }
.article-body-html ul, .article-body-html ol { padding-left: 24px; }
.article-body-html a { color: var(--accent); }
.article-body-html img { max-width: 100%; border-radius: var(--radius-sm); }
.article-cover { margin: 18px 0; max-width: 960px; }
.article-cover img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: cover; border-radius: var(--radius-sm); }
.article-body-html blockquote {
    margin: 1em 0;
    padding: 8px 16px;
    border-left: 3px solid var(--accent);
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-body-html table { border-collapse: collapse; width: 100%; margin: 0 0 1em; }
.article-body-html th, .article-body-html td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
@media (max-width: 720px) {
    .article-page { padding: 18px 16px; }
    .article-page-head { gap: 12px; }
    .article-icon.lg { width: 44px; height: 44px; font-size: 21px; }
    .article-nav { flex-direction: column; }
    .article-nav-prev, .article-nav-next { max-width: none; }
    .home-articles .articles-list { flex-direction: column; }
}

/* ---------- Навигация между статьями ---------- */
.article-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0 0;
}
.article-nav-prev, .article-nav-next {
    flex: 1 1 280px;
    max-width: calc(50% - 5px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    min-width: 0;
    box-sizing: border-box;
}
.article-nav-prev:hover, .article-nav-next:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.article-nav-next { text-align: right; }
.article-nav-label { font-size: 12px; color: var(--muted); }
.article-nav-title {
    font-weight: 650;
    font-size: 14px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ---------- Статьи на главной ---------- */
.home-articles { margin-top: 22px; }
.home-articles h2 { margin-bottom: 10px; }
.home-articles .articles-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
}
.home-articles .article-card {
    flex: 1 1 300px;
    min-width: 0;
}

/* ---------- Тематические карточки на главной ---------- */
.home-interesting { margin-top: 24px; }
.home-interesting h2 { margin: 0 0 12px; }
.interesting-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.interesting-card {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.interesting-card:hover {
    transform: translateY(-2px);
    border-color: rgba(88, 166, 255, .65);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    text-decoration: none;
}
.interesting-image {
    display: block;
    aspect-ratio: 28 / 13;
    overflow: hidden;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-soft);
}
.interesting-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .25s ease;
}
.interesting-card:hover .interesting-image img { transform: scale(1.025); }
.interesting-body { display: block; padding: 15px 16px 17px; }
.interesting-body strong {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
    line-height: 1.3;
}
.interesting-body > span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

/* ============================================================
   Адаптив
   ============================================================ */
@media (max-width: 900px) {
    .header-search input { width: 150px; }
    .header-search input:focus { width: 170px; }
    .chart-box { height: 380px; }
    .table-wrap { max-height: none; }
    .interesting-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    main { padding: 18px 14px 34px; }
    .container { padding: 0 14px; }
    .interesting-grid { grid-template-columns: 1fr; gap: 12px; }
    .interesting-card { display: grid; grid-template-columns: 118px minmax(0, 1fr); }
    .interesting-image { aspect-ratio: auto; min-height: 112px; border-bottom: 0; border-right: 1px solid var(--border-soft); }
    .interesting-body { align-self: center; padding: 13px 14px; }

    /* Таблицы → карточки */
    table.tbl, .tbl tbody { display: block; }
    .tbl thead { display: none; }
    .tbl tbody tr {
        display: block;
        margin: 10px;
        padding: 12px 14px;
        background: var(--surface-2);
        border: 1px solid var(--border-soft);
        border-radius: var(--radius-sm);
    }
    .tbl tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        padding: 4.5px 0;
        border: none;
        text-align: right;
    }
    .tbl tbody td::before {
        content: attr(data-l);
        color: var(--muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .05em;
        text-align: left;
        white-space: nowrap;
    }

    .topbar-inner { flex-wrap: wrap; gap: 8px; padding-bottom: 10px; }
    .nav { order: 3; flex-basis: 100%; }
    .header-search { margin-left: auto; }
    .header-search input { width: 130px; }

    .chart-box { height: 310px; }
    .chart-controls { padding: 11px 12px; }
    .search-field .input { width: 100%; }
    .stats-grid { gap: 10px; }
    .stat-card { padding: 13px 14px; }
    .footer-inner { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Страница монеты (/coin/{base}) ---------- */
.coin-meta-link { margin-top: 14px; font-size: 13.5px; }
.coin-meta-link a { color: var(--accent); text-decoration: none; }
.coin-meta-link a:hover { text-decoration: underline; }

.coin-page { display: flex; flex-direction: column; gap: 20px; }

.coin-hero {
    display: flex;
    align-items: stretch;
    gap: 20px;
    padding: 22px 24px;
}
.coin-hero-main { flex: 1; min-width: 0; }
.coin-hero-label { color: var(--muted); font-size: 13.5px; }
.coin-hero-price { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.coin-hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.coin-hero-meta span { color: var(--muted); font-size: 12px; }
.coin-hero-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 10px;
    flex: 1.6;
    min-width: 0;
}

.coin-seo h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px;
    letter-spacing: -0.01em;
}
.coin-seo p { color: var(--muted); line-height: 1.65; }
.coin-seo .btn { margin-top: 6px; }

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px 16px;
}
.faq-item summary {
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 0;
    list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    float: right;
    color: var(--muted);
    font-weight: 500;
}
.faq-item[open] summary::after { content: '–'; }
.faq-item p { margin: 0 0 14px; }
.ex-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-link {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s ease;
}
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.ex-cmp-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
}
.ex-cmp-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Страница сравнения (/compare) ---------- */
.cmp-cards { display: flex; gap: 14px; flex-wrap: wrap; }
.cmp-card { flex: 1 1 200px; padding: 18px 20px; text-align: center; }
.cmp-dot { width: 10px; height: 10px; border-radius: 50%; margin: 0 auto 6px; }
.cmp-dot.blue { background: #58a6ff; }
.cmp-dot.green { background: #16c784; }
.cmp-price { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 6px; }
.cmp-diff .cmp-price { font-size: 32px; }
.cmp-diff.low .cmp-price { color: #f0b90b; }
.cmp-diff.mid .cmp-price { color: #ea3943; }
.cmp-diff.high .cmp-price { color: #ea3943; }
.cmp-diff.zero .cmp-price { color: var(--muted); }
.cmp-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.cmp-legend { display: flex; align-items: center; gap: 14px; font-size: 13.5px; font-weight: 600; }
.cmp-legend .cmp-dot { width: 8px; height: 8px; margin: 0; }
.cmp-intervals { display: flex; gap: 6px; }
.cmp-intervals .cmp-iv {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.cmp-intervals .cmp-iv.active,
.cmp-intervals .cmp-iv:hover { border-color: var(--accent); color: var(--accent); }
.cmp-chart-box { height: 360px; display: flex; flex-direction: column; }
#cmp-chart { flex: 1 1 auto; min-height: 0; }

@media (max-width: 720px) {
    .cmp-cards { flex-direction: column; }
    .cmp-price { font-size: 22px; }
    .cmp-diff .cmp-price { font-size: 26px; }
    .cmp-chart-head { justify-content: flex-start; flex-direction: column; align-items: flex-start; }
    .cmp-chart-box { height: 280px; }
}

@media (max-width: 720px) {
    .coin-hero { flex-direction: column; padding: 16px 16px; }
    .coin-hero-price { font-size: 28px; }
    .coin-hero-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Таблица бирж ---------- */
.exchange-icon-table {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.exchange-icon-table img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    padding: 2px;
}

.exchange-name-table {
    font-weight: 600;
    color: var(--text);
}

.exchange-details {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.exchange-icon {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.exchange-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.exchange-icon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: var(--radius);
}

.exchange-info {
    flex: 1;
    min-width: 0;
}

.exchange-name {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}

.exchange-desc {
    color: var(--muted);
    line-height: 1.6;
    margin: 0 0 12px;
}

.exchange-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

.exchange-link:hover {
    text-decoration: underline;
}
}

/* ---------- RTL (Arabic) ---------- */
[dir="rtl"] { --font: "Noto Sans Arabic", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif; }
[dir="rtl"] .header-search { margin-left: 0; margin-right: auto; }
[dir="rtl"] .header-search svg { left: auto; right: 11px; }
[dir="rtl"] .header-search input { padding: 8px 32px 8px 12px; }
[dir="rtl"] .lang-switch { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .search-field svg { left: auto; right: 11px; }
[dir="rtl"] .search-field .input { padding-left: 12px; padding-right: 33px; }
[dir="rtl"] .slider::after { left: auto; right: 2px; }
[dir="rtl"] .switch input:checked + .slider::after { transform: translateX(-15px); }
[dir="rtl"] .tbl thead th { text-align: right; }
[dir="rtl"] .tbl th .arr { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .chart-mini { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .best-flag { margin-left: 0; margin-right: 5px; }
[dir="rtl"] .chart-box, [dir="rtl"] #chart { direction: ltr; }
[dir="rtl"] .article-body-html ul, [dir="rtl"] .article-body-html ol { padding-left: 0; padding-right: 24px; }
[dir="rtl"] .article-body-html blockquote { border-left: 0; border-right: 3px solid var(--accent); }
[dir="rtl"] .article-body-html th, [dir="rtl"] .article-body-html td { text-align: right; }
[dir="rtl"] .article-nav-next { text-align: left; }
[dir="rtl"] .faq-item summary::after { float: left; }
/* Tickers, prices and addresses stay left-to-right inside Arabic text. */
[dir="rtl"] .ticker-name, [dir="rtl"] code, [dir="rtl"] .tbl td.num, [dir="rtl"] input[type="search"] { unicode-bidi: plaintext; }
@media (max-width: 720px) {
    [dir="rtl"] .interesting-image { border-right: 0; border-left: 1px solid var(--border-soft); }
    [dir="rtl"] .tbl tbody td { text-align: left; }
    [dir="rtl"] .tbl tbody td::before { text-align: right; }
    [dir="rtl"] .header-search { margin-left: 0; margin-right: auto; }
}
