.ai-header {
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
    padding: clamp(0.8rem, 1.9vw, 1.25rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--surface-strong) 92%, transparent), color-mix(in srgb, var(--surface-muted) 88%, transparent)),
        radial-gradient(circle at top right, var(--bg-accent), transparent 30%);
    box-shadow: var(--shadow);
}

.ai-header::after {
    content: "";
    position: absolute;
    inset: auto -8% -32% auto;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    background: var(--bg-accent);
    filter: blur(10px);
    opacity: 0.7;
}

.ai-title {
    position: relative;
    z-index: 1;
    max-width: 22ch;
    margin: 0 0 0.25rem;
    font-size: clamp(1.35rem, 2.55vw, 2rem);
    line-height: 1.02;
    letter-spacing: -0.06em;
}

.ai-subtitle {
    position: relative;
    z-index: 1;
    max-width: 38rem;
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(0.82rem, 0.96vw, 0.94rem);
}

.search-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    margin: 0 auto 2rem;
}

.search-container,
.date-filter-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
}

.search-container {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    padding: 0.8rem;
    flex-wrap: wrap;
}

.search-select,
.search-input {
    min-height: 3.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text);
    padding: 0 1rem;
}

.search-select {
    min-width: 8.5rem;
}

.search-input {
    flex: 1 1 18rem;
}

.search-select:focus,
.search-input:focus {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: 0 0 0 4px var(--focus);
}

.search-button,
.ai-summary-link,
.paper-link,
.tab-button.active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 3.35rem;
    padding: 0 1.35rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.search-button:hover,
.ai-summary-link:hover,
.paper-link:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.topic-tabs,
.period-tabs,
.tabs-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 1.7rem;
}

.tabs-container {
    margin-bottom: 2rem;
}

.topic-tab,
.period-tab,
.tab-button {
    min-height: 3rem;
    padding: 0 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.topic-tab.active,
.period-tab.active,
.tab-button.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: transparent;
}

.topic-tab:hover,
.period-tab:hover,
.tab-button:hover,
.topic-tab:focus-visible,
.period-tab:focus-visible,
.tab-button:focus-visible {
    color: var(--text);
    transform: translateY(-1px);
    outline: none;
    border-color: var(--border-strong);
}

.content-grid {
    display: grid;
    gap: 2rem;
}

.category-section,
.period-section {
    padding: 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.category-title,
.period-title {
    margin: 0 0 1.2rem;
    font-size: clamp(1.2rem, 2.2vw, 1.6rem);
    letter-spacing: -0.03em;
}

.cards-container,
.repos-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius-md) + 2px);
    background: var(--surface-strong);
    box-shadow: var(--shadow-soft);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.card-preview {
    min-height: 5.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--surface-strong)), color-mix(in srgb, var(--bg) 80%, var(--surface-strong)));
}

.card-preview-placeholder,
.paper-preview-placeholder {
    font-size: 2.15rem;
    color: var(--text);
    opacity: 0.9;
}

.card-content,
.paper-content,
.repo-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 1.2rem;
}

.card-header,
.paper-header,
.repo-header,
.card-meta,
.paper-meta,
.repo-meta,
.card-footer,
.paper-footer,
.repo-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.card-header,
.paper-header,
.repo-header {
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title,
.paper-title,
.repo-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.card-title a,
.paper-title a,
.repo-title a {
    color: var(--text);
    text-decoration: none;
}

.card-title a:hover,
.paper-title a:hover,
.repo-title a:hover {
    color: var(--text-muted);
}

.card-votes,
.card-stars,
.paper-votes,
.repo-votes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 3rem;
}

.vote-count,
.star-count {
    font-size: 1.05rem;
    font-weight: 700;
}

.vote-icon,
.star-icon {
    color: var(--text-soft);
    font-size: 0.85rem;
}

.card-meta,
.paper-meta,
.repo-meta {
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.authors-info,
.repo-info,
.author-details,
.paper-stats,
.repo-stats,
.card-links,
.paper-links,
.card-badges,
.repo-topics,
.card-actions,
.paper-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.author-avatars,
.owner-avatar {
    display: flex;
}

.author-avatar,
.author-more,
.owner-avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin-left: -0.35rem;
    border-radius: 50%;
    border: 2px solid var(--surface-strong);
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.68rem;
    font-weight: 600;
}

.author-avatar:first-child,
.owner-avatar-circle:first-child {
    margin-left: 0;
}

.card-links {
    justify-content: flex-end;
}

.link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    text-decoration: none;
    background: var(--surface);
}

.link-icon:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.card-description,
.paper-abstract {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    flex: 1;
}

.card-footer,
.paper-footer,
.repo-footer {
    align-items: center;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.card-actions.actions-centered {
    width: 100%;
    justify-content: center;
}

.card-likes {
    display: flex;
    align-items: center;
}

.like-button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.6rem;
    padding: 0 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.engagement-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.6rem;
    padding: 0 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    box-shadow: var(--shadow-soft);
}

