:root {
  --border-radius: 4px;
  --color-bg: #f6f4ef;
  --color-blue: #003d73;
  --color-ink: #202124;
  --color-muted: #61666d;
  --color-line: #e6e3df;
  --color-neutral-light: #f1efe9;
  --color-accent-1: #2E939F;
  --color-accent-1-light: #53C0CC;
  --color-border: #c5b087;
  --color-border-control: var(--color-accent-1);
  --color-focus: var(--color-blue);
  --shadow: 0 14px 40px rgba(41, 37, 31, 0.2);
  --shadow-sm: 0 3px 10px rgba(41, 37, 31, 0.1);
  --lane-height: 46px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--color-ink);
  background: var(--color-bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}
button {
  transition: all 300ms ease;
}
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

header {
  padding: .5em 28px;
  border-bottom: 1px solid var(--color-line);
  background: #fbfaf7;
  width: 100%;
}
dialog a,
.toolbar-toggle {
  color: var(--color-blue);
  -webkit-text-decoration: solid underline currentColor 1px;
  text-decoration: solid underline currentColor 1px;
  text-decoration-color: currentcolor;
  text-underline-offset: 2px;
  transition: color 200ms, text-underline-offset 200ms, text-decoration-thickness 200ms;
}
.header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}

:is(h1, h2) {
  margin: 0;
  font-size: clamp(1.25rem, 2.2vw, 2.00rem);
  letter-spacing: 0;
}

:is(h1, h2) span {
  color: var(--color-muted);
  font-weight: 620;
}

.event-count {
  flex: 0 0 auto;
  color: var(--color-muted);
  font-weight: 720;
  white-space: nowrap;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 28px;
  border-bottom: 1px solid var(--color-line);
  background: #fffdfa;
  width: 100%;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toolbar-toggle {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.fullscreen-toggle[hidden],
.fullscreen-collapse,
.is-fullscreen .fullscreen-expand {
  display: none;
}

.is-fullscreen .fullscreen-collapse {
  display: inline;
}

:root:fullscreen {
  background: var(--color-bg);
  overflow-y: auto;
}

.toolbar-toggle-icon {
  display: inline-block;
  width: 1em;
  font-size: 0.85em;
  text-align: center;
}

.toolbar[hidden] {
  display: none;
}

.group-location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.search-wrap {
  position: relative;
  min-width: min(12em, 100%);
  flex: 1;
}

.search {
  width: 100%;
  padding-right: 40px;
}

.clear-search {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.clear-search.is-visible {
  display: flex;
}

.clear-search:hover,
.clear-search:focus-visible {
  background: #ece6db;
  color: var(--color-ink);
}

.control {
  height: 38px;
  border: 1.5px solid var(--color-border-control);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  background: #fff;
  color: var(--color-ink);
  padding: 0 12px;
}
select.control {
  appearance: base-select;
  display: flex;
  align-items: center;
}
select.control::picker-icon {
  color: var(--color-accent-1);
}

.control:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--color-focus);
}
select.control:not(:has(option[value=""]:checked)) {
    border: 2px solid var(--color-accent-1);
}

.minimap {
  width: 100%;
  padding: 0 0 22px 0;
  border-bottom: 1px solid var(--color-line);
  position: sticky;
  top: var(--toolbar-height, 63px);
  z-index: 8;
  background: #FFF;
}

.minimap-track {
  position: relative;
  height: 58px;
  border-bottom: 1px solid var(--color-border);
}

.minimap-bars {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--minimap-years), minmax(2px, 1fr));
  align-items: end;
  gap: 1px;
  height: 100%;
}

.minimap-year {
  position: relative;
  display: flex;
  align-items: end;
  min-width: 0;
  height: 100%;
}

.minimap-year.is-decade::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: -18px;
  left: 0;
  width: 1px;
  background: var(--color-border);
}

.minimap-year.is-decade::after {
  content: attr(data-decade);
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  color: var(--color-ink);
  font-size: 0.7rem;
  font-weight: 700;
  transform: translateX(-50%);
  white-space: nowrap;
}

.minimap-bar {
  position: relative;
  width: 100%;
  min-width: 2px;
  height: 100%;
  background: linear-gradient(to top, var(--color-accent-1-light) calc(var(--count-ratio) * 100%),  var(--color-neutral-light) calc(var(--count-ratio) * 100%));
  border: 0;
  padding: 0;
  border-radius: 2px 2px 0 0;
  opacity: 0.25;
  cursor: default;
}

.minimap-bar.has-events {
  opacity: .8;
  cursor: pointer;
}

.minimap-bar.has-events:hover,
.minimap-bar.is-selected,
.minimap-bar:focus-visible {
  opacity: 1;
    background: linear-gradient(to top, var(--color-accent-1) calc(var(--count-ratio) * 100%),  var(--color-neutral-light) calc(var(--count-ratio) * 100%));
}

.minimap-bar:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

