:root {
    --bg: #0f172a;
    --surface: rgba(15, 23, 42, 0.6);
    --card: #111d34;
    --card-border: rgba(255, 255, 255, 0.1);
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --success: #4ade80;
    --warning: #facc15;
    --danger: #f87171;
    --radius: 18px;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    margin: 0;
    padding: 1.5rem;
    min-height: 100vh;
    background: linear-gradient(135deg, #0a1024 0%, #14213d 100%);
    color: var(--text);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 20px 30px, rgba(148, 163, 184, 0.35), transparent),
        radial-gradient(1px 1px at 150px 120px, rgba(56, 189, 248, 0.3), transparent),
        radial-gradient(2px 2px at 90px 200px, rgba(99, 102, 241, 0.25), transparent);
    background-size: 180px 180px, 220px 220px, 260px 260px;
    opacity: 0.35;
    pointer-events: none;
    z-index: -1;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.08), transparent 55%),
        radial-gradient(circle at 85% 30%, rgba(99, 102, 241, 0.08), transparent 55%);
    opacity: 0.8;
    pointer-events: none;
    z-index: -2;
}

.app-shell {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 25px 45px rgba(10, 23, 46, 0.3);
}

.header-content {
    flex: 1 1 320px;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.header-eyebrow {
    display: inline-block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(148, 163, 184, 0.7);
}

.header-content h1 {
    margin: 0;
    font-size: 2.35rem;
    line-height: 1.2;
}

.tagline {
    margin: 0;
    color: rgba(148, 163, 184, 0.85);
    max-width: 640px;
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.meta-chip {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.12);
    display: flex;
    gap: 0.35rem;
    align-items: baseline;
}

.meta-chip__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(148, 163, 184, 0.65);
}

.meta-chip__value {
    font-weight: 600;
    color: var(--text);
}

.header-visual {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orbit {
    position: relative;
    width: 220px;
    height: 220px;
}

.orbit__planet {
    position: absolute;
    inset: 50%;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #38bdf8, #3b82f6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.orbit__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px dashed rgba(56, 189, 248, 0.35);
}

.orbit__ring--one {
    transform: rotate(12deg);
}

.orbit__ring--two {
    transform: scale(0.65) rotate(-18deg);
}

.header-actions .cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    border-radius: calc(var(--radius) / 1.5);
    background: rgba(148, 163, 184, 0.1);
    color: var(--text);
    text-decoration: none;
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: 0.25s ease;
}

.header-actions .cta:hover {
    background: rgba(148, 163, 184, 0.25);
}

.info-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.4rem;
}

.info-card {
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--radius);
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.info-card__eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(148, 163, 184, 0.65);
}

.info-card__title {
    margin: 0;
    font-size: 1.2rem;
}

.info-card__copy {
    margin: 0;
    color: rgba(148, 163, 184, 0.85);
    line-height: 1.6;
}

