/* ==========================================================================
 * 历史必应筛选区：地区网格 + 年/月步进器
 * 仅 /list/detail.html 使用
 * ========================================================================== */
.af-panel {
    padding: 1rem 1.125rem 1.125rem;
    border-radius: 16px;
    background: var(--bg-body, #fff);
}

.af-heading {
    margin-bottom: .625rem;
    font-size: .8125rem;
    line-height: 1;
    color: #8a93a3;
}

.af-area-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: .625rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.af-area-grid li {
    margin: 0;
    min-width: 0;
}

.af-area-grid li a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: .375rem .5rem;
    border: 1px solid rgba(140, 150, 170, .28);
    border-radius: 12px;
    font-size: .875rem;
    font-weight: 500;
    color: inherit;
    text-decoration: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color .2s, background-color .2s, color .2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .af-area-grid li:not(.current) a:hover {
        border-color: rgba(37, 99, 235, .45);
        background: rgba(37, 99, 235, .06);
    }
}

.af-area-grid li a:active {
    transform: scale(.98);
}

.af-area-grid li.current a {
    border-color: #2563eb;
    color: #2563eb !important;
    background: rgba(37, 99, 235, .08);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
    font-weight: 600;
}

/* 年 / 月步进器 */
.af-steppers {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .875rem;
    padding: .5rem .75rem;
    border: 1px solid rgba(140, 150, 170, .22);
    border-radius: 12px;
    background: rgba(140, 150, 170, .06);
}

.af-stepper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.af-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6b7484;
    cursor: pointer;
    transition: background-color .2s, color .2s;
    -webkit-tap-highlight-color: transparent;
}

.af-step-btn::before {
    content: '';
    width: .4375rem;
    height: .4375rem;
    border-top: 1.5px solid currentColor;
    border-right: 1.5px solid currentColor;
}

.af-step-btn[data-step="-1"]::before {
    transform: rotate(-135deg);
    margin-left: .125rem;
}

.af-step-btn[data-step="1"]::before {
    transform: rotate(45deg);
    margin-right: .125rem;
}

@media (hover: hover) {
    .af-step-btn:not(:disabled):hover {
        background: rgba(140, 150, 170, .16);
        color: inherit;
    }
}

.af-step-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.af-step-value {
    min-width: 3.75rem;
    padding: .25rem .5rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: center;
    font-size: .9375rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .af-step-value:hover {
        background: rgba(140, 150, 170, .16);
    }
}

.af-step-value[aria-expanded="true"] {
    background: rgba(37, 99, 235, .1);
    color: #2563eb;
}

.af-lists {
    display: none;
}

/* 年 / 月完整选择面板 */
.af-pop {
    position: absolute;
    z-index: 30;
    top: calc(100% + .5rem);
    left: 0;
    min-width: 15rem;
    padding: .75rem;
    border: 1px solid rgba(140, 150, 170, .22);
    border-radius: 14px;
    background: var(--bg-body, #fff);
    box-shadow: 0 18px 40px -18px rgba(15, 23, 42, .45);
    animation: afPopIn .16s ease both;
}

.af-pop.af-pop-end {
    left: auto;
    right: 0;
}

.af-pop-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .375rem;
}

.af-pop[data-pop="year"] .af-pop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.af-pop-item {
    min-height: 2.25rem;
    padding: .25rem .5rem;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(140, 150, 170, .08);
    color: inherit;
    font-size: .8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .af-pop-item:hover {
        background: rgba(37, 99, 235, .1);
        color: #2563eb;
    }
}

.af-pop-item.is-current {
    border-color: #2563eb;
    background: rgba(37, 99, 235, .1);
    color: #2563eb;
    font-weight: 600;
}

/* 标题和遮罩只在手机的抽屉形态下出现 */
.af-pop-title,
.af-pop-mask {
    display: none;
}

@keyframes afPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 991.98px) {
    .af-area-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .af-panel {
        padding: .875rem;
    }

    .af-area-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: .5rem;
    }

    .af-area-grid li a {
        min-height: 2.5rem;
        font-size: .8125rem;
        border-radius: 10px;
    }

    .af-steppers {
        padding: .375rem .5rem;
    }

    .af-step-value {
        min-width: 3.25rem;
        font-size: .875rem;
    }

    /* 手机上改为底部抽屉，避免弹层贴边溢出 */
    .af-pop,
    .af-pop.af-pop-end {
        position: fixed;
        z-index: 1051;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        min-width: 0;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
        border-width: 1px 0 0;
        border-radius: 18px 18px 0 0;
        animation-name: afSheetIn;
    }

    .af-pop-title {
        display: block;
        margin-bottom: .75rem;
        font-size: .8125rem;
        color: #8a93a3;
        text-align: center;
    }

    .af-pop-item {
        min-height: 2.75rem;
        font-size: .875rem;
    }

    .af-pop-mask {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(15, 23, 42, .45);
        animation: afPopFade .16s ease both;
    }
}

@keyframes afSheetIn {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: none; }
}

@keyframes afPopFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 暗色模式 */
.nice-dark-mode .af-area-grid li a {
    border-color: rgba(255, 255, 255, .14);
}

@media (hover: hover) {
    .nice-dark-mode .af-area-grid li:not(.current) a:hover {
        border-color: rgba(96, 165, 250, .5);
        background: rgba(96, 165, 250, .08);
    }
}

.nice-dark-mode .af-area-grid li.current a {
    border-color: #3b82f6;
    color: #93c5fd !important;
    background: rgba(59, 130, 246, .14);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}

.nice-dark-mode .af-steppers {
    border-color: rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .04);
}

.nice-dark-mode .af-step-btn {
    color: #9aa4b5;
}

.nice-dark-mode .af-step-value[aria-expanded="true"] {
    background: rgba(59, 130, 246, .18);
    color: #93c5fd;
}

.nice-dark-mode .af-pop {
    border-color: rgba(255, 255, 255, .1);
    box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .8);
}

.nice-dark-mode .af-pop-item {
    background: rgba(255, 255, 255, .06);
}

.nice-dark-mode .af-pop-item.is-current {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, .18);
    color: #93c5fd;
}

@media (hover: hover) {
    .nice-dark-mode .af-step-value:hover {
        background: rgba(255, 255, 255, .1);
    }

    .nice-dark-mode .af-pop-item:hover {
        background: rgba(59, 130, 246, .16);
        color: #bfdbfe;
    }
}

@media (hover: hover) {
    .nice-dark-mode .af-step-btn:not(:disabled):hover {
        background: rgba(255, 255, 255, .1);
        color: #fff;
    }
}
