.panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-left: 1px solid var(--rule-strong);
  box-shadow: -12px 0 32px -16px rgb(0 0 0 / 0.35);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: panel-in 140ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
}

@keyframes panel-in {
  from { transform: translateX(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.panel__head {
  position: sticky;
  top: 0;
  /* Above the body. The strip's ticks and bars are positioned, and without a
     stacking order of its own the sticky header - which comes first in the
     DOM - was painted over by them as the card scrolled. */
  z-index: 2;
  padding: var(--step-4) var(--step-4) var(--step-3);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--rule);
}

.panel__close {
  position: absolute;
  top: var(--step-2);
  right: var(--step-2);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.panel__close:hover { background: var(--bg-sunken); color: var(--ink); }

.panel__title {
  margin: 0 var(--step-6) var(--step-2) 0;
  font-family: var(--font-text);
  font-size: 20px;
  line-height: 1.25;
  font-weight: 600;
}

.panel__meta {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: var(--step-2);
  flex-wrap: wrap;
}

.panel__badge {
  padding: 1px var(--step-2);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel__dates {
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.panel__body { padding: var(--step-4); }

.panel__figure {
  margin: 0 0 var(--step-4);
}

.panel__figure img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.panel__credit {
  margin-top: var(--step-1);
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.4;
}

.panel__credit a { color: var(--ink-faint); }
.panel__credit a:hover { color: var(--accent); }

.panel__flag {
  margin: 0 0 var(--step-3);
  padding: var(--step-2) var(--step-3);
  border-left: 3px solid var(--rule-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font-size: 12px;
}

.panel__flag--contested { border-left-color: var(--accent); }

.panel__summary,
.panel__prose {
  margin: 0 0 var(--step-3);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.55;
}

.panel__note {
  margin: 0 0 var(--step-4);
  padding: var(--step-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.panel__note p { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

.panel__h3 {
  margin: var(--step-4) 0 var(--step-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
}

.panel__chips { display: flex; flex-wrap: wrap; gap: var(--step-1); margin-bottom: var(--step-2); }

.panel__chip {
  padding: 2px var(--step-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  text-transform: capitalize;
}

button.panel__chip { cursor: pointer; }
button.panel__chip:hover { border-color: var(--accent); color: var(--ink); }

/* The lane strip: the entry among its neighbours, drawn to scale. */
.strip { margin: 0 0 var(--step-4); }

.strip__head {
  display: flex;
  justify-content: space-between;
  gap: var(--step-2);
  margin-bottom: var(--step-1);
}

.strip__step {
  padding: 3px var(--step-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.strip__step:hover { border-color: var(--accent); color: var(--ink); }

.strip__axis {
  position: relative;
  height: 15px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--step-2);
}

.strip__tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  color: var(--ink-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Height comes from the row count the packer settled on. Neighbours that run
   past the window are clipped here rather than spilling out of the card. */
.strip__rows { position: relative; overflow: hidden; }
.strip__rows[data-rows="1"] { height: 26px; }
.strip__rows[data-rows="2"] { height: 56px; }
.strip__rows[data-rows="3"] { height: 86px; }
.strip__rows[data-rows="4"] { height: 116px; }

.strip__bar {
  position: absolute;
  height: 26px;
  min-width: 6px;
  padding: 0 var(--step-2);
  border: 0;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  text-align: left;
  overflow: hidden;
  /* A cut title reads as a mistake without this: "Martin Luther" arrived as
     "Mart" and "The Reformation" as "The Reform", sliced mid-word with no
     sign anything was missing. The canvas clips at word boundaries instead,
     which needs text measurement this strip deliberately does without - its
     bars are percentages so it reflows without measuring anything. An
     ellipsis is the honest version of the same promise. */
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.strip__bar:hover { color: var(--ink); outline: 1px solid var(--accent); }

/* The entry the card is about. Not a link - you are already here. */
.strip__bar[data-self="true"] {
  background: var(--select);
  color: var(--bg);
  font-weight: 600;
  cursor: default;
}

.strip__bar-title { pointer-events: none; }
.strip__bar[data-narrow="true"] { padding: 0; min-width: 8px; }
.strip__bar[data-narrow="true"] .strip__bar-title { display: none; }

@media (pointer: coarse) {
  .strip__step { min-height: 36px; padding-inline: var(--step-3); }
}

/* "At the same time" - one row per contemporary, each a jump. */
.panel__same { margin: 0 0 var(--step-2); padding: 0; list-style: none; }

.panel__same-item { margin-bottom: var(--step-1); }

.panel__same-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 var(--step-2);
  width: 100%;
  padding: var(--step-2) var(--step-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.panel__same-button:hover { border-color: var(--accent); }

.panel__same-title {
  grid-column: 1;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.3;
}

.panel__same-when {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel__same-where {
  grid-column: 1;
  color: var(--ink-faint);
  font-size: 11px;
}

@media (pointer: coarse) {
  .panel__same-button { min-height: 44px; }
}

.panel__links { margin: 0; padding-left: var(--step-4); font-size: 13px; }
.panel__links li { margin-bottom: var(--step-1); }
.panel__links a, .panel__wikidata { color: var(--accent); }

.panel__wikidata { display: inline-block; margin-top: var(--step-4); font-size: 12px; }

.panel__shimmer, .panel__error { color: var(--ink-faint); font-size: 13px; }

.panel :focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }

@media (max-width: 640px) {
  /* A sheet from the bottom, not a drawer from the side: it spans the width,
     so sliding it in sideways describes a movement it does not make. */
  .panel {
    top: auto;
    width: 100%;
    max-height: 72%;
    border-left: 0;
    border-top: 1px solid var(--rule-strong);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -12px 32px -16px rgb(0 0 0 / 0.45);
    /* Clears the home indicator, which the minimap was carrying until it gave
       up its row to this card. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: panel-up 160ms ease-out;
  }
}

@keyframes panel-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (pointer: coarse) {
  /* Related-entry chips are the panel's main navigation, so they get the same
     minimum as every other touch target. */
  button.panel__chip { min-height: 44px; padding-inline: var(--step-3); }
  .panel__links a { display: inline-block; padding: var(--step-1) 0; }
}
