:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e2da;
  --accent: #6d4aff;
  --soft: #f3f0ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Map-pin icon used in events and links */
  --pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e4572e' d='M12 2a7 7 0 0 0-7 7c0 5.2 7 13 7 13s7-7.8 7-13a7 7 0 0 0-7-7z'/%3E%3Ccircle cx='12' cy='9' r='2.6' fill='white'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1c1f; --panel: #222327; --text: #e8e6e3; --muted: #9aa0a6; --border: #34363b; --accent: #a48bff; --soft: #2c2840; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto minmax(150px, 34vh);
  height: 100vh;
}

/* ---------- header ---------- */
#top {
  display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.5rem; align-items: center;
  padding: .8rem 1.2rem .7rem; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand h1 { margin: .1rem 0 0; font-size: 1.35rem; }
.home { color: var(--muted); text-decoration: none; font-size: .85rem; }
.home:hover { color: var(--accent); }
.muted { color: var(--muted); margin: 0; font-size: .85rem; }
.tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: flex-end; }
#search {
  flex: 1 1 220px; max-width: 360px; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: .95rem;
}
.buttons { display: flex; gap: .3rem; }
.buttons button {
  min-width: 2.2rem; height: 2.2rem; padding: 0 .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: .9rem; cursor: pointer;
}
.buttons button:hover { border-color: var(--accent); color: var(--accent); }
.toggle { display: inline-flex; gap: .35rem; align-items: center; font-size: .85rem; color: var(--muted); cursor: pointer; user-select: none; }
#categories { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); border-radius: 999px; padding: .2rem .6rem;
  font-size: .8rem; cursor: pointer;
}
.chip .n { color: var(--muted); }
.chip.off { opacity: .4; }
.dot { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- the timeline ---------- */
#timeline { min-height: 0; background: var(--panel); --c: var(--accent); }
#list { --c: var(--accent); }
#hint { padding: .35rem 1.2rem; background: var(--panel); border-top: 1px solid var(--border); font-size: .78rem; }
#timeline .vis-timeline { border: 0 !important; font-family: inherit; }
#timeline .vis-panel.vis-center, #timeline .vis-panel.vis-left, #timeline .vis-panel.vis-right, #timeline .vis-panel.vis-top, #timeline .vis-panel.vis-bottom { border-color: var(--border) !important; }
#timeline .vis-time-axis .vis-text { color: var(--muted); font-size: .8rem; }
#timeline .vis-time-axis .vis-text.vis-major { color: var(--text); font-weight: 600; }
#timeline .vis-time-axis .vis-grid.vis-minor { border-color: var(--border); }
#timeline .vis-time-axis .vis-grid.vis-major { border-color: #cfc9bd; }
#timeline .vis-labelset .vis-label { color: var(--text); border-color: var(--border); font-size: .85rem; }
#timeline.lanes .vis-labelset .vis-label .vis-inner { padding: .4rem .6rem; border-left: 4px solid var(--c); }
#timeline .vis-foreground .vis-group { border-color: var(--border); }

#timeline .vis-item {
  cursor: pointer; color: var(--text); font-size: .85rem;
  border-color: var(--c); background: var(--panel);
}
/* Short spans still show their title, just past the end of the bar */
#timeline .vis-item.vis-range .vis-item-overflow { overflow: visible; }
/* A single moment: a coloured dot with the title beside it */
#timeline .vis-item.vis-point { border: 0; background: none; }
#timeline .vis-item.vis-dot { border-width: 5px; border-color: var(--c); background: var(--c); }
#timeline .vis-item.vis-dot.approx { border-width: 2px; border-style: dashed; background: var(--panel); width: 10px; height: 10px; }
#timeline .vis-item.vis-point.approx .ev-title::before { content: "c. "; color: var(--muted); }
#timeline .vis-item.vis-point .vis-item-content { padding: 2px 4px 2px 3px; }
/* A span of time: a coloured bar */
#timeline .vis-item.vis-range {
  --fill: color-mix(in srgb, var(--c) 24%, var(--panel));
  background: var(--fill); border: 1.5px solid var(--c); border-radius: 6px; color: var(--text);
}
#timeline .vis-item.vis-range.approx-start { border-left-style: dashed; background: linear-gradient(to right, transparent, var(--fill) min(40px, 35%)); }
#timeline .vis-item.vis-range.approx-end { border-right-style: dashed; background: linear-gradient(to left, transparent, var(--fill) min(40px, 35%)); }
#timeline .vis-item.vis-range.approx-start.approx-end { background: linear-gradient(to right, transparent, var(--fill) min(40px, 30%), var(--fill) max(calc(100% - 40px), 70%), transparent); }
#timeline .vis-item.vis-range .vis-item-content { padding: 3px 8px; }
#timeline .vis-item.vis-range.vis-selected { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); z-index: 2; }
#timeline .vis-item.vis-point.vis-selected { background: color-mix(in srgb, var(--c) 16%, transparent); border-radius: 6px; }
#timeline .vis-item.vis-dot.vis-selected { border-color: var(--c); background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 35%, transparent); }
#timeline .vis-item.vis-dot.approx.vis-selected { background: var(--panel); }
#timeline .vis-item:hover .ev-title { text-decoration: underline; text-decoration-color: var(--c); text-underline-offset: 2px; }
.ev { display: inline-flex; align-items: center; gap: .3rem; }
.ev-map, .pin-inline {
  display: inline-block; width: 15px; height: 15px; flex: none; vertical-align: -2px;
  background: var(--pin) center / contain no-repeat;
}
.ev-map { cursor: pointer; border-radius: 4px; transition: transform .1s; }
.ev-map:hover { transform: scale(1.3); }

