.filters {
    --overlap: 48px;
    --home: 44px;
    --thread-radius: 16px;
    position: relative;
    margin-top: calc(var(--overlap) * -1);
}

.filters .station-title {
    --thread-inset: 20px;
}

.filters-stage {
    justify-content: flex-start;
    padding-top: calc(var(--bar) + 12px);
    overflow-anchor: none;
}

.filters-body {
    width: 100%;
    max-width: var(--column);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.filters-stack {
    --thread-left: 20px;
    --thread-right: 2px;
    --rung: 8px;
    flex-grow: 1;
    margin: 0;
    padding: 0 24px 16px var(--home);
    list-style: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--rung);
}

.filters-stack::before {
    content: "";
    margin-bottom: calc(var(--rung) * -1);
}

.filters-item {
    --thread-pass: across;
    --thread-inset: 50%;
    --thread-trim: -6px;
    --on: min(1, var(--passing) * 1000);
    --done: clamp(0, (var(--passing) - 0.999) * 1000, 1);
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    width: 76%;
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1.5px dashed color-mix(in srgb, var(--pending) calc((1 - var(--on)) * 100%), transparent);
    border-radius: 6px;
    outline: 1.5px solid color-mix(in srgb, color-mix(in srgb, var(--fg) calc(var(--done) * 100%), var(--accent)) calc(var(--on) * 100%), transparent);
    outline-offset: -1.5px;
    background: var(--panel);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) calc((var(--on) - var(--done)) * 18%), transparent);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    color: color-mix(in srgb, var(--fg) calc(var(--on) * 100%), var(--muted));
    transition: border-color .2s, outline-color .2s, color .2s, box-shadow .2s;
}

.filters-item:nth-child(2) {
    --thread-dir: rtl;
    width: 88%;
}

.filters-item:nth-child(3) {
    width: 100%;
}

.filters-log {
    position: relative;
    z-index: 2;
    margin: 0 0 0 var(--home);
    overflow: hidden;
    border: 2px solid var(--fg);
    border-radius: 6px;
    background: var(--panel);
    font-family: var(--font-body);
    font-size: 12px;
}

.filters-log p {
    margin: 0;
}

.log-head {
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: var(--item-bg);
    font-weight: 600;
    font-size: 11px;
    line-height: 28px;
}

.log-head span {
    display: inline-block;
    box-shadow: inset 0 -2px var(--accent);
}

.log-line {
    padding: 0 12px;
    line-height: 20px;
    white-space: nowrap;
    color: var(--body);
}

.log-line:nth-child(2) {
    padding-top: 8px;
}

.log-line:last-child {
    padding-bottom: 8px;
}

.log-type {
    --caret: 7px;
    --done: clamp(0, (var(--type) - 0.999) * 1000, 1);
    position: relative;
    display: inline-block;
    vertical-align: top;
}

.log-type::after {
    content: "";
    position: absolute;
    inset: 0 0 0 round(down, var(--type) * 100%, 1ch);
    border-left: calc(min(1, var(--type) * 1000) * var(--caret)) solid var(--accent);
    background: var(--panel);
    opacity: calc(1 - var(--done));
    animation: log-caret .5s step-end infinite;
}

.log-line .log-type:first-child {
    --type: clamp(0, var(--passing) * 2, 1);
}

.log-ok .log-type:first-child {
    --type: var(--passing);
}

.log-result {
    --type: clamp(0, var(--passing) * 2 - 1, 1);
    display: block;
    width: max-content;
    margin-left: calc(var(--lead, 0) * 1ch);
    color: var(--muted);
}

.log-line b {
    font-weight: 600;
    color: var(--accent-ink);
}

.log-ok b {
    color: var(--fg);
}

@keyframes log-caret {
    50% {
        border-left-color: transparent;
    }
}

.filters-finish {
    width: 100%;
    max-width: var(--column);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 0 28px var(--home);
}

.filters-board {
    --thread-corner: 3;
    --thread-approach: side;
    --thread-exit: down;
    --thread-tie: 8px;
    --lift-x: -6;
    --lift-y: 7;
    --lift-rotate: -6;
}

@media (max-height: 700px) {
    .filters {
        --overlap: 40px;
    }

    .filters-stage {
        gap: 12px;
        padding-bottom: 12px;
    }

    .filters-body {
        gap: 12px;
    }

    .filters-stack {
        --rung: 5px;
        padding-bottom: 26px;
    }

    .filters-item {
        height: 26px;
        font-size: 12px;
    }

    .log-head {
        line-height: 24px;
    }

    .log-line {
        line-height: 18px;
    }

    .log-line:nth-child(2) {
        padding-top: 5px;
    }

    .log-line:last-child {
        padding-bottom: 6px;
    }

    .filters-finish {
        padding: 4px 0 16px var(--home);
    }
}

@media (min-width: 1200px) {
    .filters {
        --overlap: 0px;
        --thread-axis: center;
    }

    .filters-stage {
        padding-top: calc(var(--bar) + 15px);
        padding-bottom: 24px;
    }

    .filters-body {
        max-width: 960px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto repeat(3, 1fr) auto;
        gap: 0 48px;
    }

    .filters-stack {
        grid-column: 1;
        grid-row: 2 / span 3;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: subgrid;
        justify-items: end;
        align-items: center;
        gap: 0;
        padding: 0 0 0 96px;
        --thread-left: 74px;
        --thread-right: -24px;
    }

    .filters-stack::before {
        content: none;
    }

    .filters-item {
        --thread-dir: rtl;
        width: 80%;
        height: 40px;
        padding: 0 16px;
        font-size: 15px;
    }

    .filters-item:nth-child(2) {
        --thread-dir: ltr;
        width: 90%;
    }

    .filters-log {
        grid-column: 2;
        grid-row: 1 / -1;
        display: grid;
        grid-template-rows: subgrid;
        margin: 0;
        font-size: 14px;
    }

    .log-head {
        padding: 0 16px;
        font-size: 12px;
        line-height: 34px;
    }

    .log-line {
        display: flex;
        align-items: center;
        padding: 0 16px;
        border-top: 1px solid var(--line);
        line-height: 24px;
    }

    .log-line:nth-child(2) {
        padding-top: 0;
        border-top: 0;
    }

    .log-line:last-child {
        padding: 10px 16px;
    }

    .log-result {
        margin-left: 1ch;
    }

    .log-type {
        --caret: 8px;
    }

    .filters-finish {
        max-width: 960px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 48px;
        padding: 20px 0 8px;
    }

    .filters-board {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (min-width: 1200px) and (max-height: 820px) {
    .filters-stage {
        gap: 16px;
    }

    .filters-item {
        height: 34px;
    }

    .filters-finish {
        padding: 12px 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .filters-item {
        transition: none;
    }

    .log-type::after {
        animation: none;
    }
}
