/* V21.4 — Home unificada definitiva
   Esta camada carrega DEPOIS do styles.css e congela a ESTRUTURA da página Início.
   Os temas podem mudar só variáveis visuais: cor, contraste, sombra e textura.
*/

html[data-theme="claro"] body[data-active-view="dashboard"] {
  --home-bg: #f5f1e8;
  --home-panel: rgba(255, 249, 236, .94);
  --home-panel-soft: rgba(255, 253, 248, .82);
  --home-text: #10233f;
  --home-muted: #5c6f86;
  --home-line: rgba(183, 139, 69, .28);
  --home-gold: #a97823;
  --home-shadow: 0 18px 42px rgba(33, 41, 56, .10);
}
html[data-theme="escuro"] body[data-active-view="dashboard"] {
  --home-bg: #07121b;
  --home-panel: rgba(9, 25, 35, .96);
  --home-panel-soft: rgba(13, 33, 46, .88);
  --home-text: #f8ead0;
  --home-muted: #c7b99e;
  --home-line: rgba(196, 149, 58, .34);
  --home-gold: #d0a24a;
  --home-shadow: 0 18px 42px rgba(0, 0, 0, .22);
}
html[data-theme="pergaminho"] body[data-active-view="dashboard"] {
  --home-bg: #ead8af;
  --home-panel: rgba(255, 246, 224, .92);
  --home-panel-soft: rgba(255, 250, 238, .78);
  --home-text: #2c1f0e;
  --home-muted: #725633;
  --home-line: rgba(139, 94, 40, .28);
  --home-gold: #9a6b1f;
  --home-shadow: 0 18px 42px rgba(70, 42, 12, .12);
}

