body[data-page="tool-tf-motif"] {
    --app-fixed-nav-width: min(1560px, 100%);
    --app-fixed-page-width: min(1560px, 100%);
    --app-fixed-wide-width: min(1640px, 100%);
    /* Keep the document as the scroll container for the evidence panel. */
    overflow-x: clip;
    overflow-y: visible;
}
body[data-page="tool-tf-motif"] .page-header { padding: 6rem 0 1.45rem; }
body[data-page="tool-tf-motif"] .page-header h1 { margin-bottom: .3rem; font-size: clamp(1.95rem, 4vw, 3rem); }

.tf-atlas {
    --tf-blue: #2362ae;
    --tf-deep: #174375;
    --tf-rule: #d8e4ef;
    --tf-wash: #f3f8fd;
    padding: 0 0 3.75rem;
    color: var(--text-primary);
}
.tf-content { min-width: 0; }
.tf-atlas [hidden] { display: none !important; }
.tf-atlas :focus-visible { outline: 2px solid #286bd0; outline-offset: 3px; }

.tf-query {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.25fr) repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 13px 16px;
    margin-bottom: 18px;
    padding: 15px 19px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.tf-field { min-width: 0; }
.tf-field > label { display: block; margin-bottom: .42rem; }
.tf-scope-filters { display: contents; }
.tf-atlas input[type=search] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--tf-rule);
    border-radius: 9px;
    background-color: #f0f5fa;
    color: var(--text-primary);
    font: .9rem var(--font-display);
    padding: 0 11px;
}
.tf-query .search-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.tf-query .search-actions button {
    min-width: 78px;
    min-height: 42px;
    padding: .55rem .9rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}
