* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: #e9dfc6;
  color: #3a3324;
  font-family: Georgia, "Times New Roman", serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Top bar */
.rt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #f3ecd8;
  border-bottom: 1px solid #cbbd9a;
  flex-wrap: wrap;
}
.rt-titles h1 {
  margin: 0;
  font-size: 26px;
  color: #2f2715;
  letter-spacing: 0.5px;
}
.rt-titles p {
  margin: 2px 0 0;
  font-size: 13px;
  color: #7d6f4f;
}
.rt-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#rt-search {
  padding: 8px 14px;
  border: 1px solid #c2b48f;
  border-radius: 20px;
  background: #fffdf6;
  color: #3a3324;
  font-family: inherit;
  font-size: 14px;
  width: 170px;
}
#rt-search:focus { outline: none; border-color: #8a7741; }
.rt-zoom {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #c2b48f;
  background: #fffdf6;
  color: #5b4f2e;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.rt-zoom:hover { background: #efe6cf; }
.rt-nav { display: flex; gap: 6px; }
.rt-nav a {
  text-decoration: none;
  color: #6b5d39;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid #c2b48f;
  border-radius: 6px;
  background: #fffdf6;
  font-family: system-ui, sans-serif;
}
.rt-nav a:hover { background: #efe6cf; }

.rt-match {
  padding: 7px 16px;
  background: #f6efdb;
  border-bottom: 1px solid #d8caa6;
  color: #6d5e38;
  font-size: 13px;
  font-family: system-ui, sans-serif;
}

/* Scroll area + timeline */
.rt-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  background: #e9dfc6;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.rt-track { position: relative; }

.rt-axis {
  position: sticky;
  top: 0;
  height: 34px;
  z-index: 5;
  background: #efe6cf;
  border-bottom: 1px solid #cbbd9a;
}
.rt-corner {
  position: sticky;
  left: 0;
  width: 132px;
  height: 34px;
  z-index: 6;
  background: #e7dcbf;
  border-right: 1px solid #cbbd9a;
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #8a7a52;
  font-family: system-ui, sans-serif;
}
.rt-tick {
  position: absolute;
  top: 0;
  height: 34px;
  border-left: 1px solid #d3c4a0;
  padding-left: 5px;
  font-size: 11px;
  color: #8a7a52;
  display: flex;
  align-items: center;
  font-family: system-ui, sans-serif;
  white-space: nowrap;
}

.rt-rows { position: relative; }
.rt-row {
  position: relative;
  border-bottom: 1px solid #d8caa6;
}
.rt-row-label {
  position: sticky;
  left: 0;
  width: 132px;
  height: 54px;
  z-index: 3;
  background: #e7dcbf;
  border-right: 1px solid #cbbd9a;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: bold;
  color: #4a3f24;
  font-size: 14px;
  line-height: 1.15;
}

.rt-bar {
  position: absolute;
  height: 32px;
  top: 11px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.rt-bar:hover { filter: brightness(1.08); }
.rt-bar.dim { opacity: 0.16; }
.rt-bar.match { outline: 3px solid #2f2715; outline-offset: 1px; z-index: 2; }

.rt-bar-label {
  position: absolute;
  height: 32px;
  top: 11px;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-family: system-ui, -apple-system, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  z-index: 1;
}
.rt-bar-label.inside { color: #fff; padding: 0 7px; overflow: hidden; }
.rt-bar-label.outside { color: #3a3324; padding-left: 5px; }
.rt-bar-label.dim { opacity: 0.16; }
.rt-bar-label.match { color: #1a1206; font-weight: bold; }

/* Overview minimap */
.rt-overview {
  background: #f3ecd8;
  border-top: 1px solid #cbbd9a;
  padding: 6px 12px 10px;
}
.rt-ov-label {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #8a7a52;
  font-family: system-ui, sans-serif;
  margin-bottom: 4px;
}
.rt-minimap {
  position: relative;
  height: 54px;
  background: #e9dfc6;
  border: 1px solid #cbbd9a;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}
.rt-ov-bar {
  position: absolute;
  border-radius: 1px;
  opacity: 0.85;
}
.rt-ov-view {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(47, 39, 21, 0.16);
  border-left: 1px solid rgba(47, 39, 21, 0.5);
  border-right: 1px solid rgba(47, 39, 21, 0.5);
  pointer-events: none;
}

/* Detail modal */
.rt-modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.rt-modal-card {
  background: #fbf6e8;
  border: 1px solid #c2b48f;
  border-radius: 14px;
  max-width: 440px;
  width: 100%;
  padding: 22px 22px 24px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.rt-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: none;
  background: none;
  font-size: 26px;
  color: #8a7a52;
  cursor: pointer;
  line-height: 1;
}
.rt-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.rt-modal-card h2 {
  margin: 0;
  font-size: 24px;
  color: #2f2715;
  padding-right: 16px;
}
.rt-modal-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  margin-top: 8px;
}
.rt-modal-kingdom {
  font-size: 12px;
  font-family: system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8a7a52;
  margin-top: 4px;
}
.rt-modal-title {
  margin: 6px 0 0;
  font-style: italic;
  color: #6d5e38;
  font-size: 15px;
}
.rt-modal-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-family: system-ui, sans-serif;
}
.rt-pill {
  background: #ece2c6;
  border: 1px solid #d3c4a0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 14px;
  color: #4a3f24;
}
.rt-arrow { color: #a8946a; font-size: 16px; }
.rt-yrs {
  margin-left: auto;
  color: #9a8a62;
  font-size: 13px;
}
.rt-modal-hr {
  border: none;
  border-top: 1px solid #d8caa6;
  margin: 16px 0 14px;
}
.rt-modal-note {
  margin: 0;
  line-height: 1.55;
  color: #3a3324;
  font-size: 15px;
}

@media (max-width: 560px) {
  .rt-titles h1 { font-size: 21px; }
  #rt-search { width: 130px; }
}

.rt-modal-map {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 18px;
  background: #6b4f1d;
  color: #f3ecd8;
  border-radius: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: bold;
  text-decoration: none;
  transition: background 0.15s;
}
.rt-modal-map:hover { background: #543d12; }
