:root {
  --bg: #04060d;
  --panel: #0b1220;
  --panel2: #101a2e;
  --line: rgba(255, 255, 255, 0.08);
  --text: #dbe7ff;
  --dim: #7c8db0;
  --red: #ff5c5c;
  --blue: #4a9eff;
  --green: #2dd4a7;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- header ---------- */
.ch-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1626, #0a1120);
  flex-wrap: wrap;
  z-index: 10;
}
.ch-back {
  color: var(--dim);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.ch-back:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.ch-header-title h1 {
  margin: 0;
  font-size: 19px;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.ch-header-title span { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.ch-header-hint { margin-left: auto; font-size: 11.5px; color: var(--dim); }

/* ---------- stage (fullscreen map) ---------- */
.ch-stage { position: relative; flex: 1; min-height: 0; }
.ch-map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: auto;
  cursor: grab;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(20, 34, 60, 0.35), transparent 60%),
    var(--bg);
}
.ch-map::-webkit-scrollbar { display: none; }
.ch-map.grabbing { cursor: grabbing; }
.ch-map.grabbing .ch-mcard { pointer-events: none; }

#ch-map-sizer { position: relative; }
#ch-map-inner { position: relative; z-index: 1; transform-origin: 0 0; }
#ch-map-svg { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 0; }

.ch-zoom {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 4;
}
.ch-zoom button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(5, 10, 20, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.ch-zoom button:hover { border-color: rgba(255, 255, 255, 0.45); }

.ch-edge {
  fill: none;
  stroke: #101a2e;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.4;
}
#ch-arr path { fill: #101a2e; }
#ch-arr-in path { fill: #2dd4a7; }
#ch-arr-out path { fill: #ff5c5c; }

.ch-edge.ch-edge-in,
.ch-edge.ch-edge-out {
  opacity: 1;
  stroke-width: 2.5;
  stroke-dasharray: 5 9;
  animation: ch-flow 0.9s linear infinite;
}
.ch-edge.ch-edge-in { stroke: #2dd4a7; }
.ch-edge.ch-edge-out { stroke: #ff5c5c; }
@keyframes ch-flow { to { stroke-dashoffset: -14; } }

.ch-mcard {
  position: absolute;
  width: 172px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(180deg, #111c33, #0b1220);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
  transition: transform 0.25s ease, border-color 0.2s ease, box-shadow 0.25s ease;
  z-index: 1;
}
.ch-mcard:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.7);
}
.ch-mcard .ch-mc-date { font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
.ch-mcard .ch-mc-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
}
.ch-mcard.cur {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 16px 40px -10px rgba(0, 0, 0, 0.85);
  z-index: 2;
}
.ch-mcard.pop { animation: ch-pop 0.5s ease; }
@keyframes ch-pop {
  0% { transform: scale(0.8); opacity: 0.1; }
  100% { transform: scale(1); }
}

.ch-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  background: rgba(5, 10, 20, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  max-width: 90%;
  text-overflow: ellipsis;
  overflow: hidden;
}
.ch-hint.warn { color: #ff8d8d; border-color: rgba(255, 92, 92, 0.4); }

/* ---------- right panel ---------- */
.ch-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 392px;
  max-width: 92vw;
  background: rgba(9, 14, 26, 0.97);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(105%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  z-index: 6;
  box-shadow: -24px 0 60px -20px rgba(0, 0, 0, 0.8);
  padding: 20px 20px 28px;
}
.ch-panel.open { transform: none; }
.ch-panel-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  z-index: 2;
}
.ch-panel-x:hover { color: #fff; }

.ch-hero {
  height: 170px;
  border-radius: 16px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
}
.ch-hero-icon { font-size: 66px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55)); }
.ch-hero-year {
  position: absolute;
  right: 14px;
  bottom: 8px;
  font-size: 24px;
  font-family: Georgia, serif;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.ch-panel-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ch-panel-date { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.ch-panel-title {
  margin: 0 0 12px;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 500;
  font-size: 23px;
  line-height: 1.3;
}
.ch-panel-desc { margin: 0 0 18px; font-size: 14px; line-height: 1.7; color: #c6d4f0; }

.ch-panel-sub {
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 14px 0 8px;
}
.ch-panel-sub.up { color: #7ce6c8; }
.ch-panel-sub.down { color: #ff8d8d; }
.ch-plink {
  display: flex;
  align-items: baseline;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.4;
}
.ch-plink:hover { border-color: rgba(255, 255, 255, 0.3); }
.ch-plink .ch-plink-date { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--dim); font-size: 11px; }
.ch-panel-nav { display: flex; gap: 8px; margin-top: 18px; }
.ch-panel-nav .ch-navbtn { flex: 1; }
.ch-panel-pos { font-size: 11px; color: var(--dim); text-align: center; margin-top: 8px; }

.ch-navbtn {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.ch-navbtn:hover { background: rgba(255, 255, 255, 0.14); }

.ch-tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.ch-tag.esc { background: rgba(255, 92, 92, 0.15); color: #ff8d8d; border: 1px solid rgba(255, 92, 92, 0.35); }
.ch-tag.deesc { background: rgba(74, 158, 255, 0.15); color: #8fc4ff; border: 1px solid rgba(74, 158, 255, 0.35); }
.ch-tag.hope { background: rgba(45, 212, 167, 0.15); color: #7ce6c8; border: 1px solid rgba(45, 212, 167, 0.35); }

/* ---------- footer (timeline + filters) ---------- */
.ch-footer {
  flex: none;
  border-top: 1px solid var(--line);
  background: #0a1120;
  padding: 12px 18px 14px;
  z-index: 8;
}
.ch-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.ch-search {
  flex: 1 1 260px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.ch-search:focus { border-color: rgba(74, 158, 255, 0.6); box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15); }
.ch-search::placeholder { color: rgba(255, 255, 255, 0.3); }
.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip {
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--dim);
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.ch-chip:hover { color: #fff; }
.ch-chip.active { background: rgba(74, 158, 255, 0.25); border-color: rgba(74, 158, 255, 0.6); color: #fff; }
.ch-count { font-size: 11px; color: var(--dim); white-space: nowrap; }

.ch-temp-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.ch-temp-divider {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.ch-temp-marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  pointer-events: none;
  border-radius: 2px;
}
.ch-modes { display: flex; gap: 6px; margin-top: 8px; }
.ch-ticks { position: relative; height: 14px; margin-top: 5px; font-size: 10px; color: var(--dim); }
.ch-ticks span { position: absolute; transform: translateX(-50%); }
.ch-temp-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--dim); letter-spacing: 1px; }
.ch-temp-legend { margin-top: 5px; font-size: 10.5px; color: var(--dim); text-align: center; letter-spacing: 0.4px; }

@media (max-width: 900px) {
  .ch-header-hint { display: none; }
  .ch-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 62vh;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    transform: translateY(105%);
  }
  .ch-panel.open { transform: none; }
}

/* ================= МОБИЛЬНАЯ АДАПТАЦИЯ ================= */
@media (max-width: 480px) {
  .ch-header {
    padding: 8px 12px;
    gap: 10px;
  }
  .ch-header-title h1 { font-size: 16px; }
  .ch-header-title span { font-size: 10px; }
  .ch-back { font-size: 12px; padding: 8px 12px; }

  .ch-search { font-size: 16px; }

  .ch-panel {
    max-height: 72vh;
    border-radius: 18px 18px 0 0;
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  }
  .ch-panel-title { font-size: 19px; }
  .ch-panel-desc { font-size: 13.5px; }
  .ch-hero { height: 120px; }
  .ch-hero-icon { font-size: 52px; }

  .ch-hint {
    max-width: 92%;
    font-size: 10.5px;
    padding: 6px 12px;
    white-space: normal;
    text-align: center;
  }

  .ch-zoom { left: 10px; bottom: 10px; }

  .ch-footer {
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  }
  .ch-filters { gap: 8px; margin-bottom: 8px; }
  .ch-temp-legend { font-size: 9.5px; }
}

/* Тач-устройства: крупные цели нажатия */
@media (pointer: coarse) {
  .ch-zoom button { width: 42px; height: 42px; font-size: 17px; }
  .ch-chip { padding: 8px 13px; font-size: 12.5px; }
  .ch-mcard { width: 190px; font-size: 13px; }
  .ch-mcard .ch-mc-title { font-size: 13px; }
  .ch-navbtn { padding: 11px 14px; font-size: 13.5px; }
  .ch-plink { padding: 11px 12px; font-size: 13.5px; }
  .ch-panel-x { font-size: 24px; padding: 8px 12px; }
  .ch-temp-track { height: 20px; }
}