.tf-query .search-actions .btn-search {
    border-color: transparent;
    background: linear-gradient(135deg, #2563eb, #0ea5a3);
    color: #fff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .18);
}
.tf-query .search-actions button:hover:not(:disabled) { filter: brightness(.97); }
.tf-query .search-actions button:disabled { opacity: .55; cursor: not-allowed; }
.tf-set-trigger > span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tf-picker { position: relative; }
.tf-set-menu {
    position: absolute;
    z-index: 30;
    inset: calc(100% + .3rem) auto auto 0;
    width: max(100%, min(26rem, calc(100vw - 5rem)));
    padding: .55rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}
.tf-set-search-row, .tf-set-pages { display: flex; gap: .45rem; }
.tf-set-search-row input[type=search] {
    min-width: 0;
    height: 42px;
    padding: 0 .95rem;
    border-color: var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    transition: border-color .2s, box-shadow .2s;
}
.tf-set-search-row input[type=search]:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(26, 86, 219, .12);
}
.tf-set-action {
    flex: none;
    padding: .5rem .62rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: .83rem var(--font-display);
    cursor: pointer;
}
.tf-set-action:disabled { opacity: .5; cursor: default; }
.tf-set-status { padding: .4rem 0; color: var(--text-secondary); font-size: .82rem; }
.tf-options {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    max-height: min(40vh, 22rem);
    margin-top: .35rem;
    overflow: auto;
    overscroll-behavior: contain;
}
.tf-option {
    display: block;
    width: 100%;
    padding: .48rem .55rem;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font: .81rem var(--font-mono);
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.tf-option strong { display: block; margin-bottom: .23rem; color: var(--accent-primary); }
.tf-option-member {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
    gap: .55rem;
    padding: .09rem 0;
    font-size: .78rem;
}
.tf-option:is(:hover, [aria-pressed=true]) { border-color: var(--border-color); background: var(--accent-primary-light); }
:is(.tf-set-action, .tf-option):focus-visible { outline-offset: -2px; }
.tf-set-pages { justify-content: flex-end; padding-top: .35rem; }
.tf-outline {
    border: 1px solid #ccddeb;
    border-radius: 7px;
    padding: 6px 10px;
    background: #fff;
    color: var(--tf-blue);
    font: 680 .78rem var(--font-display);
    cursor: pointer;
}
.tf-outline:hover { background: #edf6ff; }

#tf-results { isolation: isolate; }

.tf-panel {
    margin: 0 0 17px;
    overflow: hidden;
    border: 1px solid var(--tf-rule);
    border-radius: 15px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}
.tf-figure-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 15px 23px;
    border-bottom: 1px solid var(--tf-rule);
}
.tf-result-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px; min-width: 0; }
.tf-result-heading h2 { margin: 0; color: var(--text-primary); font: 750 1.2rem/1.3 var(--font-display); }
.tf-result-set {
    padding: 4px 8px;
    border-radius: 7px;
    background: #eef5ff;
    color: var(--accent-primary);
    font: 700 .77rem/1.4 var(--font-mono);
    text-decoration: none;
}
.tf-result-set:hover { text-decoration: underline; text-underline-offset: 2px; }
.tf-metrics { display: flex; flex-wrap: wrap; align-items: stretch; gap: 7px; margin: 0; }
.tf-metrics > div {
    min-width: 96px;
    padding: 6px 11px 7px;
    border: 1px solid var(--tf-rule);
    border-radius: 8px;
    background: var(--bg-secondary);
}
.tf-metrics dt { margin: 0 0 3px; color: var(--text-secondary); font: 670 .71rem/1.25 var(--font-display); }
.tf-metrics dd { margin: 0; color: var(--tf-deep); font: 750 1rem/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.tf-note { margin: 4px 0 10px; color: var(--text-secondary); font: .81rem/1.5 var(--font-display); }

.tf-inline-empty { margin: 12px 0; color: var(--text-secondary); font: .88rem/1.55 var(--font-display); }
.tf-warning { color: #97513c; }

.tf-scroll { max-width: 100%; overflow: auto; }

.tf-section-content { padding: 12px 24px 16px; }

/* Motif results across the selected datasets */
.tf-detail-heading h2 { margin: 0; font: 750 1.12rem/1.3 var(--font-display); }
#tf-detail-title { scroll-margin-top: 84px; }
.tf-detail-heading .tf-note { margin: 4px 0 0; }
.tf-detail-scroll {
    margin: 14px 18px 0;
    overflow: auto;
    border: 1px solid var(--tf-rule);
    border-radius: 10px;
}
.tf-detail-table { width: 100%; min-width: 950px; border-collapse: collapse; font-size: .86rem; }
.tf-detail-table :is(th, td) { padding: 8px 13px; text-align: left; border-bottom: 1px solid var(--tf-rule); }
.tf-detail-table thead th { background: var(--bg-secondary); color: var(--text-secondary); font-size: .79rem; font-weight: 720; white-space: nowrap; }
.tf-detail-table tbody tr:nth-child(even) { background: var(--tf-wash); }
.tf-detail-table tbody tr:hover { background: #eef5ff; }
.tf-detail-table tbody tr:last-child > * { border-bottom: 0; }
.tf-detail-table .tf-numeric { text-align: right; white-space: nowrap; }
.tf-detail-table td.tf-numeric { font: .79rem/1.45 var(--font-mono); }
.tf-detail-motif { color: var(--accent-primary); font-weight: 700; text-decoration: none; white-space: nowrap; }
a.tf-detail-motif:hover { text-decoration: underline; text-underline-offset: 2px; }
.tf-detail-logo { min-width: 50px; min-height: 29px; white-space: nowrap; }
.tf-detail-dataset { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; }
.tf-detail-tissue {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: .74rem;
    white-space: nowrap;
}
.tf-detail-footer { padding-inline: 18px; }
.tf-detail-results { padding-bottom: 14px; }
.tf-detail-footer .catalog-pagination { margin-bottom: 0; }

.tf-dialog {
    width: min(calc(100% - 24px), 760px);
    max-height: 88dvh;
    margin: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 14px 52px #152c4a35;
}
.tf-dialog::backdrop { background: #17335266; }
.tf-dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--border-color);
}
.tf-dialog-head h2 { margin: 0; font: 750 1.12rem/1.35 var(--font-display); }
.tf-dialog-close.tf-outline {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-color: var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 1.12rem;
}
.tf-dialog-close.tf-outline:hover { background: #eaf2fe; color: var(--accent-primary); }
.tf-dialog-body { padding: 10px 20px 16px; }
.tf-logo-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.tf-logo-field {
    display: grid;
    flex: 0 1 230px;
    gap: 4px;
    color: var(--text-secondary);
    font: 680 .78rem/1.35 var(--font-display);
}
.tf-logo-field .scedar-filter-select { width: 100%; min-height: 36px; height: 36px; padding-block: 4px; font-size: .84rem; }
.tf-logo-scroll { max-width: 100%; overflow: auto; border: 1px solid #d8e4ef; border-radius: 10px; background: #fbfdff; }
.tf-logo-plot { display: block; width: 100%; height: auto; font-family: var(--font-display); }
.tf-logo-position { cursor: pointer; }
.tf-logo-position:focus-visible { stroke: var(--accent-primary); stroke-width: 1.5; outline: none; }
.tf-logo-inspection { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px 16px; padding: 9px 11px; margin-top: 8px; border-radius: 8px; background: var(--bg-secondary); }
.tf-logo-position-label { color: var(--text-primary); font-size: .8rem; }
.tf-logo-bases { display: flex; flex-wrap: wrap; gap: 5px 14px; }
.tf-logo-base { color: var(--text-secondary); white-space: nowrap; font: .8rem/1.4 var(--font-mono); }
.tf-logo-note { margin: 6px 0 0; color: var(--text-secondary); font-size: .76rem; }
.tf-stored-matrix { border-top: 1px solid var(--border-color); margin-top: 12px; }
.tf-stored-matrix summary { padding: 8px 0 2px; color: var(--text-secondary); cursor: pointer; font-size: .8rem; font-weight: 680; }
.tf-matrix-table { width: max-content; min-width: 100%; border-spacing: 2px; text-align: center; font: .72rem var(--font-mono); }
.tf-matrix-table :is(th,td) { min-width: 28px; padding: 4px; }
.tf-matrix-table th { background: #f0f5fa; color: #435b74; }
.tf-matrix-table td { border-radius: 3px; color: #102b48; }

.tf-dialog[data-kind="motif"] { width: min(calc(100% - 24px), 660px); }
.tf-dialog[data-kind="motif"] .tf-dialog-head { align-items: flex-start; }
.tf-dialog[data-kind="motif"] .tf-dialog-identity { min-width: 0; }
.tf-dialog[data-kind="motif"] .tf-dialog-identity h2 {
    color: var(--text-primary);
    font-size: clamp(1.35rem, 4vw, 1.7rem);
    line-height: 1.16;
    overflow-wrap: anywhere;
}
.tf-dialog-title-link {
    color: var(--tf-blue);
    text-decoration: none;
}
.tf-dialog-title-link:is(:hover, :focus-visible) {
    text-decoration: underline;
    text-underline-offset: .14em;
}
.tf-dialog[data-kind="motif"] .tf-dialog-accession {
    margin: 4px 0 0;
    color: #64748b;
    font: 600 .78rem/1.35 var(--font-mono);
}
.tf-dialog[data-kind="motif"] .tf-dialog-body { padding-top: 15px; }
.tf-dialog[data-kind="motif"] .tf-logo-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.25rem), 1fr));
    margin: 0 0 13px;
}
.tf-dialog[data-kind="motif"] .tf-logo-field { min-width: 0; }
.tf-dialog[data-kind="motif"] :is(.tf-logo-scroll, .tf-stored-matrix .tf-scroll) { overscroll-behavior-x: contain; }
.tf-dialog[data-kind="motif"] .tf-matrix-table :is(th, td) { padding-inline: 2px; }
.tf-dialog[data-kind="motif"] .tf-logo-plot { height: clamp(180px, 29dvh, 248px); }
.tf-dialog[data-kind="motif"] :is(.tf-logo-inspection, .tf-logo-bases) { justify-content: center; }
.tf-dialog[data-kind="motif"] .tf-logo-inspection { text-align: center; }

.tf-heat-content { padding-top: 13px; }
.tf-heat-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tf-heat-controls .tf-view-switch { grid-template-columns: repeat(2, minmax(5.5rem, 1fr)); margin: 0; }
.tf-heat-controls input[type=search] { min-width: 0; max-width: 270px; height: 38px; }
.tf-chart-actions { display: flex; align-items: center; gap: 10px; }
.tf-summary-link { display: inline-flex; align-items: center; min-height: 38px; text-decoration: none; white-space: nowrap; }
.tf-heat-scroll {
    width: 100%;
    container-type: inline-size;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-block: .7rem .9rem;
}
.tf-heat {
    --tf-label: clamp(154px, 24vw, 224px);
    --tf-cell: clamp(15px, calc((100cqw - var(--tf-label) - 6px) / var(--tf-column-count, 1) - 3px), 26px);
    width: max-content;
    margin-inline: auto;
    border-collapse: separate;
    border-spacing: 3px;
    text-align: left;
    font: .8rem/1.15 var(--font-display);
}
.tf-heat :is(th, td) { padding: 0; }
.tf-heat :is(.tf-heat-corner, .tf-motif-cell) {
    position: sticky;
    left: 0;
    z-index: 1;
    width: var(--tf-label);
    min-width: var(--tf-label);
    max-width: var(--tf-label);
    background: var(--bg-card);
    padding-inline: .5rem;
}
.tf-heat-corner { color: var(--text-secondary); }
.tf-motif-cell { height: var(--tf-cell); color: #1b385b; }
.tf-motif-label { display: flex; align-items: baseline; justify-content: space-between; gap: .45rem; }
.tf-motif-cell span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-motif-cell span { font-weight: 700; }
.tf-motif-cell small { flex: none; color: var(--text-secondary); font: .64rem/1.05 var(--font-mono); }
.tf-heat .tf-motif-cell.is-selected {
    border-radius: 4px;
    background: var(--accent-primary-light);
    box-shadow: inset 3px 0 var(--accent-primary);
}
.tf-heat :is(.tf-heat-cell, .tf-heat-dataset) {
    display: block;
    width: var(--tf-cell);
    padding: 0;
    border: 1px solid rgba(71, 85, 105, .12);
    border-radius: 3px;
    cursor: pointer;
}
.tf-heat-cell { height: var(--tf-cell); background: var(--tf-fill); }
.tf-heat-dataset { height: 15px; margin-bottom: 3px; background: var(--tf-tissue); }
.tf-heat-unavailable {
    background: repeating-linear-gradient(135deg, #f5f7fa 0 3px, #d4dce7 3px 4px);
}
.tf-heat :is(.tf-heat-cell, .tf-heat-dataset):hover {
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 2px #2c4668;
}
.tf-heat :is(.tf-heat-cell, .tf-heat-dataset)[aria-pressed="true"] {
    box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 3px var(--accent-primary);
}
.tf-heat :is(.tf-heat-cell, .tf-heat-dataset):focus-visible {
    outline-offset: 0;
    scroll-margin-inline-start: calc(var(--tf-label) + 4px);
}

.tf-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .4rem 1rem;
    padding: .72rem 1.25rem;
    border-top: 1px solid var(--tf-rule);
    background: var(--tf-wash);
    color: var(--text-secondary);
    text-align: center;
    font: .79rem var(--font-display);
}
.tf-legend > span { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .4rem; }
.tf-tissue-legend { border: 1px solid var(--tf-rule); border-radius: 8px; }
.tf-heat-ramp { width: 95px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, #eaf5ff, #819bc3 50%, #18417d); }
.tf-heat-status-key { width: 13px; height: 13px; border: 1px solid rgba(71, 85, 105, .18); border-radius: 3px; }
.tf-heat-tissue-key { width: 12px; height: 8px; border-radius: 2px; background: var(--tf-tissue); }

.tf-dialog-note { margin: 9px 20px 0; }
.tf-detail-method { margin-top: 14px; }
.tf-support-table { margin: 12px 0; border-collapse: collapse; color: #395570; font: .77rem var(--font-display); text-align: left; }
.tf-support-table :is(th,td) { padding: 6px 11px; border-bottom: 1px solid #dce8f2; white-space: nowrap; }
.tf-support-table th { background: #f2f7fb; }
.tf-support-table td:nth-child(2), .tf-support-table td:nth-child(3) { text-align: right; }

@media (max-width: 930px) {
    body[data-page="tool-tf-motif"] .nav-balance { display: none !important; }
    body[data-page="tool-tf-motif"] .nav-brand small { display: none; }
    body[data-page="tool-tf-motif"] .nav-wordmark-img { width: clamp(90px, 18vw, 178px) !important; }
    body[data-page="tool-tf-motif"] .nav-links { flex: 0 1 auto; gap: 2px; }
    body[data-page="tool-tf-motif"] .nav-container { justify-content: space-between; }
}
@media (max-width: 1020px) {
    .tf-query { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
    .tf-query .search-actions { grid-column: 1 / -1; }
    .tf-set-menu { inset-inline: auto 0; }
}
@media (max-width: 760px) {
    .tf-query { padding: .9rem; gap: .75rem; }
    .tf-query .search-actions button { flex: 1; min-width: 0; }
    .tf-set-menu { width: min(400px, calc(100vw - 76px)); }
}
@media (max-width: 670px) {
    body[data-page="tool-tf-motif"] .tf-content { padding-inline: .65rem; }
    body[data-page="tool-tf-motif"] .nav-logo-img { width: 28px !important; height: 28px !important; flex-basis: 28px !important; }
    body[data-page="tool-tf-motif"] .nav-brand { display: none; }
    body[data-page="tool-tf-motif"] :is(.nav-links > li > a,.nav-dropdown-trigger) { position: relative; min-width: 28px; padding-inline: 5px; gap: 2px; }
    body[data-page="tool-tf-motif"] :is(.nav-links > li > a,.nav-dropdown-trigger) > span:not(.nav-item-icon) {
        position: absolute;
        width: 1px;
        height: 1px;
        clip-path: inset(50%);
        overflow: hidden;
        white-space: nowrap;
    }
    body[data-page="tool-tf-motif"] .site-footer-top { grid-template-columns: minmax(0, 1fr); }
    .tf-set-menu { width: min(400px, calc(100vw - 54px)); }
    .tf-figure-head, .tf-section-content { padding-inline: 14px; }
    .tf-detail-scroll { margin-inline: 14px; }
    .tf-detail-footer { padding-inline: 14px; }
}
@media (max-width: 520px) {
    .tf-dialog[data-kind="motif"] .tf-logo-inspection { display: grid; justify-content: stretch; }
    .tf-dialog[data-kind="motif"] .tf-logo-bases {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .tf-options { max-height: min(22dvh, 16rem); }
    .tf-option-member { grid-template-columns: minmax(7.25rem, max-content) minmax(0, 1fr); gap: .4rem; font-size: .73rem; }
    .tf-logo-field { flex: 1 1 205px; min-width: 0; }
    .tf-heat-controls input[type=search] { max-width: none; }
    .tf-chart-actions { width: 100%; min-width: 0; }
    .tf-metrics { width: 100%; }
    .tf-metrics > div { flex: 1 1 79px; min-width: 0; padding-inline: 8px; }
    .tf-heat { --tf-label: 125px; }
    .tf-heat .tf-motif-label { display: grid; gap: .12rem; }
}
