/*
 * Hoja de estilos principal del Atlas Biblico.
 * Agrupa los tokens visuales, la estructura responsive y los estados de
 * interaccion. Cada bloque importante esta documentado para facilitar el
 * mantenimiento sin acoplar el diseno a un personaje concreto.
 */

/* Tokens globales: paleta natural, radios, sombras y altura de cabecera. */
:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --paper-deep: #eee7d7;
  --ivory: #fffdf7;
  --ink: #21333a;
  --ink-soft: #5f6b6e;
  --line: rgba(50, 62, 62, 0.16);
  --line-strong: rgba(50, 62, 62, 0.28);
  --clay: #9b4c38;
  --clay-dark: #743729;
  --clay-soft: #ecd7ca;
  --sea: #315f78;
  --sea-soft: #d6e4e8;
  --gold: #a98245;
  --olive: #6d7554;
  --shadow: 0 18px 45px rgba(34, 45, 45, 0.16);
  --shadow-soft: 0 10px 28px rgba(34, 45, 45, 0.1);
  --radius-xl: 24px;
  --radius-lg: 17px;
  --radius-md: 12px;
  --topbar-height: 74px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* Normalizacion minima y estilos base de controles. */
* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

html {
  background: var(--paper);
}

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

body.has-overlay {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
canvas:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(155, 76, 56, 0.38);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.025em;
}

p {
  line-height: 1.56;
}

code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: rgba(47, 61, 64, 0.08);
  font-size: 0.88em;
}

/* Utilidades de accesibilidad y enlaces de salto. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--clay);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Estado de carga y error fatal compartido por la entrada. */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 43%, rgba(78, 119, 132, 0.18), transparent 28%),
    linear-gradient(145deg, #f8f3e8, #e8e4d8);
  text-align: center;
}

.loading-screen h1 {
  max-width: 620px;
  margin: 4px 0 8px;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.loading-screen > p:last-child {
  color: var(--ink-soft);
}

.loading-mark {
  position: relative;
  width: 82px;
  height: 82px;
  margin-bottom: 24px;
  border: 1px solid rgba(49, 95, 120, 0.26);
  border-radius: 50%;
  background: radial-gradient(circle at 37% 32%, #7e9da8, #345e70 70%);
  box-shadow: 0 18px 55px rgba(49, 95, 120, 0.23);
}

.loading-mark::before,
.loading-mark::after {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 248, 226, 0.35);
  border-radius: 50%;
  content: "";
}

.loading-mark::after {
  inset: 18px 3px;
}

.loading-mark span {
  position: absolute;
  inset: -8px;
  border: 2px solid transparent;
  border-top-color: var(--clay);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Estructura principal a pantalla completa. */
.atlas-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--paper);
}

/* Cabecera, marca, selectores y herramientas globales. */
.topbar {
  position: relative;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  height: var(--topbar-height);
  padding: 0 18px 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 247, 238, 0.96);
  box-shadow: 0 2px 18px rgba(35, 45, 44, 0.05);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-compass {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(155, 76, 56, 0.22);
  border-radius: 50%;
  background: #f3e7da;
  color: var(--clay);
  font-size: 1rem;
}

.brand-block strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  line-height: 1.05;
}

.brand-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Selector de personajes propio: conserva la identidad visual y el orden cronologico. */
.character-picker {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(220px, 280px);
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.character-picker-label {
  white-space: nowrap;
}

.character-picker-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 44px;
  gap: 12px;
  padding: 6px 11px 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--ivory);
  box-shadow: 0 4px 15px rgba(34, 45, 45, 0.06);
  color: var(--ink);
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.character-picker-button:hover,
.character-picker-button[aria-expanded="true"] {
  border-color: rgba(155, 76, 56, 0.48);
  box-shadow: 0 8px 22px rgba(34, 45, 45, 0.11);
}

.character-picker-button:active {
  transform: translateY(1px);
}

#character-picker-current {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

#character-picker-current strong,
#character-picker-current small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#character-picker-current strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
  font-weight: 600;
}

#character-picker-current small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.62rem;
  font-weight: 650;
}

.picker-chevron {
  color: var(--clay);
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 180ms ease;
}

.character-picker-button[aria-expanded="true"] .picker-chevron {
  transform: rotate(180deg);
}

.character-menu {
  position: absolute;
  z-index: 230;
  top: calc(100% + 10px);
  right: 0;
  width: min(410px, calc(100vw - 28px));
  max-height: min(68vh, 590px);
  padding: 7px;
  overflow: auto;
  border: 1px solid rgba(50, 62, 62, 0.2);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.99);
  box-shadow: 0 24px 70px rgba(26, 38, 40, 0.25);
}

.character-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.character-option:hover,
.character-option:focus-visible {
  border-color: var(--line);
  background: #f7f0e4;
}

.character-option:active {
  transform: translateY(1px);
}

.character-option.is-active {
  border-color: rgba(155, 76, 56, 0.24);
  background: var(--clay-soft);
}

.character-option > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.character-option strong,
.character-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-option strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  font-weight: 600;
}

.character-option small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.character-order {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: rgba(49, 95, 120, 0.1);
  color: var(--sea);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.character-option.is-active .character-order {
  background: var(--clay);
  color: white;
}

.character-check {
  color: var(--clay-dark);
  font-size: 0.95rem;
  text-align: center;
}

.compact-field {
  display: grid;
  grid-template-columns: auto minmax(110px, auto);
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.compact-field select,
.playback-options select {
  min-width: 120px;
  height: 38px;
  padding: 0 33px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%) calc(100% - 15px) 16px / 5px 5px no-repeat,
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%) calc(100% - 10px) 16px / 5px 5px no-repeat,
    var(--ivory);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.journey-field-mobile {
  display: none;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.icon-button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.icon-button:hover,
.tool-button:hover,
.tool-button.is-active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.icon-button:active,
.tool-button:active {
  transform: translateY(1px);
}

.icon-button kbd,
.search-hint kbd {
  min-width: 22px;
  padding: 3px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--ivory);
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-family: inherit;
  text-align: center;
}

/* Rejilla de escritorio: carril de recorridos y escenario cartografico. */
.workspace {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  height: calc(100% - var(--topbar-height));
  min-height: 0;
}

/* Navegacion lateral de recorridos del personaje activo. */
.journey-rail {
  position: relative;
  z-index: 20;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 22px 15px 14px;
  border-right: 1px solid var(--line);
  overflow: hidden;
  background: linear-gradient(180deg, #f9f6ee, #f3eee3);
}

.rail-heading {
  padding: 0 8px 13px;
}

.rail-heading h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.rail-heading > p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}

.journey-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  padding: 4px 2px 8px;
  overflow: auto;
  scrollbar-width: thin;
}

.journey-card {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 57px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.journey-card:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.58);
  transform: translateX(2px);
}

.journey-card.is-active {
  border-color: rgba(155, 76, 56, 0.2);
  background: #fffaf0;
  box-shadow: 0 7px 20px rgba(93, 68, 48, 0.08);
}

.journey-order {
  display: inline-grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-size: 0.75rem;
}

.journey-card.is-active .journey-order {
  border-color: var(--clay);
  background: var(--clay);
  color: white;
}

.journey-card-copy {
  min-width: 0;
}

.journey-card-copy strong,
.journey-card-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-card-copy strong {
  font-size: 0.82rem;
  line-height: 1.35;
}

.journey-card-copy small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.journey-arrow {
  color: var(--ink-soft);
  font-size: 1.3rem;
}

.rail-overview-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.52);
  font-size: 0.75rem;
  font-weight: 750;
}

.rail-overview-button:hover {
  background: var(--ivory);
}

/* Superficie del globo y controles superpuestos. */
.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 48% 46%, rgba(248, 246, 230, 0.12), transparent 35%),
    linear-gradient(165deg, #dce1d9 0%, #cfd8d6 45%, #e6e1d4 100%);
}

#globe-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#globe-canvas.is-dragging {
  cursor: grabbing;
}

.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(238, 235, 222, 0.47), transparent 25%, transparent 75%, rgba(230, 229, 219, 0.28)),
    linear-gradient(0deg, rgba(225, 224, 214, 0.58), transparent 22%);
}

/* Tarjeta editorial que resume el recorrido seleccionado. */
.journey-summary {
  position: absolute;
  z-index: 8;
  top: 22px;
  left: 23px;
  display: grid;
  grid-template-columns: 47px minmax(0, 1fr);
  gap: 13px;
  width: min(510px, calc(100% - 500px));
  min-width: 380px;
  padding: 15px 16px 13px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 17px;
  background: rgba(249, 247, 239, 0.84);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.summary-index {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border: 1px solid rgba(155, 76, 56, 0.24);
  border-radius: 50%;
  background: var(--clay-soft);
  color: var(--clay-dark);
  font-family: Georgia, serif;
}

.summary-copy {
  min-width: 0;
}

.summary-copy h1 {
  margin: 0 0 5px;
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  line-height: 1.12;
}

.summary-copy > p:not(.eyebrow) {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.77rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.summary-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 650;
}

.summary-meta span + span::before {
  margin-right: 12px;
  content: "·";
}

.summary-focus {
  grid-column: 2;
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--clay-dark);
  font-size: 0.7rem;
  font-weight: 800;
}

.summary-focus span {
  margin-left: 4px;
  transition: margin 160ms ease;
}

.summary-focus:hover span {
  margin-left: 8px;
}

/* Controles compactos de zoom, vista general, capas y modo guiado. */
.map-controls {
  position: absolute;
  z-index: 12;
  right: 19px;
  top: 83px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  border: 1px solid rgba(45, 58, 58, 0.14);
  border-radius: 13px;
  background: rgba(251, 249, 242, 0.89);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.map-controls button {
  display: grid;
  width: 37px;
  height: 37px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.map-controls button:hover {
  background: rgba(49, 95, 120, 0.09);
}

.map-controls button + button {
  border-top: 1px solid var(--line);
}

.map-tools {
  position: absolute;
  z-index: 12;
  top: 22px;
  right: 18px;
  display: flex;
  gap: 7px;
}

.tool-button {
  border-color: rgba(45, 58, 58, 0.14);
  background: rgba(251, 249, 242, 0.89);
  box-shadow: 0 7px 20px rgba(35, 45, 44, 0.08);
  backdrop-filter: blur(10px);
}

.guided-dot {
  width: 8px;
  height: 8px;
  border: 1px solid var(--clay);
  border-radius: 50%;
}

.tool-button.is-active .guided-dot {
  background: var(--clay);
  box-shadow: 0 0 0 3px rgba(155, 76, 56, 0.13);
}

.map-tooltip {
  position: absolute;
  z-index: 40;
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  transform: translate(12px, -38px);
  pointer-events: none;
  background: rgba(35, 49, 54, 0.92);
  color: white;
  box-shadow: 0 8px 24px rgba(22, 32, 35, 0.2);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Panel de capas y conmutadores personalizados. */
.layers-panel {
  position: absolute;
  z-index: 35;
  top: 69px;
  right: 18px;
  width: 340px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: panel-in 180ms ease both;
}

.layers-panel header,
.bible-header,
.info-dialog > header,
.textual-dialog > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.layers-panel h2,
.info-dialog h2,
.textual-dialog h2,
.bible-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.close-button {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.66);
}

.close-button:hover {
  border-color: var(--line-strong);
  background: white;
}

.close-button svg {
  width: 17px;
  height: 17px;
}

.layer-options {
  display: grid;
  gap: 1px;
  padding: 8px 0 14px;
}

.layer-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 55px;
  padding: 7px 2px;
  cursor: pointer;
}

.layer-row strong,
.layer-row small {
  display: block;
}

.layer-row strong {
  font-size: 0.78rem;
}

.layer-row small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.66rem;
}

.layer-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.layer-row i {
  position: relative;
  flex: 0 0 auto;
  width: 39px;
  height: 22px;
  border-radius: 999px;
  background: #d6d6cf;
  transition: background 160ms ease;
}

.layer-row i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(33, 51, 58, 0.24);
  content: "";
  transition: transform 160ms ease;
}

.layer-row input:checked + i {
  background: var(--clay);
}

.layer-row input:checked + i::after {
  transform: translateX(17px);
}

.layer-row input:focus-visible + i {
  outline: 3px solid rgba(155, 76, 56, 0.3);
  outline-offset: 3px;
}

/* Leyenda compacta: cada tipo politico conserva un codigo lineal distinto. */
.region-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  margin: -2px 0 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8f4ea;
}

.region-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.61rem;
  font-weight: 700;
}

.region-legend-item i {
  display: block;
  width: 22px;
  height: 0;
  border-top: 2px solid currentColor;
}

.region-empire {
  color: #67506a;
}

.region-kingdom {
  color: #9b4c38;
}

.region-province {
  color: #356b7b;
}

.region-province i {
  border-top-style: dashed;
}

.region-territory {
  color: #68714e;
}

.region-territory i {
  border-top-style: dashed;
}

.region-cultural-region {
  color: #8a6a43;
}

.region-cultural-region i {
  border-top-style: dotted;
}

/* Ficha contextual de lugar, etapa, acontecimiento o recorrido. */
.context-panel {
  position: absolute;
  z-index: 30;
  top: 75px;
  right: 18px;
  bottom: 150px;
  display: flex;
  width: min(390px, calc(100% - 36px));
  min-height: 220px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: var(--shadow);
  backdrop-filter: blur(13px);
  animation: panel-in 190ms ease both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 19px 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf7, #faf7ef);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.13;
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.35;
}

