:root {
    /* Refreshed academic palette (single theme, no switcher) */
    --bg: #eceef3;
    --surface: #f5f6f9;
    --border: #e6e8ec;
    --text: #16182b;
    --muted: #6b7280;
    --accent: #3538cd;
    --accent-soft: #ececfb;
    --pos: #1d8a4e;
    --neg: #c2410c;
    --top-row: #f4f4ff;

    /* Fonts (loaded in base.html) */
    --font-head: 'IBM Plex Sans', sans-serif;
    --font-num: 'IBM Plex Mono', monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-head);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.narrow {
    margin: 0 auto;
}

/* ── Header ── */

.site-header {
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
}

.site-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-title {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.site-tagline {
    margin: 8px 0 0;
    font-size: 15px;
    color: var(--muted);
    line-height: 1.45;
}

.top-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.top-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
}

.top-nav a:hover {
    color: var(--text);
    background: var(--surface);
}

.top-nav a.nav-active {
    color: #fff;
    background: var(--accent);
    font-weight: 600;
}

/* ── Hero ── */

.hero {
    padding: 36px 0 20px;
}

.hero + .section {
    padding-top: 4px;
}

.hero h2 {
    margin: 0 0 8px;
}

.hero-copy {
    color: var(--muted);
    margin: 0;
}

.hero-copy a {
    color: var(--accent);
}

/* ── Sections ── */

.section {
    padding: 28px 0 40px;
}

.muted-section {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.section-heading {
    margin-bottom: 16px;
}

.section-heading h3 {
    margin: 0;
}

.section-heading p {
    color: var(--muted);
    margin: 6px 0 0;
}

/* ── Intro block above leaderboard ── */

.intro-block {
    margin-bottom: 24px;
}

.intro-block p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 15px;
}

.intro-block p:last-child {
    margin-bottom: 0;
}

.intro-block a {
    color: var(--accent);
}

/* ── Table ── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: middle;
    text-align: left;
    font-size: 14px;
}

.leaderboard-table thead th {
    background: #fafafa;
    font-weight: 600;
    vertical-align: middle;
}

.leaderboard-table tr:last-child th,
.leaderboard-table tr:last-child td {
    border-bottom: none;
}

.leaderboard-table th:last-child,
.leaderboard-table td:last-child {
    border-right: none;
}

/* Name column — wider so badge fits */
.col-name {
    min-width: 240px;
}

/* Rewriters page: plain td instead of th */
.row-name {
    min-width: 240px;
    max-width: 320px;
    font-weight: 500;
}

.cost-cell {
    font-family: var(--font-num);
    font-size: 13px;
    white-space: nowrap;
    color: var(--text);
}

.type-cell {
    white-space: nowrap;
    color: var(--muted);
    font-size: 13px;
}

.desc-cell {
    max-width: 380px;
    color: var(--muted);
    font-size: 13px;
}

.col-desc {
    min-width: 200px;
}

/* ── Badges ── */

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1.6;
}

.badge-paper {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.badge-community {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* ── Weight row ── */

.weight-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-align: right;
}

/* hide spin buttons so the number sits truly centred */
.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.weight-input { -moz-appearance: textfield; appearance: textfield; }

.weight-input {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

/* ── Buttons ── */

.btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
}

.btn:hover {
    opacity: 0.85;
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--surface);
    opacity: 1;
}

.btn-copy {
    font-size: 12px;
    padding: 5px 14px;
}

/* ── Flash messages ── */

.flash-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}

.flash {
    width: min(760px, calc(100% - 32px));
    margin: 0 auto;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
}

.flash-success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.flash-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* ── Code blocks ── */

.code-example {
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-num);
    border-radius: 6px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    margin: 12px 0 20px;
}

/* ── Paper & BibTeX section ── */

/* ── Paper & Code ── */

.paper { margin-top: 16px; padding-bottom: 40px; }

