:root {
    --glossary-current: #28a745;
    --glossary-rereview: #ffc107;
    --glossary-missing: #d3d3d3;
}

.progress-header-inner {
    max-width: 1400px;
    margin: 0 auto;
}

header .back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: #fff;
    opacity: 0.9;
    text-decoration: none;
}

header .back-link:hover,
header .back-link:focus-visible {
    opacity: 1;
    text-decoration: underline;
}

.progress-main {
    max-width: 1400px;
}

#loading {
    min-height: 8rem;
}

.corpus-overview,
.book-progress-section {
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 8px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.overview-heading-row,
.ledger-heading-row,
.book-progress-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.progress-kicker {
    margin-bottom: 0.25rem;
    color: #666;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.corpus-overview h2,
.chapter-ledger h2,
.book-progress-title,
.progress-group-heading {
    color: var(--primary-color);
}

.corpus-overview h2,
.chapter-ledger h2 {
    font-size: 1.8rem;
}

.coverage-figure,
.book-progress-percent {
    color: var(--primary-color);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.coverage-figure {
    font-size: 2rem;
}

.coverage-track {
    display: flex;
    width: 100%;
    height: 1.25rem;
    margin-top: 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--glossary-missing);
}

.coverage-segment {
    height: 100%;
    transition: width 0.3s ease;
}

.coverage-segment.current,
.status-swatch.current,
.chapter-progress-square.current {
    background: var(--glossary-current);
}

.coverage-segment.rereview,
.status-swatch.rereview,
.chapter-progress-square.rereview {
    background: var(--glossary-rereview);
}

.status-swatch.missing,
.chapter-progress-square.missing {
    background: var(--glossary-missing);
}

.coverage-key,
.book-progress-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 2rem;
    margin-top: 1rem;
    color: #555;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.86rem;
}

.coverage-key span,
.book-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.status-swatch {
    display: inline-block;
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    border-radius: 2px;
}

.corpus-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.corpus-metric {
    display: flex;
    min-height: 6rem;
    padding: 0.85rem 1rem;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: rgba(248, 249, 250, 0.65);
}

.corpus-metric-label {
    color: #666;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.corpus-metric-value {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 700;
}

.corpus-metric-note,
.publication-note,
.ledger-note,
.books-loading-status {
    color: #666;
    font-size: 0.84rem;
}

.publication-note {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.chapter-ledger {
    margin-top: 3rem;
}

.ledger-heading-row {
    margin-bottom: 1.5rem;
}

.books-loading-status {
    min-height: 1.5rem;
    text-align: center;
}

.progress-group-heading {
    margin: 2.5rem 0 1rem;
    font-size: 2rem;
}

.book-progress-title {
    margin: 0;
    font-size: 1.65rem;
}

.book-subtitle {
    margin-top: 0.2rem;
    color: #666;
    font-size: 0.95rem;
}

.book-progress-percent {
    font-size: 1.35rem;
}

.chapter-progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20px, 1fr));
    gap: 2px;
    max-width: 100%;
    margin-top: 1.25rem;
}

.chapter-progress-square {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 2px;
    transition: transform 0.2s ease;
}

.chapter-progress-square:hover,
.chapter-progress-square:focus-visible {
    z-index: 10;
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    transform: scale(1.18);
}

.chapter-progress-square::after {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    z-index: 100;
    display: none;
    min-width: 18rem;
    max-width: min(26rem, 90vw);
    padding: 0.55rem 0.65rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.84);
    color: #fff;
    content: attr(data-tooltip);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.76rem;
    line-height: 1.4;
    pointer-events: none;
    text-align: left;
    white-space: pre-line;
    transform: translateX(-50%);
}

.chapter-progress-square:hover::after,
.chapter-progress-square:focus-visible::after {
    display: block;
}

.last-updated {
    margin: 2rem 0;
    color: #666;
    font-size: 0.9rem;
    text-align: center;
}

@media (max-width: 768px) {
    .progress-main {
        padding: 1.5rem 1rem;
    }

    .corpus-overview,
    .book-progress-section {
        padding: 1rem;
    }

    .chapter-progress-grid {
        grid-template-columns: repeat(auto-fit, minmax(12px, 1fr));
        gap: 1px;
    }

    .chapter-progress-square::after {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .coverage-segment,
    .chapter-progress-square {
        transition: none;
    }
}
