/* ---------- My tests page (mobile first) ---------- */

.mt-root {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.mt-breadcrumbs-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.mt-title {
    font-family: var(--third-family);
    color: var(--text-dark-color);
    font-weight: 600;
    font-size: 24px;
    line-height: 1.25;
    margin: 0;
}

.mt-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}

.mt-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

.mt-section-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.mt-section-title-link {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    min-width: 0;
}

.mt-section-title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 18px;
    line-height: 28px;
    color: var(--text-dark-color);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mt-section-chevron {
    flex: 0 0 auto;
    color: var(--text-gray-color);
    display: inline-flex;
    align-items: center;
}

.mt-section-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.mt-icon-action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: none;
    background: var(--gray-200);
    color: var(--text-gray-dark-color);
    cursor: pointer;
    padding: 0;
    transition: background-color .15s ease;
}

    .mt-icon-action:hover:not(:disabled) {
        background: var(--gray-300);
    }

    .mt-icon-action:disabled {
        cursor: default;
        opacity: .45;
    }

.mt-scroller {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

    .mt-scroller::-webkit-scrollbar {
        display: none;
    }

    .mt-scroller > * {
        scroll-snap-align: start;
    }

.mt-empty {
    width: 100%;
    padding: 24px;
    border-radius: 16px;
    background: var(--gray-200);
    color: var(--gray-500);
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    text-align: center;
    box-sizing: border-box;
}

.mt-empty--all {
    padding: 48px 24px;
    font-size: 16px;
    color: var(--gray-600);
}

.mt-auth-required {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 40px 16px;
    text-align: center;
}

.mt-auth-required-title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 24px;
    color: var(--text-dark-color);
    margin: 0;
}

.mt-auth-required-sub {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-500);
    max-width: 420px;
    margin: 0;
}

.mt-auth-required-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

/* ---------- Test card mini ---------- */

.test-card-mini {
    position: relative;
    flex: 0 0 auto;
    width: 272px;
    min-height: 108px;
    /* Design cap: card must not grow taller than 112px regardless of content. */
    max-height: 112px;
    border-radius: 16px;
    padding: 12px;
    box-sizing: border-box;
    background: #1CCD9D;
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(22, 30, 57, .12);
}

    .test-card-mini:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(22, 30, 57, .20);
    }

    .test-card-mini:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

.test-card-mini__bg {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    max-height: 112px;
    width: auto;
    object-fit: contain;
    object-position: right top;
    pointer-events: none;
    opacity: .85;
    z-index: 0;
}

.test-card-mini > :not(.test-card-mini__bg) {
    position: relative;
    z-index: 1;
}

