/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8f9fa;
    color: #333;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* 隐藏所有滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Chrome, Safari, Opera */
body::-webkit-scrollbar {
    display: none;
}

/* 容器 */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* 头部 */
.main-header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 20px;
    position: relative;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #495057;
    letter-spacing: 1px;
}

/* 主题切换按钮 */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: #6c757d;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
    transform: rotate(20deg);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

/* 搜索区域 */
.search-section {
    width: 100%;
    max-width: 600px;
}

.search-container {
    display: flex;
    background: white;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    margin-bottom: 20px;
}

.search-container:hover {
    box-shadow: 0 6px 25px rgba(0,0,0,0.15);
}

.search-input {
    flex: 1;
    padding: 16px 24px;
    border: none;
    font-size: 16px;
    outline: none;
    background: transparent;
    color: #333;
    min-height: 48px;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    padding: 0 24px;
    border: none;
    background: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
}

.search-btn:hover {
    background: #0069d9;
}

/* 搜索历史区域 */
.search-history {
    width: 100%;
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: none;
}

.search-history.show {
    display: block;
}

.history-title {
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
}

.history-item:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.history-item .delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 12px;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

/* 搜索引擎选择器 */
.engine-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    max-width: 600px;
    width: 100%;
}

.engine-btn {
    padding: 12px 20px;
    border: none;
    background: white;
    color: #495057;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 80px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.engine-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.engine-btn.active {
    background: #007bff;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* 底部 */
.main-footer {
    margin-top: auto;
    padding: 20px 0;
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    color: #6c757d;
    font-size: 14px;
}

.copyright,
.time {
    white-space: nowrap;
}

.time {
    font-weight: 600;
    color: #495057;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-header h1 {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .theme-toggle {
        top: 15px;
        right: 15px;
        padding: 10px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .search-container {
        border-radius: 30px;
        margin-bottom: 15px;
    }
    
    .search-input {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .search-btn {
        padding: 0 20px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .search-history {
        border-radius: 12px;
        padding: 12px;
        margin-top: 10px;
    }
    
    .history-item {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px;
    }
    
    .engine-selector {
        gap: 10px;
        flex-direction: column;
        align-items: center;
    }
    
    .engine-btn {
        padding: 12px 24px;
        font-size: 14px;
        border-radius: 22px;
        min-width: 120px;
        min-height: 48px;
        width: 100%;
        max-width: 200px;
    }
    
    .footer-content {
        gap: 15px;
        flex-direction: column;
    }
    
    .copyright,
    .time {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .main-header h1 {
        font-size: 1.6rem;
        margin-bottom: 25px;
    }
    
    .theme-toggle {
        top: 12px;
        right: 12px;
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .search-container {
        border-radius: 25px;
    }
    
    .search-input {
        padding: 12px 16px;
        font-size: 16px;
        min-height: 42px;
    }
    
    .search-btn {
        padding: 0 16px;
        min-width: 42px;
        min-height: 42px;
    }
    
    .search-history {
        border-radius: 10px;
        padding: 10px;
    }
    
    .history-item {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 32px;
    }
    
    .engine-btn {
        padding: 10px 20px;
        font-size: 13px;
        border-radius: 20px;
        min-width: 100px;
        min-height: 44px;
        width: 90%;
        max-width: 180px;
    }
    
    .footer-content {
        gap: 12px;
    }
    
    .copyright,
    .time {
        font-size: 12px;
    }
    
    /* 确保底部有足够的空间，避免被虚拟键盘遮挡 */
    .main-footer {
        padding: 15px 0;
    }
}

/* 超小屏幕优化 (320px及以下) */
@media (max-width: 320px) {
    .main-header h1 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .engine-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-height: 40px;
        width: 85%;
        max-width: 160px;
    }
    
    .history-item {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .footer-content {
        gap: 10px;
    }
    
    .copyright,
    .time {
        font-size: 11px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .engine-btn,
    .search-btn,
    .theme-toggle,
    .history-item {
        /* 增加触摸目标大小 */
        min-height: 48px;
        min-width: 48px;
    }
    
    .engine-btn {
        padding: 14px 26px;
    }
    
    /* 减少动画效果，提升性能 */
    .engine-btn,
    .search-btn,
    .theme-toggle {
        transition: none;
    }
    
    .engine-btn:hover,
    .search-btn:hover,
    .theme-toggle:hover {
        transform: none;
    }
}

/* 暗色模式 */
body.dark-mode {
    background: #212529;
    color: #e9ecef;
}

body.dark-mode .main-header h1 {
    color: #e9ecef;
}

body.dark-mode .search-input {
    color: #e9ecef;
    background: #343a40;
}

body.dark-mode .search-input::placeholder {
    color: #adb5bd;
}

body.dark-mode .search-btn {
    background: #0d6efd;
}

body.dark-mode .search-btn:hover {
    background: #0b5ed7;
}

body.dark-mode .search-history {
    background: #343a40;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border: 1px solid #495057;
}

body.dark-mode .history-title {
    color: #adb5bd;
    border-bottom-color: #495057;
}

body.dark-mode .history-item {
    background: #495057;
    border-color: #6c757d;
    color: #e9ecef;
}

body.dark-mode .history-item:hover {
    background: #0d6efd;
    border-color: #0d6efd;
}

body.dark-mode .engine-btn {
    background: #343a40;
    color: #e9ecef;
}

body.dark-mode .engine-btn:hover {
    background: #495057;
}

body.dark-mode .engine-btn.active {
    background: #0d6efd;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

body.dark-mode .footer-content {
    color: #adb5bd;
}

body.dark-mode .time {
    color: #e9ecef;
}

body.dark-mode .theme-toggle {
    color: #adb5bd;
}

body.dark-mode .theme-toggle:hover {
    background: rgba(13, 110, 253, 0.2);
    color: #0d6efd;
}