.history {
  display: grid;
  gap: 1rem;
}

.history > .section-heading {
  align-items: end;
  padding: 0.25rem 0;
}

.history > .section-heading h2 {
  margin: 0;
  font-size: clamp(1.85rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 31rem), 1fr));
  align-items: start;
  gap: 1rem;
}

.history-card {
  position: relative;
  display: grid;
  gap: 1rem;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-surface);
  padding: 1.15rem;
  background:
    radial-gradient(circle at 100% 0, color-mix(in srgb, var(--color-accent-secondary) 9%, transparent), transparent 18rem),
    linear-gradient(145deg, rgb(255 255 255 / 2.5%), transparent 58%),
    var(--color-surface);
  box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 15%);
}

.history-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.2rem;
  background: linear-gradient(var(--color-accent), var(--color-accent-secondary));
  content: "";
}

.history-card > .room-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-card > .room-heading h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card > .room-heading code,
.history-participant-identity code {
  display: none;
}

.history-card > .room-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.9rem;
}

.history-card > .room-metadata .badge[data-kind="accent"] {
  border-color: color-mix(in srgb, var(--color-success) 40%, var(--color-border));
  background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface-raised));
  color: color-mix(in srgb, var(--color-success) 86%, var(--color-text));
}

.history-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.history-dates > div {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem;
  background: rgb(255 255 255 / 3%);
}

.history-dates strong {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.history-dates span {
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  font-weight: 700;
}

.history-participants {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-participant {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
  padding: 0.75rem 0.8rem;
  background: rgb(255 255 255 / 2.5%);
}

.history-participant[data-current="true"] {
  border-color: color-mix(in srgb, var(--color-accent) 52%, var(--color-border));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--color-accent) 11%, transparent), transparent 65%),
    rgb(255 255 255 / 3%);
  box-shadow: inset 0.18rem 0 0 var(--color-accent);
}

.history-participant-identity {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.history-participant-identity strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-participant > .room-metadata {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-participant .badge {
  min-height: 1.85rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.68rem;
}

.history-pagination {
  display: flex;
  justify-content: center;
  margin-top: 0.25rem;
}

.history-pagination button {
  min-width: min(100%, 16rem);
}

.history > [data-history-empty] {
  margin: 0;
  text-align: center;
}

@media (max-width: 48rem) {
  .history-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 38rem) {
  .history > .section-heading {
    align-items: stretch;
  }

  .history > .section-heading,
  .history > .section-heading .section-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .history-card {
    padding: 0.9rem;
  }

  .history-participant {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.55rem;
  }

  .history-participant > .room-metadata {
    justify-content: flex-start;
  }
}

@media (max-width: 22rem) {
  .history-card {
    gap: 0.8rem;
    padding: 0.75rem;
  }

  .history-card > .room-heading h3 {
    font-size: 1.1rem;
  }

  .history-dates {
    grid-template-columns: 1fr;
  }

  .history-participant {
    padding: 0.65rem;
  }
}