.test-card-mini__top {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.test-card-mini__theme {
    background: #FFFFFF;
    color: #161E27;
    padding: 4px 6px;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.test-card-mini__theme--muted {
    background: rgba(255, 255, 255, .22);
    color: #FFFFFF;
    font-weight: 500;
}

.test-card-mini__draft {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #FFFFFF;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 11px;
    opacity: .95;
}

    .test-card-mini__draft svg {
        flex: 0 0 auto;
    }

.test-card-mini__title {
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 15px;
    line-height: 1.25;
    color: #FFFFFF;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.test-card-mini__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 500;
}

.test-card-mini__questions {
    color: #FFFFFF;
    opacity: .95;
}

.test-card-mini__metrics {
    display: flex;
    gap: 12px;
}

.test-card-mini__metric {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #FFFFFF;
}

/* The "like" metric is a real button — reset default chrome and add
   a couple of affordances (hover, pressed). */
.test-card-mini__metric--like {
    background: transparent;
    border: none;
    padding: 2px 4px;
    margin: -2px -4px; /* keep hit-target tight against other metrics */
    border-radius: 6px;
    cursor: pointer;
    color: #FFFFFF;
    font: inherit;
    transition: background-color .15s ease, transform .1s ease;
}

    .test-card-mini__metric--like:hover:not(:disabled) {
        background: rgba(255, 255, 255, .15);
    }

    .test-card-mini__metric--like:active:not(:disabled) {
        transform: scale(.92);
    }

    .test-card-mini__metric--like:disabled {
        cursor: default;
        opacity: .7;
    }

.test-card-mini__metric--liked svg {
    /* Slightly pop the heart when it's currently liked. */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}

.test-card-mini--removed {
    opacity: .7;
}

/* ---------- Collection cover mosaic ---------- */
/* The cover is a grid of up to four tiles, one per newest test. The 2px gaps show the card
   background through, so the tiles read as separate chips rather than one smeared square. */

.cc-cover {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    gap: 2px;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    background: #FFFFFF;
    border-radius: 16px;
    overflow: hidden;
    box-sizing: border-box;
}

.cc-cover--2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.cc-cover--3,
.cc-cover--4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

    /* Three tiles: the newest one keeps a full-height cell on the left. */
    .cc-cover--3 > .cc-cover__tile:first-child {
        grid-row: span 2;
    }

.cc-cover__tile {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--green-color);
}

.cc-cover__tile--empty {
    box-sizing: border-box;
    background: var(--gray-200);
    border: 1px dashed var(--gray-300);
    color: var(--gray-500);
}

.cc-cover__empty-icon {
    width: 45%;
    height: 45%;
    pointer-events: none;
}

/* Oversized and offset so the decorative pattern bleeds off the tile instead of
   floating in the middle as a smudge. */
.cc-cover__pattern {
    position: absolute;
    top: -25%;
    left: -18%;
    width: 150%;
    height: 150%;
    object-fit: contain;
    pointer-events: none;
}

.cc-cover__more {
    position: relative;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    color: #FFFFFF;
}

/* ---------- Collection card mini ---------- */

.collection-card-mini {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 272px;
    min-height: 72px;
    padding: 0 8px 0 0;
    background: #FFFFFF;
    border: none;
    border-radius: 16px;
    color: inherit;
    font: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
    box-shadow: 0 2px 8px rgba(22, 30, 57, .06);
}

    .collection-card-mini:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(22, 30, 57, .12);
    }

    .collection-card-mini:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

/* Sizing only — the mosaic itself is styled by .cc-cover. Also used by the loading skeletons,
   which render a plain grey box with these dimensions. */
.collection-card-mini__cover {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: 16px;
}

.collection-card-mini__info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.collection-card-mini__title-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.collection-card-mini__title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 16px;
    line-height: 20px;
    color: var(--text-gray-dark-color);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.collection-card-mini__subtitle {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    color: var(--gray-600);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-card-mini__owner {
    color: var(--gray-500);
}

/* Status badges carry both a glyph and dark-on-tint text: the previous brand-colour text on a
   14% tint sat around 2:1 contrast and failed WCAG AA, and colour was the only status cue. */
.collection-card-mini__badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 11px;
    line-height: 16px;
    white-space: nowrap;
}

.collection-card-mini__badge-icon {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
}

.collection-card-mini__badge-text {
    white-space: nowrap;
}

.collection-card-mini__badge--draft {
    background: #F1F3F5;
    color: #495057;
}

.collection-card-mini__badge--published {
    background: #EAF9F4;
    color: #0E7A5F;
}

.collection-card-mini__badge--locked {
    background: #FDECEA;
    color: #A32D2D;
}

.collection-card-mini__chevron {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: var(--gray-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
}

/* ---------- Collection card square (public surfaces) ---------- */

.collection-card-square {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 118px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: transform .15s ease;
}

    .collection-card-square:hover {
        transform: translateY(-2px);
    }

    .collection-card-square:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 3px;
        border-radius: 18px;
    }

.collection-card-square__cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(22, 30, 57, .10);
}

