.assessment-history {
  min-width: 0;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
#history-view .page-intro { padding-block: 28px 12px; margin-bottom: 12px; }
#history-view .page-intro h1 { max-width: none; font-size: clamp(1.8rem, 3vw, 3rem); line-height: 1.2; }
#history-view .assessment-history { margin-top: 12px; }
.assessment-history[hidden] { display: none !important; }
.assessment-history .ah-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.assessment-history .ah-heading h2,
.assessment-history .ah-heading h3 { margin: 0; font-size: 1.28rem; line-height: 1.4; }
.assessment-history .ah-heading p { max-width: 68ch; margin: 7px 0 0; color: var(--muted); font-size: .9rem; }
.assessment-history .ah-status { min-height: 1.65em; margin: 12px 0; color: var(--muted); font-size: .9rem; }
.assessment-history .ah-status[data-state="error"] { color: var(--danger); }
.assessment-history .ah-content { min-width: 0; }
.assessment-history .ah-record-list { margin: 0; padding: 0; list-style: none; }
.assessment-history .ah-record { min-width: 0; padding: 20px 0; border-bottom: 1px solid var(--line); }
.assessment-history .ah-record:first-child { padding-top: 4px; }
.assessment-history .ah-record-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.assessment-history .ah-record-title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.5; }
.assessment-history .ah-record-date { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 7px; color: var(--muted); font-size: .85rem; }
.assessment-history .ah-player-profile { margin: 6px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.assessment-history .ah-player-profile:empty { display: none; }
.assessment-history .ah-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 16px 0 0; border-block: 1px solid var(--line); }
.assessment-history .ah-metric { min-width: 0; padding: 11px 12px 12px 0; }
.assessment-history .ah-metric + .ah-metric { padding-left: 12px; border-left: 1px solid var(--line); }
.assessment-history .ah-metric dt { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.assessment-history .ah-metric dd { margin: 4px 0 0; color: var(--green-deep, var(--green)); font-size: 1.1rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.assessment-history .ah-total dd { font-size: 1.2rem; }
.assessment-history .ah-card-details { margin-top: 14px; }
.assessment-history .ah-card-details > summary { width: fit-content; color: var(--green-deep, var(--green)); cursor: pointer; font-weight: 700; text-underline-offset: .2em; }
.assessment-history .ah-card-preview { width: min(100%, 360px); margin: 14px 0 0; }
.assessment-history .ah-card-preview img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface, var(--paper, #fffef9)); }
.assessment-history .ah-card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.assessment-history .ah-search { margin-bottom: 14px; }
.assessment-history .ah-search label { min-width: min(100%, 280px); }
.assessment-history .ah-status { padding-block: 2px; }
.assessment-history .ah-admin-results { min-height: 72px; }
.assessment-history .ah-admin-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.assessment-history .ah-admin-table th,
.assessment-history .ah-admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.assessment-history .ah-admin-table th { color: var(--muted); background: var(--surface-muted, #edf2ec); font-size: .78rem; }
.assessment-history .ah-admin-table td { font-size: .88rem; font-variant-numeric: tabular-nums; }
.assessment-history .ah-admin-table tbody tr:last-child td { border-bottom: 0; }
.assessment-history .ah-admin-table tbody tr:hover { background: color-mix(in srgb, var(--surface, #fffef9) 86%, var(--green-soft, #dff3e8)); }
.assessment-history .ah-pagination { margin-top: 14px; }
.assessment-history :is(button, input, summary, a):focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.assessment-history .ah-admin-actions { min-width: 220px; }
.assessment-history .ah-detail-trigger { min-height: 44px; padding: 9px 12px; white-space: normal; }
.assessment-history .ah-detail-dialog {
  width: min(760px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface, var(--paper, #fffef9));
  box-shadow: 0 20px 56px rgba(18, 35, 29, .24);
}
.assessment-history .ah-detail-dialog::backdrop { background: rgba(9, 28, 21, .58); }
.assessment-history .ah-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.assessment-history .ah-detail-title { min-width: 0; margin: 0; font-size: 1.3rem; line-height: 1.4; }
.assessment-history .ah-detail-close { flex: 0 0 68px; min-width: 68px; min-height: 44px; padding: 8px; white-space: nowrap; }
.assessment-history .ah-detail-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin: 18px 0 14px; padding: 14px 0; border-block: 1px solid var(--line); }
.assessment-history .ah-detail-meta-item { min-width: 0; }
.assessment-history .ah-detail-meta-item dt,
.assessment-history .ah-detail-score dt { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.assessment-history .ah-detail-meta-item dd,
.assessment-history .ah-detail-score dd { margin: 4px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.assessment-history .ah-detail-meta-item:last-child dd { color: var(--green-deep, var(--green)); font-size: 1.1rem; font-weight: 750; }
.assessment-history .ah-detail-status { min-height: 1.5em; margin: 10px 0; color: var(--muted); font-size: .9rem; }
.assessment-history .ah-detail-status[data-state="error"] { color: var(--danger); }
.assessment-history .ah-detail-question { min-width: 0; padding: 18px 0; border-top: 1px solid var(--line); }
.assessment-history .ah-detail-question-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.assessment-history .ah-detail-question-number { margin: 0; font-size: 1rem; line-height: 1.45; }
.assessment-history .ah-detail-code { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.assessment-history .ah-detail-question-state { color: var(--muted); font-size: .84rem; }
.assessment-history .ah-detail-question-title { margin: 8px 0 0; line-height: 1.6; }
.assessment-history .ah-detail-answer-label { margin: 14px 0 6px; font-size: .88rem; }
.assessment-history .ah-detail-answer { max-width: 100%; margin: 0; padding: 12px; border-radius: 8px; color: var(--ink); background: var(--surface-muted, #edf2ec); white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.65; }
.assessment-history .ah-detail-scores { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 14px 0 0; border-block: 1px solid var(--line); }
.assessment-history .ah-detail-score { min-width: 0; padding: 10px 9px; }
.assessment-history .ah-detail-score + .ah-detail-score { border-left: 1px solid var(--line); }
.assessment-history .ah-detail-score dd { color: var(--green-deep, var(--green)); font-weight: 700; }
.assessment-history .ah-detail-retry { min-height: 44px; }

@media (max-width: 680px) {
  .assessment-history .ah-heading { align-items: start; }
  .assessment-history .ah-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assessment-history .ah-metric:nth-child(odd) { padding-left: 0; border-left: 0; }
  .assessment-history .ah-metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .assessment-history .ah-total { grid-column: span 2; padding-left: 0; border-left: 0; }
  .assessment-history .ah-search { align-items: stretch; }
  .assessment-history .ah-search label { flex: 1 1 100%; }
  .assessment-history .ah-search .button { flex: 1 1 96px; }
  .assessment-history .ah-pagination { gap: 8px; }
  .assessment-history .ah-pagination > span { flex-basis: 100%; order: -1; }
  .assessment-history .ah-pagination .button { flex: 1 1 96px; }
  .assessment-history .ah-detail-dialog { padding: 18px; }
  .assessment-history .ah-detail-meta { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .assessment-history .ah-detail-scores { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assessment-history .ah-detail-score:nth-child(odd) { border-left: 0; }
  .assessment-history .ah-detail-score:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
