body {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* 暗色主题样式 */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #ffffff;
    --border-color: #444;
    --header-bg: #3d3d3d;
    --input-bg: #333;
    --input-border: #555;
    --button-bg: #4CAF50;
    --button-hover: #45a049;
    --button-disabled: #555;
    --notification-bg: #2d442d;
    --notification-border: #3c763d;
    --notification-text: #a9d9aa;
    --error-bg: #442d2d;
    --error-border: #763c3c;
    --error-text: #f2a8a8;
    --ip-option-hover: #3a3a3a;
    --selected-ip-bg: #3a3a3a;
    --country-header-bg: #3d3d3d;
    --ip-border: #444;
}

[data-theme="dark"] body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

[data-theme="dark"] .container {
    background-color: var(--container-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] h1 {
    color: var(--text-color);
}

[data-theme="dark"] .filter-input {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-color);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="%23ccc" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
}

[data-theme="dark"] .filter-input:focus {
    border-color: var(--button-bg);
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

[data-theme="dark"] select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-color);
}

[data-theme="dark"] .ip-display {
    background-color: var(--selected-ip-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .ip-list-container {
    border-color: var(--border-color);
}

[data-theme="dark"] .no-results {
    color: #aaa;
}

[data-theme="dark"] .country-header {
    background-color: var(--country-header-bg);
    color: var(--text-color);
}

[data-theme="dark"] .ip-option {
    color: var(--text-color);
    border-bottom-color: var(--ip-border);
}

[data-theme="dark"] .ip-option:hover {
    background-color: var(--ip-option-hover);
}

[data-theme="dark"] .notification {
    background-color: var(--notification-bg);
    border-color: var(--notification-border);
    color: var(--notification-text);
}

[data-theme="dark"] .error {
    background-color: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative; /* 为按钮定位 */
}

h1 {
    color: #333;
    text-align: center;
}

.controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 4px;
}

button:hover {
    background-color: #45a049;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 主题切换按钮样式 */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 1px solid #ddd;
    font-size: 18px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
}

[data-theme="dark"] .theme-toggle {
    border-color: #555;
    color: #fff;
}

.filter-container {
    margin-bottom: 20px;
}

.filter-input {
    width: 100%;
    padding: 12px 20px;
    box-sizing: border-box;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="%23999" d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 20px 20px;
    padding-left: 40px;
    transition: border-color 0.3s;
}

.filter-input:focus {
    border-color: #4CAF50;
    outline: none;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

select {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.ip-display {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    font-size: 18px;
    text-align: center;
    margin-bottom: 20px;
    word-break: break-all;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.country-group {
    margin-bottom: 10px;
}

.country-header {
    font-weight: bold;
    background-color: #e9e9e9;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
}

.country-ips {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.country-expanded .country-ips {
    max-height: 1000px;
    transition: max-height 0.5s ease-in;
}

.ip-option {
    display: block;
    padding: 8px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    color: #333;
}

.ip-option:hover {
    background-color: #f0f0f0;
}

.ip-list-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.notification {
    padding: 10px;
    background-color: #dff0d8;
    border: 1px solid #d6e9c6;
    color: #3c763d;
    border-radius: 4px;
    margin-bottom: 20px;
    display: none;
}

.loading {
    text-align: center;
    padding: 20px;
}

.error {
    background-color: #f2dede;
    border-color: #ebccd1;
    color: #a94442;
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }
    
    .container {
        padding: 15px;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    h1 {
        font-size: 20px;
        margin-top: 10px;
        margin-bottom: 20px;
    }
    
    .theme-toggle {
        position: fixed;
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 16px;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.9);
    }
    
    [data-theme="dark"] .theme-toggle {
        background: rgba(45, 45, 45, 0.9);
    }
    
    .controls {
        flex-direction: column;
        gap: 8px;
    }
    
    button {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        margin: 2px 0;
    }
    
    .filter-input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 14px 16px 14px 40px;
    }
    
    .ip-display {
        font-size: 16px;
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .ip-list-container {
        max-height: 300px;
        margin-bottom: 15px;
    }
    
    .country-header {
        padding: 10px;
        font-size: 15px;
    }
    
    .ip-option {
        padding: 10px;
        font-size: 14px;
    }
    
    .notification {
        font-size: 14px;
        padding: 8px;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 12px;
    }
    
    h1 {
        font-size: 18px;
        margin: 5px 0 15px 0;
    }
    
    .theme-toggle {
        top: 5px;
        right: 5px;
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .filter-input {
        padding: 12px 14px 12px 40px;
    }
    
    .ip-display {
        font-size: 15px;
        padding: 10px;
    }
}

/* 防止移动端点击延迟 */
button, .ip-option, .country-header {
    touch-action: manipulation;
}

/* 优化移动端滚动体验 */
.ip-list-container {
    -webkit-overflow-scrolling: touch;
}

/* 优化移动端输入框 */
.filter-input {
    -webkit-appearance: none;
    appearance: none;
}

/* 防止长按菜单 */
.ip-option, button {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}