.collection-card-square__title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    line-height: 18px;
    color: var(--text-gray-dark-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.collection-card-square__meta {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: var(--gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-card-square__owner {
    color: var(--gray-500);
}

.mt-collections-grid {
    width: 100%;
}

/* ---------- Collection publish row (own collection detail page) ---------- */

.mt-collection-publish {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.mt-collection-publish__note {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-600);
}

.mt-collection-publish__btn {
    height: 40px;
    padding: 0 18px;
    border: none;
    border-radius: 10px;
    background: var(--green-color);
    color: #FFFFFF;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: filter .15s ease;
}

    .mt-collection-publish__btn:hover:not(:disabled) {
        filter: brightness(1.05);
    }

    .mt-collection-publish__btn:disabled {
        opacity: .65;
        cursor: default;
    }

.mt-collection-publish__btn--ghost {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--text-gray-dark-color);
}

.mt-collection-publish__error {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    color: var(--red-color);
    margin: -4px 0 0;
}

/* ---------- Tablet ---------- */
@media (min-width: 768px) {

    .mt-root {
        gap: 24px;
        padding: 0px 22px;
        height: 100%;
        max-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 16px;
        /* Hide the scrollbar chrome but keep the container scrollable. */
        scrollbar-width: thin;
    }

        .mt-root::-webkit-scrollbar {
            width: 6px;
        }

        .mt-root::-webkit-scrollbar-thumb {
            background-color: rgba(135, 148, 168, .35);
            border-radius: 6px;
        }

        .mt-root::-webkit-scrollbar-thumb:hover {
            background-color: rgba(135, 148, 168, .55);
        }

    .mt-title {
        font-size: 28px;
    }

    .mt-section-title {
        font-size: 20px;
    }

    .test-card-mini {
        width: 303px;
        min-height: 112px;
        max-height: 112px;
        padding: 16px;
        border-radius: 20px;
    }

    .test-card-mini__bg {
        max-height: 120px;
    }

    .test-card-mini__title {
        font-size: 16px;
    }

    .collection-card-mini {
        width: 100%;
        min-height: 96px;
        border-radius: 20px;
    }

    .collection-card-mini__cover {
        width: 96px;
        height: 96px;
        border-radius: 20px;
    }

    .collection-card-square {
        width: 128px;
    }

    .collection-card-square__cover {
        border-radius: 20px;
    }

    .mt-scroller.mt-collections-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        overflow-x: visible;
        overflow-y: visible;
        scroll-snap-type: none;
        padding-bottom: 0;
    }

    /* Arrow buttons are meaningless once items flow in a grid. */
    .mt-collections-actions {
        display: none;
    }
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {

    .mt-title {
        font-size: 32px;
    }

    .mt-section-title {
        font-size: 20px;
    }

    .mt-scroller.mt-collections-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.mt-root--list {
    gap: 16px;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 24px;
}

.mt-list-header {
    display: grid;
    grid-template-areas:
        "back title"
        "search search";
    grid-template-columns: auto 1fr;
    row-gap: 12px;
    column-gap: 12px;
    align-items: center;
    width: 100%;
}

.mt-list-back {
    grid-area: back;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.mt-list-title {
    grid-area: title;
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 20px;
    line-height: 1.25;
    color: var(--text-dark-color);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mt-list-search {
    grid-area: search;
    width: 100%;
    max-width: 100%;
}

.mt-list-search-input-wrap {
    position: relative;
    width: 100%;
}

.mt-list-search-icon {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--gray-500);
    pointer-events: none;
}

.mt-list-search-input {
    box-sizing: border-box;
    width: 100%;
    height: 48px;
    padding: 0 16px 0 40px;
    border-radius: 12px;
    border: 1px solid var(--gray-300);
    background: #FFFFFF;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 15px;
    color: var(--text-dark-color);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .mt-list-search-input::placeholder {
        color: var(--gray-500);
    }

    .mt-list-search-input:focus {
        border-color: var(--blue-color);
        box-shadow: 0 0 0 3px rgba(75, 159, 255, .15);
    }

.mt-tag-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-height: 32px;
}

    .mt-tag-row::-webkit-scrollbar {
        display: none;
    }

    .mt-tag-row > * {
        scroll-snap-align: start;
    }

.mt-tag {
    display: inline-flex;
    flex-direction: row;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 8px;
    border: none;
    background: #F0F0F6;
    color: var(--text-dark-color);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}

    .mt-tag:hover {
        background: #E6E7EF;
    }

.mt-tag--active {
    background: var(--blue-color);
    color: #FFFFFF;
}

    .mt-tag--active:hover {
        background: var(--blue-700);
    }

.mt-tag--reset {
    background: transparent;
    color: var(--gray-600);
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 6px 8px;
}

    .mt-tag--reset:hover {
        background: transparent;
        color: var(--text-dark-color);
    }

.mt-tag__title {
    white-space: nowrap;
}

.mt-tag__x {
    color: currentColor;
    opacity: .85;
    flex: 0 0 auto;
}

/* Card grid — responsive columns. On mobile each card fills the width. */
.mt-list-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
}

.mt-list-grid__item {
    display: block;
    width: 100%;
    min-width: 0;
}

    .mt-list-grid__item .test-card-mini {
        width: 100%;
        min-height: 108px;
        max-height: 112px;
    }

.mt-list-grid--collections {
}

    .mt-list-grid--collections .collection-card-mini {
        width: 100%;
    }

/* Empty state for the list pages — bigger and centered. */
.mt-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 24px;
    text-align: center;
    border-radius: 20px;
    background: var(--gray-200);
    color: var(--gray-600);
}

.mt-list-empty__title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 18px;
    color: var(--text-dark-color);
    margin: 0;
}

.mt-list-empty__sub {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-600);
    margin: 0;
    max-width: 480px;
}

