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

:root {
  --blue:        #003f8a;
  --blue-mid:    #0055bb;
  --blue-light:  #0066cc;
  --gold:        #f5a623;
  --gold-dark:   #c8851a;
  --green:       #2d9c6e;
  --bg:          #0a1628;
  --surface:     #111e35;
  --border:      rgba(255,255,255,.1);
  --text:        #e8edf5;
  --muted:       #4a6080;
  --line-w:      3px;
  --node-size:   78px;
  --radius:      12px;
  --ease:        cubic-bezier(.4,0,.2,1);
  --timeline-bg-image: url("assets/bg-4.png");
  --bg-overlay-start: rgba(6, 16, 31, .82);
  --bg-overlay-end: rgba(6, 16, 31, .9);
  --bg-effect-opacity: .86;
  --bg-accent-cyan-opacity: .22;
  --bg-accent-gold-opacity: .11;
  --bg-shade-start-opacity: .86;
  --bg-shade-end-opacity: .94;
  --header-bg: rgba(10,22,40,.95);
  --header-height: 62px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: none;
}

body {
  position: relative;
  background-image:
    radial-gradient(circle at 20% 12%, rgba(25, 211, 217, var(--bg-accent-cyan-opacity)), transparent 30%),
    radial-gradient(circle at 78% 18%, rgba(246, 238, 38, var(--bg-accent-gold-opacity)), transparent 28%),
    linear-gradient(180deg, rgba(5, 44, 63, var(--bg-shade-start-opacity)), rgba(5, 16, 32, var(--bg-shade-end-opacity))),
    linear-gradient(var(--bg-overlay-start), var(--bg-overlay-end)),
    var(--timeline-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity .25s var(--ease);
}

body.video-bg-active .bg-video {
  opacity: 1;
}

body.video-bg-active::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(var(--bg-overlay-start), var(--bg-overlay-end));
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      112deg,
      transparent 0 48px,
      rgba(75, 225, 229, .045) 49px 51px,
      transparent 52px 112px
    );
  mix-blend-mode: screen;
  opacity: var(--bg-effect-opacity);
}

/* ── Header ────────────────────────────────── */
.h-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.h-back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: rgba(255,255,255,.5);
  font-size: .78rem;
  font-weight: 500;
  text-decoration: none;
  padding: .35rem .8rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  transition: color .18s, background .18s, border-color .18s;
  white-space: nowrap;
}
.h-back:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.3);
}

.h-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.h-logo {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -.3px;
  color: #fff;
}
.h-divider { color: rgba(255,255,255,.25); font-size: .9rem; }
.h-subtitle {
  font-size: .8rem;
  font-weight: 400;
  color: rgba(255,255,255,.45);
  letter-spacing: .3px;
}

.h-fullscreen {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.7);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  padding: .38rem .9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
  white-space: nowrap;
}
.h-fullscreen:hover {
  background: rgba(255,255,255,.13);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}

.editor-toggle {
  position: absolute;
  right: 9.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: .38rem .82rem;
  border: 1px solid rgba(245,166,35,.34);
  border-radius: 999px;
  background: rgba(245,166,35,.1);
  color: #ffd58e;
  font-family: inherit;
  font-size: .76rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
.editor-toggle:hover {
  background: rgba(245,166,35,.18);
  border-color: rgba(245,166,35,.62);
  color: #fff;
}

/* ── Stage ────────────────────────────────── */
.h-stage {
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 60px;
  gap: 0;
  position: relative;
  z-index: 1;
  touch-action: none;
  user-select: none;
}

.h-stage::before,
.h-stage::after {
  content: '';
  position: absolute;
  left: 2vw;
  right: 2vw;
  height: 150px;
  pointer-events: none;
  opacity: calc(var(--bg-effect-opacity) * .78);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(49, 232, 231, .2), transparent 62%),
    repeating-radial-gradient(ellipse at 50% 52%, transparent 0 18px, rgba(74, 222, 224, .22) 19px 21px, transparent 22px 42px);
  filter: blur(.2px);
  transform: skewY(-4deg);
}
.h-stage::before {
  top: calc(50% - 225px);
}
.h-stage::after {
  top: calc(50% + 55px);
  transform: scaleX(-1) skewY(4deg);
  opacity: calc(var(--bg-effect-opacity) * .48);
}