@media (pointer: coarse) and (hover: none) {
  .minimap {
    padding-bottom: 0;
  }

  .minimap-track {
    height: auto;
    padding: 4px 20px 22px;
    overflow-x: auto;
  }

  .minimap-bars {
    grid-template-columns: repeat(var(--minimap-years), minmax(24px, 1fr));
    min-width: 100%;
    width: max-content;
    height: 58px;
    gap: 2px;
  }
}

.timeline-shell {
  flex: 1;
  min-height: 0;
  overflow: visible;
  background: var(--color-bg);
}

.timeline {
  --location-label-width: 3rem;
  position: relative;
  width: 100%;
  font-size: .8rem;
}

.lane {
  display: block;
  min-width: 0;
  width: 100%;
  transition: all 300ms ease;
}

.location-viewport {
  position: relative;
  overflow: auto;
  max-height: calc(100svh - var(--header-height, 54px) - var(--toolbar-height, 63px) - var(--minimap-height, 80px));
  scrollbar-gutter: stable;
  scroll-timeline: --location-scroll inline;
}

/*
  CSS-only horizontal scroll shadows: overlays on .timeline sit above the
  viewport (and its sticky headers/cards), fading in/out via the viewport's
  horizontal scroll timeline. No scroll timeline support → no shadows.
*/
/*
@supports (animation-timeline: scroll()) {
  .timeline {
    --scroll-shadow-size: 18px;
    --scroll-shadow-color: rgb(41 37 31 / .1);
    --scroll-fade-distance: 40px;
    --scrollbar-size: 14px;
    --scroll-shadow-inset: 0px;
    timeline-scope: --location-scroll;
  }

  .timeline.is-grouped-by-location {
    --scroll-shadow-inset: var(--location-label-width);
  }

  .timeline::before,
  .timeline::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: var(--scrollbar-size);
    z-index: 7;
    width: var(--scroll-shadow-size);
    pointer-events: none;
    opacity: 0;
    animation: scroll-shadow-fade linear both;
    animation-timeline: --location-scroll;
  }

  .timeline::before {
    left: var(--scroll-shadow-inset);
    background: linear-gradient(to right, rgb(41 37 31 / .2), var(--scroll-shadow-color) 33%, transparent);
    animation-range: 0 var(--scroll-fade-distance);
  }

  .timeline::after {
    right: var(--scrollbar-size);
    background: linear-gradient(to left, rgb(41 37 31 / .2), var(--scroll-shadow-color) 33%, transparent);
    animation-direction: reverse;
    animation-range: calc(100% - var(--scroll-fade-distance)) 100%;
  }
}

@keyframes scroll-shadow-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
*/
.location-viewport:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
}

.location-grid {
  --year-width: 18em;
  width: max(100%, calc(var(--location-label-width) + var(--year-count) * var(--year-width)));
}

/* Keep the corner label accessible without widening the axis. */
.axis-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.location-headings,
.location-row {
  display: grid;
  grid-template-columns: var(--location-label-width) repeat(var(--year-count), minmax(0, 1fr));
}

.timeline:not(.is-grouped-by-location) .location-headings,
.timeline:not(.is-grouped-by-location) .location-row {
  grid-template-columns: repeat(var(--year-count), minmax(0, 1fr));
}

.timeline:not(.is-grouped-by-location) .location-heading,
.timeline:not(.is-grouped-by-location) .location-label {
  display: none;
}

.location-headings {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.location-heading,
.year-heading,
.location-label {
  margin: 0;
  padding: 12px;
  font-size: inherit;
  font-weight: 760;
  border-right: 1px solid var(--color-line);
}

.location-heading,
.location-label {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--color-bg);
  overflow-wrap: anywhere;
}

.location-label {
  padding: 16px 12px;
}

.location-label > span {
  display: block;
  position: sticky;
  /* This scroll viewport already begins below the controls and minimap. */
  top: calc(var(--year-headings-height, 0px) + 16px);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  overflow-wrap: normal;
}

.location-row {
  border-bottom: 1px solid var(--color-border);
  min-height: var(--lane-height);
}

/* .location-row:nth-child(even) {
  background: #f1eee6;
} */

.location-cell {
  min-width: 0;
  border-right: 1px solid var(--color-line);
  padding-top: calc(1em * (sibling-index() - 1));
}

.location-cell .event {
  width: 100%;
  justify-content: flex-start;
  margin-inline: unset;
}

.location-cell .event::before {
  flex-shrink: 0;
}

/* Duration decorations share the row's stacking context so all cards cover them. */
.event-duration {
  position: absolute;
  left: 0;
  top: 50%;
  height: 0;
  pointer-events: none;
  z-index: 0;
}

.event-duration::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 4px;
  background: var(--color-event);
}

.event-duration::after {
  content: "";
  position: absolute;
  right: 0;
  top: -5px;
  width: 10px;
  height: 10px;
  background: var(--color-event);
}

.event-title,
.event-teaser,
.event::before {
  position: relative;
  z-index: 1;
}

.location-cell .event.has-image {
  gap: 0;
}

.location-cell .has-image .event-title {
  margin-left: -3em;
  flex: 1;
}

.track {
  padding: 7px 7px 7px 12px;
}
.track:has(img){
  padding-bottom: 10px;
}

