/* The reading room: shared typography and rhythm for research tools. */
.research-page main {
    max-width: 1200px;
    padding-top: 146px;
}

.research-page header:not(.site-header) > div:first-child { min-height: 78px; }
.research-nav { align-items: center; gap: 25px; }
.research-nav-link {
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
}
.research-nav-link:hover,
.research-nav-link.is-current { color: var(--ink); }
.research-nav-link.is-current {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 8px;
}
.research-mobile-nav { padding: 10px 24px 24px; }
.research-mobile-nav .research-nav-link {
    display: block;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}
.brand-dot,
.title-period { color: var(--accent); }

.research-page-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 255px;
    align-items: end;
    gap: 64px;
    padding-bottom: 46px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.research-page-intro .eyebrow { margin-bottom: 22px; }
.research-page-intro h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(42px, 5.6vw, 70px);
    font-weight: 400;
    letter-spacing: -.045em;
    line-height: 1.02;
    color: var(--ink);
}
.research-page-description {
    max-width: 635px;
    margin-top: 22px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--muted);
    text-wrap: pretty;
}
.research-crosslink {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0 3px 24px;
    border-left: 1px solid var(--line);
    color: var(--ink);
    font-size: 17px;
    font-weight: 500;
}
.research-crosslink .eyebrow { margin-bottom: 2px; }
.research-crosslink > span:nth-child(2) { line-height: 1.5; }
.research-crosslink > span:nth-child(2) > span { margin-left: 12px; color: var(--accent); }
.research-crosslink small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.8; }
a.research-crosslink:hover > span:nth-child(2) { color: var(--accent); }

#search-container,
#comparison-filters {
    top: 77px;
    margin: 0 0 22px;
    padding: 14px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: var(--paper) !important;
    box-shadow: none;
}
#search-container > div:first-child { margin-bottom: 0; gap: 12px; }
#search-input-container { width: 100%; }
#search-input,
#paper-search,
#main-filter-btn,
#sort-select,
#tag-filter,
#sort-order {
    min-height: 44px;
    padding-top: 11px;
    padding-bottom: 11px;
    border-color: var(--line) !important;
    border-radius: 4px;
    background: var(--surface) !important;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink) !important;
    box-shadow: none;
}
#sort-select { padding-right: 28px; appearance: auto; }
#search-input::placeholder,
#paper-search::placeholder { color: var(--muted); }
#search-input:focus,
#paper-search:focus,
#sort-select:focus,
#tag-filter:focus,
#sort-order:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
#unified-filter-menu { max-height: min(600px, 70vh); border-radius: 4px; border-color: var(--line); }
#unified-filter-menu h4 { font-family: var(--font-mono); font-weight: 500; font-size: 10px; }
.custom-checkbox { background: var(--surface); border-color: var(--line); }
.custom-checkbox:checked { background: var(--accent); border-color: var(--accent); }
.custom-checkbox::before { box-shadow: inset 1em 1em var(--paper) !important; }
.research-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .03em;
    color: var(--muted);
}
#result-count { font-family: var(--font-mono); font-size: 10px; }

