.tweet-compare {
    --tweet-compare-surface: #ffffff;
    --tweet-compare-text: #111827;
    --tweet-compare-muted: #526070;
    --tweet-compare-border: rgba(15, 23, 42, 0.12);
    --tweet-compare-soft: #f8fafc;
    --tweet-compare-focus: rgba(13, 110, 253, 0.32);
    padding-bottom: 3rem;
}

.tweet-compare__header {
    max-width: 900px;
}

.tweet-compare__jump-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin: -0.25rem 0 1.25rem;
}

.tweet-compare__jump-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--tweet-compare-border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--tweet-compare-text);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
}

.tweet-compare__jump-link:hover {
    background: var(--tweet-compare-soft);
    color: var(--tweet-compare-text);
}

.tweet-compare__jump-link:focus-visible,
.tweet-compare__candidate-button:focus-visible,
.tweet-compare__selected-remove:focus-visible,
.tweet-compare .btn:focus-visible,
.tweet-compare .form-control:focus-visible {
    outline: 3px solid var(--tweet-compare-focus);
    outline-offset: 2px;
    box-shadow: none;
}

.tweet-compare__section {
    border-radius: 1rem;
    background: var(--tweet-compare-surface);
}

.tweet-compare__section .card-body {
    padding: 1.5rem;
}

.tweet-compare__section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tweet-compare__section-title {
    margin: 0 0 0.4rem;
    color: var(--tweet-compare-text);
    font-size: clamp(1.15rem, 0.7vw + 1rem, 1.45rem);
    font-weight: 700;
}

.tweet-compare__section-note,
.tweet-compare__status {
    color: var(--tweet-compare-muted);
    font-size: 0.94rem;
    line-height: 1.7;
}

.tweet-compare__count-pill,
.tweet-compare__chart-summary {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tweet-compare__filters,
.tweet-compare__settings-grid {
    display: grid;
    gap: 1.25rem;
}

.tweet-compare__filters {
    grid-template-columns: minmax(220px, 1.1fr) minmax(220px, 1fr);
    align-items: start;
    margin-bottom: 1.25rem;
}

.tweet-compare__search-field {
    grid-row: span 2;
}

.tweet-compare__search-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

.tweet-compare__search-clear {
    min-height: 2.5rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--tweet-compare-border);
    border-radius: 999px;
    background: #ffffff;
    color: #0d6efd;
    font-size: 0.85rem;
    font-weight: 700;
}

.tweet-compare__search-clear:hover {
    background: #eff6ff;
}

.tweet-compare__search-help,
.tweet-compare__unit-hint {
    margin-top: 0.5rem;
    color: var(--tweet-compare-muted);
    font-size: 0.86rem;
    line-height: 1.6;
}

.tweet-compare__control-title {
    margin: 0 0 0.65rem;
    color: var(--tweet-compare-text);
    font-size: 0.98rem;
    font-weight: 700;
}

.tweet-compare__button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
}

.tweet-compare__button-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.tweet-compare .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.85rem;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tweet-compare .btn:hover,
.tweet-compare__candidate-button:hover {
    transform: translateY(-1px);
}

.tweet-compare__candidate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.65rem;
}

.tweet-compare__candidate-summary {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--tweet-compare-border);
    border-radius: 0.85rem;
    background: var(--tweet-compare-soft);
    color: var(--tweet-compare-text);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.5;
}

.tweet-compare__candidate-summary[hidden],
.tweet-compare-floating-cta[hidden] {
    display: none;
}