.event {
  position: relative;
  display: flex;
  margin-inline: auto;
  align-items: center;
  justify-content: center;
  gap: 1em;
  border: 0;
  padding: 1em 0;
  cursor: pointer;
  border-radius: 0 7px 7px 0;
  text-align: left;
  background: transparent;

  &::before {
    content: "";
    display: block;
    width: 1.5em;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    background: var(--color-event);
    box-shadow: var(--shadow-sm);
  }
}

.event.has-image {
  padding: 0;

  &::before {
    display: none;
  }
}

.event-teaser {
  width: 9em;
  height: 9em;
  margin: 0;
  padding: 0;
  flex: 0 0 9em;
  border-radius: var(--border-radius);
  overflow: clip;
  box-shadow: -4px 4px 0 var(--color-event), var(--shadow-sm);
}
.event-teaser img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.5);
}
.event:hover {
  .event-title {
    transform: scale(1.15);
  }
}
.event:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}

.event-title {
  min-width: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
  transition: transform 300ms ease-in-out;
  padding: 10px 8px;
  background: rgb(255 255 255 / 95%);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}

dialog {
  width: min(1200px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 24, 28, 0.42);
}

.modal {
  padding: 14px;
  background: #fffdfa;
  display: grid;
  grid-template-areas: 
    "header header"
    "image image"
    "text text"
    "actions actions";
  gap: 1em;
}
@media (width > 800px) {
  .modal {
    padding: 10px 40px 40px 40px;
    display: grid;
    grid-template-areas:
      "actions actions"
      "header header"
      "image text";
  }
  .modal:has(img:not([hidden])) {
    grid-template-columns: auto auto;
    gap: 20px 40px;
  }
}
.modal figure {
  grid-area: image;
  margin: 0;
  min-width: 0;
}
.modal figcaption {
  margin-top: 8px;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.modal img {
  max-width: 100%;
}
.modal-header {
  grid-area: header;
  border-bottom: 1px solid var(--color-line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.modal-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.modal h2 {
  margin: 0 0 7px;
  font-size: clamp(1.2rem, 0.8rem + 0.8vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.nav-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-line);
  border-radius: 7px;
  background: #fff;
  color: var(--color-ink);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.nav-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.date-line {
  color: var(--color-muted);
  font-weight: 720;
  display: flex;
  align-items: center;
}
.date-line span {
  display: inline-flex;
  align-items: center;
}
.date-line span::before {
  content: "";
  width: 1em;
  height: 1em;
  margin-inline: .5em .25em;
  border-radius: 50%;
  background: var(--color-event, currentColor);
}

.close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.description {
  grid-area: text;
  margin: 0;
  color: #35383d;
  line-height: 1.55;
  font-size: 1.125rem;
  max-width: 50rem;
}

.empty,
.loading {
  padding: 34px 28px;
  color: var(--color-muted);
}

.floating-actions {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.floating-action {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(39, 93, 139, 0.28);
  border-radius: 50%;
  background: rgba(255, 253, 250, 0.95);
  color: var(--color-accent-1);
  box-shadow: 0 8px 24px rgba(41, 37, 31, 0.18);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.floating-action:hover,
.floating-action:focus-visible {
  background: var(--color-accent-1);
  color: #fff;
}

@media (max-width: 799px) {
  :root {
    --lane-height: 52px;
  }

  .header-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .toolbar {
    padding: 12px 18px;
  }
}

:root {
  --color-checkbox-hover: #a3cef1;
  --color-checkbox-disabled-bg: #d9d9d9;
}

input[type="checkbox"] {
  width: 1.5em;
  height: 1.5em;
  margin: 6px;
  padding: 2px;
  border: 1.5px solid var(--color-border-control);
  appearance: none;
  box-shadow: var(--shadow-sm);
  background-color: #FFF;
  outline: none;
  border-radius: 6px;
  transition: outline 0.1s;
  cursor: pointer;
}

input[type="checkbox"]:checked {
  background-size: cover;
  padding: 2px;
}

input[type="checkbox"]:not(:disabled):checked {
  border-color: var(--color-border);
  background-size: 20px 20px;
  background-position: center;
  background-repeat: no-repeat;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 32 32" xml:space="preserve"><path style="fill: %23000000" d="M11.941,28.877l-11.941-11.942l5.695-5.696l6.246,6.246l14.364-14.364L32,8.818"/></svg>');
}

input[type="checkbox"]:disabled {
  background-color: var(--color-checkbox-disabled-bg);
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--color-checkbox-hover);
}

@media (prefers-reduced-motion: reduce) {
  input[type="checkbox"] {
    transition: none;
  }
}

@supports not selector(::-webkit-scrollbar) {
  .location-viewport {
    scrollbar-width: 14px;
    scrollbar-color: var(--color-accent-1-light) var(--color-accent-1);
    scrollbar-gutter: stable;
  }
}
.location-viewport::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
.location-viewport::-webkit-scrollbar-thumb {
  background: var(--color-accent-1);
  border-radius: 10px;
}
.location-viewport::-webkit-scrollbar-track {
  background-color: var(--color-border);
}