/* Paper entries keep the notebook's reading order in full and split views. */
#papers-list:not(.hidden) { display: flex; flex-direction: column; gap: 0; }
#papers-list .paper-card {
    margin: 0;
    padding: 30px 6px 28px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent !important;
    overflow: visible;
    box-shadow: none;
    transition: background-color .18s ease;
}
#papers-list .paper-card:last-child { border-bottom: 1px solid var(--line); }
#papers-list .paper-card:hover,
#papers-list .paper-card:focus-visible { background: var(--surface-soft) !important; }
#papers-list .paper-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.paper-card h3 {
    max-width: 900px;
    margin-bottom: 13px;
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -.015em;
}
.paper-card > p { max-width: 850px; font-size: 13px; line-height: 1.8; font-weight: 400; }
.paper-card > div:nth-of-type(2) { margin-top: 6px; margin-bottom: 13px; font-size: 12px; line-height: 1.7; }
.paper-card > div:nth-of-type(2) > span:first-child { font-style: normal; font-weight: 500; }
.paper-card > div:nth-of-type(2) svg { display: none; }
.paper-card > div:nth-of-type(3) > span {
    padding: 4px 8px;
    margin-right: 6px;
    margin-bottom: 0;
    border: 0;
    border-radius: 2px;
    background: var(--surface-soft) !important;
    color: var(--muted) !important;
    font-size: 10px;
}
.paper-card > div:first-child > div:last-child { opacity: 1; gap: 4px; }
.paper-card > div:first-child > div:last-child button { padding: 8px; background: transparent !important; border-color: var(--line); }
.paper-card details { margin-top: 16px; }
.paper-card summary { font-size: 11px; color: var(--muted) !important; font-weight: 500; }
.paper-card details > div { max-width: 880px; line-height: 1.85; }
.paper-card > div:last-child.absolute { display: none; }
#papers-list.shrink-left .paper-card { padding: 22px 8px; }
#papers-list.shrink-left h3 { font-size: 20px; }
#papers-list.shrink-left .paper-card > div:first-child { gap: 8px; }
#papers-list.shrink-left .paper-card > div:first-child > div:first-child { padding-right: 0; }
#papers-list.shrink-left .paper-card > div:first-child > div:last-child { flex-direction: column; }
#right-pane,
#compare-left-pane { border-radius: 4px; border-color: var(--line); box-shadow: none; }
#papers-layout { scroll-margin-top: 65px; }
#right-pane > div:nth-child(2), #compare-left-pane > div:nth-child(2) { padding: 22px; }
#right-pane > div:nth-child(2) > div, #compare-left-pane > div:nth-child(2) > div { border-radius: 2px; }
#right-pane button[title="Download Markdown"], #compare-left-pane button[title="Download Markdown"] { color: var(--ink) !important; background: var(--surface-soft) !important; }
#right-pane a[class~="bg-gray-900"], #compare-left-pane a[class~="bg-gray-900"] { background: var(--ink) !important; color: var(--paper) !important; border-radius: 3px; }
@media (min-width: 1024px) {
    #right-pane, #compare-left-pane { top: 170px; height: calc(100vh - 190px); }
}
#right-pane h2,
#compare-left-pane h2 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; }
.markdown-body { font-family: var(--font-body); line-height: 1.85; }
.markdown-body strong { color: var(--ink) !important; }
.markdown-body a,
.markdown-body details > summary .accordion-chevron { color: var(--accent); }
.markdown-body code,
.markdown-body pre { background: var(--surface-soft) !important; font-family: var(--font-mono); font-size: .875em; }
.markdown-body blockquote { color: var(--muted) !important; border-left-color: var(--line) !important; }
.papers-page footer { margin-top: 56px; font-size: 11px; }
.papers-page footer > div { max-width: 1200px; text-align: left; }

