/* History perspective: compact factual comparison cards. */

.history-case-shell {
    margin: 16px 0 0;
    border: 1px solid var(--border-color, #e2e6ef);
    border-radius: 8px;
    background: var(--bg-card, #fff);
}

.history-case-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 18px;
    cursor: pointer;
    list-style: none;
}

.history-case-head::-webkit-details-marker {
    display: none;
}

.history-case-head h3 {
    margin: 0 0 5px;
    font-size: 16px;
    line-height: 1.35;
}

.history-case-head p {
    max-width: 760px;
    margin: 0;
    color: var(--text-secondary, #667085);
    font-size: 12.5px;
    line-height: 1.55;
}

.history-case-head-hint {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border: 1px solid var(--border-color, #e2e6ef);
    border-radius: 6px;
    color: var(--text-secondary, #667085);
    font-size: 12px;
    white-space: nowrap;
}

.history-case-head-hint::before {
    content: '展开';
}

.history-case-head-hint::after {
    content: '⌄';
    font-size: 13px;
    line-height: 1;
}

.history-case-shell[open] .history-case-head-hint::before {
    content: '收起';
}

.history-case-shell[open] .history-case-head-hint::after {
    content: '⌃';
}

.history-case-body {
    padding: 0 18px 18px;
}

.history-case-scales {
    display: inline-flex;
    gap: 2px;
    margin-top: 2px;
    padding: 3px;
    border: 1px solid var(--border-color, #e2e6ef);
    border-radius: 7px;
    background: var(--bg-subtle, #f7f8fa);
}

.history-case-scale {
    min-height: 30px;
    padding: 5px 12px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary, #667085);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.history-case-scale:hover {
    color: var(--text-primary, #1f2937);
}

.history-case-scale.is-active {
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1f2937);
    font-weight: 600;
}

.history-case-status {
    margin: 10px 0 0;
    color: var(--text-secondary, #667085);
    font-size: 12.5px;
}

.history-case-status.is-error {
    color: var(--danger, #b42318);
}

.history-case-result:not(:empty) {
    margin-top: 14px;
}

.history-case-overview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    flex-wrap: wrap;
    padding: 10px 0 12px;
    border-top: 1px solid var(--border-color, #e2e6ef);
    border-bottom: 1px solid var(--border-color, #e2e6ef);
}

.history-case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.history-case-meta > div {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.history-case-meta span {
    color: var(--text-tertiary, #98a2b3);
    font-size: 11.5px;
    white-space: nowrap;
}

.history-case-meta strong {
    color: var(--text-primary, #1f2937);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.history-case-scope {
    margin: 0;
    color: var(--text-secondary, #667085);
    font-size: 11.5px;
    white-space: nowrap;
}

.history-case-availability {
    margin: 8px 0 0;
    color: var(--text-tertiary, #98a2b3);
    font-size: 11.5px;
    line-height: 1.5;
}

.history-case-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.history-case-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 13px 14px 14px;
    border: 1px solid var(--border-color, #e2e6ef);
    border-top: 2px solid var(--text-tertiary, #98a2b3);
    border-radius: 7px;
    background: var(--bg-card, #fff);
}

.history-case-card.is-up {
    border-top-color: var(--up, #e0323c);
}

.history-case-card.is-down {
    border-top-color: var(--down, #12a366);
}

.history-case-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 26px;
}

.history-case-card-title {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.history-case-card-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: var(--bg-subtle, #f2f4f7);
    color: var(--text-secondary, #667085);
    font-size: 11px;
    font-weight: 600;
}

.history-case-date {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-primary, #1f2937);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: left;
    cursor: pointer;
}

.history-case-date:not(.is-static):hover {
    color: var(--accent, #1576e8);
    text-decoration: underline;
}

.history-case-date.is-static {
    cursor: default;
}

.history-case-tier {
    overflow: hidden;
    padding: 2px 6px;
    border: 1px solid var(--border-color, #e2e6ef);
    border-radius: 5px;
    color: var(--text-secondary, #667085);
    font-size: 10.5px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-case-comparable {
    flex: none;
    color: var(--text-tertiary, #98a2b3);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.history-case-review {
    margin-top: 11px;
}

.history-case-review-head {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.history-case-review-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary, #667085);
    font-size: 10.5px;
    font-weight: 600;
}

.history-case-review-label::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.history-case-review-label.is-ai {
    color: var(--accent, #1576e8);
}

.history-case-review-headline {
    margin: 0;
    color: var(--text-primary, #1f2937);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.55;
}

.history-case-review-bullets {
    display: grid;
    gap: 4px;
    margin: 7px 0 0;
    padding: 0;
    list-style: none;
}

.history-case-review-bullets li {
    position: relative;
    padding-left: 10px;
    color: var(--text-secondary, #475467);
    font-size: 11.5px;
    line-height: 1.55;
}

.history-case-review-bullets li::before {
    content: '';
    position: absolute;
    top: .62em;
    left: 0;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-tertiary, #98a2b3);
}

.history-case-evidence {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--border-color, #e2e6ef);
}

.history-case-evidence-block {
    min-width: 0;
}

.history-case-evidence-block.is-divergent {
    padding-left: 8px;
    border-left: 1px solid var(--border-color, #e2e6ef);
}

.history-case-evidence-block h5,
.history-case-forward-head h5,
.history-case-counterexample-diff h5 {
    margin: 0 0 6px;
    color: var(--text-secondary, #667085);
    font-size: 10.5px;
    font-weight: 600;
}

.history-case-evidence-list {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.history-case-evidence-list li {
    min-width: 0;
    color: var(--text-primary, #1f2937);
    font-size: 10.5px;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.history-case-evidence-list li > span {
    display: block;
    overflow: hidden;
    margin-bottom: 1px;
    color: var(--text-tertiary, #98a2b3);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-case-evidence-list li > strong {
    font-weight: 500;
}

.history-case-evidence-list li > i {
    margin: 0 4px;
    color: var(--text-tertiary, #98a2b3);
    font-style: normal;
}

.history-case-evidence-list.is-divergent li > strong:last-child {
    color: var(--warning-text, #b54708);
}

.history-case-evidence-empty {
    margin: 0;
    color: var(--text-tertiary, #98a2b3);
    font-size: 10.5px;
    line-height: 1.5;
}

.history-case-forward {
    margin-top: auto;
    padding-top: 12px;
}

.history-case-forward-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.history-case-forward-head span {
    color: var(--text-tertiary, #98a2b3);
    font-size: 9.5px;
}

.history-case-forward-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
}

.history-case-path-chart {
    position: relative;
    min-width: 0;
    height: 84px;
    padding-bottom: 16px;
}

.history-case-path-chart svg {
    display: block;
    width: 100%;
    height: 68px;
    overflow: visible;
}

.history-case-path-zero {
    stroke: var(--border-color, #e2e6ef);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}

.history-case-path-line {
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.history-case-path-dot {
    stroke: var(--bg-card, #fff);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

.history-case-path-chart.is-up .history-case-path-line,
.history-case-path-chart.is-up .history-case-path-dot {
    stroke: var(--up, #e0323c);
    fill: var(--up, #e0323c);
}

.history-case-path-chart.is-down .history-case-path-line,
.history-case-path-chart.is-down .history-case-path-dot {
    stroke: var(--down, #12a366);
    fill: var(--down, #12a366);
}

.history-case-path-chart.is-flat .history-case-path-line,
.history-case-path-chart.is-flat .history-case-path-dot {
    stroke: var(--text-tertiary, #98a2b3);
    fill: var(--text-tertiary, #98a2b3);
}

.history-case-path-start,
.history-case-path-end {
    position: absolute;
    bottom: 0;
    color: var(--text-tertiary, #98a2b3);
    font-size: 9px;
    line-height: 1;
}

.history-case-path-start {
    left: 0;
}

.history-case-path-end {
    right: 0;
}

.history-case-path-empty {
    min-height: 68px;
    display: flex;
    align-items: center;
    color: var(--text-tertiary, #98a2b3);
    font-size: 10.5px;
}

.history-case-forward-stats {
    display: grid;
    gap: 3px;
    min-width: 64px;
    margin: 0;
}

.history-case-forward-stats > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 7px;
}

.history-case-forward-stats dt {
    color: var(--text-tertiary, #98a2b3);
    font-size: 9.5px;
}

.history-case-forward-stats dd {
    margin: 0;
    color: var(--text-primary, #1f2937);
    font-size: 10.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.history-case-forward-stats dd.is-up {
    color: var(--up, #e0323c);
}

.history-case-forward-stats dd.is-down {
    color: var(--down, #12a366);
}

.history-case-counterexample {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #e2e6ef);
}

.history-case-counterexample-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
}

.history-case-counterexample-kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--warning-text, #b54708);
    font-size: 10px;
    font-weight: 600;
}

.history-case-counterexample-head h4 {
    margin: 0;
    color: var(--text-primary, #1f2937);
    font-size: 13px;
}

.history-case-counterexample-note {
    color: var(--text-tertiary, #98a2b3);
    font-size: 10.5px;
}

.history-case-counterexample-card {
    padding: 12px 14px;
    border: 1px solid var(--border-color, #e2e6ef);
    border-left: 2px solid var(--warning-text, #b54708);
    border-radius: 7px;
    background: var(--bg-card, #fff);
}

.history-case-counterexample-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.history-case-counterexample-title > span:not(.history-case-date) {
    color: var(--text-secondary, #667085);
    font-size: 10.5px;
}

.history-case-counterexample-title > b {
    margin-left: auto;
    color: var(--text-primary, #1f2937);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.history-case-counterexample .history-case-review {
    max-width: 900px;
}

.history-case-counterexample-diff {
    margin-top: 10px;
}

.history-case-counterexample-diff .history-case-evidence-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 18px;
}

.history-case-counterexample .history-case-forward {
    max-width: 540px;
}

.history-case-unavailable {
    padding: 14px 16px;
    border: 1px dashed var(--border-color, #e2e6ef);
    border-radius: 7px;
    background: var(--bg-subtle, #f7f8fa);
}

.history-case-unavailable strong {
    display: block;
    color: var(--text-primary, #1f2937);
    font-size: 13px;
}

.history-case-unavailable p {
    margin: 5px 0 0;
    color: var(--text-secondary, #667085);
    font-size: 12px;
    line-height: 1.55;
}

.history-case-unavailable.is-error {
    border-color: var(--danger-border, #fda29b);
}

[data-theme="dark"] .history-case-card,
[data-theme="dark"] .history-case-counterexample-card,
[data-theme="dark"] .history-case-shell {
    background: var(--bg-card, #111827);
}

[data-theme="dark"] .history-case-card-index,
[data-theme="dark"] .history-case-unavailable {
    background: rgba(148, 163, 184, 0.12);
}

[data-theme="dark"] .history-case-evidence-list.is-divergent li > strong:last-child,
[data-theme="dark"] .history-case-counterexample-kicker {
    color: #fbbf24;
}

@media (max-width: 1080px) {
    .history-case-grid {
        grid-template-columns: 1fr;
    }

    .history-case-card {
        padding: 14px 15px;
    }

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

@media (max-width: 640px) {
    .history-case-head {
        padding: 14px;
    }

    .history-case-head p {
        font-size: 12px;
    }

    .history-case-body {
        padding: 0 14px 14px;
    }

    .history-case-scales {
        display: flex;
        width: 100%;
    }

    .history-case-scale {
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 4px;
        white-space: nowrap;
    }

    .history-case-overview {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-case-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 7px 12px;
    }

    .history-case-meta > div {
        justify-content: space-between;
    }

    .history-case-scope {
        white-space: normal;
    }

    .history-case-availability {
        overflow-wrap: anywhere;
    }

    .history-case-card-head {
        align-items: flex-start;
    }

    .history-case-card-title {
        align-items: center;
        width: 100%;
        flex-wrap: wrap;
    }

    .history-case-date {
        flex: none;
        max-width: 100%;
    }

    .history-case-tier {
        min-width: 0;
        max-width: 100%;
    }

    .history-case-counterexample-title > .history-case-date {
        flex: none;
        max-width: 100%;
    }

    .history-case-counterexample-title > span:not(.history-case-date) {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .history-case-counterexample-title > b {
        margin-left: 0;
    }

    .history-case-evidence {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .history-case-evidence-block.is-divergent {
        padding-top: 9px;
        padding-left: 0;
        border-top: 1px solid var(--border-color, #e2e6ef);
        border-left: 0;
    }

    .history-case-forward-body {
        grid-template-columns: minmax(0, 1fr) 62px;
        gap: 6px;
    }

    .history-case-counterexample-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .history-case-counterexample-diff .history-case-evidence-list {
        grid-template-columns: 1fr;
    }
}
