/* * 1. 悬浮定位容器 (PX)
    * 使用 fixed 定位将其固定在左下角
    */
:root {
    --primary-color: #3b82f6;
    --bg-color: #ffffff;
    --text-color: #fff;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}
#translate-widget-container {
    position: fixed;
    bottom: 110px;  /* 距离底部 32px */
    left: 32px;    /* 距离左侧 32px */
    z-index: 9999; /* 确保在最上层 */
    
    /* 响应式调整：手机端稍微缩小边距 */
    @media (max-width: 640px) {
        bottom: 16px;
        left: 16px;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 宽度 (PX) */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 240px; 
    max-width: 80vw;
    
}
/*.custom-select {background:linear-gradient(121.59deg, #17BD6A 0%, #3597F2 100%);}*/

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
    height: 48px;
    background: var(--bg-color);background:linear-gradient(121.59deg, #17BD6A 0%, #3597F2 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.custom-select-trigger:hover {
    border-color: #b0b0b0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.arrow {
    transition: transform 0.3s ease;
    color: #888;
    font-size: 14px;
}

.custom-select.open .arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
}
/* * 2. 向上展开逻辑 (PX)
    */
.custom-options {
    position: absolute;
    display: block;
    bottom: 100%; 
    top: auto; 
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow: hidden;
    max-height: 50vh; 
}

.custom-options-scroll {
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #000 transparent;

    /* 关键：防止滚动穿透 */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; /* 增强 iOS 滑动流畅度 */
    
    /* 新增：确保触摸事件被正确处理 */
    touch-action: pan-y; /* 允许垂直滚动，阻止水平滚动 */
}

.custom-options-scroll::-webkit-scrollbar {
    width: 6px;
}

.custom-options-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-options-scroll::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

.custom-select.open .custom-options {
    opacity: 1; background:linear-gradient(121.59deg, #17BD6A 0%, #3597F2 100%);
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f9fafb;
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background-color: var(--hover-bg);
    color: var(--primary-color);
}

.custom-option.selected {
    background-color: #c6e8e2;
    color: var(--primary-color);
    font-weight: 600;
}

.option-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #fff;
    margin-right: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.custom-option:hover .option-dot,
.custom-option.selected .option-dot {
    background-color: var(--primary-color);
}

.globe-icon {
    margin-right: 8px;
    font-size: 18px;
    color: #6b7280;
}

.demo-bg-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ccc;
    font-size: 2rem;
    font-weight: bold;
    pointer-events: none;
    text-align: center;
}
/* 移动端滚动穿透修复 */
@media (max-width: 768px) {
    .menu-open {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    .custom-options-scroll {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }
}

#translate select {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
    height: 48px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}
#translate select option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f9fafb;
}