.trend-chart-frame {
    position: relative;
    margin-top: .4rem;
}

.trend-chart-scroll-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.trend-chart-scroll {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
}

.trend-axis-overlay {
    position: absolute;
    top: 0;
    z-index: 2;
    width: 55px;
    height: 230px;
    color: #586b7e;
    font-size: 11px;
    line-height: 1;
    pointer-events: none;
}

.trend-axis-overlay span {
    position: absolute;
    white-space: nowrap;
    transform: translateY(-50%);
}

.trend-axis-overlay .trend-axis-top { top: 28px; }
.trend-axis-overlay .trend-axis-mid { top: 124px; }
.trend-axis-overlay .trend-axis-bottom { top: 220px; }

.trend-score-overlay {
    left: 0;
    text-align: right;
    background: linear-gradient(90deg, #fff 78%, rgba(255, 255, 255, 0));
}

.trend-score-overlay span { right: 10px; }

.trend-time-overlay {
    right: 0;
    width: 75px;
    background: linear-gradient(270deg, #fff 78%, rgba(255, 255, 255, 0));
}

.trend-time-overlay span { left: 10px; }

/* Viewport labels remain visible while the intrinsic SVG scrolls. The
   SVG groups stay in the markup for its stable chart structure and fallback. */
.trend-chart-scroll .activity-trend-chart > .trend-score-axis,
.trend-chart-scroll .activity-trend-chart > .trend-time-axis {
    visibility: hidden;
}

.trend-chart-scroll:focus-visible {
    outline: 3px solid rgba(28, 91, 255, .3);
    outline-offset: 3px;
}

.trend-chart-scroll .activity-trend-chart {
    display: block;
    width: auto;
    max-width: none;
    min-width: 100%;
    height: 296px;
    min-height: 0;
    margin: 0;
}

.trend-date-axis text {
    fill: #586b7e;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.trend-stat-grid span, .trend-stat-grid small,
.trend-subject-breakdown dt, .trend-subject-breakdown dd small,
.trend-subject-breakdown header span, .trend-legend .trend-series-key { color: #586b7e; }
.trend-legend .series-2, .trend-certification-series.series-2 { color: #b44b27; }
.trend-legend .series-5, .trend-certification-series.series-5 { color: #916207; }

.trend-month-axis path {
    fill: none;
    stroke: #cbd3e1;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.trend-month-axis text {
    fill: #56647a;
    font-size: 11px;
    font-weight: 650;
}

.trend-data-disclosure { margin-top: .8rem; border-top: 1px solid var(--border-subtle, #d8dee8); }
.trend-data-disclosure > summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; color: var(--text-primary, #172033); font-size: .82rem; font-weight: 750; }
.trend-data-disclosure > summary small { color: var(--text-muted, #596579); font-size: .72rem; font-weight: 650; }
.trend-data-table { overflow-x: auto; overscroll-behavior-inline: contain; }
.trend-data-table:focus-visible { outline: 3px solid rgba(28, 91, 255, .3); outline-offset: -3px; }
.trend-data-table table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: .78rem; }
.trend-data-table th, .trend-data-table td { padding: .65rem .7rem; border-top: 1px solid var(--border-subtle, #d8dee8); text-align: left; white-space: nowrap; }
.trend-data-table thead th { color: var(--text-secondary, #475569); font-size: .7rem; text-transform: uppercase; }

@media (max-width: 640px) {
    .trend-chart-card {
        width: 100vw;
        margin-inline: calc(50% - 50vw);
        padding: 1rem 0 .85rem;
        border-inline: 0;
        border-radius: 0;
        box-sizing: border-box;
    }
    .trend-legend {
        justify-content: flex-start;
        gap: .55rem .8rem;
        padding-inline: .25rem;
        font-size: .78rem;
        line-height: 1.35;
    }
    .trend-subject-breakdown, .trend-data-disclosure { margin-inline: .5rem; }
    .trend-legend .trend-series-key { justify-content: flex-start; }
    .trend-axis-overlay { width: 44px; font-size: 11px; }
    .trend-score-overlay span { right: 6px; }
    .trend-time-overlay { width: 58px; }
    .trend-time-overlay span { left: 6px; }
    .trend-chart-scroll {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .trend-date-axis text { font-size: 11px; }
    .trend-chart-scroll-hint {
        display: block;
        position: static;
        width: auto;
        height: auto;
        margin: .45rem .25rem 0;
        padding: 0;
        overflow: visible;
        clip: auto;
        white-space: normal;
        color: var(--text-muted, #596579);
        font-size: .75rem;
        line-height: 1.4;
    }
}