/* Clusters of events that are too close together to show separately */
#timeline .vis-item.vis-cluster {
  min-width: 1.9rem; background: var(--accent); border: 2px solid var(--panel); color: #fff; border-radius: 999px;
  font-size: .8rem; font-weight: 700; box-shadow: 0 0 0 1px var(--accent);
}
#timeline .vis-item.vis-cluster .vis-item-content { padding: 3px 6px; text-align: center; width: 100%; }

/* Hover card */
#timeline div.vis-tooltip {
  max-width: 340px; white-space: normal; padding: .6rem .75rem; border-radius: 10px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0,0,0,.15); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .85rem; line-height: 1.4;
}
.tip b { font-size: .95rem; }
.tip-date { color: var(--accent); font-weight: 600; margin: .15rem 0 .35rem; }
.tip-hint { color: var(--muted); font-size: .75rem; margin-top: .45rem; }

/* ---------- the list below the timeline ---------- */
#list-panel { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--border); background: var(--bg); }
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem; padding: .6rem 1.2rem .4rem; }
.list-head h2 { margin: 0; font-size: 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: .9rem; color: var(--muted); font-size: .78rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.lg-dot.approx { background: none; border: 2px dashed var(--accent); }
.lg-bar { width: 26px; height: 10px; border-radius: 3px; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 24%, var(--panel)); display: inline-block; }
.lg-cluster { display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.1rem; padding: 0 .3rem; border-radius: 999px; background: var(--accent); color: #fff; font-style: normal; font-weight: 700; font-size: .7rem; }
.lg-bar.fuzzy { border-left-style: dashed; background: linear-gradient(to right, transparent, color-mix(in srgb, var(--accent) 24%, var(--panel)) 70%); }

#list { list-style: none; margin: 0; padding: 0 1.2rem 1.2rem; overflow-y: auto; flex: 1; }
#list li { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; gap: .2rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
#list li.more { display: block; }
#list li.sep { display: block; padding: .9rem 0 .3rem; border-bottom: 0; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.when {
  display: flex; align-items: flex-start; gap: .45rem; text-align: left; border: 0; background: none; padding: 0;
  color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; font-variant-numeric: tabular-nums;
}
.when:hover { color: var(--accent); }
.when .dot { background: var(--c); margin-top: .3rem; }
.when .dot.approx { background: none; border: 2px dashed var(--c); }
.when .dot.bar { width: 1rem; height: .55rem; border-radius: 3px; margin-top: .4rem; }
.what { min-width: 0; }
.what .title { font-weight: 600; color: var(--text); text-decoration: none; }
.what a.title:hover { color: var(--accent); text-decoration: underline; }
.what a.title::after { content: " ↗"; color: var(--muted); font-weight: 400; font-size: .8em; }
.what .cat { color: var(--muted); font-size: .78rem; margin-left: .4rem; }
.maplink { margin-left: .6rem; font-size: .8rem; color: var(--accent); text-decoration: none; white-space: nowrap; }
.maplink:hover { text-decoration: underline; }
.maplink .pin-inline { width: 13px; height: 13px; margin-right: .15rem; }
.what p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }

@media (max-width: 760px) {
  body { grid-template-rows: auto minmax(280px, 55vh) auto auto; height: auto; min-height: 100vh; }
  #top { grid-template-columns: 1fr; padding: .7rem .8rem; }
  .tools { justify-content: flex-start; }
  #search { max-width: none; }
  #list { padding: 0 .8rem 1rem; overflow: visible; }
  #list li { grid-template-columns: 1fr; }
  .list-head { padding: .6rem .8rem .3rem; }
}