/* ── Row wrap ── */
.h-row-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Era label */
.h-row-era {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding-left: 2px;
}
.era-bottom {
  text-align: right;
  padding-right: 2px;
  padding-left: 0;
}

/* ── Row ── */
.h-row {
  display: flex;
  align-items: center;
  position: relative;
  height: calc(var(--node-size) + 48px);
}

.h-row::after {
  content: '';
  position: absolute;
  left: 2%;
  right: 2%;
  top: 50%;
  height: 76px;
  transform: translateY(-50%);
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 10% 50%, rgba(244, 238, 40, .18), transparent 12%),
    radial-gradient(ellipse at 35% 48%, rgba(57, 216, 223, .18), transparent 22%),
    radial-gradient(ellipse at 68% 50%, rgba(73, 215, 222, .15), transparent 26%),
    repeating-linear-gradient(168deg, transparent 0 21px, rgba(116, 234, 236, .22) 22px 23px, transparent 24px 46px);
  opacity: calc(var(--bg-effect-opacity) * .9);
  mix-blend-mode: screen;
}

/* Horizontal connecting line */
.h-row::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: var(--line-w);
  background: linear-gradient(90deg, rgba(210,248,255,.1), rgba(230,253,255,.85), rgba(210,248,255,.16));
  border-radius: 2px;
  z-index: 0;
  box-shadow: 0 0 10px rgba(97, 223, 229, .58);
}

/* ── Bridge (carriage-return connector) ── */
.h-bridge {
  padding: 0;
  height: clamp(60px, 10vh, 110px);
  flex-shrink: 0;
}
.h-bridge-inner {
  height: 100%;
  margin: 0 calc(var(--node-size) / 2 - var(--line-w) / 2);
  border-right: var(--line-w) solid rgba(230,253,255,.6);
  border-bottom: var(--line-w) solid rgba(230,253,255,.6);
  border-bottom-right-radius: 20px;
  opacity: .42;
  box-shadow: 0 0 12px rgba(97,223,229,.45);
}

/* ── Year node ── */
.h-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  cursor: pointer;
  touch-action: none;
}

/* Tooltip */
.h-tooltip {
  position: absolute;
  bottom: calc(var(--node-size) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(0,20,55,.92);
  color: rgba(255,255,255,.9);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
  max-width: 220px;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(6px);
}
/* tooltip arrow */
.h-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0,20,55,.92);
}

/* Row 2: tooltip above circles, pointing down — same side (above) */
#row2 .h-tooltip {
  bottom: calc(var(--node-size) + 12px);
  top: auto;
}