.paper h3 {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.paper-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.paper-links a {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, color .15s;
}

.paper-links a:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.bibtex {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.bibtex-label {
    padding: 13px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.bibtex-body { padding: 0 18px 16px; }

.bibtex-body pre {
    margin: 0;
    padding: 16px;
    border-radius: 9px;
    background: var(--surface);
    font-family: var(--font-num);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
    overflow-x: auto;
    white-space: pre;
}

.bibtex-body .btn { margin-top: 10px; }

/* ── Info list (submit page) ── */

.info-list {
    margin: 0 0 24px;
    padding-left: 20px;
}

.info-list li {
    margin-bottom: 10px;
    font-size: 15px;
}

.info-list a, .note-list a {
    color: var(--accent);
}

/* inline code: monospace, accent-colored, subtle chip background */
code {
    font-family: var(--font-num);
    font-size: 0.92em;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 4px;
    padding: 1px 5px;
}

/* override chip style inside pre blocks so code examples aren't affected */
pre code {
    color: inherit;
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 1em;
}

/* note list with * prefix instead of default bullet */
.note-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

.note-list li {
    padding-left: 18px;
    margin-bottom: 8px;
    font-size: 15px;
    position: relative;
}

.note-list li::before {
    content: '*';
    position: absolute;
    left: 0;
    color: var(--muted);
    font-weight: 600;
}

/* ── Rewriters table ── */

.rewriters-table {
    min-width: 760px;
}

/* ── Prompt expand (Additional info) ── */

.prompt-details {
    margin-top: 8px;
}

.prompt-details summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    user-select: none;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.prompt-details summary::before {
    content: '▶';
    font-size: 9px;
    transition: transform 0.15s;
    display: inline-block;
}

.prompt-details[open] summary::before {
    transform: rotate(90deg);
}

.prompt-details summary:hover {
    text-decoration: underline;
}

.prompt-inner {
    margin-top: 8px;
}

.prompt-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    font-family: var(--font-num);
    font-size: 12px;
    line-height: 1.55;
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 180px;
    margin: 0 0 6px;
}

.btn-copy-prompt {
    font-size: 12px;
    padding: 4px 12px;
}

/* ── Leaderboard grid (sortable, rank badges) ──
   Index-page rows render as a CSS grid instead of a <table> so the sort/
   weight JS can reorder whole row elements without rebuilding any HTML. */

.lb-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.lb-cardhead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.lb-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lb-accentbar {
    width: 6px;
    height: 24px;
    border-radius: 4px;
    background: var(--accent);
    display: inline-block;
}

.lb-title h2 {
    margin: 0;
    font-size: 19px;
}

.lb-title p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.lb-tools {
    display: flex;
    gap: 8px;
}

.lb-scroll {
    overflow-x: auto;
}

.lb-grid-wrap {
    min-width: 960px;
    padding: 0 10px;
}

.lb-grid {
    display: grid;
    grid-template-columns: 48px minmax(200px, 2.2fr) 88px repeat(5, minmax(86px, 1fr)) 120px;
    align-items: center;
}

.lb-head {
    align-items: end;
    padding: 14px 10px 10px;
    border-bottom: 2px solid var(--text);
}

.lb-head .col-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--muted);
    text-transform: uppercase;
}

.sort-btn {
    appearance: none;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-head);
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    padding: 0;
    width: 100%;
    color: var(--muted);
}

.sort-btn.is-active {
    color: var(--accent);
}

.lb-weight {
    padding: 8px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.lb-weight .weight-cell {
    display: flex;
    justify-content: flex-end;
}

.lb-row {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

.lb-row.is-top {
    background: var(--top-row);
}

.lb-rank {
    display: flex;
    align-items: center;
}

.rank-badge {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-num);
    font-weight: 700;
    font-size: 13px;
}

.rank-badge.r-medal {
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}

.rank-badge.r-first {
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
}

.rank-badge.r-plain {
    color: var(--muted);
    font-weight: 600;
}

.lb-name {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding-right: 14px;
}

.lb-name .name-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.lb-badge {
    flex: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
}

.lb-badge.is-community {
    background: #f0fdf4;
    color: var(--pos);
}

.lb-cost {
    display: flex;
    justify-content: flex-end;
    font-family: var(--font-num);
    font-size: 14px;
    color: var(--muted);
}

.lb-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding-right: 4px;
}

.cell-num {
    font-family: var(--font-num);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.cell-num.is-neg {
    color: var(--neg);
}

.cell-se {
    font-family: var(--font-num);
    font-size: 10.5px;
    color: var(--muted);
}

.lb-avg {
    display: flex;
    justify-content: flex-end;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.avg-num {
    font-family: var(--font-num);
    font-size: 14px;
    font-weight: 600; /* matches .cell-num */
    color: var(--accent);
}

.avg-num.is-neg {
    color: var(--neg);
}

.lb-legend {
    padding: 11px 20px;
    font-size: 11.5px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ── Responsive ── */

@media (max-width: 720px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero {
        padding-top: 24px;
    }

    .paper-links {
        flex-direction: column;
    }
}