/* ---------- Infinite scroll ---------- */

.infinite-sentinel {
    /* Height > 0 so IntersectionObserver can actually observe it. */
    height: 1px;
    width: 100%;
    pointer-events: none;
}

.mt-list-loader {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 0;
    color: var(--gray-600);
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
}

    .mt-list-loader::before {
        content: "";
        display: inline-block;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        border: 2px solid var(--gray-300);
        border-top-color: var(--blue-color);
        animation: mt-list-loader-spin .8s linear infinite;
    }

@keyframes mt-list-loader-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 640px) {
    .mt-list-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {

    .mt-root--list {
        margin: 0;
        padding-left: 8px;
        padding-right: 8px;
    }

    .mt-list-header {
        grid-template-areas: "back title search";
        grid-template-columns: auto 1fr auto;
        gap: 16px;
    }

    .mt-list-back {
        width: 48px;
        height: 48px;
    }

    .mt-list-title {
        font-size: 24px;
    }

    .mt-list-search {
        width: 303px;
        max-width: 303px;
    }

    .mt-list-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }

        .mt-list-grid__item .test-card-mini {
            min-height: 108px;
            max-height: 112px;
            padding: 16px;
        }
}

@media (min-width: 1024px) {

    .mt-root--list {
        padding-left: 22px;
        padding-right: 22px;
    }
}

@media (min-width: 1200px) {

    .mt-list-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ============================================================
   "Создать коллекцию" — header action + creation modal
   ============================================================ */

/* The list header grows a third area for the primary action. Declared after the tablet override of
   .mt-list-header above, so the media rule further down is what wins on wide screens. */
.mt-list-header--with-action {
    grid-template-areas:
        "back title"
        "search search"
        "action action";
    grid-template-columns: auto 1fr;
}

.mt-list-action {
    grid-area: action;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: 12px;
    /* blue-800 rather than the brand blue: white on #2C6CDC clears 4.5:1, the lighter blues do not. */
    background: var(--blue-800);
    color: #FFFFFF;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    line-height: 20px;
    white-space: nowrap;
    transition: filter .15s ease;
}

    .mt-list-action:hover {
        filter: brightness(1.08);
    }

    .mt-list-action:focus-visible {
        outline: 2px solid var(--text-dark-color);
        outline-offset: 2px;
    }

/* Same button repeated inside the empty state — sized to its content there. */
.mt-list-empty__cta {
    width: auto;
    margin-top: 8px;
}

/* ---------- Creation modal ---------- */

.mt-ccm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 57, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}

.mt-ccm-dialog {
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    border-radius: 20px;
    background: #FFFFFF;
    box-shadow: 0 18px 48px rgba(22, 30, 57, .28);
}

.mt-ccm-dialog__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mt-ccm-dialog__title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 18px;
    line-height: 1.25;
    color: var(--text-dark-color);
    margin: 0;
}

.mt-ccm-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: var(--gray-200);
    color: var(--text-gray-dark-color);
    cursor: pointer;
}

    .mt-ccm-dialog__close:hover:not(:disabled) {
        background: var(--gray-300);
    }

    .mt-ccm-dialog__close:disabled {
        opacity: .5;
        cursor: default;
    }

    .mt-ccm-dialog__close:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

.mt-ccm-hint {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: var(--gray-600);
    margin: 0;
}