.h-node:hover .h-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Circle */
.h-circle {
  width: var(--node-size);
  height: var(--node-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 28%, rgba(255,255,255,.42), transparent 17%),
    linear-gradient(155deg, #4ff2ff 0%, #13bbe8 44%, #006cc4 100%);
  border: 3px solid rgba(105, 229, 246, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .5px;
  color: rgba(255,255,255,.95);
  text-shadow: 0 2px 5px rgba(0,0,0,.48);
  transition: transform .18s var(--ease), filter .18s, box-shadow .18s;
  filter: drop-shadow(0 0 11px rgba(56, 220, 247, .7)) drop-shadow(0 4px 9px rgba(0,0,0,.5));
  position: relative;
  z-index: 2;
  box-shadow:
    inset 0 0 0 5px rgba(255,255,255,.13),
    inset 0 -12px 24px rgba(0, 45, 115, .28),
    0 0 0 6px rgba(86, 225, 246, .18),
    0 0 0 10px rgba(86, 225, 246, .08);
}

.h-circle::before,
.h-circle::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.h-circle::before {
  inset: -10px;
  border: 3px solid rgba(105, 229, 246, .74);
  box-shadow: 0 0 18px rgba(65, 221, 242, .62);
}
.h-circle::after {
  inset: 7px;
  border: 1px solid rgba(255,255,255,.24);
  box-shadow: inset 0 0 18px rgba(255,255,255,.16), 0 0 10px rgba(255,255,255,.1);
}

.h-node:hover .h-circle {
  transform: scale(1.18);
  filter: drop-shadow(0 0 18px rgba(45, 221, 238, .9)) drop-shadow(0 5px 14px rgba(0,0,0,.55));
}

.h-node.tuio-hover .h-circle {
  transform: scale(1.2);
  box-shadow: 0 0 0 4px rgba(255,255,255,.42);
  filter: drop-shadow(0 0 16px rgba(255,255,255,.42)) drop-shadow(0 5px 16px rgba(0,0,0,.55));
}

/* Milestone */
.h-node.milestone .h-circle {
  background:
    radial-gradient(circle at 36% 27%, rgba(255,255,255,.54), transparent 18%),
    linear-gradient(155deg, #f9ff58 0%, #f1eb18 54%, #cadb16 100%);
  border-color: rgba(250, 246, 63, .94);
  color: #10202d;
  text-shadow: 0 1px 3px rgba(255,255,255,.5);
  filter: drop-shadow(0 0 22px rgba(241, 238, 37, .86)) drop-shadow(0 4px 10px rgba(0,0,0,.48));
  box-shadow:
    inset 0 0 0 5px rgba(255,255,255,.22),
    inset 0 -12px 24px rgba(169, 145, 0, .2),
    0 0 0 6px rgba(241, 238, 37, .2),
    0 0 0 11px rgba(241, 238, 37, .1);
}
.h-node.milestone .h-circle::before {
  border-color: rgba(250, 246, 63, .82);
  box-shadow: 0 0 22px rgba(241, 238, 37, .72);
}
.h-node.milestone:hover .h-circle {
  filter: drop-shadow(0 0 26px rgba(241, 238, 37, .9)) drop-shadow(0 5px 16px rgba(0,0,0,.55));
}

/* Future */
.h-node.future .h-circle {
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.18), transparent 20%),
    linear-gradient(155deg, rgba(156, 171, 185, .86), rgba(68, 82, 98, .88));
  border-color: rgba(220,231,240,.24);
  color: rgba(255,255,255,.72);
  opacity: .78;
  filter: grayscale(.25) drop-shadow(0 0 8px rgba(210,225,240,.2)) drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.h-node.future .h-circle::before {
  border-color: rgba(220,231,240,.26);
  box-shadow: 0 0 12px rgba(210,225,240,.22);
}
.h-node.future:hover .h-circle {
  opacity: .9;
  filter: grayscale(.2) drop-shadow(0 0 12px rgba(210,225,240,.36));
}

/* Milestone pulse ring */
.h-node.milestone .h-circle::before {
  animation: none;
}
@keyframes pulse {
  0%, 100% { opacity: .4; transform: scale(1); }
  50%       { opacity: 0; transform: scale(1.3); }
}

/* ── Modal ────────────────────────────────── */
.hm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,10,30,.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
}
.hm-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.hm-modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 720px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  transform: translateY(18px) scale(.97);
  transition: transform .22s var(--ease);
  overflow: hidden;
}
.hm-backdrop.open .hm-modal {
  transform: translateY(0) scale(1);
}

.hm-close {
  position: absolute;
  top: .9rem;
  right: .9rem;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s;
  z-index: 10;
}
.hm-close:hover { background: rgba(255,255,255,.25); }

.hm-header {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  padding: 1.6rem 1.75rem 1.4rem;
  position: relative;
  flex-shrink: 0;
}
.hm-header.milestone {
  background: linear-gradient(135deg, #7a5000, var(--gold-dark));
}
.hm-header.future {
  background: linear-gradient(135deg, #1e2d42, #2d3e55);
}

.hm-year {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
  margin-bottom: .3rem;
}
.hm-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  padding-right: 2rem;
}

.hm-body {
  flex: 1;
  min-height: 0;
  background: #fff;
  font-size: .88rem;
  line-height: 1.6;
  color: #333;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hm-media {
  flex-shrink: 0;
  height: 190px;
  background: #eef2f7;
  border-bottom: 1px solid #e2e8f0;
  overflow: hidden;
}
.hm-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #fff;
}

