:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.5rem;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

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

/* 导航栏样式 */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.brand-icon {
    width: 2rem;
    height: 2rem;
}

/* 标签页样式 */
.tabs-container {
    margin: 2rem 0;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-button {
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.875rem;
    border-bottom: 3px solid transparent;
    flex-shrink: 0;
}

.tab-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgb(79 70 229 / 0.05);
}

.tab-content {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* 工具网格 */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

label {
    font-weight: 600;
    color: var(--text-primary);
}

textarea,
input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--surface);
}

textarea:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
}

.code-output {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.875rem;
    min-height: 200px;
}

.diff-output {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 200px;
    font-family: monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}

.diff-added {
    background-color: #dcfce7;
    color: #166534;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

.diff-removed {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
    text-decoration: line-through;
}

.diff-changed {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

/* 按钮样式 */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #0891b2;
}

/* 输出显示 */
.output-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.result-value {
    font-family: monospace;
    color: var(--text-primary);
    background: var(--surface-hover);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

/* 测试工具样式 */
.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.test-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.test-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.test-display {
    margin: 1rem 0;
}

.test-area {
    background: var(--surface-hover);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin: 1rem 0;
}

.test-area:hover {
    border-color: var(--primary-color);
    background: rgb(79 70 229 / 0.05);
}

.test-area.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.screen-test-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.screen-test-area {
    width: 100%;
    height: 200px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* 全屏测试 */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    display: none;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.fullscreen-overlay.active {
    display: flex;
}

.screen-test-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.color-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    transition: background-color 0.3s ease;
}

.color-info {
    text-align: center;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    transition: opacity 0.3s ease;
}

.color-info span {
    display: block;
    margin: 0.5rem 0;
    transition: opacity 0.3s ease;
}

.exit-fullscreen {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10000;
    opacity: 1;
}

.exit-fullscreen:hover {
    background: rgba(255,255,255,0.3);
}

/* 键盘显示 */
.key-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-family: monospace;
}

#keyboard-log {
    height: 100px;
    resize: vertical;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }

    .tabs-header {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1;
        min-width: 120px;
        text-align: center;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .test-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }

    .tab-content {
        padding: 1rem;
    }

    .tab-button {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    .color-info {
        font-size: 1.5rem;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* 页脚 */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    margin-top: auto;
}