.mt-ccm-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mt-ccm-label {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-dark-color);
}

.mt-ccm-label__optional {
    font-weight: 500;
    color: var(--gray-600);
}

.mt-ccm-input,
.mt-ccm-textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--gray-300);
    background: #FFFFFF;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 15px;
    line-height: 20px;
    color: var(--text-dark-color);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.mt-ccm-input {
    height: 48px;
}

.mt-ccm-textarea {
    min-height: 88px;
    resize: vertical;
}

    .mt-ccm-input::placeholder,
    .mt-ccm-textarea::placeholder {
        color: var(--gray-500);
    }

    .mt-ccm-input:focus,
    .mt-ccm-textarea:focus {
        border-color: var(--blue-color);
        box-shadow: 0 0 0 3px rgba(75, 159, 255, .15);
    }

    .mt-ccm-input:disabled,
    .mt-ccm-textarea:disabled {
        background: var(--gray-200);
        color: var(--gray-600);
    }

.mt-ccm-counter {
    align-self: flex-end;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 12px;
    line-height: 16px;
    color: var(--gray-600);
}

.mt-ccm-error {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: #A32D2D;
    margin: 0;
}

.mt-ccm-dialog__foot {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.mt-ccm-cancel,
.mt-ccm-submit {
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    line-height: 20px;
    white-space: nowrap;
    transition: background-color .15s ease, filter .15s ease;
}

.mt-ccm-cancel {
    border: 1px solid var(--gray-300);
    background: #FFFFFF;
    color: var(--text-dark-color);
}

    .mt-ccm-cancel:hover:not(:disabled) {
        background: var(--gray-200);
    }

.mt-ccm-submit {
    border: none;
    /* Same AA-safe blue as the header action. */
    background: var(--blue-800);
    color: #FFFFFF;
}

    .mt-ccm-submit:hover:not(:disabled) {
        filter: brightness(1.08);
    }

    .mt-ccm-cancel:disabled,
    .mt-ccm-submit:disabled {
        opacity: .55;
        cursor: default;
    }

    .mt-ccm-cancel:focus-visible,
    .mt-ccm-submit:focus-visible {
        outline: 2px solid var(--text-dark-color);
        outline-offset: 2px;
    }

/* ---------- "Добавить в коллекцию" modal ---------- */
/* Shares the shell of the creation modal above; the body is a scrollable list of collection rows,
   each a real toggle button. Selection is shown by a tick glyph plus a filled box, never by colour
   alone, and the row keeps its own busy spinner so one failed toggle cannot be mistaken for another. */

.mt-atc-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 57, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}

.mt-atc-dialog {
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    padding: 20px;
    border-radius: 20px;
    background: #FFFFFF;
    box-shadow: 0 18px 48px rgba(22, 30, 57, .28);
    overflow: hidden;
}

.mt-atc-dialog__head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mt-atc-dialog__title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 18px;
    line-height: 1.25;
    color: var(--text-dark-color);
    margin: 0;
}

.mt-atc-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: var(--gray-200);
    color: var(--text-gray-dark-color);
    cursor: pointer;
}

    .mt-atc-dialog__close:hover:not(:disabled) {
        background: var(--gray-300);
    }

    .mt-atc-dialog__close:disabled {
        opacity: .5;
        cursor: default;
    }

    .mt-atc-dialog__close:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

.mt-atc-hint {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: var(--gray-600);
    margin: 0;
}

.mt-atc-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The loading placeholder is inert, so it never scrolls. */
.mt-atc-list--skeleton {
    overflow: hidden;
}

.mt-atc-list__item {
    display: block;
}

.mt-atc-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    min-height: 64px;
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: 14px;
    background: #FFFFFF;
    color: inherit;
    font: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

    .mt-atc-row:hover:not(:disabled) {
        background: var(--gray-200);
    }

    .mt-atc-row:focus-visible {
        outline: 2px solid var(--blue-color);
        outline-offset: 2px;
    }

    .mt-atc-row:disabled {
        cursor: default;
        opacity: .7;
    }

.mt-atc-row--selected {
    border-color: var(--blue-800);
    background: #F2F6FE;
}

    .mt-atc-row--selected:hover:not(:disabled) {
        background: #E8F0FD;
    }