/* Plain text fallback (years without details) */
.hm-plain {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 1.75rem 1.6rem;
}
.hm-plain p { color: #555; margin-bottom: .7rem; }
.hm-plain p:last-child { margin-bottom: 0; }

/* ── Tabs ── */
.hm-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.hm-tab {
  flex: 1;
  padding: .7rem .5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
  text-align: center;
  line-height: 1.3;
}
.hm-tab:hover { color: #444; background: #f0f4f8; }
.hm-tab.active {
  color: var(--blue-mid);
  border-bottom-color: var(--blue-mid);
  background: #fff;
}
.hm-modal.milestone .hm-tab.active {
  color: #7a5000;
  border-bottom-color: #c8851a;
}

.hm-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem 1.25rem;
  background-size: cover;
  background-position: center;
}
.hm-tab-content .hm-card-label {
  font-size: .9rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: .5rem;
}
.hm-tab-content .hm-card-text {
  font-size: .82rem;
  color: #555;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}
.hm-tab-image,
.timeline-popup-tab-image {
  margin: .25rem 0 0;
  background: #fff;
}
.hm-tab-image img,
.timeline-popup-tab-image img {
  width: 100%;
  max-height: var(--popup-image-height, 220px);
  display: block;
  object-fit: contain;
}
.hm-tab-content .tag-row { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.hm-tab-content .tag {
  display: inline-flex; align-items: center; gap: .28rem;
  font-size: .7rem; font-weight: 600; padding: .16rem .5rem;
  border-radius: 999px; background: rgba(0,63,138,.08); color: var(--blue-mid);
  border: 1px solid rgba(0,63,138,.18);
}
.hm-tab-content .tag img,
.timeline-popup-tags .flag-tag img {
  width: 20px;
  height: 15px;
  display: block;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

/* Timer progress bar */
.hm-tab-progress {
  height: 4px;
  background: #e2e8f0;
  flex-shrink: 0;
}
.hm-tab-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
}
.hm-modal.milestone .hm-tab-bar {
  background: linear-gradient(90deg, #7a5000, var(--gold-dark));
}

/* Conquista legislative footer */
.hm-conquista {
  background: #111827;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  flex-shrink: 0;
}
.hm-conquista-icon {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.hm-conquista-content {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.hm-conquista-label {
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #fff;
}
.hm-conquista-text {
  font-size: .8rem;
  color: rgba(255,255,255,.65);
  line-height: 1.5;
}

/* Future message */
.hm-body .future-msg {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1.75rem;
  color: #888;
}
.hm-body .future-msg span { display: block; font-size: 2.2rem; margin-bottom: .6rem; }
.hm-body .future-msg strong { color: #555; }

/* TUIO multi-touch layer */
.tuio-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
}

.tuio-cursor {
  --cursor-hue: 200;
  position: absolute;
  left: 0;
  top: 0;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 2px solid hsl(var(--cursor-hue), 90%, 62%);
  border-radius: 50%;
  background: hsla(var(--cursor-hue), 90%, 55%, .16);
  box-shadow: 0 0 24px hsla(var(--cursor-hue), 90%, 55%, .55);
  transition: transform .06s linear;
}

.tuio-cursor::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: hsl(var(--cursor-hue), 90%, 62%);
}

.tuio-cursor span {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  min-width: 26px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(0, 10, 30, .75);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  text-align: center;
}

.tuio-status {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 920;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 34px;
  padding: .42rem .7rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(8, 18, 34, .82);
  color: rgba(255,255,255,.72);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.tuio-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #718096;
  box-shadow: 0 0 12px rgba(113,128,150,.65);
}

.tuio-status[data-state="online"] .tuio-status-dot {
  background: #f5a623;
  box-shadow: 0 0 12px rgba(245,166,35,.65);
}

.tuio-status[data-state="multi"] .tuio-status-dot {
  background: #35d07f;
  box-shadow: 0 0 14px rgba(53,208,127,.75);
}

.tuio-status[data-state="connecting"] .tuio-status-dot {
  background: #7eb8ff;
  box-shadow: 0 0 12px rgba(126,184,255,.65);
}

.popup-layer {
  position: fixed;
  inset: 0;
  z-index: 820;
  pointer-events: none;
}

.timeline-popup {
  position: absolute;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 380px;
  min-height: 0;
  font-family: var(--popup-font-family, 'Inter', system-ui, sans-serif);
  font-size: var(--popup-font-size, 13px);
  border: 2px solid rgba(70, 222, 222, .42);
  border-radius: 18px;
  background: #041429;
  box-shadow: 0 0 0 1px rgba(230,238,45,.08), 0 0 28px rgba(33,217,207,.16), 0 24px 60px rgba(0,0,0,.62);
  pointer-events: auto;
  animation: popupIn .16s var(--ease);
}

.timeline-popup.attention {
  animation: popupPulse .22s var(--ease);
}

/* Header */
.timeline-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: 1.05rem 1.35rem 1rem;
  background: linear-gradient(100deg, #084e80 0%, #008f91 36%, #60bb83 68%, #ecea00 100%);
  flex-shrink: 0;
}
.timeline-popup.milestone .timeline-popup-header {
  background: linear-gradient(100deg, #084e80 0%, #008f91 36%, #60bb83 68%, #ecea00 100%);
}
.timeline-popup.future .timeline-popup-header {
  background: linear-gradient(100deg, #084e80 0%, #008f91 36%, #60bb83 68%, #ecea00 100%);
}
.timeline-popup-year {
  display: block;
  margin-bottom: .14rem;
  color: rgba(255,255,255,.72);
  font-size: var(--popup-year-size, 16px);
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: none;
}
.timeline-popup h2 {
  color: #fff;
  font-size: 1.2em;
  line-height: 1.25;
  padding-right: .4rem;
  text-shadow: 0 1px 10px rgba(0,0,0,.22);
}

.timeline-popup-media {
  flex-shrink: 0;
  height: max(138px, var(--popup-image-height, 138px));
  background: #eef2f7;
  border-bottom: 1px solid #e2e8f0;
  overflow: hidden;
}
.timeline-popup-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #fff;
}
.timeline-popup-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,245,.58);
  color: #07162a;
  cursor: pointer;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timeline-popup-close:hover { background: rgba(255,255,245,.82); }

/* Tab bar */
.timeline-popup-tabs {
  display: flex;
  background: #041429;
  border-top: 1px solid rgba(80,225,224,.32);
  border-bottom: 1px solid rgba(80,225,224,.26);
  flex-shrink: 0;
}
.timeline-popup-tab {
  flex: 1;
  padding: .72rem .5rem;
  background: none;
  border: none;
  border-bottom: 4px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 1em;
  font-weight: 700;
  color: rgba(228,234,246,.66);
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.timeline-popup-tab:hover { color: #f5f564; background: rgba(255,255,255,.04); }
.timeline-popup-tab.active {
  color: #f5f564;
  border-bottom-color: #f5f564;
  background: transparent;
}
.timeline-popup.milestone .timeline-popup-tab.active {
  color: #f5f564;
  border-bottom-color: #f5f564;
}

/* Body — cresce para caber o conteúdo, sem scroll */
.timeline-popup-body {
  flex-shrink: 0;
  padding: 1.45rem 1.6rem 1.7rem;
  background: #041429;
  background-size: cover;
  background-position: center;
  min-height: var(--popup-tab-min-height, 150px);
  max-height: var(--popup-tab-max-height, 360px);
  overflow-y: auto;
}
.timeline-popup-body p {
  color: rgba(236,242,255,.86);
  font-size: 1.32em;
  line-height: 1.22;
  margin-bottom: .45rem;
  white-space: pre-line;
}
.timeline-popup-body p:last-child { margin-bottom: 0; }
.timeline-popup-inline-image {
  margin: .15rem 0 .6rem;
  height: var(--popup-image-height, 138px);
}
.timeline-popup-inline-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,.96);
}
.timeline-popup-label {
  display: block;
  margin-bottom: .85rem;
  color: #fff;
  font-size: 1.45em;
  font-weight: 800;
}
.timeline-popup-category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
  margin: -.1rem 0 .55rem;
}
.timeline-popup-category-tags span {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(0,94,184,.18);
  border-radius: 999px;
  padding: .16rem .48rem;
  background: rgba(0,94,184,.08);
  color: var(--blue-mid);
  font-size: .68em;
  font-weight: 800;
}
.timeline-popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
}
.timeline-popup-tags > span {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .14rem .42rem;
  border: 1px solid rgba(82,226,217,.32);
  border-radius: 999px;
  background: rgba(82,226,217,.09);
  color: #d9fbff;
  font-size: .82em;
  font-weight: 700;
}

/* Tab progress bar */
.timeline-popup-tab-progress {
  height: 5px;
  background: rgba(255,255,255,.08);
  flex-shrink: 0;
}
.timeline-popup-tab-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d9b300 0%, #f5f564 36%, #50dccd 68%, #1e9ce5 100%);
}
.timeline-popup.milestone .timeline-popup-tab-bar {
  background: linear-gradient(90deg, #d9b300 0%, #f5f564 36%, #50dccd 68%, #1e9ce5 100%);
}

/* Conquista footer */
.timeline-popup-conquista {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem 1.1rem;
  background: #111827;
  flex-shrink: 0;
}
.timeline-popup-conquista-icon {
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.timeline-popup-conquista-text-wrap {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.timeline-popup-conquista-label {
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #fff;
}
.timeline-popup-conquista-text {
  font-size: .76rem;
  color: rgba(255,255,255,.6);
  line-height: 1.45;
}

/* Meta */
.timeline-popup-meta {
  height: var(--popup-footer-height, 25px);
  min-height: var(--popup-footer-height, 25px);
  max-height: var(--popup-footer-height, 25px);
  padding: 0 .55rem;
  border-top: 1px solid rgba(80,225,224,.24);
  background: #041429;
  color: rgba(226,236,255,.62);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .35rem;
  overflow: hidden;
}
.timeline-popup-meta-label {
  color: rgba(226,236,255,.64);
  text-transform: uppercase;
  white-space: nowrap;
}
.timeline-popup-meta-tags {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .18rem;
  overflow: hidden;
}
.timeline-popup-meta-tags > span {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: rgba(237,255,255,.94);
  font-size: .72rem;
  border: 1px solid rgba(75,232,219,.55);
  border-radius: 999px;
  padding: .08rem .44rem;
  background: rgba(75,232,219,.12);
  box-shadow: 0 0 10px rgba(75,232,219,.42), inset 0 0 8px rgba(75,232,219,.12);
}
.timeline-popup-meta-tags img {
  width: 14px;
  height: 10px;
  display: block;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.16);
}
.timeline-popup-meta-empty {
  min-width: 0;
  overflow: hidden;
  color: rgba(255,255,255,.48);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes popupIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes popupPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

@keyframes popupTimer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.multi-detail {
  position: fixed;
  left: 1rem;
  right: 10.5rem;
  bottom: 1rem;
  z-index: 850;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .75rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}

.multi-detail.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.multi-card {
  min-height: 146px;
  max-height: 210px;
  overflow: hidden;
  padding: .85rem .95rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius);
  background: rgba(12, 25, 45, .92);
  box-shadow: 0 14px 38px rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
}

.multi-card.milestone {
  border-color: rgba(245,166,35,.55);
}

.multi-card.future {
  border-style: dashed;
}

.multi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .45rem;
}

.multi-year {
  display: block;
  margin-bottom: .18rem;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: 1.8px;
}

.multi-card h3 {
  color: #fff;
  font-size: .9rem;
  line-height: 1.25;
}

.multi-card p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  color: rgba(255,255,255,.64);
  font-size: .76rem;
  line-height: 1.45;
}

.multi-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.8);
  cursor: pointer;
}

