:root {
  --ink: #1f2529;
  --muted: #61707a;
  --paper: #d3d4d1;
  --row-separator: #c3c5c1;
  --row-title-background: #a9a8a8;
  --grid: rgba(255, 255, 255, 0.72);
  --dark: #2d3032;
  --label: #8c6b38;
  --blue: #2072bc;
  --gold: #d1a52d;
  --top-layer: 2147483647;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #e9ebe7;
  overflow: hidden;
}

button {
  font: inherit;
}

.app {
  height: 100vh;
  overflow: hidden;
}

.timeline-shell {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: auto;
  background: #c7c9c5;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.timeline-shell.is-dragging,
.timeline-shell.is-dragging * {
  cursor: grabbing !important;
}

.timeline {
  --label-width: 86px;
  --header-height: 64px;
  --header-tick-height: 32px;
  --age-band-lane-height: 20px;
  --age-band-level-count: 1;
  --row-height: 92px;
  --events-height: 230px;
  position: relative;
  min-height: 100%;
  background: var(--paper);
}

.timeline-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 90;
  width: var(--label-width);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px 0 7px;
  --corner-background: #a7a9a6;
  background: var(--corner-background);
  border-right: 1px solid var(--corner-background);
  box-shadow: 5px 0 14px rgba(0,0,0,0.12);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.15;
  text-transform: none;
}

.corner-title {
  display: block;
  max-width: calc(100% - 24px);
  color: #111;
  font-size: 52px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  transform: translate(-5px, -5px);
  overflow-wrap: anywhere;
}

.event-filters-mount {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 70;
  height: var(--header-height);
  background: #bfc1be;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: var(--header-tick-height);
  background: rgba(31,37,41,0.44);
  z-index: 3;
}

.tick span {
  position: absolute;
  left: 6px;
  top: 7px;
  width: 72px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.age-bands {
  position: absolute;
  top: 0;
  left: var(--label-width);
  z-index: 71;
  height: var(--header-height);
  background: #bfc1be;
}

.age-band {
  --age-band-color: #8f9290;
  appearance: none;
  position: absolute;
  top: var(--header-tick-height);
  height: var(--age-band-lane-height);
  padding: 2px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--age-band-color);
  background: var(--age-band-color);
  color: #111;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  z-index: 2;
  cursor: pointer;
}

.age-band:focus-visible {
  outline: 2px solid rgba(32,114,188,0.65);
  outline-offset: -2px;
}

.age-band-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.age-population {
  position: absolute;
  top: 21px;
  transform: translateX(-100%);
  max-width: 42px;
  padding-right: 5px;
  overflow: hidden;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 4;
  cursor: help;
}

.rows {
  position: relative;
}