.panel-scroll {
  min-height: 0;
  flex: 1;
  padding: 17px 19px 22px;
  overflow: auto;
  scrollbar-color: rgba(74, 84, 82, 0.28) transparent;
  scrollbar-width: thin;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f2ede0;
  color: var(--ink);
  font-weight: 750;
}

.confidence-high,
.narrative-explicit {
  border-color: rgba(86, 112, 80, 0.24);
  background: #e7eddf;
  color: #4b6548;
}

.confidence-probable,
.narrative-inference,
.route-regional {
  border-color: rgba(169, 130, 69, 0.27);
  background: #f4ead0;
  color: #735e31;
}

.confidence-disputed,
.confidence-area,
.narrative-debated,
.narrative-historical-reconstruction {
  border-color: rgba(155, 76, 56, 0.24);
  background: #f2ded2;
  color: #743729;
}

.route-sea {
  border-color: rgba(49, 95, 120, 0.23);
  background: var(--sea-soft);
  color: #264e65;
}

.route-land,
.route-stay {
  border-color: rgba(155, 76, 56, 0.23);
  background: var(--clay-soft);
  color: var(--clay-dark);
}

.lead-copy {
  margin-bottom: 16px;
  color: #34464b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
  line-height: 1.62;
}

/* Tarjeta de etapa: historia primero y datos de ruta condensados en una sola linea. */
.stage-story {
  margin: 0 0 15px;
  padding: 13px 14px;
  border-left: 3px solid var(--clay);
  border-radius: 0 10px 10px 0;
  background: #f6eee2;
  color: #344348;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  line-height: 1.56;
}

.stage-story span {
  display: block;
  margin-bottom: 5px;
  color: var(--clay-dark);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stage-route-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8ef;
}