/* The comparison catalogue uses an open two-column editorial index. */
#paper-grid:not(.hidden) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 38px; row-gap: 0; }
#paper-grid .navigation-paper {
    min-height: 0;
    padding: 28px 0 32px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent !important;
    transform: none;
    box-shadow: none;
}
#paper-grid .navigation-paper:has([data-action="select"][aria-pressed="true"]) {
    border-top-color: var(--accent);
    box-shadow: 0 -2px 0 var(--accent);
}
.navigation-paper-meta p { font-family: var(--font-mono); font-size: 10px; font-weight: 400; letter-spacing: .04em; }
.navigation-paper-title { margin-top: 16px; font-family: var(--font-display); font-weight: 500; font-size: 29px; line-height: 1.16; letter-spacing: -.018em; }
.navigation-paper h3 { font-family: var(--font-mono); font-size: 9px; font-weight: 400; letter-spacing: .075em; }
.navigation-paper-idea { margin-top: 22px; }
.navigation-paper-idea p,
.navigation-paper-method p { font-size: 13px; line-height: 1.85; color: var(--muted) !important; }
.navigation-paper-tags > span { border-radius: 2px; background: var(--surface-soft) !important; font-size: 10px; }
.navigation-paper-actions { padding-top: 22px; gap: 10px; }
.navigation-paper-actions button { flex: 0 1 auto; min-width: 128px; padding: 10px 17px; border-radius: 3px; font-size: 11px; font-weight: 500; }
.navigation-paper-actions [data-action="select"] { background: var(--ink) !important; color: var(--paper) !important; }
.navigation-paper-actions [data-action="select"][aria-pressed="true"] { background: var(--accent) !important; color: var(--paper) !important; }
.navigation-paper-actions [data-action="select"]:hover:not(:disabled) { background: var(--accent) !important; color: var(--paper) !important; }
#loading-state { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#loading-state > div { height: 400px; border-radius: 3px; }
#loading-state > div:last-child { display: none; }
#compare-tray { border-color: var(--line) !important; background: var(--surface) !important; }
#compare-tray > div { max-width: 1200px; }
#compare-tray button { border-radius: 3px; }
#selection-count { font-weight: 500; }
#selection-chips button { font-family: var(--font-body); font-size: 10px; font-weight: 400; }
#detail-modal > div:last-child,
#compare-modal > div:last-child { border-radius: 5px; background: var(--paper) !important; }
#detail-title,
#compare-title { font-family: var(--font-display); font-weight: 500; font-size: 32px; letter-spacing: -.02em; }
#detail-content { padding-top: 26px; }
#detail-content .markdown-body { max-width: 800px; font-size: 14px; line-height: 1.9; }
#detail-content h3 { font-family: var(--font-mono); font-weight: 500; font-size: 11px; }
.compare-table thead th h3 { font-family: var(--font-display); font-size: 21px; font-weight: 500; line-height: 1.25; }
.compare-table .field-column { font-family: var(--font-mono); font-size: 10px; font-weight: 500; line-height: 1.6; }
.compare-table td .markdown-body { font-size: 13px; line-height: 1.85; }
.research-page :is(button, a, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

@media (max-width: 1023px) {
    .research-nav { gap: 17px; }
    .research-nav-link { font-size: 12px; }
    .research-page-intro { gap: 30px; grid-template-columns: minmax(0, 1fr) 220px; }
    .research-page-intro h1 { font-size: 56px; }
    #search-container { position: relative; top: 0; }
}

@media (max-width: 767px) {
    .research-page main { padding-top: 116px; padding-left: 22px; padding-right: 22px; }
    .research-page-intro { display: block; padding-bottom: 30px; margin-bottom: 8px; }
    .research-page-intro .eyebrow { margin-bottom: 18px; }
    .research-page-intro h1 { font-size: clamp(40px, 10vw, 58px); }
    .research-page-description { margin-top: 18px; font-size: 14px; line-height: 1.85; }
    .research-crosslink { margin-top: 25px; padding-left: 15px; gap: 6px; font-size: 15px; }
    .research-crosslink .eyebrow { margin-bottom: 0; }
    .comparison-howto small { max-width: 330px; }
    #search-container, #comparison-filters { position: relative; top: 0; padding-top: 12px; margin-bottom: 18px; }
    #search-container > div:first-child { gap: 8px; }
    #main-filter-btn, #sort-select { width: 50%; min-width: 0; }
    #main-filter-btn { padding-left: 12px; padding-right: 12px; }
    .research-results-bar { font-size: 9px; align-items: start; }
    .research-results-bar > span:last-child { max-width: 110px; text-align: right; }
    #papers-list .paper-card { padding: 24px 0; }
    .paper-card h3 { font-size: 23px; }
    .paper-card > div:first-child > div:first-child { padding-right: 8px; }
    .paper-card > div:first-child > div:last-child { flex-direction: column; }
    .paper-card > div:nth-of-type(2) { font-size: 11px; gap: 6px 14px; }
    .paper-card > div:nth-of-type(3) > span { margin-bottom: 5px; }
    #paper-grid:not(.hidden) { grid-template-columns: minmax(0, 1fr); }
    #paper-grid .navigation-paper { padding: 25px 0 30px; }
    .navigation-paper-title { font-size: 27px; }
    .navigation-paper-actions button { flex: 1; }
    #loading-state { grid-template-columns: minmax(0, 1fr); }
    #detail-title, #compare-title { font-size: 25px; }
    #detail-modal > div:last-child { border-radius: 6px 6px 0 0; }
    #compare-tray > div { padding-left: 22px; padding-right: 22px; }
    #selection-message { white-space: normal; font-size: 10px; }
    #compare-tray > div > div:last-child { justify-content: flex-end; }
    .papers-page footer { margin-top: 24px; }
    #right-pane > div:first-child > div:first-child,
    #compare-left-pane > div:first-child > div:first-child { flex-direction: column; gap: 14px; }
    #right-pane h2, #compare-left-pane h2 { margin-right: 0; font-size: 24px; }
    .compare-table { min-width: 0 !important; width: max-content; }
    .compare-table .field-column { width: 112px; min-width: 112px; max-width: 112px; padding: 12px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .research-page *, .research-page *::before, .research-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