.impact-veils {
  position: absolute;
  top: 0;
  left: var(--label-width);
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.impact-veil {
  --impact-veil-border-color: #7ba7d9;
  position: absolute;
  border: 0 solid transparent;
  border-radius: 999px;
  filter: blur(1px);
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: border-color 120ms ease;
}

.impact-veil.is-source-hovered {
  border: 1px solid var(--impact-veil-border-color);
}

.row {
  position: relative;
  height: var(--row-height);
}

.row-label {
  position: sticky;
  left: 0;
  z-index: 30;
  width: var(--label-width);
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 7px;
  background: var(--row-title-background);
  color: #111;
  font-size: 10px;
  font-weight: 950;
  line-height: 1.14;
  text-transform: none;
  border-bottom: 1px solid var(--row-separator);
  box-shadow: 5px 0 14px rgba(0,0,0,0.12);
  cursor: default;
}

.row-label-text {
  appearance: none;
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.row-label-text.is-selected {
  color: #111;
}

.row-label-text.is-dimmed {
  color: #818181;
}

.row-label-text:focus-visible {
  outline: 2px solid rgba(32,114,188,0.65);
  outline-offset: 2px;
}

.row[data-row="armenia"] .row-label {
  padding-right: 28px;
  overflow: hidden;
}

.ararat-contour {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 36px;
  height: 20px;
  opacity: 0.9;
  pointer-events: none;
}

.ararat-ridge,
.ararat-snow {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ararat-ridge {
  stroke: rgba(15, 19, 21, 0.88);
  stroke-width: 3;
}

.ararat-snow {
  stroke: rgba(239, 212, 128, 0.92);
  stroke-width: 2;
}

.bar {
  --bar-color: #7ba7d9;
  --bar-text-color: #000000;
  position: absolute;
  top: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--bar-color);
  border-radius: 0;
  background: var(--bar-color);
  color: var(--bar-text-color);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 5px 12px rgba(0,0,0,0.12);
}

.bar:focus-visible,
.bar:hover {
  z-index: 20;
  outline: 3px solid rgba(32,114,188,0.4);
  filter: brightness(1.05);
}

.bar.is-event-relevant {
  z-index: 25;
  outline: 4px solid rgba(208, 165, 38, 0.9);
  outline-offset: 0;
  filter: brightness(1.08) saturate(1.12);
  box-shadow: 0 7px 18px rgba(0,0,0,0.22);
}

.bar.marker {
  width: 16px !important;
  height: 16px;
  border-radius: 50%;
  overflow: visible;
  border: 3px solid var(--bar-color);
}

.bar.marker .bar-label {
  position: absolute;
  left: 20px;
  top: -4px;
  width: 130px;
  height: auto;
  padding: 0;
  text-align: left;
}

.bar-label {
  display: block;
  width: 100%;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.events-row {
  position: sticky;
  bottom: 0;
  z-index: 55;
  height: var(--events-height);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 2px solid var(--dark);
  background: #bfc1be;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
  cursor: grab;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: none;
}

.events-row::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.events-resize-handle {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 8px;
  margin-top: -8px;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
}

.events-resize-handle::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.events-row.is-resizing,
.events-row.is-resizing * {
  cursor: ns-resize !important;
  user-select: none;
}

.events-row.is-dragging,
.events-row.is-dragging * {
  cursor: grabbing !important;
}

.events-label {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  width: var(--label-width);
  min-width: var(--label-width);
  max-width: var(--label-width);
  height: 100%;
  padding: 0 7px;
  background: var(--row-title-background);
  color: #111;
  font-size: 10px;
  font-weight: 950;
  line-height: 1.14;
  text-transform: none;
  box-shadow: 5px 0 14px rgba(0,0,0,0.12);
  transform: translateX(var(--timeline-scroll-left, 0px));
  will-change: transform;
}

.events-content {
  position: relative;
  min-height: var(--events-height);
  margin-top: calc(-1 * var(--events-height));
}

.event-pin {
  position: absolute;
  top: 22px;
  width: 0;
  height: 172px;
}

.event-pin.is-open {
  z-index: 35;
}

.event-pin button {
  position: absolute;
  top: var(--offset);
  left: 7px;
  width: 208px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #273039;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.22;
  text-align: left;
  border-radius: 3px;
  white-space: normal;
  overflow-wrap: break-word;
  cursor: pointer;
  transition: opacity 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.event-pin button:hover,
.event-pin button:focus-visible,
.event-pin.is-open > button {
  background: rgba(255,255,255,0.7);
  box-shadow: 0 0 0 2px rgba(32,114,188,0.35);
  outline: 0;
}

.event-pin strong {
  color: var(--blue);
}

.events-row.is-filtering .event-pin button {
  opacity: 0.22;
}

.events-row.is-filtering .event-pin.is-relevant button {
  z-index: 2;
  background: rgba(255, 242, 135, 0.95);
  box-shadow: 0 0 0 3px rgba(208, 165, 38, 0.45), 0 6px 14px rgba(0,0,0,0.18);
  opacity: 1;
}

.event-detail-popover,
.era-detail-popover,
.bar-detail-popover {
  position: fixed;
  z-index: var(--top-layer);
  box-sizing: border-box;
  width: 286px;
  max-height: calc(100vh - 16px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 12px 11px;
  border: 1px solid rgba(31,37,41,0.38);
  background: #f4f0df;
  color: #1f2529;
  box-shadow: 0 12px 24px rgba(0,0,0,0.24);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.34;
  cursor: default;
  user-select: text;
}

.event-detail-header {
  display: block;
}

.event-detail-title {
  margin: 0;
  color: #172027;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.event-detail-meta {
  margin: 5px 0 7px;
  color: #52616b;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.25;
}

.event-detail-popover p,
.era-detail-popover p,
.bar-detail-popover p {
  margin: 0;
}

.event-filters {
  position: absolute;
  top: 6px;
  left: 0;
  z-index: 95;
  width: max-content;
  min-width: 156px;
  max-width: min(300px, calc(100vw - var(--label-width) - 20px));
  max-height: none;
  margin: 0;
  padding: 7px 8px 8px;
  overflow-y: visible;
  border: 1px solid rgba(31,37,41,0.42);
  background: rgba(167,169,166,0.96);
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  cursor: default;
}

.event-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px 0 6px;
}

.event-filter-row {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) 68px;
  align-items: center;
  gap: 5px;
}

.event-filter-action,
.event-filter-only {
  min-height: 20px;
  padding: 0 5px;
  border: 1px solid rgba(31,37,41,0.32);
  background: rgba(255,255,255,0.58);
  color: #172027;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}

.event-filter-only {
  width: 68px;
}

.event-filter-action:hover,
.event-filter-action:focus-visible,
.event-filter-only:hover,
.event-filter-only:focus-visible {
  background: rgba(255,255,255,0.88);
  outline: 2px solid rgba(32,114,188,0.35);
}

.event-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 20px;
  color: #172027;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.05;
  cursor: pointer;
}

.event-filter span {
  overflow: visible;
  white-space: nowrap;
}

.event-filter input {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--blue);
}

.event-filters-toggle,
.language-toggle {
  position: absolute;
  right: 4px;
  z-index: 96;
  width: 20px;
  height: 20px;
  display: grid;
  place-content: center;
  gap: 2px;
  padding: 0;
  border: 1px solid rgba(31,37,41,0.42);
  background: rgba(167,169,166,0.96);
  color: #172027;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
  cursor: pointer;
}

.event-filters-toggle {
  top: 5px;
}

.language-toggle {
  top: 29px;
  overflow: hidden;
}

.language-flag {
  display: block;
  width: 14px;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(31,37,41,0.45);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.28);
}

.flag-armenia {
  background: linear-gradient(
    to bottom,
    #d90012 0 33.333%,
    #0033a0 33.333% 66.666%,
    #f2a800 66.666% 100%
  );
}

.flag-russia {
  background: linear-gradient(
    to bottom,
    #ffffff 0 33.333%,
    #0039a6 33.333% 66.666%,
    #d52b1e 66.666% 100%
  );
}

.flag-us {
  position: relative;
  background: repeating-linear-gradient(
    to bottom,
    #b22234 0 1px,
    #ffffff 1px 2px
  );
}

.flag-us::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 5px;
  background: #3c3b6e;
}

.event-filters-toggle span {
  display: block;
  width: 11px;
  height: 2px;
  background: #172027;
}

.event-filters-toggle:hover,
.event-filters-toggle:focus-visible,
.language-toggle:hover,
.language-toggle:focus-visible {
  background: rgba(225,226,222,0.96);
  outline: 2px solid rgba(32,114,188,0.35);
}

.timeline-error {
  margin: 24px;
  max-width: 760px;
  padding: 18px;
  border: 1px solid #b85a5a;
  background: #fff7f7;
  color: #631f1f;
}

.timeline-error pre {
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .timeline {
    --label-width: 86px;
  }

  .row-label,
  .events-label {
    font-size: 10px;
    padding: 0 7px;
  }
}
