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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e8f2ff;
    transform: scale(1.02);
}

.upload-content h3 {
    margin: 15px 0 10px;
    color: #333;
    font-size: 1.3rem;
}

.upload-content p {
    color: #666;
    margin: 5px 0;
}

.upload-icon {
    color: #667eea;
    margin-bottom: 10px;
}

.preview-container {
    text-align: center;
    margin-top: 20px;
}

.preview-container img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

/* 文本输入区域 */
.text-section {
    margin-bottom: 30px;
}

.text-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.text-section label {
    font-weight: 600;
    color: #333;
    margin: 0;
}

.file-upload-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-file-upload {
    padding: 8px 16px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-file-upload:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.file-name {
    font-size: 12px;
    color: #28a745;
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-section textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
}

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

/* 控制面板 */
.controls-section {
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.control-group input[type="range"] {
    margin-bottom: 5px;
}

.control-group span {
    font-size: 14px;
    color: #666;
    text-align: center;
}

.control-group select {
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 颜色选择器样式 */
.color-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input-group input[type="color"] {
    width: 50px;
    height: 40px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    transition: border-color 0.3s ease;
}

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

.color-input-group span {
    font-family: monospace;
    font-size: 14px;
    color: #666;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
    min-width: 80px;
    text-align: center;
}

/* 按钮样式 */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e5e9;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #667eea;
}

/* 结果区域 */
.result-section {
    margin-top: 40px;
    text-align: center;
}

.result-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5rem;
}

.canvas-container {
    margin: 20px 0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: inline-block;
    background: white;
}

.canvas-container canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    main {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls-section {
        grid-template-columns: 1fr;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .result-actions button {
        width: 200px;
    }
}

/* 加载动画 */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 滑块样式 */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e5e9;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

/* 词频统计区域样式 */
.word-frequency-section {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #e1e5e9;
    text-align: left;
}

.word-frequency-section h4 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.2rem;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.frequency-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.frequency-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    transition: all 0.3s ease;
}

.frequency-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.frequency-rank {
    font-weight: bold;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

.frequency-word {
    flex: 1;
    margin: 0 15px;
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.frequency-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* 词频统计响应式设计 */
@media (max-width: 768px) {
    .frequency-list {
        grid-template-columns: 1fr;
    }
    
    .frequency-item {
        padding: 10px 12px;
    }
    
    .frequency-word {
        font-size: 14px;
        margin: 0 10px;
    }
    
    .frequency-count {
        font-size: 12px;
        padding: 3px 8px;
        min-width: 50px;
    }
}