*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background: #0a0a0a;
  color: #e8e4d9;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Loading ─────────────────────────────────────────────── */

#ch-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  color: #c8943a;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.12em;
  z-index: 100;
}

/* ── Layout shell ────────────────────────────────────────── */

#ch-content {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────── */

#ch-header {
  flex: 0 0 auto;
  padding: 14px 24px 12px;
  border-bottom: 1px solid rgba(200, 148, 58, 0.22);
}

.ch-masthead h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 26px;
  color: #c8943a;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.ch-subtitle {
  font-size: 10px;
  color: #6a6660;
  letter-spacing: 0.07em;
  margin-top: 2px;
  text-transform: uppercase;
}

/* ── Timeline container ──────────────────────────────────── */

#ch-timeline {
  flex: 1 1 auto;
  overflow-x: scroll;
  overflow-y: hidden;
  cursor: grab;
  position: relative;
  user-select: none;
}

#ch-timeline.dragging {
  cursor: grabbing;
}

#ch-timeline::-webkit-scrollbar {
  height: 3px;
}

#ch-timeline::-webkit-scrollbar-track {
  background: #0a0a0a;
}

#ch-timeline::-webkit-scrollbar-thumb {
  background: rgba(200, 148, 58, 0.25);
  border-radius: 2px;
}

#ch-track {
  height: 100%;
  position: relative;
}

/* ── Axis rule ───────────────────────────────────────────── */

#ch-axis-rule {
  position: absolute;
  top: 50%;
  left: 0;
  height: 2px;
  background: #c8943a;
  transform-origin: left center;
}

/* ── Tick marks & labels ─────────────────────────────────── */

#ch-ticks {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
}

.ch-tick {
  position: absolute;
  top: calc(50% - 3px);
  width: 1px;
  height: 6px;
  background: rgba(200, 148, 58, 0.22);
  transform: translateX(-50%);
}

.ch-tick-decade {
  height: 14px;
  top: calc(50% - 7px);
  background: rgba(200, 148, 58, 0.5);
}

.ch-decade-label {
  position: absolute;
  top: calc(50% - 32px);
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #c8943a;
  letter-spacing: 0.12em;
  opacity: 0;
}

/* ── Markers ─────────────────────────────────────────────── */

#ch-markers {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
}

.ch-marker-wrap {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}

.ch-marker {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ch-marker-wrap:hover .ch-marker {
  transform: scale(1.2);
  box-shadow: 0 0 14px rgba(200, 148, 58, 0.35);
  z-index: 10;
}

.ch-marker-icon {
  font-size: 13px;
  line-height: 1;
  color: rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.ch-marker-name {
  position: absolute;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8px;
  color: #e8e4d9;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  left: 50%;
  transform: translateX(-50%);
  letter-spacing: 0.04em;
  background: rgba(10, 10, 10, 0.75);
  padding: 1px 3px;
  border-radius: 2px;
}

.ch-marker-wrap:hover .ch-marker-name {
  opacity: 1;
}

/* Label direction by side */
.ch-marker-wrap[data-side="above"] .ch-marker-name {
  top: calc(100% + 5px);
}

.ch-marker-wrap[data-side="below"] .ch-marker-name {
  bottom: calc(100% + 5px);
}

/* ── Preview card ────────────────────────────────────────── */

.ch-card {
  position: fixed;
  width: 280px;
  background: #111;
  border: 1px solid rgba(200, 148, 58, 0.28);
  border-radius: 8px;
  overflow: hidden;
  z-index: 500;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  opacity: 0;
}

.ch-card-thumb {
  height: 56px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.ch-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ch-card-thumb-overlay {
  position: absolute;
  inset: 0;
}

.ch-card-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #e8e4d9;
  font-size: 16px;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.ch-card-close:hover {
  opacity: 1;
}

.ch-card-body {
  padding: 11px 14px 13px;
}

.ch-card-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 5px;
}

.ch-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.ch-card-year {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #6a6660;
  letter-spacing: 0.06em;
}

.ch-card-cat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  color: #4a4845;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

.ch-card-desc {
  font-size: 11px;
  color: #b8b4a9;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 9px;
}

.ch-card-links {
  list-style: none;
  margin-bottom: 10px;
}

.ch-card-links li {
  font-size: 11px;
  padding: 1px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ch-card-links li::before {
  content: '→';
  color: #c8943a;
  font-size: 10px;
}

.ch-card-links a {
  color: #c8c4b9;
  text-decoration: none;
}

.ch-card-links a:hover {
  color: #e8e4d9;
}

.ch-card-visit {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-decoration: none;
  letter-spacing: 0.07em;
  transition: background 0.15s;
}

.ch-card-visit:hover {
  background: rgba(200, 148, 58, 0.1);
}

/* ── Footer ──────────────────────────────────────────────── */

#ch-footer {
  flex: 0 0 auto;
  border-top: 1px solid rgba(200, 148, 58, 0.18);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

#ch-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

#ch-footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#ch-site-count {
  font-size: 10px;
  color: #4a4845;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

#ch-decade-jumps {
  display: flex;
  gap: 4px;
}

/* ── Filter pills ────────────────────────────────────────── */

.ch-filter-pill {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #6a6660;
  padding: 3px 9px;
  border-radius: 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s, color 0.15s;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ch-filter-pill:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #b8b4a9;
}

.ch-filter-pill.ch-filter-active {
  border-color: #c8943a;
  color: #c8943a;
}

.ch-filter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Decade jump pills ───────────────────────────────────── */

.ch-decade-pill {
  background: none;
  border: 1px solid rgba(200, 148, 58, 0.28);
  color: #c8943a;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.ch-decade-pill:hover {
  background: rgba(200, 148, 58, 0.12);
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
  #ch-header {
    padding: 10px 14px 9px;
  }

  .ch-masthead h1 {
    font-size: 20px;
  }

  #ch-footer {
    padding: 8px 14px;
    gap: 10px;
  }

  #ch-footer-right {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ch-marker,
  .ch-card,
  .ch-filter-pill,
  .ch-decade-pill {
    transition: none !important;
  }
}