.stage-route-points {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.stage-route-points button {
  max-width: 42%;
  min-width: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-route-points button:hover {
  color: var(--clay-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stage-route-distance {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 0.67rem;
  font-weight: 750;
}

.panel-scroll > p:not(.lead-copy) {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.accuracy-note {
  margin: 15px 0;
  padding: 12px 13px;
  border-left: 3px solid var(--gold);
  border-radius: 0 9px 9px 0;
  background: #f5efe0;
}

.accuracy-note strong {
  display: block;
  margin-bottom: 4px;
  color: #5e5036;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.accuracy-note p {
  margin: 0;
  color: #6c614e;
  font-size: 0.73rem;
  line-height: 1.5;
}

.panel-section {
  margin-top: 21px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.panel-section h3,
.section-heading h3 {
  margin: 0 0 10px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #efe9dd;
  color: var(--ink-soft);
  font-size: 0.64rem;
  font-weight: 800;
}

.event-list {
  display: grid;
  gap: 5px;
}

.event-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.event-row:hover {
  background: #f6f0e5;
}

.event-mark {
  width: 8px;
  height: 8px;
  border: 2px solid var(--clay);
  border-radius: 50%;
}

.event-row strong,
.event-row small {
  display: block;
}

.event-row strong {
  font-size: 0.78rem;
  line-height: 1.35;
}

.event-row small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.63rem;
  line-height: 1.35;
}

.empty-copy {
  margin: 8px 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.chip-list,
.reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip-list button,
.reference-pill {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #faf7ee;
  color: var(--ink);
  font-size: 0.67rem;
  font-weight: 700;
}

.chip-list button:hover,
.reference-pill:hover {
  border-color: rgba(155, 76, 56, 0.33);
  background: var(--clay-soft);
}

.reference-list {
  margin-bottom: 12px;
}

.source-details {
  margin-top: 20px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.source-details summary {
  cursor: pointer;
  font-weight: 750;
}

.source-details ul {
  padding-left: 19px;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 15px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--line);
}

.fact-grid > div {
  min-height: 70px;
  padding: 11px;
  background: #fbf8f0;
}

.fact-grid dt {
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fact-grid dd {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
}

.fact-grid button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--clay-dark);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(155, 76, 56, 0.3);
  text-underline-offset: 2px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.74rem;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--clay-dark);
  background: var(--clay);
  color: white;
  box-shadow: 0 7px 16px rgba(116, 55, 41, 0.18);
}

.primary-button:hover {
  background: var(--clay-dark);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #fbf8f0;
  color: var(--ink);
}

.secondary-button:hover {
  background: white;
}

.full-width {
  width: 100%;
}

/* Reproductor y linea temporal sincronizados con la camara. */
.timeline-shell {
  position: absolute;
  z-index: 18;
  right: 18px;
  bottom: 16px;
  left: 18px;
  display: grid;
  grid-template-columns: minmax(450px, 0.95fr) minmax(0, 1.45fr);
  gap: 14px;
  min-height: 116px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  background: rgba(250, 248, 241, 0.91);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.playback-controls {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 2px 4px;
  border-right: 1px solid var(--line);
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.transport-controls button {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.transport-controls button:hover {
  background: rgba(49, 95, 120, 0.09);
}

.transport-controls .play-button {
  width: 45px;
  height: 45px;
  margin: 0 2px;
  background: var(--clay);
  color: white;
  box-shadow: 0 7px 18px rgba(116, 55, 41, 0.25);
}

.transport-controls .play-button:hover {
  background: var(--clay-dark);
}

.play-symbol {
  margin-left: 2px;
  font-size: 0.82rem;
}

.pause-symbol {
  font-weight: 900;
  letter-spacing: -0.2em;
  transform: translateX(-1px);
}

.playback-current {
  min-width: 0;
}

.playback-title-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.playback-title-row > span {
  flex: 0 0 auto;
  color: var(--clay);
  font-family: Georgia, serif;
  font-size: 0.7rem;
}

.playback-title-row strong {
  overflow: hidden;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-progress {
  height: 4px;
  margin-top: 9px;
  border-radius: 99px;
  overflow: hidden;
  background: #dfddd4;
}

.journey-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--clay);
  transition: width 80ms linear;
}

.playback-options {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.playback-options select {
  min-width: 62px;
  width: 62px;
  height: 32px;
  padding-left: 8px;
  font-size: 0.68rem;
}

.toggle-chip {
  min-height: 31px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.63rem;
  font-weight: 750;
}

.toggle-chip.is-on {
  border-color: rgba(155, 76, 56, 0.25);
  background: var(--clay-soft);
  color: var(--clay-dark);
}

.timeline {
  min-width: 0;
  overflow: auto hidden;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.timeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--stage-count), minmax(82px, 1fr));
  align-items: center;
  min-width: max(100%, calc(var(--stage-count) * 88px));
  height: 100%;
  padding: 11px 20px 7px;
}

.timeline-track::before {
  position: absolute;
  top: 39px;
  right: 32px;
  left: 32px;
  height: 1px;
  background: rgba(54, 67, 68, 0.23);
  content: "";
}

.timeline-stop {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  height: 84px;
  align-content: start;
  justify-items: center;
  gap: 8px;
  padding: 14px 5px 0;
  border: 0;
  scroll-snap-align: center;
  background: transparent;
  color: var(--ink-soft);
}

.timeline-dot {
  display: block;
  width: 10px;
  height: 10px;
  border: 2px solid #838981;
  border-radius: 50%;
  background: #f8f5ec;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.timeline-stop:hover .timeline-dot {
  transform: scale(1.3);
  border-color: var(--clay);
}

.timeline-stop.is-active .timeline-dot {
  width: 15px;
  height: 15px;
  border: 4px solid #fff8ec;
  background: var(--clay);
  box-shadow: 0 0 0 2px var(--clay), 0 4px 10px rgba(116, 55, 41, 0.24);
}

.timeline-stop.is-complete .timeline-dot {
  border-color: var(--clay);
  background: var(--clay);
}

.timeline-label {
  display: -webkit-box;
  width: 100%;
  overflow: hidden;
  font-size: 0.61rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.timeline-stop.is-active .timeline-label {
  color: var(--ink);
}

/* Tarjeta narrativa opcional del modo guiado. */
.guided-card {
  position: absolute;
  z-index: 26;
  top: 118px;
  left: 23px;
  width: min(430px, calc(100% - 46px));
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 17px;
  overflow: hidden;
  background: rgba(255, 253, 247, 0.95);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: panel-in 220ms ease both;
}

.guided-progress {
  height: 4px;
  background: #e3dfd4;
}

.guided-progress span {
  display: block;
  height: 100%;
  background: var(--clay);
  transition: width 80ms linear;
}

.guided-content {
  padding: 16px 48px 16px 17px;
}

.guided-count {
  margin-bottom: 6px;
  color: var(--clay);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guided-content h2 {
  margin-bottom: 7px;
  font-size: 1.25rem;
}

.guided-content > p {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.guided-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.65rem;
}

.guided-meta button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--clay-dark);
  font-weight: 800;
}

.guided-close {
  position: absolute;
  top: 12px;
  right: 11px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.guided-close:hover {
  background: #f1ede3;
}

.guided-close svg {
  width: 16px;
}

/* Infraestructura comun de dialogos modales. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 43, 46, 0.48);
  backdrop-filter: blur(7px);
  animation: fade-in 180ms ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}


.search-dialog,
.info-dialog,
.textual-dialog,
/* Lector local de pasajes y capitulos. */
.bible-dialog {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  overflow: hidden;
  background: var(--ivory);
  box-shadow: 0 30px 90px rgba(18, 29, 31, 0.31);
  animation: dialog-in 220ms ease both;
}

/* Busqueda global y resultados del atlas o del texto biblico. */
.search-dialog {
  align-self: start;
  margin-top: min(14vh, 120px);
}

.search-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 14px 15px 14px 20px;
  border-bottom: 1px solid var(--line);
}

.search-header > svg {
  width: 25px;
  height: 25px;
  color: var(--clay);
}

.search-header input {
  width: 100%;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 600;
}

.search-header input::placeholder {
  color: #8b918e;
}

.search-hint {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.search-results {
  min-height: 190px;
  max-height: min(560px, 60vh);
  padding: 11px 13px 18px;
  overflow: auto;
}

.search-empty {
  padding: 35px 24px 22px;
  text-align: center;
}

.search-empty h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
}

.search-empty p:not(.eyebrow) {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.result-section + .result-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.result-section-title {
  display: flex;
  justify-content: space-between;
  padding: 6px 9px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-result-list {
  display: grid;
  gap: 3px;
}

.search-result {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 62px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
}

.search-result:hover {
  border-color: var(--line);
  background: #f8f3e8;
}

.result-kind {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8e6dc;
  color: var(--ink-soft);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bible-result .result-kind {
  background: var(--clay-soft);
  color: var(--clay-dark);
}

.search-result strong,
.search-result small {
  display: block;
}

.search-result strong {
  font-size: 0.8rem;
}

.search-result small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.35;
}

.search-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  color: var(--ink-soft);
  font-size: 0.69rem;
}

.mini-spinner,
.large-spinner {
  display: inline-block;
  border: 2px solid rgba(49, 95, 120, 0.2);
  border-top-color: var(--sea);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.mini-spinner {
  width: 14px;
  height: 14px;
}

.large-spinner {
  width: 38px;
  height: 38px;
  border-width: 3px;
}

.bible-dialog {
  display: flex;
  width: min(850px, 100%);
  height: min(780px, calc(100vh - 48px));
  flex-direction: column;
}

.bible-header {
  align-items: center;
  padding: 17px 20px;
}

.bible-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bible-heading > svg {
  width: 28px;
  height: 28px;
  color: var(--clay);
}

.bible-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  overflow: auto hidden;
  background: #f8f4ea;
}

.bible-tabs button {
  flex: 0 0 auto;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ivory);
  font-size: 0.68rem;
  font-weight: 750;
}

.bible-tabs button.is-active {
  border-color: var(--clay);
  background: var(--clay);
  color: white;
}

.bible-content {
  min-height: 0;
  flex: 1;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 253, 247, 0.96), rgba(255, 253, 247, 0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 29px, rgba(67, 78, 74, 0.04) 30px);
}

.bible-loading,
.bible-error {
  display: grid;
  min-height: 320px;
  place-content: center;
  justify-items: center;
  padding: 30px;
  color: var(--ink-soft);
  text-align: center;
}

.bible-error strong {
  margin-bottom: 7px;
  color: var(--clay-dark);
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

.scripture-passage {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 34px 50px;
}

.scripture-passage > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.scripture-passage h3 {
  margin: 0;
  font-size: 1.7rem;
}

.verse-list p {
  margin: 0;
  padding: 4px 7px;
  border-radius: 6px;
  color: #2d3c40;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.8;
}

.verse-list sup {
  display: inline-block;
  min-width: 23px;
  color: var(--clay);
  font-family: Inter, sans-serif;
  font-size: 0.58rem;
  font-weight: 800;
  vertical-align: super;
}

.verse-list p.is-highlighted {
  background: #f1e7cf;
}

.bible-footer {
  flex: 0 0 auto;
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  background: #f4f0e7;
  color: var(--ink-soft);
  font-size: 0.58rem;
  text-align: center;
}

.info-dialog,
/* Ayuda y alternativa textual accesible al Canvas. */
.textual-dialog {
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.info-dialog > header,
.textual-dialog > header {
  flex: 0 0 auto;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 20px 0;
}

.help-grid article {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #faf7ef;
}

.help-grid h3 {
  margin-bottom: 7px;
  font-size: 1rem;
}

.help-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.textual-dialog {
  width: min(900px, 100%);
  height: min(820px, calc(100vh - 48px));
}

.textual-explorer {
  min-height: 0;
  flex: 1;
  padding: 16px 2px 2px;
  overflow: auto;
}

.textual-journey {
  border-bottom: 1px solid var(--line);
}

.textual-journey summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
}

.textual-journey summary::-webkit-details-marker {
  display: none;
}

.textual-journey summary strong,
.textual-journey summary small {
  display: block;
}

.textual-journey summary strong {
  font-size: 0.85rem;
}

.textual-journey summary small {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.textual-journey-body {
  padding: 0 10px 20px 52px;
}

.textual-journey-body > p {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.textual-journey ol {
  margin: 16px 0 0;
  padding-left: 22px;
}

.textual-journey li {
  padding-left: 5px;
}

.textual-journey li::marker {
  color: var(--clay);
  font-family: Georgia, serif;
  font-size: 0.75rem;
}

.textual-journey li button {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 11px 8px;
  border: 0;
  border-bottom: 1px solid rgba(50, 62, 62, 0.08);
  background: transparent;
  text-align: left;
}

.textual-journey li button:hover {
  background: #f8f3e8;
}

.textual-stage-route {
  color: var(--clay);
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
}

.textual-journey li strong {
  font-size: 0.77rem;
}

.textual-journey li small {
  color: var(--ink-soft);
  font-size: 0.64rem;
}

/* Region reservada para mensajes breves no intrusivos. */
.toast-region {
  position: fixed;
  z-index: 500;
  right: 20px;
  bottom: 20px;
}

/* Ajuste intermedio para portatiles y tabletas apaisadas. */
@media (max-width: 1200px) {
  .topbar {
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  }

  .journey-summary {
    width: min(450px, calc(100% - 410px));
    min-width: 340px;
  }

  .summary-copy > p:not(.eyebrow) {
    -webkit-line-clamp: 1;
  }

  .timeline-shell {
    grid-template-columns: minmax(400px, 1fr) minmax(0, 1.2fr);
  }

  .playback-controls {
    grid-template-columns: auto minmax(125px, 1fr);
  }

  .playback-options {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

/* Compactacion de cabecera y carril antes de entrar en modo movil. */
@media (max-width: 1020px) {
  .topbar {
    grid-template-columns: auto minmax(240px, 1fr) auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .journey-rail {
    display: none;
  }

  .journey-field-mobile {
    display: grid;
  }

  .journey-summary {
    width: min(500px, calc(100% - 360px));
  }
}

/* Composicion movil: el globo sigue siendo protagonista y los paneles se apilan. */
@media (max-width: 820px) {
  :root {
    --topbar-height: 66px;
  }

  .topbar {
    grid-template-columns: auto minmax(160px, 1fr) auto;
    padding: 0 10px;
  }

  .brand-kicker,
  .brand-compass,
  .wide-label,
  .search-button kbd {
    display: none;
  }

  .character-picker {
    grid-template-columns: 1fr;
  }

  .character-picker-label {
    display: none;
  }

  .character-picker-button {
    width: min(255px, 38vw);
    min-height: 40px;
  }

  .character-menu {
    right: 50%;
    transform: translateX(50%);
  }

  .brand-block strong {
    font-size: 1.1rem;
  }

  .compact-field {
    grid-template-columns: 1fr;
  }

  .compact-field > span {
    display: none;
  }

  .compact-field select {
    width: min(270px, 38vw);
  }

  .icon-button {
    width: 40px;
    padding: 0;
  }

  .search-button span {
    display: none;
  }

  .journey-summary {
    top: 13px;
    left: 13px;
    width: calc(100% - 145px);
    min-width: 0;
    padding: 11px;
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .summary-index {
    width: 35px;
    height: 35px;
  }

  .summary-copy h1 {
    font-size: 1.12rem;
  }

  .summary-copy > p:not(.eyebrow),
  .summary-meta,
  .summary-focus {
    display: none;
  }

  .map-tools {
    top: 76px;
    right: 11px;
    flex-direction: column;
  }

  .tool-button span:not(.guided-dot) {
    display: none;
  }

  .tool-button {
    width: 41px;
    padding: 0;
  }

  .map-controls {
    top: 169px;
    right: 11px;
  }

  .context-panel {
    top: auto;
    right: 8px;
    bottom: 132px;
    left: 8px;
    width: auto;
    max-height: min(55vh, 520px);
    border-radius: 19px 19px 14px 14px;
  }

  .timeline-shell {
    right: 8px;
    bottom: 8px;
    left: 8px;
    display: block;
    min-height: 112px;
    padding: 8px;
  }

  .playback-controls {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 49px;
    padding: 0 2px 7px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .playback-options {
    grid-column: auto;
  }

  .toggle-chip {
    display: none;
  }

  .timeline {
    height: 48px;
  }

  .timeline-track {
    height: 48px;
    padding: 5px 16px 0;
  }

  .timeline-track::before {
    top: 18px;
  }

  .timeline-stop {
    height: 43px;
    padding-top: 8px;
  }

  .timeline-label {
    display: none;
  }

  .guided-card {
    top: 82px;
    left: 10px;
    width: calc(100% - 72px);
  }

  .layers-panel {
    top: 69px;
    right: 9px;
    width: min(340px, calc(100% - 18px));
  }
}

/* Afinado para telefonos estrechos y controles tactiles. */
@media (max-width: 560px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .brand-block strong {
    font-size: 0;
  }

  .brand-block strong::after {
    font-size: 1.05rem;
    content: "Atlas";
  }

  .compact-field select {
    width: 42vw;
    min-width: 130px;
    padding-left: 9px;
    font-size: 0.74rem;
  }

  .character-picker-button {
    width: min(190px, 44vw);
    min-width: 130px;
    padding-left: 9px;
  }

  #character-picker-current small {
    display: none;
  }

  .character-menu {
    width: min(360px, calc(100vw - 16px));
  }

  .topbar-actions {
    gap: 0;
  }

  .journey-summary {
    width: calc(100% - 124px);
  }

  .summary-copy h1 {
    font-size: 0.94rem;
  }

  .summary-copy .eyebrow {
    font-size: 0.56rem;
  }

  .map-tools {
    top: 71px;
  }

  .map-controls {
    top: 163px;
  }

  .playback-options {
    display: none;
  }

  .playback-controls {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transport-controls button:first-child {
    display: none;
  }

  .guided-card {
    width: calc(100% - 64px);
  }

  .guided-content {
    padding: 13px 42px 13px 14px;
  }

  .guided-content > p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  /* Los dialogos ocupan casi toda la pantalla en moviles sin ocultar sus cierres. */
  .overlay {
    padding: 8px;
  }

  .search-dialog {
    align-self: stretch;
    max-height: calc(100vh - 16px);
    margin-top: 0;
    border-radius: 17px;
  }

  .search-hint span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-result {
    grid-template-columns: 66px minmax(0, 1fr) auto;
    padding: 7px;
  }

  .bible-dialog,
  .textual-dialog {
    height: calc(100vh - 16px);
    border-radius: 17px;
  }

  .info-dialog {
    max-height: calc(100vh - 16px);
    overflow: auto;
  }

  .scripture-passage {
    padding: 22px 18px 45px;
  }

  .scripture-passage > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .verse-list p {
    padding-right: 2px;
    padding-left: 2px;
    font-size: 1rem;
  }

  .bible-footer {
    text-align: left;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .textual-dialog,
  .info-dialog {
    padding: 16px;
  }

  .textual-journey-body {
    padding-left: 10px;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }
}

/* Reduce alturas en escritorios de poca resolucion vertical. */
@media (max-height: 680px) and (min-width: 821px) {
  .journey-summary {
    top: 14px;
    padding-top: 11px;
    padding-bottom: 10px;
  }

  .summary-copy > p:not(.eyebrow),
  .summary-focus {
    display: none;
  }

  .map-tools {
    top: 14px;
  }

  .map-controls {
    top: 70px;
  }

  .context-panel {
    top: 66px;
    bottom: 132px;
  }

  .timeline-shell {
    bottom: 8px;
    min-height: 105px;
  }
}

/* Elimina transiciones no esenciales cuando el sistema solicita menos movimiento. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Experiencia de interfaz compacta y adaptable
   Esta capa final sustituye la composicion anterior sin alterar sus estilos
   editoriales, y centraliza todos los paneles plegables y sus transiciones.
   ========================================================================== */
:root {
  --topbar-height: 58px;
  --rail-width: 252px;
  --edge-gap: 10px;
  --timeline-height: 124px;
  --radius-xl: 13px;
  --radius-lg: 10px;
  --radius-md: 8px;
  --shadow: 0 14px 34px rgba(25, 37, 40, 0.18);
  --shadow-soft: 0 7px 20px rgba(25, 37, 40, 0.11);
}

.topbar {
  grid-template-columns: minmax(190px, 1fr) minmax(250px, auto) minmax(300px, 1fr);
  height: var(--topbar-height);
  padding: 0 9px 0 12px;
  box-shadow: 0 1px 10px rgba(35, 45, 44, 0.05);
}

.brand-block {
  gap: 8px;
}

.brand-compass {
  width: 31px;
  height: 31px;
  border-radius: 8px;
}

.brand-block strong {
  font-size: 1.12rem;
}

.brand-kicker {
  margin-bottom: 1px;
  font-size: 0.56rem;
}

.character-picker {
  grid-template-columns: auto minmax(190px, 242px);
  gap: 6px;
}

.character-picker-button {
  min-height: 38px;
  padding: 4px 9px 4px 11px;
  border-radius: 8px;
  box-shadow: none;
}

.character-menu {
  top: calc(100% + 6px);
  padding: 5px;
  border-radius: 10px;
}

.character-option {
  padding: 8px;
  border-radius: 7px;
}

.topbar-actions {
  gap: 2px;
}

.icon-button,
.tool-button {
  min-height: 36px;
  padding: 0 9px;
  border-radius: 7px;
}

.icon-button svg,
.tool-button svg {
  width: 18px;
  height: 18px;
}

.workspace {
  position: relative;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  height: calc(100% - var(--topbar-height));
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 260ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.workspace.is-rail-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.journey-rail {
  z-index: 55;
  width: var(--rail-width);
  min-width: 0;
  padding: 13px 9px 9px;
  background: linear-gradient(180deg, #faf7ef, #f2ede2);
  opacity: 1;
  transform: translateX(0);
  transform-origin: left center;
  transition:
    opacity 180ms ease,
    transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
    visibility 0ms linear;
}

.workspace.is-rail-collapsed .journey-rail {
  visibility: hidden;
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
  transition:
    opacity 150ms ease,
    transform 240ms cubic-bezier(0.4, 0, 1, 1),
    visibility 0ms linear 240ms;
}

.rail-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 5px;
}

.rail-heading {
  min-width: 0;
  padding: 2px 5px 10px;
}

.rail-heading h2 {
  margin-bottom: 5px;
  font-size: 1.14rem;
  line-height: 1.15;
}

.rail-heading > p:last-child {
  font-size: 0.7rem;
  line-height: 1.38;
}

.rail-close-button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
}

.rail-close-button:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.rail-close-button svg {
  width: 15px;
  height: 15px;
}

.journey-list {
  gap: 3px;
  padding: 2px 0 7px;
}

.journey-card {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  min-height: 50px;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 7px;
}

.journey-card:hover {
  transform: none;
}

.journey-card.is-active {
  box-shadow: 0 4px 12px rgba(93, 68, 48, 0.07);
}

.journey-order {
  width: 26px;
  height: 26px;
  font-size: 0.68rem;
}

.journey-card-copy strong {
  font-size: 0.77rem;
}

.journey-card-copy small {
  margin-top: 2px;
  font-size: 0.61rem;
}

.rail-overview-button {
  min-height: 37px;
  border-radius: 7px;
}

.rail-scrim {
  position: absolute;
  inset: 0;
  z-index: 48;
  display: none;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(27, 39, 42, 0.42);
  transition: opacity 220ms ease;
}

.map-stage {
  min-width: 0;
  min-height: 0;
}

.map-vignette {
  background:
    linear-gradient(90deg, rgba(238, 235, 222, 0.22), transparent 20%, transparent 80%, rgba(230, 229, 219, 0.18)),
    linear-gradient(0deg, rgba(225, 224, 214, 0.35), transparent 18%);
}

.journey-summary,
.guided-card {
  display: none !important;
}

.map-tools {
  top: var(--edge-gap);
  right: var(--edge-gap);
  gap: 5px;
}

.tool-button {
  border-color: rgba(45, 58, 58, 0.16);
  background: rgba(251, 249, 242, 0.94);
  box-shadow: 0 4px 14px rgba(35, 45, 44, 0.08);
}

.map-controls {
  top: 53px;
  right: var(--edge-gap);
  padding: 2px;
  border-radius: 8px;
}

.map-controls button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.layers-panel {
  top: 52px;
  right: var(--edge-gap);
  bottom: var(--edge-gap);
  width: min(354px, calc(100% - 20px));
  max-height: 690px;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  overscroll-behavior: contain;
}

.layers-panel header {
  position: sticky;
  z-index: 2;
  top: -12px;
  align-items: center;
  padding: 9px 0 10px;
  background: rgba(255, 253, 247, 0.97);
}

.layers-panel h2 {
  font-size: 1.18rem;
}

.close-button {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

.layer-options {
  gap: 2px;
  padding: 6px 0 10px;
}

.layer-row {
  min-height: 48px;
  gap: 10px;
  padding: 5px 3px;
  border-bottom: 1px solid rgba(50, 62, 62, 0.07);
}

.layer-row:last-child {
  border-bottom: 0;
}

.layer-ident {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.layer-ident > span:last-child {
  min-width: 0;
}

.layer-icon {
  display: grid;
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid rgba(49, 95, 120, 0.14);
  border-radius: 7px;
  background: rgba(49, 95, 120, 0.07);
  color: var(--sea);
}

.layer-icon svg {
  width: 16px;
  height: 16px;
}

.layer-row strong {
  font-size: 0.73rem;
  line-height: 1.2;
}

.layer-row small {
  margin-top: 2px;
  font-size: 0.6rem;
  line-height: 1.28;
}

.layer-switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.layer-switch i {
  width: 36px;
  height: 20px;
}

.layer-switch i::after {
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
}

.layer-switch input:checked + i::after {
  transform: translateX(16px);
}

.region-legend {
  gap: 6px 9px;
  margin: 0 0 10px;
  padding: 8px 9px;
  border-radius: 7px;
}

.region-legend-item i {
  width: 15px;
  height: 11px;
  border: 1px solid currentColor;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.42;
}

.region-province i,
.region-territory i,
.region-cultural-region i {
  border-top-style: solid;
}

.context-panel {
  top: var(--edge-gap);
  right: auto;
  bottom: calc(var(--timeline-height) + 20px);
  left: var(--edge-gap);
  width: min(376px, calc(100% - 20px));
  min-height: 0;
  max-height: calc(100% - var(--timeline-height) - 30px);
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(calc(-100% - 18px));
  pointer-events: none;
  animation: none;
  transition:
    opacity 190ms ease,
    transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
    visibility 0ms linear 260ms,
    bottom 220ms ease;
}

.context-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
  transition:
    opacity 190ms ease,
    transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
    visibility 0ms linear;
}

.workspace:not(.is-timeline-open) .context-panel {
  bottom: var(--edge-gap);
  max-height: calc(100% - 20px);
}

.panel-header {
  gap: 10px;
  padding: 13px 13px 11px;
}

.panel-header h2 {
  font-size: 1.28rem;
  line-height: 1.16;
}

.panel-subtitle {
  margin-top: 3px;
  font-size: 0.65rem;
}

.context-progress {
  flex: 0 0 3px;
  height: 3px;
  overflow: hidden;
  background: #e3dfd4;
}

.context-progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--clay);
  transition: width 90ms linear;
}

.panel-scroll {
  padding: 12px 13px 16px;
  overscroll-behavior: contain;
}

.context-stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-row {
  margin-bottom: 10px;
}

.status-badge {
  min-height: 23px;
  padding: 0 7px;
}

.lead-copy {
  margin-bottom: 12px;
  font-size: 0.94rem;
  line-height: 1.5;
}

.stage-story {
  margin-bottom: 10px;
  padding: 10px 11px;
  border-radius: 0 7px 7px 0;
  font-size: 0.9rem;
  line-height: 1.48;
}

.stage-route-summary {
  align-items: flex-start;
  padding: 8px;
  border-radius: 7px;
}

.stage-route-distance {
  display: grid;
  justify-items: end;
  text-align: right;
}

.stage-route-distance small {
  display: block;
  margin-top: 3px;
  color: var(--clay-dark);
  font-size: 0.58rem;
  white-space: nowrap;
}

.mobility-note,
.context-intro {
  margin: 9px 0 0;
  padding: 9px 10px;
  border: 1px solid rgba(49, 95, 120, 0.13);
  border-radius: 7px;
  background: rgba(214, 228, 232, 0.4);
}

.mobility-note strong,
.context-intro > span {
  display: block;
  margin-bottom: 3px;
  color: var(--sea);
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobility-note p,
.context-intro p {
  margin: 0;
  color: #50636a;
  font-size: 0.68rem;
  line-height: 1.42;
}

.accuracy-note {
  margin: 10px 0;
  padding: 9px 10px;
  border-radius: 0 7px 7px 0;
}

.panel-section {
  margin-top: 15px;
  padding-top: 13px;
}

.narrative-section p {
  margin: 0 0 8px;
  color: #435257;
  font-size: 0.75rem;
  line-height: 1.5;
}

.narrative-section p:last-child {
  margin-bottom: 0;
}

.context-details {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #faf7ef;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.context-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 750;
}

.context-details p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.route-place-grid {
  display: grid;
  gap: 6px;
}

.route-place-card,
.next-context-card {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbf8f0;
  color: var(--ink);
  text-align: left;
}

.route-place-card:hover,
.next-context-card:hover {
  border-color: rgba(155, 76, 56, 0.35);
  background: #fffaf0;
}

.route-place-card > span:first-child,
.next-context-card > span {
  color: var(--clay);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.route-place-card strong,
.next-context-card strong {
  font-size: 0.77rem;
}

.route-place-card small,
.next-context-card small {
  color: var(--ink-soft);
  font-size: 0.63rem;
  line-height: 1.35;
}

.route-place-description {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink-soft) !important;
  font-size: 0.68rem !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  line-height: 1.4;
  text-transform: none !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.context-stage-list {
  display: grid;
  gap: 3px;
}

.context-stage-list > button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.context-stage-list > button:hover {
  background: #f6f0e5;
}

.context-stage-list strong,
.context-stage-list small {
  display: block;
}

.context-stage-list strong {
  font-size: 0.72rem;
  line-height: 1.25;
}

.context-stage-list small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.59rem;
}

.context-stage-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: var(--clay-soft);
  color: var(--clay-dark);
  font-size: 0.61rem;
  font-weight: 800;
}

.journey-facts {
  grid-template-columns: 1fr 1fr;
  margin: 11px 0;
  border-radius: 7px;
}

.journey-facts > div {
  min-height: 58px;
  padding: 8px;
}

.guided-finish-button {
  margin-top: 12px;
}

.timeline-toggle {
  position: absolute;
  z-index: 32;
  right: 50%;
  bottom: calc(var(--timeline-height) + 16px);
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid rgba(45, 58, 58, 0.18);
  border-radius: 8px;
  transform: translateX(50%);
  background: rgba(251, 249, 242, 0.95);
  color: var(--ink);
  box-shadow: 0 5px 16px rgba(35, 45, 44, 0.12);
  backdrop-filter: blur(10px);
  font-size: 0.66rem;
  font-weight: 800;
  transition: bottom 240ms ease, background 150ms ease, transform 150ms ease;
}

.timeline-toggle:hover {
  background: white;
}

.timeline-toggle:not(.is-open) {
  bottom: var(--edge-gap);
}

.timeline-toggle svg {
  width: 16px;
  height: 16px;
}

.timeline-toggle-chevron {
  font-size: 0.78rem;
  transition: transform 180ms ease;
}

.timeline-toggle.is-open .timeline-toggle-chevron {
  transform: rotate(180deg);
}

.timeline-shell {
  right: var(--edge-gap);
  bottom: var(--edge-gap);
  left: var(--edge-gap);
  grid-template-columns: minmax(330px, 0.75fr) minmax(0, 1.55fr);
  gap: 8px;
  height: var(--timeline-height);
  min-height: 0;
  padding: 7px;
  border-radius: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(calc(100% + 18px));
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
    visibility 0ms linear 260ms;
}

.timeline-shell.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition:
    opacity 180ms ease,
    transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
    visibility 0ms linear;
}

.playback-controls {
  grid-template-columns: auto minmax(110px, 1fr);
  grid-template-rows: auto auto;
  gap: 5px 9px;
  padding: 3px 8px 3px 2px;
}

.transport-controls {
  gap: 1px;
}

.transport-controls button {
  width: 29px;
  height: 29px;
  border-radius: 7px;
}

.transport-controls .play-button {
  width: 39px;
  height: 39px;
  margin: 0 1px;
  border-radius: 9px;
}

.playback-options {
  grid-column: 1 / -1;
  justify-content: flex-start;
  gap: 4px;
}

.playback-options select {
  height: 29px;
  border-radius: 7px;
}

.toggle-chip {
  min-height: 29px;
  border-radius: 7px;
}

.timeline {
  min-height: 0;
  overscroll-behavior-inline: contain;
}

.timeline-track {
  display: flex;
  align-items: stretch;
  min-width: 100%;
  height: 100%;
  padding: 4px 8px 2px;
}

.timeline-track::before {
  display: none;
}

.timeline-origin {
  position: relative;
  display: grid;
  flex: 0 0 86px;
  grid-template-rows: 47px auto;
  align-items: center;
  justify-items: end;
  min-width: 0;
  padding: 0 6px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  text-align: right;
}

.timeline-origin::after {
  position: absolute;
  z-index: -1;
  top: 45px;
  right: -7px;
  width: 14px;
  height: 3px;
  background: rgba(54, 67, 68, 0.23);
  content: "";
}

.timeline-origin > span:last-child {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: 0.6rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-origin-dot {
  align-self: end;
  width: 11px;
  height: 11px;
  margin-bottom: -5px;
  border: 2px solid var(--sea);
  border-radius: 50%;
  background: #f8f5ec;
}

.timeline-stop {
  position: relative;
  display: grid;
  flex: var(--leg-weight) 0 148px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 34px 22px minmax(0, 1fr);
  align-content: stretch;
  justify-items: stretch;
  min-width: 132px;
  max-width: 255px;
  height: 100%;
  gap: 0;
  padding: 0 5px 0 0;
  color: var(--ink-soft);
  text-align: left;
}

.timeline-leg-metrics {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: end;
  justify-self: center;
  display: flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 253, 247, 0.58);
  white-space: nowrap;
}

.timeline-leg-metrics strong {
  color: var(--ink);
  font-size: 0.58rem;
}

.timeline-leg-metrics small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.54rem;
  text-overflow: ellipsis;
}

.timeline-leg-line {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  display: block;
  width: calc(100% + 4px);
  height: 3px;
  overflow: hidden;
  background: rgba(54, 67, 68, 0.22);
}

.timeline-leg-line > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--clay);
  transition: width 80ms linear;
}

.timeline-dot {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  width: 11px;
  height: 11px;
  margin-left: -1px;
}

.timeline-stop.is-active .timeline-dot {
  width: 14px;
  height: 14px;
  border-width: 3px;
}

.timeline-label {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: start;
  display: grid;
  width: 100%;
  gap: 1px;
  padding: 3px 0 0 8px;
  overflow: visible;
  text-align: right;
  -webkit-line-clamp: initial;
}

.timeline-label strong,
.timeline-label small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-label strong {
  font-size: 0.61rem;
}

.timeline-label small {
  color: var(--ink-soft);
  font-size: 0.53rem;
  font-weight: 600;
}

/* Los dialogos usan una unica caja de desplazamiento y respetan la altura dinamica. */
.overlay {
  padding: clamp(10px, 2vw, 20px);
}

.search-dialog,
.info-dialog,
.textual-dialog,
.bible-dialog {
  max-height: calc(100dvh - clamp(20px, 4vw, 40px));
  border-radius: 12px;
}

.search-dialog {
  display: flex;
  align-self: center;
  min-height: 0;
  max-height: min(720px, calc(100dvh - 32px));
  flex-direction: column;
  margin-top: 0;
}

.search-header,
.search-hint {
  flex: 0 0 auto;
}

.search-results {
  min-height: 0;
  max-height: none;
  flex: 1;
  overscroll-behavior: contain;
}

.info-dialog {
  min-height: 0;
  overflow: hidden;
}

.help-grid {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.dialog-actions {
  flex: 0 0 auto;
}

.bible-dialog,
.textual-dialog {
  height: min(820px, calc(100dvh - 32px));
}

.bible-content,
.textual-explorer {
  overscroll-behavior: contain;
}

@media (max-width: 1200px) {
  .topbar {
    grid-template-columns: minmax(155px, 0.75fr) minmax(230px, auto) minmax(285px, 1fr);
  }

  .brand-kicker {
    display: none;
  }

  .timeline-shell {
    grid-template-columns: minmax(310px, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 1020px) {
  :root {
    --mobile-rail-width: min(82vw, 286px);
  }

  .topbar {
    grid-template-columns: auto minmax(210px, 1fr) auto;
  }

  .workspace,
  .workspace.is-rail-collapsed,
  .workspace.is-rail-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .journey-rail {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--mobile-rail-width);
    visibility: hidden;
    opacity: 0;
    transform: translateX(-100%);
    box-shadow: 18px 0 42px rgba(23, 34, 37, 0.24);
    pointer-events: none;
  }

  .workspace.is-rail-open .journey-rail {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    transition:
      opacity 180ms ease,
      transform 260ms cubic-bezier(0.2, 0.75, 0.25, 1),
      visibility 0ms linear;
  }

  .rail-scrim {
    display: block;
  }

  .workspace.is-rail-open .rail-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .journey-field-mobile {
    display: grid;
  }

  .compact-field select {
    height: 36px;
    border-radius: 8px;
  }
}

@media (min-width: 821px) and (max-width: 1020px) {
  .workspace.is-rail-open .context-panel.is-open {
    left: calc(var(--mobile-rail-width) + 10px);
    width: min(376px, calc(100% - var(--mobile-rail-width) - 20px));
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: 56px;
    --timeline-height: 142px;
  }

  .topbar {
    grid-template-columns: auto minmax(150px, 1fr) auto;
    padding: 0 6px;
  }

  .brand-kicker,
  .brand-compass,
  .wide-label,
  .search-button kbd {
    display: none;
  }

  .brand-block strong {
    font-size: 1rem;
  }

  .character-picker {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-picker-label,
  .compact-field > span {
    display: none;
  }

  .character-picker-button {
    width: min(225px, 35vw);
    min-height: 36px;
  }

  .compact-field {
    grid-template-columns: minmax(0, 1fr);
  }

  .compact-field select {
    width: min(225px, 35vw);
    min-width: 115px;
  }

  .character-menu {
    right: 50%;
    transform: translateX(50%);
  }

  .icon-button {
    width: 36px;
    padding: 0;
  }

  .search-button span {
    display: none;
  }

  .map-tools {
    top: 8px;
    right: 8px;
    flex-direction: column;
  }

  .tool-button {
    width: 37px;
    padding: 0;
  }

  .tool-button span {
    display: none;
  }

  .map-controls {
    top: 91px;
    right: 8px;
  }

  .layers-panel {
    top: 8px;
    right: 51px;
    bottom: 8px;
    width: min(354px, calc(100% - 67px));
    max-height: none;
  }

  .context-panel {
    top: auto;
    right: 7px;
    bottom: calc(var(--timeline-height) + 19px);
    left: 7px;
    width: auto;
    max-height: min(52dvh, 520px);
    border-radius: 10px;
    transform: translateY(calc(100% + var(--timeline-height) + 30px));
  }

  .context-panel.is-open {
    transform: translateY(0);
  }

  .workspace:not(.is-timeline-open) .context-panel {
    bottom: 48px;
    max-height: min(64dvh, 590px);
  }

  .timeline-toggle {
    bottom: calc(var(--timeline-height) + 12px);
  }

  .timeline-toggle:not(.is-open) {
    bottom: 7px;
  }

  .timeline-shell {
    display: grid;
    right: 7px;
    bottom: 7px;
    left: 7px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 49px minmax(0, 1fr);
    gap: 4px;
    height: var(--timeline-height);
    padding: 6px;
  }

  .playback-controls {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
    gap: 7px;
    padding: 0 2px 5px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .playback-options {
    grid-column: auto;
    justify-content: flex-end;
  }

  .toggle-chip {
    display: none;
  }

  .timeline-origin {
    flex-basis: 74px;
  }

  .timeline-stop {
    min-width: 120px;
    flex-basis: 132px;
  }

  .timeline-leg-metrics small {
    display: none;
  }

  .timeline-label small {
    display: none;
  }

  .overlay {
    padding: 7px;
  }

  .search-dialog,
  .info-dialog,
  .textual-dialog,
  .bible-dialog {
    max-height: calc(100dvh - 14px);
    border-radius: 10px;
  }

  .info-dialog,
  .textual-dialog {
    padding: 14px;
  }

  .help-grid {
    padding: 13px 0;
  }
}

@media (max-width: 560px) {
  :root {
    --timeline-height: 182px;
  }

  .topbar {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 3px;
    padding: 0 4px;
  }

  .brand-block {
    overflow: hidden;
  }

  .brand-block strong {
    font-size: 0;
  }

  .brand-block strong::after {
    font-size: 0.92rem;
    content: "Atlas";
  }

  .topbar-center {
    gap: 4px;
  }

  .character-picker-button {
    width: min(174px, 42vw);
    min-width: 112px;
    padding-left: 8px;
  }

  #character-picker-current small {
    display: none;
  }

  .compact-field select {
    width: min(150px, 36vw);
    min-width: 98px;
    padding-left: 7px;
    font-size: 0.69rem;
  }

  .character-menu {
    width: calc(100vw - 10px);
    max-height: calc(100dvh - var(--topbar-height) - 10px);
  }

  .topbar-actions .icon-button:not(.rail-global-toggle):not(.search-button) {
    display: none;
  }

  .map-tools {
    top: 6px;
    right: 6px;
  }

  .map-controls {
    top: 87px;
    right: 6px;
  }

  .layers-panel {
    top: 6px;
    right: 48px;
    bottom: 6px;
    width: calc(100% - 56px);
    padding: 10px;
  }

  .layers-panel header {
    top: -10px;
  }

  .layer-row {
    min-height: 46px;
  }

  .layer-row small {
    display: none;
  }

  .context-panel {
    right: 5px;
    bottom: calc(var(--timeline-height) + 15px);
    left: 5px;
    max-height: min(60dvh, 560px);
  }

  .workspace:not(.is-timeline-open) .context-panel {
    bottom: 45px;
    max-height: calc(100% - 55px);
  }

  .panel-header {
    padding: 10px;
  }

  .panel-header h2 {
    font-size: 1.12rem;
  }

  .panel-scroll {
    padding: 10px;
  }

  .stage-route-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .stage-route-distance {
    justify-items: start;
    text-align: left;
  }

  .journey-facts {
    grid-template-columns: 1fr 1fr;
  }

  .timeline-toggle {
    min-height: 30px;
    bottom: calc(var(--timeline-height) + 10px);
    padding: 0 8px;
  }

  .timeline-toggle:not(.is-open) {
    bottom: 5px;
  }

  .timeline-shell {
    right: 5px;
    bottom: 5px;
    left: 5px;
    grid-template-rows: 77px minmax(0, 1fr);
    height: var(--timeline-height);
    padding: 5px;
  }

  .playback-controls {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 4px 7px;
  }

  .playback-options {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .playback-options .toggle-chip {
    display: inline-flex;
  }

  .playback-title-row strong {
    font-size: 0.68rem;
  }

  .timeline-origin {
    flex-basis: 68px;
  }

  .timeline-stop {
    min-width: 108px;
    flex-basis: 118px;
  }

  .timeline-leg-metrics {
    padding-right: 3px;
    padding-left: 3px;
  }

  .timeline-label {
    padding-left: 4px;
  }

  .overlay {
    padding: 0;
  }

  .search-dialog,
  .info-dialog,
  .textual-dialog,
  .bible-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .search-dialog {
    min-height: 100dvh;
  }

  .search-header {
    padding: max(9px, env(safe-area-inset-top)) 8px 9px 12px;
  }

  .search-hint {
    padding: 7px 12px;
  }

  .search-result {
    grid-template-columns: 65px minmax(0, 1fr) auto;
    min-height: 56px;
    padding: 7px;
    border-radius: 7px;
  }

  .info-dialog,
  .textual-dialog {
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .bible-dialog {
    height: 100dvh;
  }

  .bible-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .bible-footer {
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .textual-journey-body {
    padding-left: 8px;
  }
}

@media (max-height: 680px) and (min-width: 821px) {
  :root {
    --timeline-height: 110px;
  }

  .context-panel {
    top: 7px;
    bottom: calc(var(--timeline-height) + 15px);
  }

  .workspace:not(.is-timeline-open) .context-panel {
    bottom: 7px;
  }

  .timeline-shell {
    bottom: 7px;
    height: var(--timeline-height);
  }

  .timeline-toggle {
    bottom: calc(var(--timeline-height) + 13px);
  }

  .timeline-toggle:not(.is-open) {
    bottom: 7px;
  }

  .timeline-leg-metrics small,
  .timeline-label small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workspace,
  .journey-rail,
  .context-panel,
  .timeline-shell,
  .timeline-toggle,
  .rail-scrim {
    transition-duration: 0.01ms !important;
  }
}

/* El escenario no debe convertirse en un contenedor desplazable por paneles fuera de vista. */
.map-stage {
  overflow: clip;
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
  }

  .brand-block {
    display: none;
  }

  .topbar-center {
    min-width: 0;
    justify-content: stretch;
    gap: 4px;
  }

  .character-picker,
  .journey-field-mobile {
    min-width: 0;
  }

  .character-picker {
    flex: 1.12 1 0;
    width: auto;
  }

  .journey-field-mobile {
    flex: 0.88 1 0;
    width: auto;
  }

  .character-picker-button,
  .compact-field select {
    width: 100%;
    min-width: 0;
  }
}

/* En pantallas estrechas los modales son superficies completas: no se escalan ni
   se desplazan fuera del viewport durante su entrada. */
@keyframes mobile-dialog-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 560px) {
  .overlay {
    align-items: stretch;
    justify-items: stretch;
  }

  .search-dialog,
  .info-dialog,
  .textual-dialog,
  .bible-dialog {
    min-width: 0;
    min-height: 0;
    margin: 0;
    transform: none;
    animation: mobile-dialog-fade 150ms ease both;
  }

  .search-dialog {
    min-height: 100dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .search-dialog,
  .info-dialog,
  .textual-dialog,
  .bible-dialog {
    animation: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workspace,
  .journey-rail,
  .context-panel,
  .timeline-shell,
  .timeline-toggle,
  .rail-scrim {
    transition: none !important;
  }
}


/* Pestanas persistentes junto a la posicion real de cada panel, incluso al cerrarlo. */
.rail-reopen, .context-reopen {
  position: absolute; z-index: 62; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 11px; background: rgba(250,248,241,.96); color: #273a3a;
  border: 1px solid rgba(50,65,65,.2); border-radius: 0 8px 8px 0;
  box-shadow: 0 4px 13px rgba(24,35,37,.12); cursor: pointer;
  font: 600 12px/1.2 inherit;
  transition: opacity 180ms ease, transform 220ms ease, visibility 0ms;
}
.rail-reopen svg, .context-reopen svg { width: 16px; height: 16px; flex: none; }
.rail-reopen { top: 18px; left: 0; }
.workspace.is-rail-open .rail-reopen { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-10px); }
.context-reopen { top: 58px; left: var(--edge-gap); border-radius: 8px; }
.workspace.is-context-open .context-reopen { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-10px); }
.rail-reopen:focus-visible, .context-reopen:focus-visible { outline: 3px solid #277899; outline-offset: 2px; }
@media (max-width: 1020px) {
  .rail-reopen { top: 8px; }
  .context-reopen { top: 54px; left: 8px; }
}
@media (max-width: 540px) {
  .rail-reopen, .context-reopen { padding: 8px; font-size: 11px; }
}

/* Historia biblica: shared shell, independent narrative surfaces. */
.topbar { grid-template-columns: minmax(150px, .65fr) minmax(0, 1.5fr) auto; }
.topbar-center { min-width: 0; gap: 10px; }
.experience-switch { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #ece7da; }
.experience-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 4px 10px; border: 0; border-radius: 5px; background: transparent; color: #5a584f; font-size: .74rem; font-weight: 750; white-space: nowrap; }
.experience-switch button[aria-pressed="true"] { background: #fcfaf4; color: #6e4327; box-shadow: 0 1px 4px #3d321c24; }
.experience-switch svg { width: 17px; height: 17px; flex: 0 0 auto; }
.mode-history { --timeline-height: 150px; }
.mode-history .topbar-center { justify-content: center; }
.mode-history #journey-list { display: block; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.history-icon { display: block; flex: 0 0 auto; width: 28px; height: 28px; }
.history-filters { padding: 0 3px 12px; border-bottom: 1px solid var(--line); }
.history-search-label { display: block; margin: 3px 0 5px; font-size: .68rem; font-weight: 700; }
#history-query { width: 100%; min-width: 0; min-height: 38px; padding: 7px; border: 1px solid #bcb7a8; border-radius: 5px; background: #fffdf7; color: var(--ink); font-size: .77rem; }
.history-filter-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 6px; margin-top: 9px; }
.history-filter-grid label { min-width: 0; display: grid; gap: 4px; font-size: .64rem; color: #5b615c; font-weight: 700; }
.history-filter-grid select { min-width: 0; width: 100%; height: 34px; padding: 3px; border: 1px solid #c5c1b4; border-radius: 4px; background: #fffdf7; color: var(--ink); font-size: .7rem; text-overflow: ellipsis; }
.history-result-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: .66rem; font-weight: 700; }
.history-result-row button { min-height: 30px; padding: 3px; border: 0; background: transparent; text-decoration: underline; color: var(--clay-dark); font-size: .66rem; }
.history-filter-hint { margin: 4px 0 0; color: #62685f; font-size: .63rem; line-height: 1.4; }
.history-era-group { border-bottom: 1px solid var(--line); }
.history-era-group > summary { display: flex; align-items: center; gap: 7px; min-height: 47px; padding: 7px 2px; cursor: pointer; list-style: none; font-size: .75rem; font-weight: 750; }
.history-era-group > summary::-webkit-details-marker { display: none; }
.history-era-group > summary::after { content: '+'; margin-left: auto; font-size: 16px; }
.history-era-group[open] > summary::after { content: '\2212'; }
.history-era-group summary small { display: block; padding-top: 2px; font-size: .61rem; font-weight: 500; color: #677063; }
.history-era-number { display: grid; flex: 0 0 28px; width: 28px; height: 28px; place-items: center; border-bottom: 3px solid var(--era-color); background: #eee8da; font-size: .65rem; }
.history-episode-button { display: flex; align-items: center; gap: 8px; min-height: 54px; width: 100%; padding: 7px 5px; border: 0; border-left: 3px solid transparent; border-radius: 4px; background: transparent; text-align: left; color: #514f43; }
.history-episode-button:hover { background: #fffdf6; }
.history-episode-button.is-active { border-left-color: #986c42; background: #fffaf0; color: #704624; }
.history-episode-button .history-icon { width: 27px; height: 27px; }
.history-episode-button > span { min-width: 0; }
.history-episode-button strong { display: block; font-size: .73rem; line-height: 1.3; }
.history-episode-button small { display: block; margin-top: 3px; color: #6a6a5e; font-size: .61rem; line-height: 1.35; }
.history-empty { padding: 20px 7px; text-align: center; }
.history-empty > svg { width: 42px; height: 42px; margin: 0 auto 10px; }
.history-empty h3 { font-size: 1rem; }
.history-empty p { font-size: .78rem; line-height: 1.5; margin: 8px 0 12px; }
.mode-history .timeline-shell { grid-template-columns: minmax(335px, .75fr) minmax(0, 1.55fr); align-items: stretch; }
.mode-history #timeline { display: grid; grid-template-rows: 39px minmax(0, 1fr); min-width: 0; min-height: 0; padding: 0; overflow: hidden; }
.history-era-track { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding: 0 2px 3px; }
.history-era-track button { flex: 0 0 auto; min-height: 29px; padding: 4px 8px; border: 1px solid #d1caba; border-bottom: 2px solid var(--era-color, #8b775a); border-radius: 4px; background: #f8f4eb; color: #55594e; font-size: .63rem; white-space: nowrap; }
.history-era-track button[aria-pressed="true"] { background: #534b3d; color: #fff; }
.history-time-track { position: relative; display: flex; align-items: stretch; gap: 4px; min-width: 0; min-height: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding: 3px 2px 7px; }
.history-time-stop { position: relative; display: flex; align-items: center; gap: 7px; flex: 0 0 195px; min-width: 0; padding: 5px 7px; border: 1px solid #ddd6c6; border-radius: 5px; background: #faf7f0; color: #635848; text-align: left; }
.history-time-stop::after { position: absolute; content: ''; top: 50%; right: -5px; width: 4px; border-top: 1px solid #c2b393; }
.history-time-stop:last-child::after { display: none; }
.history-time-stop.is-active { background: #fff9e9; border-color: #a16b37; box-shadow: inset 0 -2px #a16b37; color: #69431f; }
.history-time-stop > span:last-child { min-width: 0; }
.history-time-stop strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .69rem; line-height: 1.35; }
.history-time-stop small { display: block; margin-top: 3px; font-size: .57rem; line-height: 1.3; }
.history-time-icon { position: relative; flex: 0 0 28px; align-self: center; }
.history-time-icon > small { position: absolute; top: -12px; left: 0; margin: 0; font-size: .55rem; }
.history-timeline-empty { padding: 12px; font-size: .77rem; }
.mode-history .playback-controls { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; min-width: 0; }
.mode-history .playback-current { min-width: 0; }
.mode-history .playback-title-row { align-items: start; }
.mode-history #history-play-title { display: -webkit-box; white-space: normal; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; font-size: .74rem; }
#history-step-count { color: #846749; white-space: nowrap; font-size: .65rem; }
.mode-history .transport-controls button:disabled { opacity: .35; cursor: default; }
.mode-history .context-panel { width: min(382px, calc(100% - 20px)); }
.history-panel-header { align-items: start; }
.history-panel-header > div:nth-child(2) { flex: 1; min-width: 0; }
.history-heading-icon { display: grid; flex: 0 0 42px; width: 42px; height: 45px; place-items: center; border: 1px solid #ded3bf; border-bottom: 3px solid var(--era-color); border-radius: 5px; color: #8a6235; background: #f6eedc; }
.history-heading-icon svg { width: 34px; height: 34px; }
.mode-history .panel-header h2 { font-size: 1.1rem; }
.mode-history .panel-scroll { font-size: .85rem; line-height: 1.55; scrollbar-gutter: stable; }
.mode-history .panel-section > p { font-size: .85rem; line-height: 1.55; margin: 6px 0; }
.mode-history .panel-section h3 { font-size: .72rem; }
.history-kind-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; margin-bottom: 12px; font-size: .61rem; color: #69685f; }
.history-kind { display: inline-block; padding: 3px 6px; border-radius: 3px; background: #ece1c9; color: #795222; font-size: .62rem; font-weight: 750; }
.history-kind.kind-historical { color: #225f72; background: #dcecf0; }
.history-kind.kind-vision { color: #69417e; background: #ece1f2; }
.history-summary { color: #383d36; }
.history-highlights { margin: 7px 0 0; padding-left: 17px; }
.history-highlights li { padding: 2px 0 4px 1px; }
.history-place-list { display: grid; gap: 4px; margin: 10px 0; }
.history-place-list button { display: flex; align-items: center; gap: 8px; min-height: 43px; padding: 6px; background: #edf0e9; border: 1px solid #d3dbcb; border-radius: 4px; text-align: left; color: #3d614d; }
.history-place-list strong { display: block; font-size: .74rem; }
.history-place-list small { display: block; font-size: .67rem; color: #577069; }
.history-context-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--line); }
.history-context-nav button { min-width: 0; border: 1px solid #c5c1b4; border-radius: 4px; padding: 9px; background: #f6f1e6; text-align: left; color: #6b5435; font-size: .71rem; line-height: 1.4; }
.history-context-nav small { display: block; margin-bottom: 4px; font-size: .6rem; color: #737367; }
.history-context-nav > :last-child { text-align: right; }
.mode-history .source-details { font-size: .73rem; line-height: 1.5; }
.mode-history .source-details p { margin: 8px 0; }
.mode-history .source-details a { color: #285e6a; text-decoration: underline; overflow-wrap: anywhere; }
.history-extrabiblical { margin-top: 12px; padding: 9px; background: #e3edf0; color: #305d6a; font-size: .77rem; line-height: 1.5; }
.history-map-caption { position: absolute; right: 10px; bottom: calc(var(--timeline-height) + 60px); z-index: 4; display: flex; align-items: center; gap: 8px; max-width: 242px; padding: 9px 10px; border: 1px solid #d1c4ad; border-radius: 7px; background: #fcf8eced; color: #806135; pointer-events: none; box-shadow: 0 4px 14px #42361c15; }
.history-map-caption > svg { width: 42px; height: 42px; }
.history-map-caption strong { display: block; font-size: .71rem; line-height: 1.4; }
.history-map-caption small { display: block; margin-top: 4px; color: #727263; font-size: .64rem; line-height: 1.45; }
.workspace:not(.is-timeline-open) .history-map-caption { bottom: 54px; }
.mode-history #layers-panel { display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }
.mode-history #layers-panel[hidden] { display: none; }
.mode-history .layers-header { position: static; flex: 0 0 auto; gap: 8px; }
.history-layers-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-bottom: 12px; }
.history-layers-scroll h3 { margin: 13px 0 7px; color: #576659; font-size: .67rem; text-transform: uppercase; letter-spacing: .06em; }
.history-layers-scroll .layer-option { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) 28px; align-items: center; gap: 8px; min-height: 48px; padding: 5px 2px; border-bottom: 1px solid #d9d8cc; cursor: pointer; }
.history-layer-icon { display: grid; width: 30px; height: 30px; place-items: center; color: #826647; background: #f0e9da; border-radius: 5px; }
.history-layer-icon svg { width: 25px; height: 25px; }
.history-layers-scroll .layer-copy { min-width: 0; }
.history-layers-scroll strong { display: block; font-size: .72rem; }
.history-layers-scroll small { display: block; margin-top: 3px; font-size: .64rem; color: #657365; line-height: 1.35; }
.history-layers-scroll input[type="checkbox"] { width: 21px; height: 21px; accent-color: #766041; opacity: 1; position: static; }
.history-layers-scroll .layer-switch { display: none; }
.history-layer-note { margin: 12px 0; font-size: .68rem; line-height: 1.5; color: #666d5e; }
.history-textual-intro { font-size: .9rem; line-height: 1.65; margin: 0 0 18px; }
.history-textual-episode .textual-journey-body { font-size: .92rem; line-height: 1.6; }
.history-textual-episode .panel-section { margin-top: 20px; }
.history-textual-episode summary .history-icon { width: 30px; height: 30px; }
.history-textual-episode summary { display: flex; gap: 12px; }
.history-textual-episode summary small { display: block; margin-top: 4px; }
.bible-overlay { z-index: 110; }
@media (max-width: 1300px) {
  .topbar .wide-label, .character-picker-label, .brand-kicker { display: none; }
  .character-picker { grid-template-columns: minmax(0, 1fr); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .character-picker-button { max-width: 210px; }
  .experience-switch button { padding-inline: 8px; }
}
@media (max-width: 1100px) {
  .mode-history { --timeline-height: 178px; }
  .mode-history .timeline-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 62px minmax(0, 1fr); gap: 4px; }
  .mode-history .playback-controls { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 1fr; padding: 0 3px 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .mode-history .playback-options { grid-column: auto; align-items: center; }
}
@media (max-width: 1020px) and (min-width: 821px) {
  .mode-history .workspace.is-rail-open .context-panel { width: min(382px, calc(100% - var(--mobile-rail-width) - 20px)); }
  .topbar .brand-block { display: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 820px) {
  :root { --topbar-height: 92px; }
  .atlas-shell.mode-history { --topbar-height: 56px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 4px 6px; }
  .topbar .brand-block, .topbar .rail-global-toggle { display: none; }
  .topbar-center { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; }
  .experience-switch { grid-column: 1 / -1; justify-content: center; }
  .experience-switch button { flex: 1; gap: 4px; min-height: 32px; padding: 3px 5px; font-size: .69rem; }
  .experience-switch svg { width: 15px; height: 15px; }
  .topbar-actions { align-self: start; padding-top: 4px; }
  .topbar-actions .icon-button:not(.rail-global-toggle):not(.search-button) { display: inline-flex; }
  .character-picker, .compact-field { width: 100%; min-width: 0; }
  .character-picker-button, .compact-field select { width: 100%; min-width: 0; max-width: none; min-height: 33px; font-size: .72rem; }
  .character-menu { left: 0; right: auto; transform: none; max-width: calc(100vw - 12px); }
  .mode-history .topbar-center { display: flex; justify-content: flex-start; }
  .mode-history .experience-switch { flex: 1; max-width: 270px; }
  .mode-history .context-panel { width: auto; max-height: min(45dvh, calc(100% - var(--timeline-height) - 65px)); }
  .mode-history .workspace:not(.is-timeline-open) .context-panel { max-height: min(52dvh, calc(100% - 80px)); }
  .mode-history .toggle-chip { display: inline-flex; min-height: 30px; padding: 3px 6px; font-size: .63rem; }
  .mode-history .workspace.is-context-open .history-map-caption { display: none; }
  .history-map-caption { right: 8px; max-width: 220px; }
  .history-textual-episode .textual-journey-body { padding-inline: 12px; }
}
@media (max-width: 560px) {
  .mode-history { --timeline-height: 194px; }
  .mode-history .timeline-shell { grid-template-rows: 83px minmax(0, 1fr); }
  .mode-history .playback-controls { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 6px; }
  .mode-history .playback-options { grid-column: 1 / -1; justify-content: flex-start; gap: 8px; }
  .mode-history .transport-controls button { width: 30px; height: 36px; }
  .mode-history .playback-current { padding: 0; }
  .mode-history #history-play-title { font-size: .69rem; -webkit-line-clamp: 1; }
  .history-time-stop { flex-basis: 172px; }
  .history-heading-icon { flex-basis: 34px; width: 34px; height: 38px; }
  .history-heading-icon svg { width: 28px; height: 28px; }
  .mode-history .panel-header h2 { font-size: .99rem; }
  .history-filter-grid select { min-height: 36px; }
}
@media (max-height: 540px) and (min-width: 561px) {
  .mode-history { --timeline-height: 144px; }
  .mode-history .timeline-shell { grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); grid-template-rows: minmax(0, 1fr); }
  .mode-history .playback-controls { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr auto; border-bottom: 0; }
  .mode-history .playback-options { grid-column: 1 / -1; }
  .mode-history .context-panel { top: 7px; bottom: calc(var(--timeline-height) + 18px); right: auto; width: min(360px, calc(100% - 58px)); max-height: none; }
  .mode-history .workspace:not(.is-timeline-open) .context-panel { top: 7px; bottom: 44px; max-height: none; }
  .mode-history .history-panel-header { padding: 6px; }
  .history-heading-icon { display: none; }
  .mode-history .panel-header h2 { font-size: .91rem; }
}
@media (prefers-reduced-motion: reduce) {
  .history-time-track, .history-era-track { scroll-behavior: auto; }
  .history-episode-button, .history-time-stop { transition: none; }
}
.history-layers-scroll .layer-option:has([data-history-layer="battles"]) .history-layer-icon { color: #a84339; }
.history-layers-scroll .layer-option:has([data-history-layer="sacred"]) .history-layer-icon { color: #69478c; }
.history-layers-scroll .layer-option:has([data-history-layer="symbols"]) .history-layer-icon { color: #7951a4; }
.history-layers-scroll .layer-option:has([data-history-layer="routes"]) .history-layer-icon { color: #177978; }

@media (max-width: 560px) and (max-height: 650px) {
  .mode-history .workspace.is-timeline-open .context-panel { max-height: min(32dvh, calc(100% - var(--timeline-height) - 100px)); }
}

/* Shared visual atlas: native modal focus trap, bounded scroll and no background scroll. */
.atlas-dialog { border:1px solid #d7c7a8; padding:0; background:#fbf7ed; color:#383b32; width:min(660px,calc(100vw - 28px)); max-height:calc(100dvh - 32px); border-radius:8px; overflow:hidden; box-shadow:0 28px 90px #1c292a70; }
.atlas-dialog[open] { display:flex; flex-direction:column; }
.atlas-dialog::backdrop { background:rgba(23,37,42,.62); backdrop-filter:blur(3px); }
body:has(.atlas-dialog[open]) { overflow:hidden; }
.atlas-dialog-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:16px 20px; flex:0 0 auto; border-bottom:1px solid #d7c7a8; }
.atlas-dialog-header h2 { font:600 23px Georgia,serif; margin:2px 0 6px; }
.atlas-dialog-header p { margin:0; font-size:12px; }
.atlas-dialog-body { overflow-y:auto; overscroll-behavior:contain; padding:16px 20px 24px; min-height:0; line-height:1.6; }
.atlas-dialog-body h3 { font-size:14px; margin:20px 0 9px; }
.atlas-editorial-note,.atlas-smallprint { font-size:12px; line-height:1.6; color:#686753; }
.atlas-catalogue { display:grid; gap:4px; }
.atlas-catalogue-item { display:flex; gap:12px; align-items:center; width:100%; text-align:left; border:1px solid #ddd0b7; border-radius:5px; background:#fffdf6; color:inherit; padding:8px 10px; min-height:64px; }
.atlas-catalogue-item:hover,.atlas-catalogue-item:focus-visible { background:#efe6ce; border-color:#a88c58; }
.atlas-catalogue-item>svg { width:54px; height:54px; flex:0 0 54px; }
.atlas-catalogue-item>span:nth-child(2) { flex:1; min-width:0; }
.atlas-catalogue-item strong,.atlas-catalogue-item small { display:block; }
.atlas-catalogue-item small { font-size:11px; color:#77705c; }
.atlas-landmark-art { display:flex; align-items:center; justify-content:center; gap:24px; border-radius:6px; background:linear-gradient(160deg,#e8dac0,#f8f1df); padding:10px; margin-bottom:16px; }
.atlas-landmark-art svg { width:160px; height:160px; }
.atlas-landmark-art span { max-width:130px; font:italic 17px Georgia,serif; color:#8c7855; }
.atlas-dialog button:focus-visible { outline:3px solid #247981; outline-offset:2px; }
@media(max-width:560px) {
 .atlas-dialog { width:100%; max-width:100%; height:100dvh; max-height:100dvh; margin:0; border:0; border-radius:0; }
 .atlas-dialog-header { padding:12px 14px; padding-top:max(12px,env(safe-area-inset-top)); }
 .atlas-dialog-header h2 { font-size:20px; }
 .atlas-dialog-body { padding:12px 14px max(24px,env(safe-area-inset-bottom)); }
 .atlas-landmark-art svg { width:120px; height:120px; }
 .atlas-dialog button { min-height:44px; }
}

/* Illustrated atlas: vectors remain crisp, and the narrative keeps its own scroll. */
.history-art { margin: 0 0 10px; overflow: hidden; border: 1px solid rgba(83,66,45,.16); border-radius: 5px; }
.history-art > svg { display: block; width: 100%; height: auto; aspect-ratio: 8 / 3; }
.history-art figcaption { padding: 5px 8px; font-size: 10px; line-height: 1.35; color: var(--muted); background: rgba(222,213,191,.22); }
.history-date-note { margin: 0 0 12px; padding: 0; border: 0; }
.history-date-note > summary { min-height: 36px; display: list-item; padding: 8px 0; font-size: 11px; }
.history-date-note > p { font-size: 12px; line-height: 1.5; padding: 8px 10px; margin: 0; border-left: 2px solid #9e8051; background: rgba(197,177,139,.12); }
.history-date-badge { font-weight: 650; color: #755b32; }
.history-story-flow { list-style: none; margin: 0; padding: 0; }
.history-story-flow > li { display: grid; grid-template-columns: 25px minmax(0,1fr); gap: 8px; position: relative; padding: 0 0 12px; font-size: 12px; line-height: 1.5; }
.history-story-flow > li:last-child { padding-bottom: 0; }
.history-story-flow > li:not(:last-child)::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 2px; border-left: 1px solid #cbb990; }
.history-step-number { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #cbb990; border-radius: 50%; font-size: 10px; font-weight: 750; background: #f4eddd; color: #74552f; }
.history-depth { padding: 0; background: rgba(200,181,145,.10); border: 1px solid rgba(142,119,78,.18); border-radius: 5px; margin: 12px 0; }
.history-depth > summary { min-height: 44px; padding: 12px; font-weight: 650; font-size: 12px; }
.history-depth summary small { float: right; margin-left: 10px; color: var(--muted); font-size: 10px; font-weight: 400; }
.history-depth > section { padding: 0 12px 12px; }
.history-depth h3 { margin: 0 0 6px; font-size: 13px; }
.history-depth p { margin: 0; font-size: 12px; line-height: 1.6; }
.history-art, .history-story-flow, .history-depth { max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .history-date-note > summary { min-height: 44px; padding-block: 12px; }
  .history-art figcaption { font-size: 10px; }
}

/* The legacy journeys timeline has a fixed mobile height; history fills its second row. */
.mode-history #timeline { height: 100%; align-self: stretch; }
@media (max-width: 560px) and (max-height: 650px) {
  .mode-history .workspace.is-timeline-open .context-panel { max-height: min(43dvh, calc(100% - var(--timeline-height) - 70px)); }
  .mode-history .history-panel-header { padding: 8px; }
  .mode-history .history-panel-header .eyebrow { font-size: 9px; }
  .mode-history .history-panel-header .panel-subtitle { font-size: 10px; }
}

/* Manual History navigation; journey playback styles remain unchanged. */
.mode-history .playback-controls {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 7px;
  align-content: center;
}
.mode-history .history-transport { display: flex; gap: 6px; width: 100%; }
.mode-history .history-transport button,
.mode-history .history-transport button:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  min-width: 0;
  min-height: 42px;
  height: auto;
  flex: 1;
  padding: 7px 10px;
  font-size: .72rem;
  font-weight: 650;
}
.mode-history .history-transport button span { font-size: 1.3rem; line-height: 1; }
.mode-history .history-current { padding: 0; }
@media (min-width: 1021px) {
  .mode-history .playback-controls { grid-template-columns: minmax(190px, auto) minmax(0, 1fr); grid-template-rows: auto; }
}

/* A full date remains in the list, card and tooltip; compact timeline labels stay inside. */
.history-time-stop > span:last-child small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 560px) {
  .mode-history { --timeline-height: 206px; }
}

/* 1.2.2: compact manual controls reserve the remaining width for History. */
.mode-history .timeline-shell { grid-template-columns: 212px minmax(0, 1fr); }
.mode-history .playback-controls {
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, auto) auto;
  padding: 10px; gap: 8px; min-width: 0; align-content: center;
}
.mode-history .history-current { order: 0; min-width: 0; }
.mode-history .history-current .playback-title-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.mode-history #history-step-count { font-size: 10px; line-height: 1.2; white-space: nowrap; }
.mode-history #history-current-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal; max-width: 100%; font-size: 12px; line-height: 1.35;
}
.mode-history .history-transport { order: 1; gap: 5px; }
.mode-history .history-transport button,
.mode-history .history-transport button:first-child { min-height: 44px; padding: 5px 7px; gap: 4px; font-size: 11px; }
.history-scope-filter { display: grid; gap: 4px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.history-scope-filter select { width: 100%; min-height: 36px; border: 1px solid #cdbd9c; background: #fffdf7; color: inherit; border-radius: 4px; padding: 6px; }
.history-scope-badge { font-size: 11px; font-weight: 650; color: #745c38; margin: 8px 0; }
.history-overview-links, .history-map-presets, .parallel-related { display: grid; gap: 6px; margin: 10px 0; }
.history-overview-links h3 { font-size: 13px; margin: 0; }
.history-parallels-button { margin: 8px 0 12px; }
.history-map-reference {
  order: -1; min-height: 36px; max-width: 190px; padding: 5px 9px;
  border: 1px solid #c3b28f; border-radius: 6px; background: #fbf9f0ee;
  font-size: 10px; line-height: 1.3; color: #51482e; box-shadow: 0 4px 14px #232d2c14;
}
.history-map-reference[hidden] { display: none; }
.history-map-reference:focus-visible { outline: 3px solid #247981; outline-offset: 2px; }

/* Parallel dates are textual as well as graphical; the dialog owns focus and scroll. */
.history-parallel-dialog {
  width: min(1080px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid #cbb990; border-radius: 8px; overflow: hidden;
  background: #fbf7ed; color: #383b32; box-shadow: 0 28px 90px #1c292a70;
}
.history-parallel-dialog[open] { display: flex; flex-direction: column; }
.history-parallel-dialog::backdrop { background: #17252a9e; backdrop-filter: blur(3px); }
body:has(.history-parallel-dialog[open]) { overflow: hidden; }
.parallel-header { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #d7c7a8; }
.parallel-header h2 { margin: 0; font: 600 25px/1.2 Georgia, serif; }
.parallel-header .close-button { flex: 0 0 44px; width: 44px; min-height: 44px; }
.parallel-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 24px; min-height: 0; line-height: 1.5; }
.parallel-scroll h3 { margin: 0 0 8px; font-size: 16px; }
.parallel-scroll p, .parallel-scroll aside { font-size: 13px; }
.parallel-controls { display: flex; gap: 16px; align-items: center; margin: 16px 0; }
.parallel-controls label { display: grid; gap: 5px; min-width: 0; font-size: 12px; font-weight: 650; }
.parallel-controls select { min-height: 44px; padding: 6px; max-width: 100%; background: #fffdf6; border: 1px solid #bcaa87; border-radius: 4px; }
.parallel-controls p { flex: 1; }
.parallel-axis { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; margin-left: 42%; font-size: 11px; border-bottom: 1px solid #b5a17e; }
.parallel-lane { margin: 14px 0 20px; }
.parallel-lane h3 { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #dfd2b8; }
.parallel-row { width: 100%; display: grid; grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); align-items: center; gap: 10px; text-align: left; padding: 9px 0; border: 0; border-bottom: 1px solid #e4dac6; background: transparent; color: inherit; }
.parallel-row:hover, .parallel-row:focus-visible { background: #efe6ce; }
.parallel-row.is-selected { background: #e6eade; }
.parallel-copy { display: grid; gap: 2px; padding-left: 7px; min-width: 0; overflow-wrap: anywhere; }
.parallel-copy strong { font-size: 12px; }
.parallel-copy small { font-size: 10px; line-height: 1.4; }
.parallel-copy small:last-child { color: #69614d; }
.parallel-track { position: relative; display: block; height: 18px; border-left: 1px solid #ccb991; border-right: 1px solid #ccb991; background: #e5decb; margin-right: 5px; }
.parallel-track i { display: block; position: absolute; top: 3px; bottom: 3px; min-width: 2px; max-width: 100%; background: #9b7543; border-radius: 2px; }
.parallel-row.is-selected .parallel-track i { background: #426c62; }
.parallel-evidence { border-top: 2px solid #c6b28d; padding-top: 16px; }
.parallel-evidence article { padding: 10px 0; }
.parallel-evidence h4 { font-size: 14px; margin: 6px 0; }
.parallel-evidence .parallel-source { font-size: 11px; }
.history-parallel-dialog button:focus-visible, .history-parallel-dialog select:focus-visible { outline: 3px solid #247981; outline-offset: 2px; }
@media (max-width: 1020px) {
  .mode-history .timeline-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 65px minmax(0, 1fr); }
  .mode-history .playback-controls { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; padding: 6px 10px; gap: 8px; align-items: center; }
  .mode-history .history-transport { width: 182px; }
  .mode-history #history-current-title { font-size: 11px; }
  .mode-history .history-current .playback-title-row { gap: 2px; }
}
@media (max-width: 560px) {
  .history-map-reference { max-width: 133px; font-size: 9px; padding: 4px 7px; }
  .mode-history .history-transport { width: 170px; }
  .mode-history .playback-controls { padding-inline: 7px; }
  .history-parallel-dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .parallel-header { padding: 12px; }
  .parallel-header h2 { font-size: 21px; }
  .parallel-scroll { padding: 12px 12px max(24px, env(safe-area-inset-bottom)); }
  .parallel-controls { display: block; }
  .parallel-controls select { width: 100%; }
  .parallel-row { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .parallel-track { margin-left: 7px; }
  .parallel-axis { margin-left: 7px; }
  .parallel-copy strong { font-size: 13px; }
  .history-parallel-dialog button { min-height: 44px; }
}
@media (min-width: 561px) and (max-width: 1020px) and (max-height: 560px) {
  .mode-history .timeline-shell { grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .mode-history .playback-controls { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .mode-history .history-transport { width: 100%; }
}

.journey-load-notice { max-width: min(420px, calc(100vw - 40px)); padding: 12px 16px; border: 1px solid #c9b797; border-radius: 6px; background: #fffaf0; color: #423a2b; box-shadow: 0 8px 30px #1c292a40; font-size: 13px; }
.journey-load-notice button { min-height: 44px; margin-top: 6px; }

/* 1.2.3 — Navegación consolidada. Las acciones globales viven solo en cabecera. */
.topbar { grid-template-columns: minmax(132px, .55fr) minmax(185px, 1fr) auto; }
.topbar-actions { align-items: center; flex: 0 0 auto; gap: 3px; }
.topbar-actions .icon-button, .topbar-view-menu > summary { min-height: 40px; border-radius: 7px; }
.topbar-actions .icon-button svg, .topbar-view-menu svg { flex: 0 0 17px; width: 17px; height: 17px; }
.topbar-actions .icon-button[hidden], .topbar-view-items [hidden] { display: none !important; }
.topbar-view-menu { position: relative; flex: 0 0 auto; }
.topbar-view-menu > summary { display: inline-flex; list-style: none; cursor: pointer; }
.topbar-view-menu > summary::-webkit-details-marker { display: none; }
.topbar-view-menu[open] > summary { background: #eee6d7; border-color: #d0bfa1; }
.topbar-view-items {
  position: absolute; top: calc(100% + 7px); right: 0; z-index: 110;
  width: min(282px, calc(100vw - 18px)); max-height: min(72dvh, 560px); overflow-y: auto;
  display: grid; gap: 2px; padding: 7px; border: 1px solid #ccbda2;
  border-radius: 9px; box-shadow: 0 14px 35px #192a2b42;
  background: #faf7ee; color: #334341;
}
.topbar-view-items button {
  width: 100%; display: flex; align-items: center; gap: 11px;
  min-height: 42px; padding: 7px 10px; border: 0; border-radius: 5px;
  background: transparent; color: inherit; text-align: left; font: 650 13px/1.3 inherit; cursor: pointer;
}
.topbar-view-items button:hover, .topbar-view-items button:focus-visible { background: #ece3d2; }
.topbar-view-items button svg { width: 17px; height: 17px; }
.disclaimer-open { color: #694c34; }
/* Hide old floating affordances even if styles are cached from an earlier version. */
.map-tools, .map-controls, .history-map-reference { display: none !important; }
/* Easy-to-scan layer sets: four main switches, advanced controls only on demand. */
.layers-panel { width: min(320px, calc(100% - 26px)); }
.mode-history #layers-panel { width: min(320px, calc(100% - 26px)); }
.layer-advanced { margin: 10px 0; border-top: 1px solid #d9ceb8; }
.layer-advanced > summary { cursor: pointer; list-style: none; padding: 13px 2px; color: #625236; font-size: 12px; font-weight: 750; }
.layer-advanced > summary::after { content: '⌄'; float: right; }
.layer-advanced[open] > summary::after { content: '⌃'; }
.layer-advanced > summary::-webkit-details-marker { display: none; }
.compact-layer-row { min-height: 46px; }
.compact-layer-row .layer-ident { align-items: center; }
.history-layers-scroll > .layer-option { min-height: 55px; }
.history-layers-scroll .layer-option { min-height: 47px; }
/* Documentary context: curated facts, not a second list of biblical episodes. */
.world-episode { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-bottom: 13px; border-bottom: 1px solid #ddceb5; }
.world-episode > span { color: #78634b; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.world-episode strong { color: #2d3f3a; font-size: 15px; }
.world-episode small { color: #6c6455; font-size: 11px; }
.world-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.world-picker { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 750; color: #48524b; }
.world-picker select { max-width: 240px; min-height: 42px; min-width: 145px; padding: 5px; border: 1px solid #c7b897; border-radius: 6px; background: #fffdf6; color: #293c37; }
.world-summary { display: flex; flex-wrap: wrap; gap: 5px 12px; justify-content: space-between; margin: 9px 0 16px; font-size: 12px; color: #725b39; font-weight: 700; }
.world-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 22px 16px; }
.world-group { min-width: 0; padding: 0; }
.world-group-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; border-bottom: 2px solid #c7b28d; padding-bottom: 6px; }
.world-group-heading h3 { margin: 0; font: 600 19px/1.3 Georgia, serif; }
.world-group-heading small { color: #697167; font-size: 10px; }
.world-card { background: #fffdf7; border: 1px solid #dfd5c0; border-radius: 7px; margin: 0 0 8px; padding: 11px 12px; }
.world-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 3px 10px; }
.world-card-head strong { color: #304d49; font-size: 14px; }
.world-dates { font-size: 11px; font-weight: 650; white-space: nowrap; color: #725637; }
.world-card .world-region { display: block; margin-top: 4px; color: #687166; font-size: 11px; }
.world-card p { margin: 7px 0; line-height: 1.55; font-size: 13px; }
.world-sources summary, .world-more > summary { cursor: pointer; color: #69583c; font-size: 11px; font-weight: 750; min-height: 25px; }
.world-sources a { display: block; margin: 6px 0 5px; color: #236178; font-size: 12px; overflow-wrap: anywhere; }
.world-more > summary { padding: 11px 5px; }
.world-empty { margin-top: 20px; padding: 28px 12px; text-align: center; border: 1px dashed #bfaf90; border-radius: 8px; font-size: 14px; }
.disclaimer-dialog { width: min(900px, 100%); max-width: 900px; }
.disclaimer-dialog > header { flex: 0 0 auto; }
.disclaimer-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 23px 26px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 18px 26px; }
.disclaimer-content h3 { margin: 0 0 8px; font: 600 17px Georgia, serif; color: #444e43; }
.disclaimer-content p { margin: 0; line-height: 1.7; font-size: 13px; color: #4a514c; }
@media (max-width: 1250px) {
 .topbar-actions .icon-button { padding-inline: 6px; }
 .topbar .brand-block .brand-kicker { display: none; }
}
@media (max-width: 820px) {
  .atlas-shell { --topbar-height: 116px; }
  .atlas-shell.mode-history { --topbar-height: 104px; }
  .topbar { width: 100%; height: var(--topbar-height); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 44px; align-items: center; gap: 2px; padding: 3px 8px; }
  .topbar .brand-block { display: none; }
  .topbar-center, .mode-history .topbar-center { min-width: 0; width: 100%; justify-content: center; }
  .topbar-actions { align-self: center; width: 100%; justify-content: space-around; min-width: 0; }
  .topbar-actions .icon-button:not(.rail-global-toggle):not(.search-button) { display: inline-flex; }
  .topbar-actions .icon-button, .topbar-view-menu > summary { width: auto; padding: 0 7px; min-height: 40px; font-size: 11px; gap: 4px; }
  .topbar-actions .icon-button svg { width: 15px; height: 15px; }
  .topbar-actions .search-button span { display: inline; }
  .topbar-view-menu .topbar-view-items { right: -42px; }
  .layers-panel, .mode-history #layers-panel { top: 4px; right: 6px; bottom: 4px; width: min(320px, calc(100% - 12px)); }
}
@media (max-width: 560px) {
 .topbar-actions { gap: 1px; }
 .topbar-actions .icon-button, .topbar-view-menu > summary { padding-inline: 4px; font-size: 10px; }
 .topbar-actions .search-button span { display: none; }
 .world-groups, .disclaimer-content { grid-template-columns: minmax(0, 1fr); }
 .world-picker { width: 100%; justify-content: space-between; }
 .world-picker select { flex: 1; max-width: min(260px, 65vw); }
 .world-scroll { padding: 12px 12px max(24px, env(safe-area-inset-bottom)); }
 .disclaimer-content { padding: 12px 16px 24px; }
}

/* 1.2.4 — Ayuda accesible desde la cabecera, agrupada y desplazable. */
.help-open { color: #365d60; }
.atlas-help-dialog { width: min(880px, 100%); max-width: 880px; padding: 0; }
.atlas-help-dialog > header { flex: 0 0 auto; align-items: center; padding: 18px 24px 15px; margin: 0; }
.atlas-help-dialog .help-heading { min-width: 0; }
.atlas-help-dialog .help-heading > p:last-child { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.atlas-help-dialog .help-content {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  padding: 18px 24px 26px; scrollbar-gutter: stable;
}
.atlas-help-dialog .help-group + .help-group { margin-top: 22px; }
.atlas-help-dialog .help-group > h3 { margin: 0 0 11px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: #766246; }
.atlas-help-dialog .help-grid { padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; overflow: visible; }
.atlas-help-dialog .help-grid article { display: flex; align-items: flex-start; gap: 12px; min-width: 0; padding: 14px; border-radius: 10px; }
.atlas-help-dialog .help-grid article > div { min-width: 0; }
.atlas-help-dialog .help-symbol { flex: 0 0 32px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #ece5d5; color: #695539; }
.atlas-help-dialog .help-symbol svg { width: 18px; height: 18px; }
.atlas-help-dialog .help-grid h4 { margin: 0 0 5px; color: #2c4847; font-size: 14px; line-height: 1.25; }
.atlas-help-dialog .help-grid p { font-size: 12px; line-height: 1.55; color: #58625c; }
.atlas-help-dialog .help-grid strong { color: #364f4f; }
.atlas-help-dialog .help-content:focus-visible { outline: 2px solid #347a88; outline-offset: -3px; }
@media (max-width: 820px) {
  .atlas-help-dialog > header { padding: 14px 16px 12px; }
  .atlas-help-dialog .help-content { padding: 13px 16px 24px; }
}
@media (max-width: 920px) {
  .atlas-help-dialog .help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .atlas-help-dialog .help-grid { grid-template-columns: minmax(0, 1fr); }
  .atlas-help-dialog .help-grid article { padding: 11px; }
}
@media (max-width: 360px) {
  /* El botón conserva su nombre accesible aunque se abrevie en pantallas mínimas. */
  .topbar-actions .disclaimer-open span { display: none; }
  .topbar-actions .help-open span { display: inline; }
}
@media (max-width: 360px) {
  .topbar-actions .icon-button, .topbar-view-menu > summary { padding-inline: 2px; gap: 2px; }
}
@media (max-width: 360px) {
  .topbar-actions .icon-button, .topbar-view-menu > summary { font-size: 9px; padding-inline: 1px; gap: 1px; min-width: 40px; }
}

/* 1.2.5 — Pestanas de reapertura ligadas a sus paneles, fuera del menu Vista.
   El atributo hidden evita controles invisibles en el orden de tabulacion. */
.panel-reopen-tab {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid #c8baa2;
  background: rgba(251, 248, 239, .98);
  color: #334342;
  box-shadow: 0 5px 16px rgba(30, 43, 43, .14);
  cursor: pointer;
  font: 750 12px/1.2 system-ui, sans-serif;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.panel-reopen-tab svg { width: 17px; height: 17px; flex: none; }
.panel-reopen-tab:hover { background: #fffef9; border-color: #927d5b; }
.panel-reopen-tab:focus-visible { outline: 3px solid #267c90; outline-offset: 2px; }
.panel-reopen-tab[hidden] { display: none !important; }

/* Indice: queda adherido al borde izquierdo de la zona de trabajo. */
.workspace > .rail-reopen {
  top: 12px;
  left: 0;
  z-index: 64;
  border-radius: 0 9px 9px 0;
}

/* Ficha: en escritorio sale del mismo borde por el que se despliega.
   Cuando el indice tambien esta plegado, se separa verticalmente. */
.map-stage > .context-reopen {
  top: 14px;
  left: 0;
  bottom: auto;
  z-index: 48;
  border-radius: 0 9px 9px 0;
}
.workspace.is-rail-collapsed .map-stage > .context-reopen { top: 66px; }

/* Cronologia: la pestana se desplaza con el borde superior del panel.
   Cuando esta plegado permanece en la parte inferior del contenedor. */
.map-stage > .timeline-reopen-tab {
  z-index: 49;
  right: 50%;
  left: auto;
  top: auto;
  bottom: calc(var(--timeline-height) + var(--edge-gap) - 1px);
  min-height: 35px;
  padding: 6px 12px;
  border-radius: 9px 9px 0 0;
  transform: translateX(50%);
  transition: bottom 260ms cubic-bezier(.2,.75,.25,1), background 150ms ease;
}
.map-stage > .timeline-reopen-tab:not(.is-open) {
  bottom: 0;
  border-bottom: 0;
}
.map-stage > .timeline-reopen-tab.is-open .timeline-toggle-chevron { transform: rotate(0deg); }
.map-stage > .timeline-reopen-tab:not(.is-open) .timeline-toggle-chevron { transform: rotate(180deg); }

/* Si la ficha lateral esta abierta, el tirador de cronologia usa el extremo
   opuesto de la banda: nunca queda sobre el contenido de la ficha. */
@media (min-width: 821px) {
  .workspace.is-context-open .map-stage > .timeline-reopen-tab.is-open {
    right: var(--edge-gap);
    transform: none;
  }
}
@media (max-width: 1020px) {
  .workspace > .rail-reopen { top: 8px; }
  /* El indice en modo cajon se superpone al mapa; no ofrecer otro tab por encima. */
  .workspace.is-rail-open .map-stage > .context-reopen { visibility: hidden; pointer-events: none; }
}
@media (max-width: 820px) {
  /* La ficha se despliega desde abajo en movil: pestaña junto a ese borde,
     sin competir con el indice (arriba) ni la cronologia (centrada abajo). */
  .map-stage > .context-reopen,
  .workspace.is-rail-collapsed .map-stage > .context-reopen {
    top: auto;
    bottom: calc(var(--timeline-height) + 62px);
    left: 7px;
  }
  .workspace:not(.is-timeline-open) .map-stage > .context-reopen { bottom: 52px; }
  /* La ficha movil se levanta lo justo para no tapar el tirador
     de la cronologia. Se vuelve desplazable si falta altura. */
  .workspace.is-context-open.is-timeline-open .context-panel.is-open {
    bottom: calc(var(--timeline-height) + 61px);
    min-height: 0;
    max-height: min(52dvh, calc(100% - var(--timeline-height) - 85px));
  }
}
@media (max-width: 560px) {
  .panel-reopen-tab { min-height: 44px; padding: 8px 10px; font-size: 11px; }
  .map-stage > .timeline-reopen-tab { min-height: 38px; padding: 7px 10px; }
  .workspace > .rail-reopen { top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .map-stage > .timeline-reopen-tab { transition: none; }
}

/* Acceso al catálogo estático desde el menú de vista, sin afectar al globo. */
.topbar-view-items .atlas-catalogue-menu-link {
  display:flex; align-items:center; gap:9px; padding:10px 12px; color:inherit;
  font-size:inherit; text-decoration:none; border-radius:6px;
}
.topbar-view-items .atlas-catalogue-menu-link:hover,
.topbar-view-items .atlas-catalogue-menu-link:focus-visible { background:#ece3d2; }
.topbar-view-items .atlas-catalogue-menu-link svg { width:17px; height:17px; }

/* Título semántico estable también después del renderizado de JavaScript. */
.brand-block .app-brand-title { margin:0; font-size:inherit; font-weight:inherit; line-height:1; }
