/* EarthMetrics — тёмная тема по макету */
:root {
  --bg: #0E1116; --panel: #11161D; --card: #161B22; --line: #232A33; --line2: #2D3540;
  --text: #E6E8EB; --soft: #C9D0D8; --muted: #A9B1BC; --faint: #8B95A2;
  --accent: #FF8A4C; --m3: #7A8BA8; --m4: #E0A33A; --m5: #F07A2B; --m6: #E5484D;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 'Exo 2', system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #FFB088; }
h1, h2 { font-family: 'Exo 2', sans-serif; margin: 0; }
h1 { font-weight: 800; font-size: clamp(24px, 2.8vw, 34px); line-height: 1.15; letter-spacing: -0.01em; }
h1 a { color: inherit; }
h2 { font-weight: 500; font-size: 16px; }
.wrap { max-width: 1320px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .strong { font-weight: 600; }
.accent { color: var(--accent); } .nowrap { white-space: nowrap; } .grow { flex: 1 1 auto; min-width: 0; }
.right { text-align: right; }

.top { border-bottom: 1px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding-top: 16px; padding-bottom: 16px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); }
.logo svg { color: var(--accent); }
.logo span { font: 800 19px 'Exo 2', sans-serif; letter-spacing: 0.01em; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { padding: 10px 14px; border-radius: 8px; color: var(--muted); }
.nav a[aria-current] { color: var(--text); background: #1A2029; }
.top-actions { display: flex; gap: 10px; }
.btn, .btn-ghost { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 10px; }
.btn { background: var(--accent); color: #14100C; font-weight: 600; }
.btn:hover { color: #14100C; background: #FFA06C; }
.btn-ghost { border: 1px solid var(--line2); color: var(--soft); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line2); color: var(--soft); }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.hero-title { font-size: clamp(20px, 2.2vw, 26px); line-height: 1.2; }

.main { display: flex; flex-direction: column; gap: 28px; padding-top: 28px; padding-bottom: 64px; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; }
.hero-text { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; flex: 1 1 480px; justify-content: flex-end; }
.tiles.wide { justify-content: stretch; flex: none; }   /* в колонке main: без этого 480px уходят в высоту */
.tile { flex: 1 1 140px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.tiles:not(.wide) .tile { max-width: 210px; }
.tile-num { font: 600 26px 'Fira Code', monospace; }
.tile-num.sm { font-size: 19px; }
.tile-label { font-size: 12px; color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.row.three > .panel { flex: 1 1 360px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.panel.pad { padding: 20px; display: flex; flex-direction: column; gap: 4px; background: var(--card); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head.plain { padding: 0 0 10px; border: 0; }
.map-panel, .grow-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; }
.map { flex: 1 1 auto; min-height: 460px; background: #0B0F14; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.dot.m3, .mag.m3 { background: var(--m3); } .dot.m4, .mag.m4 { background: var(--m4); }
.dot.m5, .mag.m5 { background: var(--m5); } .dot.m6, .mag.m6 { background: var(--m6); }
.ring { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--m6); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: #2A1C14; color: #FFD2B8; }

.side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; }
.card { display: block; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; color: var(--text); }
.card-link:hover { border-color: var(--line2); color: var(--text); }
.card-top { display: flex; align-items: center; gap: 12px; }
.card-text { margin-top: 8px; font-size: 13px; color: var(--soft); }
.mag { display: inline-block; min-width: 44px; text-align: center; font: 600 15px 'Fira Code', monospace; padding: 4px 8px; border-radius: 7px; color: #14100C; }
.card-top .mag { font-size: 20px; padding: 6px 10px; }

.table-box { overflow-x: auto; }
table.events { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
.events th { padding: 12px; text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.events td { padding: 12px; border-top: 1px solid #1E252E; color: var(--soft); }
.events th:first-child, .events td:first-child { padding-left: 20px; }
.events td a { color: var(--text); }
.events td a:hover { color: var(--accent); }

.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.num { font: 600 16px 'Fira Code', monospace; }
.week-img, .card-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.panel.pad.post { display: block; }   /* текст поста — обычный поток, не flex: иначе <b> рвёт строки */
.post { color: var(--soft); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.post b { color: var(--text); }
.small-text { font-size: 13px; }

.back { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.ev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; }
.ev-mag { width: 132px; height: 132px; border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #14100C; text-align: center; }
.ev-mag span { font: 600 44px/1 'Fira Code', monospace; }
.ev-mag small { font-size: 11px; font-weight: 600; margin-top: 6px; padding: 0 8px; }
.ev-mag.m3 { background: var(--m3); } .ev-mag.m4 { background: var(--m4); } .ev-mag.m5 { background: var(--m5); } .ev-mag.m6 { background: var(--m6); }
.page-title { margin-bottom: -12px; }

.foot { border-top: 1px solid var(--line); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-top: 22px; padding-bottom: 22px; font-size: 13px; color: var(--faint); }

/* Окно точки на карте: стили MapLibre подключаются позже — перекрываем селектором с .map */
.map .maplibregl-popup-content { background: var(--card); color: var(--text); border: 1px solid var(--line2); border-radius: 10px; font: 13px/1.45 'Exo 2', sans-serif; padding: 10px 28px 10px 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); }
.map .maplibregl-popup-content a { color: var(--accent); }
.map .maplibregl-popup-close-button { color: var(--muted); font-size: 18px; width: 28px; height: 28px; }
.map .maplibregl-popup-close-button:hover { background: transparent; color: var(--text); }
.map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--line2); }
.map .maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--line2); }
.map .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--line2); }
.map .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--line2); }

/* Графики «Динамика за 30 дней» */
.dynamics { gap: 12px; }
.charts { display: flex; flex-wrap: wrap; gap: 24px; }
.chart-box { flex: 1 1 380px; min-width: 0; margin: 0; }
.chart-box figcaption { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); margin-bottom: 6px; }
.flag { display: inline-block; width: 20px; height: 15px; margin-right: 8px; vertical-align: -2px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); }
h1 .flag { width: 32px; height: 24px; margin-right: 12px; vertical-align: 0; }
.hero-title .flag { width: 26px; height: 19px; margin-right: 10px; vertical-align: -1px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .tick { fill: var(--faint); font: 11px 'Exo 2', sans-serif; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit.on { fill: rgba(255, 255, 255, 0.05); }
.chart-tip { position: fixed; display: none; z-index: 50; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line2); color: var(--text); font-size: 13px; white-space: nowrap; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 13px; min-height: 32px; display: flex; align-items: center; }
.chart-table table.events { min-width: 0; max-width: 420px; }
/* Страницы серии и роя */
.crumbs a { color: var(--muted); }
.detail-head { display: flex; flex-direction: column; gap: 8px; }
.chip { display: inline-block; margin-right: 8px; padding: 2px 10px; border-radius: 999px; background: #1E2530; color: var(--soft); font-weight: 600; }
.chip.live { background: #2A1C14; color: #FFB088; }
.list-link { color: var(--text); }
.list-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.02); }
.stack { display: flex; flex-direction: column; gap: 24px; }
.side-map { display: flex; flex-direction: column; }
.side-map .map { min-height: 420px; }
.side-map .short-map { min-height: 300px; }
.pad-x { padding: 0 20px 14px; }
.detail-chart { position: relative; height: 260px; margin: 6px 0 0 40px; }
.detail-chart.short { height: 170px; }
.detail-chart .plot { position: absolute; inset: 0 0 22px 0; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-chart .gridline { position: absolute; left: 0; right: 0; border-top: 1px solid #1E252E; }
.detail-chart .ylabel { position: absolute; left: -40px; width: 34px; margin-top: -8px; text-align: right; font-size: 11px; color: var(--faint); }
.detail-chart .dot-pt { position: absolute; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
.detail-chart .xaxis { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; }
.detail-chart .xaxis span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--faint); white-space: nowrap; }
.detail-bars { margin: 10px 0 4px 40px; }
.detail-bars .bars { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--line2); }
.detail-bars.tall .bars { height: 190px; }
.detail-bars .bar-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.detail-bars .bar { position: relative; z-index: 2; width: 100%; max-width: 24px; background: #3987e5; border-radius: 4px 4px 0 0; }   /* поверх линии фона */
.detail-bars .bar-n { font: 500 11px 'Fira Code', monospace; color: var(--soft); }
.detail-bars .bar-labels { display: flex; gap: 2px; margin-top: 4px; }
.detail-bars .bar-label { flex: 1 1 0; min-width: 0; text-align: center; height: 16px; font-size: 11px; color: var(--faint); white-space: nowrap; overflow: visible; }
.detail-bars .baseline { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); pointer-events: none; z-index: 1; }
.detail-bars .baseline span { position: absolute; left: -38px; top: -9px; width: 32px; text-align: right; font-size: 11px; color: var(--muted); }
@media (max-width: 700px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .tiles:not(.wide) .tile { max-width: none; }
  .map { min-height: 340px; }
  .detail-chart, .detail-bars { margin-left: 34px; }
  .ev-mag { width: 96px; height: 96px; border-radius: 18px; }
  .ev-mag span { font-size: 36px; }
}