.info-card__link {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.info-card__link:hover {
    text-decoration: underline;
}

.card {
    background: rgba(17, 29, 52, 0.95);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 25px 45px rgba(8, 47, 73, 0.35);
}

.filters-card h2,
.results h2,
.detail-panel h2 {
    margin-top: 0;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.filter-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.filter-column {
    flex: 1 1 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-inline {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filters-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.filters-card__eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(148, 163, 184, 0.65);
}

.filters-card__header h2 {
    margin: 0.25rem 0;
}

.filters-card__description {
    margin: 0;
    color: rgba(148, 163, 184, 0.8);
}

.filters-card__icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

label {
    font-weight: 600;
    font-size: 0.95rem;
}

input[type="search"],
select {
    padding: 0.65rem 0.75rem;
    border-radius: calc(var(--radius) / 2);
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

input[type="search"]::placeholder {
    color: rgba(226, 232, 240, 0.5);
}

input[type="search"]:focus,
select:focus,
input[type="range"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

input[type="range"] {
    flex: 1;
}

#score-value {
    min-width: 2rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.filter-actions .btn-secondary {
    order: 3;
}

.favorites-count {
    color: rgba(226, 232, 240, 0.75);
    font-weight: 600;
    margin-right: auto;
}

.btn-primary,
.btn-secondary {
    border: none;
    border-radius: calc(var(--radius) / 1.5);
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0f172a;
    box-shadow: 0 15px 25px rgba(14, 165, 233, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 35px rgba(14, 165, 233, 0.3);
}

.btn-ghost {
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: transparent;
    color: var(--text);
    border-radius: calc(var(--radius) / 1.5);
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s ease;
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.15);
}

.btn-ghost.is-active {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.5);
    color: #e0f2fe;
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.2);
}

.btn-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn-favorite {
    width: 100%;
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border-radius: calc(var(--radius) / 1.5);
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.12);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-favorite:hover {
    background: rgba(56, 189, 248, 0.2);
}

.btn-favorite.is-active {
    border-color: rgba(248, 113, 113, 0.6);
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
}

.match-counter {
    margin-top: 1rem;
    color: var(--muted);
}

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

.insight-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.insight-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.insight-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.layout-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 2fr 1fr;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.feedback {
    min-height: 24px;
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.feedback.error {
    color: var(--danger);
}

.feedback.success {
    color: var(--success);
}

.article-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    max-height: 82vh;
    min-height: 55vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.article-card {
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: calc(var(--radius) / 1.2);
    padding: 1rem;
    background: rgba(15, 23, 42, 0.75);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 20px 35px rgba(8, 47, 73, 0.35);
}

.article-card.active {
    border-color: var(--accent);
    background: rgba(14, 165, 233, 0.08);
    box-shadow: 0 20px 35px rgba(14, 165, 233, 0.25);
}

.article-card.is-favorite {
    border-color: rgba(248, 113, 113, 0.6);
    box-shadow: 0 25px 40px rgba(248, 113, 113, 0.3);
}

.article-card__thumb {
    width: 100%;
    height: 140px;
    border-radius: calc(var(--radius) / 2);
    background: rgba(15, 23, 42, 0.6);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin-bottom: 0.75rem;
    transition: transform 0.2s ease;
}

.article-card:hover .article-card__thumb {
    transform: scale(1.02);
}

.article-card__source {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(148, 163, 184, 0.08);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.article-card__time {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: rgba(226, 232, 240, 0.6);
}

.article-card__favorite {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: rgba(248, 250, 252, 0.6);
    transition: 0.2s ease;
    z-index: 2;
    pointer-events: auto;
}

.article-card__favorite:hover {
    transform: scale(1.05);
}

.article-card.is-favorite .article-card__favorite {
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.6);
    background: rgba(248, 113, 113, 0.18);
}

.article-card__favorite button {
    all: unset;
    cursor: pointer;
}

.article-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.article-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.article-summary {
    margin: 0;
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.95rem;
}

.article-badge {
    align-self: flex-start;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
}

.detail-panel {
    position: sticky;
    top: 1.5rem;
    align-self: start;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-blend-mode: multiply;
}

.detail-image {
    width: 100%;
    height: 200px;
    border-radius: calc(var(--radius) / 2);
    background-color: rgba(15, 23, 42, 0.8);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    margin-bottom: 1rem;
}

.detail-placeholder {
    margin: 0;
    color: var(--muted);
}

.detail-content.hidden {
    display: none;
}

.detail-content h3 {
    margin-top: 0;
}

.detail-meta {
    margin: 0.25rem 0 1rem;
    color: var(--muted);
}

.detail-summary {
    margin: 0;
    line-height: 1.6;
    color: rgba(226, 232, 240, 0.83);
}

.detail-authors {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.75rem 0 0;
    padding: 0;
}

.detail-authors li {
    background: rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.detail-extra {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.detail-extra dt {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.detail-extra dd {
    margin: 0;
    font-weight: 600;
}

.empty-state {
    color: var(--muted);
    margin: 2rem 0;
    text-align: center;
}

.article-list.loading {
    opacity: 0.6;
    pointer-events: none;
}

::selection {
    background: rgba(56, 189, 248, 0.35);
    color: #0f172a;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.65);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.55), rgba(14, 165, 233, 0.7));
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.7), rgba(14, 165, 233, 0.85));
}

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

    .detail-panel {
        position: static;
    }
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    .filter-columns {
        flex-direction: column;
    }

    .field-inline {
        flex-direction: column;
    }
}
