:root {
  --paper: #f4ead6;
  --paper-deep: #e7d7b9;
  --ink: #30291e;
  --muted: #766b58;
  --line: rgba(65, 51, 31, 0.24);
  --panel: rgba(252, 245, 229, 0.96);
  --shadow: 0 18px 40px rgba(55, 41, 21, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    radial-gradient(circle at 18% 12%, rgba(196, 134, 89, 0.12), transparent 32rem),
    var(--paper);
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 82px;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 234, 214, 0.94);
  backdrop-filter: blur(10px);
}

.brand h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.9;
}

.kicker,
.panel-kicker,
.search-wrap span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.controls {
  display: flex;
  align-items: end;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-wrap {
  display: grid;
  gap: 0.25rem;
}

.search-wrap input {
  width: min(42vw, 280px);
  min-height: 38px;
  border: 1px solid rgba(65, 51, 31, 0.34);
  border-radius: 2px;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  background: #fff8e8;
}

.event-filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 38px;
}

.event-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  color: var(--ink);
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
}

.event-filter input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #8f7354;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 38px;
}

.zoom-controls button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(65, 51, 31, 0.34);
  border-radius: 999px;
  color: var(--ink);
  background: #fff8e8;
  cursor: pointer;
}

.close-panel {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(65, 51, 31, 0.34);
  border-radius: 999px;
  color: var(--ink);
  background: #fff8e8;
  cursor: pointer;
}

.zoom-controls input {
  width: 220px;
  accent-color: #8f7354;
}

main {
  position: relative;
}

.intro-panel {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 15;
  width: min(260px, calc(100vw - 2rem));
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intro-panel p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.map-shell {
  min-height: calc(100vh - 82px);
}

.map-scroller {
  overflow: auto;
  height: calc(100vh - 82px);
  border-top: 1px solid rgba(255, 255, 255, 0.38);
}

#histomap {
  display: block;
  min-width: 1800px;
  background:
    linear-gradient(90deg, rgba(82, 58, 28, 0.04) 1px, transparent 1px) 0 0 / 128px 100%,
    linear-gradient(rgba(82, 58, 28, 0.025) 1px, transparent 1px) 0 0 / 100% 48px,
    var(--paper);
}

.axis-line,
.year-tick line,
.region-rule {
  stroke: rgba(65, 51, 31, 0.27);
  stroke-width: 1;
}

.year-tick .minor-year-line {
  stroke: rgba(65, 51, 31, 0.11);
  stroke-width: 0.8;
}

.year-tick .major-year-line {
  stroke: rgba(65, 51, 31, 0.27);
  stroke-width: 1;
}

.year-tick text,
.region-label,
.era-label {
  fill: var(--muted);
  font-size: 12px;
}

.region-label {
  display: none;
  font-size: 15px;
  text-anchor: middle;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.band {
  cursor: pointer;
  stroke: none;
  stroke-width: 0;
  stroke-linejoin: round;
  transition: opacity 160ms ease, filter 160ms ease;
}

.band.is-dimmed {
  opacity: 0.18;
}

.band.is-active {
  opacity: 1;
  filter: saturate(1.22) contrast(1.08) drop-shadow(0 0 1px rgba(30, 22, 13, 0.75));
}

.band-label {
  pointer-events: none;
  font-size: 14px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke-width: 4.5px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.event-marker {
  cursor: pointer;
  opacity: 0.98;
}

.book-marker {
  cursor: pointer;
  filter: drop-shadow(0 3px 4px rgba(24, 18, 11, 0.42));
}

.book-marker image {
  pointer-events: none;
}

.mouse-year line {
  stroke: rgba(38, 31, 22, 0.6);
  stroke-width: 1;
  stroke-dasharray: 7 7;
}

.mouse-year {
  pointer-events: none;
}

.mouse-year text {
  fill: #261f16;
  font-size: 15px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(244, 234, 214, 0.92);
  stroke-width: 7px;
}

.tooltip {
  position: fixed;
  z-index: 30;
  display: none;
  max-width: 300px;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(65, 51, 31, 0.28);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.tooltip strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 1.05rem;
}

.tooltip span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.tooltip p {
  margin: 0;
  line-height: 1.35;
}

.info-panel {
  position: fixed;
  top: 98px;
  right: 1rem;
  z-index: 25;
  width: min(360px, calc(100vw - 2rem));
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.book-ad-panel {
  position: fixed;
  top: 98px;
  right: 1rem;
  z-index: 20;
  width: min(360px, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.info-panel.is-hidden {
  display: none;
}

.close-panel {
  float: right;
  margin-left: 0.75rem;
}

.info-panel h2 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.8rem;
  font-weight: 500;
}

.info-panel p {
  line-height: 1.45;
}

.event-list {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.event-list li {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.event-list time {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
}

.book-ad {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.info-panel .book-ad {
  clear: both;
  margin: 0 0 1rem;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}

.book-ad img {
  display: block;
  width: 66px;
  height: 105px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(32, 24, 13, 0.3);
}

.book-ad-copy {
  display: grid;
  gap: 0.16rem;
  line-height: 1.2;
}

.book-ad-kicker {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-ad strong {
  font-size: 1.08rem;
}

.book-ad-copy > span:not(.book-ad-kicker) {
  color: var(--muted);
  font-size: 0.88rem;
}

.book-ad b {
  margin-top: 0.3rem;
  color: #5f421d;
  font-size: 0.9rem;
}

.book-ad:hover strong,
.book-ad:hover b {
  text-decoration: underline;
}

a {
  color: #6d4734;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.empty-state {
  fill: var(--muted);
  font-size: 18px;
  text-anchor: middle;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    justify-content: flex-start;
    width: 100%;
  }

  .search-wrap input {
    width: min(92vw, 330px);
  }

  .map-scroller {
    height: calc(100vh - 142px);
  }

  .info-panel {
    top: auto;
    right: 0.75rem;
    bottom: 0.75rem;
    max-height: 48vh;
  }

  .book-ad-panel {
    top: auto;
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .intro-panel {
    display: none;
  }
}
