.rating-history-panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.rating-history-panel > .panel-toolbar {
  align-items: center;
  padding: 11px 16px;
}

.rating-history-heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 9px;
}

.rating-history-heading p {
  margin: 0;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.rating-history-list {
  display: grid;
}

.rating-history-row {
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.16s ease;
}

.rating-history-row:hover {
  background: color-mix(in srgb, var(--teal) 3%, var(--surface));
}

.rating-history-entry {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.rating-history-toggle {
  display: grid;
  min-height: 56px;
  min-width: 0;
  width: 100%;
  grid-template-columns: minmax(250px, auto) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 0;
  padding: 9px 12px 9px 16px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.rating-history-toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 30%, transparent);
  outline-offset: -3px;
}

.rating-history-row.has-warning {
  border-left-color: var(--amber);
}

.rating-history-row.is-failed {
  border-left-color: var(--coral);
}

.rating-history-main {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.rating-history-main strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.rating-history-main time {
  padding-left: 8px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rating-history-delta {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.rating-history-delta.is-positive {
  color: #147a70;
}

.rating-history-delta.is-negative {
  color: #b33e34;
}

.rating-history-delta.is-neutral,
.rating-history-delta.is-initial {
  color: var(--muted);
}

.rating-history-meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.rating-history-meta:empty {
  display: none;
}

.rating-history-meta span {
  display: inline-flex;
  min-height: 22px;
  max-width: 100%;
  align-items: center;
  border-radius: 6px;
  padding: 0 7px;
  overflow: hidden;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating-history-meta span.is-change {
  background: rgba(42, 157, 143, 0.14);
  color: #19766c;
}

.rating-history-meta span.is-attention {
  background: rgba(245, 158, 11, 0.16);
  color: #8b5d0b;
}

.rating-history-meta span.is-danger {
  background: rgba(211, 86, 73, 0.14);
  color: #a73a30;
}

.rating-history-expand-cue {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.rating-history-expand-cue > span:last-child {
  font-size: 15px;
  transition: transform 0.16s ease;
}

.rating-history-toggle[aria-expanded="true"]
  .rating-history-expand-cue
  > span:last-child {
  transform: rotate(180deg);
}

.rating-history-update-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  justify-self: end;
  margin-right: 12px;
  padding: 0 4px;
  color: #147a70;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  text-decoration: none;
}

.rating-history-preview {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-strong) 55%, var(--surface));
}

.rating-history-records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rating-history-record {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px 6px 6px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.rating-history-record:hover {
  border-color: color-mix(in srgb, var(--teal) 45%, var(--border));
}

.rating-history-record:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 30%, transparent);
  outline-offset: 1px;
}

.rating-history-record-jacket,
.rating-history-record-jacket img,
.rating-history-record-placeholder {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 5px;
  background: var(--surface-strong);
  object-fit: cover;
}

.rating-history-record-title {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.rating-history-record-title strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating-history-record-title small,
.rating-history-record-title span,
.rating-history-record-rating small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.rating-history-record-rating {
  display: grid;
  justify-items: end;
}

.rating-history-record-rating strong {
  color: var(--teal);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.rating-history-preview-status {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rating-history-preview-status.is-error {
  color: var(--coral);
}

.rating-history-update-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rating-history-update-link:focus-visible {
  border-radius: 5px;
  outline: 3px solid color-mix(in srgb, var(--teal) 32%, transparent);
  outline-offset: 2px;
}

.rating-history-filters {
  align-items: center;
}

.rating-history-filters .record-option {
  min-height: 32px;
}

@media (max-width: 980px) {
  .rating-history-toggle {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 10px 12px;
  }

  .rating-history-meta {
    grid-column: 1 / -1;
  }

  .rating-history-records {
    grid-template-columns: minmax(0, 1fr);
  }

  .rating-history-panel > .panel-toolbar {
    align-items: stretch;
    flex-direction: row;
  }

  .rating-history-filters {
    width: auto;
    flex: 0 0 auto;
  }
}

@media (max-width: 560px) {
  .rating-history-main {
    gap: 6px;
  }

  .rating-history-main strong {
    font-size: 20px;
  }

  .rating-history-main time {
    padding-left: 6px;
  }

  .rating-history-update-link {
    margin-right: 8px;
  }

  .rating-history-preview {
    padding: 8px 10px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rating-history-expand-cue > span:last-child {
    transition: none;
  }
}
