.yearview {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.yearview__head {
  display: flex;
  align-items: center;
  gap: var(--step-3);
  flex-wrap: wrap;
  padding: var(--step-3) var(--step-4);
  /* Nothing sits above this now, so it clears the status bar itself. */
  padding-top: calc(var(--step-3) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--rule);
  background: var(--bg-raised);
}

.yearview__year {
  margin: 0;
  font-family: var(--font-text);
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.yearview__count { margin: 0; color: var(--ink-faint); font-size: 12px; }

.yearview__steps { display: flex; gap: var(--step-1); }

.yearview__step {
  padding: 3px var(--step-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

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

.yearview__actions { margin-left: auto; display: flex; align-items: center; gap: var(--step-2); }

.yearview__link {
  padding: 4px var(--step-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.yearview__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--step-4);
  /* The minimap row normally carries this inset, and it is hidden here, so
     the last entries would otherwise sit under the home indicator. */
  padding-bottom: calc(var(--step-4) + env(safe-area-inset-bottom, 0px));
  /* Columns rather than one long list: a busy year runs to dozens of entries,
     and a single column makes the reader scroll past regions they can see. */
  columns: 340px;
  column-gap: var(--step-6);
}

.yearview__lane {
  break-inside: avoid;
  margin: 0 0 var(--step-5);
}

.yearview__laneName {
  margin: 0 0 var(--step-2);
  padding-bottom: 3px;
  border-bottom: 1px solid var(--rule);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
}

.yearview__list { margin: 0; padding: 0; list-style: none; }

.yearview__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 var(--step-2);
  padding: var(--step-1) 0;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 45%, transparent);
}

.yearview__name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.yearview__name:hover { color: var(--accent); }

.yearview__span {
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: center;
}

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

/*
 * How far through its own span this year falls.
 *
 * A rule rather than a chart. The numbers are already on the row - "year 217
 * of 235" - so this adds no labels and no axis; it exists so the column can
 * be read down, and an empire near its end can be told from one just begun
 * without doing arithmetic on every line.
 *
 * Two pixels tall, because there are up to forty of these in a view whose
 * whole virtue is that it is a dense text column.
 */
.yearview__track {
  grid-column: 1 / -1;
  height: 2px;
  margin-top: 3px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--rule-strong) 55%, transparent);
  overflow: hidden;
}

.yearview__done {
  display: block;
  height: 100%;
  border-radius: 1px;
  background: var(--ink-faint);
}

/* On the row that began or ended this year, the rule takes the accent too, so
   the eye finds those first. */
.yearview__item[data-boundary="true"] .yearview__done { background: var(--accent); }

/* Something that began or ended in this exact year, rather than a century
   merely passing through it. */
.yearview__item[data-boundary="true"] .yearview__name { font-weight: 600; }
.yearview__where--now { color: var(--accent); }

.yearview__empty { color: var(--ink-faint); }

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

@media (max-width: 560px) {
  /* The header was taking more than half the screen: the year on one line,
     six steppers wrapped onto a second, and the actions onto a third. It is
     now two compact rows, with the steppers scrolling instead of wrapping. */
  .yearview__head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "year count link" "steps steps steps";
    gap: var(--step-2);
    align-items: center;
    padding: var(--step-2) var(--step-3);
    /* As above: the shorthand would drop the notch inset. */
    padding-top: calc(var(--step-2) + env(safe-area-inset-top, 0px));
  }

  .yearview__year { grid-area: year; font-size: 20px; }
  .yearview__count { grid-area: count; display: block; font-size: 11px; white-space: nowrap; }
  .yearview__link { grid-area: link; padding: 4px var(--step-2); font-size: 11px; }
  .yearview__actions { display: contents; }

  /* The steppers own this row, so they share it equally rather than bunching
     at the left with dead space beside them. Equal widths also mean the same
     target size wherever your thumb lands. */
  .yearview__steps {
    grid-area: steps;
    flex-wrap: nowrap;
    gap: var(--step-1);
  }

  .yearview__step {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 2px;
    text-align: center;
  }

  /* The shorthand would drop the safe-area inset set above, which is exactly
     where it matters most - this is the phone case. */
  .yearview__body {
    columns: auto;
    padding: var(--step-3);
    padding-bottom: calc(var(--step-3) + env(safe-area-inset-bottom, 0px));
  }
  .yearview__lane { margin-bottom: var(--step-4); }

  /* Stack rather than compete for width: a long title and a date range on one
     line forces both to wrap. */
  .yearview__item {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 5px 0;
  }

  .yearview__name { font-size: 15px; line-height: 1.3; }

  .yearview__span,
  .yearview__where {
    grid-column: 1;
    display: inline;
    font-size: 11px;
  }

  .yearview__track { grid-column: 1; margin-top: 4px; }

  /* Span and position read as one meta line under the title. */
  .yearview__span::after {
    content: " \00b7 ";
    color: var(--ink-faint);
  }
}

@media (pointer: coarse) {
  /* Height only - the width comes from sharing the row, and padding here
     would push the six of them wider than the screen. */
  .yearview__step { min-height: 44px; }
  .yearview__link { min-height: 44px; }
  .yearview__name { min-height: 32px; }
}

/* Above the phone layout the steppers sit inline in a single header row, and
   keep their natural width. */
@media (min-width: 561px) {
  .yearview__step { padding-inline: var(--step-3); }
}