.like-button:hover,
.like-button.liked {
    color: var(--text);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.like-button i {
    font-size: 1rem;
}

.engagement-pill i {
    font-size: 1rem;
}

.like-count,
.card-info,
.authors-text,
.repo-text,
.paper-popularity,
.paper-downvotes,
.paper-likes,
.submitted-by,
.submitter-name,
.author-name,
.repo-name,
.stat-item {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.submitter-name,
.author-name {
    color: var(--text);
    font-weight: 600;
}

.badge,
.repo-source,
.topic-tag,
.topic-more,
.language-badge,
.date-badge,
.tag-badge,
.forks-badge,
.trend-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.95rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
}

.language-badge,
.repo-source,
.trend-badge {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: transparent;
}

.paper-link {
    min-height: 2.2rem;
    padding: 0 0.85rem;
}

.loading-spinner,
.error-message,
.loading-state,
.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    padding: 2rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-muted);
    text-align: center;
}

.error-message,
.error-state {
    color: var(--danger-text);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.date-filter-container {
    min-width: min(100%, 320px);
}

.date-filter-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: transparent;
    color: var(--text);
    border: 0;
    cursor: pointer;
}

.date-filter-title {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
}

.date-filter-title i,
.date-filter-toggle i {
    color: var(--text-soft);
}

.date-filter-content {
    display: none;
    padding: 0 1.15rem 1.15rem;
    border-top: 1px solid var(--border);
}

.date-presets,
.date-range-section {
    padding-top: 1rem;
}

.preset-header,
.date-range-header {
    margin-bottom: 0.7rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.preset-buttons {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.preset-btn {
    min-height: 2.4rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.preset-btn:hover,
.preset-btn.active {
    color: var(--text);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.preset-btn.active {
    background: var(--surface-strong);
}

.date-inputs-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.75rem;
    align-items: end;
}

.date-input-group {
    display: grid;
    gap: 0.45rem;
}

.date-input-group label {
    margin: 0;
}

.date-input,
.date-filter-content .date-input {
    min-height: 2.85rem;
}

.date-separator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.85rem;
    color: var(--text-soft);
}

.date-actions {
    display: flex;
    gap: 0.7rem;
    margin-top: 1rem;
}

.date-btn {
    flex: 1;
    min-height: 2.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.date-btn.apply-btn {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: transparent;
}

.date-btn.clear-btn {
    color: var(--text-muted);
}

.current-filter-display {
    margin-top: 1rem;
}

.current-filter-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--text-muted);
}

.remove-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.date-filter-content label {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.date-filter-content input,
.date-filter-content select,
.date-filter-content button {
    width: 100%;
    margin-bottom: 0.9rem;
}

.date-filter-content input,
.date-filter-content select {
    min-height: 2.85rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--text);
}

.date-filter-content button {
    min-height: 2.85rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    cursor: pointer;
}

#result-count {
    margin: -0.5rem 0 1rem;
    color: var(--text-muted);
    font-family: "IBM Plex Mono", monospace;
}

.summary-content .inline-figure {
    display: grid !important;
    justify-items: center;
    width: min(100%, 54rem) !important;
    margin: 1.5rem auto !important;
}

.summary-content .inline-figure img {
    display: block;
    width: auto !important;
    max-width: 100% !important;
    max-height: min(72vh, 42rem) !important;
    margin: 0 auto;
    object-fit: contain;
}

.summary-content .inline-figure figcaption {
    width: 100%;
}

.paper-social-card {
    width: min(100%, 72rem);
    margin: 0 auto;
    padding: 1.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.paper-social-card[hidden] {
    display: none !important;
}

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

.paper-social-title {
    margin: 0;
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    letter-spacing: -0.03em;
}

.paper-social-copy {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.paper-social-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
    padding: 0 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text-muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.paper-social-embed {
    width: 100%;
    max-width: 34rem;
    margin: 0 auto;
    min-height: 3rem;
}

.paper-social-actions {
    margin-top: 0.9rem;
    display: flex;
    justify-content: center;
}

.paper-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 2.6rem;
    padding: 0 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.paper-social-link:hover,
.paper-social-link:focus-visible {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    opacity: 0.96;
    outline: none;
}

.paper-social-fallback {
    margin: 0;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 960px) {
    .search-section {
        grid-template-columns: 1fr;
    }

    .cards-container,
    .repos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .ai-header {
        padding: 0.95rem 0.9rem;
        text-align: center;
    }

    .ai-header::after {
        width: 9rem;
        height: 9rem;
        inset: auto -8% -28% auto;
    }

    .ai-title {
        max-width: none;
        margin-bottom: 0.3rem;
        font-size: clamp(1.3rem, 6vw, 1.85rem);
    }

    .ai-subtitle {
        max-width: none;
        margin: 0 auto;
        font-size: 0.84rem;
    }

    .search-container {
        padding: 0.7rem;
    }

    .search-select,
    .search-input,
    .search-button {
        width: 100%;
    }

    .date-inputs-container,
    .date-actions {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .date-separator {
        min-height: auto;
        justify-content: flex-start;
        padding-left: 0.25rem;
        transform: rotate(90deg);
    }

    .cards-container,
    .repos-grid {
        grid-template-columns: 1fr;
    }

    .card-header,
    .paper-header,
    .repo-header,
    .card-meta,
    .paper-meta,
    .repo-meta,
    .card-footer,
    .paper-footer,
    .repo-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .summary-content .inline-figure img {
        max-height: 50vh !important;
    }

    .paper-social-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .paper-social-meta {
        white-space: normal;
    }

    .paper-social-embed {
        max-width: 100%;
    }
}
