* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

.section {
    padding: 30px;
    border-bottom: 1px solid #eee;
}

.section:last-child {
    border-bottom: none;
}

.section h2 {
    color: #667eea;
    font-size: 1.3rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.section h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: #667eea;
    margin-right: 10px;
    border-radius: 2px;
}

/* 上传区域 */
.upload-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.file-upload {
    text-align: center;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    background: #f8f9fa;
    border: 2px dashed #667eea;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.file-label:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.file-label:active {
    transform: scale(0.98);
}

.upload-icon {
    font-size: 1.5rem;
}

.file-name {
    margin-top: 10px;
    color: #28a745;
    font-size: 0.9rem;
}

.divider {
    text-align: center;
    color: #999;
    position: relative;
    font-size: 0.9rem;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #ddd;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.text-input textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.text-input textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* 按钮样式 */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-appearance: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:active {
    transform: scale(0.98);
}

.btn:active:disabled {
    transform: none;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: scale(0.98) translateY(0);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.btn-success:active {
    transform: scale(0.98) translateY(0);
}

/* 分隔符选项 */
.delimiter-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.radio-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.radio-option:active {
    transform: scale(0.99);
}

.radio-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-option input[type="text"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    width: 200px;
}

.radio-option input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* 数据预览 */
.data-preview {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.preview-info {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.preview-items {
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.preview-item {
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    font-size: 0.85rem;
    border-left: 3px solid #28a745;
}

/* 搜索区域 */
.search-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-area textarea {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.search-area textarea:focus {
    outline: none;
    border-color: #28a745;
}

/* 搜索结果 */
.search-results {
    margin-top: 20px;
}

.result-header {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 500;
}

.result-header.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.result-header.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.result-item {
    padding: 15px;
    margin: 10px 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #28a745;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.result-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #667eea;
    font-weight: 500;
}

.result-item-content {
    color: #333;
    line-height: 1.6;
    word-wrap: break-word;
}

.highlight {
    background: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

/* 关键词分组 */
.keyword-group {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9ff;
    border-radius: 10px;
    border: 1px solid #e0e7ff;
}

.keyword-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 500;
}

.keyword-header.not-found {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.keyword-text {
    font-size: 1rem;
}

.keyword-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.keyword-group .result-item {
    margin-left: 0;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 10px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .section {
        padding: 20px 15px;
    }

    .section h2 {
        font-size: 1.15rem;
    }

    /* 优化上传区域 */
    .file-label {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    /* 优化文本输入 */
    .text-input textarea {
        min-height: 120px;
        font-size: 0.95rem;
    }

    .search-area textarea {
        min-height: 100px;
        font-size: 0.95rem;
    }

    /* 优化单选选项 */
    .radio-option {
        padding: 10px;
        font-size: 0.9rem;
    }

    .radio-option input[type="text"] {
        width: 150px;
        font-size: 0.85rem;
    }

    /* 优化关键词分组 */
    .keyword-group {
        padding: 12px;
        margin: 15px 0;
    }

    .keyword-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .keyword-text {
        font-size: 0.9rem;
        word-break: break-all;
    }

    .keyword-count {
        align-self: flex-end;
    }

    /* 优化搜索结果 */
    .result-item {
        padding: 12px;
        margin: 8px 0;
    }

    .result-item-header {
        font-size: 0.85rem;
        flex-wrap: wrap;
        gap: 5px;
    }

    .result-item-content {
        font-size: 0.9rem;
        line-height: 1.7;
    }

    /* 优化预览 */
    .preview-item {
        font-size: 0.8rem;
        padding: 6px;
    }
}

@media screen and (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        border-radius: 8px;
    }

    .header {
        padding: 15px 10px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .section {
        padding: 15px 10px;
    }

    .section h2 {
        font-size: 1rem;
    }

    .section h2::before {
        width: 3px;
        height: 16px;
    }

    /* 按钮优化 */
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
        touch-action: manipulation;
    }

    /* 上传区域 */
    .file-label {
        width: 100%;
        padding: 15px 20px;
        font-size: 1rem;
        box-sizing: border-box;
    }

    .upload-icon {
        font-size: 1.8rem;
    }

    .file-name {
        font-size: 0.85rem;
    }

    /* 文本输入 */
    .text-input textarea,
    .search-area textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 12px;
        min-height: 100px;
    }

    /* 单选选项 */
    .radio-option {
        flex-wrap: wrap;
        padding: 12px 10px;
        font-size: 0.9rem;
    }

    .radio-option input[type="radio"] {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .radio-option input[type="text"] {
        width: 100%;
        margin-top: 8px;
        padding: 10px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    /* 数据预览 */
    .data-preview {
        padding: 12px;
        margin-top: 15px;
    }

    .preview-info {
        font-size: 0.85rem;
    }

    .preview-items {
        max-height: 150px;
    }

    .preview-item {
        font-size: 0.75rem;
        padding: 6px;
    }

    /* 搜索结果 */
    .result-header {
        padding: 12px;
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    /* 关键词分组 */
    .keyword-group {
        padding: 10px;
        margin: 12px 0;
    }

    .keyword-header {
        padding: 10px;
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .keyword-text {
        font-size: 0.85rem;
        word-break: break-all;
        line-height: 1.4;
    }

    .keyword-count {
        align-self: flex-end;
        font-size: 0.75rem;
        padding: 3px 10px;
    }

    /* 搜索结果项 */
    .result-item {
        padding: 10px;
        margin: 8px 0;
    }

    .result-item-header {
        font-size: 0.8rem;
        flex-wrap: wrap;
        gap: 8px;
    }

    .result-item-content {
        font-size: 0.85rem;
        line-height: 1.6;
    }

    .highlight {
        padding: 1px 3px;
        font-size: 0.85rem;
    }

    /* 分隔符 */
    .divider {
        font-size: 0.85rem;
        margin: 15px 0;
    }
}

/* 超小屏幕优化 */
@media screen and (max-width: 360px) {
    .header h1 {
        font-size: 1.1rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .section h2 {
        font-size: 0.95rem;
    }

    .btn {
        padding: 12px 15px;
        font-size: 0.95rem;
    }

    .keyword-text {
        font-size: 0.8rem;
    }

    .result-item-content {
        font-size: 0.8rem;
    }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    .header {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .subtitle {
        display: none;
    }

    .section {
        padding: 10px;
    }

    .section h2 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .text-input textarea,
    .search-area textarea {
        min-height: 80px;
    }

    .data-preview,
    .preview-items {
        max-height: 100px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