/* Skeleton rows are inert placeholders, so they get no hover or pointer affordance. */
.mt-atc-row--skeleton {
    cursor: default;
}

.mt-atc-row__cover {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.mt-atc-row__cover--skeleton {
    display: block;
    background: var(--gray-300);
}

.mt-atc-row__info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.mt-atc-row__title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    line-height: 20px;
    color: var(--text-dark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.mt-atc-row__subtitle {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 16px;
    color: var(--gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Checkbox-shaped indicator: an empty outline when the test is not in the collection, a filled box
   with a tick when it is. */
.mt-atc-row__check {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 2px solid var(--gray-300);
    background: #FFFFFF;
    color: #FFFFFF;
}

.mt-atc-row--selected .mt-atc-row__check {
    border-color: var(--blue-800);
    background: var(--blue-800);
}

.mt-atc-row__spinner {
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    border-top-color: var(--blue-800);
    animation: mt-list-loader-spin .8s linear infinite;
}

.mt-atc-empty {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 0;
}

.mt-atc-empty__title {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    line-height: 20px;
    color: var(--text-dark-color);
    margin: 0;
}

.mt-atc-empty__sub {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: var(--gray-600);
    margin: 0;
}

.mt-atc-error {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 13px;
    line-height: 18px;
    color: #A32D2D;
    margin: 0;
}

.mt-atc-secondary {
    align-self: flex-start;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    background: #FFFFFF;
    color: var(--text-dark-color);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    line-height: 20px;
    transition: background-color .15s ease;
}

    .mt-atc-secondary:hover:not(:disabled) {
        background: var(--gray-200);
    }

    .mt-atc-secondary:disabled {
        opacity: .55;
        cursor: default;
    }

    .mt-atc-secondary:focus-visible {
        outline: 2px solid var(--text-dark-color);
        outline-offset: 2px;
    }

.mt-atc-dialog__foot {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.mt-atc-create,
.mt-atc-done {
    height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    line-height: 20px;
    white-space: nowrap;
    transition: background-color .15s ease, filter .15s ease;
}

.mt-atc-create {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--gray-300);
    background: #FFFFFF;
    color: var(--text-dark-color);
}

    .mt-atc-create:hover:not(:disabled) {
        background: var(--gray-200);
    }

.mt-atc-done {
    border: none;
    background: var(--blue-800);
    color: #FFFFFF;
}

    .mt-atc-done:hover:not(:disabled) {
        filter: brightness(1.08);
    }

    .mt-atc-create:disabled,
    .mt-atc-done:disabled {
        opacity: .55;
        cursor: default;
    }

    .mt-atc-create:focus-visible,
    .mt-atc-done:focus-visible {
        outline: 2px solid var(--text-dark-color);
        outline-offset: 2px;
    }

@media (min-width: 768px) {

    .mt-list-header--with-action {
        grid-template-areas: "back title search action";
        grid-template-columns: auto 1fr auto auto;
    }

    .mt-list-action {
        width: auto;
    }
}

/* ---------- Reduced motion ---------- */
/* Card lifts and the loader spinner are decorative; users who ask for less motion get neither. */
@media (prefers-reduced-motion: reduce) {

    .test-card-mini,
    .collection-card-mini,
    .collection-card-square,
    .mt-icon-action,
    .mt-tag,
    .mt-collection-publish__btn,
    .mt-list-search-input,
    .mt-list-action,
    .mt-ccm-input,
    .mt-ccm-textarea,
    .mt-ccm-cancel,
    .mt-ccm-submit,
    .mt-atc-row,
    .mt-atc-secondary,
    .mt-atc-create,
    .mt-atc-done {
        transition: none;
    }

    /* The row spinner is the only progress cue for a toggle, so it stays — just without the spin. */
    .mt-atc-row__spinner {
        animation: none;
    }

        .test-card-mini:hover,
        .collection-card-mini:hover,
        .collection-card-square:hover {
            transform: none;
        }

        .test-card-mini__metric--like:active:not(:disabled) {
            transform: none;
        }

    .mt-scroller {
        scroll-behavior: auto;
    }

    .mt-tag-row {
        scroll-behavior: auto;
    }

    .mt-list-loader::before {
        animation: none;
    }
}