.tweet-compare__candidate-footer {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.tweet-compare__candidate-button {
    display: grid;
    gap: 0.25rem;
    min-height: 72px;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid rgba(13, 110, 253, 0.22);
    border-radius: 0.85rem;
    background: #ffffff;
    color: var(--tweet-compare-text);
    text-align: left;
    cursor: pointer;
    overflow-wrap: anywhere;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tweet-compare__candidate-button.is-selected,
.tweet-compare__candidate-button[aria-pressed="true"] {
    border-color: #0d6efd;
    background: #eff6ff;
}

.tweet-compare__candidate-name {
    font-weight: 800;
    line-height: 1.35;
}

.tweet-compare__candidate-meta {
    color: var(--tweet-compare-muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.tweet-compare__empty-state {
    padding: 1rem;
    border: 1px solid var(--tweet-compare-border);
    border-radius: 0.85rem;
    background: var(--tweet-compare-soft);
    color: var(--tweet-compare-text);
}

.tweet-compare__selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.tweet-compare__selected-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 44px;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.85rem;
    border: 1px solid rgba(25, 135, 84, 0.35);
    border-radius: 999px;
    background: #f0fdf4;
    color: #14532d;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.tweet-compare__selected-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(20, 83, 45, 0.1);
    color: #14532d;
    font-weight: 800;
}

.tweet-compare__action-block {
    display: grid;
    align-content: end;
    gap: 0.65rem;
}

.tweet-compare__chart-wrap {
    position: relative;
    min-height: 420px;
}

.tweet-compare__chart-wrap canvas {
    width: 100%;
    min-height: 420px;
}

.tweet-compare__summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.tweet-compare__summary-card {
    display: grid;
    gap: 0.35rem;
    padding: 1rem;
    border: 1px solid var(--tweet-compare-border);
    border-radius: 0.85rem;
    background: #ffffff;
}

.tweet-compare__summary-keyword {
    margin: 0;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.tweet-compare__summary-number {
    margin: 0;
    color: var(--tweet-compare-text);
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.tweet-compare__summary-meta {
    margin: 0;
    color: var(--tweet-compare-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.tweet-compare-floating-cta {
    position: sticky;
    bottom: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 1rem auto;
    padding: 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(10px);
}

.tweet-compare-floating-cta__count,
.tweet-compare-floating-cta__link,
.tweet-compare-floating-cta__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.3;
    white-space: nowrap;
}

.tweet-compare-floating-cta__count {
    padding: 0.35rem 0.75rem;
    background: #eff6ff;
    color: #1d4ed8;
    font-variant-numeric: tabular-nums;
}

.tweet-compare-floating-cta__link {
    padding: 0.35rem 0.75rem;
    color: var(--tweet-compare-text);
    text-decoration: none;
}

.tweet-compare-floating-cta__link:hover {
    background: var(--tweet-compare-soft);
    color: var(--tweet-compare-text);
}

.tweet-compare-floating-cta__button {
    padding: 0.35rem 0.95rem;
    border: 0;
    background: #0d6efd;
    color: #ffffff;
}

.tweet-compare-floating-cta__button:focus-visible,
.tweet-compare__search-clear:focus-visible {
    outline: 3px solid var(--tweet-compare-focus);
    outline-offset: 2px;
}

@media (min-width: 992px) {
    .tweet-compare__settings-grid {
        grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr) minmax(220px, 0.6fr);
        align-items: start;
    }
}

@media (max-width: 767.98px) {
    .tweet-compare__section .card-body {
        padding: 1.1rem;
    }

    .tweet-compare__section-header,
    .tweet-compare__filters {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .tweet-compare__search-field {
        grid-row: auto;
    }

    .tweet-compare__count-pill,
    .tweet-compare__chart-summary,
    .tweet-compare__section-header .btn {
        width: 100%;
        justify-content: center;
    }

    .tweet-compare__candidate-grid {
        grid-template-columns: 1fr;
    }

    .tweet-compare__chart-wrap,
    .tweet-compare__chart-wrap canvas {
        min-height: 340px;
    }

    .tweet-compare-floating-cta {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        width: auto;
        margin-left: 0;
        border-radius: 1rem;
    }

    .tweet-compare-floating-cta__count {
        flex: 1 1 auto;
    }
}

@media (max-width: 420px) {
    .tweet-compare__search-control {
        grid-template-columns: 1fr;
    }

    .tweet-compare__search-clear,
    .tweet-compare-floating-cta__link,
    .tweet-compare-floating-cta__button {
        width: 100%;
    }

    .tweet-compare-floating-cta {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .tweet-compare-floating-cta__count {
        grid-column: 1 / -1;
    }
}
