/* Shared choice filters keep multiple selections in a compact top-layer menu. */
.choice-filter-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 31px;
    padding: 5px 48px 5px 8px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--text-emphasis) 15%, transparent);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 11.5px;
    font-weight: 500;
    text-align: left;
    box-shadow: none;
    transform: none;
    cursor: pointer;
}

/* Choice filters own their arrow so compact table controls can tune it independently. */
.choice-filter-trigger::before {
    position: absolute;
    top: 22%;
    right: 39px;
    bottom: 22%;
    width: 1px;
    background: var(--border);
    content: "";
}

.choice-filter-trigger::after {
    position: absolute;
    top: 50%;
    right: 13px;
    width: 12px;
    height: 8px;
    background: var(--select-arrow) center / contain no-repeat;
    content: "";
    transform: translateY(-50%);
}

/* Narrow table filters reserve less space and place the divider nearer the arrow. */
.column-filters .choice-filter-trigger {
    padding-right: 40px;
}

.column-filters .choice-filter-trigger::before {
    right: 31px;
}

.column-filters .choice-filter-trigger::after {
    right: 9px;
    width: 9px;
    height: 6px;
}

.choice-filter-trigger > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.choice-filter-trigger.is-active {
    border-color: var(--selected-border);
    background: var(--hover-surface);
    color: var(--link);
}

.choice-filter-trigger:hover {
    border-color: var(--focus);
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    transform: none;
}

.choice-filter-trigger.is-active:hover {
    background: var(--hover-surface);
    color: var(--link);
}

.choice-filter-trigger:focus-visible {
    border-color: var(--focus);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 14%, transparent);
}

.choice-filter-popover {
    position: fixed;
    inset: unset;
    box-sizing: border-box;
    width: max-content;
    min-width: 200px;
    max-width: min(340px, calc(100vw - 24px));
    margin: 0;
    padding: 10px 12px 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--shadow-ink) 20%, transparent);
    text-align: left;
    text-transform: none;
}

/* The reset action needs its own outline now that the repeated heading is gone. */
.choice-filter-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: calc(100% - 20px);
    max-width: 240px;
    min-height: 27px;
    margin: 0 auto 6px;
    padding: 3px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.2;
    box-shadow: none;
    transition: border-color .15s ease, background .15s ease;
    cursor: pointer;
}

.choice-filter-popover > .choice-filter-clear:hover {
    border-color: var(--focus);
    background: var(--hover-surface);
    color: var(--text);
    box-shadow: none;
    transform: none;
}

.choice-filter-popover > .choice-filter-clear:focus-visible {
    outline: 2px solid var(--selected-border);
    outline-offset: 1px;
}

.choice-filter-options label:hover {
    background: var(--hover-surface);
}

/* The unframed option list scrolls independently at the popover's outside edge. */
.choice-filter-options {
    max-height: min(280px, calc(100vh - 160px));
    margin-inline: -12px;
    padding: 4px 0 4px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: var(--text-subtle) transparent;
    scrollbar-width: thin;
}

.choice-filter-options::-webkit-scrollbar {
    width: 6px;
}

.choice-filter-options::-webkit-scrollbar-track {
    background: transparent;
}

.choice-filter-options::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--text-subtle);
}

.choice-filter-popover .choice-filter-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 4px 8px;
    border-radius: 5px;
    color: var(--text);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: normal;
    line-height: 1.3;
    text-align: left;
    text-transform: none;
    cursor: pointer;
}

.choice-filter-options input[type="radio"] {
    flex: 0 0 16px;
    width: 16px;
    min-width: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--primary);
}

/* Apply actions inherit central button styling; mobile width belongs to dialog-actions. */
.choice-filter-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 8px;
    padding-bottom: 12px;
}

.column-filters th.status-column .choice-filter-trigger > span:first-child {
    flex: 1;
    text-align: center;
}