html[data-theme] body[data-active-view="dashboard"] #dashboardView,
html[data-theme] body[data-active-view="dashboard"] .memorial-dashboard {
  background: var(--home-bg) !important;
  color: var(--home-text) !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-dashboard {
  display: grid !important;
  gap: 16px !important;
  width: 100% !important;
  max-width: 1480px !important;
  margin: 0 auto !important;
  padding: 0 0 28px !important;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .memorial-dashboard,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-panel h3,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .memorial-hero-card h2,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .family-chapter-card strong {
  font-family: Georgia, "Times New Roman", serif !important;
}

/* HERO: a grade é uma só nos três temas */
html[data-theme] body[data-active-view="dashboard"] #dashboardHero.memorial-hero-card {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 148px !important;
  align-items: center !important;
  gap: 28px !important;
  min-height: 220px !important;
  padding: 34px 38px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 0 0 28px 28px !important;
  background: var(--home-panel) !important;
  color: var(--home-text) !important;
  box-shadow: var(--home-shadow) !important;
  overflow: hidden !important;
}
html[data-theme] body[data-active-view="dashboard"] #dashboardHero.memorial-hero-card::before,
html[data-theme] body[data-active-view="dashboard"] #dashboardHero.memorial-hero-card::after {
  content: none !important;
  display: none !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-family-cover-img {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  opacity: .34 !important;
  filter: saturate(.9) contrast(.94) !important;
}
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-family-cover-img { opacity: .24 !important; filter: brightness(.65) saturate(.88) contrast(1.05) !important; }
html[data-theme] body[data-active-view="dashboard"] .memorial-hero-content,
html[data-theme] body[data-active-view="dashboard"] .memorial-crest-box {
  position: relative !important;
  z-index: 2 !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-hero-card h2 {
  margin: 10px 0 10px !important;
  color: var(--home-text) !important;
  font-size: clamp(2rem, 4vw, 4rem) !important;
  line-height: .95 !important;
  letter-spacing: -.04em !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-hero-card p {
  max-width: 780px !important;
  margin: 0 !important;
  color: var(--home-muted) !important;
  font-size: 1.05rem !important;
  line-height: 1.55 !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-crest-box {
  width: 148px !important;
  min-height: 148px !important;
  display: grid !important;
  place-items: center !important;
  gap: 8px !important;
  padding: 16px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 24px !important;
  background: var(--home-panel-soft) !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-crest-box img {
  width: 82px !important;
  height: 82px !important;
  object-fit: contain !important;
  border-radius: 18px !important;
}
html[data-theme] body[data-active-view="dashboard"] .memorial-crest-box span {
  color: var(--home-muted) !important;
  font-size: .78rem !important;
  font-weight: 900 !important;
  text-align: center !important;
}

/* Estatísticas e atalhos: exatamente o mesmo grid */
html[data-theme] body[data-active-view="dashboard"] .dashboard-stats-strip {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 12px !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-stats-strip article,
html[data-theme] body[data-active-view="dashboard"] .quick-action {
  display: grid !important;
  place-items: center !important;
  min-height: 74px !important;
  padding: 14px 12px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 18px !important;
  background: var(--home-panel-soft) !important;
  color: var(--home-text) !important;
  box-shadow: none !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-stats-strip strong {
  color: var(--home-gold) !important;
  font-size: 2.2rem !important;
  line-height: 1 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-stats-strip span {
  color: var(--home-muted) !important;
  font-weight: 800 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-quick-bar {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  gap: 12px !important;
}
html[data-theme] body[data-active-view="dashboard"] .quick-action {
  gap: 6px !important;
  font-weight: 900 !important;
}
html[data-theme] body[data-active-view="dashboard"] .quick-action .ui-icon { color: var(--home-gold) !important; }

/* GRID PRINCIPAL: posição fixa por componente */
html[data-theme] body[data-active-view="dashboard"] .dashboard-content-grid,
html[data-theme] body[data-active-view="dashboard"] .dashboard-premium-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-auto-flow: row !important;
  gap: 16px !important;
  align-items: stretch !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-origins-panel { grid-column: 1 / -1 !important; grid-row: 1 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-timeline-panel { grid-column: 1 !important; grid-row: 2 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-memories-panel { grid-column: 2 !important; grid-row: 2 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-birthday-panel { grid-column: 1 !important; grid-row: 3 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-today-panel { grid-column: 2 !important; grid-row: 3 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-chapters-panel { grid-column: 1 / -1 !important; grid-row: 4 !important; }
html[data-theme] body[data-active-view="dashboard"] .dashboard-panel {
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 24px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 24px !important;
  background: var(--home-panel) !important;
  color: var(--home-text) !important;
  box-shadow: var(--home-shadow) !important;
  overflow: hidden !important;
}
html[data-theme] body[data-active-view="dashboard"] .panel-heading-row {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 16px !important;
  margin-bottom: 16px !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-panel h3 {
  margin: 4px 0 0 !important;
  color: var(--home-text) !important;
  font-size: 1.35rem !important;
  line-height: 1.15 !important;
}
html[data-theme] body[data-active-view="dashboard"] .eyebrow {
  display: inline-flex !important;
  align-items: center !important;
  min-height: 28px !important;
  padding: 6px 12px !important;
  border: 1px solid color-mix(in srgb, var(--home-gold) 26%, transparent) !important;
  border-radius: 999px !important;
  background: color-mix(in srgb, var(--home-gold) 14%, transparent) !important;
  color: var(--home-gold) !important;
  font-size: .76rem !important;
  font-weight: 950 !important;
  letter-spacing: .04em !important;
  text-transform: uppercase !important;
}
html[data-theme] body[data-active-view="dashboard"] .button.ghost {
  min-height: 44px !important;
  padding: 0 16px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 14px !important;
  background: var(--home-panel-soft) !important;
  color: var(--home-text) !important;
}

/* Listas internas: mesma altura visual, sem cartões gigantes no escuro */
html[data-theme] body[data-active-view="dashboard"] .dashboard-list {
  display: grid !important;
  gap: 10px !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-list > *,
html[data-theme] body[data-active-view="dashboard"] .today-history-card,
html[data-theme] body[data-active-view="dashboard"] .dashboard-country-chip {
  border: 1px solid var(--home-line) !important;
  border-radius: 18px !important;
  background: var(--home-panel-soft) !important;
  color: var(--home-text) !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-country-list {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  margin-top: 12px !important;
  background: transparent !important;
  border: 0 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-country-chip {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-height: 42px !important;
  padding: 8px 14px !important;
  font-size: 1.05rem !important;
}

/* Mapa realista */
html[data-theme] body[data-active-view="dashboard"] .dashboard-origin-map {
  border: 1px solid var(--home-line) !important;
  border-radius: 24px !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
}
.memorial-world-map {
  --map-ink: var(--home-text, #2C1F0E);
  --map-muted: var(--home-muted, #765b35);
  --map-paper: var(--home-panel, rgba(255,248,229,.94));
  --map-line: var(--home-line, rgba(139,94,40,.24));
  display: grid !important;
  gap: 14px !important;
  width: 100% !important;
}
.memorial-world-header { display: none !important; }
.memorial-world-stage {
  position: relative !important;
  isolation: isolate !important;
  min-height: 520px !important;
  border: 1px solid var(--map-line) !important;
  border-radius: 24px !important;
  background: linear-gradient(135deg, #fbf0d2 0%, #e8d3a9 52%, #fff8e4 100%) !important;
  overflow: hidden !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 18px 44px rgba(70,42,12,.10) !important;
}
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-world-stage { min-height: 430px !important; }
.memorial-world-base {
  position: absolute !important;
  inset: 0 !important;
  z-index: 1 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  opacity: .95 !important;
  pointer-events: none !important;
  user-select: none !important;
}
html[data-theme="escuro"] .memorial-world-stage {
  background: linear-gradient(135deg, #081720 0%, #0c2430 55%, #07131b 100%) !important;
}
html[data-theme="escuro"] .memorial-world-base {
  opacity: .80 !important;
  filter: brightness(.72) contrast(1.15) saturate(.75) sepia(.18) hue-rotate(160deg) !important;
}
html[data-theme="claro"] .memorial-world-base { opacity: .88 !important; }
html[data-theme="pergaminho"] .memorial-world-base { opacity: .98 !important; }
.memorial-world-routes {
  position: absolute !important;
  inset: 0 !important;
  z-index: 4 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
}
.memorial-route-line {
  fill: none !important;
  stroke: var(--home-gold, #b9842b) !important;
  stroke-width: 3.5 !important;
  stroke-linecap: round !important;
  stroke-dasharray: 10 7 !important;
  filter: drop-shadow(0 2px 2px rgba(255,255,255,.68)) !important;
}
html[data-theme="escuro"] .memorial-route-line { filter: drop-shadow(0 2px 5px rgba(0,0,0,.6)) !important; }
.memorial-map-pin {
  position: absolute !important;
  z-index: 7 !important;
  transform: translate(-50%, -50%) !important;
  display: block !important;
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  cursor: pointer !important;
  overflow: visible !important;
}
.memorial-map-pin .pin-dot {
  position: absolute !important;
  inset: 0 !important;
  border-radius: 999px !important;
  background: var(--home-gold) !important;
  border: 3px solid rgba(255,255,255,.92) !important;
  box-shadow: 0 0 0 4px rgba(196,149,58,.24), 0 7px 18px rgba(45,25,8,.24) !important;
}
.memorial-map-pin .pin-card {
  position: absolute !important;
  left: 26px !important;
  top: -42px !important;
  z-index: 8 !important;
  width: 164px !important;
  min-height: 64px !important;
  display: grid !important;
  gap: 3px !important;
  padding: 10px 12px !important;
  border: 1px solid var(--home-line) !important;
  border-radius: 18px !important;
  background: color-mix(in srgb, var(--home-panel) 92%, transparent) !important;
  color: var(--home-text) !important;
  text-align: left !important;
  box-shadow: 0 14px 34px rgba(42,28,10,.15) !important;
  backdrop-filter: blur(8px) !important;
}
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-route-feature { display: none !important; }
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin .pin-card {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: none !important;
}
.memorial-world-timeline {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 10px !important;
  padding: 16px 18px !important;
  border: 1px solid var(--map-line) !important;
  border-radius: 20px !important;
  background: color-mix(in srgb, var(--map-paper) 82%, transparent) !important;
  overflow-x: auto !important;
}
.memorial-world-timeline span { min-width: 120px !important; text-align:center !important; display:grid !important; gap:4px !important; color:var(--map-muted) !important; font-weight:800 !important; }
.memorial-world-timeline span::before { content:'' !important; width:12px !important; height:12px !important; margin:0 auto 3px !important; border-radius:999px !important; background:var(--map-paper) !important; border:3px solid var(--home-gold) !important; }
.memorial-world-timeline strong { color: var(--home-gold) !important; font-size:.86rem !important; }
.memorial-world-timeline em { color: var(--map-muted) !important; font-style:normal !important; font-size:.76rem !important; }

/* Capítulos: número nunca sobrepõe texto */
html[data-theme] body[data-active-view="dashboard"] .dashboard-chapters-grid {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 14px !important;
}
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card {
  position: relative !important;
  display: grid !important;
  grid-template-columns: 38px minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  column-gap: 12px !important;
  row-gap: 5px !important;
  align-items: start !important;
  min-height: 118px !important;
  padding: 18px !important;
  border: 0 !important;
  border-radius: 18px !important;
  text-align: left !important;
  overflow: hidden !important;
  color: #fffaf0 !important;
  box-shadow: none !important;
}
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card span {
  position: static !important;
  grid-row: 1 / 3 !important;
  width: 34px !important;
  height: 34px !important;
  display: grid !important;
  place-items: center !important;
  margin: 0 !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.88) !important;
  color: #87571c !important;
  font-size: .95rem !important;
  font-weight: 950 !important;
  line-height: 1 !important;
}
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card strong,
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card small {
  position: static !important;
  min-width: 0 !important;
  margin: 0 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card strong { color: #fffaf0 !important; font-size: 1rem !important; line-height: 1.15 !important; }
html[data-theme] body[data-active-view="dashboard"] .family-chapter-card small { color: rgba(255,250,240,.86) !important; font-size: .82rem !important; line-height: 1.32 !important; }

@media (max-width: 1180px) {
  html[data-theme] body[data-active-view="dashboard"] .dashboard-content-grid,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-premium-grid { grid-template-columns: 1fr !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-origins-panel,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-timeline-panel,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-memories-panel,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-birthday-panel,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-today-panel,
  html[data-theme] body[data-active-view="dashboard"] .dashboard-chapters-panel { grid-column: 1 !important; grid-row: auto !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-quick-bar { grid-template-columns: repeat(3, minmax(0,1fr)) !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-chapters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .memorial-world-stage { min-height: 480px !important; }
}
@media (max-width: 760px) {
  html[data-theme] body[data-active-view="dashboard"] #dashboardHero.memorial-hero-card { grid-template-columns: 1fr !important; padding: 22px !important; min-height: 180px !important; }
  html[data-theme] body[data-active-view="dashboard"] .memorial-crest-box { width: 100% !important; min-height: 118px !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-stats-strip { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-quick-bar { grid-template-columns: 1fr 1fr !important; }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-chapters-grid { grid-template-columns: 1fr !important; }
  .memorial-map-pin .pin-card { display: none !important; }
  .memorial-world-stage,
  body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-world-stage { min-height: 330px !important; }
  .memorial-world-timeline { padding: 12px !important; }
}


/* ======================================================================
   V21.5 — Correção estrutural definitiva da Home
   Problema encontrado: o tema escuro ainda herdava auto-flow do grid antigo.
   Solução: a Home agora usa uma pilha explícita no HTML com linhas internas.
   Assim a ordem não depende mais de grid-row/grid-column por tema.
   ====================================================================== */
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-auto-flow: row !important;
  gap: 16px !important;
  align-items: stretch !important;
}

html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-origins-panel,
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel,
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-home-row {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  min-width: 0 !important;
}

html[data-theme] body[data-active-view="dashboard"] .dashboard-home-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 16px !important;
  align-items: stretch !important;
}

html[data-theme] body[data-active-view="dashboard"] .dashboard-home-row > .dashboard-panel {
  width: 100% !important;
  min-width: 0 !important;
  height: auto !important;
  grid-column: auto !important;
  grid-row: auto !important;
}

html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-origins-panel {
  order: 1 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-row-stories {
  order: 2 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-row-family {
  order: 3 !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel {
  order: 4 !important;
}

/* Reforço: nenhuma regra antiga do tema escuro pode transformar painéis em grade própria. */
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-origins-panel,
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel {
  grid-column: 1 / -1 !important;
  grid-row: auto !important;
}
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-row-stories > .dashboard-timeline-panel,
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-row-stories > .dashboard-memories-panel,
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-row-family > .dashboard-birthday-panel,
html[data-theme="escuro"] body[data-active-view="dashboard"] .dashboard-home-row-family > .dashboard-today-panel {
  grid-column: auto !important;
  grid-row: auto !important;
}

/* Ajuste visual: capítulos ficam com largura real de linha inteira nos 3 temas. */
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel .dashboard-chapters-grid {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 14px !important;
}
html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel .family-chapter-card {
  min-width: 0 !important;
}

@media (max-width: 1180px) {
  html[data-theme] body[data-active-view="dashboard"] .dashboard-home-row {
    grid-template-columns: 1fr !important;
  }
  html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel .dashboard-chapters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 760px) {
  html[data-theme] body[data-active-view="dashboard"] .dashboard-home-layout > .dashboard-chapters-panel .dashboard-chapters-grid {
    grid-template-columns: 1fr !important;
  }
}


/* V21.11 — Home: pins alinhados ao mapa e cards mais compactos */
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin .pin-title {
  font-size: .98rem !important;
  line-height: 1.05 !important;
}
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin .pin-card em {
  display: block !important;
  margin-top: 2px !important;
  font-size: .82rem !important;
  line-height: 1.18 !important;
  font-weight: 700 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin.country-br .pin-card { top: -26px !important; }
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin.country-es .pin-card { top: -30px !important; }
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin.country-jp .pin-card { top: -30px !important; }
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-world-timeline strong { font-size: .96rem !important; }
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-world-timeline em {
  max-width: 180px !important;
  margin: 0 auto !important;
  line-height: 1.15 !important;
}


/* V21.12 — Home: cards dos pins respeitam as bordas do mapa */
.memorial-map-pin.pin-edge-right .pin-card {
  left: auto !important;
  right: 26px !important;
}
.memorial-map-pin.pin-edge-left .pin-card {
  left: 26px !important;
  right: auto !important;
}
.memorial-map-pin.pin-edge-top .pin-card {
  top: 16px !important;
}
.memorial-map-pin.pin-edge-bottom .pin-card {
  top: -86px !important;
}
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin.country-jp .pin-card {
  right: 26px !important;
  left: auto !important;
}


/* =============================================================================
   V22 — CORREÇÕES DE REGRESSÃO
   ============================================================================= */

/* 1. Timeline card: equalizar visual premium para claro/sépia/pergaminho
   (no escuro já estava perfeito; claro e pergaminho mostravam layout antigo) */
html[data-theme="claro"] .timeline-event-card.timeline-premium-card,
html[data-theme="sepia"] .timeline-event-card.timeline-premium-card,
html[data-theme="pergaminho"] .timeline-event-card.timeline-premium-card {
  display: grid !important;
  grid-template-columns: 4.45rem 1fr !important;
  gap: .85rem !important;
  align-items: start !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

/* Medalha dourada nos temas claros */
html[data-theme="claro"] .timeline-medallion,
html[data-theme="sepia"] .timeline-medallion,
html[data-theme="pergaminho"] .timeline-medallion {
  display: grid !important;
  place-items: center !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at 35% 23%, #fff9dc 0 20%, #e6c073 48%, #b8892a 100%) !important;
  border: 1px solid rgba(76,45,12,.36) !important;
  box-shadow: 0 15px 30px rgba(44,31,14,.18), inset 0 2px 0 rgba(255,255,255,.65) !important;
  color: #2C1F0E !important;
  font-size: 1.38rem !important;
}

/* Corpo do evento nos temas claros */
html[data-theme="claro"] .timeline-event-body,
html[data-theme="sepia"] .timeline-event-body {
  border: 1px solid rgba(184,137,42,.28) !important;
  background: linear-gradient(135deg, rgba(255,252,241,.98), rgba(242,224,186,.82)) !important;
  box-shadow: 0 8px 24px rgba(44,31,14,.08), inset 0 1px 0 rgba(255,255,255,.62) !important;
}

html[data-theme="pergaminho"] .timeline-event-body {
  border: 1px solid rgba(118,69,30,.26) !important;
  background: linear-gradient(135deg, rgba(255,248,225,.98), rgba(238,216,170,.86)) !important;
}

/* Título do evento */
html[data-theme="claro"] .timeline-event-top strong,
html[data-theme="sepia"] .timeline-event-top strong,
html[data-theme="pergaminho"] .timeline-event-top strong {
  color: #2c1f0e !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

/* Descrição */
html[data-theme="claro"] .timeline-event-body p,
html[data-theme="sepia"] .timeline-event-body p,
html[data-theme="pergaminho"] .timeline-event-body p {
  color: #4a2e10 !important;
}

/* Data */
html[data-theme="claro"] .timeline-date-seal,
html[data-theme="sepia"] .timeline-date-seal,
html[data-theme="pergaminho"] .timeline-date-seal {
  color: #7a4b1a !important;
  font-weight: 800 !important;
  font-size: .8rem !important;
  background: rgba(255,243,210,.9) !important;
  border: 1px solid rgba(166,112,47,.24) !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}


/* 2. Sombra fantasma na linha de geração (tree-card-generation agora ocupa
   grid-column: 1/-1 e herda background do legado) */
.family-card .tree-card-generation {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="escuro"] .family-card .tree-card-generation {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

html[data-theme="escuro"] #treeView .family-card .tree-card-generation {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #c2d8e8 !important;
}


/* 3. Mapa da home: garantir que memorial-world-map não seja afetado
   pelo CSS de origens (origins-unified usa body[data-active-view="originsMap"]) */
body[data-active-view="dashboard"] .memorial-world-map {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

body[data-active-view="dashboard"] .memorial-world-stage {
  display: block !important;
  position: relative !important;
}


/* V22.2 — Timeline card escuro equalizado com claro/sépia/pergaminho */
html[data-theme="escuro"] .timeline-event-card.timeline-premium-card {
  display: grid !important;
  grid-template-columns: 4.45rem 1fr !important;
  gap: .85rem !important;
  align-items: start !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

html[data-theme="escuro"] .timeline-event-body {
  border: 1px solid rgba(196,149,58,.24) !important;
  background: linear-gradient(135deg, rgba(22,38,52,.98), rgba(14,26,38,.94)) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.04) !important;
}

html[data-theme="escuro"] .timeline-event-top strong {
  color: #fff4dc !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

html[data-theme="escuro"] .timeline-event-body p {
  color: rgba(220,200,170,.85) !important;
}

html[data-theme="escuro"] .timeline-date-seal {
  color: #c4953a !important;
  font-weight: 800 !important;
  font-size: .8rem !important;
  background: rgba(196,149,58,.12) !important;
  border: 1px solid rgba(196,149,58,.28) !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

/* V22.2 — .tree-card-generation sem fundo em todos os temas */
.family-card .tree-card-generation {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}


/* =============================================================================
   V22.3 — CARD "HISTÓRIA VIVA" (.dashboard-mini-event) para temas claro/sépia/pergaminho
   O tema escuro já tinha CSS próprio no styles.css. Os outros temas usavam botão genérico.
   ============================================================================= */

/* ── Layout base do grid de eventos ── */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-timeline,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-timeline,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-timeline {
  position: relative !important;
  display: grid !important;
  gap: 12px !important;
  padding: 8px 0 4px !important;
}

/* linha vertical dourada */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-timeline::before,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-timeline::before,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-timeline::before {
  content: '' !important;
  position: absolute !important;
  left: 78px !important;
  top: 16px !important;
  bottom: 16px !important;
  width: 3px !important;
  border-radius: 99px !important;
  background: linear-gradient(180deg, transparent, rgba(184,137,42,.5), transparent) !important;
}

/* ── Card do evento ── */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-event,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-event,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-event {
  position: relative !important;
  display: grid !important;
  grid-template-columns: 58px 58px 1fr !important;
  gap: 12px !important;
  align-items: center !important;
  padding: 10px !important;
  border: 1px solid rgba(184,137,42,.22) !important;
  border-radius: 18px !important;
  background: linear-gradient(135deg, rgba(255,252,241,.98), rgba(242,224,186,.82)) !important;
  box-shadow: 0 6px 18px rgba(70,42,12,.08), inset 0 1px 0 rgba(255,255,255,.65) !important;
  color: #2c1f0e !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: transform .16s ease, box-shadow .16s ease !important;
  width: 100% !important;
}

html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-event:hover,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-event:hover,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-event:hover {
  transform: translateX(2px) !important;
  box-shadow: 0 10px 28px rgba(70,42,12,.13), inset 0 1px 0 rgba(255,255,255,.7) !important;
}

/* ── Ano ── */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-year,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-year,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-year {
  color: #b8892a !important;
  font-weight: 900 !important;
  font-size: .92rem !important;
}

/* ── Medalha dourada ── */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-medal,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-medal,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-medal {
  position: relative !important;
  z-index: 2 !important;
  display: grid !important;
  place-items: center !important;
  width: 54px !important;
  height: 54px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(184,137,42,.46) !important;
  background: radial-gradient(circle at 35% 22%, #fff9dc 0 20%, #e6c073 48%, #b8892a 100%) !important;
  box-shadow: 0 8px 20px rgba(70,42,12,.18), inset 0 2px 0 rgba(255,255,255,.65) !important;
  color: #2c1f0e !important;
  font-size: 1.25rem !important;
}

/* ── Texto ── */
html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-copy,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-copy,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-copy {
  display: grid !important;
  gap: 3px !important;
  min-width: 0 !important;
}

html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-copy strong,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-copy strong,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-copy strong {
  color: #2c1f0e !important;
  font-size: 1rem !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-copy small,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-copy small,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-copy small {
  color: rgba(70,45,14,.72) !important;
  font-size: .82rem !important;
  line-height: 1.35 !important;
}

html[data-theme="claro"] body[data-active-view="dashboard"] .dashboard-mini-copy em,
html[data-theme="sepia"] body[data-active-view="dashboard"] .dashboard-mini-copy em,
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-copy em {
  color: #b8892a !important;
  font-style: normal !important;
  font-size: .78rem !important;
  font-weight: 700 !important;
}

/* pergaminho: tom ainda mais quente */
html[data-theme="pergaminho"] body[data-active-view="dashboard"] .dashboard-mini-event {
  background: linear-gradient(135deg, rgba(255,248,225,.98), rgba(238,216,170,.86)) !important;
  border-color: rgba(118,69,30,.22) !important;
}


/* =============================================================================
   V22.3 — MAPA DA HOME: corrigir visibilidade do palco e do SVG base
   ============================================================================= */

/* Garantir que o SVG do mapa mundi apareça na home em todos os temas */
body[data-active-view="dashboard"] .memorial-world-stage {
  display: block !important;
  position: relative !important;
  overflow: hidden !important;
  min-height: 430px !important;
}

body[data-active-view="dashboard"] .memorial-world-base {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  opacity: .95 !important;
  z-index: 1 !important;
}

html[data-theme="escuro"] body[data-active-view="dashboard"] .memorial-world-base {
  opacity: .80 !important;
  filter: brightness(.72) contrast(1.15) saturate(.75) sepia(.18) hue-rotate(160deg) !important;
}

/* Pins sempre visíveis na home (não só no hover) */
body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body[data-active-view="dashboard"] .memorial-world-map.compact .memorial-map-pin .pin-card {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

/* Override de qualquer opacity:0 residual do styles.css legado */
body[data-active-view="dashboard"] .memorial-world-map .memorial-map-pin .pin-card {
  opacity: 1 !important;
  visibility: visible !important;
}
