:root {
    --bg: #f2ede4;
    --bg-strong: #f8f3ea;
    --surface: rgba(255, 251, 245, 0.78);
    --surface-strong: rgba(255, 250, 244, 0.94);
    --surface-deep: rgba(255, 250, 244, 0.98);
    --line: rgba(36, 31, 23, 0.12);
    --line-strong: rgba(36, 31, 23, 0.2);
    --text: #1f1b15;
    --text-soft: #655d52;
    --accent: #7d5c36;
    --accent-soft: rgba(125, 92, 54, 0.12);
    --shadow: 0 22px 70px rgba(30, 24, 18, 0.08);
    --stage-dark: #171517;
    --stage-deep: #09070c;
    --stage-line: rgba(255, 255, 255, 0.08);
    --stage-label: rgba(255, 248, 239, 0.78);
}

[data-theme="dark"] {
    --bg: #0f1114;
    --bg-strong: #171a1f;
    --surface: rgba(22, 25, 30, 0.84);
    --surface-strong: rgba(27, 31, 37, 0.94);
    --surface-deep: rgba(20, 23, 28, 0.98);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #ece7dc;
    --text-soft: #b8b0a2;
    --accent: #d3b98e;
    --accent-soft: rgba(211, 185, 142, 0.13);
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
    --stage-dark: #0a0d15;
    --stage-deep: #03050a;
    --stage-line: rgba(255, 255, 255, 0.06);
    --stage-label: rgba(233, 228, 220, 0.8);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(125, 92, 54, 0.08), transparent 28%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    line-height: 1.6;
}

[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(211, 185, 142, 0.12), transparent 30%),
        linear-gradient(180deg, #121418 0%, #0a0c0f 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
code,
.eyebrow,
.search-label,
.panel-label,
.filter-chip,
.detail-label,
.back-link,
.result-chip,
.theme-toggle,
.close-detail {
    font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

.page-shell {
    padding: 34px 18px 52px;
}

.page-frame {
    max-width: 1360px;
    margin: 0 auto;
    padding: 34px 34px 26px;
    border: 1px solid var(--line);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.6fr);
    gap: 28px;
    margin-bottom: 28px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--text-soft);
    font-size: 0.84rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.back-link:hover {
    color: var(--accent);
}

.eyebrow,
.panel-label,
.detail-label {
    margin: 0 0 10px;
    color: var(--text-soft);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    max-width: 11ch;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    line-height: 0.95;
    font-weight: 500;
    letter-spacing: -0.04em;
}

.intro {
    margin: 18px 0 0;
    max-width: 58ch;
    color: var(--text-soft);
    font-size: 1.03rem;
}

.hero-side {
    display: grid;
    gap: 16px;
    align-content: start;
    justify-items: end;
}

.hero-stats {
    display: grid;
    width: 100%;
    gap: 10px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.stat strong {
    font-size: 1.2rem;
    font-weight: 600;
}

.stat span {
    color: var(--text-soft);
    font-size: 0.88rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.theme-toggle,
.close-detail {
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    padding: 11px 15px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.theme-toggle {
    min-width: 76px;
}

.theme-toggle:hover,
.close-detail:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
}

.control-bar {
    margin-bottom: 18px;
}

.search-shell {
    display: block;
    max-width: 540px;
}

.search-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 0.79rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#expert-search {
    width: 100%;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    padding: 16px;
    font-size: 1rem;
    font-family: inherit;
}

#expert-search::placeholder {
    color: var(--text-soft);
}

#expert-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.field-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.filter-chip {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-soft);
    padding: 8px 11px;
    cursor: pointer;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.filter-chip:hover,
.filter-chip.is-active {
    color: var(--accent);
    border-color: var(--line-strong);
    background: var(--accent-soft);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.75fr);
    gap: 28px;
    align-items: start;
}

.galaxy-panel,
.detail-panel {
    min-width: 0;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 16px;
}

.panel-caption,
.panel-meta {
    margin: 0;
    color: var(--text-soft);
}

.panel-meta {
    white-space: nowrap;
    font-size: 0.92rem;
}

.galaxy-stage {
    position: relative;
    min-height: 620px;
    border: 1px solid var(--line);
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 48%, rgba(255, 210, 155, 0.12), transparent 22%),
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.08), transparent 22%),
        radial-gradient(circle at 72% 68%, rgba(147, 183, 255, 0.1), transparent 20%),
        linear-gradient(180deg, var(--stage-dark) 0%, var(--stage-deep) 100%);
}

.galaxy-stage::before,
.galaxy-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.galaxy-stage::before {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 228, 183, 0.11), transparent 18%),
        radial-gradient(circle at 48% 48%, rgba(255, 242, 214, 0.08), transparent 32%);
    mix-blend-mode: screen;
}

