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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* 头部 */
.header {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
}

/* 主内容 */
.main-content {
    padding: 30px;
}

/* 标签页 */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #e8e8e8;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1em;
    color: #666;
    font-weight: 500;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #1976d2;
}

.tab-btn.active {
    color: #1976d2;
    border-bottom-color: #1976d2;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

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

textarea, select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus, select:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* 乱码模式提示 */
.pattern-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border: 1px solid #ffb74d;
    border-radius: 8px;
    margin-bottom: 20px;
}

.pattern-alert.hidden {
    display: none;
}

.alert-icon {
    font-size: 1.5em;
}

.alert-content {
    flex: 1;
}

.suggest-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #1976d2;
    color: white;
    border-radius: 4px;
    font-size: 0.85em;
    margin-left: 8px;
}

/* 按钮 */
.button-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(25, 118, 210, 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f0;
    color: #666;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-copy, .btn-select {
    padding: 6px 12px;
    font-size: 0.85em;
    background: #f0f0f0;
    color: #666;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-copy:hover, .btn-select:hover {
    background: #1976d2;
    color: white;
}

.btn-select.selected {
    background: #4caf50;
    color: white;
}

.btn-toggle {
    padding: 6px 16px;
    font-size: 0.85em;
    background: transparent;
    color: #1976d2;
    border: 1px solid #1976d2;
    border-radius: 6px;
    cursor: pointer;
}

.btn-toggle:hover {
    background: #1976d2;
    color: white;
}

/* 最佳匹配 */
.best-match {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #1976d2;
    border-radius: 12px;
}

.best-match.hidden {
    display: none;
}

.best-match-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.best-badge {
    padding: 4px 12px;
    background: #1976d2;
    color: white;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.best-encoding {
    font-size: 1.2em;
    font-weight: 700;
    color: #1565c0;
}

.best-score {
    padding: 4px 10px;
    background: rgba(25, 118, 210, 0.15);
    color: #1565c0;
    border-radius: 6px;
    font-size: 0.85em;
}

.best-match-content {
    position: relative;
}

.best-match-content textarea {
    background: white;
    border: 1px solid #90caf9;
}

.btn-copy-best {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn-copy-best:hover {
    background: #1565c0;
}

/* 结果区域 */
.result {
    margin-top: 20px;
    padding: 20px;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
}

.result.hidden {
    display: none;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.result-header h3 {
    color: #333;
    font-size: 1.1em;
}

.result-list {
    display: grid;
    gap: 12px;
}

.result-list.collapsed {
    max-height: 300px;
    overflow: hidden;
    position: relative;
}

.result-list.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, #fafafa);
    pointer-events: none;
}

.encoding-result-item {
    padding: 15px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    transition: all 0.3s;
}

.encoding-result-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.encoding-result-item.likely {
    border-left: 4px solid #4caf50;
}

.result-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.result-item-header h4 {
    margin: 0;
    color: #333;
    font-weight: 600;
    min-width: 100px;
}

.score-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
}

.score-badge.high {
    background: #e8f5e9;
    color: #2e7d32;
}

.score-badge.medium {
    background: #fff3e0;
    color: #f57c00;
}

.score-badge.low {
    background: #ffebee;
    color: #c62828;
}

.result-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    background: #f9f9f9;
    resize: none;
}

/* 文件上传 */
.file-upload {
    margin-bottom: 15px;
}

#fileInput {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border: 2px dashed #1976d2;
    border-radius: 12px;
    background: #f8faff;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.file-label:hover, .file-label.dragover {
    background: #e3f2fd;
    border-color: #1565c0;
}

.file-label span {
    margin-top: 15px;
    font-weight: 600;
    color: #1976d2;
}

.file-label small {
    margin-top: 8px;
    color: #999;
    font-size: 0.85em;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #e3f2fd;
    border-radius: 8px;
    margin-bottom: 15px;
}

.file-info.hidden {
    display: none;
}

.file-icon {
    font-size: 1.5em;
}

#fileName {
    flex: 1;
    font-weight: 500;
}

#fileSize {
    color: #666;
    font-size: 0.9em;
}

.btn-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: #ef5350;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
}

/* 下载区域 */
.download-section {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.download-section label {
    font-weight: 500;
}

.download-section select {
    width: auto;
    min-width: 150px;
}

/* 友情链接 */
.friendlinks {
    padding: 30px;
    background: #fafafa;
    border-top: 1px solid #e8e8e8;
}

.friendlinks h3 {
    text-align: center;
    color: #1976d2;
    font-size: 1.2em;
    margin-bottom: 20px;
}

.links-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.link-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
}

.link-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15);
    border-color: #1976d2;
}

.link-name {
    font-weight: 600;
    color: #1976d2;
    margin-bottom: 5px;
}

.link-desc {
    font-size: 0.85em;
    color: #999;
}

/* 底部 */
.footer {
    padding: 20px 30px;
    text-align: center;
    color: #999;
    font-size: 0.9em;
    background: #fafafa;
    border-top: 1px solid #e8e8e8;
}

/* 加载动画 */
#loadingSpinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#loadingSpinner.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loadingSpinner p {
    color: white;
    margin-top: 15px;
    font-size: 1.1em;
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 350px;
    animation: slideIn 0.3s ease;
    z-index: 2000;
}

.notification.hidden {
    display: none;
}

.notification.success {
    border-left: 4px solid #4caf50;
    color: #2e7d32;
}

.notification.error {
    border-left: 4px solid #f44336;
    color: #c62828;
}

.notification.info {
    border-left: 4px solid #1976d2;
    color: #1976d2;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 响应式 */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 30px 20px;
    }
    
    .header h1 {
        font-size: 1.6em;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .best-match-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .download-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .download-section select {
        width: 100%;
    }
    
    .result-item-header {
        flex-wrap: wrap;
    }
}
