/* R04–R06 public catalog browse surfaces ----------------------------------- */

:where([data-runtime-theme="target-u"]) .catalog-browse {
    --catalog-grid-min: 17rem;
}

#explore-search-form .quick-search__panel {
    /* Above the floating school index (45), below the site navigation (50). */
    z-index: 46;
}

:where([data-runtime-theme="target-u"]) .catalog-university-description {
    margin: 0;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-search-panel {
    padding: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-search-panel--simple {
    width: 100%;
    margin-inline: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-panel--paired {
    width: 100%;
    margin-inline: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-search-toolbar {
    width: 100%;
    padding-block: 0;
    border-block-end: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-search-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    flex: 1 1 100%;
    gap: var(--theme-spacing-sm);
    width: auto;
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-search-field {
    width: 100%;
}

:where([data-runtime-theme="target-u"]) .catalog-university-type-filter {
    flex: 0 0 auto;
}

:where([data-runtime-theme="target-u"]) .catalog-results {
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-results-toolbar {
    margin-bottom: var(--theme-spacing-xl);
    padding-block-start: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-results-toolbar > p {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-entity-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--theme-spacing-lg);
}

@media screen {
    /* Font swaps only need to lay out cards near the reader.
       Leave the leading cards and the active keyboard target fully rendered. */
    :is(.catalog-university-card, .catalog-placement-card):nth-child(n + 5):not(:focus-within) {
        content-visibility: auto;
    }

    /* Reserve the usual content height until the browser measures each card. */
    .catalog-university-card {
        contain-intrinsic-block-size: auto 14.3rem;
    }

    .catalog-placement-card {
        contain-intrinsic-block-size: auto 20.5rem;
    }
}

@media screen and (min-width: 48rem) {
    .catalog-university-card {
        contain-intrinsic-block-size: auto 14.5rem;
    }

    .catalog-placement-card {
        contain-intrinsic-block-size: auto 20rem;
    }
}


:where([data-runtime-theme="target-u"]) .catalog-external-code {
    margin: 0;
    color: var(--theme-color-muted);
}

/* Sizing now comes from the icon contract's 20px step (.ico--20). */

:where([data-runtime-theme="target-u"]) .catalog-placeholder {
    color: var(--theme-color-muted);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
}

/* Department exploration -------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .catalog-explore-toolbar > [data-catalog-summary] {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--theme-spacing-sm);
    max-inline-size: none;
}

.catalog-explore-toolbar [data-catalog-summary] > span {
    white-space: nowrap;
}

@media (max-width: 36rem) {
    .catalog-explore-toolbar .quick-chips > .ui-type-micro {
        display: none;
    }
}

@media (max-width: 24rem) {
    .catalog-explore-toolbar [data-catalog-summary] {
        flex-direction: column;
    }
}

/* Open school sections share the page background. */
:where([data-runtime-theme="target-u"]) .catalog-university-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-university-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    padding-block: var(--theme-spacing-xl) var(--theme-spacing-2xl);
    border-block-start: 1px solid var(--theme-color-border-strong);
}

:where([data-runtime-theme="target-u"]) .catalog-university-group:first-child {
    padding-block-start: var(--theme-spacing-sm);
    border-block-start: 0;
}

[data-ui-route="department-explore"] .catalog-university-group__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--theme-spacing-sm);
    padding: 0 0 var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .catalog-university-group__identity {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .catalog-university-group__title {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm) var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .catalog-university-group__title > h2,
:where([data-runtime-theme="target-u"]) .catalog-university-group__meta {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-university-group__actions {
    display: flex;
    justify-content: flex-end;
}

:where([data-runtime-theme="target-u"]) .catalog-strip-range {
    margin: 0;
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .catalog-status-row {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--theme-spacing-sm);
}

/* Keyboard users can step over a school's departments in one move. */
:where([data-runtime-theme="target-u"]) .catalog-strip-skip {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

:where([data-runtime-theme="target-u"]) .catalog-strip-skip:focus-visible {
    position: static;
    width: fit-content;
    height: auto;
    margin: 0 var(--theme-spacing-card) var(--theme-spacing-sm);
    overflow: visible;
    clip-path: none;
    color: var(--theme-color-primary);
    font-size: var(--theme-text-supporting);
    font-weight: var(--theme-text-supporting--font-weight);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-strip-skip:focus-visible,
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-university-group__title h2:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
}

.catalog-strip-shell {
    --catalog-rail-width: 56px;
    position: relative;
    min-width: 0;
}

/* Bleed only the focus-safe padding; the first card aligns with the title. */
:where([data-runtime-theme="target-u"]) .catalog-department-strip {
    display: flex;
    min-width: 0;
    gap: var(--theme-spacing-md);
    margin: 0 -4px;
    padding: 4px 4px 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 4px;
    scroll-snap-type: x proximity;
    list-style: none;
}

[data-catalog-layout="cards"] .catalog-department-strip {
    scrollbar-width: none;
}

[data-catalog-layout="cards"] .catalog-department-strip::-webkit-scrollbar {
    display: none;
}

:where([data-runtime-theme="target-u"]) .catalog-department-strip__item {
    display: flex;
    flex: 0 0 16.5rem;
    min-width: 0;
    scroll-snap-align: start;
}

/*
 * Cards in a strip share the tallest card's height. The name anchors to the
 * top edge and the group badges to the bottom edge with the same inset, so a
 * short card never ends in a deeper blank than it starts with.
 */
:where([data-runtime-theme="target-u"]) .catalog-department-strip .catalog-department-card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

/*
 * 探索卡片沒有 status row 契約：收藏愛心疊在卡片右上角，不佔版面高度，
 * 系名維持原本的上緣。角落落位沿用 status row 的內距與光學校正，
 * 系名右側讓出愛心的寬度，長系名換行時不會壓到愛心。
 */
:where([data-runtime-theme="target-u"]) .catalog-department-card > .catalog-department-card__favorite {
    position: absolute;
    z-index: 2;
    inset-block-start: 0;
    inset-inline-end: 0;
    min-height: 0;
    pointer-events: none;
}

:where([data-runtime-theme="target-u"]) .catalog-department-card__favorite > button {
    pointer-events: auto;
}

:where([data-runtime-theme="target-u"]) .catalog-department-card__body .ui-entity-card__name {
    padding-inline-end: var(--theme-spacing-3xl);
    overflow-wrap: anywhere;
}

:where([data-runtime-theme="target-u"]) .catalog-department-card > .catalog-department-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding-block: var(--theme-spacing-lg);
}

/* List view uses the same links, controls and reading order as the strip. */
[data-catalog-layout="list"] .catalog-department-strip {
    display: grid;
    gap: 0;
    margin-inline: 0;
    padding: var(--theme-spacing-xs);
    overflow: visible;
    border: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

[data-catalog-layout="list"] .catalog-department-strip__item + li {
    border-block-start: 1px solid var(--theme-color-border);
}

[data-catalog-layout="list"] .catalog-department-strip__item:focus-within {
    position: relative;
    z-index: 1;
}

[data-catalog-layout="list"] .catalog-department-card {
    border: 0;
}

[data-catalog-layout="list"] .catalog-department-card > .catalog-department-card__favorite {
    inset-block: 0;
    padding-block: 0;
}

[data-catalog-layout="list"] .catalog-department-card__favorite > button {
    margin-block: auto;
}

[data-catalog-layout="list"] .catalog-department-card > .catalog-department-card__body {
    flex-flow: row wrap;
    align-items: center;
    align-content: center;
    column-gap: var(--theme-spacing-sm);
    min-height: 56px;
    padding-block: var(--theme-spacing-md);
    padding-inline-end: calc(var(--theme-spacing-card) + 44px);
    overflow-wrap: anywhere;
}

[data-catalog-layout="list"] .catalog-department-card__body .ui-entity-card__name {
    flex-basis: 100%;
    padding-inline-end: 0;
}

[data-catalog-layout="list"] .catalog-department-card .catalog-status-row {
    margin: 0;
    padding: 0;
}

@media (min-width: 48rem) {
    [data-catalog-layout="list"] .catalog-department-card > .catalog-department-card__body {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
        column-gap: var(--theme-spacing-lg);
    }

    [data-catalog-layout="list"] .catalog-department-card__category {
        grid-column: 2;
    }

    [data-catalog-layout="list"] .catalog-department-card .catalog-status-row {
        grid-column: 3;
    }
}

:where([data-runtime-theme="target-u"]) .catalog-department-card__category {
    margin: 0;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-department-card .catalog-status-row {
    margin-block-start: auto;
    padding-block-start: var(--theme-spacing-sm);
}

.catalog-strip-rail,
.catalog-strip-track-row,
.catalog-mobile-expand.ui-button {
    display: none;
}

@media (min-width: 48rem) {
    /* Desktop card strips carry a bottom track per school (v2.36), which replaces
       the top divider between schools so single-row and multi-row groups match. */
    [data-catalog-layout="cards"] .catalog-university-group {
        padding-block-end: var(--theme-spacing-lg);
        border-block-start: 0;
    }

    [data-catalog-layout="cards"] .catalog-strip-track-row:not([hidden]) {
        display: flex;
        align-items: center;
        gap: var(--theme-spacing-md);
        margin-block-start: var(--theme-spacing-md);
    }

    /* The progress line is also a scrollbar (catalog_strip.js): drag the thumb,
       or press the line to bring the thumb there. pan-y leaves vertical page
       scrolling to the browser while horizontal drags reach the script. */
    .catalog-strip-track {
        position: relative;
        flex: 1;
        height: 2px;
        background: var(--theme-color-border);
        cursor: pointer;
        touch-action: pan-y;
        -webkit-user-select: none;
        user-select: none;
    }

    /* A 44px hit area centred on the 2px line, without changing the layout. */
    .catalog-strip-track::before {
        content: "";
        position: absolute;
        inset: -21px 0;
    }

    /* Non-scrollable schools show the 100% progress bar and range label, but cannot be dragged. */
    [data-catalog-layout="cards"] .catalog-strip-track-row[data-scrollable="false"] .catalog-strip-track {
        cursor: default;
        touch-action: auto;
    }

    [data-catalog-layout="cards"] .catalog-strip-track-row[data-scrollable="false"] .catalog-strip-track::before {
        content: none;
    }

    .catalog-strip-track__thumb {
        position: absolute;
        inset-block: 0;
        background: var(--theme-color-primary);
    }
}

@media (hover: hover) and (pointer: fine) and (min-width: 48rem) {
    [data-catalog-layout="cards"] .catalog-department-strip__item {
        scroll-margin-inline-start: var(--catalog-rail-width);
    }

    [data-catalog-layout="cards"] .catalog-strip-rail:not([hidden]) {
        display: flex;
        align-items: center;
        position: absolute;
        z-index: 3;
        inset-block: 4px 6px;
        width: var(--catalog-rail-width);
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        color: var(--theme-color-primary);
        cursor: pointer;
    }

    .catalog-strip-rail--prev {
        --catalog-fade-direction: to right;
        --catalog-arrow-shift: -2px;
        inset-inline-start: -4px;
        justify-content: flex-start;
    }

    .catalog-strip-rail--next {
        --catalog-fade-direction: to left;
        --catalog-arrow-shift: 2px;
        inset-inline-end: -4px;
        justify-content: flex-end;
    }

    .catalog-strip-rail::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background: linear-gradient(var(--catalog-fade-direction), var(--theme-color-background),
            color-mix(in oklch, var(--theme-color-background) 86%, transparent) 42%, transparent);
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
        mask-image: linear-gradient(var(--catalog-fade-direction), #000 0% 42%, transparent);
    }

    .catalog-strip-rail .ico {
        --theme-icon-stroke: 1.8;
        position: relative;
        z-index: 1;
        width: 24px;
        height: 24px;
        margin-inline: var(--theme-spacing-sm);
        transition: color var(--theme-motion-duration-interaction);
    }

    .catalog-strip-rail:hover .ico {
        color: var(--theme-color-primary-light);
    }

    @media (prefers-reduced-motion: no-preference) {
        .catalog-strip-rail .ico {
            transition-property: color, transform;
        }

        .catalog-strip-rail:hover .ico {
            transform: translateX(var(--catalog-arrow-shift));
        }
    }
}

@media (max-width: 47.999rem) {
    /* The first two schools can share the initial viewport. */
    [data-ui-route="department-explore"]:not([data-catalog-layout="list"]) .catalog-university-group:nth-child(n + 3) {
        content-visibility: auto;
        contain-intrinsic-block-size: auto 22rem;
        overflow-clip-margin: var(--theme-focus-ring-outer-extent);
    }

    .catalog-university-group {
        padding-block: var(--theme-spacing-lg) var(--theme-spacing-xl);
    }

    .catalog-university-group:first-child {
        padding-block-start: var(--theme-spacing-xs);
    }

    [data-ui-route="department-explore"] .catalog-university-group__header {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: var(--theme-spacing-sm);
        row-gap: 0;
        padding-block-end: var(--theme-spacing-md);
    }

    [data-ui-route="department-explore"] .catalog-university-group__identity,
    [data-ui-route="department-explore"] .catalog-university-group__meta {
        display: contents;
    }

    [data-ui-route="department-explore"] .catalog-university-group__title {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    [data-ui-route="department-explore"] .catalog-university-group__meta-summary {
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
    }

    [data-ui-route="department-explore"] .catalog-university-group__meta-sep {
        display: none;
    }

    [data-ui-route="department-explore"] .catalog-university-group__meta-groups {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    [data-ui-route="department-explore"] .catalog-university-group__actions {
        grid-column: 2;
        grid-row: 2;
        justify-content: flex-end;
    }

    [data-ui-route="department-explore"] .catalog-university-route-link {
        padding-inline-end: 0;
        border-inline-end-width: 0;
        white-space: nowrap;
    }

    [data-ui-route="department-explore"] .catalog-university-route-link::after {
        inset-inline-end: 0;
    }

    [data-ui-route="department-explore"]:not([data-catalog-layout="list"]) .catalog-department-strip {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: var(--theme-spacing-sm);
        margin: 0;
        padding: 0;
        overflow: visible;
        scroll-snap-type: none;
    }

    [data-ui-route="department-explore"]:not([data-catalog-layout="list"])
    [data-mobile-collapsed="true"] .catalog-department-strip__item:nth-child(n + 4) {
        display: none;
    }

    [data-catalog-layout="cards"] .catalog-mobile-expand:not([hidden]) {
        display: inline-flex;
        width: 100%;
        margin-block-start: var(--theme-spacing-sm);
    }

    .catalog-mobile-expand[aria-expanded="false"] .catalog-mobile-expand__less,
    .catalog-mobile-expand[aria-expanded="true"] .catalog-mobile-expand__more {
        display: none;
    }

    .catalog-mobile-expand[aria-expanded="true"] .ico {
        transform: rotate(180deg);
    }
}

/* Admission filters ------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-lg);
}

:where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel .catalog-search-toolbar {
    padding: var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-disclosure {
    display: grid;
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-toggle {
    justify-content: flex-start;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-toggle__icon {
    flex: 0 0 20px;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-toggle__label {
    flex: 0 0 auto;
    color: var(--theme-color-foreground);
    font-weight: 650;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-toggle .t-value {
    flex: 0 1 auto;
    margin-inline-start: auto;
    color: var(--theme-color-muted);
    text-align: end;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-xl);
    padding: var(--theme-spacing-card);
    border: 1px solid var(--theme-color-border);
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface__header {
    padding-block-end: var(--theme-spacing-lg);
    border-block-end: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface__header > div {
    display: grid;
    max-width: 44rem;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface__header h2,
:where([data-runtime-theme="target-u"]) .catalog-filter-surface__header p {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface__header p {
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-groups {
    display: grid;
    min-width: 0;
    gap: 0;
}

/* These generic listbox layouts remain for the university-detail and
 * accumulation-score routes. R05 no longer renders any nested listbox. */
:where([data-runtime-theme="target-u"]) .catalog-filter-grid,
:where([data-runtime-theme="target-u"]) .catalog-nojs-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-grid[hidden] {
    display: none;
}

:where([data-runtime-theme="target-u"]) .catalog-filter {
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-popover {
    inset-inline-start: 0;
    width: 100%;
    max-height: min(32rem, 66vh);
    overflow-y: auto;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-popover--wide {
    width: min(44rem, calc(100vw - var(--theme-spacing-3xl)));
}

:where([data-runtime-theme="target-u"]) .catalog-option-list--columns {
    grid-template-columns: minmax(0, 1fr);
}

:where([data-runtime-theme="target-u"]) .catalog-region-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--theme-spacing-md);
}

:where([data-runtime-theme="target-u"]) .catalog-region-group {
    display: grid;
    align-content: start;
    gap: var(--theme-spacing-sm);
    min-width: 0;
    padding: var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-region-group__header {
    display: flex;
    min-height: 44px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .catalog-region-group__header h3 {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-region-group__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .catalog-compact-action {
    min-inline-size: 44px;
    padding-inline: var(--theme-spacing-sm);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--theme-spacing-sm);
    padding-top: var(--theme-spacing-lg);
    border-top: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-native-filter-group {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-sm);
    margin: 0;
    padding: var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface .catalog-native-filter-group {
    gap: var(--theme-spacing-md);
    padding: var(--theme-spacing-xl) 0;
    border: 0;
    border-block-start: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface .catalog-native-filter-group:first-child {
    padding-block-start: 0;
    border-block-start: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-surface .catalog-native-filter-group:last-child {
    padding-block-end: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-native-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(8rem, 100%), 1fr));
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .catalog-native-options--region {
    align-content: start;
}

:where([data-runtime-theme="target-u"]) .catalog-native-option {
    box-sizing: border-box;
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: var(--theme-spacing-sm);
    padding: var(--theme-spacing-sm);
    border-radius: var(--theme-radius-control);
    color: var(--theme-color-foreground);
    font-size: var(--theme-text-control);
}

:where([data-runtime-theme="target-u"]) .catalog-native-option:has(input:checked) {
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .catalog-native-option__indicator {
    display: grid;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    place-items: center;
    border: 1px solid var(--theme-color-border-strong);
    border-radius: 0;
    background: var(--theme-color-surface);
}

:where([data-runtime-theme="target-u"]) .catalog-native-option__indicator::after {
    width: 8px;
    height: 8px;
    background: var(--theme-color-primary);
    content: '';
    opacity: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-native-option input:checked + .catalog-native-option__indicator {
    border-color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .catalog-native-option input:checked + .catalog-native-option__indicator::after {
    opacity: 1;
}

:where([data-runtime-theme="target-u"]) .catalog-native-option__label {
    min-width: 0;
    overflow-wrap: anywhere;
}

:where([data-runtime-theme="target-u"]) .catalog-subject-mode-group {
    display: grid;
    min-width: 0;
    width: min(100%, 20rem);
    gap: var(--theme-spacing-xs);
    margin: 0;
    padding: 0 0 var(--theme-spacing-sm);
    border: 0;
    border-block-end: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-subject-mode-group > legend {
    padding: 0;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-subject-mode-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--theme-spacing-xs);
    width: 100%;
}

:where([data-runtime-theme="target-u"]) .catalog-subject-mode-option {
    box-sizing: border-box;
    min-width: 0;
    width: 100%;
    padding-inline: var(--theme-spacing-sm);
    text-align: center;
    white-space: normal;
}

:where([data-runtime-theme="target-u"]) .catalog-subject-mode-option:has(input:checked) {
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

/* The frame belongs to the keyboard, so it keys off the input's
 * :focus-visible rather than the label's :focus-within. */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-native-option:has(input:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-subject-mode-option:has(input:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}

/* The label is the complete visible owner; suppress the native-control
 * fallback so keyboard focus does not draw a second ring inside that owner. */
:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-native-option input:focus-visible {
    outline: 0;
    outline-offset: 0;
    box-shadow: none;
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-subject-mode-option input:focus-visible {
    outline: 0;
    outline-offset: 0;
    box-shadow: none;
}

/* Admission cards --------------------------------------------------------- */
:where([data-runtime-theme="target-u"]) .catalog-card-status {
    justify-content: space-between;
}

:where([data-runtime-theme="target-u"]) .catalog-favorite-slot {
    flex: 0 0 auto;
    margin-inline-start: auto;
}

:where([data-runtime-theme="target-u"]) .catalog-filter-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding: var(--theme-spacing-sm) var(--theme-spacing-md);
    border: 1px solid var(--theme-color-border);
    border-radius: var(--theme-radius-control);
    background: var(--theme-color-surface);
    color: var(--theme-color-primary);
    font-family: var(--theme-font-sans);
    font-size: var(--theme-text-supporting);
    font-weight: 600;
    line-height: var(--theme-text-supporting--line-height);
    text-decoration: none;
    transition:
        background-color var(--theme-motion-duration-interaction),
        border-color var(--theme-motion-duration-interaction),
        color var(--theme-motion-duration-interaction);
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .catalog-filter-link:hover {
        border-color: var(--theme-color-border-strong);
        background: var(--theme-color-surface-muted);
    }
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"])) .catalog-filter-link:focus-visible {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: var(--theme-focus-ring-gap);
    box-shadow: var(--theme-focus-ring-halo);
}


:where([data-runtime-theme="target-u"]) .catalog-evidence-label {
    display: block;
    margin-bottom: var(--theme-spacing-xs);
    color: var(--theme-color-foreground);
    font-weight: 600;
}

/* School Program card: one horizontal row per program --------------------- */
:where([data-runtime-theme="target-u"]) .catalog-entity-grid.catalog-entity-grid--departments {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--theme-spacing-sm);
}

/*
 * Conjoined two-pane Entity card for university program listings.
 * Mobile: program info + actions (favorite + guide) on top, expanded admission
 * groups below. Desktop: program pane on the left, admission groups on the right.
 * The entire program pane (except the favorite control) triggers the guide link
 * and its hover feedback without affecting the admission group links.
 */
:where([data-runtime-theme="target-u"]) .catalog-program-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__main {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--theme-spacing-md);
    min-width: 0;
    padding: var(--theme-spacing-lg) var(--theme-spacing-card);
    transition: background-color var(--theme-motion-duration-interaction);
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__hit {
    position: absolute;
    inset: 0;
    z-index: 1;
    text-decoration: none;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__hit:focus {
    outline: none;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--theme-spacing-sm);
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__head > .ui-entity-card__identity {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__head > .ui-entity-card__status {
    position: relative;
    z-index: 2;
    flex: none;
    min-height: 0;
    align-items: flex-start;
    padding: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__foot {
    display: flex;
    flex: 1 0 auto;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--theme-spacing-sm) var(--theme-spacing-md);
    min-width: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__guide {
    align-self: flex-end;
    margin-inline-start: auto;
    min-height: 28px;
    padding: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-program-card > .ui-entity-card__evidence {
    align-content: start;
    border-block-start: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-program-card__category {
    margin: 0;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-program-card .catalog-status-row {
    margin: 0;
}

@media (hover: hover) and (pointer: fine) {
    :where([data-runtime-theme="target-u"]) .catalog-program-card__main:not(:has(.ui-favorite-control:hover)):hover {
        background: var(--theme-color-surface-muted);
    }

    :where([data-runtime-theme="target-u"]) .catalog-program-card__main:not(:has(.ui-favorite-control:hover)):hover .ui-entity-card__name,
    :where([data-runtime-theme="target-u"]) .catalog-program-card__main:not(:has(.ui-favorite-control:hover)):hover .ui-entity-card__action {
        color: var(--theme-color-primary-light);
    }

    :where([data-runtime-theme="target-u"]) .catalog-program-card__main:not(:has(.ui-favorite-control:hover)):hover .ui-entity-card__action > span::after {
        clip-path: inset(0);
    }

    :where([data-runtime-theme="target-u"]) .catalog-program-card__main:not(:has(.ui-favorite-control:hover)):hover .ui-entity-card__action svg {
        transform: translateX(3px);
    }
}

:where([data-runtime-theme="target-u"]:not([data-focus-modality="pointer"]))
.catalog-program-card__main:has(> .catalog-program-card__hit:focus-visible) {
    outline: var(--theme-focus-ring-width) solid var(--theme-color-focus);
    outline-offset: -2px;
    box-shadow: var(--theme-focus-ring-halo);
}

@media (min-width: 64rem) {
    :where([data-runtime-theme="target-u"]) .catalog-program-card {
        grid-template-columns: minmax(17.5rem, 21rem) minmax(0, 1fr);
    }

    :where([data-runtime-theme="target-u"]) .catalog-program-card > .ui-entity-card__evidence {
        border-block-start: 0;
        border-inline-start: 1px solid var(--theme-color-border);
    }
}

/* Pagination and empty states -------------------------------------------- */
:where([data-runtime-theme="target-u"]) .catalog-pagination-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--theme-spacing-lg);
    margin-top: var(--theme-spacing-2xl);
    padding-top: var(--theme-spacing-lg);
    border-top: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-pagination-summary {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-pagination-bar .ui-pagination {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    width: 100%;
}

/* The current page is a persistent selection, so it speaks the selection
 * language: pale selected surface plus Navy ink. */
:where([data-runtime-theme="target-u"]) .catalog-page-indicator {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding-inline: var(--theme-spacing-md);
    border-radius: var(--theme-radius-control);
    background: var(--theme-color-surface-selected);
    color: var(--theme-color-primary);
}

:where([data-runtime-theme="target-u"]) .ui-empty-state .ui-type-body {
    max-width: 42rem;
    margin: 0;
}

/* Responsive adaptation --------------------------------------------------- */
.catalog-switch-short {
    display: none;
}

@media (max-width: 47.999rem) {
    .ui-page-header.catalog-admission-header {
        row-gap: var(--theme-spacing-sm);
        padding-block-end: var(--theme-spacing-sm);
    }

    .catalog-admission-header .ui-page-header__actions,
    .catalog-admission-header .ui-page-header__actions .ui-button {
        gap: var(--theme-spacing-xs);
    }

    .catalog-admission-header .ui-page-header__actions .ui-button {
        padding: var(--theme-spacing-xs);
    }

    .catalog-admission-header .ui-page-header__actions:has(> a + a) {
        container-type: inline-size;
        font-size: var(--theme-text-control);
    }

    .catalog-personal-actions { container-name: personal-actions; }
    .catalog-distribution-actions { container-name: distribution-actions; }

    .catalog-switch-destination {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        clip-path: inset(50%);
        overflow: hidden;
    }

    /* Each character uses 1.02em including tracking. The arrow, gaps,
       padding and borders together use 42px. Personal has 16/14 characters
       across the two buttons, distribution has 14/12. */
    @container personal-actions (inline-size < calc(16.32em + 42px)) {
        .catalog-switch-name { display: none; }
        .catalog-switch-short { display: inline; }
    }

    @container personal-actions (inline-size < calc(14.28em + 42px)) {
        .catalog-admission-header .catalog-track-switch { display: none; }
    }

    @container distribution-actions (inline-size < calc(14.28em + 42px)) {
        .catalog-switch-name { display: none; }
        .catalog-switch-short { display: inline; }
    }

    @container distribution-actions (inline-size < calc(12.24em + 42px)) {
        .catalog-admission-header .catalog-track-switch { display: none; }
    }

    :where([data-runtime-theme="target-u"]) .catalog-entity-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    :where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel .catalog-search-toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: var(--theme-spacing-sm);
    }

    :where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel .catalog-search-control {
        width: auto;
        min-width: 0;
    }

    :where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel .catalog-filter-toggle {
        width: auto;
    }

    :where([data-runtime-theme="target-u"]) .catalog-filter-actions > .ui-button--tertiary,
    :where([data-runtime-theme="target-u"]) .catalog-filter-actions > .ui-button--quiet {
        width: fit-content;
        align-self: center;
    }

    :where([data-runtime-theme="target-u"]) .catalog-admission-filter-panel {
        gap: var(--theme-spacing-md);
    }

    :where([data-runtime-theme="target-u"]) .catalog-filter-disclosure {
        gap: var(--theme-spacing-lg);
    }
}

@media (min-width: 40rem) {
    :where([data-runtime-theme="target-u"]) .catalog-filter-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    :where([data-runtime-theme="target-u"]) .catalog-option-list--columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-fact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-fact:nth-child(odd) {
        padding-inline-end: var(--theme-spacing-lg);
        border-inline-end: 1px solid var(--theme-color-border);
    }

    :where([data-runtime-theme="target-u"]) .catalog-fact:nth-child(even) {
        padding-inline-start: var(--theme-spacing-lg);
    }

    :where([data-runtime-theme="target-u"]) .catalog-fact--wide {
        grid-column: 1 / -1;
        padding-inline: 0;
        border-inline-end: 0;
    }
}

@media (min-width: 48rem) {
    :where([data-runtime-theme="target-u"]) .catalog-region-groups {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-entity-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-university-group__header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    :where([data-runtime-theme="target-u"]) .catalog-filter-grid,
    :where([data-runtime-theme="target-u"]) .catalog-nojs-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-filter-grid.catalog-filter-grid--paired,
    :where([data-runtime-theme="target-u"]) .catalog-nojs-filters.catalog-filter-grid--paired {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }


    :where([data-runtime-theme="target-u"]) [data-catalog-filter="region"] .catalog-filter-popover,
    :where([data-runtime-theme="target-u"]) [data-catalog-filter="subject"] .catalog-filter-popover {
        inset-inline: auto 0;
    }

    :where([data-runtime-theme="target-u"]) .catalog-native-filter-group--wide {
        grid-column: 1 / -1;
    }

    :where([data-runtime-theme="target-u"]) .catalog-pagination-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    :where([data-runtime-theme="target-u"]) .catalog-pagination-bar .ui-pagination {
        display: flex;
        width: auto;
    }
}

@media (min-width: 72rem) {
    :where([data-runtime-theme="target-u"]) .catalog-filter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-filter-grid.catalog-filter-grid--paired,
    :where([data-runtime-theme="target-u"]) .catalog-nojs-filters.catalog-filter-grid--paired {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    :where([data-runtime-theme="target-u"]) .catalog-region-groups {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }


    :where([data-runtime-theme="target-u"]) [data-catalog-filter="region"] .catalog-filter-popover,
    :where([data-runtime-theme="target-u"]) [data-catalog-filter="academic_group"] .catalog-filter-popover,
    :where([data-runtime-theme="target-u"]) [data-catalog-filter="subject"] .catalog-filter-popover {
        inset-inline: auto 0;
    }
}

/* The canonical shell remains the only horizontal safety owner. At wide
 * viewports its usable area can expose a compact three-up comparison grid;
 * narrower desktop widths retain the roomier two-up composition. */
@media (min-width: 85rem) {
    :where([data-runtime-theme="target-u"]) .catalog-entity-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Spec153 Browse recovery composition ------------------------------------
 * These rules only compose the R04/R05 page organisms. Shared ui-* owners
 * keep their canonical geometry in style.css, and R06 remains unchanged. */
:where([data-runtime-theme="target-u"]) .catalog-browse--recovery {
    gap: var(--theme-spacing-lg);
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--simple {
    padding-block: var(--theme-spacing-sm) var(--theme-spacing-md);
    border-block-end: 1px solid var(--theme-color-border);
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-search-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-search-control,
:where([data-runtime-theme="target-u"]) .catalog-taskbar--explore .catalog-search-control {
    width: 100%;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-university-type-filter {
    align-self: center;
    justify-self: start;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-search-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 15rem);
    align-items: stretch;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-filter-toggle:not([hidden]) {
    display: inline-flex;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-search-toolbar:has(.catalog-filter-toggle[hidden]) {
    grid-template-columns: minmax(0, 1fr);
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-search-control {
    display: block;
    width: 100%;
}

:where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-filter-toggle:not([hidden]) {
    display: flex;
}

:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-toolbar {
    align-items: flex-start;
    gap: var(--theme-spacing-sm) var(--theme-spacing-lg);
    margin-bottom: var(--theme-spacing-lg);
}

:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-toolbar__summary {
    display: grid;
    min-width: 0;
    gap: var(--theme-spacing-xs);
}

:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-toolbar__summary > p,
:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-scope {
    margin: 0;
}

:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-scope {
    overflow-wrap: anywhere;
    color: var(--theme-color-muted);
}

:where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-reset {
    flex: 0 0 auto;
}

:where([data-runtime-theme="target-u"]) .catalog-empty-action {
    width: fit-content;
    margin-block-start: var(--theme-spacing-md);
}

@media (max-width: 47.999rem) {
    :where([data-runtime-theme="target-u"]) .catalog-browse--recovery {
        gap: var(--theme-spacing-md);
        padding-block: var(--theme-spacing-lg);
    }

    :where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-search-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    :where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-search-control,
    :where([data-runtime-theme="target-u"]) .catalog-taskbar--explore .catalog-search-control {
        grid-template-columns: minmax(0, 1fr);
    }

    :where([data-runtime-theme="target-u"]) .catalog-taskbar--university .catalog-search-submit,
    :where([data-runtime-theme="target-u"]) .catalog-taskbar--explore .catalog-search-submit,
    :where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-filter-toggle {
        width: 100%;
    }

    :where([data-runtime-theme="target-u"]) .catalog-browse--recovery .catalog-results-reset {
        width: fit-content;
    }
}

@media (max-width: 39.999rem) {
    :where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-search-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    :where([data-runtime-theme="target-u"]) .catalog-taskbar--admission .catalog-filter-toggle {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    :where([data-runtime-theme="target-u"]) .catalog-filter-link {
        transition-duration: 0.01ms;
    }
}