.galaxy-stage::after {
    background-image:
        linear-gradient(to right, transparent 0, transparent calc(100% - 1px), var(--stage-line) calc(100% - 1px)),
        linear-gradient(to bottom, transparent 0, transparent calc(100% - 1px), var(--stage-line) calc(100% - 1px));
    background-size: 140px 140px;
    opacity: 0.35;
}

.galaxy-map {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 620px;
}

.galaxy-empty {
    position: absolute;
    inset: auto 24px 24px 24px;
    padding: 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 11, 17, 0.62);
    color: rgba(255, 248, 239, 0.92);
    backdrop-filter: blur(10px);
}

.galaxy-empty p {
    margin: 0 0 6px;
}

.result-rail-shell {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.result-rail-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 10px;
}

.result-rail {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.result-rail:empty::before {
    content: "No quick results yet.";
    color: var(--text-soft);
    font-size: 0.94rem;
}

.result-chip {
    flex: 0 0 auto;
    display: grid;
    gap: 4px;
    min-width: 170px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.result-chip:hover,
.result-chip.is-active {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: var(--accent-soft);
}

.result-chip strong {
    font-size: 0.98rem;
    line-height: 1.15;
}

.result-chip span {
    color: var(--text-soft);
    font-size: 0.79rem;
    line-height: 1.35;
}

.detail-panel {
    position: sticky;
    top: 126px;
    display: grid;
    gap: 18px;
    min-height: 620px;
    max-height: calc(100vh - 146px);
    padding: 24px 22px 26px;
    border: 1px solid var(--line);
    background: var(--surface-deep);
    overflow: auto;
    scrollbar-gutter: stable;
}

.detail-header {
    display: grid;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.detail-header-top {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 18px;
}

.detail-eyebrow {
    margin: 0 0 10px;
    color: var(--text-soft);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.detail-header h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 0.98;
    font-weight: 500;
    letter-spacing: -0.04em;
}

.detail-summary {
    margin: 0;
    max-width: 62ch;
    color: var(--text-soft);
    font-size: 1rem;
}

.detail-link {
    display: inline-flex;
    width: fit-content;
    color: var(--accent);
    font-size: 0.92rem;
}

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

.detail-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-chip {
    padding: 4px 8px;
    border: 1px solid var(--line);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.detail-block {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.detail-copy {
    margin: 0;
    color: var(--text-soft);
}

.paper-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.paper-item {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.paper-item:first-child {
    padding-top: 0;
    border-top: 0;
}

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

.empty-detail {
    align-self: center;
}

.empty-detail p,
.empty-note {
    margin: 0 0 8px;
}

.empty-note {
    color: var(--text-soft);
}

.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(10, 11, 14, 0.42);
    backdrop-filter: blur(3px);
}

.close-detail {
    display: none;
    min-width: 68px;
}

.star-node {
    cursor: pointer;
}

.star-halo {
    opacity: 0.18;
    transition: opacity 180ms ease, transform 180ms ease;
}

.star-core {
    stroke: rgba(255, 255, 255, 0.75);
    stroke-width: 1.1;
}

.star-node.is-active .star-halo,
.star-node.is-hovered .star-halo {
    opacity: 0.42;
}

.star-node.is-active .star-core {
    stroke-width: 1.7;
}

.star-label {
    fill: var(--stage-label);
    font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
    letter-spacing: 0.03em;
    pointer-events: none;
}

.star-label-small {
    fill: rgba(255, 248, 239, 0.56);
    font-size: 11px;
}

.star-label-active {
    fill: rgba(255, 248, 239, 0.9);
    font-size: 14px;
}

.star-count-label {
    fill: rgba(255, 248, 239, 0.52);
    font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stage-copy {
    fill: rgba(255, 248, 239, 0.66);
    font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
    font-size: 15px;
}

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

    .hero-side {
        justify-items: start;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .detail-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 960px) {
    body.detail-open {
        overflow: hidden;
    }

    .detail-overlay[hidden] {
        display: none;
    }

    .detail-overlay {
        display: block;
    }

    .detail-panel {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        width: 100%;
        max-width: none;
        max-height: min(72vh, 760px);
        min-height: 0;
        padding: 18px 18px 24px;
        border: 1px solid var(--line);
        border-radius: 22px 22px 0 0;
        transform: translateY(104%);
        transition: transform 220ms ease;
        scrollbar-gutter: auto;
        box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.24);
    }

    body.detail-open .detail-panel {
        transform: translateY(0);
    }

    .close-detail {
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }
}

@media (max-width: 720px) {
    .page-shell {
        padding: 16px 10px 34px;
    }

    .page-frame {
        padding: 22px 18px 18px;
    }

    .control-bar {
        margin-bottom: 16px;
    }

    .galaxy-stage,
    .galaxy-map {
        min-height: 470px;
    }

    .panel-head,
    .result-rail-head,
    .detail-header-top {
        flex-direction: column;
        align-items: start;
    }

    .panel-meta {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .theme-toggle,
    .close-detail,
    .filter-chip,
    .result-chip,
    .star-halo {
        transition: none;
    }
}