.multi-close:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
}

.multi-meta {
  margin-top: .55rem;
  color: rgba(255,255,255,.36);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.timeline-editor {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  z-index: 1400;
  width: min(430px, calc(100vw - 20px));
  background: #f7f9fc;
  color: #152033;
  border-left: 1px solid rgba(15, 23, 42, .18);
  box-shadow: -24px 0 56px rgba(0,0,0,.45);
  transform: translateX(104%);
  transition: transform .22s var(--ease);
  pointer-events: auto;
}
.timeline-editor.open {
  transform: translateX(0);
}
.editor-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem .75rem;
  background: #10213a;
  color: #fff;
}
.editor-kicker {
  display: block;
  margin-bottom: .16rem;
  color: rgba(255,255,255,.5);
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.editor-head h2 {
  font-size: 1rem;
  line-height: 1.2;
}
.editor-icon {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  font-size: 1.05rem;
}
.editor-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #e8edf5;
  border-bottom: 1px solid #d8e0ec;
}
.editor-tab {
  min-height: 42px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #66758c;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.editor-tab.active {
  background: #fff;
  color: var(--blue-mid);
  border-bottom-color: var(--blue-mid);
}
.editor-pane {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
}
.editor-pane.active {
  display: block;
}
.editor-sheet-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin-bottom: .9rem;
  border: 1px solid rgba(34,197,94,.32);
  border-radius: 8px;
  background: rgba(34,197,94,.08);
  color: #157347;
  font-size: .76rem;
  font-weight: 800;
  text-decoration: none;
}
.editor-sheet-link-primary {
  border-color: rgba(0,85,187,.34);
  background: rgba(0,85,187,.08);
  color: var(--blue-mid);
}
.editor-original {
  margin-bottom: 1rem;
  padding: .8rem;
  border: 1px solid #d6b06a;
  border-radius: 8px;
  background: #fff8ea;
}
.editor-original-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .45rem;
}
.editor-original-head span {
  color: #8a5b00;
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.editor-original-head strong {
  color: #8a5b00;
  font-size: .78rem;
}
.editor-original h3 {
  margin-bottom: .55rem;
  color: #172033;
  font-size: .88rem;
  line-height: 1.28;
}
.editor-original img {
  width: 100%;
  max-height: 130px;
  display: block;
  object-fit: contain;
  margin-bottom: .6rem;
  border: 1px solid rgba(138,91,0,.18);
  border-radius: 6px;
  background: #fff;
}
.editor-original textarea {
  width: 100%;
  border: 1px solid rgba(138,91,0,.24);
  border-radius: 8px;
  background: #fff;
  color: #3f3f46;
  font: inherit;
  font-size: .78rem;
  line-height: 1.45;
  padding: .55rem;
  resize: vertical;
}
.editor-original p,
.editor-original small {
  color: #76520c;
  font-size: .72rem;
  line-height: 1.45;
}
.editor-original small {
  display: block;
  margin-top: .45rem;
  word-break: break-all;
}
.editor-field {
  display: grid;
  gap: .35rem;
  margin-bottom: .82rem;
}
.editor-field span,
.editor-check span,
.editor-detail legend,
.editor-subhead {
  color: #34445c;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .2px;
}
.editor-field input,
.editor-field select,
.editor-field textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  font: inherit;
  font-size: .82rem;
  padding: .48rem .6rem;
}
.editor-field textarea {
  resize: vertical;
  line-height: 1.45;
}
.editor-field input[type="color"] {
  padding: 3px;
}
.editor-field input[type="range"] {
  padding: 0;
}
.editor-upload {
  display: flex;
  gap: .5rem;
  margin: -.35rem 0 .85rem;
}
.editor-upload button {
  min-height: 34px;
  padding: .42rem .7rem;
  border: 1px solid rgba(0,85,187,.28);
  border-radius: 8px;
  background: rgba(0,85,187,.08);
  color: var(--blue-mid);
  font-family: inherit;
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
}
.editor-upload button:hover {
  background: rgba(0,85,187,.14);
}
.editor-apply-row {
  display: flex;
  justify-content: flex-end;
  margin: -.25rem 0 .75rem;
}
.editor-apply-row button {
  min-height: 34px;
  padding: .42rem .72rem;
  border: 1px solid rgba(245,166,35,.38);
  border-radius: 8px;
  background: rgba(245,166,35,.12);
  color: #9a6400;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
}
.editor-apply-row button:hover {
  background: rgba(245,166,35,.2);
}
.editor-image-preview {
  width: 100%;
  max-height: 150px;
  display: block;
  object-fit: contain;
  margin: -.35rem 0 .85rem;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #fff;
}
.editor-range output {
  float: right;
  color: var(--blue-mid);
}
.editor-check {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 34px;
  margin-bottom: .62rem;
}
.editor-check input {
  width: 18px;
  height: 18px;
}
.editor-subhead {
  margin: 1rem 0 .65rem;
  padding-top: .85rem;
  border-top: 1px solid #d8e0ec;
  text-transform: uppercase;
}
.editor-detail {
  margin: 0 0 .8rem;
  padding: .75rem;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: #fff;
}
.editor-detail legend {
  padding: 0 .35rem;
}
.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .45rem;
  padding: .75rem;
  border-top: 1px solid #d8e0ec;
  background: #fff;
}
.editor-actions button {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #25344c;
  font-family: inherit;
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}
.editor-actions button:first-child {
  background: var(--blue-mid);
  border-color: var(--blue-mid);
  color: #fff;
}

@media (max-width: 900px) {
  .multi-detail {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
  .editor-toggle {
    right: 1rem;
    bottom: -44px;
  }
}
